Make images smaller using best-in-class codecs, right in the browser.
JavaScript
Release build of png
Surmac832287fa6d5
diff --git a/cli/.DS_Store b/cli/.DS_Storeindex aed2c26d..ceb4825c 100644Binary files a/cli/.DS_Store and b/cli/.DS_Store differdiff --git a/codecs/png/Cargo.toml b/codecs/png/Cargo.tomlindex daaaf71d..2114d14b 100644--- a/codecs/png/Cargo.toml+++ b/codecs/png/Cargo.toml@@ -5,6 +5,9 @@ authors = ["Surma <[email protected]>"]edition = "2018"publish = false+[package.metadata.wasm-pack.profile.release]+wasm-opt = ["-O", "--no-validation"]+[lib]crate-type = ["cdylib"]diff --git a/codecs/png/package.json b/codecs/png/package.jsonindex adce0fe0..5e22d088 100644--- a/codecs/png/package.json+++ b/codecs/png/package.json@@ -1,6 +1,6 @@{"name": "oxipng","scripts": {- "build": "../build-rust.sh rm -rf pkg && wasm-pack build --debug --target web -- --verbose --locked && rm pkg/.gitignore"+ "build": "../build-rust.sh rm -rf pkg && wasm-pack build --target web -- --verbose --locked && rm pkg/.gitignore"}}diff --git a/codecs/png/pkg/squoosh_png.js b/codecs/png/pkg/squoosh_png.jsindex b011728c..651ae14d 100644--- a/codecs/png/pkg/squoosh_png.js+++ b/codecs/png/pkg/squoosh_png.js@@ -113,8 +113,6 @@ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'function passStringToWasm0(arg, malloc, realloc) {- if (typeof(arg) !== 'string') throw new Error('expected a string argument');-if (realloc === undefined) {const buf = cachedTextEncoder.encode(arg);const ptr = malloc(buf.length);@@ -143,7 +141,7 @@ function passStringToWasm0(arg, malloc, realloc) {ptr = realloc(ptr, len, len = offset + arg.length * 3);const view = getUint8Memory0().subarray(ptr + offset, ptr + len);const ret = encodeString(arg, view);- if (ret.read !== arg.length) throw new Error('failed to pass whole string');+offset += ret.written;}@@ -174,10 +172,6 @@ function passArray8ToWasm0(arg, malloc) {return ptr;}-function _assertNum(n) {- if (typeof(n) !== 'number') throw new Error('expected a number argument');-}-function getArrayU8FromWasm0(ptr, len) {return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);}@@ -193,8 +187,6 @@ export function encode(data, width, height) {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];@@ -234,8 +226,6 @@ function addHeapObject(obj) {const idx = heap_next;heap_next = heap[idx];- if (typeof(heap_next) !== 'number') throw new Error('corrupt heap');-heap[idx] = obj;return idx;}@@ -251,25 +241,6 @@ function handleError(f) {};}-function logError(f) {- return function () {- try {- return f.apply(this, arguments);-- } catch (e) {- let error = (function () {- try {- return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();- } catch(_) {- return "<failed to stringify thrown value>";- }- }());- console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);- throw e;- }- };-}-async function load(module, imports) {if (typeof Response === 'function' && module instanceof Response) {diff --git a/codecs/png/pkg/squoosh_png_bg.wasm b/codecs/png/pkg/squoosh_png_bg.wasmindex 9de06b41..a0ad39c3 100644Binary files a/codecs/png/pkg/squoosh_png_bg.wasm and b/codecs/png/pkg/squoosh_png_bg.wasm differ