Fixup import.meta in OxiPNG

This commit is contained in:
Ingvar Stepanyan
2020-04-29 15:41:02 +01:00
committed by Ingvar Stepanyan
parent 47f9d22dd8
commit 82fadac70e
4 changed files with 5 additions and 4 deletions

View File

@ -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 "============================================="

View File

@ -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 = {};

View File

@ -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 = {};

View File

@ -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,
};