strictjs-runtime 2.0.4 → 2.0.5
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/index.js +8 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import fs from "fs";
|
|
3
2
|
import path from "path";
|
|
4
3
|
import { fileURLToPath } from "url";
|
|
@@ -18,14 +17,19 @@ import initWASM, {
|
|
|
18
17
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
18
|
const __dirname = path.dirname(__filename);
|
|
20
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Initializes StrictJS Runtime
|
|
22
|
+
* - Works in both Node.js and browser
|
|
23
|
+
* - Automatically detects environment and loads WASM correctly
|
|
24
|
+
*/
|
|
21
25
|
export default async function strictInit() {
|
|
22
26
|
if (typeof window === "undefined") {
|
|
23
|
-
// Node.js environment
|
|
27
|
+
// Node.js environment
|
|
24
28
|
const wasmPath = path.resolve(__dirname, "pkg/strictjs_runtime_bg.wasm");
|
|
25
29
|
const wasmBuffer = fs.readFileSync(wasmPath);
|
|
26
30
|
await initWASM(wasmBuffer);
|
|
27
31
|
} else {
|
|
28
|
-
// Browser environment
|
|
32
|
+
// Browser environment
|
|
29
33
|
await initWASM();
|
|
30
34
|
}
|
|
31
35
|
|
|
@@ -42,6 +46,7 @@ export default async function strictInit() {
|
|
|
42
46
|
};
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
// Named exports for direct imports
|
|
45
50
|
export {
|
|
46
51
|
get_memory,
|
|
47
52
|
HeapType,
|