aboutsummaryrefslogtreecommitdiff
path: root/src/z/App/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/z/App/main.js')
-rw-r--r--src/z/App/main.js39
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();
+ },
+);