@d0paminedriven/fs 7.1.0 → 7.3.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/README.md +104 -51
  2. package/dist/chunk-2IRCHZCF.js +75 -0
  3. package/dist/{chunk-LFHV4PPA.js → chunk-2XQ44ZWR.js} +339 -3
  4. package/dist/{chunk-IUGBPDQJ.js → chunk-6HHKXBIM.js} +5 -2
  5. package/dist/chunk-HPM4IQQR.js +69 -0
  6. package/dist/{chunk-3WB2TSBO.js → chunk-KNLXF622.js} +2 -2
  7. package/dist/chunk-KOKPGEU4.js +69 -0
  8. package/dist/chunk-LQP2FYMK.js +237 -0
  9. package/dist/chunk-NHYRCNMW.js +107 -0
  10. package/dist/chunk-NOOFSAF4.js +165 -0
  11. package/dist/chunk-PTXZQBLV.js +367 -0
  12. package/dist/{chunk-RJ2YQE3C.js → chunk-R63XI7FS.js} +1 -1
  13. package/dist/{chunk-QBG7TFHM.js → chunk-UW52DMHT.js} +2 -2
  14. package/dist/chunk-Z2WZLZC4.js +75 -0
  15. package/dist/fs/index.d.ts +18 -282
  16. package/dist/fs/index.js +13 -6
  17. package/dist/fs-atomic/index.d.ts +38 -0
  18. package/dist/fs-atomic/index.js +14 -0
  19. package/dist/fs-base/index.d.ts +112 -0
  20. package/dist/fs-base/index.js +13 -0
  21. package/dist/fs-core/index.d.ts +24 -0
  22. package/dist/fs-core/index.js +17 -0
  23. package/dist/fs-fetch/index.d.ts +64 -0
  24. package/dist/fs-fetch/index.js +19 -0
  25. package/dist/fs-size/index.d.ts +30 -0
  26. package/dist/fs-size/index.js +16 -0
  27. package/dist/fs-tmp/index.d.ts +194 -0
  28. package/dist/fs-tmp/index.js +18 -0
  29. package/dist/image/index.d.ts +35 -1
  30. package/dist/image/index.js +5 -4
  31. package/dist/index.d.ts +12 -2
  32. package/dist/index.js +36 -8
  33. package/dist/ld/index.d.ts +14 -0
  34. package/dist/ld/index.js +8 -0
  35. package/dist/mime/index.d.ts +1 -0
  36. package/dist/mime/index.js +4 -3
  37. package/dist/types/index.d.ts +12 -12
  38. package/dist/types/index.js +1 -1
  39. package/dist/types/stream.d.ts +9 -0
  40. package/dist/types/stream.js +1 -0
  41. package/dist/url/index.d.ts +1 -0
  42. package/dist/url/index.js +3 -2
  43. package/dist/utils/index.d.ts +2 -1
  44. package/dist/utils/index.js +2 -1
  45. package/package.json +37 -5
  46. package/dist/chunk-3REIEDSC.js +0 -745
  47. package/dist/fs/index.cjs +0 -1818
  48. package/dist/fs/index.d.cts +0 -464
  49. package/dist/image/index.cjs +0 -1071
  50. package/dist/image/index.d.cts +0 -88
  51. package/dist/index.cjs +0 -1838
  52. package/dist/index.d.cts +0 -10
  53. package/dist/mime/index.cjs +0 -509
  54. package/dist/mime/index.d.cts +0 -502
  55. package/dist/types/index.cjs +0 -38
  56. package/dist/types/index.d.cts +0 -333
  57. package/dist/url/index.cjs +0 -181
  58. package/dist/url/index.d.cts +0 -33
  59. package/dist/utils/index.cjs +0 -157
  60. package/dist/utils/index.d.cts +0 -25
