roxify 1.2.1 → 1.2.3

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/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 RoxCompressor
3
+ Copyright (c) 2025 Yohan SANNIER
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
6
+ of this software and associated documentation files (the "Software"), to use,
7
+ modify, merge, publish, distribute, sublicense, and/or sell tools or applications
8
+ that make use of the Software, provided that the Software itself is not copied,
9
+ rebranded, or redistributed as a standalone package under a different name or
10
+ ownership.
11
11
 
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { mkdirSync, readFileSync, statSync, writeFileSync } from 'fs';
4
4
  import { basename, dirname, join, resolve } from 'path';
5
5
  import { DataFormatError, decodePngToBinary, encodeBinaryToPng, IncorrectPassphraseError, listFilesInPng, PassphraseRequiredError, } from './index.js';
6
6
  import { packPaths, unpackBuffer } from './pack.js';
7
- const VERSION = '1.1.9';
7
+ const VERSION = '1.2.3';
8
8
  function showHelp() {
9
9
  console.log(`
10
10
  ROX CLI — Encode/decode binary in PNG
@@ -221,6 +221,8 @@ async function encodeCommand(args) {
221
221
  inputBuffer = readFileSync(resolvedInput);
222
222
  console.log('');
223
223
  displayName = basename(resolvedInput);
224
+ options.includeFileList = true;
225
+ options.fileList = [basename(resolvedInput)];
224
226
  }
225
227
  }
226
228
  Object.assign(options, {
package/dist/index.js CHANGED
@@ -87,7 +87,7 @@ function deltaDecode(data) {
87
87
  }
88
88
  return out;
89
89
  }
90
- async function parallelZstdCompress(payload, level = 22, onProgress) {
90
+ async function parallelZstdCompress(payload, level = 11, onProgress) {
91
91
  const chunkSize = 1024 * 1024 * 1024;
92
92
  if (payload.length <= chunkSize) {
93
93
  if (onProgress)
@@ -245,9 +245,10 @@ export async function optimizePngBuffer(pngBuf, fast = false) {
245
245
  const inPath = join(tmpdir(), `rox_zop_in_${Date.now()}_${Math.random().toString(36).slice(2)}.png`);
246
246
  const outPath = inPath + '.out.png';
247
247
  writeFileSync(inPath, pngBuf);
248
+ const iterations = fast ? 15 : 40;
248
249
  const args = [
249
250
  '-y',
250
- '--iterations=500',
251
+ `--iterations=${iterations}`,
251
252
  '--filters=01234mepb',
252
253
  inPath,
253
254
  outPath,
@@ -1277,7 +1278,7 @@ export async function encodeBinaryToPng(input, opts = {}) {
1277
1278
  opts.onProgress({ phase: 'compress_start', total: payload.length });
1278
1279
  const useDelta = mode !== 'screenshot';
1279
1280
  const deltaEncoded = useDelta ? deltaEncode(payload) : payload;
1280
- payload = await parallelZstdCompress(deltaEncoded, 22, (loaded, total) => {
1281
+ payload = await parallelZstdCompress(deltaEncoded, 11, (loaded, total) => {
1281
1282
  if (opts.onProgress) {
1282
1283
  opts.onProgress({
1283
1284
  phase: 'compress_progress',
@@ -1465,10 +1466,10 @@ export async function encodeBinaryToPng(input, opts = {}) {
1465
1466
  raw: { width, height, channels: 3 },
1466
1467
  })
1467
1468
  .png({
1468
- compressionLevel: 9,
1469
+ compressionLevel: 6,
1469
1470
  palette: false,
1470
- effort: 10,
1471
- adaptiveFiltering: true,
1471
+ effort: 1,
1472
+ adaptiveFiltering: false,
1472
1473
  })
1473
1474
  .toBuffer();
1474
1475
  if (opts.onProgress)
@@ -1476,13 +1477,10 @@ export async function encodeBinaryToPng(input, opts = {}) {
1476
1477
  if (opts.onProgress)
1477
1478
  opts.onProgress({ phase: 'optimizing', loaded: 0, total: 100 });
1478
1479
  let optInterval = null;
1479
- const MIN_OPT_MS = 8000;
1480
- let optStart = Date.now();
1481
1480
  if (opts.onProgress) {
1482
1481
  let optLoaded = 0;
1483
- optStart = Date.now();
1484
1482
  optInterval = setInterval(() => {
1485
- optLoaded = Math.min(optLoaded + 2, 99);
1483
+ optLoaded = Math.min(optLoaded + 5, 95);
1486
1484
  opts.onProgress?.({
1487
1485
  phase: 'optimizing',
1488
1486
  loaded: optLoaded,
@@ -1491,12 +1489,7 @@ export async function encodeBinaryToPng(input, opts = {}) {
1491
1489
  }, 100);
1492
1490
  }
1493
1491
  try {
1494
- const optimizedPromise = optimizePngBuffer(bufScr, !!opts.onProgress);
1495
- const optimized = await optimizedPromise;
1496
- const elapsedOpt = Date.now() - optStart;
1497
- if (elapsedOpt < MIN_OPT_MS) {
1498
- await new Promise((r) => setTimeout(r, MIN_OPT_MS - elapsedOpt));
1499
- }
1492
+ const optimized = await optimizePngBuffer(bufScr, true);
1500
1493
  clearInterval(progressInterval);
1501
1494
  if (optInterval) {
1502
1495
  clearInterval(optInterval);
@@ -1504,18 +1497,13 @@ export async function encodeBinaryToPng(input, opts = {}) {
1504
1497
  }
1505
1498
  if (opts.onProgress)
1506
1499
  opts.onProgress({ phase: 'optimizing', loaded: 100, total: 100 });
1507
- try {
1508
- const verified = await decodePngToBinary(optimized);
1509
- if (verified.buf && verified.buf.equals(input)) {
1510
- progressBar?.stop();
1511
- return optimized;
1512
- }
1513
- }
1514
- catch (e) { }
1515
1500
  progressBar?.stop();
1516
- return bufScr;
1501
+ return optimized;
1517
1502
  }
1518
1503
  catch (e) {
1504
+ clearInterval(progressInterval);
1505
+ if (optInterval)
1506
+ clearInterval(optInterval);
1519
1507
  progressBar?.stop();
1520
1508
  return bufScr;
1521
1509
  }
package/dist/minpng.js CHANGED
@@ -75,7 +75,7 @@ export async function encodeMinPng(rgb, width, height) {
75
75
  transformed.push(g, r, b);
76
76
  }
77
77
  const transformedBuf = Buffer.from(transformed);
78
- const compressed = Buffer.from(await zstdCompress(transformedBuf, 22));
78
+ const compressed = Buffer.from(await zstdCompress(transformedBuf, 11));
79
79
  const header = Buffer.alloc(4 + 1 + 4 + 4);
80
80
  PIXEL_MAGIC.copy(header, 0);
81
81
  header[4] = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Encode binary data into PNG images with Zstd compression and decode them back. Supports CLI and programmatic API (Node.js ESM).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -45,7 +45,6 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@mongodb-js/zstd": "^2.0.1",
48
- "zopflipng-bin": "^1.0.1",
49
48
  "fflate": "^0.7.4",
50
49
  "lzma-purejs": "^0.9.3",
51
50
  "png-chunks-encode": "^1.0.0",
@@ -53,6 +52,12 @@
53
52
  "sharp": "^0.34.5",
54
53
  "cli-progress": "^3.9.1"
55
54
  },
55
+ "optionalDependencies": {
56
+ "zopflipng-bin": "^1.0.1"
57
+ },
58
+ "overrides": {
59
+ "graceful-fs": "^4.2.10"
60
+ },
56
61
  "devDependencies": {
57
62
  "typescript": "^4.9.5",
58
63
  "@types/cli-progress": "^3.9.0"