roxify 1.6.1 → 1.6.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/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import { DataFormatError, decodePngToBinary, encodeBinaryToPng, hasPassphraseInP
6
6
  import { packPathsGenerator, unpackBuffer } from './pack.js';
7
7
  import * as cliProgress from './stub-progress.js';
8
8
  import { encodeWithRustCLI, isRustBinaryAvailable, } from './utils/rust-cli-wrapper.js';
9
- const VERSION = '1.6.1';
9
+ const VERSION = '1.6.2';
10
10
  function getDirectorySize(dirPath) {
11
11
  let totalSize = 0;
12
12
  try {
Binary file
@@ -1,7 +1,8 @@
1
1
  import { existsSync } from 'fs';
2
2
  import { createRequire } from 'module';
3
3
  import { arch, platform } from 'os';
4
- import { join, resolve } from 'path';
4
+ import { dirname, resolve } from 'path';
5
+ import { fileURLToPath } from 'url';
5
6
  function getNativeModule() {
6
7
  let moduleDir;
7
8
  let nativeRequire;
@@ -10,12 +11,13 @@ function getNativeModule() {
10
11
  nativeRequire = require;
11
12
  }
12
13
  else {
13
- moduleDir = process.cwd();
14
+ // ESM: derive module directory from this file's URL and create a require based on it
15
+ moduleDir = dirname(fileURLToPath(import.meta.url));
14
16
  try {
15
17
  nativeRequire = require;
16
18
  }
17
19
  catch {
18
- nativeRequire = createRequire(process.cwd() + '/package.json');
20
+ nativeRequire = createRequire(import.meta.url);
19
21
  }
20
22
  }
21
23
  function getNativePath() {
@@ -39,13 +41,18 @@ function getNativeModule() {
39
41
  if (!target || !ext) {
40
42
  throw new Error(`Unsupported platform: ${currentPlatform}`);
41
43
  }
42
- const prebuiltPath = join(moduleDir, '../../roxify_native.node');
43
- const prebuiltLibPath = join(moduleDir, '../../libroxify_native.node');
44
- const bundlePath = join(moduleDir, '../roxify_native.node');
45
- const bundleLibPath = join(moduleDir, '../libroxify_native.node');
46
- const bundlePathWithTarget = join(moduleDir, `../roxify_native-${target}.node`);
47
- const bundleLibPathWithTarget = join(moduleDir, `../libroxify_native-${target}.node`);
48
- console.debug('[native] moduleDir', moduleDir);
44
+ const targets = targetAlt ? [target, targetAlt] : [target];
45
+ const candidates = [];
46
+ const pushIf = (...paths) => {
47
+ for (const p of paths)
48
+ candidates.push(p);
49
+ };
50
+ // Try multiple locations relative to the compiled JS file (dist),
51
+ // package root and common 'dist' directories used by packaging tools.
52
+ for (const t of targets) {
53
+ pushIf(resolve(moduleDir, `../roxify_native-${t}.node`), resolve(moduleDir, `../libroxify_native-${t}.node`), resolve(moduleDir, `../../roxify_native-${t}.node`), resolve(moduleDir, `../../libroxify_native-${t}.node`), resolve(moduleDir, `../dist/roxify_native-${t}.node`), resolve(moduleDir, `../../dist/roxify_native-${t}.node`));
54
+ }
55
+ pushIf(resolve(moduleDir, '../roxify_native.node'), resolve(moduleDir, '../libroxify_native.node'), resolve(moduleDir, '../../roxify_native.node'), resolve(moduleDir, '../../libroxify_native.node'), resolve(moduleDir, '../dist/roxify_native.node'), resolve(moduleDir, '../../dist/roxify_native.node'));
49
56
  let root = moduleDir && moduleDir !== '.' ? moduleDir : process.cwd();
50
57
  while (root.length > 1 &&
51
58
  !existsSync(resolve(root, 'package.json')) &&
@@ -55,38 +62,13 @@ function getNativeModule() {
55
62
  break;
56
63
  root = parent;
57
64
  }
58
- const bundleNode = resolve(moduleDir, '../roxify_native.node');
59
- const bundleLibNode = resolve(moduleDir, '../libroxify_native.node');
60
- const bundleNodeWithTarget = resolve(moduleDir, `../roxify_native-${target}.node`);
61
- const bundleLibNodeWithTarget = resolve(moduleDir, `../libroxify_native-${target}.node`);
62
- const repoNode = resolve(root, 'roxify_native.node');
63
- const repoLibNode = resolve(root, 'libroxify_native.node');
64
- const repoNodeWithTarget = resolve(root, `roxify_native-${target}.node`);
65
- const repoLibNodeWithTarget = resolve(root, `libroxify_native-${target}.node`);
66
- const targetNode = resolve(root, 'target/release/roxify_native.node');
67
- const targetSo = resolve(root, 'target/release/roxify_native.so');
68
- const targetLibSo = resolve(root, 'target/release/libroxify_native.so');
69
- const nodeModulesNode = resolve(root, 'node_modules/roxify/roxify_native.node');
70
- const nodeModulesNodeWithTarget = resolve(root, `node_modules/roxify/roxify_native-${target}.node`);
71
- const prebuiltNode = resolve(moduleDir, '../../roxify_native.node');
72
- const prebuiltLibNode = resolve(moduleDir, '../../libroxify_native.node');
73
- const prebuiltNodeWithTarget = resolve(moduleDir, `../../roxify_native-${target}.node`);
74
- const prebuiltLibNodeWithTarget = resolve(moduleDir, `../../libroxify_native-${target}.node`);
75
- // Support multiple possible OS triples (e.g. windows-gnu and windows-msvc)
76
- const targets = targetAlt ? [target, targetAlt] : [target];
77
- const candidates = [];
78
65
  for (const t of targets) {
79
- const bundleNodeWithT = resolve(moduleDir, `../roxify_native-${t}.node`);
80
- const bundleLibNodeWithT = resolve(moduleDir, `../libroxify_native-${t}.node`);
81
- const repoNodeWithT = resolve(root, `roxify_native-${t}.node`);
82
- const repoLibNodeWithT = resolve(root, `libroxify_native-${t}.node`);
83
- const nodeModulesNodeWithT = resolve(root, `node_modules/roxify/roxify_native-${t}.node`);
84
- const prebuiltNodeWithT = resolve(moduleDir, `../../roxify_native-${t}.node`);
85
- const prebuiltLibNodeWithT = resolve(moduleDir, `../../libroxify_native-${t}.node`);
86
- candidates.push(bundleLibNodeWithT, bundleNodeWithT, repoLibNodeWithT, repoNodeWithT, nodeModulesNodeWithT, prebuiltLibNodeWithT, prebuiltNodeWithT);
66
+ pushIf(resolve(root, `roxify_native-${t}.node`), resolve(root, `libroxify_native-${t}.node`), resolve(root, `dist/roxify_native-${t}.node`));
87
67
  }
88
- candidates.push(bundleLibNode, bundleNode, repoLibNode, repoNode, targetNode, targetLibSo, targetSo, nodeModulesNode, prebuiltLibNode, prebuiltNode);
89
- for (const c of candidates) {
68
+ pushIf(resolve(root, 'roxify_native.node'), resolve(root, 'libroxify_native.node'), resolve(root, 'dist/roxify_native.node'), resolve(root, 'target/release/roxify_native.node'), resolve(root, 'target/release/libroxify_native.so'), resolve(root, 'target/release/roxify_native.so'), resolve(root, 'node_modules/roxify/roxify_native.node'));
69
+ // Remove duplicates while preserving order
70
+ const uniqueCandidates = [...new Set(candidates)];
71
+ for (const c of uniqueCandidates) {
90
72
  try {
91
73
  if (!existsSync(c))
92
74
  continue;
@@ -96,19 +78,19 @@ function getNativeModule() {
96
78
  if (!existsSync(nodeAlias)) {
97
79
  require('fs').copyFileSync(c, nodeAlias);
98
80
  }
99
- console.debug('[native] using node alias', nodeAlias);
100
81
  return nodeAlias;
101
82
  }
102
83
  catch (e) {
103
84
  return c;
104
85
  }
105
86
  }
106
- console.debug('[native] using path', c);
107
87
  return c;
108
88
  }
109
- catch { }
89
+ catch (e) {
90
+ // ignore errors while checking candidates
91
+ }
110
92
  }
111
- throw new Error(`Native module not found for ${currentPlatform}-${arch()}. Checked: ${candidates.join(' ')}`);
93
+ throw new Error(`Native module not found for ${currentPlatform}-${arch()}. Checked: ${uniqueCandidates.join(' ')}`);
112
94
  }
113
95
  return nativeRequire(getNativePath());
114
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.6.1",
3
+ "version": "1.6.4",
4
4
  "type": "module",
5
5
  "description": "Ultra-lightweight PNG steganography with native Rust acceleration. Encode binary data into PNG images with zstd compression.",
6
6
  "main": "dist/index.js",
@@ -33,11 +33,11 @@
33
33
  "build:all": "npm run build:native && npm run build && npm run build:cli",
34
34
  "build:cross": "node scripts/build-all-platforms.js && npm run build && npm run build:cli",
35
35
  "build:native:fast": "cargo build -p roxify_native --release --lib --no-default-features",
36
- "build:native:quick-release": "FAST_RELEASE=1 cargo build --profile fastdev -p roxify_native --lib --no-default-features",
37
- "build:native:super-fast": "USE_SYSTEM_ZSTD=1 FAST_RELEASE=1 cargo build --profile fastdev -p roxify_native --lib --no-default-features -j 1",
38
- "build:native:low-cpu": "LOW_CPU=1 USE_SYSTEM_ZSTD=1 FAST_RELEASE=1 MAX_JOBS=1 node scripts/build-native-targets.cjs",
36
+ "build:native:quick-release": "cross-env FAST_RELEASE=1 cargo build --profile fastdev -p roxify_native --lib --no-default-features",
37
+ "build:native:super-fast": "cross-env USE_SYSTEM_ZSTD=1 FAST_RELEASE=1 cargo build --profile fastdev -p roxify_native --lib --no-default-features -j 1",
38
+ "build:native:low-cpu": "cross-env LOW_CPU=1 USE_SYSTEM_ZSTD=1 FAST_RELEASE=1 MAX_JOBS=1 node scripts/build-native-targets.cjs",
39
39
  "build:native:targets": "node scripts/build-native-targets.cjs",
40
- "build:native:targets:fast": "FAST_RELEASE=1 node scripts/build-native-targets.cjs",
40
+ "build:native:targets:fast": "cross-env FAST_RELEASE=1 node scripts/build-native-targets.cjs",
41
41
  "build:pkg": "npm run build && npx pkg . --target node18-win-x64 --output dist/rox.exe --compress Brotli --public",
42
42
  "postbuild:native": "node scripts/copy-native.js",
43
43
  "clean:targets": "node scripts/clean-artifacts.js",
@@ -85,6 +85,7 @@
85
85
  "license": "MIT",
86
86
  "devDependencies": {
87
87
  "@types/node": "^22.0.0",
88
+ "cross-env": "^7.0.3",
88
89
  "pkg": "^5.8.1",
89
90
  "typescript": "^5.6.0"
90
91
  },
Binary file
Binary file