miniray 0.1.3 → 0.1.4
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/esm/node.mjs +18 -2
- package/lib/main.js +18 -2
- package/miniray.wasm +0 -0
- package/package.json +1 -1
package/esm/node.mjs
CHANGED
|
@@ -40,8 +40,15 @@ export async function initialize(options) {
|
|
|
40
40
|
const wasmModule = options.wasmModule;
|
|
41
41
|
|
|
42
42
|
// Default to miniray.wasm in the package directory
|
|
43
|
+
// Use require.resolve to find files within the package, which works
|
|
44
|
+
// regardless of bundling or working directory
|
|
43
45
|
if (!wasmURL && !wasmModule) {
|
|
44
|
-
|
|
46
|
+
try {
|
|
47
|
+
wasmURL = require.resolve('miniray/miniray.wasm');
|
|
48
|
+
} catch {
|
|
49
|
+
// Fallback to relative path for local development
|
|
50
|
+
wasmURL = path.join(__dirname, '..', 'miniray.wasm');
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
_initPromise = _doInitialize(wasmURL, wasmModule);
|
|
@@ -57,7 +64,16 @@ export async function initialize(options) {
|
|
|
57
64
|
|
|
58
65
|
async function _doInitialize(wasmURL, wasmModule) {
|
|
59
66
|
// Load wasm_exec.js - this defines Go globally
|
|
60
|
-
|
|
67
|
+
// Use require.resolve to find files within the package, which works
|
|
68
|
+
// regardless of bundling or working directory
|
|
69
|
+
let wasmExecPath;
|
|
70
|
+
try {
|
|
71
|
+
wasmExecPath = require.resolve('miniray/wasm_exec.js');
|
|
72
|
+
} catch {
|
|
73
|
+
// Fallback to relative path for local development
|
|
74
|
+
wasmExecPath = path.join(__dirname, '..', 'wasm_exec.js');
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
if (!fs.existsSync(wasmExecPath)) {
|
|
62
78
|
throw new Error(`wasm_exec.js not found at ${wasmExecPath}`);
|
|
63
79
|
}
|
package/lib/main.js
CHANGED
|
@@ -36,8 +36,15 @@ async function initialize(options) {
|
|
|
36
36
|
const wasmModule = options.wasmModule;
|
|
37
37
|
|
|
38
38
|
// Default to miniray.wasm in the package directory
|
|
39
|
+
// Use require.resolve to find files within the package, which works
|
|
40
|
+
// regardless of bundling or working directory
|
|
39
41
|
if (!wasmURL && !wasmModule) {
|
|
40
|
-
|
|
42
|
+
try {
|
|
43
|
+
wasmURL = require.resolve('miniray/miniray.wasm');
|
|
44
|
+
} catch {
|
|
45
|
+
// Fallback to relative path for local development
|
|
46
|
+
wasmURL = path.join(__dirname, '..', 'miniray.wasm');
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
_initPromise = _doInitialize(wasmURL, wasmModule);
|
|
@@ -62,7 +69,16 @@ async function _doInitialize(wasmURL, wasmModule) {
|
|
|
62
69
|
globalThis.crypto ??= require('crypto');
|
|
63
70
|
|
|
64
71
|
// Load wasm_exec.js to set up Go runtime
|
|
65
|
-
|
|
72
|
+
// Use require.resolve to find files within the package, which works
|
|
73
|
+
// regardless of bundling or working directory
|
|
74
|
+
let wasmExecPath;
|
|
75
|
+
try {
|
|
76
|
+
wasmExecPath = require.resolve('miniray/wasm_exec.js');
|
|
77
|
+
} catch {
|
|
78
|
+
// Fallback to relative path for local development
|
|
79
|
+
wasmExecPath = path.join(__dirname, '..', 'wasm_exec.js');
|
|
80
|
+
}
|
|
81
|
+
|
|
66
82
|
if (!fs.existsSync(wasmExecPath)) {
|
|
67
83
|
throw new Error(`wasm_exec.js not found at ${wasmExecPath}`);
|
|
68
84
|
}
|
package/miniray.wasm
CHANGED
|
Binary file
|