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.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,
}