fix: babel evt-polyfill

fix: worker paths
fix: wasm paths
This commit is contained in:
ThaUnknown 2023-03-16 15:37:30 +01:00
parent 8848b75be0
commit a73b691653
4 changed files with 46 additions and 29 deletions

1
package-lock.json generated
View File

@ -25,6 +25,7 @@
"dompurify": "3.0.1",
"epubjs": "0.4.2",
"escape-html": "1.0.3",
"event-target-polyfill": "0.0.3",
"fast-text-encoding": "1.0.6",
"flv.js": "1.6.2",
"headroom.js": "0.12.0",

View File

@ -84,6 +84,7 @@
"dompurify": "3.0.1",
"epubjs": "0.4.2",
"escape-html": "1.0.3",
"event-target-polyfill": "0.0.3",
"fast-text-encoding": "1.0.6",
"flv.js": "1.6.2",
"headroom.js": "0.12.0",

View File

@ -1270,10 +1270,11 @@ function tryRemoveElement(elem) {
fonts: avaliableFonts,
fallbackFont: 'liberation sans',
availableFonts: {'liberation sans': `${appRouter.baseUrl()}/libraries/default.woff2`},
// Disabled eslint compat, but is safe as corejs3 polyfills URL
// eslint-disable-next-line compat/compat
workerUrl: `${appRouter.baseUrl()}/${new URL('jassub/dist/jassub-worker.js', import.meta.url)}`,
workerUrl: `${appRouter.baseUrl()}${new URL('jassub/dist/jassub-worker.js', import.meta.url).pathname}`,
// eslint-disable-next-line compat/compat
legacyWorkerUrl: `${appRouter.baseUrl()}/${new URL('jassub/dist/jassub-worker-legacy.js', import.meta.url)}`,
legacyWorkerUrl: `${appRouter.baseUrl()}${new URL('jassub/dist/jassub-worker-legacy.js', import.meta.url).pathname}`,
timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000,
// new jassub options; override all, even defaults
blendMode: 'js',
@ -1290,37 +1291,39 @@ function tryRemoveElement(elem) {
prescaleHeightLimit: 1080,
maxRenderHeight: 2160
};
import('jassub').then(({ default: JASSUB }) => {
Promise.all([
apiClient.getNamedConfiguration('encoding'),
// Worker in Tizen 5 doesn't resolve relative path with async request
resolveUrl(options.workerUrl),
resolveUrl(options.legacyWorkerUrl)
]).then(([config, workerUrl, legacyWorkerUrl]) => {
options.workerUrl = workerUrl;
options.legacyWorkerUrl = legacyWorkerUrl;
import('event-target-polyfill').then(() => {
import('jassub').then(({ default: JASSUB }) => {
Promise.all([
apiClient.getNamedConfiguration('encoding'),
// Worker in Tizen 5 doesn't resolve relative path with async request
resolveUrl(options.workerUrl),
resolveUrl(options.legacyWorkerUrl)
]).then(([config, workerUrl, legacyWorkerUrl]) => {
options.workerUrl = workerUrl;
options.legacyWorkerUrl = legacyWorkerUrl;
const cleanup = () => {
this.#currentJASSUB.destroy();
this.#currentJASSUB = null;
onErrorInternal(this, 'mediadecodeerror');
};
const cleanup = () => {
this.#currentJASSUB.destroy();
this.#currentJASSUB = null;
onErrorInternal(this, 'mediadecodeerror');
};
if (config.EnableFallbackFont) {
apiClient.getJSON(fallbackFontList).then((fontFiles = []) => {
fontFiles.forEach(font => {
const fontUrl = apiClient.getUrl(`/FallbackFont/Fonts/${font.Name}`, {
api_key: apiClient.accessToken()
if (config.EnableFallbackFont) {
apiClient.getJSON(fallbackFontList).then((fontFiles = []) => {
fontFiles.forEach(font => {
const fontUrl = apiClient.getUrl(`/FallbackFont/Fonts/${font.Name}`, {
api_key: apiClient.accessToken()
});
avaliableFonts.push(fontUrl);
});
avaliableFonts.push(fontUrl);
this.#currentJASSUB = new JASSUB(options);
this.#currentJASSUB.addEventListener('error', cleanup, { once: true });
});
} else {
this.#currentJASSUB = new JASSUB(options);
this.#currentJASSUB.addEventListener('error', cleanup, { once: true });
});
} else {
this.#currentJASSUB = new JASSUB(options);
this.#currentJASSUB.addEventListener('error', cleanup, { once: true });
}
}
});
});
});
}

View File

@ -8,10 +8,13 @@ const { DefinePlugin } = require('webpack');
const Assets = [
'native-promise-only/npo.js',
'libarchive.js/dist/worker-bundle.js',
'pdfjs-dist/build/pdf.worker.js'
];
const JassubWasm = [
'jassub/dist/jassub-worker.wasm',
'jassub/dist/jassub-worker-legacy.mem',
'jassub/dist/default.woff2',
'pdfjs-dist/build/pdf.worker.js'
'jassub/dist/default.woff2'
];
const LibarchiveWasm = [
@ -80,6 +83,14 @@ const config = {
to: path.resolve(__dirname, './dist/libraries/wasm-gen')
};
})
}),
new CopyPlugin({
patterns: JassubWasm.map(asset => {
return {
from: path.resolve(__dirname, `./node_modules/${asset}`),
to: path.resolve(__dirname, './dist')
};
})
})
],
output: {
@ -144,6 +155,7 @@ const config = {
{
test: /\.(js|jsx)$/,
include: [
path.resolve(__dirname, 'node_modules/event-target-polyfill'),
path.resolve(__dirname, 'node_modules/rvfc-polyfill'),
path.resolve(__dirname, 'node_modules/@jellyfin/sdk'),
path.resolve(__dirname, 'node_modules/@remix-run/router'),