roxify 1.13.9 → 1.14.0

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
@@ -3,7 +3,7 @@ import { readdirSync, readFileSync, statSync, writeFileSync } from 'fs';
3
3
  import { open } from 'fs/promises';
4
4
  import { basename, dirname, join, resolve } from 'path';
5
5
  import * as cliProgress from './stub-progress.js';
6
- import { decodeWithRustCLI, encodeWithRustCLI, havepassphraseWithRustCLI, isRustBinaryAvailable, listWithRustCLI, } from './utils/rust-cli-wrapper.js';
6
+ import { encodeWithRustCLI, havepassphraseWithRustCLI, isRustBinaryAvailable, listWithRustCLI, } from './utils/rust-cli-wrapper.js';
7
7
  async function loadJsEngine() {
8
8
  const indexMod = await import('./index.js');
9
9
  const packMod = await import('./pack.js');
@@ -20,7 +20,7 @@ async function loadJsEngine() {
20
20
  VFSIndexEntry: undefined,
21
21
  };
22
22
  }
23
- const VERSION = '1.13.9';
23
+ const VERSION = '1.14.0';
24
24
  function getDirectorySize(dirPath) {
25
25
  let totalSize = 0;
26
26
  try {
@@ -591,24 +591,33 @@ async function decodeCommand(args) {
591
591
  }
592
592
  const resolvedInput = resolve(inputPath);
593
593
  const resolvedOutput = parsed.output || outputPath || '.';
594
- if (!isRustBinaryAvailable()) {
595
- console.error('Error: Rust decoder binary not found');
596
- process.exit(1);
597
- }
598
594
  try {
599
595
  console.log(' ');
600
596
  console.log('Decoding... (Using native Rust decoder)\n');
601
597
  const startTime = Date.now();
602
598
  const decodeBar = new cliProgress.SingleBar({ format: ' {bar} {percentage}% | {step} | {elapsed}s' }, cliProgress.Presets.shades_classic);
603
599
  decodeBar.start(100, 0, { step: 'Decoding', elapsed: '0' });
604
- await decodeWithRustCLI(resolvedInput, resolvedOutput, parsed.passphrase, parsed.files, parsed.dict, parsed.ramBudgetMb, (current, total, step) => {
605
- const pct = total > 0 ? Math.floor((current / total) * 100) : 0;
606
- const elapsed = Math.floor((Date.now() - startTime) / 1000);
607
- decodeBar.update(Math.min(pct, 99), {
608
- step: step || 'Decoding',
609
- elapsed: String(elapsed),
610
- });
611
- });
600
+ const js = await loadJsEngine();
601
+ const result = await js.decodePngToBinary(readFileSync(resolvedInput));
602
+ if (result.files && result.files.length > 0) {
603
+ const outputDir = resolve(resolvedOutput);
604
+ for (const file of result.files) {
605
+ const dest = join(outputDir, file.path);
606
+ const parent = dirname(dest);
607
+ try {
608
+ await import('fs/promises').then(({ mkdir }) => mkdir(parent, { recursive: true }));
609
+ }
610
+ catch { }
611
+ writeFileSync(dest, file.buf);
612
+ }
613
+ }
614
+ else if (result.buf) {
615
+ const outputFile = resolvedOutput === '.' ? join(process.cwd(), result.meta?.name || basename(resolvedInput).replace(/\.[^.]+$/, '')) : resolvedOutput;
616
+ writeFileSync(outputFile, result.buf);
617
+ }
618
+ else {
619
+ throw new Error('Decoded result is empty');
620
+ }
612
621
  const decodeTime = Date.now() - startTime;
613
622
  decodeBar.update(100, { step: 'done', elapsed: String(Math.floor(decodeTime / 1000)) });
614
623
  decodeBar.stop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.13.9",
3
+ "version": "1.14.0",
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",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "build": "tsc",
23
- "bundle": "esbuild src/index.ts --bundle --platform=node --target=node18 --outfile=dist/index.js --format=esm --minify && esbuild src/cli.ts --bundle --platform=node --target=node18 --outfile=dist/cli.js --format=esm --minify && tsc --emitDeclarationOnly --declaration --declarationDir dist",
23
+ "bundle": "esbuild src/cli.ts --bundle --platform=node --target=node18 --outfile=dist/cli.js --format=esm --minify --external:./index.js --external:./pack.js && tsc --emitDeclarationOnly --declaration --declarationDir dist",
24
24
  "prebuild:pkg": "node scripts/copy-cli-binary.js",
25
25
  "build:native": "cargo build --release --lib",
26
26
  "build:native:linux": "cargo build --release --lib --target x86_64-unknown-linux-gnu",
@@ -42,7 +42,7 @@
42
42
  "clean:targets": "node scripts/clean-artifacts.js",
43
43
  "release:prepare": "npm run build && npm run build:native:targets && node scripts/prepare-release.cjs",
44
44
  "release:github": "npm run release:prepare && node scripts/create-gh-release.cjs",
45
- "package:prepare": "npm run bundle && npm run build:native:targets && node scripts/pack-npm.cjs",
45
+ "package:prepare": "npm run build && npm run bundle && npm run build:native:targets && node scripts/pack-npm.cjs",
46
46
  "publish:npm": "npm run package:prepare && echo 'Run npm publish --access public'",
47
47
  "release:flow": "node scripts/release-flow.cjs",
48
48
  "release:flow:auto": "AUTO_PUBLISH=1 node scripts/release-flow.cjs",