fold app/ into src/editor/
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
71863e215c
commit
d72155df4c
10 changed files with 11 additions and 4 deletions
55
src/editor/Builder/www/index.html
Normal file
55
src/editor/Builder/www/index.html
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{[app_name]s}</title>
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="module">
|
||||
import {{mach}} from "./mach.js";
|
||||
import {{sysjs}} from "./mach-sysjs.js";
|
||||
import setupWasmserve from "./wasmserve.js";
|
||||
|
||||
setupWasmserve();
|
||||
|
||||
let imports = {{
|
||||
mach,
|
||||
sysjs,
|
||||
}};
|
||||
|
||||
fetch("{[wasm_path]s}")
|
||||
.then(response => response.arrayBuffer())
|
||||
.then(buffer => WebAssembly.instantiate(buffer, imports))
|
||||
.then(results => results.instance)
|
||||
.then(instance => {{
|
||||
sysjs.init(instance);
|
||||
mach.init(instance);
|
||||
instance.exports.wasmInit();
|
||||
|
||||
let frame = true;
|
||||
let last_update_time = performance.now();
|
||||
let update = function () {{
|
||||
if (!frame) {{
|
||||
instance.exports.wasmDeinit();
|
||||
return;
|
||||
}}
|
||||
if (mach.machHasEvent() ||
|
||||
last_update_time + mach.wait_timeout * 1000 <= performance.now()) {{
|
||||
if (instance.exports.wasmUpdate()) {{
|
||||
instance.exports.wasmDeinit();
|
||||
return;
|
||||
}}
|
||||
last_update_time = performance.now();
|
||||
}}
|
||||
window.requestAnimationFrame(update);
|
||||
}};
|
||||
window.requestAnimationFrame(update);
|
||||
}})
|
||||
.catch(err => console.error(err));
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue