ironmark 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/wasm/web.js CHANGED
@@ -1,30 +1,31 @@
1
- import {
2
- __wbg_set_wasm,
3
- parse as wasmParse,
4
- parseToAst as wasmParseToAst,
5
- } from "./pkg/ironmark_bg.js";
1
+ import * as wasmGlue from "./pkg/ironmark_bg.js";
6
2
  import { createParse, createParseToAst } from "./shared.js";
7
3
 
8
4
  let initialized = false;
9
5
 
10
6
  export async function init(input) {
11
7
  if (initialized) return;
8
+ const imports = { "./ironmark_bg.js": wasmGlue };
12
9
 
13
10
  const url =
14
11
  input instanceof URL || typeof input === "string"
15
12
  ? input
16
13
  : new URL("./pkg/ironmark_bg.wasm", import.meta.url);
17
14
 
18
- const { instance } =
15
+ const instantiateResult =
19
16
  typeof input === "object" && input instanceof WebAssembly.Module
20
- ? await WebAssembly.instantiate(input, {})
17
+ ? await WebAssembly.instantiate(input, imports)
21
18
  : typeof WebAssembly.instantiateStreaming === "function"
22
- ? await WebAssembly.instantiateStreaming(fetch(url), {})
23
- : await WebAssembly.instantiate(await fetch(url).then((r) => r.arrayBuffer()), {});
19
+ ? await WebAssembly.instantiateStreaming(fetch(url), imports)
20
+ : await WebAssembly.instantiate(await fetch(url).then((r) => r.arrayBuffer()), imports);
21
+ const instance =
22
+ instantiateResult instanceof WebAssembly.Instance
23
+ ? instantiateResult
24
+ : instantiateResult.instance;
24
25
 
25
- __wbg_set_wasm(instance.exports);
26
+ wasmGlue.__wbg_set_wasm(instance.exports);
26
27
  initialized = true;
27
28
  }
28
29
 
29
- export const parse = createParse(wasmParse);
30
- export const parseToAst = createParseToAst(wasmParseToAst);
30
+ export const parse = createParse(wasmGlue.parse);
31
+ export const parseToAst = createParseToAst(wasmGlue.parseToAst);