7zip-native 0.0.12 → 0.0.14

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
@@ -90,6 +90,7 @@ Each entry includes:
90
90
  | --- | --- | --- |
91
91
  | `id` | `number` | Stable ID within this opened archive |
92
92
  | `path` | `string` | Entry path, using `/` separators |
93
+ | `extractedPath` | `string` | Relative output path after platform-specific filename normalization; Windows-invalid characters are replaced |
93
94
  | `size` | `bigint` | Uncompressed size |
94
95
  | `compressedSize` | `bigint` | Compressed size |
95
96
  | `isDirectory` | `boolean` | Whether the entry is a directory |
package/dist/index.cjs CHANGED
@@ -99,6 +99,11 @@ function sanitizeOutputPath(entryPath) {
99
99
  }
100
100
  return entryPath.replace(/\\/g, '/').split('/').map(sanitizeWindowsSegment).join('/');
101
101
  }
102
+ function getExtractedPath(entryPath) {
103
+ const normalized = sanitizeOutputPath(entryPath).replace(/\\/g, '/');
104
+ const segments = normalized.split('/').filter(segment => segment !== '' && segment !== '.');
105
+ return segments.join(node_path.sep);
106
+ }
102
107
  function assertSafeRelativeArchivePath(entryPath) {
103
108
  const normalized = entryPath.replace(/\\/g, '/');
104
109
  const segments = normalized.split('/').filter(segment => segment !== '' && segment !== '.');
@@ -481,7 +486,12 @@ class Archive {
481
486
  }
482
487
  async entries() {
483
488
  this.assertOpen();
484
- this.entriesPromise ??= native.entries(this.handle).catch((cause) => {
489
+ this.entriesPromise ??= native.entries(this.handle)
490
+ .then(entries => entries.map(entry => ({
491
+ ...entry,
492
+ extractedPath: getExtractedPath(entry.path),
493
+ })))
494
+ .catch((cause) => {
485
495
  throw new ArchiveError('ERR_ARCHIVE_OPEN', errorMessage(cause), { cause });
486
496
  });
487
497
  return this.entriesPromise;
package/dist/index.d.cts CHANGED
@@ -5,6 +5,7 @@ type EntrySelector = EntryId | string;
5
5
  interface ArchiveEntry {
6
6
  readonly id: EntryId;
7
7
  readonly path: string;
8
+ readonly extractedPath: string;
8
9
  readonly size: bigint;
9
10
  readonly compressedSize: bigint;
10
11
  readonly isDirectory: boolean;
package/dist/index.d.mts CHANGED
@@ -5,6 +5,7 @@ type EntrySelector = EntryId | string;
5
5
  interface ArchiveEntry {
6
6
  readonly id: EntryId;
7
7
  readonly path: string;
8
+ readonly extractedPath: string;
8
9
  readonly size: bigint;
9
10
  readonly compressedSize: bigint;
10
11
  readonly isDirectory: boolean;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ type EntrySelector = EntryId | string;
5
5
  interface ArchiveEntry {
6
6
  readonly id: EntryId;
7
7
  readonly path: string;
8
+ readonly extractedPath: string;
8
9
  readonly size: bigint;
9
10
  readonly compressedSize: bigint;
10
11
  readonly isDirectory: boolean;
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { rename, link, rm, lstat, mkdir } from 'node:fs/promises';
3
3
  import { randomUUID } from 'node:crypto';
4
4
  import { createRequire } from 'node:module';
5
5
  import { availableParallelism } from 'node:os';
6
- import { dirname, resolve, join, extname, relative, sep } from 'node:path';
6
+ import { dirname, resolve, join, extname, sep, relative } from 'node:path';
7
7
  import { Readable } from 'node:stream';
8
8
  import { pipeline } from 'node:stream/promises';
9
9
 
@@ -96,6 +96,11 @@ function sanitizeOutputPath(entryPath) {
96
96
  }
97
97
  return entryPath.replace(/\\/g, '/').split('/').map(sanitizeWindowsSegment).join('/');
98
98
  }
99
+ function getExtractedPath(entryPath) {
100
+ const normalized = sanitizeOutputPath(entryPath).replace(/\\/g, '/');
101
+ const segments = normalized.split('/').filter(segment => segment !== '' && segment !== '.');
102
+ return segments.join(sep);
103
+ }
99
104
  function assertSafeRelativeArchivePath(entryPath) {
100
105
  const normalized = entryPath.replace(/\\/g, '/');
101
106
  const segments = normalized.split('/').filter(segment => segment !== '' && segment !== '.');
@@ -478,7 +483,12 @@ class Archive {
478
483
  }
479
484
  async entries() {
480
485
  this.assertOpen();
481
- this.entriesPromise ??= native.entries(this.handle).catch((cause) => {
486
+ this.entriesPromise ??= native.entries(this.handle)
487
+ .then(entries => entries.map(entry => ({
488
+ ...entry,
489
+ extractedPath: getExtractedPath(entry.path),
490
+ })))
491
+ .catch((cause) => {
482
492
  throw new ArchiveError('ERR_ARCHIVE_OPEN', errorMessage(cause), { cause });
483
493
  });
484
494
  return this.entriesPromise;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "7zip-native",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Native 7zip bindings for Node.js",
5
5
  "main": "./dist/index.cjs",
6
6
  "type": "module",
Binary file
Binary file