diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-06 14:12:03 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-06 14:12:03 +0200 |
| commit | a4b2398aba2211ce5901ceb46f73057864bd1707 (patch) | |
| tree | 99c3d277ad991c189bf342238509be59b36b7889 /src/z/App/main.js | |
| parent | dccd1987b418e47b4b82eda3aeaed40be18d9e45 (diff) | |
add global registry
Diffstat (limited to 'src/z/App/main.js')
| -rw-r--r-- | src/z/App/main.js | 39 |
1 files changed, 39 insertions, 0 deletions
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(); + }, +); |