Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
play with creating new HTML component via WebAssembly
- Loading branch information
Showing
6 changed files
with
928 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width"> | ||
<link href="/-/fonts/fonts.css" rel="stylesheet" type="text/css"> | ||
<link href="/-/style.css" rel="stylesheet" type="text/css"> | ||
<script src="/-/wasm_exec.js"></script> | ||
<script> | ||
if (!WebAssembly.instantiateStreaming) { // polyfill for Safari :/ | ||
WebAssembly.instantiateStreaming = async (resp, importObject) => { | ||
const source = await (await resp).arrayBuffer(); | ||
return await WebAssembly.instantiate(source, importObject); | ||
}; | ||
} | ||
const go = new Go(); | ||
WebAssembly.instantiateStreaming(fetch("/-/main.wasm"), go.importObject).then((result) => { | ||
go.run(result.instance); | ||
}); | ||
window.addEventListener('keydown', (event) => { | ||
if (event.key !== '®') { | ||
return; | ||
} | ||
WebAssembly.instantiateStreaming(fetch("/-/main.wasm"), go.importObject).then((result) => { | ||
go.run(result.instance); | ||
}); | ||
event.preventDefault(); | ||
}); | ||
</script> | ||
</head> | ||
<body></body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.