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