strictjs-runtime 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/index.js +15 -34
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,24 +1,11 @@
1
-
2
-
3
1
  import { fileURLToPath } from "url";
4
- import {
5
- StrictNumber,
6
- StrictString,
7
- get_memory,
8
- HeapType,
9
- StrictArray,
10
- StrictForLoop,
11
- StrictFunction,
12
- StrictObject,
13
- Schema
14
- } from "./pkg/strictjs_runtime.js";
2
+ import * as wasmModule from "./pkg/strictjs_runtime.js";
15
3
 
16
4
  // Check if we're in Node.js environment
17
5
  const isNode = typeof process !== 'undefined' &&
18
6
  process.versions != null &&
19
7
  process.versions.node != null;
20
8
 
21
- let initWASM;
22
9
  let wasmInitialized = false;
23
10
 
24
11
  // Dynamic import to handle different environments
@@ -30,40 +17,35 @@ if (isNode) {
30
17
  const __filename = fileURLToPath(import.meta.url);
31
18
  const __dirname = path.dirname(__filename);
32
19
 
33
- initWASM = (await import("./pkg/strictjs_runtime.js")).initWASM;
34
-
35
20
  const wasmPath = path.resolve(__dirname, "pkg/strictjs_runtime_bg.wasm");
36
21
  const wasmBuffer = fs.readFileSync(wasmPath);
37
22
 
38
- await initWASM(wasmBuffer);
23
+ await wasmModule.default(wasmBuffer);
39
24
  wasmInitialized = true;
40
-
41
- } else {
42
- // Browser environment
43
- initWASM = (await import("./pkg/strictjs_runtime.js")).initWASM;
44
25
  }
45
26
 
46
27
  export default async function strictInit() {
47
28
  if (!wasmInitialized && !isNode) {
48
29
  // Initialize WASM for browser
49
- await initWASM();
30
+ await wasmModule.default();
50
31
  wasmInitialized = true;
51
32
  }
52
33
 
53
34
  return {
54
- StrictNumber,
55
- StrictString,
56
- get_memory,
57
- HeapType,
58
- StrictArray,
59
- StrictForLoop,
60
- StrictFunction,
61
- StrictObject,
62
- Schema
35
+ StrictNumber: wasmModule.StrictNumber,
36
+ StrictString: wasmModule.StrictString,
37
+ get_memory: wasmModule.get_memory,
38
+ HeapType: wasmModule.HeapType,
39
+ StrictArray: wasmModule.StrictArray,
40
+ StrictForLoop: wasmModule.StrictForLoop,
41
+ StrictFunction: wasmModule.StrictFunction,
42
+ StrictObject: wasmModule.StrictObject,
43
+ Schema: wasmModule.Schema
63
44
  };
64
45
  }
65
46
 
66
- export {
47
+ // Export all the named exports directly
48
+ export const {
67
49
  StrictNumber,
68
50
  StrictString,
69
51
  get_memory,
@@ -73,5 +55,4 @@ export {
73
55
  StrictFunction,
74
56
  StrictObject,
75
57
  Schema
76
- };
77
-
58
+ } = wasmModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strictjs-runtime",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A lightweight low-level runtime for StrictJS with WebAssembly support.",
5
5
  "main": "index.js",
6
6
  "module": "index.js",