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