From 95b85544fe62d49eab8e81e3b76eef1ff7f027ea Mon Sep 17 00:00:00 2001 From: Neil Gershenfeld <gersh@cba.mit.edu> Date: Thu, 26 Dec 2024 11:57:26 -0500 Subject: [PATCH] wip --- Rust/wasmpi/web/dist/package.json | 15 +++ Rust/wasmpi/web/dist/wasmpi.d.ts | 35 ++++++ Rust/wasmpi/web/dist/wasmpi.js | 136 +++++++++++++++++++++++ Rust/wasmpi/web/dist/wasmpi_bg.wasm | Bin 0 -> 1406 bytes Rust/wasmpi/web/dist/wasmpi_bg.wasm.d.ts | 7 ++ 5 files changed, 193 insertions(+) create mode 100644 Rust/wasmpi/web/dist/package.json create mode 100644 Rust/wasmpi/web/dist/wasmpi.d.ts create mode 100644 Rust/wasmpi/web/dist/wasmpi.js create mode 100644 Rust/wasmpi/web/dist/wasmpi_bg.wasm create mode 100644 Rust/wasmpi/web/dist/wasmpi_bg.wasm.d.ts diff --git a/Rust/wasmpi/web/dist/package.json b/Rust/wasmpi/web/dist/package.json new file mode 100644 index 0000000..12bfb03 --- /dev/null +++ b/Rust/wasmpi/web/dist/package.json @@ -0,0 +1,15 @@ +{ + "name": "wasmpi", + "type": "module", + "version": "0.1.0", + "files": [ + "wasmpi_bg.wasm", + "wasmpi.js", + "wasmpi.d.ts" + ], + "main": "wasmpi.js", + "types": "wasmpi.d.ts", + "sideEffects": [ + "./snippets/*" + ] +} \ No newline at end of file diff --git a/Rust/wasmpi/web/dist/wasmpi.d.ts b/Rust/wasmpi/web/dist/wasmpi.d.ts new file mode 100644 index 0000000..59be2b8 --- /dev/null +++ b/Rust/wasmpi/web/dist/wasmpi.d.ts @@ -0,0 +1,35 @@ +/* tslint:disable */ +/* eslint-disable */ +export function rust_serial_pi(npts: number): number; +export function rust_serial_map_pi(npts: number): number; + +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + +export interface InitOutput { + readonly memory: WebAssembly.Memory; + readonly rust_serial_pi: (a: number) => number; + readonly rust_serial_map_pi: (a: number) => number; + readonly __wbindgen_export_0: WebAssembly.Table; + readonly __wbindgen_start: () => void; +} + +export type SyncInitInput = BufferSource | WebAssembly.Module; +/** +* Instantiates the given `module`, which can either be bytes or +* a precompiled `WebAssembly.Module`. +* +* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. +* +* @returns {InitOutput} +*/ +export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; + +/** +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and +* for everything else, calls `WebAssembly.instantiate` directly. +* +* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. +* +* @returns {Promise<InitOutput>} +*/ +export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>; diff --git a/Rust/wasmpi/web/dist/wasmpi.js b/Rust/wasmpi/web/dist/wasmpi.js new file mode 100644 index 0000000..3fffffa --- /dev/null +++ b/Rust/wasmpi/web/dist/wasmpi.js @@ -0,0 +1,136 @@ +let wasm; + +/** + * @param {number} npts + * @returns {number} + */ +export function rust_serial_pi(npts) { + const ret = wasm.rust_serial_pi(npts); + return ret; +} + +/** + * @param {number} npts + * @returns {number} + */ +export function rust_serial_map_pi(npts) { + const ret = wasm.rust_serial_map_pi(npts); + return ret; +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +function __wbg_get_imports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_init_externref_table = function() { + const table = wasm.__wbindgen_export_0; + 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; +} + +function __wbg_init_memory(imports, memory) { + +} + +function __wbg_finalize_init(instance, module) { + wasm = instance.exports; + __wbg_init.__wbindgen_wasm_module = module; + + + wasm.__wbindgen_start(); + return wasm; +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + + if (typeof module !== 'undefined') { + if (Object.getPrototypeOf(module) === Object.prototype) { + ({module} = module) + } else { + console.warn('using deprecated parameters for `initSync()`; pass a single object instead') + } + } + + const imports = __wbg_get_imports(); + + __wbg_init_memory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(module_or_path) { + if (wasm !== undefined) return wasm; + + + if (typeof module_or_path !== 'undefined') { + if (Object.getPrototypeOf(module_or_path) === Object.prototype) { + ({module_or_path} = module_or_path) + } else { + console.warn('using deprecated parameters for the initialization function; pass a single object instead') + } + } + + if (typeof module_or_path === 'undefined') { + module_or_path = new URL('wasmpi_bg.wasm', import.meta.url); + } + const imports = __wbg_get_imports(); + + if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) { + module_or_path = fetch(module_or_path); + } + + __wbg_init_memory(imports); + + const { instance, module } = await __wbg_load(await module_or_path, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync }; +export default __wbg_init; diff --git a/Rust/wasmpi/web/dist/wasmpi_bg.wasm b/Rust/wasmpi/web/dist/wasmpi_bg.wasm new file mode 100644 index 0000000000000000000000000000000000000000..0747a4eade0b7998bae8411a246e39e25b5382f9 GIT binary patch literal 1406 zcmZQbEY4+QU|?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wm|Iv_SXvrb8d@4z8e5uJnp&D!np;{}S~65~78K>DlqRPZ6*F<<B<7`;CZ?w{ zvILbDmoV@Y6y+zU78j?c=q6P%vx1UgvaF$=g|VK2f`+9*lCf!`nUS%Ak%5tkuA!l> zk(nl2d16jcX)&9Do{_Ph5l?wyajq`3=o11ZSxZX=4Fi+pM6)zwlSEAhPyUj`qV&{~ z__Wl-lG38oVis-w+){9%sGFXXpOlzWtj$rJnVzScT2Z3SUzD1bT9lfXoT^(=S&&++ Q&6Qi4Q<7Phm{Xbx03ozHZ2$lO literal 0 HcmV?d00001 diff --git a/Rust/wasmpi/web/dist/wasmpi_bg.wasm.d.ts b/Rust/wasmpi/web/dist/wasmpi_bg.wasm.d.ts new file mode 100644 index 0000000..1969a34 --- /dev/null +++ b/Rust/wasmpi/web/dist/wasmpi_bg.wasm.d.ts @@ -0,0 +1,7 @@ +/* tslint:disable */ +/* eslint-disable */ +export const memory: WebAssembly.Memory; +export const rust_serial_pi: (a: number) => number; +export const rust_serial_map_pi: (a: number) => number; +export const __wbindgen_export_0: WebAssembly.Table; +export const __wbindgen_start: () => void; -- GitLab