roxify 1.6.0 → 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.4.0';
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,43 +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
- const candidates = [
76
- bundleLibNodeWithTarget,
77
- bundleNodeWithTarget,
78
- bundleLibNode,
79
- bundleNode,
80
- repoLibNodeWithTarget,
81
- repoNodeWithTarget,
82
- repoLibNode,
83
- repoNode,
84
- targetNode,
85
- targetLibSo,
86
- targetSo,
87
- nodeModulesNodeWithTarget,
88
- nodeModulesNode,
89
- prebuiltLibNodeWithTarget,
90
- prebuiltNodeWithTarget,
91
- prebuiltLibNode,
92
- prebuiltNode,
93
- ];
94
- for (const c of candidates) {
65
+ for (const t of targets) {
66
+ pushIf(resolve(root, `roxify_native-${t}.node`), resolve(root, `libroxify_native-${t}.node`), resolve(root, `dist/roxify_native-${t}.node`));
67
+ }
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) {
95
72
  try {
96
73
  if (!existsSync(c))
97
74
  continue;
@@ -101,19 +78,19 @@ function getNativeModule() {
101
78
  if (!existsSync(nodeAlias)) {
102
79
  require('fs').copyFileSync(c, nodeAlias);
103
80
  }
104
- console.debug('[native] using node alias', nodeAlias);
105
81
  return nodeAlias;
106
82
  }
107
83
  catch (e) {
108
84
  return c;
109
85
  }
110
86
  }
111
- console.debug('[native] using path', c);
112
87
  return c;
113
88
  }
114
- catch { }
89
+ catch (e) {
90
+ // ignore errors while checking candidates
91
+ }
115
92
  }
116
- 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(' ')}`);
117
94
  }
118
95
  return nativeRequire(getNativePath());
119
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.6.0",
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",
@@ -14,6 +14,7 @@
14
14
  "roxify_native.node",
15
15
  "libroxify_native.node",
16
16
  "roxify_native-x86_64-pc-windows-gnu.node",
17
+ "roxify_native-x86_64-pc-windows-msvc.node",
17
18
  "roxify_native-x86_64-unknown-linux-gnu.node",
18
19
  "libroxify_native-x86_64-unknown-linux-gnu.node",
19
20
  "README.md",
@@ -32,11 +33,11 @@
32
33
  "build:all": "npm run build:native && npm run build && npm run build:cli",
33
34
  "build:cross": "node scripts/build-all-platforms.js && npm run build && npm run build:cli",
34
35
  "build:native:fast": "cargo build -p roxify_native --release --lib --no-default-features",
35
- "build:native:quick-release": "FAST_RELEASE=1 cargo build --profile fastdev -p roxify_native --lib --no-default-features",
36
- "build:native:super-fast": "USE_SYSTEM_ZSTD=1 FAST_RELEASE=1 cargo build --profile fastdev -p roxify_native --lib --no-default-features -j 1",
37
- "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",
38
39
  "build:native:targets": "node scripts/build-native-targets.cjs",
39
- "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",
40
41
  "build:pkg": "npm run build && npx pkg . --target node18-win-x64 --output dist/rox.exe --compress Brotli --public",
41
42
  "postbuild:native": "node scripts/copy-native.js",
42
43
  "clean:targets": "node scripts/clean-artifacts.js",
@@ -84,6 +85,7 @@
84
85
  "license": "MIT",
85
86
  "devDependencies": {
86
87
  "@types/node": "^22.0.0",
88
+ "cross-env": "^7.0.3",
87
89
  "pkg": "^5.8.1",
88
90
  "typescript": "^5.6.0"
89
91
  },
Binary file