mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 00:37:19 +00:00
Review by rreverser
This commit is contained in:
@@ -10,13 +10,16 @@ export function pathify(path: string): string {
|
|||||||
export function instantiateEmscriptenWasm<T extends EmscriptenWasm.Module>(
|
export function instantiateEmscriptenWasm<T extends EmscriptenWasm.Module>(
|
||||||
factory: EmscriptenWasm.ModuleFactory<T>,
|
factory: EmscriptenWasm.ModuleFactory<T>,
|
||||||
path: string,
|
path: string,
|
||||||
workerWasm: string = '',
|
workerJS: string = '',
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
return factory({
|
return factory({
|
||||||
locateFile(requestPath) {
|
locateFile(requestPath) {
|
||||||
|
// The glue code generated by emscripten uses the original
|
||||||
|
// file names of the worker file and the wasm binary.
|
||||||
|
// These will have changed in the bundling process and
|
||||||
|
// we need to inject them here.
|
||||||
if (requestPath.endsWith('.wasm')) return pathify(path);
|
if (requestPath.endsWith('.wasm')) return pathify(path);
|
||||||
if (requestPath.endsWith('.worker.js'))
|
if (requestPath.endsWith('.worker.js')) return new URL(workerJS).pathname;
|
||||||
return new URL(workerWasm).pathname;
|
|
||||||
return requestPath;
|
return requestPath;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user