@d0paminedriven/fs 2.0.0 → 4.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.
@@ -146,7 +146,8 @@ var Fs = class {
146
146
  return { ...this.omitFields(targ, keys) };
147
147
  }
148
148
  exists(target) {
149
- if (!/\//gm.test(target)) return fsSync.existsSync(resolve(join(this.cwd, target)));
149
+ if (!/\//gm.test(target))
150
+ return fsSync.existsSync(resolve(join(this.cwd, target)));
150
151
  return fsSync.existsSync(relative(this.cwd ?? process.cwd(), target));
151
152
  }
152
153
  arrToArrOfArrs = /* @__PURE__ */ __name(({
@@ -191,18 +192,23 @@ var Fs = class {
191
192
  }
192
193
  readDir(path, options) {
193
194
  if (this.isRootPathTargeted(path)) {
194
- return this.handleBuffStrArrUnion(fsSync.readdirSync(resolve(join(this.cwd, "./")), options));
195
- } else return this.handleBuffStrArrUnion(
196
- fsSync.readdirSync(
197
- relative(this.cwd ??= process.cwd(), path),
198
- options
199
- )
200
- );
195
+ return this.handleBuffStrArrUnion(
196
+ fsSync.readdirSync(resolve(join(this.cwd, "./")), options)
197
+ );
198
+ } else
199
+ return this.handleBuffStrArrUnion(
200
+ fsSync.readdirSync(
201
+ relative(this.cwd ??= process.cwd(), path),
202
+ options
203
+ )
204
+ );
201
205
  }
202
206
  executeCommand = /* @__PURE__ */ __name(({
203
207
  command,
204
208
  ...options
205
- }) => Buffer.from(execSync(command, { ...options }).toJSON().data).toString("utf-8"), "executeCommand");
209
+ }) => Buffer.from(execSync(command, { ...options }).toJSON().data).toString(
210
+ "utf-8"
211
+ ), "executeCommand");
206
212
  fileGenTimestamp(d) {
207
213
  const date = d.toISOString();
208
214
  return `/* file-autogenerated by @d0paminedriven/fs on ${date.split(/([T])/gm)?.[0]} at ${date.split(/([T])/gm)[2]?.split(/([Z])/gm)?.[0]} UTC */`;
@@ -214,7 +220,8 @@ var Fs = class {
214
220
  return this.fileGenTimestamp(d).replace("/*", "<!--").replace("*/", "-->");
215
221
  }
216
222
  existsSync(path) {
217
- if (!/\//gm.test(path)) return fsSync.existsSync(resolve(join(this.cwd, path)));
223
+ if (!/\//gm.test(path))
224
+ return fsSync.existsSync(resolve(join(this.cwd, path)));
218
225
  return fsSync.existsSync(relative(this.cwd ?? process.cwd(), path));
219
226
  }
220
227
  pathHandler(path) {
@@ -276,6 +283,41 @@ var Fs = class {
276
283
  );
277
284
  }
278
285
  }, "writeFileAsync");
286
+ dirExists(dir) {
287
+ const resolved = relative(this.cwd, dir);
288
+ try {
289
+ return fsSync.statSync(resolved).isDirectory();
290
+ } catch {
291
+ return false;
292
+ }
293
+ }
294
+ async unlink(path) {
295
+ if (this.existsSync(path)) {
296
+ return await fsAsync.unlink(relative(this.cwd, path));
297
+ } else {
298
+ throw new Error(`input path ${path} does not exist`);
299
+ }
300
+ }
301
+ async rmdir(dir, options) {
302
+ const resolved = relative(this.cwd, dir);
303
+ if (this.dirExists(dir)) {
304
+ return fsAsync.rmdir(relative(this.cwd, dir), options);
305
+ } else {
306
+ throw new Error(`directory ${resolved} does not exist`);
307
+ }
308
+ }
309
+ rm(dir) {
310
+ const resolved = resolve(this.cwd, dir);
311
+ if (this.dirExists(dir)) {
312
+ return fsSync.rm(resolved, { force: true, recursive: true }, (err) => {
313
+ if (err?.message) {
314
+ console.error(err?.message);
315
+ }
316
+ });
317
+ } else {
318
+ throw new Error(`directory ${resolved} does not exist`);
319
+ }
320
+ }
279
321
  fileToBuffer = /* @__PURE__ */ __name((path) => Buffer.from(
280
322
  fsSync.readFileSync(relative(this.cwd ?? process.cwd(), path)).toJSON().data
281
323
  ), "fileToBuffer");
@@ -390,6 +432,8 @@ var Fs = class {
390
432
  js: this.jsVal,
391
433
  json: "application/json",
392
434
  jsonld: "application/ld+json",
435
+ ktx: "image/ktx",
436
+ ktx2: "image/ktx2",
393
437
  m3u8: "application/vnd.apple.mpegurl",
394
438
  m4a: "audio/mp4",
395
439
  m4v: "video/mp4",
@@ -482,7 +526,9 @@ var Fs = class {
482
526
  p.pathname.split(/\//g).reverse()[0] ?? ""
483
527
  );
484
528
  if (doesUrlPathContainFileExtension === false)
485
- console.warn(`no file extension detected in input url ${path}, attempting fetch`);
529
+ console.warn(
530
+ `no file extension detected in input url ${path}, attempting fetch`
531
+ );
486
532
  const response = await fetch(path);
487
533
  if (!response.ok) {
488
534
  throw new Error(`Failed to fetch asset: ${response.statusText}`);
@@ -623,6 +669,43 @@ var Fs = class {
623
669
  return console.error(err);
624
670
  }
625
671
  }
672
+ async fetchRemoteWriteLocalLargeFiles(inputUrl, outputPath, useDetectedExtension = true) {
673
+ const MAX_SAFE_IN_MEMORY_MB = 100;
674
+ try {
675
+ const head = await fetch(inputUrl, { method: "HEAD" });
676
+ const contentLength = head.headers.get("content-length");
677
+ const fileSizeMb = contentLength ? parseInt(contentLength, 10) / (1024 * 1024) : null;
678
+ const formattedPath = useDetectedExtension ? `${outputPath}.${this.assetType(inputUrl)}` : outputPath;
679
+ this.generateDirIfDNE(this.pathHandler(formattedPath), {
680
+ recursive: true
681
+ });
682
+ if (fileSizeMb !== null && fileSizeMb > MAX_SAFE_IN_MEMORY_MB) {
683
+ const res = await fetch(inputUrl);
684
+ if (!res.ok || !res.body) {
685
+ throw new Error(`Failed to fetch asset: ${res.statusText}`);
686
+ }
687
+ const writeStream = fsSync.createWriteStream(
688
+ relative(this.cwd ?? process.cwd(), formattedPath)
689
+ );
690
+ const reader = res.body.getReader();
691
+ const pump = /* @__PURE__ */ __name(async () => {
692
+ while (true) {
693
+ const { done, value } = await reader.read();
694
+ if (done) break;
695
+ writeStream.write(value);
696
+ }
697
+ writeStream.end();
698
+ }, "pump");
699
+ await pump();
700
+ return;
701
+ }
702
+ const result = await this.assetToBufferView(inputUrl);
703
+ const cleanData = this.cleanDataUrl(result.b64encodedData);
704
+ this.withWs(formattedPath, Buffer.from(cleanData, "base64"));
705
+ } catch (err) {
706
+ console.error(`[fetchRemoteWriteLocal error]:`, err);
707
+ }
708
+ }
626
709
  // USE fluent-ffmpeg for video/animated image transforms (apng, etc)
627
710
  // https://www.npmjs.com/package/fluent-ffmpeg
628
711
  // https://www.npmjs.com/package/@types/fluent-ffmpeg
@@ -688,4 +771,4 @@ var Fs = class {
688
771
  export {
689
772
  Fs
690
773
  };
691
- //# sourceMappingURL=chunk-J3NUWUIN.js.map
774
+ //# sourceMappingURL=chunk-ELR74GDM.js.map
package/dist/fs/index.cjs CHANGED
@@ -187,7 +187,8 @@ var Fs = class {
187
187
  return { ...this.omitFields(targ, keys) };
188
188
  }
189
189
  exists(target) {
190
- if (!/\//gm.test(target)) return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, target)));
190
+ if (!/\//gm.test(target))
191
+ return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, target)));
191
192
  return import_fs.default.existsSync((0, import_path.relative)(this.cwd ?? process.cwd(), target));
192
193
  }
193
194
  arrToArrOfArrs = /* @__PURE__ */ __name(({
@@ -232,18 +233,23 @@ var Fs = class {
232
233
  }
233
234
  readDir(path, options) {
234
235
  if (this.isRootPathTargeted(path)) {
235
- return this.handleBuffStrArrUnion(import_fs.default.readdirSync((0, import_path.resolve)((0, import_path.join)(this.cwd, "./")), options));
236
- } else return this.handleBuffStrArrUnion(
237
- import_fs.default.readdirSync(
238
- (0, import_path.relative)(this.cwd ??= process.cwd(), path),
239
- options
240
- )
241
- );
236
+ return this.handleBuffStrArrUnion(
237
+ import_fs.default.readdirSync((0, import_path.resolve)((0, import_path.join)(this.cwd, "./")), options)
238
+ );
239
+ } else
240
+ return this.handleBuffStrArrUnion(
241
+ import_fs.default.readdirSync(
242
+ (0, import_path.relative)(this.cwd ??= process.cwd(), path),
243
+ options
244
+ )
245
+ );
242
246
  }
243
247
  executeCommand = /* @__PURE__ */ __name(({
244
248
  command,
245
249
  ...options
246
- }) => Buffer.from((0, import_child_process.execSync)(command, { ...options }).toJSON().data).toString("utf-8"), "executeCommand");
250
+ }) => Buffer.from((0, import_child_process.execSync)(command, { ...options }).toJSON().data).toString(
251
+ "utf-8"
252
+ ), "executeCommand");
247
253
  fileGenTimestamp(d) {
248
254
  const date = d.toISOString();
249
255
  return `/* file-autogenerated by @d0paminedriven/fs on ${date.split(/([T])/gm)?.[0]} at ${date.split(/([T])/gm)[2]?.split(/([Z])/gm)?.[0]} UTC */`;
@@ -255,7 +261,8 @@ var Fs = class {
255
261
  return this.fileGenTimestamp(d).replace("/*", "<!--").replace("*/", "-->");
256
262
  }
257
263
  existsSync(path) {
258
- if (!/\//gm.test(path)) return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, path)));
264
+ if (!/\//gm.test(path))
265
+ return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, path)));
259
266
  return import_fs.default.existsSync((0, import_path.relative)(this.cwd ?? process.cwd(), path));
260
267
  }
261
268
  pathHandler(path) {
@@ -317,6 +324,41 @@ var Fs = class {
317
324
  );
318
325
  }
319
326
  }, "writeFileAsync");
327
+ dirExists(dir) {
328
+ const resolved = (0, import_path.relative)(this.cwd, dir);
329
+ try {
330
+ return import_fs.default.statSync(resolved).isDirectory();
331
+ } catch {
332
+ return false;
333
+ }
334
+ }
335
+ async unlink(path) {
336
+ if (this.existsSync(path)) {
337
+ return await import_promises.default.unlink((0, import_path.relative)(this.cwd, path));
338
+ } else {
339
+ throw new Error(`input path ${path} does not exist`);
340
+ }
341
+ }
342
+ async rmdir(dir, options) {
343
+ const resolved = (0, import_path.relative)(this.cwd, dir);
344
+ if (this.dirExists(dir)) {
345
+ return import_promises.default.rmdir((0, import_path.relative)(this.cwd, dir), options);
346
+ } else {
347
+ throw new Error(`directory ${resolved} does not exist`);
348
+ }
349
+ }
350
+ rm(dir) {
351
+ const resolved = (0, import_path.resolve)(this.cwd, dir);
352
+ if (this.dirExists(dir)) {
353
+ return import_fs.default.rm(resolved, { force: true, recursive: true }, (err) => {
354
+ if (err?.message) {
355
+ console.error(err?.message);
356
+ }
357
+ });
358
+ } else {
359
+ throw new Error(`directory ${resolved} does not exist`);
360
+ }
361
+ }
320
362
  fileToBuffer = /* @__PURE__ */ __name((path) => Buffer.from(
321
363
  import_fs.default.readFileSync((0, import_path.relative)(this.cwd ?? process.cwd(), path)).toJSON().data
322
364
  ), "fileToBuffer");
@@ -431,6 +473,8 @@ var Fs = class {
431
473
  js: this.jsVal,
432
474
  json: "application/json",
433
475
  jsonld: "application/ld+json",
476
+ ktx: "image/ktx",
477
+ ktx2: "image/ktx2",
434
478
  m3u8: "application/vnd.apple.mpegurl",
435
479
  m4a: "audio/mp4",
436
480
  m4v: "video/mp4",
@@ -523,7 +567,9 @@ var Fs = class {
523
567
  p.pathname.split(/\//g).reverse()[0] ?? ""
524
568
  );
525
569
  if (doesUrlPathContainFileExtension === false)
526
- console.warn(`no file extension detected in input url ${path}, attempting fetch`);
570
+ console.warn(
571
+ `no file extension detected in input url ${path}, attempting fetch`
572
+ );
527
573
  const response = await fetch(path);
528
574
  if (!response.ok) {
529
575
  throw new Error(`Failed to fetch asset: ${response.statusText}`);
@@ -664,6 +710,43 @@ var Fs = class {
664
710
  return console.error(err);
665
711
  }
666
712
  }
713
+ async fetchRemoteWriteLocalLargeFiles(inputUrl, outputPath, useDetectedExtension = true) {
714
+ const MAX_SAFE_IN_MEMORY_MB = 100;
715
+ try {
716
+ const head = await fetch(inputUrl, { method: "HEAD" });
717
+ const contentLength = head.headers.get("content-length");
718
+ const fileSizeMb = contentLength ? parseInt(contentLength, 10) / (1024 * 1024) : null;
719
+ const formattedPath = useDetectedExtension ? `${outputPath}.${this.assetType(inputUrl)}` : outputPath;
720
+ this.generateDirIfDNE(this.pathHandler(formattedPath), {
721
+ recursive: true
722
+ });
723
+ if (fileSizeMb !== null && fileSizeMb > MAX_SAFE_IN_MEMORY_MB) {
724
+ const res = await fetch(inputUrl);
725
+ if (!res.ok || !res.body) {
726
+ throw new Error(`Failed to fetch asset: ${res.statusText}`);
727
+ }
728
+ const writeStream = import_fs.default.createWriteStream(
729
+ (0, import_path.relative)(this.cwd ?? process.cwd(), formattedPath)
730
+ );
731
+ const reader = res.body.getReader();
732
+ const pump = /* @__PURE__ */ __name(async () => {
733
+ while (true) {
734
+ const { done, value } = await reader.read();
735
+ if (done) break;
736
+ writeStream.write(value);
737
+ }
738
+ writeStream.end();
739
+ }, "pump");
740
+ await pump();
741
+ return;
742
+ }
743
+ const result = await this.assetToBufferView(inputUrl);
744
+ const cleanData = this.cleanDataUrl(result.b64encodedData);
745
+ this.withWs(formattedPath, Buffer.from(cleanData, "base64"));
746
+ } catch (err) {
747
+ console.error(`[fetchRemoteWriteLocal error]:`, err);
748
+ }
749
+ }
667
750
  // USE fluent-ffmpeg for video/animated image transforms (apng, etc)
668
751
  // https://www.npmjs.com/package/fluent-ffmpeg
669
752
  // https://www.npmjs.com/package/@types/fluent-ffmpeg
@@ -1,6 +1,6 @@
1
1
  import expand from 'dotenv-expand';
2
2
  import sharp from 'sharp';
3
- import { RemoveFields, Unenumerate, ReadDirOptions, ExecuteCommandProps, MkDirSyncOptions, WriteStreamDataShape, WriteStreamOptions, WriteFileAsyncDataUnion, WriteFileAsyncOptions, ParsedUrlInfo } from '../types/index.cjs';
3
+ import { RemoveFields, Unenumerate, ReadDirOptions, ExecuteCommandProps, MkDirSyncOptions, WriteStreamDataShape, WriteStreamOptions, WriteFileAsyncDataUnion, WriteFileAsyncOptions, RmDirOptions, ParsedUrlInfo } from '../types/index.cjs';
4
4
  import 'stream';
5
5
  import 'buffer';
6
6
 
@@ -47,6 +47,10 @@ declare class Fs {
47
47
  generateDirIfDNE<const T extends string>(path: T, options?: MkDirSyncOptions): string | undefined;
48
48
  withWs<const T extends string>(path: T, data: WriteStreamDataShape, options?: WriteStreamOptions): string | boolean | undefined;
49
49
  writeFileAsync: <const T extends string>(path: T, data: WriteFileAsyncDataUnion, options?: WriteFileAsyncOptions) => Promise<string | void>;
50
+ dirExists<const T extends string>(dir: T): boolean;
51
+ unlink<const P extends string>(path: P): Promise<void>;
52
+ rmdir<const D extends string>(dir: D, options?: RmDirOptions): Promise<void>;
53
+ rm<const D extends string>(dir: D): void;
50
54
  fileToBuffer: <const T extends string>(path: T) => Buffer<ArrayBuffer>;
51
55
  dirContainsDir<const From extends string, const To extends string>(readDir: From, targetDir: To, options?: ReadDirOptions): boolean;
52
56
  isServerSide(): boolean;
@@ -104,6 +108,8 @@ declare class Fs {
104
108
  readonly js: "application/node" | "text/javascript";
105
109
  readonly json: "application/json";
106
110
  readonly jsonld: "application/ld+json";
111
+ readonly ktx: "image/ktx";
112
+ readonly ktx2: "image/ktx2";
107
113
  readonly m3u8: "application/vnd.apple.mpegurl";
108
114
  readonly m4a: "audio/mp4";
109
115
  readonly m4v: "video/mp4";
@@ -211,6 +217,8 @@ declare class Fs {
211
217
  readonly js: "application/node" | "text/javascript";
212
218
  readonly json: "application/json";
213
219
  readonly jsonld: "application/ld+json";
220
+ readonly ktx: "image/ktx";
221
+ readonly ktx2: "image/ktx2";
214
222
  readonly m3u8: "application/vnd.apple.mpegurl";
215
223
  readonly m4a: "audio/mp4";
216
224
  readonly m4v: "video/mp4";
@@ -317,6 +325,8 @@ declare class Fs {
317
325
  readonly js: "application/node" | "text/javascript";
318
326
  readonly json: "application/json";
319
327
  readonly jsonld: "application/ld+json";
328
+ readonly ktx: "image/ktx";
329
+ readonly ktx2: "image/ktx2";
320
330
  readonly m3u8: "application/vnd.apple.mpegurl";
321
331
  readonly m4a: "audio/mp4";
322
332
  readonly m4v: "video/mp4";
@@ -382,12 +392,12 @@ declare class Fs {
382
392
  readonly "7z": "application/x-7z-compressed";
383
393
  }[T];
384
394
  assetToBuffer<const T extends string>(path: T): Promise<{
385
- readonly b64encodedData: `data:application/node;base64, ${string}` | `data:text/javascript;base64, ${string}` | `data:application/x-gzip;base64, ${string}` | `data:application/gzip;base64, ${string}` | `data:application/octet-stream;base64, ${string}` | `data:text/plain;base64, ${string}` | `data:model/obj;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:application/zip;base64, ${string}` | `data:application/x-zip-compressed;base64, ${string}` | `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:image/bmp;base64, ${string}` | `data:application/x-bzip;base64, ${string}` | `data:application/x-bzip2;base64, ${string}` | `data:application/x-cdf;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: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: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: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:application/rtf;base64, ${string}` | `data:application/x-sh;base64, ${string}` | `data:application/sql;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: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:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
386
- readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
395
+ readonly b64encodedData: `data:application/node;base64, ${string}` | `data:text/javascript;base64, ${string}` | `data:application/x-gzip;base64, ${string}` | `data:application/gzip;base64, ${string}` | `data:application/octet-stream;base64, ${string}` | `data:text/plain;base64, ${string}` | `data:model/obj;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:application/zip;base64, ${string}` | `data:application/x-zip-compressed;base64, ${string}` | `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:image/bmp;base64, ${string}` | `data:application/x-bzip;base64, ${string}` | `data:application/x-bzip2;base64, ${string}` | `data:application/x-cdf;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: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: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:application/rtf;base64, ${string}` | `data:application/x-sh;base64, ${string}` | `data:application/sql;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: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:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
396
+ readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "ktx" | "ktx2" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
387
397
  }>;
388
398
  assetToBufferView<const T extends string>(path: T): Promise<{
389
399
  readonly b64encodedData: string;
390
- readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
400
+ readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "ktx" | "ktx2" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
391
401
  }>;
392
402
  formatHelper<const T extends string>(f: T): string;
393
403
  range(from: number, to: number): number[];
@@ -418,6 +428,7 @@ declare class Fs {
418
428
  * ✅ 'public/assets/image-1.png'
419
429
  */
420
430
  fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
431
+ fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
421
432
  imageTransform<const F extends "webp" | "avif" | "jpg" | "png" | "tif" | "tiff" | "jp2" | "jpeg">({ format, target, quality, tint, resize }: {
422
433
  format: F;
423
434
  target: Buffer<ArrayBuffer>;
@@ -1,6 +1,6 @@
1
1
  import expand from 'dotenv-expand';
2
2
  import sharp from 'sharp';
3
- import { RemoveFields, Unenumerate, ReadDirOptions, ExecuteCommandProps, MkDirSyncOptions, WriteStreamDataShape, WriteStreamOptions, WriteFileAsyncDataUnion, WriteFileAsyncOptions, ParsedUrlInfo } from '../types/index.js';
3
+ import { RemoveFields, Unenumerate, ReadDirOptions, ExecuteCommandProps, MkDirSyncOptions, WriteStreamDataShape, WriteStreamOptions, WriteFileAsyncDataUnion, WriteFileAsyncOptions, RmDirOptions, ParsedUrlInfo } from '../types/index.js';
4
4
  import 'stream';
5
5
  import 'buffer';
6
6
 
@@ -47,6 +47,10 @@ declare class Fs {
47
47
  generateDirIfDNE<const T extends string>(path: T, options?: MkDirSyncOptions): string | undefined;
48
48
  withWs<const T extends string>(path: T, data: WriteStreamDataShape, options?: WriteStreamOptions): string | boolean | undefined;
49
49
  writeFileAsync: <const T extends string>(path: T, data: WriteFileAsyncDataUnion, options?: WriteFileAsyncOptions) => Promise<string | void>;
50
+ dirExists<const T extends string>(dir: T): boolean;
51
+ unlink<const P extends string>(path: P): Promise<void>;
52
+ rmdir<const D extends string>(dir: D, options?: RmDirOptions): Promise<void>;
53
+ rm<const D extends string>(dir: D): void;
50
54
  fileToBuffer: <const T extends string>(path: T) => Buffer<ArrayBuffer>;
51
55
  dirContainsDir<const From extends string, const To extends string>(readDir: From, targetDir: To, options?: ReadDirOptions): boolean;
52
56
  isServerSide(): boolean;
@@ -104,6 +108,8 @@ declare class Fs {
104
108
  readonly js: "application/node" | "text/javascript";
105
109
  readonly json: "application/json";
106
110
  readonly jsonld: "application/ld+json";
111
+ readonly ktx: "image/ktx";
112
+ readonly ktx2: "image/ktx2";
107
113
  readonly m3u8: "application/vnd.apple.mpegurl";
108
114
  readonly m4a: "audio/mp4";
109
115
  readonly m4v: "video/mp4";
@@ -211,6 +217,8 @@ declare class Fs {
211
217
  readonly js: "application/node" | "text/javascript";
212
218
  readonly json: "application/json";
213
219
  readonly jsonld: "application/ld+json";
220
+ readonly ktx: "image/ktx";
221
+ readonly ktx2: "image/ktx2";
214
222
  readonly m3u8: "application/vnd.apple.mpegurl";
215
223
  readonly m4a: "audio/mp4";
216
224
  readonly m4v: "video/mp4";
@@ -317,6 +325,8 @@ declare class Fs {
317
325
  readonly js: "application/node" | "text/javascript";
318
326
  readonly json: "application/json";
319
327
  readonly jsonld: "application/ld+json";
328
+ readonly ktx: "image/ktx";
329
+ readonly ktx2: "image/ktx2";
320
330
  readonly m3u8: "application/vnd.apple.mpegurl";
321
331
  readonly m4a: "audio/mp4";
322
332
  readonly m4v: "video/mp4";
@@ -382,12 +392,12 @@ declare class Fs {
382
392
  readonly "7z": "application/x-7z-compressed";
383
393
  }[T];
384
394
  assetToBuffer<const T extends string>(path: T): Promise<{
385
- readonly b64encodedData: `data:application/node;base64, ${string}` | `data:text/javascript;base64, ${string}` | `data:application/x-gzip;base64, ${string}` | `data:application/gzip;base64, ${string}` | `data:application/octet-stream;base64, ${string}` | `data:text/plain;base64, ${string}` | `data:model/obj;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:application/zip;base64, ${string}` | `data:application/x-zip-compressed;base64, ${string}` | `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:image/bmp;base64, ${string}` | `data:application/x-bzip;base64, ${string}` | `data:application/x-bzip2;base64, ${string}` | `data:application/x-cdf;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: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: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: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:application/rtf;base64, ${string}` | `data:application/x-sh;base64, ${string}` | `data:application/sql;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: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:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
386
- readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
395
+ readonly b64encodedData: `data:application/node;base64, ${string}` | `data:text/javascript;base64, ${string}` | `data:application/x-gzip;base64, ${string}` | `data:application/gzip;base64, ${string}` | `data:application/octet-stream;base64, ${string}` | `data:text/plain;base64, ${string}` | `data:model/obj;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:application/zip;base64, ${string}` | `data:application/x-zip-compressed;base64, ${string}` | `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:image/bmp;base64, ${string}` | `data:application/x-bzip;base64, ${string}` | `data:application/x-bzip2;base64, ${string}` | `data:application/x-cdf;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: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: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:application/rtf;base64, ${string}` | `data:application/x-sh;base64, ${string}` | `data:application/sql;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: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:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
396
+ readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "ktx" | "ktx2" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
387
397
  }>;
388
398
  assetToBufferView<const T extends string>(path: T): Promise<{
389
399
  readonly b64encodedData: string;
390
- readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
400
+ readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "ktx" | "ktx2" | "m3u8" | "m4a" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rtf" | "sh" | "sql" | "svg" | "tar" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
391
401
  }>;
392
402
  formatHelper<const T extends string>(f: T): string;
393
403
  range(from: number, to: number): number[];
@@ -418,6 +428,7 @@ declare class Fs {
418
428
  * ✅ 'public/assets/image-1.png'
419
429
  */
420
430
  fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
431
+ fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
421
432
  imageTransform<const F extends "webp" | "avif" | "jpg" | "png" | "tif" | "tiff" | "jp2" | "jpeg">({ format, target, quality, tint, resize }: {
422
433
  format: F;
423
434
  target: Buffer<ArrayBuffer>;
package/dist/fs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Fs
3
- } from "../chunk-J3NUWUIN.js";
3
+ } from "../chunk-ELR74GDM.js";
4
4
  import "../chunk-I6PDZOED.js";
5
5
  export {
6
6
  Fs as default
package/dist/index.cjs CHANGED
@@ -190,7 +190,8 @@ var Fs = class {
190
190
  return { ...this.omitFields(targ, keys) };
191
191
  }
192
192
  exists(target) {
193
- if (!/\//gm.test(target)) return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, target)));
193
+ if (!/\//gm.test(target))
194
+ return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, target)));
194
195
  return import_fs.default.existsSync((0, import_path.relative)(this.cwd ?? process.cwd(), target));
195
196
  }
196
197
  arrToArrOfArrs = /* @__PURE__ */ __name(({
@@ -235,18 +236,23 @@ var Fs = class {
235
236
  }
236
237
  readDir(path, options) {
237
238
  if (this.isRootPathTargeted(path)) {
238
- return this.handleBuffStrArrUnion(import_fs.default.readdirSync((0, import_path.resolve)((0, import_path.join)(this.cwd, "./")), options));
239
- } else return this.handleBuffStrArrUnion(
240
- import_fs.default.readdirSync(
241
- (0, import_path.relative)(this.cwd ??= process.cwd(), path),
242
- options
243
- )
244
- );
239
+ return this.handleBuffStrArrUnion(
240
+ import_fs.default.readdirSync((0, import_path.resolve)((0, import_path.join)(this.cwd, "./")), options)
241
+ );
242
+ } else
243
+ return this.handleBuffStrArrUnion(
244
+ import_fs.default.readdirSync(
245
+ (0, import_path.relative)(this.cwd ??= process.cwd(), path),
246
+ options
247
+ )
248
+ );
245
249
  }
246
250
  executeCommand = /* @__PURE__ */ __name(({
247
251
  command,
248
252
  ...options
249
- }) => Buffer.from((0, import_child_process.execSync)(command, { ...options }).toJSON().data).toString("utf-8"), "executeCommand");
253
+ }) => Buffer.from((0, import_child_process.execSync)(command, { ...options }).toJSON().data).toString(
254
+ "utf-8"
255
+ ), "executeCommand");
250
256
  fileGenTimestamp(d) {
251
257
  const date = d.toISOString();
252
258
  return `/* file-autogenerated by @d0paminedriven/fs on ${date.split(/([T])/gm)?.[0]} at ${date.split(/([T])/gm)[2]?.split(/([Z])/gm)?.[0]} UTC */`;
@@ -258,7 +264,8 @@ var Fs = class {
258
264
  return this.fileGenTimestamp(d).replace("/*", "<!--").replace("*/", "-->");
259
265
  }
260
266
  existsSync(path) {
261
- if (!/\//gm.test(path)) return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, path)));
267
+ if (!/\//gm.test(path))
268
+ return import_fs.default.existsSync((0, import_path.resolve)((0, import_path.join)(this.cwd, path)));
262
269
  return import_fs.default.existsSync((0, import_path.relative)(this.cwd ?? process.cwd(), path));
263
270
  }
264
271
  pathHandler(path) {
@@ -320,6 +327,41 @@ var Fs = class {
320
327
  );
321
328
  }
322
329
  }, "writeFileAsync");
330
+ dirExists(dir) {
331
+ const resolved = (0, import_path.relative)(this.cwd, dir);
332
+ try {
333
+ return import_fs.default.statSync(resolved).isDirectory();
334
+ } catch {
335
+ return false;
336
+ }
337
+ }
338
+ async unlink(path) {
339
+ if (this.existsSync(path)) {
340
+ return await import_promises.default.unlink((0, import_path.relative)(this.cwd, path));
341
+ } else {
342
+ throw new Error(`input path ${path} does not exist`);
343
+ }
344
+ }
345
+ async rmdir(dir, options) {
346
+ const resolved = (0, import_path.relative)(this.cwd, dir);
347
+ if (this.dirExists(dir)) {
348
+ return import_promises.default.rmdir((0, import_path.relative)(this.cwd, dir), options);
349
+ } else {
350
+ throw new Error(`directory ${resolved} does not exist`);
351
+ }
352
+ }
353
+ rm(dir) {
354
+ const resolved = (0, import_path.resolve)(this.cwd, dir);
355
+ if (this.dirExists(dir)) {
356
+ return import_fs.default.rm(resolved, { force: true, recursive: true }, (err) => {
357
+ if (err?.message) {
358
+ console.error(err?.message);
359
+ }
360
+ });
361
+ } else {
362
+ throw new Error(`directory ${resolved} does not exist`);
363
+ }
364
+ }
323
365
  fileToBuffer = /* @__PURE__ */ __name((path) => Buffer.from(
324
366
  import_fs.default.readFileSync((0, import_path.relative)(this.cwd ?? process.cwd(), path)).toJSON().data
325
367
  ), "fileToBuffer");
@@ -434,6 +476,8 @@ var Fs = class {
434
476
  js: this.jsVal,
435
477
  json: "application/json",
436
478
  jsonld: "application/ld+json",
479
+ ktx: "image/ktx",
480
+ ktx2: "image/ktx2",
437
481
  m3u8: "application/vnd.apple.mpegurl",
438
482
  m4a: "audio/mp4",
439
483
  m4v: "video/mp4",
@@ -526,7 +570,9 @@ var Fs = class {
526
570
  p.pathname.split(/\//g).reverse()[0] ?? ""
527
571
  );
528
572
  if (doesUrlPathContainFileExtension === false)
529
- console.warn(`no file extension detected in input url ${path}, attempting fetch`);
573
+ console.warn(
574
+ `no file extension detected in input url ${path}, attempting fetch`
575
+ );
530
576
  const response = await fetch(path);
531
577
  if (!response.ok) {
532
578
  throw new Error(`Failed to fetch asset: ${response.statusText}`);
@@ -667,6 +713,43 @@ var Fs = class {
667
713
  return console.error(err);
668
714
  }
669
715
  }
716
+ async fetchRemoteWriteLocalLargeFiles(inputUrl, outputPath, useDetectedExtension = true) {
717
+ const MAX_SAFE_IN_MEMORY_MB = 100;
718
+ try {
719
+ const head = await fetch(inputUrl, { method: "HEAD" });
720
+ const contentLength = head.headers.get("content-length");
721
+ const fileSizeMb = contentLength ? parseInt(contentLength, 10) / (1024 * 1024) : null;
722
+ const formattedPath = useDetectedExtension ? `${outputPath}.${this.assetType(inputUrl)}` : outputPath;
723
+ this.generateDirIfDNE(this.pathHandler(formattedPath), {
724
+ recursive: true
725
+ });
726
+ if (fileSizeMb !== null && fileSizeMb > MAX_SAFE_IN_MEMORY_MB) {
727
+ const res = await fetch(inputUrl);
728
+ if (!res.ok || !res.body) {
729
+ throw new Error(`Failed to fetch asset: ${res.statusText}`);
730
+ }
731
+ const writeStream = import_fs.default.createWriteStream(
732
+ (0, import_path.relative)(this.cwd ?? process.cwd(), formattedPath)
733
+ );
734
+ const reader = res.body.getReader();
735
+ const pump = /* @__PURE__ */ __name(async () => {
736
+ while (true) {
737
+ const { done, value } = await reader.read();
738
+ if (done) break;
739
+ writeStream.write(value);
740
+ }
741
+ writeStream.end();
742
+ }, "pump");
743
+ await pump();
744
+ return;
745
+ }
746
+ const result = await this.assetToBufferView(inputUrl);
747
+ const cleanData = this.cleanDataUrl(result.b64encodedData);
748
+ this.withWs(formattedPath, Buffer.from(cleanData, "base64"));
749
+ } catch (err) {
750
+ console.error(`[fetchRemoteWriteLocal error]:`, err);
751
+ }
752
+ }
670
753
  // USE fluent-ffmpeg for video/animated image transforms (apng, etc)
671
754
  // https://www.npmjs.com/package/fluent-ffmpeg
672
755
  // https://www.npmjs.com/package/@types/fluent-ffmpeg
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as Fs } from './fs/index.cjs';
2
- export { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR } from './types/index.cjs';
2
+ export { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, RmDirOptions, RmDirProps, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR } from './types/index.cjs';
3
3
  import 'dotenv-expand';
4
4
  import 'sharp';
5
5
  import 'stream';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as Fs } from './fs/index.js';
2
- export { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR } from './types/index.js';
2
+ export { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, RmDirOptions, RmDirProps, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR } from './types/index.js';
3
3
  import 'dotenv-expand';
4
4
  import 'sharp';
5
5
  import 'stream';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Fs
3
- } from "./chunk-J3NUWUIN.js";
3
+ } from "./chunk-ELR74GDM.js";
4
4
  import {
5
5
  init_esm_shims
6
6
  } from "./chunk-I6PDZOED.js";
@@ -118,6 +118,36 @@ type WriteFileAsyncProps<T extends string = string> = {
118
118
  flag?: OpenMode | undefined;
119
119
  } & Abortable) | BufferEncodingUnion | null;
120
120
  };
121
+ type RmDirOptions = {
122
+ /**
123
+ * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
124
+ * `EPERM` error is encountered, Node.js will retry the operation with a linear
125
+ * backoff wait of `retryDelay` ms longer on each try. This option represents the
126
+ * number of retries. This option is ignored if the `recursive` option is not
127
+ * `true`.
128
+ * @default 0
129
+ */
130
+ maxRetries?: number | undefined;
131
+ /**
132
+ * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
133
+ * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
134
+ * Use `fs.rm(path, { recursive: true, force: true })` instead.
135
+ *
136
+ * If `true`, perform a recursive directory removal. In
137
+ * recursive mode, operations are retried on failure.
138
+ * @default false
139
+ */
140
+ recursive?: boolean | undefined;
141
+ /**
142
+ * The amount of time in milliseconds to wait between retries.
143
+ * This option is ignored if the `recursive` option is not `true`.
144
+ * @default 100
145
+ */
146
+ retryDelay?: number | undefined;
147
+ };
148
+ type RmDirProps = {
149
+ options?: RmDirOptions;
150
+ }['options'];
121
151
  type ReadDirProps<T extends string> = {
122
152
  path: T;
123
153
  options?: ReadDirOptions;
@@ -214,4 +244,4 @@ type ParsedUrlInfo = {
214
244
  hash: string;
215
245
  };
216
246
 
217
- export type { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR };
247
+ export type { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, RmDirOptions, RmDirProps, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR };
@@ -118,6 +118,36 @@ type WriteFileAsyncProps<T extends string = string> = {
118
118
  flag?: OpenMode | undefined;
119
119
  } & Abortable) | BufferEncodingUnion | null;
120
120
  };
121
+ type RmDirOptions = {
122
+ /**
123
+ * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
124
+ * `EPERM` error is encountered, Node.js will retry the operation with a linear
125
+ * backoff wait of `retryDelay` ms longer on each try. This option represents the
126
+ * number of retries. This option is ignored if the `recursive` option is not
127
+ * `true`.
128
+ * @default 0
129
+ */
130
+ maxRetries?: number | undefined;
131
+ /**
132
+ * @deprecated since v14.14.0 In future versions of Node.js and will trigger a warning
133
+ * `fs.rmdir(path, { recursive: true })` will throw if `path` does not exist or is a file.
134
+ * Use `fs.rm(path, { recursive: true, force: true })` instead.
135
+ *
136
+ * If `true`, perform a recursive directory removal. In
137
+ * recursive mode, operations are retried on failure.
138
+ * @default false
139
+ */
140
+ recursive?: boolean | undefined;
141
+ /**
142
+ * The amount of time in milliseconds to wait between retries.
143
+ * This option is ignored if the `recursive` option is not `true`.
144
+ * @default 100
145
+ */
146
+ retryDelay?: number | undefined;
147
+ };
148
+ type RmDirProps = {
149
+ options?: RmDirOptions;
150
+ }['options'];
121
151
  type ReadDirProps<T extends string> = {
122
152
  path: T;
123
153
  options?: ReadDirOptions;
@@ -214,4 +244,4 @@ type ParsedUrlInfo = {
214
244
  hash: string;
215
245
  };
216
246
 
217
- export type { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR };
247
+ export type { Abortable, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BufferEncodingUnion, CoercionUnion, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, InferDepth, InjectScriptsProps, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, ObjEncodingOptions, OmitSrc, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, ReadDirOptions, ReadDirProps, RemoveFields, RequiredToConditional, RmDirOptions, RmDirProps, Signals, StdioOptions, TypedArray, Unenumerate, UnwrapPromise, Without, WriteFileAsyncDataUnion, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamDataShape, WriteStreamOptions, WriteStreamProps, XOR };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d0paminedriven/fs",
3
- "version": "2.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "convenient fs helpers",
5
5
  "publishConfig": {
6
6
  "access": "public"