From f2f2e9325c5de61c6df9ac35a3f027f4c3121546 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Tue, 4 Nov 2025 09:59:46 +0100 Subject: [PATCH] Clean up defunct shaka-player types patching (#8224) --- _scripts/patchShaka.mjs | 57 +++-------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) diff --git a/_scripts/patchShaka.mjs b/_scripts/patchShaka.mjs index 36efecf86..27e95c968 100644 --- a/_scripts/patchShaka.mjs +++ b/_scripts/patchShaka.mjs @@ -1,60 +1,12 @@ -// This script fixes shaka not exporting its type definitions and referencing the Roboto font on google fonts in its CSS -// by adding an export line to the type definitions and updating the CSS to point to the local Roboto font +// This script fixes shaka-player referencing the Roboto font on google fonts in its CSS +// by updating the CSS to point to the local Roboto font // this script only makes changes if they are needed, so running it multiple times doesn't cause any problems -import { appendFileSync, closeSync, ftruncateSync, openSync, readFileSync, writeSync } from 'fs' +import { closeSync, ftruncateSync, openSync, readFileSync, writeSync } from 'fs' import { resolve } from 'path' const SHAKA_DIST_DIR = resolve(import.meta.dirname, '../node_modules/shaka-player/dist') -function fixTypes() { - let fixedTypes = false - - let fileHandleNormal - try { - fileHandleNormal = openSync(`${SHAKA_DIST_DIR}/shaka-player.ui.d.ts`, 'a+') - - const contents = readFileSync(fileHandleNormal, 'utf-8') - - // This script is run after every `yarn install`, even if shaka-player wasn't updated - // So we want to check first, if we actually need to make any changes - // or if the ones from the previous run are still intact - if (!contents.includes('export default shaka')) { - appendFileSync(fileHandleNormal, 'export default shaka;\n') - - fixedTypes = true - } - } finally { - if (typeof fileHandleNormal !== 'undefined') { - closeSync(fileHandleNormal) - } - } - - let fileHandleDebug - try { - fileHandleDebug = openSync(`${SHAKA_DIST_DIR}/shaka-player.ui.debug.d.ts`, 'a+') - - const contents = readFileSync(fileHandleDebug, 'utf-8') - - // This script is run after every `yarn install`, even if shaka-player wasn't updated - // So we want to check first, if we actually need to make any changes - // or if the ones from the previous run are still intact - if (!contents.includes('export default shaka')) { - appendFileSync(fileHandleDebug, 'export default shaka;\n') - - fixedTypes = true - } - } finally { - if (typeof fileHandleDebug !== 'undefined') { - closeSync(fileHandleDebug) - } - } - - if (fixedTypes) { - console.log('Fixed shaka-player types') - } -} - function removeRobotoFont() { let cssFileHandle try { @@ -72,11 +24,10 @@ function removeRobotoFont() { console.log('Removed shaka-player Roboto font, so it uses ours') } } finally { - if (typeof cssFileHandle !== 'undefined') { + if (cssFileHandle !== undefined) { closeSync(cssFileHandle) } } } -fixTypes() removeRobotoFont()