Skip to main content
Module

x/wasmbuild/lib/wasmbuild.generated.js

Build tool to use Rust code in Deno and the browser.
Go to Latest
File
// @generated file from wasmbuild -- do not edit// deno-lint-ignore-file// deno-fmt-ignore-file// source-hash: 2db7377fc62ca0ff6df7e49f2c22133ba704c7d8let wasm;
const cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true,});
cachedTextDecoder.decode();
let cachedUint8Memory0;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));}
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
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;}
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = new TextEncoder("utf-8");
const encodeString = function (arg, view) { return cachedTextEncoder.encodeInto(arg, view);};
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 passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1); getUint8Memory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr;}
let cachedInt32Memory0;function getInt32Memory0() { if (cachedInt32Memory0.byteLength === 0) { cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); } return cachedInt32Memory0;}
function getObject(idx) { return heap[idx];}
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;}/** * @param {string} name * @param {Uint8Array} wasm_bytes * @returns {any} */export function generate_bindgen(name, wasm_bytes) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0( name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc, ); const len0 = WASM_VECTOR_LEN; const ptr1 = passArray8ToWasm0(wasm_bytes, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; wasm.generate_bindgen(retptr, ptr0, len0, ptr1, len1); 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); }}
const imports = { __wbindgen_placeholder__: { __wbindgen_json_parse: function (arg0, arg1) { const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }, __wbg_new_651776e932b7e9c7: function (arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }, __wbindgen_throw: function (arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }, },};
const wasm_url = new URL("wasmbuild_bg.wasm", import.meta.url);
/** * Decompression callback * * @callback decompressCallback * @param {Uint8Array} compressed * @return {Uint8Array} decompressed */
/** Instantiates an instance of the Wasm module returning its functions. * @remarks It is safe to call this multiple times and once successfully * loaded it will always return a reference to the same object. * @param {decompressCallback=} transform */export async function instantiate(transform) { return (await instantiateWithInstance(transform)).exports;}
let instanceWithExports;let lastLoadPromise;
/** Instantiates an instance of the Wasm module along with its exports. * @remarks It is safe to call this multiple times and once successfully * loaded it will always return a reference to the same object. * @param {decompressCallback=} transform * @returns {Promise<{ * instance: WebAssembly.Instance; * exports: { generate_bindgen: typeof generate_bindgen } * }>} */export function instantiateWithInstance(transform) { if (instanceWithExports != null) { return Promise.resolve(instanceWithExports); } if (lastLoadPromise == null) { lastLoadPromise = (async () => { try { const instance = (await instantiateModule(transform)).instance; wasm = instance.exports; cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); instanceWithExports = { instance, exports: getWasmInstanceExports(), }; return instanceWithExports; } finally { lastLoadPromise = null; } })(); } return lastLoadPromise;}
function getWasmInstanceExports() { return { generate_bindgen };}
/** Gets if the Wasm module has been instantiated. */export function isInstantiated() { return instanceWithExports != null;}
async function instantiateModule(transform) { switch (wasm_url.protocol) { case "file:": { if (typeof Deno !== "object") { throw new Error("file urls are not supported in this environment"); }
if ("permissions" in Deno) { Deno.permissions.request({ name: "read", path: wasm_url }); } const wasmCode = await Deno.readFile(wasm_url); return WebAssembly.instantiate( !transform ? wasmCode : transform(wasmCode), imports, ); } case "https:": case "http:": { if (typeof Deno === "object" && "permissions" in Deno) { Deno.permissions.request({ name: "net", host: wasm_url.host }); } const wasmResponse = await fetch(wasm_url); if (transform) { const wasmCode = new Uint8Array(await wasmResponse.arrayBuffer()); return WebAssembly.instantiate(transform(wasmCode), imports); } if ( wasmResponse.headers.get("content-type")?.toLowerCase().startsWith( "application/wasm", ) ) { return WebAssembly.instantiateStreaming(wasmResponse, imports); } else { return WebAssembly.instantiate( await wasmResponse.arrayBuffer(), imports, ); } } default: throw new Error(`Unsupported protocol: ${wasm_url.protocol}`); }}