aboutsummaryrefslogtreecommitdiff
path: root/src/z/App
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-08 19:26:47 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-08 19:26:47 +0200
commit3d0d5d88458112e5cc276f650e02609dc85c5b87 (patch)
tree7b0a48f7f7ef0af82360aa356b88a83b7dcfd699 /src/z/App
parent0260f392c19db7911496172c7d43d1178c6215cb (diff)
juicy event handler
Diffstat (limited to 'src/z/App')
-rw-r--r--src/z/App/main.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/z/App/main.js b/src/z/App/main.js
index 5e0c176..7ac2cdb 100644
--- a/src/z/App/main.js
+++ b/src/z/App/main.js
@@ -18,9 +18,22 @@ const imports = {
}
}
+async function wasm_handle_event(name, event, pass_event) {
+ await wasm_ready;
+
+ if (pass_event) {
+ const id = ObjectStore.generateFreeId();
+ ObjectStore.registerObject(id, event);
+ wasm.exports[name](this["@ptr"], id);
+ ObjectStore.free(event);
+ } else {
+ wasm.exports[name](this["@ptr"]);
+ }
+}
+
const wasm_ready = WebAssembly.instantiateStreaming(fetch("index.wasm"), imports).then(
({ instance, module }) => {
- window.wasm = {
+ wasm = {
exports: instance.exports,
memory: instance.exports.memory,
}