576 lines
20 KiB
JavaScript
576 lines
20 KiB
JavaScript
/* @ts-self-types="./nvsim.d.ts" */
|
||
|
||
/**
|
||
* In-browser pipeline. Wraps [`Pipeline`] with JS-friendly construction
|
||
* (JSON for `Scene` and `PipelineConfig`) and `Vec<u8>` outputs (raw
|
||
* concatenated [`MagFrame`] bytes — 60 bytes/frame, magic `0xC51A_6E70`).
|
||
*/
|
||
export class WasmPipeline {
|
||
__destroy_into_raw() {
|
||
const ptr = this.__wbg_ptr;
|
||
this.__wbg_ptr = 0;
|
||
WasmPipelineFinalization.unregister(this);
|
||
return ptr;
|
||
}
|
||
free() {
|
||
const ptr = this.__destroy_into_raw();
|
||
wasm.__wbg_wasmpipeline_free(ptr, 0);
|
||
}
|
||
/**
|
||
* nvsim build version (semver from Cargo.toml).
|
||
* @returns {string}
|
||
*/
|
||
static buildVersion() {
|
||
let deferred1_0;
|
||
let deferred1_1;
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
wasm.wasmpipeline_buildVersion(retptr);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
deferred1_0 = r0;
|
||
deferred1_1 = r1;
|
||
return getStringFromWasm0(r0, r1);
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
||
}
|
||
}
|
||
/**
|
||
* Bytes-per-frame for v1 — `60` today; surfaced so the dashboard
|
||
* can advance its parse cursor without re-deriving the layout.
|
||
* @returns {number}
|
||
*/
|
||
static frameBytes() {
|
||
const ret = wasm.wasmpipeline_frameBytes();
|
||
return ret >>> 0;
|
||
}
|
||
/**
|
||
* Magic constant for the `MagFrame` v1 binary record. The dashboard's
|
||
* hex-dump panel highlights these four bytes (`0xC51A_6E70` → `701A6EC5`
|
||
* little-endian) as a sanity check.
|
||
* @returns {number}
|
||
*/
|
||
static frameMagic() {
|
||
const ret = wasm.wasmpipeline_frameMagic();
|
||
return ret >>> 0;
|
||
}
|
||
/**
|
||
* Construct from JSON strings + a `seed` (BigInt-friendly; passed in
|
||
* as `f64` since wasm-bindgen does not yet ergonomically pass `u64`,
|
||
* then bit-cast through `as u64`). The dashboard sends seeds as
|
||
* `Number(seed_hex)` from a 32-bit value to fit cleanly.
|
||
* @param {string} scene_json
|
||
* @param {string} config_json
|
||
* @param {number} seed
|
||
*/
|
||
constructor(scene_json, config_json, seed) {
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
const ptr0 = passStringToWasm0(scene_json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
||
const len0 = WASM_VECTOR_LEN;
|
||
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
||
const len1 = WASM_VECTOR_LEN;
|
||
wasm.wasmpipeline_new(retptr, ptr0, len0, ptr1, len1, seed);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
||
if (r2) {
|
||
throw takeObject(r1);
|
||
}
|
||
this.__wbg_ptr = r0 >>> 0;
|
||
WasmPipelineFinalization.register(this, this.__wbg_ptr, this);
|
||
return this;
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
}
|
||
}
|
||
/**
|
||
* Run `n_samples` of the pipeline and return the concatenated raw
|
||
* `MagFrame` bytes (`n_samples * sensors * 60` bytes). The dashboard
|
||
* parses this into typed records on the main thread.
|
||
* @param {number} n_samples
|
||
* @returns {Uint8Array}
|
||
*/
|
||
run(n_samples) {
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
wasm.wasmpipeline_run(retptr, this.__wbg_ptr, n_samples);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
||
return v1;
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
}
|
||
}
|
||
/**
|
||
* Run + SHA-256 witness in one call. Returns a JS object
|
||
* `{ frames: Uint8Array, witness: Uint8Array }`. Same
|
||
* `(scene, config, seed)` produces byte-identical `witness` across
|
||
* runs, machines, and transports — the regression dashboard pins.
|
||
* @param {number} n_samples
|
||
* @returns {any}
|
||
*/
|
||
runWithWitness(n_samples) {
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
wasm.wasmpipeline_runWithWitness(retptr, this.__wbg_ptr, n_samples);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
||
if (r2) {
|
||
throw takeObject(r1);
|
||
}
|
||
return takeObject(r0);
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
}
|
||
}
|
||
}
|
||
if (Symbol.dispose) WasmPipeline.prototype[Symbol.dispose] = WasmPipeline.prototype.free;
|
||
|
||
/**
|
||
* Expected reference witness for `Proof::REFERENCE_SCENE_JSON @ seed=42,
|
||
* N=256` — the bytes the dashboard's Verify panel compares against.
|
||
* @returns {string}
|
||
*/
|
||
export function expectedReferenceWitnessHex() {
|
||
let deferred1_0;
|
||
let deferred1_1;
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
wasm.expectedReferenceWitnessHex(retptr);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
deferred1_0 = r0;
|
||
deferred1_1 = r1;
|
||
return getStringFromWasm0(r0, r1);
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Hex-encode a 32-byte witness for display.
|
||
* @param {Uint8Array} witness
|
||
* @returns {string}
|
||
*/
|
||
export function hexWitness(witness) {
|
||
let deferred3_0;
|
||
let deferred3_1;
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
const ptr0 = passArray8ToWasm0(witness, wasm.__wbindgen_export3);
|
||
const len0 = WASM_VECTOR_LEN;
|
||
wasm.hexWitness(retptr, ptr0, len0);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
||
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
||
var ptr2 = r0;
|
||
var len2 = r1;
|
||
if (r3) {
|
||
ptr2 = 0; len2 = 0;
|
||
throw takeObject(r2);
|
||
}
|
||
deferred3_0 = ptr2;
|
||
deferred3_1 = len2;
|
||
return getStringFromWasm0(ptr2, len2);
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
wasm.__wbindgen_export2(deferred3_0, deferred3_1, 1);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Convenience: parse the bundled reference scene to JSON. Lets the
|
||
* dashboard's "load reference scene" flow round-trip through the Rust
|
||
* type system instead of duplicating the JSON literal in the JS code.
|
||
* @returns {string}
|
||
*/
|
||
export function referenceSceneJson() {
|
||
let deferred1_0;
|
||
let deferred1_1;
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
wasm.referenceSceneJson(retptr);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
deferred1_0 = r0;
|
||
deferred1_1 = r1;
|
||
return getStringFromWasm0(r0, r1);
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Run the canonical reference pipeline (`Proof::generate`) end-to-end and
|
||
* return the SHA-256 witness as a 32-byte `Uint8Array`. This is the
|
||
* dashboard's source of truth for the Verify-witness panel.
|
||
* @returns {Uint8Array}
|
||
*/
|
||
export function referenceWitness() {
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
wasm.referenceWitness(retptr);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
||
if (r2) {
|
||
throw takeObject(r1);
|
||
}
|
||
return takeObject(r0);
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* One-shot pipeline run that doesn't disturb the dashboard's main
|
||
* pipeline. Used by the Ghost Murmur interactive demo (and any other
|
||
* "run-against-this-scene-please" flow) to ask: given a scene + config,
|
||
* what does the NV sensor recover at the origin?
|
||
*
|
||
* Returns a JS object:
|
||
* ```js
|
||
* {
|
||
* bRecoveredT: [number, number, number], // recovered B (Tesla)
|
||
* bMagT: number, // |B| (Tesla)
|
||
* noiseFloorPtSqrtHz: number, // δB pT/√Hz from this config
|
||
* sigmaPt: [number, number, number], // per-axis 1σ noise estimate (pT)
|
||
* nFrames: number, // samples actually run
|
||
* witnessHex: string // SHA-256 witness for this run
|
||
* }
|
||
* ```
|
||
* @param {string} scene_json
|
||
* @param {string} config_json
|
||
* @param {number} seed
|
||
* @param {number} n_samples
|
||
* @returns {any}
|
||
*/
|
||
export function runTransient(scene_json, config_json, seed, n_samples) {
|
||
try {
|
||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||
const ptr0 = passStringToWasm0(scene_json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
||
const len0 = WASM_VECTOR_LEN;
|
||
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
||
const len1 = WASM_VECTOR_LEN;
|
||
wasm.runTransient(retptr, ptr0, len0, ptr1, len1, seed, n_samples);
|
||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
||
if (r2) {
|
||
throw takeObject(r1);
|
||
}
|
||
return takeObject(r0);
|
||
} finally {
|
||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||
}
|
||
}
|
||
|
||
function __wbg_get_imports() {
|
||
const import0 = {
|
||
__proto__: null,
|
||
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||
},
|
||
__wbg_length_550d8a396009cd38: function(arg0) {
|
||
const ret = getObject(arg0).length;
|
||
return ret;
|
||
},
|
||
__wbg_length_ea16607d7b61445b: function(arg0) {
|
||
const ret = getObject(arg0).length;
|
||
return ret;
|
||
},
|
||
__wbg_new_ab79df5bd7c26067: function() {
|
||
const ret = new Object();
|
||
return addHeapObject(ret);
|
||
},
|
||
__wbg_new_with_length_825018a1616e9e55: function(arg0) {
|
||
const ret = new Uint8Array(arg0 >>> 0);
|
||
return addHeapObject(ret);
|
||
},
|
||
__wbg_new_with_length_eae667475c36c4e4: function(arg0) {
|
||
const ret = new Float64Array(arg0 >>> 0);
|
||
return addHeapObject(ret);
|
||
},
|
||
__wbg_set_636d1e3e4286e068: function(arg0, arg1, arg2) {
|
||
getObject(arg0).set(getArrayF64FromWasm0(arg1, arg2));
|
||
},
|
||
__wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
|
||
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
||
return ret;
|
||
}, arguments); },
|
||
__wbg_set_8c0b3ffcf05d61c2: function(arg0, arg1, arg2) {
|
||
getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));
|
||
},
|
||
__wbindgen_cast_0000000000000001: function(arg0) {
|
||
// Cast intrinsic for `F64 -> Externref`.
|
||
const ret = arg0;
|
||
return addHeapObject(ret);
|
||
},
|
||
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
||
// Cast intrinsic for `Ref(String) -> Externref`.
|
||
const ret = getStringFromWasm0(arg0, arg1);
|
||
return addHeapObject(ret);
|
||
},
|
||
__wbindgen_object_drop_ref: function(arg0) {
|
||
takeObject(arg0);
|
||
},
|
||
};
|
||
return {
|
||
__proto__: null,
|
||
"./nvsim_bg.js": import0,
|
||
};
|
||
}
|
||
|
||
const WasmPipelineFinalization = (typeof FinalizationRegistry === 'undefined')
|
||
? { register: () => {}, unregister: () => {} }
|
||
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpipeline_free(ptr >>> 0, 1));
|
||
|
||
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 dropObject(idx) {
|
||
if (idx < 1028) return;
|
||
heap[idx] = heap_next;
|
||
heap_next = idx;
|
||
}
|
||
|
||
function getArrayF64FromWasm0(ptr, len) {
|
||
ptr = ptr >>> 0;
|
||
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
||
}
|
||
|
||
function getArrayU8FromWasm0(ptr, len) {
|
||
ptr = ptr >>> 0;
|
||
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
||
}
|
||
|
||
let cachedDataViewMemory0 = null;
|
||
function getDataViewMemory0() {
|
||
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
||
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
||
}
|
||
return cachedDataViewMemory0;
|
||
}
|
||
|
||
let cachedFloat64ArrayMemory0 = null;
|
||
function getFloat64ArrayMemory0() {
|
||
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
||
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
||
}
|
||
return cachedFloat64ArrayMemory0;
|
||
}
|
||
|
||
function getStringFromWasm0(ptr, len) {
|
||
ptr = ptr >>> 0;
|
||
return decodeText(ptr, len);
|
||
}
|
||
|
||
let cachedUint8ArrayMemory0 = null;
|
||
function getUint8ArrayMemory0() {
|
||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||
}
|
||
return cachedUint8ArrayMemory0;
|
||
}
|
||
|
||
function getObject(idx) { return heap[idx]; }
|
||
|
||
function handleError(f, args) {
|
||
try {
|
||
return f.apply(this, args);
|
||
} catch (e) {
|
||
wasm.__wbindgen_export(addHeapObject(e));
|
||
}
|
||
}
|
||
|
||
let heap = new Array(1024).fill(undefined);
|
||
heap.push(undefined, null, true, false);
|
||
|
||
let heap_next = heap.length;
|
||
|
||
function passArray8ToWasm0(arg, malloc) {
|
||
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
||
getUint8ArrayMemory0().set(arg, ptr / 1);
|
||
WASM_VECTOR_LEN = arg.length;
|
||
return ptr;
|
||
}
|
||
|
||
function passStringToWasm0(arg, malloc, realloc) {
|
||
if (realloc === undefined) {
|
||
const buf = cachedTextEncoder.encode(arg);
|
||
const ptr = malloc(buf.length, 1) >>> 0;
|
||
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
||
WASM_VECTOR_LEN = buf.length;
|
||
return ptr;
|
||
}
|
||
|
||
let len = arg.length;
|
||
let ptr = malloc(len, 1) >>> 0;
|
||
|
||
const mem = getUint8ArrayMemory0();
|
||
|
||
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, 1) >>> 0;
|
||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
||
const ret = cachedTextEncoder.encodeInto(arg, view);
|
||
|
||
offset += ret.written;
|
||
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
||
}
|
||
|
||
WASM_VECTOR_LEN = offset;
|
||
return ptr;
|
||
}
|
||
|
||
function takeObject(idx) {
|
||
const ret = getObject(idx);
|
||
dropObject(idx);
|
||
return ret;
|
||
}
|
||
|
||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||
cachedTextDecoder.decode();
|
||
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
||
let numBytesDecoded = 0;
|
||
function decodeText(ptr, len) {
|
||
numBytesDecoded += len;
|
||
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
||
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||
cachedTextDecoder.decode();
|
||
numBytesDecoded = len;
|
||
}
|
||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
||
}
|
||
|
||
const cachedTextEncoder = new TextEncoder();
|
||
|
||
if (!('encodeInto' in cachedTextEncoder)) {
|
||
cachedTextEncoder.encodeInto = function (arg, view) {
|
||
const buf = cachedTextEncoder.encode(arg);
|
||
view.set(buf);
|
||
return {
|
||
read: arg.length,
|
||
written: buf.length
|
||
};
|
||
};
|
||
}
|
||
|
||
let WASM_VECTOR_LEN = 0;
|
||
|
||
let wasmModule, wasm;
|
||
function __wbg_finalize_init(instance, module) {
|
||
wasm = instance.exports;
|
||
wasmModule = module;
|
||
cachedDataViewMemory0 = null;
|
||
cachedFloat64ArrayMemory0 = null;
|
||
cachedUint8ArrayMemory0 = null;
|
||
return wasm;
|
||
}
|
||
|
||
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) {
|
||
const validResponse = module.ok && expectedResponseType(module.type);
|
||
|
||
if (validResponse && 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 expectedResponseType(type) {
|
||
switch (type) {
|
||
case 'basic': case 'cors': case 'default': return true;
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function initSync(module) {
|
||
if (wasm !== undefined) return wasm;
|
||
|
||
|
||
if (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();
|
||
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 (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 (module_or_path === undefined) {
|
||
module_or_path = new URL('nvsim_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);
|
||
}
|
||
|
||
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
||
|
||
return __wbg_finalize_init(instance, module);
|
||
}
|
||
|
||
export { initSync, __wbg_init as default };
|