roxify 1.6.1 → 1.6.5

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/README.md CHANGED
@@ -374,4 +374,4 @@ Contributions welcome! Please open an issue or PR on GitHub.
374
374
 
375
375
  ## CI / Multi-platform builds
376
376
 
377
- This project runs continuous integration on Linux, Windows and macOS via GitHub Actions. Native modules are built on each platform and attached to the workflow (and release) as artifacts. On releases we also publish platform artifacts to GitHub Releases. For npm publishing, set the `NPM_TOKEN` secret in your repository settings to allow automated publishes on release.
377
+ This project runs continuous integration on Linux and Windows via GitHub Actions. Native modules are built on each platform and attached to the workflow (and release) as artifacts. On releases we also publish platform artifacts to GitHub Releases. For npm publishing, set the `NPM_TOKEN` secret in your repository settings to allow automated publishes on release.
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,18 +11,18 @@ 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() {
22
24
  const platformMap = {
23
25
  linux: 'x86_64-unknown-linux-gnu',
24
- darwin: arch() === 'arm64' ? 'aarch64-apple-darwin' : 'x86_64-apple-darwin',
25
26
  win32: 'x86_64-pc-windows-gnu',
26
27
  };
27
28
  const platformAltMap = {
@@ -29,7 +30,6 @@ function getNativeModule() {
29
30
  };
30
31
  const extMap = {
31
32
  linux: 'so',
32
- darwin: 'dylib',
33
33
  win32: 'node',
34
34
  };
35
35
  const currentPlatform = platform();
@@ -39,13 +39,18 @@ function getNativeModule() {
39
39
  if (!target || !ext) {
40
40
  throw new Error(`Unsupported platform: ${currentPlatform}`);
41
41
  }
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);
42
+ const targets = targetAlt ? [target, targetAlt] : [target];
43
+ const candidates = [];
44
+ const pushIf = (...paths) => {
45
+ for (const p of paths)
46
+ candidates.push(p);
47
+ };
48
+ // Try multiple locations relative to the compiled JS file (dist),
49
+ // package root and common 'dist' directories used by packaging tools.
50
+ for (const t of targets) {
51
+ 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`));
52
+ }
53
+ 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
54
  let root = moduleDir && moduleDir !== '.' ? moduleDir : process.cwd();
50
55
  while (root.length > 1 &&
51
56
  !existsSync(resolve(root, 'package.json')) &&
@@ -55,38 +60,13 @@ function getNativeModule() {
55
60
  break;
56
61
  root = parent;
57
62
  }
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
63
  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);
64
+ pushIf(resolve(root, `roxify_native-${t}.node`), resolve(root, `libroxify_native-${t}.node`), resolve(root, `dist/roxify_native-${t}.node`));
87
65
  }
88
- candidates.push(bundleLibNode, bundleNode, repoLibNode, repoNode, targetNode, targetLibSo, targetSo, nodeModulesNode, prebuiltLibNode, prebuiltNode);
89
- for (const c of candidates) {
66
+ 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'));
67
+ // Remove duplicates while preserving order
68
+ const uniqueCandidates = [...new Set(candidates)];
69
+ for (const c of uniqueCandidates) {
90
70
  try {
91
71
  if (!existsSync(c))
92
72
  continue;
@@ -96,19 +76,19 @@ function getNativeModule() {
96
76
  if (!existsSync(nodeAlias)) {
97
77
  require('fs').copyFileSync(c, nodeAlias);
98
78
  }
99
- console.debug('[native] using node alias', nodeAlias);
100
79
  return nodeAlias;
101
80
  }
102
81
  catch (e) {
103
82
  return c;
104
83
  }
105
84
  }
106
- console.debug('[native] using path', c);
107
85
  return c;
108
86
  }
109
- catch { }
87
+ catch (e) {
88
+ // ignore errors while checking candidates
89
+ }
110
90
  }
111
- throw new Error(`Native module not found for ${currentPlatform}-${arch()}. Checked: ${candidates.join(' ')}`);
91
+ throw new Error(`Native module not found for ${currentPlatform}-${arch()}. Checked: ${uniqueCandidates.join(' ')}`);
112
92
  }
113
93
  return nativeRequire(getNativePath());
114
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.6.1",
3
+ "version": "1.6.5",
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",
@@ -25,19 +25,17 @@
25
25
  "prebuild:pkg": "node scripts/copy-cli-binary.js",
26
26
  "build:native": "cargo build --release --lib",
27
27
  "build:native:linux": "cargo build --release --lib --target x86_64-unknown-linux-gnu",
28
- "build:native:macos-x64": "cargo build --release --lib --target x86_64-apple-darwin",
29
- "build:native:macos-arm": "cargo build --release --lib --target aarch64-apple-darwin",
30
28
  "build:native:windows": "cargo build --release --lib --target x86_64-pc-windows-msvc",
31
29
  "build:cli": "cargo build --release --bin roxify_native && cp target/release/roxify_native dist/roxify-cli",
32
30
  "build:cli:windows": "cargo build --release --bin roxify_native --target x86_64-pc-windows-gnu && node scripts/copy-cli-binary.js",
33
31
  "build:all": "npm run build:native && npm run build && npm run build:cli",
34
32
  "build:cross": "node scripts/build-all-platforms.js && npm run build && npm run build:cli",
35
33
  "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",
34
+ "build:native:quick-release": "cross-env FAST_RELEASE=1 cargo build --profile fastdev -p roxify_native --lib --no-default-features",
35
+ "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",
36
+ "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
37
  "build:native:targets": "node scripts/build-native-targets.cjs",
40
- "build:native:targets:fast": "FAST_RELEASE=1 node scripts/build-native-targets.cjs",
38
+ "build:native:targets:fast": "cross-env FAST_RELEASE=1 node scripts/build-native-targets.cjs",
41
39
  "build:pkg": "npm run build && npx pkg . --target node18-win-x64 --output dist/rox.exe --compress Brotli --public",
42
40
  "postbuild:native": "node scripts/copy-native.js",
43
41
  "clean:targets": "node scripts/clean-artifacts.js",
@@ -85,6 +83,7 @@
85
83
  "license": "MIT",
86
84
  "devDependencies": {
87
85
  "@types/node": "^22.0.0",
86
+ "cross-env": "^7.0.3",
88
87
  "pkg": "^5.8.1",
89
88
  "typescript": "^5.6.0"
90
89
  },
Binary file
Binary file