From a4b2398aba2211ce5901ceb46f73057864bd1707 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Tue, 6 Oct 2026 14:12:03 +0200 Subject: add global registry --- src/z/App/main.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/z/App/main.js (limited to 'src/z/App/main.js') diff --git a/src/z/App/main.js b/src/z/App/main.js new file mode 100644 index 0000000..6251a47 --- /dev/null +++ b/src/z/App/main.js @@ -0,0 +1,39 @@ +const imports = { + object_store: { + process: ObjectStore.processWasm, + }, + console: { + log(buffer, length) { + console.log(ObjectStore.decodeString(buffer, length)) + }, + warn(buffer, length) { + console.warn(ObjectStore.decodeString(buffer, length)) + }, + err(buffer, length) { + console.error(ObjectStore.decodeString(buffer, length)) + }, + debug(buffer, length) { + console.debug(ObjectStore.decodeString(buffer, length)) + }, + } +} + +WebAssembly.instantiateStreaming(fetch("index.wasm"), imports).then( + ({ instance, module }) => { + const is64 = new Uint8Array( + instance.exports.memory.buffer, + instance.exports.bit_length, + 1, + )[0] == 8 + + window.wasm = { + exports: instance.exports, + memory: instance.exports.memory, + is64: is64, + UsizeArray: is64 ? BigUint64Array : Uint32Array, + IsizeArray: is64 ? BigInt64Array : Int32Array, + } + + wasm.exports.run(); + }, +); -- cgit v1.2.3-70-g09d2