@d0paminedriven/fs 6.3.0 → 7.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.
@@ -2,9 +2,10 @@ import expand from 'dotenv-expand';
2
2
  import sharp from 'sharp';
3
3
  import { ReadDirOptions, ExecuteCommandProps, MkDirSyncOptions, Unit, SizeOpts, WriteStreamDataShape, WriteStreamOptions, WriteFileAsyncDataUnion, WriteFileAsyncOptions, RmDirOptions } from '../types/index.cjs';
4
4
  import { MimeService } from '../mime/index.cjs';
5
+ import '../url/index.cjs';
6
+ import '../utils/index.cjs';
5
7
  import 'stream';
6
8
  import 'buffer';
7
- import '../url/index.cjs';
8
9
 
9
10
  declare class Fs extends MimeService {
10
11
  cwd: string;
@@ -134,6 +135,10 @@ declare class Fs extends MimeService {
134
135
  * ✅ 'public/assets/image-1.png'
135
136
  */
136
137
  fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
138
+ parseExif(buffer: Buffer, app1Pos: number, _app1Size: number): {
139
+ orientation: number | null;
140
+ dateTimeOriginal: string | null;
141
+ };
137
142
  /**
138
143
  *
139
144
  * @param inputUrl remote url to fetch data from
@@ -152,30 +157,78 @@ declare class Fs extends MimeService {
152
157
  */
153
158
  fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPathI: O, useDetectedExtension?: boolean): Promise<void>;
154
159
  private findBox;
155
- getImageSize(filePath: string): Promise<{
160
+ getImageSpecs(filePath: string): Promise<{
156
161
  width: number;
157
162
  height: number;
158
- type: "png";
163
+ format: "png";
164
+ frames: number;
165
+ animated: boolean;
166
+ hasAlpha: boolean;
167
+ orientation: null;
168
+ aspectRatio: number;
169
+ colorSpace: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed";
170
+ iccProfile: string | null;
171
+ exifDateTimeOriginal: string | null;
159
172
  } | {
160
173
  width: number;
161
174
  height: number;
162
- type: "jpeg";
175
+ format: "jpeg";
176
+ frames: number;
177
+ animated: false;
178
+ hasAlpha: false;
179
+ orientation: number | null;
180
+ aspectRatio: number;
181
+ colorSpace: "unknown" | "grayscale" | "ycbcr" | "ycck";
182
+ iccProfile: string | null;
183
+ exifDateTimeOriginal: string | null;
163
184
  } | {
164
185
  width: number;
165
186
  height: number;
166
- type: "gif";
187
+ format: "gif";
188
+ frames: number;
189
+ animated: boolean;
190
+ hasAlpha: null;
191
+ orientation: null;
192
+ aspectRatio: number;
193
+ colorSpace: "indexed";
194
+ iccProfile: null;
195
+ exifDateTimeOriginal: null;
167
196
  } | {
168
197
  width: number;
169
198
  height: number;
170
- type: "bmp";
199
+ format: "bmp";
200
+ frames: number;
201
+ animated: false;
202
+ hasAlpha: null;
203
+ orientation: number;
204
+ aspectRatio: number;
205
+ colorSpace: "rgb" | "indexed";
206
+ iccProfile: null;
207
+ exifDateTimeOriginal: null;
171
208
  } | {
172
209
  width: number;
173
210
  height: number;
174
- type: "webp";
211
+ format: "webp";
212
+ frames: number;
213
+ animated: boolean;
214
+ hasAlpha: boolean;
215
+ orientation: null;
216
+ aspectRatio: number;
217
+ colorSpace: "unknown" | "rgb" | "rgba";
218
+ iccProfile: string | null;
219
+ exifDateTimeOriginal: null;
175
220
  } | {
176
221
  width: number;
177
222
  height: number;
178
- type: "avif";
223
+ format: "avif";
224
+ frames: number;
225
+ animated: boolean;
226
+ hasAlpha: true | null;
227
+ orientation: null;
228
+ aspectRatio: number;
229
+ colorSpace: "unknown" | "rgb" | "rgba" | "grayscale-alpha" | "ycbcr" | "ycck";
230
+ iccProfile: string | null;
231
+ exifDateTimeOriginal: null;
179
232
  }>;
180
233
  /**
181
234
  *
@@ -213,7 +266,7 @@ declare class Fs extends MimeService {
213
266
  * fs.writeTmp("img-probe/output.png", imageBuffer);
214
267
  * ```
215
268
  */
216
- writeTmp<const F extends string>(filename: F, data: WriteStreamDataShape, options?: WriteStreamOptions): string;
269
+ writeTmp<const F extends string>(filename: F, data: WriteStreamDataShape, options?: WriteStreamOptions): void;
217
270
  /**
218
271
  * Read a file from the tmp directory
219
272
  * @param filename The filename to read (can include subdirectories)
@@ -240,7 +293,7 @@ declare class Fs extends MimeService {
240
293
  * const allFiles = fs.scanTmp();
241
294
  * ```
242
295
  */
243
- scanTmp(pattern?: string, options?: ReadDirOptions): string[];
296
+ scanTmp(pattern?: string | RegExp, options?: ReadDirOptions): string[];
244
297
  /**
245
298
  * Extract specific files from tmp directory to a target location
246
299
  * @param pattern Pattern to match files (e.g., "img-probe")
@@ -279,6 +332,7 @@ declare class Fs extends MimeService {
279
332
  * ```
280
333
  */
281
334
  cleanupTmp(pattern: string, maxAge?: number): number;
335
+ rmTmpFile<const V extends string>(filename: V): void;
282
336
  /**
283
337
  * Generate a unique tmp filename with optional prefix
284
338
  * @param prefix Optional prefix for the filename
@@ -292,6 +346,47 @@ declare class Fs extends MimeService {
292
346
  * ```
293
347
  */
294
348
  uniqueTmpName(prefix?: string, extension?: string): string;
349
+ /**
350
+ * Async generator for cleaning tmp files with batched removal
351
+ * @param pattern Pattern to match files for deletion
352
+ * @param batchSize Number of files to remove per batch (default 10)
353
+ * @yields Progress information during cleanup
354
+ * @returns Final cleanup summary
355
+ * @example
356
+ * ```ts
357
+ * const fs = new Fs(process.cwd());
358
+ * // Clean up with progress tracking
359
+ * for await (const progress of fs.cleanTmpGenerator("session-", 25)) {
360
+ * console.log(progress);
361
+ * }
362
+ * ```
363
+ */
364
+ cleanTmpGenerator(pattern: string | RegExp, batchSize?: number): AsyncGenerator<{
365
+ action: "removing";
366
+ batch: string[];
367
+ batchNumber: number;
368
+ totalBatches: number;
369
+ totalFound: number;
370
+ removed: number;
371
+ batchSize?: undefined;
372
+ totalRemoved?: undefined;
373
+ remaining?: undefined;
374
+ } | {
375
+ action: "batch-complete";
376
+ batchNumber: number;
377
+ batchSize: number;
378
+ totalRemoved: number;
379
+ remaining: number;
380
+ batch?: undefined;
381
+ totalBatches?: undefined;
382
+ totalFound?: undefined;
383
+ removed?: undefined;
384
+ }, {
385
+ action: "complete";
386
+ totalRemoved: number;
387
+ totalBatches: number;
388
+ pattern: string;
389
+ }, unknown>;
295
390
  }
296
391
 
297
392
  export = Fs;
@@ -2,9 +2,10 @@ import expand from 'dotenv-expand';
2
2
  import sharp from 'sharp';
3
3
  import { ReadDirOptions, ExecuteCommandProps, MkDirSyncOptions, Unit, SizeOpts, WriteStreamDataShape, WriteStreamOptions, WriteFileAsyncDataUnion, WriteFileAsyncOptions, RmDirOptions } from '../types/index.js';
4
4
  import { MimeService } from '../mime/index.js';
5
+ import '../url/index.js';
6
+ import '../utils/index.js';
5
7
  import 'stream';
6
8
  import 'buffer';
7
- import '../url/index.js';
8
9
 
9
10
  declare class Fs extends MimeService {
10
11
  cwd: string;
@@ -134,6 +135,10 @@ declare class Fs extends MimeService {
134
135
  * ✅ 'public/assets/image-1.png'
135
136
  */
136
137
  fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
138
+ parseExif(buffer: Buffer, app1Pos: number, _app1Size: number): {
139
+ orientation: number | null;
140
+ dateTimeOriginal: string | null;
141
+ };
137
142
  /**
138
143
  *
139
144
  * @param inputUrl remote url to fetch data from
@@ -152,30 +157,78 @@ declare class Fs extends MimeService {
152
157
  */
153
158
  fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPathI: O, useDetectedExtension?: boolean): Promise<void>;
154
159
  private findBox;
155
- getImageSize(filePath: string): Promise<{
160
+ getImageSpecs(filePath: string): Promise<{
156
161
  width: number;
157
162
  height: number;
158
- type: "png";
163
+ format: "png";
164
+ frames: number;
165
+ animated: boolean;
166
+ hasAlpha: boolean;
167
+ orientation: null;
168
+ aspectRatio: number;
169
+ colorSpace: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed";
170
+ iccProfile: string | null;
171
+ exifDateTimeOriginal: string | null;
159
172
  } | {
160
173
  width: number;
161
174
  height: number;
162
- type: "jpeg";
175
+ format: "jpeg";
176
+ frames: number;
177
+ animated: false;
178
+ hasAlpha: false;
179
+ orientation: number | null;
180
+ aspectRatio: number;
181
+ colorSpace: "unknown" | "grayscale" | "ycbcr" | "ycck";
182
+ iccProfile: string | null;
183
+ exifDateTimeOriginal: string | null;
163
184
  } | {
164
185
  width: number;
165
186
  height: number;
166
- type: "gif";
187
+ format: "gif";
188
+ frames: number;
189
+ animated: boolean;
190
+ hasAlpha: null;
191
+ orientation: null;
192
+ aspectRatio: number;
193
+ colorSpace: "indexed";
194
+ iccProfile: null;
195
+ exifDateTimeOriginal: null;
167
196
  } | {
168
197
  width: number;
169
198
  height: number;
170
- type: "bmp";
199
+ format: "bmp";
200
+ frames: number;
201
+ animated: false;
202
+ hasAlpha: null;
203
+ orientation: number;
204
+ aspectRatio: number;
205
+ colorSpace: "rgb" | "indexed";
206
+ iccProfile: null;
207
+ exifDateTimeOriginal: null;
171
208
  } | {
172
209
  width: number;
173
210
  height: number;
174
- type: "webp";
211
+ format: "webp";
212
+ frames: number;
213
+ animated: boolean;
214
+ hasAlpha: boolean;
215
+ orientation: null;
216
+ aspectRatio: number;
217
+ colorSpace: "unknown" | "rgb" | "rgba";
218
+ iccProfile: string | null;
219
+ exifDateTimeOriginal: null;
175
220
  } | {
176
221
  width: number;
177
222
  height: number;
178
- type: "avif";
223
+ format: "avif";
224
+ frames: number;
225
+ animated: boolean;
226
+ hasAlpha: true | null;
227
+ orientation: null;
228
+ aspectRatio: number;
229
+ colorSpace: "unknown" | "rgb" | "rgba" | "grayscale-alpha" | "ycbcr" | "ycck";
230
+ iccProfile: string | null;
231
+ exifDateTimeOriginal: null;
179
232
  }>;
180
233
  /**
181
234
  *
@@ -213,7 +266,7 @@ declare class Fs extends MimeService {
213
266
  * fs.writeTmp("img-probe/output.png", imageBuffer);
214
267
  * ```
215
268
  */
216
- writeTmp<const F extends string>(filename: F, data: WriteStreamDataShape, options?: WriteStreamOptions): string;
269
+ writeTmp<const F extends string>(filename: F, data: WriteStreamDataShape, options?: WriteStreamOptions): void;
217
270
  /**
218
271
  * Read a file from the tmp directory
219
272
  * @param filename The filename to read (can include subdirectories)
@@ -240,7 +293,7 @@ declare class Fs extends MimeService {
240
293
  * const allFiles = fs.scanTmp();
241
294
  * ```
242
295
  */
243
- scanTmp(pattern?: string, options?: ReadDirOptions): string[];
296
+ scanTmp(pattern?: string | RegExp, options?: ReadDirOptions): string[];
244
297
  /**
245
298
  * Extract specific files from tmp directory to a target location
246
299
  * @param pattern Pattern to match files (e.g., "img-probe")
@@ -279,6 +332,7 @@ declare class Fs extends MimeService {
279
332
  * ```
280
333
  */
281
334
  cleanupTmp(pattern: string, maxAge?: number): number;
335
+ rmTmpFile<const V extends string>(filename: V): void;
282
336
  /**
283
337
  * Generate a unique tmp filename with optional prefix
284
338
  * @param prefix Optional prefix for the filename
@@ -292,6 +346,47 @@ declare class Fs extends MimeService {
292
346
  * ```
293
347
  */
294
348
  uniqueTmpName(prefix?: string, extension?: string): string;
349
+ /**
350
+ * Async generator for cleaning tmp files with batched removal
351
+ * @param pattern Pattern to match files for deletion
352
+ * @param batchSize Number of files to remove per batch (default 10)
353
+ * @yields Progress information during cleanup
354
+ * @returns Final cleanup summary
355
+ * @example
356
+ * ```ts
357
+ * const fs = new Fs(process.cwd());
358
+ * // Clean up with progress tracking
359
+ * for await (const progress of fs.cleanTmpGenerator("session-", 25)) {
360
+ * console.log(progress);
361
+ * }
362
+ * ```
363
+ */
364
+ cleanTmpGenerator(pattern: string | RegExp, batchSize?: number): AsyncGenerator<{
365
+ action: "removing";
366
+ batch: string[];
367
+ batchNumber: number;
368
+ totalBatches: number;
369
+ totalFound: number;
370
+ removed: number;
371
+ batchSize?: undefined;
372
+ totalRemoved?: undefined;
373
+ remaining?: undefined;
374
+ } | {
375
+ action: "batch-complete";
376
+ batchNumber: number;
377
+ batchSize: number;
378
+ totalRemoved: number;
379
+ remaining: number;
380
+ batch?: undefined;
381
+ totalBatches?: undefined;
382
+ totalFound?: undefined;
383
+ removed?: undefined;
384
+ }, {
385
+ action: "complete";
386
+ totalRemoved: number;
387
+ totalBatches: number;
388
+ pattern: string;
389
+ }, unknown>;
295
390
  }
296
391
 
297
392
  export { Fs as default };
package/dist/fs/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  Fs
3
- } from "../chunk-NGBMZGGU.js";
4
- import "../chunk-C6AZRX7V.js";
5
- import "../chunk-MXEE2WS7.js";
6
- import "../chunk-XHN56MDK.js";
3
+ } from "../chunk-CTA73JRX.js";
4
+ import "../chunk-CN45SMBB.js";
5
+ import "../chunk-G27YIWW7.js";
6
+ import "../chunk-QBG7TFHM.js";
7
+ import "../chunk-IUGBPDQJ.js";
7
8
  import "../chunk-7QVYU63E.js";
8
9
  export {
9
10
  Fs as default