@push.rocks/smartarchive 4.2.4 → 5.0.1

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 (39) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/bzip2/bititerator.d.ts +6 -1
  3. package/dist_ts/bzip2/bititerator.js +30 -24
  4. package/dist_ts/bzip2/bzip2.d.ts +27 -12
  5. package/dist_ts/bzip2/bzip2.js +325 -263
  6. package/dist_ts/bzip2/index.d.ts +4 -1
  7. package/dist_ts/bzip2/index.js +36 -38
  8. package/dist_ts/classes.archiveanalyzer.d.ts +25 -5
  9. package/dist_ts/classes.archiveanalyzer.js +19 -8
  10. package/dist_ts/classes.bzip2tools.d.ts +1 -1
  11. package/dist_ts/classes.gziptools.d.ts +43 -6
  12. package/dist_ts/classes.gziptools.js +76 -24
  13. package/dist_ts/classes.smartarchive.d.ts +198 -16
  14. package/dist_ts/classes.smartarchive.js +652 -79
  15. package/dist_ts/classes.tartools.d.ts +31 -4
  16. package/dist_ts/classes.tartools.js +93 -32
  17. package/dist_ts/classes.ziptools.d.ts +47 -12
  18. package/dist_ts/classes.ziptools.js +128 -23
  19. package/dist_ts/errors.d.ts +44 -0
  20. package/dist_ts/errors.js +62 -0
  21. package/dist_ts/index.d.ts +4 -0
  22. package/dist_ts/index.js +9 -1
  23. package/dist_ts/interfaces.d.ts +119 -0
  24. package/dist_ts/interfaces.js +2 -0
  25. package/package.json +1 -1
  26. package/readme.hints.md +69 -23
  27. package/readme.md +360 -274
  28. package/ts/00_commitinfo_data.ts +1 -1
  29. package/ts/bzip2/bititerator.ts +43 -27
  30. package/ts/bzip2/bzip2.ts +289 -171
  31. package/ts/bzip2/index.ts +52 -50
  32. package/ts/classes.archiveanalyzer.ts +42 -28
  33. package/ts/classes.gziptools.ts +91 -33
  34. package/ts/classes.smartarchive.ts +765 -140
  35. package/ts/classes.tartools.ts +124 -52
  36. package/ts/classes.ziptools.ts +147 -34
  37. package/ts/errors.ts +70 -0
  38. package/ts/index.ts +11 -0
  39. package/ts/interfaces.ts +136 -0
@@ -0,0 +1,136 @@
1
+ import type * as stream from 'node:stream';
2
+ import type { SmartFile, StreamFile } from '@push.rocks/smartfile';
3
+
4
+ /**
5
+ * Supported archive formats
6
+ */
7
+ export type TArchiveFormat = 'tar' | 'tar.gz' | 'tgz' | 'zip' | 'gz' | 'bz2';
8
+
9
+ /**
10
+ * Compression level (0 = no compression, 9 = maximum compression)
11
+ */
12
+ export type TCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
13
+
14
+ /**
15
+ * Supported MIME types for archive detection
16
+ */
17
+ export type TSupportedMime =
18
+ | 'application/gzip'
19
+ | 'application/zip'
20
+ | 'application/x-bzip2'
21
+ | 'application/x-tar'
22
+ | undefined;
23
+
24
+ /**
25
+ * Entry to add to an archive during creation
26
+ */
27
+ export interface IArchiveEntry {
28
+ /** Path within the archive */
29
+ archivePath: string;
30
+ /** Content: string, Buffer, Readable stream, SmartFile, or StreamFile */
31
+ content: string | Buffer | stream.Readable | SmartFile | StreamFile;
32
+ /** Optional size hint for streams (improves performance) */
33
+ size?: number;
34
+ /** Optional file mode/permissions */
35
+ mode?: number;
36
+ /** Optional modification time */
37
+ mtime?: Date;
38
+ }
39
+
40
+ /**
41
+ * Options for creating archives
42
+ */
43
+ export interface IArchiveCreationOptions {
44
+ /** Target archive format */
45
+ format: TArchiveFormat;
46
+ /** Compression level (0-9, default depends on format) */
47
+ compressionLevel?: TCompressionLevel;
48
+ /** Base path to strip from file paths in archive */
49
+ basePath?: string;
50
+ }
51
+
52
+ /**
53
+ * Options for extracting archives
54
+ */
55
+ export interface IArchiveExtractionOptions {
56
+ /** Target directory for extraction */
57
+ targetDir: string;
58
+ /** Optional filename for single-file archives (gz, bz2) */
59
+ fileName?: string;
60
+ /** Number of leading path components to strip */
61
+ stripComponents?: number;
62
+ /** Filter function to select which entries to extract */
63
+ filter?: (entry: IArchiveEntryInfo) => boolean;
64
+ /** Whether to overwrite existing files */
65
+ overwrite?: boolean;
66
+ }
67
+
68
+ /**
69
+ * Information about an archive entry
70
+ */
71
+ export interface IArchiveEntryInfo {
72
+ /** Path of the entry within the archive */
73
+ path: string;
74
+ /** Size in bytes */
75
+ size: number;
76
+ /** Whether this entry is a directory */
77
+ isDirectory: boolean;
78
+ /** Whether this entry is a file */
79
+ isFile: boolean;
80
+ /** Modification time */
81
+ mtime?: Date;
82
+ /** File mode/permissions */
83
+ mode?: number;
84
+ }
85
+
86
+ /**
87
+ * Result of archive analysis
88
+ */
89
+ export interface IArchiveInfo {
90
+ /** Detected archive format */
91
+ format: TArchiveFormat | null;
92
+ /** Whether the archive is compressed */
93
+ isCompressed: boolean;
94
+ /** Whether this is a recognized archive format */
95
+ isArchive: boolean;
96
+ /** List of entries (if available without full extraction) */
97
+ entries?: IArchiveEntryInfo[];
98
+ }
99
+
100
+ /**
101
+ * Options for adding a file to a TAR pack stream
102
+ */
103
+ export interface IAddFileOptions {
104
+ /** Filename within the archive */
105
+ fileName?: string;
106
+ /** File content */
107
+ content?: string | Buffer | stream.Readable | SmartFile | StreamFile;
108
+ /** Size in bytes (required for streams) */
109
+ byteLength?: number;
110
+ /** Path to file on disk (alternative to content) */
111
+ filePath?: string;
112
+ }
113
+
114
+ /**
115
+ * Bit reader interface for BZIP2 decompression
116
+ */
117
+ export interface IBitReader {
118
+ (n: number | null): number | void;
119
+ bytesRead: number;
120
+ }
121
+
122
+ /**
123
+ * Huffman group for BZIP2 decompression
124
+ */
125
+ export interface IHuffmanGroup {
126
+ permute: Int32Array;
127
+ limit: Int32Array;
128
+ base: Int32Array;
129
+ minLen: number;
130
+ maxLen: number;
131
+ }
132
+
133
+ /**
134
+ * Entry filter predicate for fluent API
135
+ */
136
+ export type TEntryFilter = (entry: IArchiveEntryInfo) => boolean;