@d0paminedriven/fs 10.1.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/docs/index.d.ts +151 -0
  2. package/dist/docs/index.js +1163 -0
  3. package/dist/extract/client.d.ts +56 -0
  4. package/dist/extract/client.js +116 -0
  5. package/dist/extract/index.d.ts +66 -0
  6. package/dist/extract/index.js +620 -0
  7. package/dist/fs/index.d.ts +18 -58
  8. package/dist/fs/index.js +89 -19
  9. package/dist/fs-atomic/index.d.ts +25 -39
  10. package/dist/fs-atomic/index.js +94 -13
  11. package/dist/fs-base/index.d.ts +105 -113
  12. package/dist/fs-base/index.js +197 -12
  13. package/dist/fs-core/index.d.ts +18 -26
  14. package/dist/fs-core/index.js +43 -16
  15. package/dist/fs-fetch/index.d.ts +48 -65
  16. package/dist/fs-fetch/index.js +183 -18
  17. package/dist/fs-size/index.d.ts +15 -31
  18. package/dist/fs-size/index.js +63 -15
  19. package/dist/fs-tmp/index.d.ts +178 -195
  20. package/dist/fs-tmp/index.js +320 -17
  21. package/dist/images/index.d.ts +443 -0
  22. package/dist/images/index.js +893 -0
  23. package/dist/images/workup.d.ts +26 -0
  24. package/dist/images/workup.js +316 -0
  25. package/dist/index.d.ts +48 -22
  26. package/dist/index.js +19 -64
  27. package/dist/ld/index.d.ts +14 -16
  28. package/dist/ld/index.js +54 -6
  29. package/dist/mime/index.d.ts +301 -296
  30. package/dist/mime/index.js +348 -13
  31. package/dist/mixins/index.d.ts +30 -0
  32. package/dist/mixins/index.js +54 -0
  33. package/dist/types/index.d.ts +339 -260
  34. package/dist/types/index.js +10 -6
  35. package/dist/types/stream.d.ts +7 -9
  36. package/dist/types/stream.js +1 -1
  37. package/dist/url/index.d.ts +18 -25
  38. package/dist/url/index.js +19 -8
  39. package/dist/utils/index.d.ts +18 -26
  40. package/dist/utils/index.js +80 -7
  41. package/package.json +42 -22
  42. package/dist/chunk-4D2YBCI6.js +0 -163
  43. package/dist/chunk-5CACVZVF.js +0 -386
  44. package/dist/chunk-5H6GE5AO.js +0 -14
  45. package/dist/chunk-7QVYU63E.js +0 -7
  46. package/dist/chunk-DNR5ZI2T.js +0 -75
  47. package/dist/chunk-JZ6JNZZ6.js +0 -77
  48. package/dist/chunk-L2QMQOEJ.js +0 -366
  49. package/dist/chunk-NJHN5OE3.js +0 -33
  50. package/dist/chunk-OHKRQJZH.js +0 -82
  51. package/dist/chunk-OT5JEQKW.js +0 -139
  52. package/dist/chunk-PATMSIQK.js +0 -367
  53. package/dist/chunk-PB5A7ZFD.js +0 -79
  54. package/dist/chunk-VDKUXJE7.js +0 -240
  55. package/dist/chunk-Y5QWE4EG.js +0 -1335
  56. package/dist/chunk-YRCJWFZD.js +0 -107
  57. package/dist/image/index.d.ts +0 -182
  58. package/dist/image/index.js +0 -13
  59. package/dist/image/workup.d.ts +0 -40
  60. package/dist/image/workup.js +0 -12
