@push.rocks/smartarchive 4.2.3 → 5.0.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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/bzip2/bititerator.d.ts +6 -1
- package/dist_ts/bzip2/bititerator.js +30 -24
- package/dist_ts/bzip2/bzip2.d.ts +27 -12
- package/dist_ts/bzip2/bzip2.js +325 -263
- package/dist_ts/bzip2/index.d.ts +4 -1
- package/dist_ts/bzip2/index.js +36 -38
- package/dist_ts/classes.archiveanalyzer.d.ts +25 -5
- package/dist_ts/classes.archiveanalyzer.js +19 -8
- package/dist_ts/classes.bzip2tools.d.ts +1 -1
- package/dist_ts/classes.gziptools.d.ts +39 -6
- package/dist_ts/classes.gziptools.js +85 -24
- package/dist_ts/classes.smartarchive.d.ts +101 -16
- package/dist_ts/classes.smartarchive.js +398 -61
- package/dist_ts/classes.tartools.d.ts +31 -4
- package/dist_ts/classes.tartools.js +97 -36
- package/dist_ts/classes.ziptools.d.ts +47 -12
- package/dist_ts/classes.ziptools.js +142 -23
- package/dist_ts/errors.d.ts +44 -0
- package/dist_ts/errors.js +62 -0
- package/dist_ts/index.d.ts +4 -0
- package/dist_ts/index.js +9 -1
- package/dist_ts/interfaces.d.ts +115 -0
- package/dist_ts/interfaces.js +2 -0
- package/dist_ts/plugins.d.ts +9 -3
- package/dist_ts/plugins.js +27 -4
- package/package.json +3 -4
- package/readme.hints.md +38 -1
- package/readme.md +248 -137
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/bzip2/bititerator.ts +43 -27
- package/ts/bzip2/bzip2.ts +289 -171
- package/ts/bzip2/index.ts +52 -50
- package/ts/classes.archiveanalyzer.ts +42 -28
- package/ts/classes.gziptools.ts +96 -33
- package/ts/classes.smartarchive.ts +472 -122
- package/ts/classes.tartools.ts +128 -59
- package/ts/classes.ziptools.ts +160 -34
- package/ts/errors.ts +70 -0
- package/ts/index.ts +11 -0
- package/ts/interfaces.ts +131 -0
- package/ts/plugins.ts +29 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type * as stream from 'node:stream';
|
|
2
|
+
import type { SmartFile, StreamFile } from '@push.rocks/smartfile';
|
|
3
|
+
/**
|
|
4
|
+
* Supported archive formats
|
|
5
|
+
*/
|
|
6
|
+
export type TArchiveFormat = 'tar' | 'tar.gz' | 'tgz' | 'zip' | 'gz' | 'bz2';
|
|
7
|
+
/**
|
|
8
|
+
* Compression level (0 = no compression, 9 = maximum compression)
|
|
9
|
+
*/
|
|
10
|
+
export type TCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
11
|
+
/**
|
|
12
|
+
* Supported MIME types for archive detection
|
|
13
|
+
*/
|
|
14
|
+
export type TSupportedMime = 'application/gzip' | 'application/zip' | 'application/x-bzip2' | 'application/x-tar' | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Entry to add to an archive during creation
|
|
17
|
+
*/
|
|
18
|
+
export interface IArchiveEntry {
|
|
19
|
+
/** Path within the archive */
|
|
20
|
+
archivePath: string;
|
|
21
|
+
/** Content: string, Buffer, Readable stream, SmartFile, or StreamFile */
|
|
22
|
+
content: string | Buffer | stream.Readable | SmartFile | StreamFile;
|
|
23
|
+
/** Optional size hint for streams (improves performance) */
|
|
24
|
+
size?: number;
|
|
25
|
+
/** Optional file mode/permissions */
|
|
26
|
+
mode?: number;
|
|
27
|
+
/** Optional modification time */
|
|
28
|
+
mtime?: Date;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Options for creating archives
|
|
32
|
+
*/
|
|
33
|
+
export interface IArchiveCreationOptions {
|
|
34
|
+
/** Target archive format */
|
|
35
|
+
format: TArchiveFormat;
|
|
36
|
+
/** Compression level (0-9, default depends on format) */
|
|
37
|
+
compressionLevel?: TCompressionLevel;
|
|
38
|
+
/** Base path to strip from file paths in archive */
|
|
39
|
+
basePath?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for extracting archives
|
|
43
|
+
*/
|
|
44
|
+
export interface IArchiveExtractionOptions {
|
|
45
|
+
/** Target directory for extraction */
|
|
46
|
+
targetDir: string;
|
|
47
|
+
/** Optional filename for single-file archives (gz, bz2) */
|
|
48
|
+
fileName?: string;
|
|
49
|
+
/** Number of leading path components to strip */
|
|
50
|
+
stripComponents?: number;
|
|
51
|
+
/** Filter function to select which entries to extract */
|
|
52
|
+
filter?: (entry: IArchiveEntryInfo) => boolean;
|
|
53
|
+
/** Whether to overwrite existing files */
|
|
54
|
+
overwrite?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Information about an archive entry
|
|
58
|
+
*/
|
|
59
|
+
export interface IArchiveEntryInfo {
|
|
60
|
+
/** Path of the entry within the archive */
|
|
61
|
+
path: string;
|
|
62
|
+
/** Size in bytes */
|
|
63
|
+
size: number;
|
|
64
|
+
/** Whether this entry is a directory */
|
|
65
|
+
isDirectory: boolean;
|
|
66
|
+
/** Whether this entry is a file */
|
|
67
|
+
isFile: boolean;
|
|
68
|
+
/** Modification time */
|
|
69
|
+
mtime?: Date;
|
|
70
|
+
/** File mode/permissions */
|
|
71
|
+
mode?: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Result of archive analysis
|
|
75
|
+
*/
|
|
76
|
+
export interface IArchiveInfo {
|
|
77
|
+
/** Detected archive format */
|
|
78
|
+
format: TArchiveFormat | null;
|
|
79
|
+
/** Whether the archive is compressed */
|
|
80
|
+
isCompressed: boolean;
|
|
81
|
+
/** Whether this is a recognized archive format */
|
|
82
|
+
isArchive: boolean;
|
|
83
|
+
/** List of entries (if available without full extraction) */
|
|
84
|
+
entries?: IArchiveEntryInfo[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for adding a file to a TAR pack stream
|
|
88
|
+
*/
|
|
89
|
+
export interface IAddFileOptions {
|
|
90
|
+
/** Filename within the archive */
|
|
91
|
+
fileName?: string;
|
|
92
|
+
/** File content */
|
|
93
|
+
content?: string | Buffer | stream.Readable | SmartFile | StreamFile;
|
|
94
|
+
/** Size in bytes (required for streams) */
|
|
95
|
+
byteLength?: number;
|
|
96
|
+
/** Path to file on disk (alternative to content) */
|
|
97
|
+
filePath?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Bit reader interface for BZIP2 decompression
|
|
101
|
+
*/
|
|
102
|
+
export interface IBitReader {
|
|
103
|
+
(n: number | null): number | void;
|
|
104
|
+
bytesRead: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Huffman group for BZIP2 decompression
|
|
108
|
+
*/
|
|
109
|
+
export interface IHuffmanGroup {
|
|
110
|
+
permute: Int32Array;
|
|
111
|
+
limit: Int32Array;
|
|
112
|
+
base: Int32Array;
|
|
113
|
+
minLen: number;
|
|
114
|
+
maxLen: number;
|
|
115
|
+
}
|
package/dist_ts/plugins.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as stream from 'stream';
|
|
3
|
-
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as stream from 'node:stream';
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as fsPromises from 'node:fs/promises';
|
|
5
|
+
export { path, stream, fs, fsPromises };
|
|
6
|
+
/**
|
|
7
|
+
* List files in a directory recursively, returning relative paths
|
|
8
|
+
*/
|
|
9
|
+
export declare function listFileTree(dirPath: string, _pattern?: string): Promise<string[]>;
|
|
4
10
|
import * as smartfile from '@push.rocks/smartfile';
|
|
5
11
|
import * as smartdelay from '@push.rocks/smartdelay';
|
|
6
12
|
import * as smartpath from '@push.rocks/smartpath';
|
package/dist_ts/plugins.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
// node native scope
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as stream from 'stream';
|
|
4
|
-
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as stream from 'node:stream';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as fsPromises from 'node:fs/promises';
|
|
6
|
+
export { path, stream, fs, fsPromises };
|
|
7
|
+
/**
|
|
8
|
+
* List files in a directory recursively, returning relative paths
|
|
9
|
+
*/
|
|
10
|
+
export async function listFileTree(dirPath, _pattern = '**/*') {
|
|
11
|
+
const results = [];
|
|
12
|
+
async function walkDir(currentPath, relativePath = '') {
|
|
13
|
+
const entries = await fsPromises.readdir(currentPath, { withFileTypes: true });
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
const entryRelPath = relativePath ? path.join(relativePath, entry.name) : entry.name;
|
|
16
|
+
const entryFullPath = path.join(currentPath, entry.name);
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
await walkDir(entryFullPath, entryRelPath);
|
|
19
|
+
}
|
|
20
|
+
else if (entry.isFile()) {
|
|
21
|
+
results.push(entryRelPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
await walkDir(dirPath);
|
|
26
|
+
return results;
|
|
27
|
+
}
|
|
5
28
|
// @pushrocks scope
|
|
6
29
|
import * as smartfile from '@push.rocks/smartfile';
|
|
7
30
|
import * as smartdelay from '@push.rocks/smartdelay';
|
|
@@ -18,4 +41,4 @@ import * as fileType from 'file-type';
|
|
|
18
41
|
import * as fflate from 'fflate';
|
|
19
42
|
import tarStream from 'tar-stream';
|
|
20
43
|
export { fileType, fflate, tarStream };
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsb0JBQW9CO0FBQ3BCLE9BQU8sS0FBSyxJQUFJLE1BQU0s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VMsRUFBRSxDQUFDIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartarchive",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.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",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"homepage": "https://code.foss.global/push.rocks/smartarchive#readme",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@push.rocks/smartdelay": "^3.0.5",
|
|
20
|
-
"@push.rocks/smartfile": "^
|
|
20
|
+
"@push.rocks/smartfile": "^13.0.0",
|
|
21
21
|
"@push.rocks/smartpath": "^6.0.0",
|
|
22
22
|
"@push.rocks/smartpromise": "^4.2.3",
|
|
23
23
|
"@push.rocks/smartrequest": "^4.2.2",
|
|
@@ -28,8 +28,7 @@
|
|
|
28
28
|
"@types/tar-stream": "^3.1.4",
|
|
29
29
|
"fflate": "^0.8.2",
|
|
30
30
|
"file-type": "^21.0.0",
|
|
31
|
-
"tar-stream": "^3.1.7"
|
|
32
|
-
"through": "^2.3.8"
|
|
31
|
+
"tar-stream": "^3.1.7"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
34
|
"@git.zone/tsbuild": "^3.1.0",
|
package/readme.hints.md
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
# Smartarchive Development Hints
|
|
2
|
+
|
|
3
|
+
## Dependency Upgrades (2025-01-25)
|
|
4
|
+
|
|
5
|
+
### Completed Upgrades
|
|
6
|
+
- **@git.zone/tsbuild**: ^2.6.6 → ^3.1.0
|
|
7
|
+
- **@git.zone/tsrun**: ^1.3.3 → ^2.0.0
|
|
8
|
+
- **@git.zone/tstest**: ^2.3.4 → ^3.1.3
|
|
9
|
+
- **@push.rocks/smartfile**: ^11.2.7 → ^13.0.0
|
|
10
|
+
|
|
11
|
+
### Migration Notes
|
|
12
|
+
|
|
13
|
+
#### Smartfile v13 Migration
|
|
14
|
+
Smartfile v13 removed filesystem operations (`fs`, `memory`, `fsStream` namespaces). These were replaced with Node.js native `fs` and `fs/promises`:
|
|
15
|
+
|
|
16
|
+
**Replacements made:**
|
|
17
|
+
- `smartfile.fs.ensureDir(path)` → `fsPromises.mkdir(path, { recursive: true })`
|
|
18
|
+
- `smartfile.fs.stat(path)` → `fsPromises.stat(path)`
|
|
19
|
+
- `smartfile.fs.toReadStream(path)` → `fs.createReadStream(path)`
|
|
20
|
+
- `smartfile.fs.toStringSync(path)` → `fsPromises.readFile(path, 'utf8')`
|
|
21
|
+
- `smartfile.fs.listFileTree(dir, pattern)` → custom `listFileTree()` helper
|
|
22
|
+
- `smartfile.fsStream.createReadStream(path)` → `fs.createReadStream(path)`
|
|
23
|
+
- `smartfile.fsStream.createWriteStream(path)` → `fs.createWriteStream(path)`
|
|
24
|
+
- `smartfile.memory.toFs(content, path)` → `fsPromises.writeFile(path, content)`
|
|
25
|
+
|
|
26
|
+
**Still using from smartfile v13:**
|
|
27
|
+
- `SmartFile` class (in-memory file representation)
|
|
28
|
+
- `StreamFile` class (streaming file handling)
|
|
29
|
+
|
|
30
|
+
### Removed Dependencies
|
|
31
|
+
- `through@2.3.8` - was unused in the codebase
|
|
32
|
+
|
|
33
|
+
## Architecture Notes
|
|
34
|
+
|
|
35
|
+
- Uses `fflate` for ZIP/GZIP compression (pure JS, works in browser)
|
|
36
|
+
- Uses `tar-stream` for TAR archive handling
|
|
37
|
+
- Uses `file-type` for MIME type detection
|
|
38
|
+
- Custom BZIP2 implementation in `ts/bzip2/` directory
|