diff --git a/codecs/png/Cargo.lock b/codecs/png/Cargo.lock index 62d5b7e1..ea2dfdc0 100644 --- a/codecs/png/Cargo.lock +++ b/codecs/png/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.42" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52732a3d3ad72c58ad2dc70624f9c17b46ecd0943b9a4f1ee37c4c18c5d983e2" +checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8" dependencies = [ "wasm-bindgen", ] @@ -141,9 +141,9 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "wasm-bindgen" -version = "0.2.65" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3edbcc9536ab7eababcc6d2374a0b7bfe13a2b6d562c5e07f370456b1a8f33d" +checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -151,9 +151,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.65" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ed2fb8c84bfad20ea66b26a3743f3e7ba8735a69fe7d95118c33ec8fc1244d" +checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68" dependencies = [ "bumpalo", "lazy_static", @@ -166,9 +166,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.65" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e" +checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.65" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6" +checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe" dependencies = [ "proc-macro2", "quote", @@ -189,15 +189,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.65" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b6c0220ded549d63860c78c38f3bcc558d1ca3f4efa74942c536ddbbb55e87" +checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307" [[package]] name = "web-sys" -version = "0.3.42" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be2398f326b7ba09815d0b403095f34dd708579220d099caae89be0b32137b2" +checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/codecs/png/Cargo.toml b/codecs/png/Cargo.toml index 5c784c82..daaaf71d 100644 --- a/codecs/png/Cargo.toml +++ b/codecs/png/Cargo.toml @@ -10,14 +10,8 @@ crate-type = ["cdylib"] [dependencies] png = "0.16.7" -# wasm-bindgen 0.2.66+ emits Wasm using exported mutable globals, -# which is a stage 4 feature and not well supported. -# https://github.com/rustwasm/wasm-pack/issues/886 -wasm-bindgen = "=0.2.65" -# Need to pin web-sys to 0.3.42, because newer versions depend -# on newer versions of wasm-bindgen. -web-sys = { version = "=0.3.42", features = ["ImageData"] } -log = { version = "0.4", features = ["release_max_level_off"] } +wasm-bindgen = "0.2.68" +web-sys = { version = "0.3.45", features = ["ImageData"] } [profile.release] lto = true diff --git a/codecs/png/pkg/squoosh_png.js b/codecs/png/pkg/squoosh_png.js index a07ed4b7..b011728c 100644 --- a/codecs/png/pkg/squoosh_png.js +++ b/codecs/png/pkg/squoosh_png.js @@ -188,16 +188,22 @@ function getArrayU8FromWasm0(ptr, len) { * @returns {Uint8Array} */ export function encode(data, width, height) { - var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - var len0 = WASM_VECTOR_LEN; - _assertNum(width); - _assertNum(height); - wasm.encode(8, ptr0, len0, width, height); - var r0 = getInt32Memory0()[8 / 4 + 0]; - var r1 = getInt32Memory0()[8 / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; + try { + const retptr = wasm.__wbindgen_export_2.value - 16; + wasm.__wbindgen_export_2.value = retptr; + var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + _assertNum(width); + _assertNum(height); + wasm.encode(retptr, ptr0, len0, width, height); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; + } finally { + wasm.__wbindgen_export_2.value += 16; + } } /** @@ -303,7 +309,7 @@ async function init(input) { } const imports = {}; imports.wbg = {}; - imports.wbg.__wbg_newwithu8clampedarrayandsh_d46fa191b076edfe = handleError(function(arg0, arg1, arg2, arg3) { + imports.wbg.__wbg_newwithu8clampedarrayandsh_104cc36644cfc313 = handleError(function(arg0, arg1, arg2, arg3) { var ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0); return addHeapObject(ret); }); diff --git a/codecs/png/pkg/squoosh_png_bg.wasm b/codecs/png/pkg/squoosh_png_bg.wasm index 089b985f..3f81e9a3 100644 Binary files a/codecs/png/pkg/squoosh_png_bg.wasm and b/codecs/png/pkg/squoosh_png_bg.wasm differ diff --git a/codecs/png/pkg/squoosh_png_bg.d.ts b/codecs/png/pkg/squoosh_png_bg.wasm.d.ts similarity index 100% rename from codecs/png/pkg/squoosh_png_bg.d.ts rename to codecs/png/pkg/squoosh_png_bg.wasm.d.ts