-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (54 loc) · 1.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<script src="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;
WebAssembly.instantiateStreaming(fetch("test.wasm"), go.importObject).then((result) => {
mod = result.module;
inst = result.instance;
document.getElementById("runButton").disabled = false;
}).catch((err) => {
console.error(err, 'error');
});
async function run() {
console.log( inst,'insts' )
// console.clear();
await go.run(inst);
inst = await WebAssembly.instantiate(mod, go.importObject); // reset instance
}*/
if (!WebAssembly.instantiateStreaming) { // polyfill
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
};
}
let run
(async function() {
const go = new Go()
const { instance } = await WebAssembly.instantiateStreaming(fetch("test.wasm"), go.importObject)
run = go.run(instance)
document.getElementById("runButton").disabled = false;
})()
let printMessage
function displayMessage() {
console.log("Successful")
// printMessage = callback
document.getElementById("runButton").disabled = false
}
</script>
<body>
Heyo World
<button onClick="displayMessage();" id="runButton" disabled>Run</button>
</body>
</html>