summaryrefslogtreecommitdiff
path: root/embeds/frp-color-picker/propagators.js
blob: fe0034a579b6678cca2bdbc7c26a39c42ed73336 (plain)
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
window.addEventListener("load", async () => {
  try {
    await Scheme.load_main("propagators.wasm", {
      reflect_wasm_dir: "hoot",
      user_imports: {
        window: {
          setTimeout: setTimeout
        },
        document: {
          makeTextNode: Document.prototype.createTextNode.bind(document),
          makeElement: Document.prototype.createElement.bind(document),
          body: () => document.body,
        },
        element: {
          appendChild: (parent, child) => parent.appendChild(child),
          setAttribute: (elem, attr, value) => elem.setAttribute(attr, value),
          getValue: (elem) => elem.value,
          setValue: (elem, val) => elem.value = val,
          replaceWith: (oldElem, newElem) => oldElem.replaceWith(newElem),
          addEventListener: (elem, name, f) => elem.addEventListener(name, f)
        },
      }
    });
  } catch(e) {
    if(e instanceof WebAssembly.CompileError) {
      document.getElementById("wasm-error").hidden = false;
    }
    throw e;
  }
});