diff --git a/codecs/resize/Cargo.toml b/codecs/resize/Cargo.toml index b1f14fe6..79a49687 100644 --- a/codecs/resize/Cargo.toml +++ b/codecs/resize/Cargo.toml @@ -11,25 +11,25 @@ crate-type = ["cdylib"] default = ["console_error_panic_hook", "wee_alloc"] [dependencies] -cfg-if = "0.1.2" -wasm-bindgen = "0.2.38" -resize = "0.3.0" +cfg-if = "0.1.10" +wasm-bindgen = "0.2.63" +resize = "0.4.0" # The `console_error_panic_hook` crate provides better debugging of panics by # logging them with `console.error`. This is great for development, but requires # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for # code size when deploying. -console_error_panic_hook = { version = "0.1.1", optional = true } +console_error_panic_hook = { version = "0.1.6", optional = true } # `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size # compared to the default allocator's ~10K. It is slower than the default # allocator, however. # # Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. -wee_alloc = { version = "0.4.2", optional = true } +wee_alloc = { version = "0.4.5", optional = true } [dev-dependencies] -wasm-bindgen-test = "0.2" +wasm-bindgen-test = "0.3.13" [profile.release] # Tell `rustc` to optimize for small code size. diff --git a/codecs/resize/Dockerfile b/codecs/resize/Dockerfile index 4d58a71f..813d0c71 100644 --- a/codecs/resize/Dockerfile +++ b/codecs/resize/Dockerfile @@ -3,7 +3,7 @@ RUN rustup target add wasm32-unknown-unknown RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh RUN mkdir /opt/wabt && \ - curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.11/wabt-1.0.11-linux.tar.gz | tar -xzf - -C /opt/wabt --strip 1 + curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.15/wabt-1.0.15-linux.tar.gz | tar -xzf - -C /opt/wabt --strip 1 ENV PATH="/opt/wabt:${PATH}" WORKDIR /src diff --git a/codecs/resize/pkg/package.json b/codecs/resize/pkg/package.json index 4432d6bd..8c0daa14 100644 --- a/codecs/resize/pkg/package.json +++ b/codecs/resize/pkg/package.json @@ -11,5 +11,5 @@ ], "module": "resize.js", "types": "resize.d.ts", - "sideEffects": "false" + "sideEffects": false } \ No newline at end of file diff --git a/codecs/resize/pkg/resize.d.ts b/codecs/resize/pkg/resize.d.ts index f5266aa1..58a3b484 100644 --- a/codecs/resize/pkg/resize.d.ts +++ b/codecs/resize/pkg/resize.d.ts @@ -1,4 +1,5 @@ /* tslint:disable */ +/* eslint-disable */ /** * @param {Uint8Array} input_image * @param {number} input_width diff --git a/codecs/resize/pkg/resize.js b/codecs/resize/pkg/resize.js index dbb364ae..ef00b7e9 100644 --- a/codecs/resize/pkg/resize.js +++ b/codecs/resize/pkg/resize.js @@ -1,50 +1,2 @@ -import * as wasm from './resize_bg.wasm'; - -let cachegetUint8Memory = null; -function getUint8Memory() { - if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) { - cachegetUint8Memory = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory; -} - -let WASM_VECTOR_LEN = 0; - -function passArray8ToWasm(arg) { - const ptr = wasm.__wbindgen_malloc(arg.length * 1); - getUint8Memory().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} - -let cachegetInt32Memory = null; -function getInt32Memory() { - if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) { - cachegetInt32Memory = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory; -} - -function getArrayU8FromWasm(ptr, len) { - return getUint8Memory().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {Uint8Array} input_image -* @param {number} input_width -* @param {number} input_height -* @param {number} output_width -* @param {number} output_height -* @param {number} typ_idx -* @param {boolean} premultiply -* @param {boolean} color_space_conversion -* @returns {Uint8Array} -*/ -export function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) { - const retptr = 8; - const ret = wasm.resize(retptr, passArray8ToWasm(input_image), WASM_VECTOR_LEN, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion); - const memi32 = getInt32Memory(); - const v0 = getArrayU8FromWasm(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1]).slice(); - wasm.__wbindgen_free(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1] * 1); - return v0; -} - +import * as wasm from "./resize_bg.wasm"; +export * from "./resize_bg.js"; \ No newline at end of file diff --git a/codecs/resize/pkg/resize_bg.d.ts b/codecs/resize/pkg/resize_bg.d.ts index 51e147c3..6376fa2e 100644 --- a/codecs/resize/pkg/resize_bg.d.ts +++ b/codecs/resize/pkg/resize_bg.d.ts @@ -1,5 +1,6 @@ /* tslint:disable */ +/* eslint-disable */ export const memory: WebAssembly.Memory; +export function resize(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; export function __wbindgen_malloc(a: number): number; export function __wbindgen_free(a: number, b: number): void; -export function resize(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; diff --git a/codecs/resize/pkg/resize_bg.js b/codecs/resize/pkg/resize_bg.js new file mode 100644 index 00000000..be791e1f --- /dev/null +++ b/codecs/resize/pkg/resize_bg.js @@ -0,0 +1,52 @@ +import * as wasm from './resize_bg.wasm'; + +let cachegetUint8Memory0 = null; +function getUint8Memory0() { + if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { + cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachegetUint8Memory0; +} + +let WASM_VECTOR_LEN = 0; + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1); + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +let cachegetInt32Memory0 = null; +function getInt32Memory0() { + if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { + cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachegetInt32Memory0; +} + +function getArrayU8FromWasm0(ptr, len) { + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} +/** +* @param {Uint8Array} input_image +* @param {number} input_width +* @param {number} input_height +* @param {number} output_width +* @param {number} output_height +* @param {number} typ_idx +* @param {boolean} premultiply +* @param {boolean} color_space_conversion +* @returns {Uint8Array} +*/ +export function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) { + var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.resize(8, ptr0, len0, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion); + 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; +} + diff --git a/codecs/resize/pkg/resize_bg.wasm b/codecs/resize/pkg/resize_bg.wasm index 50fc8dc9..1f9abf09 100644 Binary files a/codecs/resize/pkg/resize_bg.wasm and b/codecs/resize/pkg/resize_bg.wasm differ diff --git a/package-lock.json b/package-lock.json index e35d0cd8..e5c2b994 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10240,7 +10240,7 @@ }, "os-locale": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "dev": true, "requires": { @@ -12869,7 +12869,7 @@ "dependencies": { "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }