mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 09:17:20 +00:00
Rename resize package
Without this, it was creating files in `pkg` prefixed with `squooshresize`, which were ignored by Git.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "squooshresize"
|
name = "resize"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Surma <surma@surma.link>"]
|
authors = ["Surma <surma@surma.link>"]
|
||||||
|
|
||||||
|
|||||||
29
codecs/resize/pkg/resize.d.ts
vendored
29
codecs/resize/pkg/resize.d.ts
vendored
@@ -1,13 +1,24 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/**
|
/**
|
||||||
* @param {Uint8Array} arg0
|
* @param {Uint8Array} input_image
|
||||||
* @param {number} arg1
|
* @param {number} input_width
|
||||||
* @param {number} arg2
|
* @param {number} input_height
|
||||||
* @param {number} arg3
|
* @param {number} output_width
|
||||||
* @param {number} arg4
|
* @param {number} output_height
|
||||||
* @param {number} arg5
|
* @param {number} typ_idx
|
||||||
* @param {boolean} arg6
|
* @param {boolean} premultiply
|
||||||
* @param {boolean} arg7
|
* @param {boolean} color_space_conversion
|
||||||
* @returns {Uint8Array}
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
export function resize(arg0: Uint8Array, arg1: number, arg2: number, arg3: number, arg4: number, arg5: number, arg6: boolean, arg7: boolean): Uint8Array;
|
export function resize(input_image: Uint8Array, input_width: number, input_height: number, output_width: number, output_height: number, typ_idx: number, premultiply: boolean, color_space_conversion: boolean): Uint8Array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If `module_or_path` is {RequestInfo}, makes a request and
|
||||||
|
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||||
|
*
|
||||||
|
* @param {RequestInfo | BufferSource | WebAssembly.Module} module_or_path
|
||||||
|
*
|
||||||
|
* @returns {Promise<any>}
|
||||||
|
*/
|
||||||
|
export default function init (module_or_path: RequestInfo | BufferSource | WebAssembly.Module): Promise<any>;
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var wasm;
|
|
||||||
const __exports = {};
|
const __exports = {};
|
||||||
|
let wasm;
|
||||||
|
|
||||||
let cachegetUint8Memory = null;
|
let cachegetUint8Memory = null;
|
||||||
function getUint8Memory() {
|
function getUint8Memory() {
|
||||||
@@ -20,95 +19,77 @@
|
|||||||
return ptr;
|
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) {
|
function getArrayU8FromWasm(ptr, len) {
|
||||||
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
|
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
|
||||||
}
|
}
|
||||||
|
|
||||||
let cachedGlobalArgumentPtr = null;
|
|
||||||
function globalArgumentPtr() {
|
|
||||||
if (cachedGlobalArgumentPtr === null) {
|
|
||||||
cachedGlobalArgumentPtr = wasm.__wbindgen_global_argument_ptr();
|
|
||||||
}
|
|
||||||
return cachedGlobalArgumentPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
let cachegetUint32Memory = null;
|
|
||||||
function getUint32Memory() {
|
|
||||||
if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {
|
|
||||||
cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);
|
|
||||||
}
|
|
||||||
return cachegetUint32Memory;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param {Uint8Array} arg0
|
* @param {Uint8Array} input_image
|
||||||
* @param {number} arg1
|
* @param {number} input_width
|
||||||
* @param {number} arg2
|
* @param {number} input_height
|
||||||
* @param {number} arg3
|
* @param {number} output_width
|
||||||
* @param {number} arg4
|
* @param {number} output_height
|
||||||
* @param {number} arg5
|
* @param {number} typ_idx
|
||||||
* @param {boolean} arg6
|
* @param {boolean} premultiply
|
||||||
* @param {boolean} arg7
|
* @param {boolean} color_space_conversion
|
||||||
* @returns {Uint8Array}
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
__exports.resize = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
__exports.resize = function(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {
|
||||||
const ptr0 = passArray8ToWasm(arg0);
|
const retptr = 8;
|
||||||
const len0 = WASM_VECTOR_LEN;
|
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 retptr = globalArgumentPtr();
|
const memi32 = getInt32Memory();
|
||||||
wasm.resize(retptr, ptr0, len0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
const v0 = getArrayU8FromWasm(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1]).slice();
|
||||||
const mem = getUint32Memory();
|
wasm.__wbindgen_free(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1] * 1);
|
||||||
const rustptr = mem[retptr / 4];
|
return v0;
|
||||||
const rustlen = mem[retptr / 4 + 1];
|
|
||||||
|
|
||||||
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
|
|
||||||
wasm.__wbindgen_free(rustptr, rustlen * 1);
|
|
||||||
return realRet;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const heap = new Array(32);
|
function init(module) {
|
||||||
|
|
||||||
heap.fill(undefined);
|
let result;
|
||||||
|
const imports = {};
|
||||||
|
|
||||||
heap.push(undefined, null, true, false);
|
if (module instanceof URL || typeof module === 'string' || module instanceof Request) {
|
||||||
|
|
||||||
let heap_next = heap.length;
|
const response = fetch(module);
|
||||||
|
|
||||||
function dropObject(idx) {
|
|
||||||
if (idx < 36) return;
|
|
||||||
heap[idx] = heap_next;
|
|
||||||
heap_next = idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
__exports.__wbindgen_object_drop_ref = function(i) { dropObject(i); };
|
|
||||||
|
|
||||||
function init(path_or_module) {
|
|
||||||
let instantiation;
|
|
||||||
const imports = { './resize': __exports };
|
|
||||||
if (path_or_module instanceof WebAssembly.Module) {
|
|
||||||
instantiation = WebAssembly.instantiate(path_or_module, imports)
|
|
||||||
.then(instance => {
|
|
||||||
return { instance, module: path_or_module }
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const data = fetch(path_or_module);
|
|
||||||
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
||||||
instantiation = WebAssembly.instantiateStreaming(data, imports)
|
result = WebAssembly.instantiateStreaming(response, imports)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
console.warn("`WebAssembly.instantiateStreaming` failed. Assuming this is because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
console.warn("`WebAssembly.instantiateStreaming` failed. Assuming this is because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
||||||
return data
|
return response
|
||||||
.then(r => r.arrayBuffer())
|
.then(r => r.arrayBuffer())
|
||||||
.then(bytes => WebAssembly.instantiate(bytes, imports));
|
.then(bytes => WebAssembly.instantiate(bytes, imports));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
instantiation = data
|
result = response
|
||||||
.then(response => response.arrayBuffer())
|
.then(r => r.arrayBuffer())
|
||||||
.then(buffer => WebAssembly.instantiate(buffer, imports));
|
.then(bytes => WebAssembly.instantiate(bytes, imports));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
return instantiation.then(({instance}) => {
|
|
||||||
wasm = init.wasm = instance.exports;
|
|
||||||
|
|
||||||
|
result = WebAssembly.instantiate(module, imports)
|
||||||
|
.then(result => {
|
||||||
|
if (result instanceof WebAssembly.Instance) {
|
||||||
|
return { instance: result, module };
|
||||||
|
} else {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
return result.then(({instance, module}) => {
|
||||||
|
wasm = instance.exports;
|
||||||
|
init.__wbindgen_wasm_module = module;
|
||||||
|
|
||||||
|
return wasm;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
self.wasm_bindgen = Object.assign(init, __exports);
|
self.wasm_bindgen = Object.assign(init, __exports);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
1
codecs/resize/pkg/resize_bg.d.ts
vendored
1
codecs/resize/pkg/resize_bg.d.ts
vendored
@@ -1,6 +1,5 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
export const memory: WebAssembly.Memory;
|
export const memory: WebAssembly.Memory;
|
||||||
export function __wbindgen_global_argument_ptr(): number;
|
|
||||||
export function __wbindgen_malloc(a: number): number;
|
export function __wbindgen_malloc(a: number): number;
|
||||||
export function __wbindgen_free(a: number, b: number): void;
|
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;
|
export function resize(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void;
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user