@push.rocks/smartarchive 5.0.1 → 5.2.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.
Files changed (80) hide show
  1. package/dist_ts/00_commitinfo_data.js +2 -2
  2. package/dist_ts/classes.archiveanalyzer.d.ts +1 -1
  3. package/dist_ts/classes.archiveanalyzer.js +34 -4
  4. package/dist_ts/classes.smartarchive.d.ts +4 -4
  5. package/dist_ts/classes.smartarchive.js +45 -26
  6. package/dist_ts/classes.tartools.d.ts +74 -23
  7. package/dist_ts/classes.tartools.js +190 -139
  8. package/dist_ts/index.d.ts +2 -6
  9. package/dist_ts/index.js +7 -11
  10. package/dist_ts/paths.js +1 -1
  11. package/dist_ts/plugins.d.ts +4 -9
  12. package/dist_ts/plugins.js +9 -13
  13. package/{dist_ts → dist_ts_shared}/bzip2/bititerator.d.ts +1 -1
  14. package/dist_ts_shared/bzip2/bititerator.js +50 -0
  15. package/{dist_ts → dist_ts_shared}/bzip2/bzip2.d.ts +2 -2
  16. package/{dist_ts → dist_ts_shared}/bzip2/bzip2.js +1 -1
  17. package/{dist_ts → dist_ts_shared}/bzip2/index.d.ts +1 -1
  18. package/dist_ts_shared/bzip2/index.js +92 -0
  19. package/dist_ts_shared/classes.bzip2tools.d.ts +10 -0
  20. package/dist_ts_shared/classes.bzip2tools.js +14 -0
  21. package/dist_ts_shared/classes.gziptools.d.ts +26 -0
  22. package/dist_ts_shared/classes.gziptools.js +38 -0
  23. package/dist_ts_shared/classes.tartools.d.ts +30 -0
  24. package/dist_ts_shared/classes.tartools.js +78 -0
  25. package/dist_ts_shared/classes.ziptools.d.ts +31 -0
  26. package/dist_ts_shared/classes.ziptools.js +103 -0
  27. package/{dist_ts → dist_ts_shared}/errors.js +1 -1
  28. package/dist_ts_shared/index.d.ts +8 -0
  29. package/dist_ts_shared/index.js +14 -0
  30. package/{dist_ts → dist_ts_shared}/interfaces.d.ts +17 -7
  31. package/{dist_ts → dist_ts_shared}/interfaces.js +1 -1
  32. package/dist_ts_shared/plugins.d.ts +9 -0
  33. package/dist_ts_shared/plugins.js +14 -0
  34. package/dist_ts_web/00_commitinfo_data.d.ts +8 -0
  35. package/dist_ts_web/00_commitinfo_data.js +9 -0
  36. package/dist_ts_web/index.d.ts +1 -0
  37. package/dist_ts_web/index.js +4 -0
  38. package/dist_ts_web/plugins.d.ts +1 -0
  39. package/dist_ts_web/plugins.js +4 -0
  40. package/npmextra.json +13 -7
  41. package/package.json +24 -13
  42. package/readme.md +154 -46
  43. package/ts/00_commitinfo_data.ts +1 -1
  44. package/ts/classes.archiveanalyzer.ts +33 -5
  45. package/ts/classes.smartarchive.ts +48 -27
  46. package/ts/classes.tartools.ts +217 -153
  47. package/ts/index.ts +7 -11
  48. package/ts/plugins.ts +8 -16
  49. package/{ts → ts_shared}/bzip2/bititerator.ts +1 -1
  50. package/{ts → ts_shared}/bzip2/bzip2.ts +2 -2
  51. package/{ts → ts_shared}/bzip2/index.ts +6 -6
  52. package/ts_shared/classes.bzip2tools.ts +14 -0
  53. package/ts_shared/classes.gziptools.ts +42 -0
  54. package/ts_shared/classes.tartools.ts +89 -0
  55. package/ts_shared/classes.ziptools.ts +107 -0
  56. package/ts_shared/index.ts +17 -0
  57. package/{ts → ts_shared}/interfaces.ts +18 -7
  58. package/ts_shared/plugins.ts +22 -0
  59. package/ts_web/00_commitinfo_data.ts +8 -0
  60. package/ts_web/index.ts +4 -0
  61. package/ts_web/plugins.ts +3 -0
  62. package/dist_ts/bzip2/bititerator.js +0 -50
  63. package/dist_ts/bzip2/index.js +0 -92
  64. package/dist_ts/classes.bzip2tools.d.ts +0 -7
  65. package/dist_ts/classes.bzip2tools.js +0 -11
  66. package/dist_ts/classes.gziptools.d.ts +0 -53
  67. package/dist_ts/classes.gziptools.js +0 -116
  68. package/dist_ts/classes.ziptools.d.ts +0 -56
  69. package/dist_ts/classes.ziptools.js +0 -171
  70. package/dist_ts/smartarchive.classes.smartarchive.d.ts +0 -34
  71. package/dist_ts/smartarchive.classes.smartarchive.js +0 -116
  72. package/dist_ts/smartarchive.paths.d.ts +0 -2
  73. package/dist_ts/smartarchive.paths.js +0 -4
  74. package/dist_ts/smartarchive.plugins.d.ts +0 -14
  75. package/dist_ts/smartarchive.plugins.js +0 -19
  76. package/ts/classes.bzip2tools.ts +0 -16
  77. package/ts/classes.gziptools.ts +0 -138
  78. package/ts/classes.ziptools.ts +0 -196
  79. /package/{dist_ts → dist_ts_shared}/errors.d.ts +0 -0
  80. /package/{ts → ts_shared}/errors.ts +0 -0
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzX3NoYXJlZC9pbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
@@ -0,0 +1,9 @@
1
+ import * as smartdelay from '@push.rocks/smartdelay';
2
+ import * as smartpromise from '@push.rocks/smartpromise';
3
+ import * as smartstream from '@push.rocks/smartstream';
4
+ import * as smartfile from '@push.rocks/smartfile';
5
+ export { smartdelay, smartpromise, smartstream, smartfile, };
6
+ import * as fileType from 'file-type';
7
+ import * as fflate from 'fflate';
8
+ import * as modernTar from 'modern-tar';
9
+ export { fileType, fflate, modernTar };
@@ -0,0 +1,14 @@
1
+ // Browser-compatible plugins for ts_shared
2
+ // NO Node.js imports allowed here
3
+ // @push.rocks scope (browser-compatible)
4
+ import * as smartdelay from '@push.rocks/smartdelay';
5
+ import * as smartpromise from '@push.rocks/smartpromise';
6
+ import * as smartstream from '@push.rocks/smartstream';
7
+ import * as smartfile from '@push.rocks/smartfile';
8
+ export { smartdelay, smartpromise, smartstream, smartfile, };
9
+ // third party scope (browser-compatible)
10
+ import * as fileType from 'file-type';
11
+ import * as fflate from 'fflate';
12
+ import * as modernTar from 'modern-tar';
13
+ export { fileType, fflate, modernTar };
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzX3NoYXJlZC9wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDJDQUEyQztBQUMzQyxrQ0FBa0M7QUFFbEMseUNBQXlDO0FBQ3pDLE9BQU8sS0FBSyxVQUFVLE1BQU0sd0JBQXdCLENBQUM7QUFDckQsT0FBTyxLQUFLLFlBQVksTUFBTSwwQkFBMEIsQ0FBQztBQUN6RCxPQUFPLEtBQUssV0FBVyxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFFbkQsT0FBTyxFQUNMLFVBQVUsRUFDVixZQUFZLEVBQ1osV0FBVyxFQUNYLFNBQVMsR0FDVixDQUFDO0FBRUYseUNBQXlDO0FBQ3pDLE9BQU8sS0FBSyxRQUFRLE1BQU0sV0FBVyxDQUFDO0FBQ3RDLE9BQU8sS0FBSyxNQUFNLE1BQU0sUUFBUSxDQUFDO0FBQ2pDLE9BQU8sS0FBSyxTQUFTLE1BQU0sWUFBWSxDQUFDO0FBRXhDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxDQUFDIn0=
@@ -0,0 +1,8 @@
1
+ /**
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
+ */
4
+ export declare const commitinfo: {
5
+ name: string;
6
+ version: string;
7
+ description: string;
8
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
+ */
4
+ export const commitinfo = {
5
+ name: '@push.rocks/smartarchive',
6
+ version: '5.1.0',
7
+ description: 'A library for working with archive files, providing utilities for compressing and decompressing data.'
8
+ };
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHNfd2ViLzAwX2NvbW1pdGluZm9fZGF0YS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUNILE1BQU0sQ0FBQyxNQUFNLFVBQVUsR0FBRztJQUN4QixJQUFJLEVBQUUsMEJBQTBCO0lBQ2hDLE9BQU8sRUFBRSxPQUFPO0lBQ2hCLFdBQVcsRUFBRSx1R0FBdUc7Q0FDckgsQ0FBQSJ9
@@ -0,0 +1 @@
1
+ export * from '../ts_shared/index.js';
@@ -0,0 +1,4 @@
1
+ // ts_web - Browser-compatible entry point
2
+ // Re-exports everything from ts_shared
3
+ export * from '../ts_shared/index.js';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90c193ZWIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsMENBQTBDO0FBQzFDLHVDQUF1QztBQUV2QyxjQUFjLHVCQUF1QixDQUFDIn0=
@@ -0,0 +1 @@
1
+ export * from '../ts_shared/plugins.js';
@@ -0,0 +1,4 @@
1
+ // Browser-compatible plugins for ts_web
2
+ // Re-export from ts_shared
3
+ export * from '../ts_shared/plugins.js';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzX3dlYi9wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHdDQUF3QztBQUN4QywyQkFBMkI7QUFDM0IsY0FBYyx5QkFBeUIsQ0FBQyJ9
package/npmextra.json CHANGED
@@ -1,9 +1,5 @@
1
1
  {
2
- "npmci": {
3
- "npmGlobalTools": [],
4
- "npmAccessLevel": "public"
5
- },
6
- "gitzone": {
2
+ "@git.zone/cli": {
7
3
  "projectType": "npm",
8
4
  "module": {
9
5
  "githost": "code.foss.global",
@@ -25,9 +21,19 @@
25
21
  "data analysis",
26
22
  "file stream"
27
23
  ]
24
+ },
25
+ "release": {
26
+ "registries": [
27
+ "https://verdaccio.lossless.digital",
28
+ "https://registry.npmjs.org"
29
+ ],
30
+ "accessLevel": "public"
28
31
  }
29
32
  },
30
- "tsdoc": {
33
+ "@git.zone/tsdoc": {
31
34
  "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
35
+ },
36
+ "@ship.zone/szci": {
37
+ "npmGlobalTools": []
32
38
  }
33
- }
39
+ }
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "@push.rocks/smartarchive",
3
- "version": "5.0.1",
3
+ "version": "5.2.0",
4
4
  "description": "A library for working with archive files, providing utilities for compressing and decompressing data.",
5
5
  "main": "dist_ts/index.js",
6
6
  "typings": "dist_ts/index.d.ts",
7
7
  "type": "module",
8
+ "exports": {
9
+ ".": "./dist_ts/index.js",
10
+ "./web": "./dist_ts_web/index.js"
11
+ },
12
+ "scripts": {
13
+ "test": "(tstest test/ --verbose)",
14
+ "build": "tsbuild --web --allowimplicitany",
15
+ "buildDocs": "tsdoc"
16
+ },
8
17
  "repository": {
9
18
  "type": "git",
10
19
  "url": "https://code.foss.global/push.rocks/smartarchive.git"
@@ -17,31 +26,34 @@
17
26
  "homepage": "https://code.foss.global/push.rocks/smartarchive#readme",
18
27
  "dependencies": {
19
28
  "@push.rocks/smartdelay": "^3.0.5",
20
- "@push.rocks/smartfile": "^13.0.0",
29
+ "@push.rocks/smartfile": "^13.1.2",
21
30
  "@push.rocks/smartpath": "^6.0.0",
22
31
  "@push.rocks/smartpromise": "^4.2.3",
23
- "@push.rocks/smartrequest": "^4.2.2",
32
+ "@push.rocks/smartrequest": "^5.0.1",
24
33
  "@push.rocks/smartrx": "^3.0.10",
25
34
  "@push.rocks/smartstream": "^3.2.5",
26
35
  "@push.rocks/smartunique": "^3.0.9",
27
36
  "@push.rocks/smarturl": "^3.1.0",
28
- "@types/tar-stream": "^3.1.4",
29
37
  "fflate": "^0.8.2",
30
- "file-type": "^21.0.0",
38
+ "file-type": "^21.2.0",
39
+ "modern-tar": "^0.7.3",
31
40
  "tar-stream": "^3.1.7"
32
41
  },
33
42
  "devDependencies": {
34
- "@git.zone/tsbuild": "^3.1.0",
35
- "@git.zone/tsrun": "^2.0.0",
36
- "@git.zone/tstest": "^3.1.3"
43
+ "@git.zone/tsbuild": "^4.0.2",
44
+ "@git.zone/tsrun": "^2.0.1",
45
+ "@git.zone/tstest": "^3.1.4",
46
+ "@types/tar-stream": "^3.1.3"
37
47
  },
38
48
  "private": false,
39
49
  "files": [
40
50
  "ts/**/*",
51
+ "ts_shared/**/*",
41
52
  "ts_web/**/*",
42
53
  "dist/**/*",
43
54
  "dist_*/**/*",
44
55
  "dist_ts/**/*",
56
+ "dist_ts_shared/**/*",
45
57
  "dist_ts_web/**/*",
46
58
  "assets/**/*",
47
59
  "cli.js",
@@ -64,9 +76,8 @@
64
76
  "data analysis",
65
77
  "file stream"
66
78
  ],
67
- "scripts": {
68
- "test": "(tstest test/ --verbose)",
69
- "build": "tsbuild --web --allowimplicitany",
70
- "buildDocs": "tsdoc"
79
+ "packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748",
80
+ "pnpm": {
81
+ "overrides": {}
71
82
  }
72
- }
83
+ }
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @push.rocks/smartarchive 📦
2
2
 
3
- A powerful, streaming-first archive manipulation library with a fluent builder API. Works seamlessly in Node.js and Deno.
3
+ A powerful, streaming-first archive manipulation library with a fluent builder API. Works seamlessly in **Node.js**, **Deno**, and **browsers**.
4
4
 
5
5
  ## Issue Reporting and Security
6
6
 
@@ -12,11 +12,12 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
12
12
  - 🌊 **Streaming-first architecture** – Process large archives without memory constraints
13
13
  - ✨ **Fluent builder API** – Chain methods for readable, expressive code
14
14
  - 🎯 **Smart detection** – Automatically identifies archive types via magic bytes
15
- - ⚡ **High performance** – Built on `tar-stream` and `fflate` for speed
15
+ - ⚡ **High performance** – Built on `modern-tar` and `fflate` for speed
16
16
  - 🔧 **Flexible I/O** – Work with files, URLs, streams, and buffers seamlessly
17
17
  - 🛠️ **Modern TypeScript** – Full type safety and excellent IDE support
18
18
  - 🔄 **Dual-mode operation** – Extract existing archives OR create new ones
19
- - 🦕 **Cross-runtime** – Works in both Node.js and Deno environments
19
+ - 🦕 **Cross-runtime** – Works in Node.js, Deno, and browsers
20
+ - 🌐 **Browser-ready** – Dedicated browser bundle with zero Node.js dependencies
20
21
 
21
22
  ## Installation 📥
22
23
 
@@ -71,6 +72,59 @@ await SmartArchive.create()
71
72
  .extract('./node_modules/lodash');
72
73
  ```
73
74
 
75
+ ## Browser Usage 🌐
76
+
77
+ smartarchive provides a dedicated browser-compatible bundle with no Node.js dependencies:
78
+
79
+ ```typescript
80
+ // Import from the /web subpath for browser environments
81
+ import { TarTools, ZipTools, GzipTools, Bzip2Tools } from '@push.rocks/smartarchive/web';
82
+
83
+ // Create a TAR archive in the browser
84
+ const tarTools = new TarTools();
85
+ const tarBuffer = await tarTools.packFiles([
86
+ { archivePath: 'hello.txt', content: 'Hello from the browser!' },
87
+ { archivePath: 'data.json', content: JSON.stringify({ browser: true }) }
88
+ ]);
89
+
90
+ // Create a TAR.GZ archive
91
+ const tgzBuffer = await tarTools.packFilesToTarGz([
92
+ { archivePath: 'file.txt', content: 'Compressed!' }
93
+ ], 6);
94
+
95
+ // Extract a TAR archive
96
+ const entries = await tarTools.extractTar(tarBuffer);
97
+ for (const entry of entries) {
98
+ console.log(`${entry.path}: ${entry.content.length} bytes`);
99
+ }
100
+
101
+ // Work with ZIP files
102
+ const zipTools = new ZipTools();
103
+ const zipBuffer = await zipTools.createZip([
104
+ { archivePath: 'doc.txt', content: 'Document content' }
105
+ ], 6);
106
+
107
+ const zipEntries = await zipTools.extractZip(zipBuffer);
108
+
109
+ // GZIP compression
110
+ const gzipTools = new GzipTools();
111
+ const compressed = gzipTools.compressSync(new TextEncoder().encode('Hello World'), 6);
112
+ const decompressed = gzipTools.decompressSync(compressed);
113
+ ```
114
+
115
+ ### Browser Bundle Exports
116
+
117
+ The `/web` subpath exports these browser-compatible tools:
118
+
119
+ | Export | Description |
120
+ |--------|-------------|
121
+ | `TarTools` | Create and extract TAR and TAR.GZ archives |
122
+ | `ZipTools` | Create and extract ZIP archives |
123
+ | `GzipTools` | GZIP compression and decompression |
124
+ | `Bzip2Tools` | BZIP2 decompression (extraction only) |
125
+
126
+ > 💡 **Note:** The browser bundle does **not** include `SmartArchive` (which requires filesystem access). Use the individual tool classes for browser applications.
127
+
74
128
  ## Core Concepts 💡
75
129
 
76
130
  ### Fluent Builder Pattern
@@ -294,51 +348,107 @@ await SmartArchive.create()
294
348
  // Use GzipTools directly for compression/decompression
295
349
  const gzipTools = new GzipTools();
296
350
 
297
- // Compress a buffer
298
- const compressed = await gzipTools.compress(Buffer.from('Hello World'), 9);
299
- const decompressed = await gzipTools.decompress(compressed);
351
+ // Compress a buffer (sync and async available)
352
+ const input = new TextEncoder().encode('Hello World');
353
+ const compressed = gzipTools.compressSync(input, 9);
354
+ const decompressed = gzipTools.decompressSync(compressed);
300
355
 
301
- // Synchronous operations
302
- const compressedSync = gzipTools.compressSync(inputBuffer, 6);
303
- const decompressedSync = gzipTools.decompressSync(compressedSync);
356
+ // Async versions (internally use sync for cross-runtime compatibility)
357
+ const compressedAsync = await gzipTools.compress(input, 6);
358
+ const decompressedAsync = await gzipTools.decompress(compressedAsync);
359
+ ```
304
360
 
305
- // Streaming
306
- const compressStream = gzipTools.getCompressionStream(6);
307
- const decompressStream = gzipTools.getDecompressionStream();
361
+ ### Working with TAR archives directly
362
+
363
+ ```typescript
364
+ import { TarTools } from '@push.rocks/smartarchive';
365
+
366
+ const tarTools = new TarTools();
367
+
368
+ // Create a TAR archive from entries (buffer-based, good for small files)
369
+ const tarBuffer = await tarTools.packFiles([
370
+ { archivePath: 'hello.txt', content: 'Hello, World!' },
371
+ { archivePath: 'data.json', content: JSON.stringify({ foo: 'bar' }) }
372
+ ]);
373
+
374
+ // Create a TAR.GZ archive
375
+ const tgzBuffer = await tarTools.packFilesToTarGz([
376
+ { archivePath: 'file.txt', content: 'Compressed content' }
377
+ ], 6);
378
+
379
+ // Extract a TAR archive
380
+ const entries = await tarTools.extractTar(tarBuffer);
381
+ for (const entry of entries) {
382
+ console.log(`${entry.path}: ${entry.isDirectory ? 'dir' : 'file'}`);
383
+ }
308
384
 
309
- createReadStream('./input.txt')
310
- .pipe(compressStream)
311
- .pipe(createWriteStream('./output.gz'));
385
+ // Extract a TAR.GZ archive
386
+ const tgzEntries = await tarTools.extractTarGz(tgzBuffer);
387
+
388
+ // Node.js only: Pack a directory (buffer-based)
389
+ const dirBuffer = await tarTools.packDirectory('./src');
390
+ const dirTgzBuffer = await tarTools.packDirectoryToTarGz('./src', 9);
312
391
  ```
313
392
 
314
- ### Working with TAR archives directly
393
+ ### Streaming TAR for Large Files (Node.js only) 🚀
394
+
395
+ For large files that don't fit in memory, use the streaming APIs:
315
396
 
316
397
  ```typescript
317
398
  import { TarTools } from '@push.rocks/smartarchive';
399
+ import * as fs from 'fs';
318
400
 
319
401
  const tarTools = new TarTools();
320
402
 
321
- // Create a TAR archive manually
322
- const pack = await tarTools.getPackStream();
403
+ // ===== STREAMING PACK =====
404
+ // Create a TAR pack stream - files are processed one at a time
405
+ const pack = tarTools.getPackStream();
323
406
 
407
+ // Add files with streaming content (requires size for streams)
324
408
  await tarTools.addFileToPack(pack, {
325
- fileName: 'hello.txt',
326
- content: 'Hello, World!'
409
+ fileName: 'small.txt',
410
+ content: 'Hello World' // Strings and buffers auto-detect size
327
411
  });
328
412
 
329
413
  await tarTools.addFileToPack(pack, {
330
- fileName: 'data.json',
331
- content: Buffer.from(JSON.stringify({ foo: 'bar' }))
414
+ fileName: 'large-video.mp4',
415
+ content: fs.createReadStream('./video.mp4'),
416
+ size: fs.statSync('./video.mp4').size // Size required for streams
332
417
  });
333
418
 
334
419
  pack.finalize();
335
- pack.pipe(createWriteStream('./output.tar'));
420
+ pack.pipe(fs.createWriteStream('output.tar'));
421
+
422
+ // ===== STREAMING DIRECTORY PACK =====
423
+ // Pack entire directory with true streaming (no buffering)
424
+ const tarStream = await tarTools.getDirectoryPackStream('./large-folder');
425
+ tarStream.pipe(fs.createWriteStream('backup.tar'));
426
+
427
+ // With GZIP compression
428
+ const tgzStream = await tarTools.getDirectoryPackStreamGz('./large-folder', 6);
429
+ tgzStream.pipe(fs.createWriteStream('backup.tar.gz'));
430
+
431
+ // ===== STREAMING EXTRACT =====
432
+ // Extract large archives without loading into memory
433
+ const extract = tarTools.getExtractStream();
336
434
 
337
- // Pack a directory to TAR.GZ buffer
338
- const tgzBuffer = await tarTools.packDirectoryToTarGz('./src', 6);
435
+ extract.on('entry', (header, stream, next) => {
436
+ console.log(`Extracting: ${header.name} (${header.size} bytes)`);
339
437
 
340
- // Pack a directory to TAR.GZ stream
341
- const tgzStream = await tarTools.packDirectoryToTarGzStream('./src');
438
+ const writeStream = fs.createWriteStream(`./out/${header.name}`);
439
+ stream.pipe(writeStream);
440
+ writeStream.on('finish', next);
441
+ });
442
+
443
+ extract.on('finish', () => console.log('Extraction complete'));
444
+
445
+ fs.createReadStream('large-archive.tar').pipe(extract);
446
+
447
+ // Or use the convenient directory extraction
448
+ await tarTools.extractToDirectory(
449
+ fs.createReadStream('archive.tar'),
450
+ './output-folder'
451
+ );
342
452
  ```
343
453
 
344
454
  ### Working with ZIP archives directly
@@ -351,7 +461,7 @@ const zipTools = new ZipTools();
351
461
  // Create a ZIP archive from entries
352
462
  const zipBuffer = await zipTools.createZip([
353
463
  { archivePath: 'readme.txt', content: 'Hello!' },
354
- { archivePath: 'data.bin', content: Buffer.from([0x00, 0x01, 0x02]) }
464
+ { archivePath: 'data.bin', content: new Uint8Array([0x00, 0x01, 0x02]) }
355
465
  ], 6);
356
466
 
357
467
  // Extract a ZIP buffer
@@ -448,13 +558,13 @@ fileStream.on('data', async (file) => {
448
558
 
449
559
  ## Supported Formats 📋
450
560
 
451
- | Format | Extension(s) | Extract | Create |
452
- |--------|--------------|---------|--------|
453
- | TAR | `.tar` | ✅ | ✅ |
454
- | TAR.GZ / TGZ | `.tar.gz`, `.tgz` | ✅ | ✅ |
455
- | ZIP | `.zip` | ✅ | ✅ |
456
- | GZIP | `.gz` | ✅ | ✅ |
457
- | BZIP2 | `.bz2` | ✅ | ❌ |
561
+ | Format | Extension(s) | Extract | Create | Browser |
562
+ |--------|--------------|---------|--------|---------|
563
+ | TAR | `.tar` | ✅ | ✅ | ✅ |
564
+ | TAR.GZ / TGZ | `.tar.gz`, `.tgz` | ✅ | ✅ | ✅ |
565
+ | ZIP | `.zip` | ✅ | ✅ | ✅ |
566
+ | GZIP | `.gz` | ✅ | ✅ | ✅ |
567
+ | BZIP2 | `.bz2` | ✅ | ❌ | ✅ |
458
568
 
459
569
  ## Type Definitions
460
570
 
@@ -468,7 +578,7 @@ type TCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
468
578
  // Entry for creating archives
469
579
  interface IArchiveEntry {
470
580
  archivePath: string;
471
- content: string | Buffer | Readable | SmartFile | StreamFile;
581
+ content: string | Buffer | Uint8Array | SmartFile | StreamFile;
472
582
  size?: number;
473
583
  mode?: number;
474
584
  mtime?: Date;
@@ -496,9 +606,9 @@ interface IArchiveInfo {
496
606
  ## Performance Tips 🏎️
497
607
 
498
608
  1. **Use streaming for large files** – `.toStreamFiles()` processes entries one at a time without loading the entire archive
499
- 2. **Provide byte lengths when known** – When using TarTools directly, provide `byteLength` for better performance
500
- 3. **Choose appropriate compression** – Use 1-3 for speed, 6 (default) for balance, 9 for maximum compression
501
- 4. **Filter early** – Use `.include()`/`.exclude()` to skip unwanted entries before processing
609
+ 2. **Choose appropriate compression** – Use 1-3 for speed, 6 (default) for balance, 9 for maximum compression
610
+ 3. **Filter early** – Use `.include()`/`.exclude()` to skip unwanted entries before processing
611
+ 4. **Use Uint8Array in browsers** – The browser bundle works with `Uint8Array` for optimal performance
502
612
 
503
613
  ## Error Handling 🛡️
504
614
 
@@ -524,23 +634,21 @@ try {
524
634
 
525
635
  ## License and Legal Information
526
636
 
527
- This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
637
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
528
638
 
529
639
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
530
640
 
531
641
  ### Trademarks
532
642
 
533
- This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
534
-
535
- ### Issue Reporting and Security
643
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
536
644
 
537
- For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
645
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
538
646
 
539
647
  ### Company Information
540
648
 
541
649
  Task Venture Capital GmbH
542
- Registered at District court Bremen HRB 35230 HB, Germany
650
+ Registered at District Court Bremen HRB 35230 HB, Germany
543
651
 
544
- For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
652
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
545
653
 
546
654
  By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartarchive',
6
- version: '5.0.1',
6
+ version: '5.2.0',
7
7
  description: 'A library for working with archive files, providing utilities for compressing and decompressing data.'
8
8
  }
@@ -1,5 +1,5 @@
1
1
  import type { SmartArchive } from './classes.smartarchive.js';
2
- import type { TSupportedMime } from './interfaces.js';
2
+ import type { TSupportedMime } from '../ts_shared/interfaces.js';
3
3
  import * as plugins from './plugins.js';
4
4
 
5
5
  /**
@@ -8,7 +8,7 @@ import * as plugins from './plugins.js';
8
8
  export type TDecompressionStream =
9
9
  | plugins.stream.Transform
10
10
  | plugins.stream.Duplex
11
- | plugins.tarStream.Extract;
11
+ | plugins.smartstream.SmartDuplex<any, any>;
12
12
 
13
13
  /**
14
14
  * Result of archive analysis
@@ -53,14 +53,42 @@ export class ArchiveAnalyzer {
53
53
  */
54
54
  private async getDecompressionStream(mimeTypeArg: TSupportedMime): Promise<TDecompressionStream> {
55
55
  switch (mimeTypeArg) {
56
- case 'application/gzip':
57
- return this.smartArchiveRef.gzipTools.getDecompressionStream();
56
+ case 'application/gzip': {
57
+ // Use fflate streaming Gunzip - instance must be created once and reused
58
+ let gunzip: plugins.fflate.Gunzip;
59
+ return new plugins.stream.Transform({
60
+ construct(callback) {
61
+ gunzip = new plugins.fflate.Gunzip((data, final) => {
62
+ this.push(Buffer.from(data));
63
+ });
64
+ callback();
65
+ },
66
+ transform(chunk, encoding, callback) {
67
+ try {
68
+ gunzip.push(chunk, false);
69
+ callback();
70
+ } catch (err) {
71
+ callback(err as Error);
72
+ }
73
+ },
74
+ flush(callback) {
75
+ try {
76
+ // Signal end of stream with empty final chunk
77
+ gunzip.push(new Uint8Array(0), true);
78
+ callback();
79
+ } catch (err) {
80
+ callback(err as Error);
81
+ }
82
+ }
83
+ });
84
+ }
58
85
  case 'application/zip':
59
86
  return this.smartArchiveRef.zipTools.getDecompressionStream();
60
87
  case 'application/x-bzip2':
61
88
  return this.smartArchiveRef.bzip2Tools.getDecompressionStream();
62
89
  case 'application/x-tar':
63
- return this.smartArchiveRef.tarTools.getDecompressionStream();
90
+ // TAR doesn't need decompression, just pass through
91
+ return plugins.smartstream.createPassThrough();
64
92
  default:
65
93
  // Handle unsupported formats or no decompression needed
66
94
  return plugins.smartstream.createPassThrough();