aboutsummaryrefslogtreecommitdiff
path: root/html
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-28 18:38:18 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-28 18:38:18 +0200
commit4dafe0f4a2b197145c3bd70ba56521cbf31130d7 (patch)
treeb2d3efd7199c38200b58d3d97052ce92d06c966f /html
parent3f4c96b24697ac92901f26afdf4f65faddae8b23 (diff)
downloadmuhqs-game-4dafe0f4a2b197145c3bd70ba56521cbf31130d7.tar.gz
muhqs-game-4dafe0f4a2b197145c3bd70ba56521cbf31130d7.zip
add local wasm launcher page for debugging
Diffstat (limited to 'html')
-rw-r--r--html/wasm.html64
1 files changed, 64 insertions, 0 deletions
diff --git a/html/wasm.html b/html/wasm.html
new file mode 100644
index 00000000..7b135308
--- /dev/null
+++ b/html/wasm.html
@@ -0,0 +1,64 @@
+<!doctype html>
+<!--
+Copyright 2018 The Go Authors. All rights reserved.
+Use of this source code is governed by a BSD-style
+license that can be found in the LICENSE file.
+-->
+<html>
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
+ <title>Go wasm</title>
+ <script src="eruda.js"></script>
+ <script>eruda.init();</script>
+</head>
+
+<body>
+ <script src="js/wasm_exec.js"></script>
+ <script>
+ if (!WebAssembly.instantiateStreaming) { // polyfill
+ WebAssembly.instantiateStreaming = async (resp, importObject) => {
+ const source = await (await resp).arrayBuffer();
+ return await WebAssembly.instantiate(source, importObject);
+ };
+ }
+
+ const go = new Go();
+ let mod, inst;
+ let url = new URLSearchParams(window.location.search).get("wasm");
+ if (!url) {
+ // url = "dummy-ui/dummy-ui.wasm";
+ // url = "client/client.wasm";
+ url = "ai-companion.wasm";
+ }
+
+
+ WebAssembly.instantiateStreaming(fetch(url), go.importObject).then((result) => {
+ document.getElementById("wasmName").innerHTML = url;
+ mod = result.module;
+ inst = result.instance;
+ document.getElementById("runButton").disabled = false;
+ }).catch((err) => {
+ console.error(err);
+ });
+
+ async function run() {
+ let wN = document.getElementById("wasmName");
+ let rB = document.getElementById("runButton");
+ document.body.removeChild(wN);
+ document.body.removeChild(rB);
+
+ console.clear();
+ await go.run(inst);
+ }
+ </script>
+ <div style="width:0; height:0; overflow:hidden;">
+ <input id="hiddenInput"></input>
+ </div>
+ <div id="wasmName"></div>
+
+ <button onClick="run();" id="runButton" disabled>Run</button>
+</body>
+
+</html>