roxify 1.5.8 → 1.5.9
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/dist/utils/native.js +18 -5
- package/dist/utils/rust-cli-wrapper.js +16 -2
- package/package.json +1 -1
package/dist/utils/native.js
CHANGED
|
@@ -13,11 +13,24 @@ function getNativeModule() {
|
|
|
13
13
|
nativeRequire = require;
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
// Try ESM import.meta.url first (may throw in CJS/bundled contexts), otherwise fallback to CWD
|
|
17
|
+
try {
|
|
18
|
+
// @ts-ignore - import.meta.url exists in proper ESM contexts
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
moduleDir = dirname(__filename);
|
|
21
|
+
nativeRequire = createRequire(import.meta.url);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Fallback (bundled CJS without __dirname): use current working directory
|
|
25
|
+
moduleDir = process.cwd();
|
|
26
|
+
try {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
nativeRequire = require;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
nativeRequire = createRequire(process.cwd());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
21
34
|
}
|
|
22
35
|
function getNativePath() {
|
|
23
36
|
const platformMap = {
|
|
@@ -2,8 +2,22 @@ import { spawn } from 'child_process';
|
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import { dirname, join } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
let moduleDir;
|
|
6
|
+
try {
|
|
7
|
+
// CJS bundlers may provide __dirname; prefer it when available
|
|
8
|
+
if (typeof __dirname !== 'undefined') {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
moduleDir = __dirname;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
// @ts-ignore - import.meta.url exists in ESM
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
moduleDir = dirname(__filename);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
moduleDir = process.cwd();
|
|
20
|
+
}
|
|
7
21
|
function findRustBinary() {
|
|
8
22
|
const candidates = [];
|
|
9
23
|
const binNames = process.platform === 'win32'
|
package/package.json
CHANGED