diff --git a/src/webworker/js.rs b/src/webworker/js.rs index f17f3b1..11ab1ea 100644 --- a/src/webworker/js.rs +++ b/src/webworker/js.rs @@ -19,6 +19,7 @@ console.debug('Initializing worker'); return; } + await mod.default(); self.postMessage({ success: true }); console.debug('Worker started'); diff --git a/vite/public/pkg/wasmworker_demo.d.ts b/vite/public/pkg/wasmworker_demo.d.ts index d468859..18e2ef1 100644 --- a/vite/public/pkg/wasmworker_demo.d.ts +++ b/vite/public/pkg/wasmworker_demo.d.ts @@ -105,29 +105,31 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl export interface InitOutput { readonly memory: WebAssembly.Memory; - readonly __webworker_sort_vec: (a: number, b: number, c: number) => void; + readonly __webworker_sort_vec: (a: number, b: number) => Array; readonly runWorker: () => number; readonly runPool: () => number; readonly runParMap: () => number; - readonly initWorkerPool: (a: number) => number; readonly __wbg_workerpooloptions_free: (a: number, b: number) => void; - readonly __wbg_get_workerpooloptions_path: (a: number, b: number) => void; + readonly __wbg_get_workerpooloptions_path: (a: number) => Array; readonly __wbg_set_workerpooloptions_path: (a: number, b: number, c: number) => void; readonly __wbg_get_workerpooloptions_strategy: (a: number) => number; readonly __wbg_set_workerpooloptions_strategy: (a: number, b: number) => void; - readonly __wbg_get_workerpooloptions_num_workers: (a: number, b: number) => void; + readonly __wbg_get_workerpooloptions_num_workers: (a: number) => Array; readonly __wbg_set_workerpooloptions_num_workers: (a: number, b: number, c: number) => void; readonly workerpooloptions_new: () => number; + readonly initWorkerPool: (a: number) => number; readonly __wbindgen_malloc: (a: number, b: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_export_2: WebAssembly.Table; - readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3f0da974b301f4e: (a: number, b: number, c: number) => void; - readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1ed3f61ce670585a: (a: number, b: number, c: number) => void; - readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h36e1010f860e4e87: (a: number, b: number, c: number) => void; - readonly __wbindgen_add_to_stack_pointer: (a: number) => number; + readonly __wbindgen_export_3: WebAssembly.Table; + readonly closure36_externref_shim: (a: number, b: number, c: number) => void; + readonly closure76_externref_shim: (a: number, b: number, c: number) => void; + readonly closure86_externref_shim: (a: number, b: number, c: number) => void; readonly __wbindgen_free: (a: number, b: number, c: number) => void; readonly __wbindgen_exn_store: (a: number) => void; - readonly wasm_bindgen__convert__closures__invoke2_mut__h6d1a51fb0f116f48: (a: number, b: number, c: number, d: number) => void; + readonly __externref_table_alloc: () => number; + readonly closure103_externref_shim: (a: number, b: number, c: number, d: number) => void; + readonly __wbindgen_start: () => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; diff --git a/vite/public/pkg/wasmworker_demo.js b/vite/public/pkg/wasmworker_demo.js index d1a3aa6..bd1a379 100644 --- a/vite/public/pkg/wasmworker_demo.js +++ b/vite/public/pkg/wasmworker_demo.js @@ -1,25 +1,5 @@ let wasm; -const heap = new Array(128).fill(undefined); - -heap.push(undefined, null, true, false); - -function getObject(idx) { return heap[idx]; } - -let heap_next = heap.length; - -function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - let WASM_VECTOR_LEN = 0; let cachedUint8ArrayMemory0 = null; @@ -107,15 +87,6 @@ function getStringFromWasm0(ptr, len) { return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - function debugString(val) { // primitive types const type = typeof val; @@ -184,7 +155,7 @@ function debugString(val) { const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(state => { - wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) + wasm.__wbindgen_export_3.get(state.dtor)(state.a, state.b) }); function makeMutClosure(arg0, arg1, dtor, f) { @@ -200,7 +171,7 @@ function makeMutClosure(arg0, arg1, dtor, f) { return f(a, state.b, ...args); } finally { if (--state.cnt === 0) { - wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + wasm.__wbindgen_export_3.get(state.dtor)(a, state.b); CLOSURE_DTORS.unregister(state); } else { state.a = a; @@ -211,16 +182,16 @@ function makeMutClosure(arg0, arg1, dtor, f) { CLOSURE_DTORS.register(real, state, state); return real; } -function __wbg_adapter_46(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3f0da974b301f4e(arg0, arg1, addHeapObject(arg2)); +function __wbg_adapter_48(arg0, arg1, arg2) { + wasm.closure36_externref_shim(arg0, arg1, arg2); } -function __wbg_adapter_49(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1ed3f61ce670585a(arg0, arg1, addHeapObject(arg2)); +function __wbg_adapter_51(arg0, arg1, arg2) { + wasm.closure76_externref_shim(arg0, arg1, arg2); } -function __wbg_adapter_52(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h36e1010f860e4e87(arg0, arg1, addHeapObject(arg2)); +function __wbg_adapter_54(arg0, arg1, arg2) { + wasm.closure86_externref_shim(arg0, arg1, arg2); } function passArray8ToWasm0(arg, malloc) { @@ -239,19 +210,12 @@ function getArrayU8FromWasm0(ptr, len) { * @returns {Uint8Array} */ export function __webworker_sort_vec(arg) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(arg, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.__webworker_sort_vec(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } + const ptr0 = passArray8ToWasm0(arg, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.__webworker_sort_vec(ptr0, len0); + var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v2; } /** @@ -260,7 +224,7 @@ export function __webworker_sort_vec(arg) { */ export function runWorker() { const ret = wasm.runWorker(); - return takeObject(ret); + return ret; } /** @@ -269,7 +233,7 @@ export function runWorker() { */ export function runPool() { const ret = wasm.runPool(); - return takeObject(ret); + return ret; } /** @@ -278,14 +242,21 @@ export function runPool() { */ export function runParMap() { const ret = wasm.runParMap(); - return takeObject(ret); + return ret; +} + +function addToExternrefTable0(obj) { + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_export_2.set(idx, obj); + return idx; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); } } @@ -324,11 +295,12 @@ export function initWorkerPool(options) { _assertClass(options, WorkerPoolOptions); var ptr0 = options.__destroy_into_raw(); const ret = wasm.initWorkerPool(ptr0); - return takeObject(ret); + return ret; } -function __wbg_adapter_143(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen__convert__closures__invoke2_mut__h6d1a51fb0f116f48(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +function notDefined(what) { return () => { throw new Error(`${what} is not defined`); }; } +function __wbg_adapter_145(arg0, arg1, arg2, arg3) { + wasm.closure103_externref_shim(arg0, arg1, arg2, arg3); } /** @@ -389,20 +361,13 @@ export class WorkerPoolOptions { * @returns {string | undefined} */ get path() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_workerpooloptions_path(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); + const ret = wasm.__wbg_get_workerpooloptions_path(this.__wbg_ptr); + let v1; + if (ret[0] !== 0) { + v1 = getStringFromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); } + return v1; } /** * The path to the wasm-bindgen glue. By default, this path is inferred. @@ -435,15 +400,8 @@ export class WorkerPoolOptions { * @returns {number | undefined} */ get num_workers() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_workerpooloptions_num_workers(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - return r0 === 0 ? undefined : r1 >>> 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } + const ret = wasm.__wbg_get_workerpooloptions_num_workers(this.__wbg_ptr); + return ret[0] === 0 ? undefined : ret[1] >>> 0; } /** * The number of workers that will be spawned. This defaults to `navigator.hardwareConcurrency`. @@ -497,11 +455,8 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; - imports.wbg.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); - }; imports.wbg.__wbindgen_cb_drop = function(arg0) { - const obj = takeObject(arg0).original; + const obj = arg0.original; if (obj.cnt-- == 1) { obj.a = 0; return true; @@ -510,12 +465,12 @@ function __wbg_get_imports() { return ret; }; imports.wbg.__wbindgen_boolean_get = function(arg0) { - const v = getObject(arg0); + const v = arg0; const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; return ret; }; imports.wbg.__wbindgen_string_get = function(arg0, arg1) { - const obj = getObject(arg1); + const obj = arg1; const ret = typeof(obj) === 'string' ? obj : undefined; var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); var len1 = WASM_VECTOR_LEN; @@ -523,116 +478,110 @@ function __wbg_get_imports() { getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; imports.wbg.__wbindgen_is_object = function(arg0) { - const val = getObject(arg0); + const val = arg0; const ret = typeof(val) === 'object' && val !== null; return ret; }; imports.wbg.__wbindgen_is_undefined = function(arg0) { - const ret = getObject(arg0) === undefined; + const ret = arg0 === undefined; return ret; }; imports.wbg.__wbindgen_in = function(arg0, arg1) { - const ret = getObject(arg0) in getObject(arg1); + const ret = arg0 in arg1; return ret; }; imports.wbg.__wbindgen_error_new = function(arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) { - const ret = getObject(arg0).crypto; - return addHeapObject(ret); + const ret = arg0.crypto; + return ret; }; imports.wbg.__wbg_process_4a72847cc503995b = function(arg0) { - const ret = getObject(arg0).process; - return addHeapObject(ret); + const ret = arg0.process; + return ret; }; imports.wbg.__wbg_versions_f686565e586dd935 = function(arg0) { - const ret = getObject(arg0).versions; - return addHeapObject(ret); + const ret = arg0.versions; + return ret; }; imports.wbg.__wbg_node_104a2ff8d6ea03a2 = function(arg0) { - const ret = getObject(arg0).node; - return addHeapObject(ret); + const ret = arg0.node; + return ret; }; imports.wbg.__wbindgen_is_string = function(arg0) { - const ret = typeof(getObject(arg0)) === 'string'; + const ret = typeof(arg0) === 'string'; return ret; }; imports.wbg.__wbg_require_cca90b1a94a0255b = function() { return handleError(function () { const ret = module.require; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbindgen_is_function = function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; + const ret = typeof(arg0) === 'function'; return ret; }; imports.wbg.__wbindgen_string_new = function(arg0, arg1) { const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) { - const ret = getObject(arg0).msCrypto; - return addHeapObject(ret); + const ret = arg0.msCrypto; + return ret; }; imports.wbg.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) { - getObject(arg0).randomFillSync(takeObject(arg1)); + arg0.randomFillSync(arg1); }, arguments) }; imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) { - getObject(arg0).getRandomValues(getObject(arg1)); + arg0.getRandomValues(arg1); }, arguments) }; imports.wbg.__wbindgen_number_new = function(arg0) { const ret = arg0; - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_object_clone_ref = function(arg0) { - const ret = getObject(arg0); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_number_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); + return ret; }; imports.wbg.__wbindgen_is_bigint = function(arg0) { - const ret = typeof(getObject(arg0)) === 'bigint'; + const ret = typeof(arg0) === 'bigint'; return ret; }; imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) { const ret = BigInt.asUintN(64, arg0); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) { - const ret = getObject(arg0) === getObject(arg1); + const ret = arg0 === arg1; return ret; }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = arg1; + const ret = typeof(obj) === 'number' ? obj : undefined; + getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); + }; imports.wbg.__wbg_static_accessor_URL_8892c157b3461cce = function() { const ret = import.meta.url; - return addHeapObject(ret); + return ret; }; imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) { - const ret = getObject(arg0) == getObject(arg1); + const ret = arg0 == arg1; return ret; }; imports.wbg.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) { - const ret = getObject(arg0)[getObject(arg1)]; - return addHeapObject(ret); + const ret = arg0[arg1]; + return ret; }; imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) { - getObject(arg0)[takeObject(arg1)] = takeObject(arg2); + arg0[arg1] = arg2; }; imports.wbg.__wbg_queueMicrotask_848aa4969108a57e = function(arg0) { - const ret = getObject(arg0).queueMicrotask; - return addHeapObject(ret); - }; - imports.wbg.__wbg_queueMicrotask_c5419c06eab41e73 = function(arg0) { - queueMicrotask(getObject(arg0)); + const ret = arg0.queueMicrotask; + return ret; }; + imports.wbg.__wbg_queueMicrotask_c5419c06eab41e73 = typeof queueMicrotask == 'function' ? queueMicrotask : notDefined('queueMicrotask'); imports.wbg.__wbg_instanceof_Window_6575cd7f1322f82f = function(arg0) { let result; try { - result = getObject(arg0) instanceof Window; + result = arg0 instanceof Window; } catch (_) { result = false; } @@ -640,24 +589,24 @@ function __wbg_get_imports() { return ret; }; imports.wbg.__wbg_document_d7fa2c739c2b191a = function(arg0) { - const ret = getObject(arg0).document; - return isLikeNone(ret) ? 0 : addHeapObject(ret); + const ret = arg0.document; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); }; imports.wbg.__wbg_navigator_3d3836196a5d8e62 = function(arg0) { - const ret = getObject(arg0).navigator; - return addHeapObject(ret); + const ret = arg0.navigator; + return ret; }; imports.wbg.__wbg_getElementById_734c4eac4fec5911 = function(arg0, arg1, arg2) { - const ret = getObject(arg0).getElementById(getStringFromWasm0(arg1, arg2)); - return isLikeNone(ret) ? 0 : addHeapObject(ret); + const ret = arg0.getElementById(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); }; imports.wbg.__wbg_setinnerHTML_559d45055154f1d8 = function(arg0, arg1, arg2) { - getObject(arg0).innerHTML = getStringFromWasm0(arg1, arg2); + arg0.innerHTML = getStringFromWasm0(arg1, arg2); }; imports.wbg.__wbg_instanceof_HtmlElement_aab18e065dc9207d = function(arg0) { let result; try { - result = getObject(arg0) instanceof HTMLElement; + result = arg0 instanceof HTMLElement; } catch (_) { result = false; } @@ -667,7 +616,7 @@ function __wbg_get_imports() { imports.wbg.__wbg_instanceof_HtmlInputElement_ee25196edbacced9 = function(arg0) { let result; try { - result = getObject(arg0) instanceof HTMLInputElement; + result = arg0 instanceof HTMLInputElement; } catch (_) { result = false; } @@ -675,45 +624,45 @@ function __wbg_get_imports() { return ret; }; imports.wbg.__wbg_value_0cffd86fb9a5a18d = function(arg0, arg1) { - const ret = getObject(arg1).value; + const ret = arg1.value; const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; - imports.wbg.__wbg_settype_623d2ee701e6310a = function(arg0, arg1, arg2) { - getObject(arg0).type = getStringFromWasm0(arg1, arg2); - }; - imports.wbg.__wbg_settype_1f2a8b1758356509 = function(arg0, arg1) { - getObject(arg0).type = __wbindgen_enum_WorkerType[arg1]; + imports.wbg.__wbg_data_134d3a704b9fca32 = function(arg0) { + const ret = arg0.data; + return ret; }; imports.wbg.__wbg_hardwareConcurrency_8363a59b91d7f80d = function(arg0) { - const ret = getObject(arg0).hardwareConcurrency; + const ret = arg0.hardwareConcurrency; return ret; }; imports.wbg.__wbg_setonmessage_7e6ff33e920fdb07 = function(arg0, arg1) { - getObject(arg0).onmessage = getObject(arg1); + arg0.onmessage = arg1; }; imports.wbg.__wbg_newwithoptions_45d40204ebfa60b5 = function() { return handleError(function (arg0, arg1, arg2) { - const ret = new Worker(getStringFromWasm0(arg0, arg1), getObject(arg2)); - return addHeapObject(ret); + const ret = new Worker(getStringFromWasm0(arg0, arg1), arg2); + return ret; }, arguments) }; imports.wbg.__wbg_postMessage_49334e5d7d9cc421 = function() { return handleError(function (arg0, arg1) { - getObject(arg0).postMessage(getObject(arg1)); + arg0.postMessage(arg1); }, arguments) }; imports.wbg.__wbg_terminate_fa0a0b8a5e8ee1ec = function(arg0) { - getObject(arg0).terminate(); + arg0.terminate(); + }; + imports.wbg.__wbg_settype_623d2ee701e6310a = function(arg0, arg1, arg2) { + arg0.type = getStringFromWasm0(arg1, arg2); + }; + imports.wbg.__wbg_settype_1f2a8b1758356509 = function(arg0, arg1) { + arg0.type = __wbindgen_enum_WorkerType[arg1]; }; imports.wbg.__wbg_newwithblobsequenceandoptions_4af878769922c608 = function() { return handleError(function (arg0, arg1) { - const ret = new Blob(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); + const ret = new Blob(arg0, arg1); + return ret; }, arguments) }; - imports.wbg.__wbg_data_134d3a704b9fca32 = function(arg0) { - const ret = getObject(arg0).data; - return addHeapObject(ret); - }; imports.wbg.__wbg_createObjectURL_11804d71ac214694 = function() { return handleError(function (arg0, arg1) { - const ret = URL.createObjectURL(getObject(arg1)); + const ret = URL.createObjectURL(arg1); const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); @@ -721,44 +670,44 @@ function __wbg_get_imports() { }, arguments) }; imports.wbg.__wbg_new_034f913e7636e987 = function() { const ret = new Array(); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbg_newnoargs_1ede4bf2ebbaaf43 = function(arg0, arg1) { const ret = new Function(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbg_call_a9ef466721e824f2 = function() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); + const ret = arg0.call(arg1); + return ret; }, arguments) }; imports.wbg.__wbg_new_e69b5f66fda8f13c = function() { const ret = new Object(); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbg_self_bf91bf94d9e04084 = function() { return handleError(function () { const ret = self.self; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_window_52dd9f07d03fd5f8 = function() { return handleError(function () { const ret = window.window; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_globalThis_05c129bf37fcf1be = function() { return handleError(function () { const ret = globalThis.globalThis; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_global_3eca19bb09e9c484 = function() { return handleError(function () { const ret = global.global; - return addHeapObject(ret); + return ret; }, arguments) }; imports.wbg.__wbg_push_36cf4d81d7da33d1 = function(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); + const ret = arg0.push(arg1); return ret; }; imports.wbg.__wbg_instanceof_ArrayBuffer_74945570b4a62ec7 = function(arg0) { let result; try { - result = getObject(arg0) instanceof ArrayBuffer; + result = arg0 instanceof ArrayBuffer; } catch (_) { result = false; } @@ -766,11 +715,11 @@ function __wbg_get_imports() { return ret; }; imports.wbg.__wbg_call_3bfa248576352471 = function() { return handleError(function (arg0, arg1, arg2) { - const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); - return addHeapObject(ret); + const ret = arg0.call(arg1, arg2); + return ret; }, arguments) }; imports.wbg.__wbg_isSafeInteger_b9dff570f01a9100 = function(arg0) { - const ret = Number.isSafeInteger(getObject(arg0)); + const ret = Number.isSafeInteger(arg0); return ret; }; imports.wbg.__wbg_new_1073970097e5a420 = function(arg0, arg1) { @@ -780,48 +729,48 @@ function __wbg_get_imports() { const a = state0.a; state0.a = 0; try { - return __wbg_adapter_143(a, state0.b, arg0, arg1); + return __wbg_adapter_145(a, state0.b, arg0, arg1); } finally { state0.a = a; } }; const ret = new Promise(cb0); - return addHeapObject(ret); + return ret; } finally { state0.a = state0.b = 0; } }; imports.wbg.__wbg_resolve_0aad7c1484731c99 = function(arg0) { - const ret = Promise.resolve(getObject(arg0)); - return addHeapObject(ret); + const ret = Promise.resolve(arg0); + return ret; }; imports.wbg.__wbg_then_748f75edfb032440 = function(arg0, arg1) { - const ret = getObject(arg0).then(getObject(arg1)); - return addHeapObject(ret); + const ret = arg0.then(arg1); + return ret; }; imports.wbg.__wbg_buffer_ccaed51a635d8a2d = function(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); + const ret = arg0.buffer; + return ret; }; imports.wbg.__wbg_newwithbyteoffsetandlength_7e3eb787208af730 = function(arg0, arg1, arg2) { - const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); - return addHeapObject(ret); + const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0); + return ret; }; imports.wbg.__wbg_new_fec2611eb9180f95 = function(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); + const ret = new Uint8Array(arg0); + return ret; }; imports.wbg.__wbg_set_ec2fcf81bc573fd9 = function(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); + arg0.set(arg1, arg2 >>> 0); }; imports.wbg.__wbg_length_9254c4bd3b9f23c4 = function(arg0) { - const ret = getObject(arg0).length; + const ret = arg0.length; return ret; }; imports.wbg.__wbg_instanceof_Uint8Array_df0761410414ef36 = function(arg0) { let result; try { - result = getObject(arg0) instanceof Uint8Array; + result = arg0 instanceof Uint8Array; } catch (_) { result = false; } @@ -830,20 +779,20 @@ function __wbg_get_imports() { }; imports.wbg.__wbg_newwithlength_76462a666eca145f = function(arg0) { const ret = new Uint8Array(arg0 >>> 0); - return addHeapObject(ret); + return ret; }; imports.wbg.__wbg_subarray_975a06f9dbd16995 = function(arg0, arg1, arg2) { - const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); - return addHeapObject(ret); + const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); + return ret; }; imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) { - const v = getObject(arg1); + const v = arg1; const ret = typeof(v) === 'bigint' ? v : undefined; getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); }; imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { - const ret = debugString(getObject(arg1)); + const ret = debugString(arg1); const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); @@ -854,19 +803,29 @@ function __wbg_get_imports() { }; imports.wbg.__wbindgen_memory = function() { const ret = wasm.memory; - return addHeapObject(ret); + return ret; }; - imports.wbg.__wbindgen_closure_wrapper188 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 38, __wbg_adapter_46); - return addHeapObject(ret); + imports.wbg.__wbindgen_closure_wrapper171 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 37, __wbg_adapter_48); + return ret; }; - imports.wbg.__wbindgen_closure_wrapper267 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 61, __wbg_adapter_49); - return addHeapObject(ret); + imports.wbg.__wbindgen_closure_wrapper294 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 77, __wbg_adapter_51); + return ret; }; - imports.wbg.__wbindgen_closure_wrapper349 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 92, __wbg_adapter_52); - return addHeapObject(ret); + imports.wbg.__wbindgen_closure_wrapper341 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 87, __wbg_adapter_54); + return ret; + }; + imports.wbg.__wbindgen_init_externref_table = function() { + const table = wasm.__wbindgen_export_2; + const offset = table.grow(4); + table.set(0, undefined); + table.set(offset + 0, undefined); + table.set(offset + 1, null); + table.set(offset + 2, true); + table.set(offset + 3, false); + ; }; return imports; @@ -883,7 +842,7 @@ function __wbg_finalize_init(instance, module) { cachedUint8ArrayMemory0 = null; - + wasm.__wbindgen_start(); return wasm; } diff --git a/vite/public/pkg/wasmworker_demo_bg.wasm b/vite/public/pkg/wasmworker_demo_bg.wasm index 444f2bf..80720de 100644 Binary files a/vite/public/pkg/wasmworker_demo_bg.wasm and b/vite/public/pkg/wasmworker_demo_bg.wasm differ diff --git a/vite/public/pkg/wasmworker_demo_bg.wasm.d.ts b/vite/public/pkg/wasmworker_demo_bg.wasm.d.ts index 682c45f..a9bafe0 100644 --- a/vite/public/pkg/wasmworker_demo_bg.wasm.d.ts +++ b/vite/public/pkg/wasmworker_demo_bg.wasm.d.ts @@ -1,26 +1,28 @@ /* tslint:disable */ /* eslint-disable */ export const memory: WebAssembly.Memory; -export function __webworker_sort_vec(a: number, b: number, c: number): void; +export function __webworker_sort_vec(a: number, b: number): Array; export function runWorker(): number; export function runPool(): number; export function runParMap(): number; -export function initWorkerPool(a: number): number; export function __wbg_workerpooloptions_free(a: number, b: number): void; -export function __wbg_get_workerpooloptions_path(a: number, b: number): void; +export function __wbg_get_workerpooloptions_path(a: number): Array; export function __wbg_set_workerpooloptions_path(a: number, b: number, c: number): void; export function __wbg_get_workerpooloptions_strategy(a: number): number; export function __wbg_set_workerpooloptions_strategy(a: number, b: number): void; -export function __wbg_get_workerpooloptions_num_workers(a: number, b: number): void; +export function __wbg_get_workerpooloptions_num_workers(a: number): Array; export function __wbg_set_workerpooloptions_num_workers(a: number, b: number, c: number): void; export function workerpooloptions_new(): number; +export function initWorkerPool(a: number): number; export function __wbindgen_malloc(a: number, b: number): number; export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number; export const __wbindgen_export_2: WebAssembly.Table; -export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3f0da974b301f4e(a: number, b: number, c: number): void; -export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1ed3f61ce670585a(a: number, b: number, c: number): void; -export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h36e1010f860e4e87(a: number, b: number, c: number): void; -export function __wbindgen_add_to_stack_pointer(a: number): number; +export const __wbindgen_export_3: WebAssembly.Table; +export function closure36_externref_shim(a: number, b: number, c: number): void; +export function closure76_externref_shim(a: number, b: number, c: number): void; +export function closure86_externref_shim(a: number, b: number, c: number): void; export function __wbindgen_free(a: number, b: number, c: number): void; export function __wbindgen_exn_store(a: number): void; -export function wasm_bindgen__convert__closures__invoke2_mut__h6d1a51fb0f116f48(a: number, b: number, c: number, d: number): void; +export function __externref_table_alloc(): number; +export function closure103_externref_shim(a: number, b: number, c: number, d: number): void; +export function __wbindgen_start(): void; diff --git a/vite/src/components/HelloWorld.vue b/vite/src/components/HelloWorld.vue index ea94549..cc975a5 100644 --- a/vite/src/components/HelloWorld.vue +++ b/vite/src/components/HelloWorld.vue @@ -1,5 +1,15 @@