@d0paminedriven/fs 10.1.0 → 11.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/docs/index.d.ts +119 -0
- package/dist/docs/index.js +1027 -0
- package/dist/extract/client.d.ts +54 -0
- package/dist/extract/client.js +118 -0
- package/dist/extract/index.d.ts +69 -0
- package/dist/extract/index.js +622 -0
- package/dist/fs/index.d.ts +19 -55
- package/dist/fs/index.js +88 -19
- package/dist/fs-atomic/index.d.ts +28 -36
- package/dist/fs-atomic/index.js +88 -13
- package/dist/fs-base/index.d.ts +105 -111
- package/dist/fs-base/index.js +188 -12
- package/dist/fs-core/index.d.ts +20 -24
- package/dist/fs-core/index.js +44 -16
- package/dist/fs-fetch/index.d.ts +48 -62
- package/dist/fs-fetch/index.js +146 -18
- package/dist/fs-size/index.d.ts +16 -28
- package/dist/fs-size/index.js +64 -15
- package/dist/fs-tmp/index.d.ts +179 -192
- package/dist/fs-tmp/index.js +321 -17
- package/dist/images/index.d.ts +447 -0
- package/dist/images/index.js +899 -0
- package/dist/images/workup.d.ts +30 -0
- package/dist/images/workup.js +317 -0
- package/dist/index.d.ts +20 -22
- package/dist/index.js +20 -64
- package/dist/ld/index.d.ts +15 -13
- package/dist/ld/index.js +56 -6
- package/dist/mime/index.d.ts +299 -294
- package/dist/mime/index.js +348 -13
- package/dist/mixins/index.d.ts +34 -0
- package/dist/mixins/index.js +54 -0
- package/dist/types/index.d.ts +279 -215
- package/dist/types/index.js +11 -6
- package/dist/types/stream.d.ts +6 -4
- package/dist/types/stream.js +1 -1
- package/dist/url/index.d.ts +15 -18
- package/dist/url/index.js +21 -8
- package/dist/utils/index.d.ts +19 -23
- package/dist/utils/index.js +82 -7
- package/package.json +33 -13
- package/dist/chunk-4D2YBCI6.js +0 -163
- package/dist/chunk-5CACVZVF.js +0 -386
- package/dist/chunk-5H6GE5AO.js +0 -14
- package/dist/chunk-7QVYU63E.js +0 -7
- package/dist/chunk-DNR5ZI2T.js +0 -75
- package/dist/chunk-JZ6JNZZ6.js +0 -77
- package/dist/chunk-L2QMQOEJ.js +0 -366
- package/dist/chunk-NJHN5OE3.js +0 -33
- package/dist/chunk-OHKRQJZH.js +0 -82
- package/dist/chunk-OT5JEQKW.js +0 -139
- package/dist/chunk-PATMSIQK.js +0 -367
- package/dist/chunk-PB5A7ZFD.js +0 -79
- package/dist/chunk-VDKUXJE7.js +0 -240
- package/dist/chunk-Y5QWE4EG.js +0 -1335
- package/dist/chunk-YRCJWFZD.js +0 -107
- package/dist/image/index.d.ts +0 -182
- package/dist/image/index.js +0 -13
- package/dist/image/workup.d.ts +0 -40
- package/dist/image/workup.js +0 -12
package/dist/fs-tmp/index.d.ts
CHANGED
|
@@ -1,196 +1,183 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import 'stream';
|
|
5
|
-
import 'fs';
|
|
6
|
-
import '../fs-size/index.js';
|
|
7
|
-
import '../fs-atomic/index.js';
|
|
8
|
-
import '../fs-base/index.js';
|
|
9
|
-
import 'node:stream';
|
|
10
|
-
import 'stream/web';
|
|
11
|
-
import 'dotenv-expand';
|
|
12
|
-
import '../image/index.js';
|
|
13
|
-
import '@d0paminedriven/metadata';
|
|
14
|
-
import '../image/workup.js';
|
|
15
|
-
import '../mime/index.js';
|
|
16
|
-
import '../url/index.js';
|
|
17
|
-
import '../utils/index.js';
|
|
18
|
-
import '../ld/index.js';
|
|
1
|
+
import { ReadDirOptions, WriteFileAsyncOptions, WriteStreamOptions, WriteableDataType } from "../types/index.js";
|
|
2
|
+
import { Streamable } from "../types/stream.js";
|
|
3
|
+
import { FsCore } from "../fs-core/index.js";
|
|
19
4
|
|
|
5
|
+
//#region src/fs-tmp/index.d.ts
|
|
20
6
|
declare class FsTmp extends FsCore {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
7
|
+
cwd: string;
|
|
8
|
+
constructor(cwd: string);
|
|
9
|
+
/**
|
|
10
|
+
* Write data to a file in the system's tmp directory
|
|
11
|
+
* @param filename The filename (can include subdirectories like "img-probe/file.txt")
|
|
12
|
+
* @param data The data to write
|
|
13
|
+
* @param options Optional write stream options
|
|
14
|
+
* @returns The full path to the written file
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const fs = new Fs(process.cwd());
|
|
18
|
+
* const tmpPath = fs.writeTmp("session-data.json", JSON.stringify(data));
|
|
19
|
+
* // Or with a subdirectory:
|
|
20
|
+
* fs.writeTmp("img-probe/output.png", imageBuffer);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
writeTmp<const F extends string>(filename: F, data: WriteableDataType, options?: WriteStreamOptions): void;
|
|
24
|
+
writeTmpAsync<const F extends string>(filename: F, data: WriteableDataType, options?: WriteFileAsyncOptions): Promise<void | string>;
|
|
25
|
+
readTmpAsync<const F extends string>(filename: F): Promise<NonSharedBuffer>;
|
|
26
|
+
/**
|
|
27
|
+
* Read a file from the tmp directory
|
|
28
|
+
* @param filename The filename to read (can include subdirectories)
|
|
29
|
+
* @returns Buffer containing the file data
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const fs = new Fs(process.cwd());
|
|
33
|
+
* const data = fs.readTmp("session-data.json");
|
|
34
|
+
* const parsed = JSON.parse(data.toString("utf-8"));
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
readTmp<const F extends string>(filename: F): Buffer<ArrayBuffer>;
|
|
38
|
+
/**
|
|
39
|
+
* Scan the tmp directory for files matching a pattern
|
|
40
|
+
* @param pattern Optional pattern to filter files (e.g., "img-probe")
|
|
41
|
+
* @param options Options for directory reading (defaults to non-recursive to avoid permission issues)
|
|
42
|
+
* @returns Array of matching file paths relative to tmp directory
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const fs = new Fs(process.cwd());
|
|
46
|
+
* // Get all img-probe files
|
|
47
|
+
* const imgFiles = fs.scanTmp("img-probe");
|
|
48
|
+
* // Get all files in tmp (non-recursive)
|
|
49
|
+
* const allFiles = fs.scanTmp();
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
scanTmp(pattern?: string | RegExp, options?: ReadDirOptions): string[];
|
|
53
|
+
/**
|
|
54
|
+
* Extract specific files from tmp directory to a target location
|
|
55
|
+
* @param pattern Pattern to match files (e.g., "img-probe")
|
|
56
|
+
* @param targetDir Target directory to extract files to
|
|
57
|
+
* @param options Options for extraction behavior
|
|
58
|
+
* @returns Array of extracted file paths
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const fs = new Fs(process.cwd());
|
|
62
|
+
* // Extract all img-probe files to ./output
|
|
63
|
+
* const extracted = fs.extractFromTmp("img-probe", "./output");
|
|
64
|
+
* // Extract with custom behavior
|
|
65
|
+
* fs.extractFromTmp("session-", "./sessions", {
|
|
66
|
+
* preserveStructure: true,
|
|
67
|
+
* cleanupAfter: true
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
extractFromTmp(pattern: string, targetDir: string, options?: {
|
|
72
|
+
preserveStructure?: boolean;
|
|
73
|
+
cleanupAfter?: boolean;
|
|
74
|
+
overwrite?: boolean;
|
|
75
|
+
}): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Clean up tmp files matching a pattern
|
|
78
|
+
* @param pattern Pattern to match files for deletion
|
|
79
|
+
* @param maxAge Optional max age in milliseconds (only delete files older than this)
|
|
80
|
+
* @returns Number of files removed
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const fs = new Fs(process.cwd());
|
|
84
|
+
* // Remove all img-probe files
|
|
85
|
+
* fs.cleanupTmp("img-probe");
|
|
86
|
+
* // Remove session files older than 1 hour
|
|
87
|
+
* fs.cleanupTmp("session-", 60 * 60 * 1000);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
cleanupTmp(pattern: string, maxAge?: number): number;
|
|
91
|
+
/**
|
|
92
|
+
* Generate a unique tmp filename with optional prefix
|
|
93
|
+
* @param prefix Optional prefix for the filename
|
|
94
|
+
* @param extension Optional file extension (without dot)
|
|
95
|
+
* @returns Unique filename
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const fs = new Fs(process.cwd());
|
|
99
|
+
* const filename = fs.uniqueTmpName("img-probe", "png");
|
|
100
|
+
* // Returns: "img-probe-1701234567890-a3b2c1.png"
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
uniqueTmpName(prefix?: string, extension?: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Async generator for cleaning tmp files with batched removal
|
|
106
|
+
* @param pattern Pattern to match files for deletion
|
|
107
|
+
* @param batchSize Number of files to remove per batch (default 10)
|
|
108
|
+
* @yields Progress information during cleanup
|
|
109
|
+
* @returns Final cleanup summary
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const fs = new Fs(process.cwd());
|
|
113
|
+
* // Clean up with progress tracking
|
|
114
|
+
* for await (const progress of fs.cleanTmpGenerator("session-", 25)) {
|
|
115
|
+
* console.log(progress);
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
cleanTmpGenerator(pattern: string | RegExp, batchSize?: number): AsyncGenerator<{
|
|
120
|
+
action: "removing";
|
|
121
|
+
batch: string[];
|
|
122
|
+
batchNumber: number;
|
|
123
|
+
totalBatches: number;
|
|
124
|
+
totalFound: number;
|
|
125
|
+
removed: number;
|
|
126
|
+
batchSize?: undefined;
|
|
127
|
+
totalRemoved?: undefined;
|
|
128
|
+
remaining?: undefined;
|
|
129
|
+
} | {
|
|
130
|
+
batch?: undefined;
|
|
131
|
+
totalBatches?: undefined;
|
|
132
|
+
totalFound?: undefined;
|
|
133
|
+
removed?: undefined;
|
|
134
|
+
action: "batch-complete";
|
|
135
|
+
batchNumber: number;
|
|
136
|
+
batchSize: number;
|
|
137
|
+
totalRemoved: number;
|
|
138
|
+
remaining: number;
|
|
139
|
+
}, {
|
|
140
|
+
action: "complete";
|
|
141
|
+
totalRemoved: number;
|
|
142
|
+
totalBatches: number;
|
|
143
|
+
pattern: string;
|
|
144
|
+
}, unknown>;
|
|
145
|
+
/**
|
|
146
|
+
* Async version of withWs with atomic write support and progress tracking
|
|
147
|
+
* @param path Target file path
|
|
148
|
+
* @param data Streamable data to write
|
|
149
|
+
* @param options Optional atomic write and abort signal
|
|
150
|
+
* @returns Promise with path and bytes written
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* const fs = new Fs(process.cwd());
|
|
154
|
+
* // Simple async write
|
|
155
|
+
* const result = await fs.asyncWithWs("output.txt", "Hello World");
|
|
156
|
+
* console.log(`Wrote ${result.bytes} bytes to ${result.path}`);
|
|
157
|
+
*
|
|
158
|
+
* // Atomic write with temp file
|
|
159
|
+
* const { path, bytes } = await fs.asyncWithWs(
|
|
160
|
+
* "critical-data.json",
|
|
161
|
+
* JSON.stringify(data),
|
|
162
|
+
* { atomic: true }
|
|
163
|
+
* );
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
asyncWithWs(path: string, data: Streamable, options?: {
|
|
167
|
+
atomic?: boolean;
|
|
168
|
+
signal?: AbortSignal;
|
|
169
|
+
}): Promise<string | {
|
|
170
|
+
path: string;
|
|
171
|
+
bytes: number;
|
|
172
|
+
newPath?: undefined;
|
|
173
|
+
newBytes?: undefined;
|
|
174
|
+
} | {
|
|
175
|
+
path: string;
|
|
176
|
+
bytes: number;
|
|
177
|
+
newPath: string;
|
|
178
|
+
newBytes: number;
|
|
179
|
+
} | undefined>;
|
|
194
180
|
}
|
|
195
|
-
|
|
181
|
+
//#endregion
|
|
196
182
|
export { FsTmp };
|
|
183
|
+
//# sourceMappingURL=index.d.ts.map
|