From 60dacff05eb73cb336f6a62595f2ab7b8e4d5414 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Wed, 29 Apr 2020 15:41:02 +0100 Subject: [PATCH] fixup --- codecs/oxipng/build.sh | 1 + codecs/oxipng/pkg-parallel/oxipng.js | 2 +- codecs/oxipng/pkg/squoosh_oxipng.js | 2 +- codecs/oxipng/spawn.ts | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/codecs/oxipng/build.sh b/codecs/oxipng/build.sh index 766fb4ba..a46bae68 100644 --- a/codecs/oxipng/build.sh +++ b/codecs/oxipng/build.sh @@ -10,6 +10,7 @@ echo "=============================================" rm -rf pkg,{-parallel} wasm-pack build -t web RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' wasm-pack build -t web -d pkg-parallel -- -Z build-std=panic_abort,std --features=parallel + sed -i "s|input = import.meta.url.replace(/\\\.js$/, '_bg.wasm');||" pkg{,-parallel}/oxipng.js rm pkg{,-parallel}/.gitignore ) echo "=============================================" diff --git a/codecs/oxipng/pkg-parallel/oxipng.js b/codecs/oxipng/pkg-parallel/oxipng.js index e79e14c1..3d4a2566 100644 --- a/codecs/oxipng/pkg-parallel/oxipng.js +++ b/codecs/oxipng/pkg-parallel/oxipng.js @@ -138,7 +138,7 @@ async function load(module, imports, maybe_memory) { async function init(input, maybe_memory) { if (typeof input === 'undefined') { - input = import.meta.url.replace(/\.js$/, '_bg.wasm'); + } const imports = {}; imports.wbg = {}; diff --git a/codecs/oxipng/pkg/squoosh_oxipng.js b/codecs/oxipng/pkg/squoosh_oxipng.js index 74c98c89..a894a364 100644 --- a/codecs/oxipng/pkg/squoosh_oxipng.js +++ b/codecs/oxipng/pkg/squoosh_oxipng.js @@ -94,7 +94,7 @@ async function load(module, imports) { async function init(input) { if (typeof input === 'undefined') { - input = import.meta.url.replace(/\.js$/, '_bg.wasm'); + } const imports = {}; imports.wbg = {}; diff --git a/codecs/oxipng/spawn.ts b/codecs/oxipng/spawn.ts index 6f4ab83a..75f5c0fc 100644 --- a/codecs/oxipng/spawn.ts +++ b/codecs/oxipng/spawn.ts @@ -17,9 +17,9 @@ async function startMainThread() { const num = navigator.hardwareConcurrency; const workers = Array.from({ length: num }, () => new Worker('./worker', { type: 'module' })); await initOxiPNG(fetch(wasmUrl), undefined as any); - const workerInit: WorkerInit = worker_initializer(); + const workerInit: WorkerInit = worker_initializer(num); await Promise.all(workers.map(worker => initWorker(worker, workerInit))); - start_main_thread(num); + start_main_thread(); return { optimise, };