diff --git a/Cargo.lock b/Cargo.lock index a18e08ca..6730de4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1086,6 +1086,29 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-downcast" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dac026d43bcca6e7ce1c0956ba68f59edf6403e8e930a5d891be72c31a44340" +dependencies = [ + "js-sys", + "once_cell", + "wasm-bindgen", + "wasm-bindgen-downcast-macros", +] + +[[package]] +name = "wasm-bindgen-downcast-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.83" @@ -1118,8 +1141,7 @@ checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "wasmer" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4927f95d9f17b9a3b123c99ca9d9d45952a7df1b97826545212d9517e1c54ec3" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "bytes", "cfg-if 1.0.0", @@ -1131,6 +1153,7 @@ dependencies = [ "target-lexicon", "thiserror", "wasm-bindgen", + "wasm-bindgen-downcast", "wasmer-compiler", "wasmer-derive", "wasmer-types", @@ -1141,8 +1164,7 @@ dependencies = [ [[package]] name = "wasmer-compiler" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50749ff89787ebce029e83b77cfb1585c1eb67ff7cb34aaa7ba64ebeb2b474f2" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "backtrace", "cfg-if 1.0.0", @@ -1165,8 +1187,7 @@ dependencies = [ [[package]] name = "wasmer-derive" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19406a021b637c2d46d202a96f15d7d27b2762af7aeeb2ebcb5896b329ab313" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1177,8 +1198,7 @@ dependencies = [ [[package]] name = "wasmer-types" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfa18d5568dec7df1bc92023bee9adcb135a2d59288e080788add89705262b4" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "enum-iterator", "enumset", @@ -1192,8 +1212,7 @@ dependencies = [ [[package]] name = "wasmer-vbus" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c49a4f8e2ff517eb63a9e04329e16f79a6f1281d438c788229bb046076622346" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "thiserror", "wasmer-vfs", @@ -1202,8 +1221,7 @@ dependencies = [ [[package]] name = "wasmer-vfs" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03215f8640183464fb824a6a64fb467db8e189ef22f5ffe744533c073ce7b425" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "slab", "thiserror", @@ -1213,8 +1231,7 @@ dependencies = [ [[package]] name = "wasmer-vm" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2ab5dbf2886cf842f1edfde10d8cbeb687fe2f27a5f7b23b5058bed1696441" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "backtrace", "cc", @@ -1237,8 +1254,7 @@ dependencies = [ [[package]] name = "wasmer-vnet" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "988238083832d04de32e9c06d1ba548f9e45558d50a70ec45dae7ee1741a6f0c" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "bytes", "thiserror", @@ -1248,8 +1264,7 @@ dependencies = [ [[package]] name = "wasmer-wasi" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd64af37eaa01ff9c14df0da7d5b22cbd9b013ceffb5afd02136d0d6b78b0bcd" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "bytes", "cfg-if 1.0.0", @@ -1283,8 +1298,7 @@ dependencies = [ [[package]] name = "wasmer-wasi-types" version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6299be55d7fb5e998b3e765d4918ae6741b87c8645788a5ed246895aecc4d2ce" +source = "git+https://github.com/wasmerio/wasmer?branch=fix-downcasting#d4041463bed13a336ea97a43d8317cb08481ed5a" dependencies = [ "byteorder", "time", diff --git a/Cargo.toml b/Cargo.toml index ad2ad9a8..5d0ce3df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,8 @@ wasmer-vfs = { version = "3.0.2", default-features = false, features = ["mem-fs" [profile.release] lto = true opt-level = 'z' + +[patch.crates-io] +wasmer = { git = "https://github.com/wasmerio/wasmer", default-features = false, features = ["js", "std"], branch = "fix-downcasting" } +wasmer-wasi = { git = "https://github.com/wasmerio/wasmer", default-features = false, features = ["js"], branch = "fix-downcasting" } +wasmer-vfs = { git = "https://github.com/wasmerio/wasmer", default-features = false, features = ["mem-fs"], branch = "fix-downcasting" } diff --git a/pkg/wasmer_wasi_js.d.ts b/pkg/wasmer_wasi_js.d.ts index 4e8f73fe..28d828dd 100644 --- a/pkg/wasmer_wasi_js.d.ts +++ b/pkg/wasmer_wasi_js.d.ts @@ -176,4 +176,79 @@ export class WASI { */ export class WasmerRuntimeError { free(): void; +/** +* @returns {Symbol} +*/ + static __wbgd_downcast_token(): Symbol; +} + +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + +export interface InitOutput { + readonly memory: WebAssembly.Memory; + readonly __wbg_wasmerruntimeerror_free: (a: number) => void; + readonly wasmerruntimeerror___wbgd_downcast_token: () => number; + readonly __wbg_memfs_free: (a: number) => void; + readonly memfs_new: (a: number) => void; + readonly memfs_from_js: (a: number, b: number) => void; + readonly memfs_readDir: (a: number, b: number, c: number, d: number) => void; + readonly memfs_createDir: (a: number, b: number, c: number, d: number) => void; + readonly memfs_removeDir: (a: number, b: number, c: number, d: number) => void; + readonly memfs_removeFile: (a: number, b: number, c: number, d: number) => void; + readonly memfs_rename: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly memfs_metadata: (a: number, b: number, c: number, d: number) => void; + readonly memfs_open: (a: number, b: number, c: number, d: number, e: number) => void; + readonly __wbg_jsvirtualfile_free: (a: number) => void; + readonly jsvirtualfile_lastAccessed: (a: number) => number; + readonly jsvirtualfile_lastModified: (a: number) => number; + readonly jsvirtualfile_createdTime: (a: number) => number; + readonly jsvirtualfile_size: (a: number) => number; + readonly jsvirtualfile_setLength: (a: number, b: number, c: number) => void; + readonly jsvirtualfile_read: (a: number, b: number) => void; + readonly jsvirtualfile_readString: (a: number, b: number) => void; + readonly jsvirtualfile_write: (a: number, b: number, c: number, d: number) => void; + readonly jsvirtualfile_writeString: (a: number, b: number, c: number, d: number) => void; + readonly jsvirtualfile_flush: (a: number, b: number) => void; + readonly jsvirtualfile_seek: (a: number, b: number, c: number) => void; + readonly __wbg_wasi_free: (a: number) => void; + readonly wasi_new: (a: number, b: number) => void; + readonly wasi_fs: (a: number, b: number) => void; + readonly wasi_getImports: (a: number, b: number, c: number) => void; + readonly wasi_instantiate: (a: number, b: number, c: number, d: number) => void; + readonly wasi_start: (a: number, b: number, c: number) => void; + readonly wasi_getStdoutBuffer: (a: number, b: number) => void; + readonly wasi_getStdoutString: (a: number, b: number) => void; + readonly wasi_getStderrBuffer: (a: number, b: number) => void; + readonly wasi_getStderrString: (a: number, b: number) => void; + readonly wasi_setStdinBuffer: (a: number, b: number, c: number, d: number) => void; + readonly wasi_setStdinString: (a: number, b: number, c: number, d: number) => void; + readonly canonical_abi_realloc: (a: number, b: number, c: number, d: number) => number; + readonly canonical_abi_free: (a: number, b: number, c: number) => void; + readonly __wbindgen_malloc: (a: number) => number; + readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; + readonly __wbindgen_export_2: WebAssembly.Table; + readonly __wbindgen_exn_store: (a: number) => void; + readonly __wbindgen_add_to_stack_pointer: (a: number) => number; + readonly __wbindgen_free: (a: number, b: number) => void; } + +export type SyncInitInput = BufferSource | WebAssembly.Module; +/** +* Instantiates the given `module`, which can either be bytes or +* a precompiled `WebAssembly.Module`. +* +* @param {SyncInitInput} module +* +* @returns {InitOutput} +*/ +export function initSync(module: SyncInitInput): InitOutput; + +/** +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and +* for everything else, calls `WebAssembly.instantiate` directly. +* +* @param {InitInput | Promise} module_or_path +* +* @returns {Promise} +*/ +export default function init (module_or_path?: InitInput | Promise): Promise; diff --git a/pkg/wasmer_wasi_js.js b/pkg/wasmer_wasi_js.js index 4f4d3e94..36a8cb8b 100644 --- a/pkg/wasmer_wasi_js.js +++ b/pkg/wasmer_wasi_js.js @@ -1,2 +1,1319 @@ -import * as wasm from "./wasmer_wasi_js_bg.wasm"; -export * from "./wasmer_wasi_js_bg.js"; \ No newline at end of file + +let wasm; + +const heap = new Array(32).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +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; +} + +const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachedUint8Memory0 = new Uint8Array(); + +function getUint8Memory0() { + if (cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +function getStringFromWasm0(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +function dropObject(idx) { + if (idx < 36) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +let WASM_VECTOR_LEN = 0; + +const cachedTextEncoder = new TextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length); + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len); + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3); + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +let cachedInt32Memory0 = new Int32Array(); + +function getInt32Memory0() { + if (cachedInt32Memory0.byteLength === 0) { + cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); + } + return cachedInt32Memory0; +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +let cachedFloat64Memory0 = new Float64Array(); + +function getFloat64Memory0() { + if (cachedFloat64Memory0.byteLength === 0) { + cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); + } + return cachedFloat64Memory0; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} + +function getArrayU8FromWasm0(ptr, len) { + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); +} + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1); + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} +/** +*/ +export class JSVirtualFile { + + static __wrap(ptr) { + const obj = Object.create(JSVirtualFile.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jsvirtualfile_free(ptr); + } + /** + * @returns {bigint} + */ + lastAccessed() { + const ret = wasm.jsvirtualfile_lastAccessed(this.ptr); + return BigInt.asUintN(64, ret); + } + /** + * @returns {bigint} + */ + lastModified() { + const ret = wasm.jsvirtualfile_lastModified(this.ptr); + return BigInt.asUintN(64, ret); + } + /** + * @returns {bigint} + */ + createdTime() { + const ret = wasm.jsvirtualfile_createdTime(this.ptr); + return BigInt.asUintN(64, ret); + } + /** + * @returns {bigint} + */ + size() { + const ret = wasm.jsvirtualfile_size(this.ptr); + return BigInt.asUintN(64, ret); + } + /** + * @param {bigint} new_size + */ + setLength(new_size) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jsvirtualfile_setLength(retptr, this.ptr, new_size); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint8Array} + */ + read() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jsvirtualfile_read(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {string} + */ + readString() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jsvirtualfile_readString(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + var ptr0 = r0; + var len0 = r1; + if (r3) { + ptr0 = 0; len0 = 0; + throw takeObject(r2); + } + return getStringFromWasm0(ptr0, len0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(ptr0, len0); + } + } + /** + * @param {Uint8Array} buf + * @returns {number} + */ + write(buf) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + var ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.jsvirtualfile_write(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + buf.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } + /** + * @param {string} buf + * @returns {number} + */ + writeString(buf) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(buf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jsvirtualfile_writeString(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + */ + flush() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jsvirtualfile_flush(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {number} position + * @returns {number} + */ + seek(position) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jsvirtualfile_seek(retptr, this.ptr, position); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class MemFS { + + static __wrap(ptr) { + const obj = Object.create(MemFS.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_memfs_free(ptr); + } + /** + */ + constructor() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.memfs_new(retptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MemFS.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {any} jso + * @returns {MemFS} + */ + static from_js(jso) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.memfs_from_js(retptr, addHeapObject(jso)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MemFS.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} path + * @returns {Array} + */ + readDir(path) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.memfs_readDir(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} path + */ + createDir(path) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.memfs_createDir(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} path + */ + removeDir(path) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.memfs_removeDir(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} path + */ + removeFile(path) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.memfs_removeFile(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} path + * @param {string} to + */ + rename(path, to) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.memfs_rename(retptr, this.ptr, ptr0, len0, ptr1, len1); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} path + * @returns {object} + */ + metadata(path) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.memfs_metadata(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string} path + * @param {any} options + * @returns {JSVirtualFile} + */ + open(path, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.memfs_open(retptr, this.ptr, ptr0, len0, addHeapObject(options)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return JSVirtualFile.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +*/ +export class WASI { + + static __wrap(ptr) { + const obj = Object.create(WASI.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasi_free(ptr); + } + /** + * @param {WasiConfig} config + */ + constructor(config) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_new(retptr, addHeapObject(config)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return WASI.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {MemFS} + */ + get fs() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_fs(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return MemFS.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {WebAssembly.Module} module + * @returns {object} + */ + getImports(module) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_getImports(retptr, this.ptr, addHeapObject(module)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {any} module_or_instance + * @param {object | undefined} imports + * @returns {WebAssembly.Instance} + */ + instantiate(module_or_instance, imports) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_instantiate(retptr, this.ptr, addHeapObject(module_or_instance), isLikeNone(imports) ? 0 : addHeapObject(imports)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Start the WASI Instance, it returns the status code when calling the start + * function + * @param {WebAssembly.Instance | undefined} instance + * @returns {number} + */ + start(instance) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_start(retptr, this.ptr, isLikeNone(instance) ? 0 : addHeapObject(instance)); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + if (r2) { + throw takeObject(r1); + } + return r0 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Get the stdout buffer + * Note: this method flushes the stdout + * @returns {Uint8Array} + */ + getStdoutBuffer() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_getStdoutBuffer(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Get the stdout data as a string + * Note: this method flushes the stdout + * @returns {string} + */ + getStdoutString() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_getStdoutString(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + var ptr0 = r0; + var len0 = r1; + if (r3) { + ptr0 = 0; len0 = 0; + throw takeObject(r2); + } + return getStringFromWasm0(ptr0, len0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(ptr0, len0); + } + } + /** + * Get the stderr buffer + * Note: this method flushes the stderr + * @returns {Uint8Array} + */ + getStderrBuffer() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_getStderrBuffer(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + if (r3) { + throw takeObject(r2); + } + var v0 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Get the stderr data as a string + * Note: this method flushes the stderr + * @returns {string} + */ + getStderrString() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.wasi_getStderrString(retptr, this.ptr); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + var r2 = getInt32Memory0()[retptr / 4 + 2]; + var r3 = getInt32Memory0()[retptr / 4 + 3]; + var ptr0 = r0; + var len0 = r1; + if (r3) { + ptr0 = 0; len0 = 0; + throw takeObject(r2); + } + return getStringFromWasm0(ptr0, len0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(ptr0, len0); + } + } + /** + * Set the stdin buffer + * @param {Uint8Array} buf + */ + setStdinBuffer(buf) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(buf, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.wasi_setStdinBuffer(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Set the stdin data as a string + * @param {string} input + */ + setStdinString(input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.wasi_setStdinString(retptr, this.ptr, ptr0, len0); + var r0 = getInt32Memory0()[retptr / 4 + 0]; + var r1 = getInt32Memory0()[retptr / 4 + 1]; + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +/** +* A struct representing an aborted instruction execution, with a message +* indicating the cause. +*/ +export class WasmerRuntimeError { + + static __wrap(ptr) { + const obj = Object.create(WasmerRuntimeError.prototype); + obj.ptr = ptr; + + return obj; + } + + __destroy_into_raw() { + const ptr = this.ptr; + this.ptr = 0; + + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmerruntimeerror_free(ptr); + } + /** + * @returns {Symbol} + */ + static __wbgd_downcast_token() { + const ret = wasm.wasmerruntimeerror___wbgd_downcast_token(); + return takeObject(ret); + } +} + +async function 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 getImports() { + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_crypto_e1d53a1d73fb10b8 = function(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_process_038c26bf42b093f8 = function(arg0) { + const ret = getObject(arg0).process; + return addHeapObject(ret); + }; + imports.wbg.__wbg_versions_ab37218d2f0b24a8 = function(arg0) { + const ret = getObject(arg0).versions; + return addHeapObject(ret); + }; + imports.wbg.__wbg_node_080f4b19d15bc1fe = function(arg0) { + const ret = getObject(arg0).node; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_string = function(arg0) { + const ret = typeof(getObject(arg0)) === 'string'; + return ret; + }; + imports.wbg.__wbg_require_78a3dcfbdba9cbce = function() { return handleError(function () { + const ret = module.require; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_168da88779e35f61 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_msCrypto_6e7d3e1f92610cbb = function(arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_newwithlength_f5933855e4f48a19 = function(arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_object = function(arg0) { + const val = getObject(arg0); + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbg_get_57245cc7d7c7619d = function(arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return addHeapObject(ret); + }; + imports.wbg.__wbg_call_97ae9d8645dc388b = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_self_6d479506f72c6a71 = function() { return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_window_f2557cc78490aceb = function() { return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_globalThis_7f206bda628d5286 = function() { return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_global_ba75c50d1cf384f4 = function() { return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbindgen_is_undefined = function(arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbg_newnoargs_b5b063fc6c2f0376 = function(arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_Function_056d5b3aef8aaa85 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Function; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_memory = function() { + const ret = wasm.memory; + return addHeapObject(ret); + }; + imports.wbg.__wbg_buffer_3f3d764d4747d564 = function(arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8c3f0052272a457a = function(arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_set_83db9690f9353e79 = function(arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_9e1ae1900cb0fbd5 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_subarray_58ad4efbb5bcb886 = function(arg0, arg1, arg2) { + const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbindgen_object_drop_ref = function(arg0) { + takeObject(arg0); + }; + imports.wbg.__wbindgen_string_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + }; + imports.wbg.__wbg_instanceof_Module_09da91721979648d = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebAssembly.Module; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_instanceof_Table_aab62205c7444b79 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebAssembly.Table; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_get_19328b9e516e0330 = function() { return handleError(function (arg0, arg1) { + const ret = getObject(arg0).get(arg1 >>> 0); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_instanceof_Memory_f1dc0d9a83a9c8ea = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebAssembly.Memory; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_get_765201544a2b6869 = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_set_bf3f89b92d5a34bf = function() { return handleError(function (arg0, arg1, arg2) { + const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2)); + return ret; + }, arguments) }; + imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len0; + getInt32Memory0()[arg0 / 4 + 0] = ptr0; + }; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + imports.wbg.__wbindgen_rethrow = function(arg0) { + throw takeObject(arg0); + }; + imports.wbg.__wbg_static_accessor_SYMBOL_45d4d15e3c4aeb33 = function() { + const ret = Symbol; + return addHeapObject(ret); + }; + imports.wbg.__wbg_newwithbyteoffsetandlength_d9aa266703cb98be = function(arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_imports_5d97b92618ae2b69 = function(arg0) { + const ret = WebAssembly.Module.imports(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_length_6e3bbe7c8bd4dbd8 = function(arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Global_6ae38baa556a9042 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebAssembly.Global; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_wasmerruntimeerror_new = function(arg0) { + const ret = WasmerRuntimeError.__wrap(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getPrototypeOf_c046822345b14263 = function() { return handleError(function (arg0) { + const ret = Reflect.getPrototypeOf(getObject(arg0)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_constructor_20fd216941fe9866 = function(arg0) { + const ret = getObject(arg0).constructor; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) { + const ret = getObject(arg0) === getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_number_get = function(arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof(obj) === 'number' ? obj : undefined; + getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; + getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); + }; + imports.wbg.__wbindgen_is_symbol = function(arg0) { + const ret = typeof(getObject(arg0)) === 'symbol'; + return ret; + }; + imports.wbg.__wbg_new0_a57059d72c5b7aee = function() { + const ret = new Date(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getTime_cb82adb2556ed13e = function(arg0) { + const ret = getObject(arg0).getTime(); + return ret; + }; + imports.wbg.__wbg_getTimezoneOffset_89bd4275e1ca8341 = function(arg0) { + const ret = getObject(arg0).getTimezoneOffset(); + return ret; + }; + imports.wbg.__wbg_new_0b9bfdd97583284e = function() { + const ret = new Object(); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) { + const ret = BigInt.asUintN(64, arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_getPrototypeOf_ca7be35aca69033c = function(arg0) { + const ret = Object.getPrototypeOf(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_name_da379f055623f0d3 = function(arg0) { + const ret = getObject(arg0).name; + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_8d2af00bc1e329ee = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_1d9a920c6bfc44a8 = function() { + const ret = new Array(); + return addHeapObject(ret); + }; + imports.wbg.__wbg_push_740e4b286702d964 = function(arg0, arg1) { + const ret = getObject(arg0).push(getObject(arg1)); + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function(arg0) { + const v = getObject(arg0); + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + return ret; + }; + imports.wbg.__wbg_isArray_27c46c67f498e15d = function(arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; + }; + imports.wbg.__wbg_entries_65a76a413fc91037 = function(arg0) { + const ret = Object.entries(getObject(arg0)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_instanceof_Instance_b0fc12339921a27e = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof WebAssembly.Instance; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_typeof = function(arg0) { + const ret = typeof getObject(arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_new_1c5d2ff1edfe6d73 = function() { return handleError(function (arg0, arg1) { + const ret = new WebAssembly.Instance(getObject(arg0), getObject(arg1)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_newwithlength_7c42f7e738a9d5d3 = function(arg0) { + const ret = new Array(arg0 >>> 0); + return addHeapObject(ret); + }; + imports.wbg.__wbg_apply_75f7334893eef4ad = function() { return handleError(function (arg0, arg1, arg2) { + const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_instanceof_Object_595a1007518cbea3 = function(arg0) { + let result; + try { + result = getObject(arg0) instanceof Object; + } catch { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbindgen_function_table = function() { + const ret = wasm.__wbindgen_export_2; + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_number_new = function(arg0) { + const ret = arg0; + return addHeapObject(ret); + }; + imports.wbg.__wbg_bind_10dfe70e95d2a480 = function(arg0, arg1, arg2, arg3) { + const ret = getObject(arg0).bind(getObject(arg1), getObject(arg2), getObject(arg3)); + return addHeapObject(ret); + }; + imports.wbg.__wbg_randomFillSync_6894564c2c334c42 = function() { return handleError(function (arg0, arg1, arg2) { + getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); + }, arguments) }; + imports.wbg.__wbg_getRandomValues_805f1c3d65988a5a = function() { return handleError(function (arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); + }, arguments) }; + imports.wbg.__wbg_exports_1f32da4bc6734cea = function(arg0) { + const ret = getObject(arg0).exports; + return addHeapObject(ret); + }; + imports.wbg.__wbg_exports_4db28c393be16bc5 = function(arg0) { + const ret = WebAssembly.Module.exports(getObject(arg0)); + return addHeapObject(ret); + }; + + return imports; +} + +function initMemory(imports, maybe_memory) { + +} + +function finalizeInit(instance, module) { + wasm = instance.exports; + init.__wbindgen_wasm_module = module; + cachedFloat64Memory0 = new Float64Array(); + cachedInt32Memory0 = new Int32Array(); + cachedUint8Memory0 = new Uint8Array(); + + + return wasm; +} + +function initSync(module) { + const imports = getImports(); + + initMemory(imports); + + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + + const instance = new WebAssembly.Instance(module, imports); + + return finalizeInit(instance, module); +} + +async function init(input) { + if (typeof input === 'undefined') { + input = new URL('wasmer_wasi_js_bg.wasm', import.meta.url); + } + const imports = getImports(); + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + initMemory(imports); + + const { instance, module } = await load(await input, imports); + + return finalizeInit(instance, module); +} + +export { initSync } +export default init; diff --git a/pkg/wasmer_wasi_js_bg.wasm b/pkg/wasmer_wasi_js_bg.wasm index 4d4bd71e..e30a4279 100644 Binary files a/pkg/wasmer_wasi_js_bg.wasm and b/pkg/wasmer_wasi_js_bg.wasm differ diff --git a/pkg/wasmer_wasi_js_bg.wasm.d.ts b/pkg/wasmer_wasi_js_bg.wasm.d.ts index 7ff53304..e2dce302 100644 --- a/pkg/wasmer_wasi_js_bg.wasm.d.ts +++ b/pkg/wasmer_wasi_js_bg.wasm.d.ts @@ -2,6 +2,7 @@ /* eslint-disable */ export const memory: WebAssembly.Memory; export function __wbg_wasmerruntimeerror_free(a: number): void; +export function wasmerruntimeerror___wbgd_downcast_token(): number; export function __wbg_memfs_free(a: number): void; export function memfs_new(a: number): void; export function memfs_from_js(a: number, b: number): void;