export interface WasmModule { default(): Promise; parse(input: string): string; parse_raw?(input: string): string; reset_engine?(): void; } let wasm: WasmModule | null = null; let loading: Promise | null = null; export function loadWasm(): Promise { if (wasm) return Promise.resolve(wasm); if (loading) return loading; loading = (async () => { // The wasm-bindgen artifacts live in /wasm/ (copied from web/static/wasm). // @ts-expect-error dynamic import of generated wasm-bindgen JS const mod: WasmModule = await import(/* @vite-ignore */ '/wasm/i_plus_plus.js'); await mod.default(); wasm = mod; return mod; })(); return loading; } export function getWasm(): WasmModule | null { return wasm; }