@d0paminedriven/fs 6.1.0 → 6.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.
- package/README.md +322 -64
- package/dist/chunk-C6AZRX7V.js +307 -0
- package/dist/{chunk-QMN5ZCE4.js → chunk-IUGBPDQJ.js} +21 -16
- package/dist/{chunk-4X5DVWVM.js → chunk-MXEE2WS7.js} +1 -1
- package/dist/{chunk-XIAKCF2X.js → chunk-NGBMZGGU.js} +358 -8
- package/dist/fs/index.cjs +503 -8
- package/dist/fs/index.d.cts +142 -4
- package/dist/fs/index.d.ts +142 -4
- package/dist/fs/index.js +3 -3
- package/dist/index.cjs +525 -23
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -5
- package/dist/mime/index.cjs +152 -5
- package/dist/mime/index.d.cts +243 -11
- package/dist/mime/index.d.ts +243 -11
- package/dist/mime/index.js +5 -3
- package/dist/types/index.d.cts +93 -31
- package/dist/types/index.d.ts +93 -31
- package/dist/types/index.js +1 -1
- package/dist/utils/index.cjs +20 -15
- package/dist/utils/index.d.cts +2 -6
- package/dist/utils/index.d.ts +2 -6
- package/dist/utils/index.js +1 -1
- package/package.json +14 -14
- package/dist/chunk-EHOBCDHE.js +0 -161
package/dist/fs/index.d.cts
CHANGED
|
@@ -10,6 +10,8 @@ declare class Fs extends MimeService {
|
|
|
10
10
|
cwd: string;
|
|
11
11
|
constructor(cwd: string);
|
|
12
12
|
private get myEnv();
|
|
13
|
+
get tmpDir(): string;
|
|
14
|
+
get tmpDirRelative(): string;
|
|
13
15
|
parseDotEnv(): expand.DotenvExpandOutput;
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
@@ -107,14 +109,15 @@ declare class Fs extends MimeService {
|
|
|
107
109
|
rmdir<const D extends string>(dir: D, options?: RmDirOptions): Promise<void>;
|
|
108
110
|
rmDirSync<const D extends string>(dir: D): void;
|
|
109
111
|
fileToBuffer: <const T extends string>(path: T) => Buffer<ArrayBuffer>;
|
|
112
|
+
fileToBufferAsync: <const T extends string>(path: T) => Promise<Buffer<ArrayBufferLike>>;
|
|
110
113
|
dirContainsDir<const From extends string, const To extends string>(readDir: From, targetDir: To, options?: ReadDirOptions): boolean;
|
|
111
114
|
assetToBuffer<const T extends string>(path: T): Promise<{
|
|
112
|
-
readonly b64encodedData: `data:
|
|
113
|
-
readonly extension: "
|
|
115
|
+
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: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:video/mpeg;base64, ${string}` | `data:application/vnd.apple.installer+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:video/webm;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:application/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}`;
|
|
116
|
+
readonly extension: "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "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" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "weba" | "avi";
|
|
114
117
|
}>;
|
|
115
118
|
assetToBufferView<const T extends string>(path: T): Promise<{
|
|
116
119
|
readonly b64encodedData: string;
|
|
117
|
-
readonly extension: "
|
|
120
|
+
readonly extension: "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "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" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "weba" | "avi" | undefined;
|
|
118
121
|
}>;
|
|
119
122
|
formatHelper<const T extends string>(f: T): string;
|
|
120
123
|
cleanDataUrl<const C extends string>(props: C): string;
|
|
@@ -131,7 +134,49 @@ declare class Fs extends MimeService {
|
|
|
131
134
|
* ✅ 'public/assets/image-1.png'
|
|
132
135
|
*/
|
|
133
136
|
fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
|
|
134
|
-
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* @param inputUrl remote url to fetch data from
|
|
140
|
+
* @param outputPath desired output path relative to the cwd
|
|
141
|
+
* @param useDetectedExtension optional, defaults to true
|
|
142
|
+
*
|
|
143
|
+
* if `useDetectedExtension` is false you must include the file extension in your output path →
|
|
144
|
+
*
|
|
145
|
+
* 🚫 'public/assets/image-1'
|
|
146
|
+
*
|
|
147
|
+
* ✅ 'public/assets/image-1.png'
|
|
148
|
+
*
|
|
149
|
+
* @description
|
|
150
|
+
* This method is designed for large files that may not fit into memory.
|
|
151
|
+
* It streams the data directly to disk instead of loading it all into memory.
|
|
152
|
+
*/
|
|
153
|
+
fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPathI: O, useDetectedExtension?: boolean): Promise<void>;
|
|
154
|
+
private findBox;
|
|
155
|
+
getImageSize(filePath: string): Promise<{
|
|
156
|
+
width: number;
|
|
157
|
+
height: number;
|
|
158
|
+
type: "png";
|
|
159
|
+
} | {
|
|
160
|
+
width: number;
|
|
161
|
+
height: number;
|
|
162
|
+
type: "jpeg";
|
|
163
|
+
} | {
|
|
164
|
+
width: number;
|
|
165
|
+
height: number;
|
|
166
|
+
type: "gif";
|
|
167
|
+
} | {
|
|
168
|
+
width: number;
|
|
169
|
+
height: number;
|
|
170
|
+
type: "bmp";
|
|
171
|
+
} | {
|
|
172
|
+
width: number;
|
|
173
|
+
height: number;
|
|
174
|
+
type: "webp";
|
|
175
|
+
} | {
|
|
176
|
+
width: number;
|
|
177
|
+
height: number;
|
|
178
|
+
type: "avif";
|
|
179
|
+
}>;
|
|
135
180
|
/**
|
|
136
181
|
*
|
|
137
182
|
* @access package-private
|
|
@@ -154,6 +199,99 @@ declare class Fs extends MimeService {
|
|
|
154
199
|
options?: sharp.ResizeOptions;
|
|
155
200
|
};
|
|
156
201
|
}): Promise<Buffer<ArrayBufferLike>>;
|
|
202
|
+
/**
|
|
203
|
+
* Write data to a file in the system's tmp directory
|
|
204
|
+
* @param filename The filename (can include subdirectories like "img-probe/file.txt")
|
|
205
|
+
* @param data The data to write
|
|
206
|
+
* @param options Optional write stream options
|
|
207
|
+
* @returns The full path to the written file
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const fs = new Fs(process.cwd());
|
|
211
|
+
* const tmpPath = fs.writeTmp("session-data.json", JSON.stringify(data));
|
|
212
|
+
* // Or with a subdirectory:
|
|
213
|
+
* fs.writeTmp("img-probe/output.png", imageBuffer);
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
writeTmp<const F extends string>(filename: F, data: WriteStreamDataShape, options?: WriteStreamOptions): string;
|
|
217
|
+
/**
|
|
218
|
+
* Read a file from the tmp directory
|
|
219
|
+
* @param filename The filename to read (can include subdirectories)
|
|
220
|
+
* @returns Buffer containing the file data
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const fs = new Fs(process.cwd());
|
|
224
|
+
* const data = fs.readTmp("session-data.json");
|
|
225
|
+
* const parsed = JSON.parse(data.toString("utf-8"));
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
readTmp<const F extends string>(filename: F): Buffer<ArrayBuffer>;
|
|
229
|
+
/**
|
|
230
|
+
* Scan the tmp directory for files matching a pattern
|
|
231
|
+
* @param pattern Optional pattern to filter files (e.g., "img-probe")
|
|
232
|
+
* @param options Options for directory reading (defaults to non-recursive to avoid permission issues)
|
|
233
|
+
* @returns Array of matching file paths relative to tmp directory
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* const fs = new Fs(process.cwd());
|
|
237
|
+
* // Get all img-probe files
|
|
238
|
+
* const imgFiles = fs.scanTmp("img-probe");
|
|
239
|
+
* // Get all files in tmp (non-recursive)
|
|
240
|
+
* const allFiles = fs.scanTmp();
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
scanTmp(pattern?: string, options?: ReadDirOptions): string[];
|
|
244
|
+
/**
|
|
245
|
+
* Extract specific files from tmp directory to a target location
|
|
246
|
+
* @param pattern Pattern to match files (e.g., "img-probe")
|
|
247
|
+
* @param targetDir Target directory to extract files to
|
|
248
|
+
* @param options Options for extraction behavior
|
|
249
|
+
* @returns Array of extracted file paths
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const fs = new Fs(process.cwd());
|
|
253
|
+
* // Extract all img-probe files to ./output
|
|
254
|
+
* const extracted = fs.extractFromTmp("img-probe", "./output");
|
|
255
|
+
* // Extract with custom behavior
|
|
256
|
+
* fs.extractFromTmp("session-", "./sessions", {
|
|
257
|
+
* preserveStructure: true,
|
|
258
|
+
* cleanupAfter: true
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
extractFromTmp(pattern: string, targetDir: string, options?: {
|
|
263
|
+
preserveStructure?: boolean;
|
|
264
|
+
cleanupAfter?: boolean;
|
|
265
|
+
overwrite?: boolean;
|
|
266
|
+
}): string[];
|
|
267
|
+
/**
|
|
268
|
+
* Clean up tmp files matching a pattern
|
|
269
|
+
* @param pattern Pattern to match files for deletion
|
|
270
|
+
* @param maxAge Optional max age in milliseconds (only delete files older than this)
|
|
271
|
+
* @returns Number of files removed
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* const fs = new Fs(process.cwd());
|
|
275
|
+
* // Remove all img-probe files
|
|
276
|
+
* fs.cleanupTmp("img-probe");
|
|
277
|
+
* // Remove session files older than 1 hour
|
|
278
|
+
* fs.cleanupTmp("session-", 60 * 60 * 1000);
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
cleanupTmp(pattern: string, maxAge?: number): number;
|
|
282
|
+
/**
|
|
283
|
+
* Generate a unique tmp filename with optional prefix
|
|
284
|
+
* @param prefix Optional prefix for the filename
|
|
285
|
+
* @param extension Optional file extension (without dot)
|
|
286
|
+
* @returns Unique filename
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* const fs = new Fs(process.cwd());
|
|
290
|
+
* const filename = fs.uniqueTmpName("img-probe", "png");
|
|
291
|
+
* // Returns: "img-probe-1701234567890-a3b2c1.png"
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
uniqueTmpName(prefix?: string, extension?: string): string;
|
|
157
295
|
}
|
|
158
296
|
|
|
159
297
|
export = Fs;
|
package/dist/fs/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ declare class Fs extends MimeService {
|
|
|
10
10
|
cwd: string;
|
|
11
11
|
constructor(cwd: string);
|
|
12
12
|
private get myEnv();
|
|
13
|
+
get tmpDir(): string;
|
|
14
|
+
get tmpDirRelative(): string;
|
|
13
15
|
parseDotEnv(): expand.DotenvExpandOutput;
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
@@ -107,14 +109,15 @@ declare class Fs extends MimeService {
|
|
|
107
109
|
rmdir<const D extends string>(dir: D, options?: RmDirOptions): Promise<void>;
|
|
108
110
|
rmDirSync<const D extends string>(dir: D): void;
|
|
109
111
|
fileToBuffer: <const T extends string>(path: T) => Buffer<ArrayBuffer>;
|
|
112
|
+
fileToBufferAsync: <const T extends string>(path: T) => Promise<Buffer<ArrayBufferLike>>;
|
|
110
113
|
dirContainsDir<const From extends string, const To extends string>(readDir: From, targetDir: To, options?: ReadDirOptions): boolean;
|
|
111
114
|
assetToBuffer<const T extends string>(path: T): Promise<{
|
|
112
|
-
readonly b64encodedData: `data:
|
|
113
|
-
readonly extension: "
|
|
115
|
+
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: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:video/mpeg;base64, ${string}` | `data:application/vnd.apple.installer+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:video/webm;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:application/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}`;
|
|
116
|
+
readonly extension: "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "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" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "weba" | "avi";
|
|
114
117
|
}>;
|
|
115
118
|
assetToBufferView<const T extends string>(path: T): Promise<{
|
|
116
119
|
readonly b64encodedData: string;
|
|
117
|
-
readonly extension: "
|
|
120
|
+
readonly extension: "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "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" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "weba" | "avi" | undefined;
|
|
118
121
|
}>;
|
|
119
122
|
formatHelper<const T extends string>(f: T): string;
|
|
120
123
|
cleanDataUrl<const C extends string>(props: C): string;
|
|
@@ -131,7 +134,49 @@ declare class Fs extends MimeService {
|
|
|
131
134
|
* ✅ 'public/assets/image-1.png'
|
|
132
135
|
*/
|
|
133
136
|
fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
|
|
134
|
-
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* @param inputUrl remote url to fetch data from
|
|
140
|
+
* @param outputPath desired output path relative to the cwd
|
|
141
|
+
* @param useDetectedExtension optional, defaults to true
|
|
142
|
+
*
|
|
143
|
+
* if `useDetectedExtension` is false you must include the file extension in your output path →
|
|
144
|
+
*
|
|
145
|
+
* 🚫 'public/assets/image-1'
|
|
146
|
+
*
|
|
147
|
+
* ✅ 'public/assets/image-1.png'
|
|
148
|
+
*
|
|
149
|
+
* @description
|
|
150
|
+
* This method is designed for large files that may not fit into memory.
|
|
151
|
+
* It streams the data directly to disk instead of loading it all into memory.
|
|
152
|
+
*/
|
|
153
|
+
fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPathI: O, useDetectedExtension?: boolean): Promise<void>;
|
|
154
|
+
private findBox;
|
|
155
|
+
getImageSize(filePath: string): Promise<{
|
|
156
|
+
width: number;
|
|
157
|
+
height: number;
|
|
158
|
+
type: "png";
|
|
159
|
+
} | {
|
|
160
|
+
width: number;
|
|
161
|
+
height: number;
|
|
162
|
+
type: "jpeg";
|
|
163
|
+
} | {
|
|
164
|
+
width: number;
|
|
165
|
+
height: number;
|
|
166
|
+
type: "gif";
|
|
167
|
+
} | {
|
|
168
|
+
width: number;
|
|
169
|
+
height: number;
|
|
170
|
+
type: "bmp";
|
|
171
|
+
} | {
|
|
172
|
+
width: number;
|
|
173
|
+
height: number;
|
|
174
|
+
type: "webp";
|
|
175
|
+
} | {
|
|
176
|
+
width: number;
|
|
177
|
+
height: number;
|
|
178
|
+
type: "avif";
|
|
179
|
+
}>;
|
|
135
180
|
/**
|
|
136
181
|
*
|
|
137
182
|
* @access package-private
|
|
@@ -154,6 +199,99 @@ declare class Fs extends MimeService {
|
|
|
154
199
|
options?: sharp.ResizeOptions;
|
|
155
200
|
};
|
|
156
201
|
}): Promise<Buffer<ArrayBufferLike>>;
|
|
202
|
+
/**
|
|
203
|
+
* Write data to a file in the system's tmp directory
|
|
204
|
+
* @param filename The filename (can include subdirectories like "img-probe/file.txt")
|
|
205
|
+
* @param data The data to write
|
|
206
|
+
* @param options Optional write stream options
|
|
207
|
+
* @returns The full path to the written file
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const fs = new Fs(process.cwd());
|
|
211
|
+
* const tmpPath = fs.writeTmp("session-data.json", JSON.stringify(data));
|
|
212
|
+
* // Or with a subdirectory:
|
|
213
|
+
* fs.writeTmp("img-probe/output.png", imageBuffer);
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
writeTmp<const F extends string>(filename: F, data: WriteStreamDataShape, options?: WriteStreamOptions): string;
|
|
217
|
+
/**
|
|
218
|
+
* Read a file from the tmp directory
|
|
219
|
+
* @param filename The filename to read (can include subdirectories)
|
|
220
|
+
* @returns Buffer containing the file data
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const fs = new Fs(process.cwd());
|
|
224
|
+
* const data = fs.readTmp("session-data.json");
|
|
225
|
+
* const parsed = JSON.parse(data.toString("utf-8"));
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
readTmp<const F extends string>(filename: F): Buffer<ArrayBuffer>;
|
|
229
|
+
/**
|
|
230
|
+
* Scan the tmp directory for files matching a pattern
|
|
231
|
+
* @param pattern Optional pattern to filter files (e.g., "img-probe")
|
|
232
|
+
* @param options Options for directory reading (defaults to non-recursive to avoid permission issues)
|
|
233
|
+
* @returns Array of matching file paths relative to tmp directory
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* const fs = new Fs(process.cwd());
|
|
237
|
+
* // Get all img-probe files
|
|
238
|
+
* const imgFiles = fs.scanTmp("img-probe");
|
|
239
|
+
* // Get all files in tmp (non-recursive)
|
|
240
|
+
* const allFiles = fs.scanTmp();
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
scanTmp(pattern?: string, options?: ReadDirOptions): string[];
|
|
244
|
+
/**
|
|
245
|
+
* Extract specific files from tmp directory to a target location
|
|
246
|
+
* @param pattern Pattern to match files (e.g., "img-probe")
|
|
247
|
+
* @param targetDir Target directory to extract files to
|
|
248
|
+
* @param options Options for extraction behavior
|
|
249
|
+
* @returns Array of extracted file paths
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const fs = new Fs(process.cwd());
|
|
253
|
+
* // Extract all img-probe files to ./output
|
|
254
|
+
* const extracted = fs.extractFromTmp("img-probe", "./output");
|
|
255
|
+
* // Extract with custom behavior
|
|
256
|
+
* fs.extractFromTmp("session-", "./sessions", {
|
|
257
|
+
* preserveStructure: true,
|
|
258
|
+
* cleanupAfter: true
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
extractFromTmp(pattern: string, targetDir: string, options?: {
|
|
263
|
+
preserveStructure?: boolean;
|
|
264
|
+
cleanupAfter?: boolean;
|
|
265
|
+
overwrite?: boolean;
|
|
266
|
+
}): string[];
|
|
267
|
+
/**
|
|
268
|
+
* Clean up tmp files matching a pattern
|
|
269
|
+
* @param pattern Pattern to match files for deletion
|
|
270
|
+
* @param maxAge Optional max age in milliseconds (only delete files older than this)
|
|
271
|
+
* @returns Number of files removed
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* const fs = new Fs(process.cwd());
|
|
275
|
+
* // Remove all img-probe files
|
|
276
|
+
* fs.cleanupTmp("img-probe");
|
|
277
|
+
* // Remove session files older than 1 hour
|
|
278
|
+
* fs.cleanupTmp("session-", 60 * 60 * 1000);
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
cleanupTmp(pattern: string, maxAge?: number): number;
|
|
282
|
+
/**
|
|
283
|
+
* Generate a unique tmp filename with optional prefix
|
|
284
|
+
* @param prefix Optional prefix for the filename
|
|
285
|
+
* @param extension Optional file extension (without dot)
|
|
286
|
+
* @returns Unique filename
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* const fs = new Fs(process.cwd());
|
|
290
|
+
* const filename = fs.uniqueTmpName("img-probe", "png");
|
|
291
|
+
* // Returns: "img-probe-1701234567890-a3b2c1.png"
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
uniqueTmpName(prefix?: string, extension?: string): string;
|
|
157
295
|
}
|
|
158
296
|
|
|
159
297
|
export { Fs as default };
|
package/dist/fs/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Fs
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-NGBMZGGU.js";
|
|
4
|
+
import "../chunk-C6AZRX7V.js";
|
|
5
|
+
import "../chunk-MXEE2WS7.js";
|
|
6
6
|
import "../chunk-XHN56MDK.js";
|
|
7
7
|
import "../chunk-7QVYU63E.js";
|
|
8
8
|
export {
|