@@ -1,14 +1,199 @@
1
- import {
2
- FsBase
3
- } from "../chunk-VDKUXJE7.js";
4
- import "../chunk-Y5QWE4EG.js";
5
- import "../chunk-5CACVZVF.js";
6
- import "../chunk-L2QMQOEJ.js";
7
- import "../chunk-NJHN5OE3.js";
8
- import "../chunk-OT5JEQKW.js";
9
- import "../chunk-PB5A7ZFD.js";
10
- import "../chunk-7QVYU63E.js";
11
- export {
12
- FsBase
1
+ import fsSync from "node:fs";
2
+ import { EOL, devNull, homedir, hostname, machine, tmpdir } from "node:os";
3
+ import { join, relative, resolve } from "node:path";
4
+ import { Readable } from "node:stream";
5
+ import { ReadableStream } from "node:stream/web";
6
+ import * as dotenv from "dotenv";
7
+ import expand from "dotenv-expand";
8
+ import { MimeService } from "../mime/index.js";
9
+ // src/fs-base/index.ts
10
+ var FsBase = class extends MimeService {
11
+ cwd;
12
+ constructor(cwd) {
13
+ super();
14
+ this.cwd = cwd;
15
+ }
16
+ get tmpDir() {
17
+ return tmpdir();
18
+ }
19
+ get homedir() {
20
+ if (process.env.HOME) return process.env.HOME;
21
+ else return homedir();
22
+ }
23
+ get platform() {
24
+ return process.platform;
25
+ }
26
+ get hostname() {
27
+ return hostname();
28
+ }
29
+ get machine() {
30
+ if (process.env.HOSTTYPE) return process.env.HOSTTYPE;
31
+ else return machine();
32
+ }
33
+ get devNull() {
34
+ return devNull;
35
+ }
36
+ get eol() {
37
+ return EOL;
38
+ }
39
+ get env() {
40
+ return dotenv.config({
41
+ processEnv: {},
42
+ quiet: true
43
+ });
44
+ }
45
+ relPath(path) {
46
+ return relative(this.cwd, path);
47
+ }
48
+ absPath(path) {
49
+ return resolve(this.relPath(path));
50
+ }
51
+ parseDotEnv() {
52
+ const env = expand.expand(this.env);
53
+ if (typeof env !== "undefined") {
54
+ if (env.error) throw new Error(env.error.message);
55
+ else return env.parsed;
56
+ } else throw new Error("env returned undefined");
57
+ }
58
+ isHomeTargeted(path) {
59
+ if (/^(~\/\.?)$/g.test(path)) return true;
60
+ else if (path.includes(this.homedir)) return true;
61
+ else return false;
62
+ }
63
+ isRootPathTargeted(path) {
64
+ if (/^(?:\.\/|\.|\/|root|\.\.\/|cwd|\.\/\.)$/g.test(path)) return true;
65
+ else return false;
66
+ }
67
+ pathHandler(path) {
68
+ return /\//g.test(path) === true ? path.split(/([/])/gim).reverse().slice(2).reverse().join("") : path;
69
+ }
70
+ isUint8Array(v) {
71
+ return v instanceof Uint8Array;
72
+ }
73
+ isBuffer(v) {
74
+ return Buffer.isBuffer(v);
75
+ }
76
+ isWebReadableStream(v) {
77
+ return v instanceof ReadableStream;
78
+ }
79
+ isAsyncIterable(v) {
80
+ return typeof v === "object" && v !== null && Symbol.asyncIterator in v;
81
+ }
82
+ formatHelper(f) {
83
+ if (/([A-Za-z]+-[A-Za-z]+)/g.test(f) === true) return f.split(/-/g).map((v) => v.substring(0, 1).toUpperCase().concat(v.substring(1))).join(" ");
84
+ else return f.substring(0, 1).toUpperCase().concat(f.substring(1));
85
+ }
86
+ cleanDataUrl(props) {
87
+ return props.replace(/^data:(?:image|application|haptics|video|text|font|model|audio|multipart)\/[A-Za-z0-9+-.]+(?:;[^,]+)*;base64,/i, "");
88
+ }
89
+ toReadable(data) {
90
+ if (typeof data === "string") return Readable.from([Buffer.from(data)]);
91
+ if (this.isBuffer(data) || this.isUint8Array(data)) return Readable.from([data]);
92
+ if (this.isWebReadableStream(data)) return Readable.fromWeb(data);
93
+ if (this.isAsyncIterable(data)) return Readable.from(data);
94
+ if (data instanceof Readable) return data;
95
+ throw new TypeError("Unsupported data type for toReadable()");
96
+ }
97
+ /**
98
+ *
99
+ * @param target path to the file or directory to check for existence
100
+ * @returns true if the file or directory exists, false otherwise
101
+ * @example
102
+ * ```ts
103
+ * const fs = new Fs(process.cwd());
104
+ * const exists = fs.exists("my-file.txt");
105
+ * console.log(exists); // true if the file exists, false otherwise
106
+ * ```
107
+ * @description
108
+ * This method checks if a file or directory exists at the specified path input
109
+ *
110
+ * Additional Note:
111
+ *
112
+ * say you have a directory that begins with a dot, such as `.turbo`;
113
+ *
114
+ * in this scenario, both `./.turbo` and `.turbo` will return true if the directory exists
115
+ *
116
+ */
117
+ exists(target) {
118
+ if (!/\//gm.test(target)) {
119
+ if (/\./g.test(target)) return fsSync.existsSync(resolve(join(this.cwd, target)));
120
+ else {
121
+ const isDir = fsSync.statSync(resolve(join(this.cwd, target)), { throwIfNoEntry: false })?.isDirectory();
122
+ if (isDir) return isDir;
123
+ else return false;
124
+ }
125
+ } else if (/\./g.test(target)) return fsSync.existsSync(relative(this.cwd ?? process.cwd(), target));
126
+ else {
127
+ const isDir = fsSync.statSync(relative(this.cwd, target), { throwIfNoEntry: false })?.isDirectory();
128
+ if (isDir) return isDir;
129
+ else return false;
130
+ }
131
+ }
132
+ /**
133
+ *
134
+ * @param ms milliseconds to wait
135
+ * @returns a promise that resolves after the specified number of milliseconds
136
+ * @example
137
+ * ```ts
138
+ * const fs = new Fs(process.cwd());
139
+ * await fs.wait(1000); // waits for 1 second
140
+ * console.log("Done waiting!");
141
+ * ```
142
+ *
143
+ * Alternatively, you can use it like this:
144
+ * ```ts
145
+ * const fs = new Fs(process.cwd());
146
+ * fs.wait(1000).then(() => { // waits for 1 second
147
+ * console.log("Done waiting!");
148
+ * // do something after waiting
149
+ * });
150
+ * ```
151
+ *
152
+ * @description
153
+ * This method is useful for delaying execution in asynchronous code, such as when you need to wait for a file operation to complete or when you want to introduce a delay in a loop.
154
+ */
155
+ wait(ms) {
156
+ return new Promise((resolve) => setTimeout(resolve, ms));
157
+ }
158
+ /**
159
+ * Handles an array or readonly array of strings and/or Buffers, converting Buffers to strings
160
+ * @param arr An array or readonly array of strings and/or Buffers
161
+ * @returns An array of strings with Buffers converted to UTF-8 strings.
162
+ */
163
+ handleBuffStrArrUnion(arr) {
164
+ return arr.map((v) => Buffer.isBuffer(v) ? Buffer.from(v).toString("utf-8") : v);
165
+ }
166
+ /**
167
+ *
168
+ * @param path path to the directory relative to the cwd
169
+ * @param options options for reading the directory, defaults to recursive
170
+ *
171
+ * The following two examples are equivalent:
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * const fs = new Fs(process.cwd());
176
+ * const files = fs.readDir("./my-directory", { recursive: true });
177
+ * console.log(files);
178
+ * ```
179
+ * @example
180
+ * ```ts
181
+ * const fs = new Fs(process.cwd());
182
+ * const files = fs.readDir("my-directory", { recursive: true });
183
+ * console.log(files);
184
+ * ```
185
+ *
186
+ * @returns an array of strings representing the contents of the directory
187
+ */
188
+ readDir(path, options = {
189
+ recursive: true,
190
+ withFileTypes: false,
191
+ encoding: "utf-8"
192
+ }) {
193
+ if (this.isRootPathTargeted(path)) return this.handleBuffStrArrUnion(fsSync.readdirSync(resolve(join(this.cwd, "./")), { ...options }));
194
+ else return this.handleBuffStrArrUnion(fsSync.readdirSync(relative(this.cwd ??= process.cwd(), path), options));
195
+ }
13
196
  };
197
+ export { FsBase };
198
+
14
199
  //# sourceMappingURL=index.js.map
@@ -1,27 +1,19 @@
1
- import { FsSize } from '../fs-size/index.js';
2
- import { WriteableDataType, WriteStreamOptions, WriteFileAsyncDataType, WriteFileAsyncOptions } from '../types/index.js';
3
- import '../fs-atomic/index.js';
4
- import '../fs-base/index.js';
5
- import 'node:stream';
6
- import 'stream/web';
7
- import 'dotenv-expand';
8
- import '../types/stream.js';
9
- import '../image/index.js';
10
- import '@d0paminedriven/metadata';
11
- import '../image/workup.js';
12
- import 'stream';
13
- import '../mime/index.js';
14
- import '../url/index.js';
15
- import '../utils/index.js';
16
- import '../ld/index.js';
17
- import 'fs';
18
-
19
- declare class FsCore extends FsSize {
20
- cwd: string;
21
- constructor(cwd: string);
22
- withWs<const T extends string>(path: T, data: WriteableDataType, options?: WriteStreamOptions): string | boolean | undefined;
23
- withWsAsync<const T extends string>(path: T, data: WriteableDataType, options?: WriteStreamOptions): Promise<string | boolean | undefined>;
24
- writeFileAsync: <const T extends string>(path: T, data: WriteFileAsyncDataType, options?: WriteFileAsyncOptions) => Promise<string | void>;
1
+ import { Abortable } from "node:events";
2
+ import { FsSize } from "../fs-size/index.js";
3
+ import { WriteFileAsyncDataType, WriteFileAsyncOptions, WriteStreamOptions, WriteableDataType } from "../types/index.js";
4
+ export interface CreateReadStreamOptions extends Abortable {
5
+ encoding?: BufferEncoding | null | undefined;
6
+ autoClose?: boolean | undefined;
7
+ emitClose?: boolean | undefined;
8
+ start?: number | undefined;
9
+ end?: number | undefined;
10
+ highWaterMark?: number | undefined;
25
11
  }
26
-
27
- export { FsCore };
12
+ export declare class FsCore extends FsSize {
13
+ cwd: string;
14
+ constructor(cwd: string);
15
+ withWs<const T extends string>(path: T, data: WriteableDataType, options?: WriteStreamOptions): string | boolean | undefined;
16
+ withWsAsync<const T extends string>(path: T, data: WriteableDataType, options?: WriteStreamOptions): Promise<string | boolean | undefined>;
17
+ writeFileAsync: <const T extends string>(path: T, data: WriteFileAsyncDataType, options?: WriteFileAsyncOptions) => Promise<string | void>;
18
+ }
19
+ //# sourceMappingURL=index.d.ts.map
@@ -1,18 +1,45 @@
1
- import {
2
- FsCore
3
- } from "../chunk-OHKRQJZH.js";
4
- import "../chunk-DNR5ZI2T.js";
5
- import "../chunk-5H6GE5AO.js";
6
- import "../chunk-YRCJWFZD.js";
7
- import "../chunk-VDKUXJE7.js";
8
- import "../chunk-Y5QWE4EG.js";
9
- import "../chunk-5CACVZVF.js";
10
- import "../chunk-L2QMQOEJ.js";
11
- import "../chunk-NJHN5OE3.js";
12
- import "../chunk-OT5JEQKW.js";
13
- import "../chunk-PB5A7ZFD.js";
14
- import "../chunk-7QVYU63E.js";
15
- export {
16
- FsCore
1
+ import fsAsync from "fs/promises";
2
+ import fsSync from "node:fs";
3
+ import { relative } from "path";
4
+ import { FsSize } from "../fs-size/index.js";
5
+ // src/fs-core/index.ts
6
+ var FsCore = class extends FsSize {
7
+ cwd;
8
+ constructor(cwd) {
9
+ super(cwd ??= process.cwd());
10
+ this.cwd = cwd;
11
+ }
12
+ withWs(path, data, options) {
13
+ try {
14
+ if (/\//g.test(path) === true) return this.generateDirIfDNE(this.pathHandler(path), { recursive: true });
15
+ else return path;
16
+ } catch (error) {
17
+ console.error(`[withWs error]: `.concat(typeof error === "string" ? error : JSON.stringify(error, null, 2)));
18
+ } finally {
19
+ return fsSync.createWriteStream(relative(this.cwd ?? process.cwd(), path), typeof options !== "undefined" ? typeof options === "object" ? options : options : { autoClose: true }).write(data);
20
+ }
21
+ }
22
+ async withWsAsync(path, data, options) {
23
+ try {
24
+ if (/\//g.test(path) === true) return this.generateDirIfDNE(this.pathHandler(path), { recursive: true });
25
+ else return path;
26
+ } catch (error) {
27
+ console.error(`[withWs error]: `.concat(typeof error === "string" ? error : JSON.stringify(error, null, 2)));
28
+ } finally {
29
+ return fsSync.createWriteStream(relative(this.cwd ?? process.cwd(), path), typeof options !== "undefined" ? typeof options === "object" ? options : options : { autoClose: true }).write(data);
30
+ }
31
+ }
32
+ writeFileAsync = async (path, data, options = {}) => {
33
+ try {
34
+ if (/\//g.test(path) === true) return this.generateDirIfDNE(this.pathHandler(path), { recursive: true });
35
+ else return path;
36
+ } catch (error) {
37
+ console.error(`[writeFileAsync error]: `.concat(error instanceof Error ? error.message : typeof error === "string" ? error : JSON.stringify(error, null, 2)));
38
+ } finally {
39
+ return fsAsync.writeFile(relative(this.cwd, path), data, options);
40
+ }
41
+ };
17
42
  };
43
+ export { FsCore };
44
+
18
45
  //# sourceMappingURL=index.js.map
@@ -1,66 +1,49 @@
1
- import { FsTmp } from '../fs-tmp/index.js';
2
- import '../types/index.js';
3
- import 'stream';
4
- import 'fs';
5
- import '../fs-core/index.js';
6
- import '../fs-size/index.js';
7
- import '../fs-atomic/index.js';
8
- import '../fs-base/index.js';
9
- import 'node:stream';
10
- import 'stream/web';
11
- import 'dotenv-expand';
12
- import '../types/stream.js';
13
- import '../image/index.js';
14
- import '@d0paminedriven/metadata';
15
- import '../image/workup.js';
16
- import '../mime/index.js';
17
- import '../url/index.js';
18
- import '../utils/index.js';
19
- import '../ld/index.js';
20
-
21
- declare class FsFetch extends FsTmp {
22
- cwd: string;
23
- constructor(cwd: string);
24
- assetToBuffer<const T extends string>(path: T): Promise<{
25
- 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:text/x-c;base64, ${string}` | `data:application/x-cdf;base64, ${string}` | `data:text/javascript;base64, ${string}` | `data:application/node;base64, ${string}` | `data:text/x-c++;base64, ${string}` | `data:text/x-csharp;base64, ${string}` | `data:application/x-csh;base64, ${string}` | `data:text/css;base64, ${string}` | `data:text/csv;base64, ${string}` | `data:image/x-icon;base64, ${string}` | `data:application/msword;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64, ${string}` | `data:image/dpx;base64, ${string}` | `data:image/emf;base64, ${string}` | `data:application/vnd.ms-fontobject;base64, ${string}` | `data:application/epub+zip;base64, ${string}` | `data:image/gif;base64, ${string}` | `data:model/gltf-binary;base64, ${string}` | `data:model/gltf+json;base64, ${string}` | `data:application/gzip;base64, ${string}` | `data:application/x-gzip;base64, ${string}` | `data:image/heic;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:text/x-java;base64, ${string}` | `data:image/jpeg;base64, ${string}` | `data:application/json;base64, ${string}` | `data:application/ld+json;base64, ${string}` | `data:application/jsonc;base64, ${string}` | `data:application/json5;base64, ${string}` | `data:image/ktx;base64, ${string}` | `data:image/ktx2;base64, ${string}` | `data:application/vnd.apple.mpegurl;base64, ${string}` | `data:audio/mp4;base64, ${string}` | `data:video/mp4;base64, ${string}` | `data:text/markdown;base64, ${string}` | `data:application/x-mdx;base64, ${string}` | `data:audio/midi;base64, ${string}` | `data:audio/x-midi;base64, ${string}` | `data:audio/mpeg;base64, ${string}` | `data:application/dash+xml;base64, ${string}` | `data:video/mpeg;base64, ${string}` | `data:application/vnd.apple.installer+xml;base64, ${string}` | `data:application/xml;base64, ${string}` | `data:application/x-ndjson;base64, ${string}` | `data:model/obj;base64, ${string}` | `data:text/plain;base64, ${string}` | `data:application/vnd.oasis.opendocument.presentation;base64, ${string}` | `data:application/vnd.oasis.opendocument.spreadsheet;base64, ${string}` | `data:application/vnd.oasis.opendocument.text;base64, ${string}` | `data:audio/ogg;base64, ${string}` | `data:video/ogg;base64, ${string}` | `data:application/ogg;base64, ${string}` | `data:font/otf;base64, ${string}` | `data:image/png;base64, ${string}` | `data:application/pdf;base64, ${string}` | `data:text/x-php;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:text/x-script.python;base64, ${string}` | `data:application/x-python-code;base64, ${string}` | `data:application/vnd.rar;base64, ${string}` | `data:text/x-ruby;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:text/x-tex;base64, ${string}` | `data:image/tiff;base64, ${string}` | `data:application/toml;base64, ${string}` | `data:text/typescript;base64, ${string}` | `data:application/typescript;base64, ${string}` | `data:video/mp2t;base64, ${string}` | `data:video/vnd.dlna.mpeg-tts;base64, ${string}` | `data:application/font-sfnt;base64, ${string}` | `data:font/ttf;base64, ${string}` | `data:model/vnd.usdz+zip;base64, ${string}` | `data:application/vnd.visio;base64, ${string}` | `data:text/vtt;base64, ${string}` | `data:application/wasm;base64, ${string}` | `data:audio/wav;base64, ${string}` | `data:audio/webm;base64, ${string}` | `data:video/webm;base64, ${string}` | `data:application/manifest+json;base64, ${string}` | `data:image/webp;base64, ${string}` | `data:font/woff;base64, ${string}` | `data:font/woff2;base64, ${string}` | `data:application/xhtml+xml;base64, ${string}` | `data:application/vnd.ms-excel;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64, ${string}` | `data:text/xml;base64, ${string}` | `data:application/vnd.mozilla.xul+xml;base64, ${string}` | `data:application/yaml;base64, ${string}` | `data:application/zip;base64, ${string}` | `data:application/x-zip-compressed;base64, ${string}` | `data:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
26
- readonly extension: "apng" | "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "svg" | "ico" | "heic" | "tiff" | "mpd" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonc" | "json5" | "jsonld" | "webmanifest" | "doc" | "node" | "js" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "md" | "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" | "weba" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "cur" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "vtt" | "c" | "cpp" | "cs" | "java" | "rb" | "tex" | "3gp" | "3g2" | "mp4" | "m4v" | "m4s" | "mpeg" | "ogv" | "avi" | "jfif" | "jif" | "jpe" | "mtlx" | "pk1" | "pjp" | "pjpeg" | "tif" | "webm";
27
- }>;
28
- assetToBufferView<const T extends string>(path: T): Promise<{
29
- readonly b64encodedData: string;
30
- readonly extension: "apng" | "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "svg" | "ico" | "heic" | "tiff" | "mpd" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonc" | "json5" | "jsonld" | "webmanifest" | "doc" | "node" | "js" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "md" | "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" | "weba" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "cur" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "vtt" | "c" | "cpp" | "cs" | "java" | "rb" | "tex" | "3gp" | "3g2" | "mp4" | "m4v" | "m4s" | "mpeg" | "ogv" | "avi" | "jfif" | "jif" | "jpe" | "mtlx" | "pk1" | "pjp" | "pjpeg" | "tif" | "webm" | undefined;
31
- }>;
32
- /**
33
- *
34
- * @param inputUrl remote url to fetch data from
35
- * @param outputPath desired output path relative to the cwd
36
- * @param useDetectedExtension optional, defaults to true
37
- *
38
- * if `useDetectedExtension` is false you must include the file extension in your output path &rarr;
39
- *
40
- * 🚫 'public/assets/image-1'
41
- *
42
- * ✅ 'public/assets/image-1.png'
43
- */
44
- fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
45
- private knownToBlockHead;
46
- /**
47
- *
48
- * @param inputUrl remote url to fetch data from
49
- * @param outputPath desired output path relative to the cwd
50
- * @param useDetectedExtension optional, defaults to true
51
- *
52
- * if `useDetectedExtension` is false you must include the file extension in your output path &rarr;
53
- *
54
- * 🚫 'public/assets/image-1'
55
- *
56
- * ✅ 'public/assets/image-1.png'
57
- *
58
- * @description
59
- * This method is designed for all files regardless of size, but especially for
60
- * larger files that may not fit into memory (it intelligently determines the best approach on the fly)
61
- * For files > 100 MB, it streams the data directly to disk instead of loading it all into memory
62
- */
63
- fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPathI: O, useDetectedExtension?: boolean): Promise<void>;
1
+ import { FsTmp } from "../fs-tmp/index.js";
2
+ export declare class FsFetch extends FsTmp {
3
+ cwd: string;
4
+ constructor(cwd: string);
5
+ assetToBuffer<const T extends string>(path: T): Promise<{
6
+ readonly b64encodedData: `data:application/octet-stream;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:multipart/voice-message;base64, ${string}` | `data:image/bmp;base64, ${string}` | `data:application/x-bzip;base64, ${string}` | `data:application/x-bzip2;base64, ${string}` | `data:text/x-c;base64, ${string}` | `data:application/x-cdf;base64, ${string}` | `data:text/javascript;base64, ${string}` | `data:application/node;base64, ${string}` | `data:text/x-c++;base64, ${string}` | `data:text/x-csharp;base64, ${string}` | `data:application/x-csh;base64, ${string}` | `data:text/css;base64, ${string}` | `data:text/csv;base64, ${string}` | `data:image/x-icon;base64, ${string}` | `data:application/msword;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64, ${string}` | `data:image/dpx;base64, ${string}` | `data:image/emf;base64, ${string}` | `data:application/vnd.ms-fontobject;base64, ${string}` | `data:application/epub+zip;base64, ${string}` | `data:image/gif;base64, ${string}` | `data:model/gltf-binary;base64, ${string}` | `data:model/gltf+json;base64, ${string}` | `data:text/x-go;base64, ${string}` | `data:application/gzip;base64, ${string}` | `data:application/x-gzip;base64, ${string}` | `data:image/heic;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:text/x-java;base64, ${string}` | `data:image/jpeg;base64, ${string}` | `data:application/json;base64, ${string}` | `data:application/jsonl;base64, ${string}` | `data:text/x-jsonl;base64, ${string}` | `data:application/ld+json;base64, ${string}` | `data:application/jsonc;base64, ${string}` | `data:application/json5;base64, ${string}` | `data:image/ktx;base64, ${string}` | `data:image/ktx2;base64, ${string}` | `data:application/vnd.apple.mpegurl;base64, ${string}` | `data:audio/mp4;base64, ${string}` | `data:video/mp4;base64, ${string}` | `data:text/markdown;base64, ${string}` | `data:application/x-mdx;base64, ${string}` | `data:audio/midi;base64, ${string}` | `data:audio/x-midi;base64, ${string}` | `data:audio/mpeg;base64, ${string}` | `data:application/dash+xml;base64, ${string}` | `data:video/mpeg;base64, ${string}` | `data:application/vnd.apple.installer+xml;base64, ${string}` | `data:application/xml;base64, ${string}` | `data:application/x-ndjson;base64, ${string}` | `data:model/obj;base64, ${string}` | `data:text/plain;base64, ${string}` | `data:application/vnd.oasis.opendocument.presentation;base64, ${string}` | `data:application/vnd.oasis.opendocument.spreadsheet;base64, ${string}` | `data:application/vnd.oasis.opendocument.text;base64, ${string}` | `data:audio/ogg;base64, ${string}` | `data:video/ogg;base64, ${string}` | `data:application/ogg;base64, ${string}` | `data:font/otf;base64, ${string}` | `data:image/png;base64, ${string}` | `data:application/pdf;base64, ${string}` | `data:text/x-php;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:text/x-script.python;base64, ${string}` | `data:application/x-python-code;base64, ${string}` | `data:application/vnd.rar;base64, ${string}` | `data:text/x-ruby;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:text/x-tex;base64, ${string}` | `data:image/tiff;base64, ${string}` | `data:application/toml;base64, ${string}` | `data:text/typescript;base64, ${string}` | `data:application/typescript;base64, ${string}` | `data:video/mp2t;base64, ${string}` | `data:video/vnd.dlna.mpeg-tts;base64, ${string}` | `data:application/font-sfnt;base64, ${string}` | `data:font/ttf;base64, ${string}` | `data:model/vnd.usdz+zip;base64, ${string}` | `data:application/vnd.visio;base64, ${string}` | `data:text/vtt;base64, ${string}` | `data:application/wasm;base64, ${string}` | `data:audio/wav;base64, ${string}` | `data:audio/webm;base64, ${string}` | `data:video/webm;base64, ${string}` | `data:application/manifest+json;base64, ${string}` | `data:image/webp;base64, ${string}` | `data:font/woff;base64, ${string}` | `data:font/woff2;base64, ${string}` | `data:application/xhtml+xml;base64, ${string}` | `data:application/vnd.ms-excel;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64, ${string}` | `data:text/xml;base64, ${string}` | `data:application/vnd.mozilla.xul+xml;base64, ${string}` | `data:application/yaml;base64, ${string}` | `data:application/zip;base64, ${string}` | `data:application/x-zip-compressed;base64, ${string}` | `data:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
7
+ readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "c" | "cda" | "cjs" | "cpp" | "cs" | "csh" | "css" | "csv" | "cur" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "go" | "gz" | "heic" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "ivt" | "jar" | "java" | "jfif" | "jif" | "jpe" | "jpeg" | "jpg" | "js" | "json" | "jsonl" | "jsonld" | "jsonlines" | "jsonc" | "json5" | "ktx" | "ktx2" | "m3u8" | "m4a" | "m4s" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpd" | "mpeg" | "mpkg" | "mtlx" | "ndjson" | "node" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "pk1" | "png" | "pdf" | "php" | "pjp" | "pjpeg" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rb" | "rs" | "rtf" | "sh" | "sql" | "sse" | "svg" | "tar" | "tex" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webm" | "webmanifest" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z";
8
+ }>;
9
+ assetToBufferView<const T extends string>(path: T): Promise<{
10
+ readonly b64encodedData: string;
11
+ readonly extension: "aac" | "abw" | "aces" | "apng" | "arc" | "avci" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "c" | "cda" | "cjs" | "cpp" | "cs" | "csh" | "css" | "csv" | "cur" | "doc" | "docx" | "dpx" | "emf" | "eot" | "epub" | "gif" | "glb" | "gltf" | "go" | "gz" | "heic" | "hjif" | "hmpg" | "htm" | "html" | "ico" | "ics" | "ivs" | "ivt" | "jar" | "java" | "jfif" | "jif" | "jpe" | "jpeg" | "jpg" | "js" | "json" | "jsonl" | "jsonld" | "jsonlines" | "jsonc" | "json5" | "ktx" | "ktx2" | "m3u8" | "m4a" | "m4s" | "m4v" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpd" | "mpeg" | "mpkg" | "mtlx" | "ndjson" | "node" | "obj" | "odp" | "ods" | "odt" | "oga" | "ogg" | "ogv" | "ogx" | "opus" | "otf" | "pk1" | "png" | "pdf" | "php" | "pjp" | "pjpeg" | "pkpass" | "ppt" | "pptx" | "py" | "pyc" | "rar" | "rb" | "rs" | "rtf" | "sh" | "sql" | "sse" | "svg" | "tar" | "tex" | "tif" | "tiff" | "toml" | "ts" | "ttf" | "txt" | "usdz" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webm" | "webmanifest" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "yaml" | "yml" | "zip" | "3gp" | "3g2" | "7z" | undefined;
12
+ }>;
13
+ /**
14
+ *
15
+ * @param inputUrl remote url to fetch data from
16
+ * @param outputPath desired output path relative to the cwd
17
+ * @param useDetectedExtension optional, defaults to true
18
+ *
19
+ * if `useDetectedExtension` is false you must include the file extension in your output path &rarr;
20
+ *
21
+ * 🚫 'public/assets/image-1'
22
+ *
23
+ * ✅ 'public/assets/image-1.png'
24
+ */
25
+ fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
26
+ private knownToBlockHead;
27
+ getUrlExt(url: string): string | null;
28
+ private fuzzyExtEquality;
29
+ private sniffFile;
30
+ /**
31
+ *
32
+ * @param inputUrl remote url to fetch data from
33
+ * @param outputPath desired output path relative to the cwd
34
+ * @param useDetectedExtension optional, defaults to true
35
+ *
36
+ * if `useDetectedExtension` is false you must include the file extension in your output path &rarr;
37
+ *
38
+ * 🚫 'public/assets/image-1'
39
+ *
40
+ * ✅ 'public/assets/image-1.png'
41
+ *
42
+ * @description
43
+ * This method is designed for all files regardless of size, but especially for
44
+ * larger files that may not fit into memory (it intelligently determines the best approach on the fly)
45
+ * It streams the data directly to disk for files of all sizes instead of loading it all into memory
46
+ */
47
+ fetchRemoteWriteLocalLargeFiles<const I extends string, const O extends string>(inputUrl: I, outputPathI: O, useDetectedExtension?: boolean, verbose?: boolean): Promise<void>;
64
48
  }
65
-
66
- export { FsFetch };
49
+ //# sourceMappingURL=index.d.ts.map