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