hron-wasm 0.4.0 → 0.4.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.
package/hron_wasm.js CHANGED
@@ -1,9 +1,21 @@
1
1
  /* @ts-self-types="./hron_wasm.d.ts" */
2
2
 
3
- import * as wasm from "./hron_wasm_bg.wasm";
4
- import { __wbg_set_wasm } from "./hron_wasm_bg.js";
5
- __wbg_set_wasm(wasm);
6
- wasm.__wbindgen_start();
7
- export {
8
- Schedule, fromCron
9
- } from "./hron_wasm_bg.js";
3
+ import * as imports from "./hron_wasm_bg.js";
4
+ import * as wasmModule from "./hron_wasm_bg.wasm";
5
+
6
+ if (typeof wasmModule.__wbindgen_start === "function") {
7
+ // Bundler environment: the wasm import is already instantiated
8
+ imports.__wbg_set_wasm(wasmModule);
9
+ wasmModule.__wbindgen_start();
10
+ } else {
11
+ // Cloudflare Workers / raw Module environment:
12
+ // import of .wasm gives a WebAssembly.Module, not instantiated exports
13
+ const mod = wasmModule.default ?? wasmModule;
14
+ const instance = new WebAssembly.Instance(mod, {
15
+ "./hron_wasm_bg.js": imports,
16
+ });
17
+ imports.__wbg_set_wasm(instance.exports);
18
+ instance.exports.__wbindgen_start();
19
+ }
20
+
21
+ export { Schedule, fromCron } from "./hron_wasm_bg.js";
package/hron_wasm_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "hron-wasm",
3
3
  "type": "module",
4
4
  "description": "WASM bindings for hron — human-readable cron",
5
- "version": "0.4.0",
5
+ "version": "0.4.2",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",