Skip to content

Commit

Permalink
Get types from WebAssembly import (neat!) (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter authored Apr 18, 2024
1 parent 443b310 commit 83beef2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wasm-demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import { defaultKeymap } from "@codemirror/commands";

const RENDER_SIZE = 512;
async function setup() {
const fidget: any = await import("./pkg").catch(console.error);
const fidget = (await import("./pkg").catch(
console.error,
)) as typeof import("./pkg");

const draw = glInit();
function setScript(text: string) {
let shape = null;
let result = null;
try {
shape = fidget.eval_script(text);
const shapeTree = fidget.eval_script(text);
result = "Ok(..)";
const startTime = performance.now();
shape = fidget.render(shape, RENDER_SIZE);
shape = fidget.render(shapeTree, RENDER_SIZE);
const endTime = performance.now();
document.getElementById("status").textContent =
`Rendered in ${endTime - startTime} ms`;
Expand Down

0 comments on commit 83beef2

Please sign in to comment.