Release build of png

This commit is contained in:
Surma
2020-12-08 18:15:45 +00:00
parent ed55660c88
commit c832287fa6
5 changed files with 5 additions and 31 deletions

BIN
cli/.DS_Store vendored

Binary file not shown.

View File

@@ -5,6 +5,9 @@ authors = ["Surma <surma@surma.dev>"]
edition = "2018" edition = "2018"
publish = false publish = false
[package.metadata.wasm-pack.profile.release]
wasm-opt = ["-O", "--no-validation"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]

View File

@@ -1,6 +1,6 @@
{ {
"name": "oxipng", "name": "oxipng",
"scripts": { "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"
} }
} }

View File

@@ -113,8 +113,6 @@ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
function passStringToWasm0(arg, malloc, realloc) { function passStringToWasm0(arg, malloc, realloc) {
if (typeof(arg) !== 'string') throw new Error('expected a string argument');
if (realloc === undefined) { if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg); const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length); const ptr = malloc(buf.length);
@@ -143,7 +141,7 @@ function passStringToWasm0(arg, malloc, realloc) {
ptr = realloc(ptr, len, len = offset + arg.length * 3); ptr = realloc(ptr, len, len = offset + arg.length * 3);
const view = getUint8Memory0().subarray(ptr + offset, ptr + len); const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view); const ret = encodeString(arg, view);
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
offset += ret.written; offset += ret.written;
} }
@@ -174,10 +172,6 @@ function passArray8ToWasm0(arg, malloc) {
return ptr; return ptr;
} }
function _assertNum(n) {
if (typeof(n) !== 'number') throw new Error('expected a number argument');
}
function getArrayU8FromWasm0(ptr, len) { function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + 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; wasm.__wbindgen_export_2.value = retptr;
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN; var len0 = WASM_VECTOR_LEN;
_assertNum(width);
_assertNum(height);
wasm.encode(retptr, ptr0, len0, width, height); wasm.encode(retptr, ptr0, len0, width, height);
var r0 = getInt32Memory0()[retptr / 4 + 0]; var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1]; var r1 = getInt32Memory0()[retptr / 4 + 1];
@@ -234,8 +226,6 @@ function addHeapObject(obj) {
const idx = heap_next; const idx = heap_next;
heap_next = heap[idx]; heap_next = heap[idx];
if (typeof(heap_next) !== 'number') throw new Error('corrupt heap');
heap[idx] = obj; heap[idx] = obj;
return idx; 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) { async function load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) { if (typeof Response === 'function' && module instanceof Response) {

Binary file not shown.