@@ -0,0 +1,64 @@
1
+ import { FsTmp } from '../fs-tmp/index.js';
2
+ import '../types/index.js';
3
+ import 'stream';
4
+ import 'buffer';
5
+ import '../fs-core/index.js';
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 '../types/stream.js';
13
+ import '../image/index.js';
14
+ import '../mime/index.js';
15
+ import '../url/index.js';
16
+ import '../utils/index.js';
17
+ import '../ld/index.js';
18
+
19
+ declare class FsFetch extends FsTmp {
20
+ cwd: string;
21
+ constructor(cwd: string);
22
+ assetToBuffer<const T extends string>(path: T): Promise<{
23
+ readonly b64encodedData: `data:audio/aac;base64, ${string}` | `data:application/x-abiword;base64, ${string}` | `data:image/aces;base64, ${string}` | `data:image/apng;base64, ${string}` | `data:application/x-freearc;base64, ${string}` | `data:image/avci;base64, ${string}` | `data:image/avif;base64, ${string}` | `data:video/x-msvideo;base64, ${string}` | `data:application/vnd.amazon.ebook;base64, ${string}` | `data:application/octet-stream;base64, ${string}` | `data:multipart/voice-message;base64, ${string}` | `data:image/bmp;base64, ${string}` | `data:application/x-bzip;base64, ${string}` | `data:application/x-bzip2;base64, ${string}` | `data:application/x-cdf;base64, ${string}` | `data:application/node;base64, ${string}` | `data:text/javascript;base64, ${string}` | `data:application/x-csh;base64, ${string}` | `data:text/css;base64, ${string}` | `data:text/csv;base64, ${string}` | `data:image/x-icon;base64, ${string}` | `data:application/msword;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64, ${string}` | `data:image/dpx;base64, ${string}` | `data:image/emf;base64, ${string}` | `data:application/vnd.ms-fontobject;base64, ${string}` | `data:application/epub+zip;base64, ${string}` | `data:image/gif;base64, ${string}` | `data:model/gltf-binary;base64, ${string}` | `data:model/gltf+json;base64, ${string}` | `data:application/gzip;base64, ${string}` | `data:application/x-gzip;base64, ${string}` | `data:haptics/hjif;base64, ${string}` | `data:haptics/hmpg;base64, ${string}` | `data:text/html;base64, ${string}` | `data:image/vnd.microsoft.icon;base64, ${string}` | `data:text/calendar;base64, ${string}` | `data:haptics/ivs;base64, ${string}` | `data:application/java-archive;base64, ${string}` | `data:image/jpeg;base64, ${string}` | `data:application/json;base64, ${string}` | `data:application/ld+json;base64, ${string}` | `data:image/ktx;base64, ${string}` | `data:image/ktx2;base64, ${string}` | `data:application/vnd.apple.mpegurl;base64, ${string}` | `data:audio/mp4;base64, ${string}` | `data:video/mp4;base64, ${string}` | `data:text/markdown;base64, ${string}` | `data:application/x-mdx;base64, ${string}` | `data:audio/midi;base64, ${string}` | `data:audio/x-midi;base64, ${string}` | `data:audio/mpeg;base64, ${string}` | `data:application/dash+xml;base64, ${string}` | `data:video/mpeg;base64, ${string}` | `data:application/vnd.apple.installer+xml;base64, ${string}` | `data:application/xml;base64, ${string}` | `data:application/x-ndjson;base64, ${string}` | `data:model/obj;base64, ${string}` | `data:text/plain;base64, ${string}` | `data:application/vnd.oasis.opendocument.presentation;base64, ${string}` | `data:application/vnd.oasis.opendocument.spreadsheet;base64, ${string}` | `data:application/vnd.oasis.opendocument.text;base64, ${string}` | `data:audio/ogg;base64, ${string}` | `data:video/ogg;base64, ${string}` | `data:application/ogg;base64, ${string}` | `data:font/otf;base64, ${string}` | `data:image/png;base64, ${string}` | `data:application/pdf;base64, ${string}` | `data:application/x-httpd-php;base64, ${string}` | `data:application/vnd.apple.pkpass;base64, ${string}` | `data:application/vnd.ms-powerpoint;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.presentationml.presentation;base64, ${string}` | `data:text/x-python;base64, ${string}` | `data:application/x-python-code;base64, ${string}` | `data:application/vnd.rar;base64, ${string}` | `data:text/rust;base64, ${string}` | `data:application/rtf;base64, ${string}` | `data:application/x-sh;base64, ${string}` | `data:application/sql;base64, ${string}` | `data:text/event-stream;base64, ${string}` | `data:image/svg+xml;base64, ${string}` | `data:application/x-tar;base64, ${string}` | `data:image/tiff;base64, ${string}` | `data:application/toml;base64, ${string}` | `data:text/typescript;base64, ${string}` | `data:video/mp2t;base64, ${string}` | `data:video/vnd.dlna.mpeg-tts;base64, ${string}` | `data:application/font-sfnt;base64, ${string}` | `data:font/ttf;base64, ${string}` | `data:model/vnd.usdz+zip;base64, ${string}` | `data:application/vnd.visio;base64, ${string}` | `data:text/vtt;base64, ${string}` | `data:application/wasm;base64, ${string}` | `data:audio/wav;base64, ${string}` | `data:audio/webm;base64, ${string}` | `data:video/webm;base64, ${string}` | `data:application/manifest+json;base64, ${string}` | `data:image/webp;base64, ${string}` | `data:font/woff;base64, ${string}` | `data:font/woff2;base64, ${string}` | `data:application/xhtml+xml;base64, ${string}` | `data:application/vnd.ms-excel;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64, ${string}` | `data:text/xml;base64, ${string}` | `data:application/vnd.mozilla.xul+xml;base64, ${string}` | `data:application/yaml;base64, ${string}` | `data:application/zip;base64, ${string}` | `data:application/x-zip-compressed;base64, ${string}` | `data:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
24
+ readonly extension: "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "mpd" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "webmanifest" | "doc" | "node" | "js" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "toml" | "azw" | "mpkg" | "m3u8" | "pkpass" | "xul" | "xls" | "eot" | "ppt" | "odp" | "ods" | "odt" | "pptx" | "xlsx" | "docx" | "rar" | "vsd" | "wasm" | "7z" | "abw" | "bz" | "bz2" | "cda" | "csh" | "arc" | "php" | "mdx" | "ndjson" | "pyc" | "sh" | "tar" | "zip" | "xhtml" | "xml" | "mtlx" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "weba" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "jpe" | "jif" | "jfif" | "pjp" | "pjpeg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "cur" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "html" | "htm" | "mjs" | "cjs" | "md" | "txt" | "rs" | "ts" | "vtt" | "py" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "webm" | "avi";
25
+ }>;
26
+ assetToBufferView<const T extends string>(path: T): Promise<{
27
+ readonly b64encodedData: string;
28
+ readonly extension: "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "mpd" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "webmanifest" | "doc" | "node" | "js" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "toml" | "azw" | "mpkg" | "m3u8" | "pkpass" | "xul" | "xls" | "eot" | "ppt" | "odp" | "ods" | "odt" | "pptx" | "xlsx" | "docx" | "rar" | "vsd" | "wasm" | "7z" | "abw" | "bz" | "bz2" | "cda" | "csh" | "arc" | "php" | "mdx" | "ndjson" | "pyc" | "sh" | "tar" | "zip" | "xhtml" | "xml" | "mtlx" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "weba" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "jpe" | "jif" | "jfif" | "pjp" | "pjpeg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "cur" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "html" | "htm" | "mjs" | "cjs" | "md" | "txt" | "rs" | "ts" | "vtt" | "py" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "webm" | "avi" | undefined;
29
+ }>;
30
+ /**
31
+ *
32
+ * @param inputUrl remote url to fetch data from
33
+ * @param outputPath desired output path relative to the cwd
34
+ * @param useDetectedExtension optional, defaults to true
35
+ *
36
+ * if `useDetectedExtension` is false you must include the file extension in your output path &rarr;
37
+ *
38
+ * 🚫 'public/assets/image-1'
39
+ *
40
+ * ✅ 'public/assets/image-1.png'
41
+ */
42
+ fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
43
+ private knownToBlockHead;
44
+ /**
45
+ *
46
+ * @param inputUrl remote url to fetch data from
47
+ * @param outputPath desired output path relative to the cwd
48
+ * @param useDetectedExtension optional, defaults to true
49
+ *
50
+ * if `useDetectedExtension` is false you must include the file extension in your output path &rarr;
51
+ *
52
+ * 🚫 'public/assets/image-1'
53
+ *
54
+ * ✅ 'public/assets/image-1.png'
55
+ *
56
+ * @description
57
+ * This method is designed for all files regardless of size, but especially for
58
+ * larger files that may not fit into memory (it intelligently determines the best approach on the fly)
59
+ * For files > 100 MB, it streams the data directly to disk instead of loading it all into memory
60
+ */
61
+ fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPathI: O, useDetectedExtension?: boolean): Promise<void>;
62
+ }
63
+
64
+ export { FsFetch };
@@ -0,0 +1,19 @@
1
+ import {
2
+ FsFetch
3
+ } from "../chunk-NOOFSAF4.js";
4
+ import "../chunk-PTXZQBLV.js";
5
+ import "../chunk-KOKPGEU4.js";
6
+ import "../chunk-2IRCHZCF.js";
7
+ import "../chunk-R63XI7FS.js";
8
+ import "../chunk-NHYRCNMW.js";
9
+ import "../chunk-LQP2FYMK.js";
10
+ import "../chunk-2XQ44ZWR.js";
11
+ import "../chunk-KNLXF622.js";
12
+ import "../chunk-UW52DMHT.js";
13
+ import "../chunk-6HHKXBIM.js";
14
+ import "../chunk-Z2WZLZC4.js";
15
+ import "../chunk-7QVYU63E.js";
16
+ export {
17
+ FsFetch
18
+ };
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,30 @@
1
+ import { Unit, SizeOpts } from '../types/index.js';
2
+ import { FsAtomic } from '../fs-atomic/index.js';
3
+ import 'stream';
4
+ import 'buffer';
5
+ import '../fs-base/index.js';
6
+ import 'node:stream';
7
+ import 'stream/web';
8
+ import 'dotenv-expand';
9
+ import '../types/stream.js';
10
+ import '../image/index.js';
11
+ import '../mime/index.js';
12
+ import '../url/index.js';
13
+ import '../utils/index.js';
14
+ import '../ld/index.js';
15
+
16
+ declare class FsSize extends FsAtomic {
17
+ cwd: string;
18
+ constructor(cwd: string);
19
+ private units;
20
+ private u;
21
+ autoFileSizeRaw(size: number | bigint): {
22
+ value: number;
23
+ unit: "B" | "KB" | "MB" | "GB" | "TB" | "PB" | undefined;
24
+ };
25
+ getSize<const S extends Unit | Lowercase<Unit> | "auto">(size: number | bigint, target: S, opts?: SizeOpts): string | number;
26
+ fileSizeMb<const T extends string>(path: T): number;
27
+ fileSize<const T extends string, const S extends Unit | Lowercase<Unit> | "auto">(path: T, target: S, opts?: SizeOpts): string | number;
28
+ }
29
+
30
+ export { FsSize };
@@ -0,0 +1,16 @@
1
+ import {
2
+ FsSize
3
+ } from "../chunk-2IRCHZCF.js";
4
+ import "../chunk-R63XI7FS.js";
5
+ import "../chunk-NHYRCNMW.js";
6
+ import "../chunk-LQP2FYMK.js";
7
+ import "../chunk-2XQ44ZWR.js";
8
+ import "../chunk-KNLXF622.js";
9
+ import "../chunk-UW52DMHT.js";
10
+ import "../chunk-6HHKXBIM.js";
11
+ import "../chunk-Z2WZLZC4.js";
12
+ import "../chunk-7QVYU63E.js";
13
+ export {
14
+ FsSize
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,194 @@
1
+ import { WriteStreamDataShape, 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 'buffer';
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 '../mime/index.js';
14
+ import '../url/index.js';
15
+ import '../utils/index.js';
16
+ import '../ld/index.js';
17
+
18
+ declare class FsTmp extends FsCore {
19
+ cwd: string;
20
+ constructor(cwd: string);
21
+ /**
22
+ * Write data to a file in the system's tmp directory
23
+ * @param filename The filename (can include subdirectories like "img-probe/file.txt")
24
+ * @param data The data to write
25
+ * @param options Optional write stream options
26
+ * @returns The full path to the written file
27
+ * @example
28
+ * ```ts
29
+ * const fs = new Fs(process.cwd());
30
+ * const tmpPath = fs.writeTmp("session-data.json", JSON.stringify(data));
31
+ * // Or with a subdirectory:
32
+ * fs.writeTmp("img-probe/output.png", imageBuffer);
33
+ * ```
34
+ */
35
+ writeTmp<const F extends string>(filename: F, data: WriteStreamDataShape, options?: WriteStreamOptions): void;
36
+ writeTmpAsync<const F extends string>(filename: F, data: string, options?: WriteFileAsyncOptions): Promise<string | void>;
37
+ readTmpAsync<const F extends string>(filename: F): Promise<Buffer<ArrayBufferLike>>;
38
+ /**
39
+ * Read a file from the tmp directory
40
+ * @param filename The filename to read (can include subdirectories)
41
+ * @returns Buffer containing the file data
42
+ * @example
43
+ * ```ts
44
+ * const fs = new Fs(process.cwd());
45
+ * const data = fs.readTmp("session-data.json");
46
+ * const parsed = JSON.parse(data.toString("utf-8"));
47
+ * ```
48
+ */
49
+ readTmp<const F extends string>(filename: F): Buffer<ArrayBuffer>;
50
+ /**
51
+ * Scan the tmp directory for files matching a pattern
52
+ * @param pattern Optional pattern to filter files (e.g., "img-probe")
53
+ * @param options Options for directory reading (defaults to non-recursive to avoid permission issues)
54
+ * @returns Array of matching file paths relative to tmp directory
55
+ * @example
56
+ * ```ts
57
+ * const fs = new Fs(process.cwd());
58
+ * // Get all img-probe files
59
+ * const imgFiles = fs.scanTmp("img-probe");
60
+ * // Get all files in tmp (non-recursive)
61
+ * const allFiles = fs.scanTmp();
62
+ * ```
63
+ */
64
+ scanTmp(pattern?: string | RegExp, options?: ReadDirOptions): string[];
65
+ /**
66
+ * Extract specific files from tmp directory to a target location
67
+ * @param pattern Pattern to match files (e.g., "img-probe")
68
+ * @param targetDir Target directory to extract files to
69
+ * @param options Options for extraction behavior
70
+ * @returns Array of extracted file paths
71
+ * @example
72
+ * ```ts
73
+ * const fs = new Fs(process.cwd());
74
+ * // Extract all img-probe files to ./output
75
+ * const extracted = fs.extractFromTmp("img-probe", "./output");
76
+ * // Extract with custom behavior
77
+ * fs.extractFromTmp("session-", "./sessions", {
78
+ * preserveStructure: true,
79
+ * cleanupAfter: true
80
+ * });
81
+ * ```
82
+ */
83
+ extractFromTmp(pattern: string, targetDir: string, options?: {
84
+ preserveStructure?: boolean;
85
+ cleanupAfter?: boolean;
86
+ overwrite?: boolean;
87
+ }): string[];
88
+ /**
89
+ * Clean up tmp files matching a pattern
90
+ * @param pattern Pattern to match files for deletion
91
+ * @param maxAge Optional max age in milliseconds (only delete files older than this)
92
+ * @returns Number of files removed
93
+ * @example
94
+ * ```ts
95
+ * const fs = new Fs(process.cwd());
96
+ * // Remove all img-probe files
97
+ * fs.cleanupTmp("img-probe");
98
+ * // Remove session files older than 1 hour
99
+ * fs.cleanupTmp("session-", 60 * 60 * 1000);
100
+ * ```
101
+ */
102
+ cleanupTmp(pattern: string, maxAge?: number): number;
103
+ /**
104
+ * Generate a unique tmp filename with optional prefix
105
+ * @param prefix Optional prefix for the filename
106
+ * @param extension Optional file extension (without dot)
107
+ * @returns Unique filename
108
+ * @example
109
+ * ```ts
110
+ * const fs = new Fs(process.cwd());
111
+ * const filename = fs.uniqueTmpName("img-probe", "png");
112
+ * // Returns: "img-probe-1701234567890-a3b2c1.png"
113
+ * ```
114
+ */
115
+ uniqueTmpName(prefix?: string, extension?: string): string;
116
+ /**
117
+ * Async generator for cleaning tmp files with batched removal
118
+ * @param pattern Pattern to match files for deletion
119
+ * @param batchSize Number of files to remove per batch (default 10)
120
+ * @yields Progress information during cleanup
121
+ * @returns Final cleanup summary
122
+ * @example
123
+ * ```ts
124
+ * const fs = new Fs(process.cwd());
125
+ * // Clean up with progress tracking
126
+ * for await (const progress of fs.cleanTmpGenerator("session-", 25)) {
127
+ * console.log(progress);
128
+ * }
129
+ * ```
130
+ */
131
+ cleanTmpGenerator(pattern: string | RegExp, batchSize?: number): AsyncGenerator<{
132
+ action: "removing";
133
+ batch: string[];
134
+ batchNumber: number;
135
+ totalBatches: number;
136
+ totalFound: number;
137
+ removed: number;
138
+ batchSize?: undefined;
139
+ totalRemoved?: undefined;
140
+ remaining?: undefined;
141
+ } | {
142
+ action: "batch-complete";
143
+ batchNumber: number;
144
+ batchSize: number;
145
+ totalRemoved: number;
146
+ remaining: number;
147
+ batch?: undefined;
148
+ totalBatches?: undefined;
149
+ totalFound?: undefined;
150
+ removed?: undefined;
151
+ }, {
152
+ action: "complete";
153
+ totalRemoved: number;
154
+ totalBatches: number;
155
+ pattern: string;
156
+ }, unknown>;
157
+ /**
158
+ * Async version of withWs with atomic write support and progress tracking
159
+ * @param path Target file path
160
+ * @param data Streamable data to write
161
+ * @param options Optional atomic write and abort signal
162
+ * @returns Promise with path and bytes written
163
+ * @example
164
+ * ```ts
165
+ * const fs = new Fs(process.cwd());
166
+ * // Simple async write
167
+ * const result = await fs.asyncWithWs("output.txt", "Hello World");
168
+ * console.log(`Wrote ${result.bytes} bytes to ${result.path}`);
169
+ *
170
+ * // Atomic write with temp file
171
+ * const { path, bytes } = await fs.asyncWithWs(
172
+ * "critical-data.json",
173
+ * JSON.stringify(data),
174
+ * { atomic: true }
175
+ * );
176
+ * ```
177
+ */
178
+ asyncWithWs(path: string, data: Streamable, options?: {
179
+ atomic?: boolean;
180
+ signal?: AbortSignal;
181
+ }): Promise<string | {
182
+ path: string;
183
+ bytes: number;
184
+ newPath?: undefined;
185
+ newBytes?: undefined;
186
+ } | {
187
+ path: string;
188
+ bytes: number;
189
+ newPath: string;
190
+ newBytes: number;
191
+ } | undefined>;
192
+ }
193
+
194
+ export { FsTmp };
@@ -0,0 +1,18 @@
1
+ import {
2
+ FsTmp
3
+ } from "../chunk-PTXZQBLV.js";
4
+ import "../chunk-KOKPGEU4.js";
5
+ import "../chunk-2IRCHZCF.js";
6
+ import "../chunk-R63XI7FS.js";
7
+ import "../chunk-NHYRCNMW.js";
8
+ import "../chunk-LQP2FYMK.js";
9
+ import "../chunk-2XQ44ZWR.js";
10
+ import "../chunk-KNLXF622.js";
11
+ import "../chunk-UW52DMHT.js";
12
+ import "../chunk-6HHKXBIM.js";
13
+ import "../chunk-Z2WZLZC4.js";
14
+ import "../chunk-7QVYU63E.js";
15
+ export {
16
+ FsTmp
17
+ };
18
+ //# sourceMappingURL=index.js.map
@@ -1,15 +1,49 @@
1
+ import { ImageSpecs } from '../types/index.js';
1
2
  import { MimeService } from '../mime/index.js';
2
- import '../types/index.js';
3
+ import { Readable } from 'node:stream';
3
4
  import 'stream';
4
5
  import 'buffer';
5
6
  import '../url/index.js';
6
7
  import '../utils/index.js';
8
+ import '../ld/index.js';
7
9
 
8
10
  declare class ImageService extends MimeService {
11
+ cwd: string;
12
+ constructor(cwd: string);
13
+ /**
14
+ * Read exactly N bytes from a stream, returning a Buffer
15
+ * Closes stream after reading or on error
16
+ */
17
+ private readBytes;
18
+ /**
19
+ * Extract image metadata from a stream, reading only ~4KB for most formats
20
+ * Automatically handles PNG, JPEG, GIF, BMP, WebP, and AVIF
21
+ */
22
+ extractFromStream(stream: Readable): Promise<ImageSpecs>;
23
+ /**
24
+ * Extract metadata from file path using streaming (memory efficient)
25
+ */
26
+ extractFromPath(filePath: string): Promise<ImageSpecs>;
27
+ private isPNG;
28
+ private isJPEG;
29
+ private isGIF;
30
+ private isBMP;
31
+ private isWebP;
32
+ private isAVIF;
33
+ private extractPNGFromBuffer;
34
+ private extractJPEGFromBuffer;
35
+ private extractGIFFromBuffer;
36
+ private extractBMPFromBuffer;
37
+ private extractWebPFromBuffer;
38
+ private extractAVIFFromBuffer;
9
39
  private parseExif;
10
40
  private parseXmpFromAvif;
11
41
  private readVarSize;
12
42
  private findBox;
43
+ /**
44
+ * Legacy method that processes entire buffer
45
+ * Use extractFromStream or extractFromPath for better memory efficiency
46
+ */
13
47
  getImageSpecsWorkup(buffer: Buffer<ArrayBufferLike>): {
14
48
  width: number;
15
49
  height: number;
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  ImageService
3
- } from "../chunk-LFHV4PPA.js";
4
- import "../chunk-3WB2TSBO.js";
5
- import "../chunk-QBG7TFHM.js";
6
- import "../chunk-IUGBPDQJ.js";
3
+ } from "../chunk-2XQ44ZWR.js";
4
+ import "../chunk-KNLXF622.js";
5
+ import "../chunk-UW52DMHT.js";
6
+ import "../chunk-6HHKXBIM.js";
7
+ import "../chunk-Z2WZLZC4.js";
7
8
  import "../chunk-7QVYU63E.js";
8
9
  export {
9
10
  ImageService
package/dist/index.d.ts CHANGED
@@ -1,10 +1,20 @@
1
1
  export { default as Fs } from './fs/index.js';
2
+ export { FsAtomic } from './fs-atomic/index.js';
3
+ export { FsBase } from './fs-base/index.js';
4
+ export { FsCore } from './fs-core/index.js';
5
+ export { FsFetch } from './fs-fetch/index.js';
6
+ export { FsSize } from './fs-size/index.js';
7
+ export { FsTmp } from './fs-tmp/index.js';
2
8
  export { ImageService } from './image/index.js';
9
+ export { LevenshteinDistance } from './ld/index.js';
3
10
  export { AllMimeTypes, FileExtension, FileExtensionToMimeType, InferTopLevelPresent, MimeService, MimeTopLevelType, MimeType, MimeTypeToFileExtension, PresentMimeTopLevelTypes, extMimeMap, mimeToExt } from './mime/index.js';
4
- export { Abortable, ArrFieldReplacer, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BoxInfo, BufferEncodingUnion, CTR, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, DX, DeepPartial, DeepPartialFields, DeepReplace, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, ImageSpecs, InferDepth, InjectScriptsProps, IsExact, IsOptional, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OnlyOptional, OnlyRequired, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, RTC, ReadDirOptions, ReadDirOptionsEntity, ReadDirProps, RemoveFields, RequireNested, RequiredToConditional, Rm, RmDirOptions, RmDirProps, Signals, SizeOpts, StdioOptions, TCN, TypedArray, Unenumerate, Unit, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR, unitsObj } from './types/index.js';
11
+ export { Abortable, ArrFieldReplacer, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BoxInfo, BufferEncodingUnion, CTR, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, DX, DeepPartial, DeepPartialFields, DeepReplace, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, ImageSpecs, InferDepth, InjectScriptsProps, IsExact, IsOptional, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, NoParamCallback, ObjEncodingOptions, OmitSrc, OnlyOptional, OnlyRequired, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, RTC, ReadDirOptions, ReadDirOptionsEntity, ReadDirProps, RemoveFields, RequireNested, RequiredToConditional, Rm, RmOptions, Signals, SizeOpts, StdioOptions, TCN, TypedArray, Unenumerate, Unit, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR, unitsObj } from './types/index.js';
12
+ export { AsyncIter, Bin, Streamable, WebRS } from './types/stream.js';
5
13
  export { HandleQueryParamsOrHash, InferExtensionIfPresent, LastSegment, SplitForwardSlash, UrlFileExt, UrlService } from './url/index.js';
6
14
  export { UtilsService } from './utils/index.js';
7
- import 'dotenv-expand';
8
15
  import 'sharp';
9
16
  import 'stream';
10
17
  import 'buffer';
18
+ import 'node:stream';
19
+ import 'stream/web';
20
+ import 'dotenv-expand';
package/dist/index.js CHANGED
@@ -1,27 +1,55 @@
1
1
  import {
2
2
  Fs
3
- } from "./chunk-3REIEDSC.js";
3
+ } from "./chunk-HPM4IQQR.js";
4
+ import {
5
+ FsFetch
6
+ } from "./chunk-NOOFSAF4.js";
7
+ import {
8
+ FsTmp
9
+ } from "./chunk-PTXZQBLV.js";
10
+ import {
11
+ FsCore
12
+ } from "./chunk-KOKPGEU4.js";
13
+ import {
14
+ FsSize
15
+ } from "./chunk-2IRCHZCF.js";
16
+ import {
17
+ unitsObj
18
+ } from "./chunk-R63XI7FS.js";
19
+ import {
20
+ FsAtomic
21
+ } from "./chunk-NHYRCNMW.js";
22
+ import {
23
+ FsBase
24
+ } from "./chunk-LQP2FYMK.js";
4
25
  import {
5
26
  ImageService
6
- } from "./chunk-LFHV4PPA.js";
27
+ } from "./chunk-2XQ44ZWR.js";
7
28
  import {
8
29
  MimeService,
9
30
  extMimeMap,
10
31
  mimeToExt
11
- } from "./chunk-3WB2TSBO.js";
12
- import {
13
- unitsObj
14
- } from "./chunk-RJ2YQE3C.js";
32
+ } from "./chunk-KNLXF622.js";
15
33
  import {
16
34
  UrlService
17
- } from "./chunk-QBG7TFHM.js";
35
+ } from "./chunk-UW52DMHT.js";
18
36
  import {
19
37
  UtilsService
20
- } from "./chunk-IUGBPDQJ.js";
38
+ } from "./chunk-6HHKXBIM.js";
39
+ import {
40
+ LevenshteinDistance
41
+ } from "./chunk-Z2WZLZC4.js";
21
42
  import "./chunk-7QVYU63E.js";
22
43
  export {
23
44
  Fs,
45
+ FsAtomic,
46
+ FsBase,
47
+ FsCore,
48
+ FsFetch,
49
+ FsSize,
50
+ FsTmp,
24
51
  ImageService,
52
+ LevenshteinDistance,
25
53
  MimeService,
26
54
  UrlService,
27
55
  UtilsService,
@@ -0,0 +1,14 @@
1
+ declare class LevenshteinDistance {
2
+ private createMatrix;
3
+ private inBounds;
4
+ private getCell;
5
+ private setCell;
6
+ /**
7
+ * Computes the Levenshtein distance between two strings, i.e.,
8
+ * the minimum number of single-character edits (insertions,
9
+ * deletions, or substitutions) needed to transform `a` into `b`.
10
+ */
11
+ calculate(a?: string | null, b?: string | null): number;
12
+ }
13
+
14
+ export { LevenshteinDistance };
@@ -0,0 +1,8 @@
1
+ import {
2
+ LevenshteinDistance
3
+ } from "../chunk-Z2WZLZC4.js";
4
+ import "../chunk-7QVYU63E.js";
5
+ export {
6
+ LevenshteinDistance
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -3,6 +3,7 @@ import { UrlService } from '../url/index.js';
3
3
  import 'stream';
4
4
  import 'buffer';
5
5
  import '../utils/index.js';
6
+ import '../ld/index.js';
6
7
 
7
8
  declare const extMimeMap: {
8
9
  readonly aac: readonly ["audio/aac"];
@@ -2,9 +2,10 @@ import {
2
2
  MimeService,
3
3
  extMimeMap,
4
4
  mimeToExt
5
- } from "../chunk-3WB2TSBO.js";
6
- import "../chunk-QBG7TFHM.js";
7
- import "../chunk-IUGBPDQJ.js";
5
+ } from "../chunk-KNLXF622.js";
6
+ import "../chunk-UW52DMHT.js";
7
+ import "../chunk-6HHKXBIM.js";
8
+ import "../chunk-Z2WZLZC4.js";
8
9
  import "../chunk-7QVYU63E.js";
9
10
  export {
10
11
  MimeService,
@@ -100,7 +100,7 @@ type WriteStreamOptions = BufferEncodingUnion | {
100
100
  };
101
101
  type WriteFileAsyncDataUnion = WithImplicitCoercion<string> | {
102
102
  [Symbol.toPrimitive](hint: "string"): string;
103
- };
103
+ } | string;
104
104
  interface ReadDirOptionsEntity extends ObjEncodingOptions {
105
105
  withFileTypes?: false | undefined;
106
106
  recursive?: boolean | undefined;
@@ -111,17 +111,23 @@ type ReadDirOptions = {
111
111
  type WriteFileAsyncOptions = (ObjEncodingOptions & {
112
112
  mode?: Mode | undefined;
113
113
  flag?: OpenMode | undefined;
114
+ flush?: boolean | undefined;
114
115
  } & Abortable) | BufferEncodingUnion | null;
115
116
  type WriteFileAsyncProps<T extends string = string> = {
116
117
  path: T;
117
- cwd: string;
118
118
  data: WriteFileAsyncDataUnion;
119
119
  options?: (ObjEncodingOptions & {
120
120
  mode?: Mode | undefined;
121
121
  flag?: OpenMode | undefined;
122
+ flush?: boolean | undefined;
122
123
  } & Abortable) | BufferEncodingUnion | null;
123
124
  };
124
- type RmDirOptions = {
125
+ type RmOptions = {
126
+ /**
127
+ * When `true`, exceptions will be ignored if `path` does not exist.
128
+ * @default true
129
+ */
130
+ force?: boolean | undefined;
125
131
  /**
126
132
  * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
127
133
  * `EPERM` error is encountered, Node.js will retry the operation with a linear
@@ -132,13 +138,9 @@ type RmDirOptions = {
132
138
  */
133
139
  maxRetries?: number | undefined;
134
140
  /**
135
- * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
136
- * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
137
- * Use `fs.rm(path, { recursive: true, force: true })` instead.
138
- *
139
141
  * If `true`, perform a recursive directory removal. In
140
142
  * recursive mode, operations are retried on failure.
141
- * @default false
143
+ * @default true
142
144
  */
143
145
  recursive?: boolean | undefined;
144
146
  /**
@@ -148,9 +150,7 @@ type RmDirOptions = {
148
150
  */
149
151
  retryDelay?: number | undefined;
150
152
  };
151
- type RmDirProps = {
152
- options?: RmDirOptions;
153
- }["options"];
153
+ type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
154
154
  type ReadDirProps<T extends string> = {
155
155
  path: T;
156
156
  options?: ReadDirOptions;
@@ -330,4 +330,4 @@ interface BoxInfo {
330
330
  size: number;
331
331
  }
332
332
 
333
- export { type Abortable, type ArrFieldReplacer, type ArrayBufferView, type ArrayOrReadOnlyArray, type BashEnv, type BoxInfo, type BufferEncodingUnion, type CTR, type CoercionUnion, type CommonExecOptions, type CommonOptions, type ConditionalPromise, type ConditionalToRequired, type DX, type DeepPartial, type DeepPartialFields, type DeepReplace, type Depth, type Dict, type Equal, type ExcludeFieldEnumerable, type ExecSyncOptions, type ExecSyncOptionsWithBufferEncoding, type ExecSyncOptionsWithStringEncoding, type ExecuteCommandProps, type Expect, type Extends, type FieldToConditionallyNever, type IOType, type ImageSpecs, type InferDepth, type InjectScriptsProps, type IsExact, type IsOptional, type MkDirOptions, type MkDirSyncOptions, type MkDirSyncProps, type Mode, type ObjEncodingOptions, type OmitSrc, type OnlyOptional, type OnlyRequired, type OpenMode, type ParsedUrlInfo, type ProcessEnv, type ProcessEnvOptions, type RTC, type ReadDirOptions, type ReadDirOptionsEntity, type ReadDirProps, type RemoveFields, type RequireNested, type RequiredToConditional, type Rm, type RmDirOptions, type RmDirProps, type Signals, type SizeOpts, type StdioOptions, type TCN, type TypedArray, type Unenumerate, type Unit, type UnwrapPromise, type Without, type WriteFileAsyncDataUnion, type WriteFileAsyncOptions, type WriteFileAsyncProps, type WriteStreamDataShape, type WriteStreamOptions, type WriteStreamProps, type XOR, unitsObj };
333
+ export { type Abortable, type ArrFieldReplacer, type ArrayBufferView, type ArrayOrReadOnlyArray, type BashEnv, type BoxInfo, type BufferEncodingUnion, type CTR, type CoercionUnion, type CommonExecOptions, type CommonOptions, type ConditionalPromise, type ConditionalToRequired, type DX, type DeepPartial, type DeepPartialFields, type DeepReplace, type Depth, type Dict, type Equal, type ExcludeFieldEnumerable, type ExecSyncOptions, type ExecSyncOptionsWithBufferEncoding, type ExecSyncOptionsWithStringEncoding, type ExecuteCommandProps, type Expect, type Extends, type FieldToConditionallyNever, type IOType, type ImageSpecs, type InferDepth, type InjectScriptsProps, type IsExact, type IsOptional, type MkDirOptions, type MkDirSyncOptions, type MkDirSyncProps, type Mode, type NoParamCallback, type ObjEncodingOptions, type OmitSrc, type OnlyOptional, type OnlyRequired, type OpenMode, type ParsedUrlInfo, type ProcessEnv, type ProcessEnvOptions, type RTC, type ReadDirOptions, type ReadDirOptionsEntity, type ReadDirProps, type RemoveFields, type RequireNested, type RequiredToConditional, type Rm, type RmOptions, type Signals, type SizeOpts, type StdioOptions, type TCN, type TypedArray, type Unenumerate, type Unit, type UnwrapPromise, type Without, type WriteFileAsyncDataUnion, type WriteFileAsyncOptions, type WriteFileAsyncProps, type WriteStreamDataShape, type WriteStreamOptions, type WriteStreamProps, type XOR, unitsObj };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unitsObj
3
- } from "../chunk-RJ2YQE3C.js";
3
+ } from "../chunk-R63XI7FS.js";
4
4
  import "../chunk-7QVYU63E.js";
5
5
  export {
6
6
  unitsObj
@@ -0,0 +1,9 @@
1
+ import { ReadableStream } from 'stream/web';
2
+
3
+ type Bin = Buffer | Uint8Array;
4
+ type WebRS = ReadableStream<Uint8Array>;
5
+ type AsyncIter = AsyncIterable<Uint8Array>;
6
+ /** Inputs you actually accept — no `any`, no lies. */
7
+ type Streamable = string | Bin | WebRS | AsyncIter;
8
+
9
+ export type { AsyncIter, Bin, Streamable, WebRS };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=stream.js.map