Skip to content
Permalink
Browse files

play with creating new HTML component via WebAssembly

  • Loading branch information...
dmitshur committed Jul 8, 2019
1 parent 8a6ef1e commit 3d5a82cb5c3fe4007581c2a9bacf55712241b9e6
Showing with 928 additions and 0 deletions.
  1. +30 −0 264/_data/index.html
  2. +28 −0 264/_data/style.css
  3. +465 −0 264/_data/wasm_exec.js
  4. +87 −0 264/errorhandler.go
  5. +212 −0 264/frontend/main.go
  6. +106 −0 264/main.go
@@ -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.

0 comments on commit 3d5a82c

Please sign in to comment.
You can’t perform that action at this time.