Load your interface (includes startup time optimizations):
#+begin_src js :tangle hoot.js
/* file: hoot.js */
var f = window.fetch; window.fetch = (inp, ini) => f(inp,
{credentials: 'include', mode: 'no-cors', ...ini});
window.addEventListener("load", () =>
fetch("hoot.wasm")
.then(r => r.arrayBuffer())
.then(bytes => Scheme.load_main(bytes, {
user_imports: { // mapped via define-foreign
document: {
body() { return document.body; },
createTextNode: Document.prototype
.createTextNode.bind(document)
},
element: {
appendChild(parent, child) {
return parent.appendChild(child);}}}})));
#+end_src
Include =reflect.js= and =hoot.js= from a HTML page:
#+begin_src html :tangle hoot.html
<!DOCTYPE html> <!-- file: hoot.html -->
<html><head><title>Hello Hoot</title>
<script type="text/javascript" src="reflect.js"></script>
<script type="text/javascript" src="hoot.js"></script>
<link rel="preload" as="fetch" href="hoot.wasm"></link>
<link rel="preload" as="fetch" href="wtf8.wasm"></link>
<link rel="preload" as="fetch" href="reflect.wasm"></link>
</head><body><h1>Hoot Test</h1></body></html>
#+end_src
For local testing, hoot provides a minimal webserver:
#+begin_src bash
guix shell guile-hoot guile-next -- \
guile -c '((@ (hoot web-server) serve))'
#+end_src