roxify 1.5.5 → 1.5.7
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
CHANGED
|
@@ -1,54 +1,77 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
1
|
import { arch, platform } from 'os';
|
|
3
|
-
import {
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
const platformAltMap = {
|
|
15
|
-
win32: 'x86_64-pc-windows-msvc',
|
|
16
|
-
};
|
|
17
|
-
const extMap = {
|
|
18
|
-
linux: 'so',
|
|
19
|
-
darwin: 'dylib',
|
|
20
|
-
win32: 'node',
|
|
21
|
-
};
|
|
22
|
-
const currentPlatform = platform();
|
|
23
|
-
const target = platformMap[currentPlatform];
|
|
24
|
-
const targetAlt = platformAltMap[currentPlatform];
|
|
25
|
-
const ext = extMap[currentPlatform];
|
|
26
|
-
if (!target || !ext) {
|
|
27
|
-
throw new Error(`Unsupported platform: ${currentPlatform}`);
|
|
5
|
+
function getNativeModule() {
|
|
6
|
+
let moduleDir;
|
|
7
|
+
let nativeRequire;
|
|
8
|
+
if (typeof __dirname !== 'undefined') {
|
|
9
|
+
// Mode CJS - variables globales disponibles
|
|
10
|
+
moduleDir = __dirname;
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
nativeRequire = require;
|
|
28
13
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
else {
|
|
15
|
+
// Mode ESM - utiliser import.meta.url
|
|
16
|
+
// @ts-ignore - import.meta.url existe en ESM
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
moduleDir = dirname(__filename);
|
|
19
|
+
nativeRequire = createRequire(import.meta.url);
|
|
34
20
|
}
|
|
35
|
-
|
|
21
|
+
function getNativePath() {
|
|
22
|
+
const platformMap = {
|
|
23
|
+
linux: 'x86_64-unknown-linux-gnu',
|
|
24
|
+
darwin: arch() === 'arm64' ? 'aarch64-apple-darwin' : 'x86_64-apple-darwin',
|
|
25
|
+
win32: 'x86_64-pc-windows-gnu',
|
|
26
|
+
};
|
|
27
|
+
const platformAltMap = {
|
|
28
|
+
win32: 'x86_64-pc-windows-msvc',
|
|
29
|
+
};
|
|
30
|
+
const extMap = {
|
|
31
|
+
linux: 'so',
|
|
32
|
+
darwin: 'dylib',
|
|
33
|
+
win32: 'node',
|
|
34
|
+
};
|
|
35
|
+
const currentPlatform = platform();
|
|
36
|
+
const target = platformMap[currentPlatform];
|
|
37
|
+
const targetAlt = platformAltMap[currentPlatform];
|
|
38
|
+
const ext = extMap[currentPlatform];
|
|
39
|
+
if (!target || !ext) {
|
|
40
|
+
throw new Error(`Unsupported platform: ${currentPlatform}`);
|
|
41
|
+
}
|
|
42
|
+
const prebuiltPath = join(moduleDir, '../../libroxify_native.node');
|
|
43
|
+
const bundlePath = join(moduleDir, '../libroxify_native.node');
|
|
44
|
+
const targetPath = join(moduleDir, `../../libroxify_native-${target}.${ext}`);
|
|
45
|
+
const targetAltPath = targetAlt
|
|
46
|
+
? join(moduleDir, `../../libroxify_native-${targetAlt}.${ext}`)
|
|
47
|
+
: null;
|
|
36
48
|
try {
|
|
37
|
-
return
|
|
49
|
+
return nativeRequire.resolve(prebuiltPath);
|
|
38
50
|
}
|
|
39
51
|
catch {
|
|
40
|
-
|
|
52
|
+
try {
|
|
53
|
+
return nativeRequire.resolve(bundlePath);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
41
56
|
try {
|
|
42
|
-
return
|
|
57
|
+
return nativeRequire.resolve(targetPath);
|
|
43
58
|
}
|
|
44
59
|
catch {
|
|
60
|
+
if (targetAltPath) {
|
|
61
|
+
try {
|
|
62
|
+
return nativeRequire.resolve(targetAltPath);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throw new Error(`Native module not found for ${currentPlatform}-${arch()}. ` +
|
|
66
|
+
`Expected: ${prebuiltPath} or ${bundlePath} or ${targetPath} or ${targetAltPath}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
45
69
|
throw new Error(`Native module not found for ${currentPlatform}-${arch()}. ` +
|
|
46
|
-
`Expected: ${prebuiltPath} or ${
|
|
70
|
+
`Expected: ${prebuiltPath} or ${bundlePath} or ${targetPath}`);
|
|
47
71
|
}
|
|
48
72
|
}
|
|
49
|
-
throw new Error(`Native module not found for ${currentPlatform}-${arch()}. ` +
|
|
50
|
-
`Expected: ${prebuiltPath} or ${targetPath}`);
|
|
51
73
|
}
|
|
52
74
|
}
|
|
75
|
+
return nativeRequire(getNativePath());
|
|
53
76
|
}
|
|
54
|
-
export const native =
|
|
77
|
+
export const native = getNativeModule();
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "roxify",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Ultra-lightweight PNG steganography with native Rust acceleration. Encode binary data into PNG images with zstd compression.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"libroxify_native-*.so",
|
|
16
16
|
"libroxify_native-*.dylib",
|
|
17
17
|
"libroxify_native-*.dll",
|
|
18
|
+
"libroxify_native-x86_64-pc-windows-gnu.node",
|
|
19
|
+
"libroxify_native-x86_64-pc-windows-msvc.node",
|
|
18
20
|
"README.md",
|
|
19
21
|
"LICENSE"
|
|
20
22
|
],
|