@d0paminedriven/fs 10.1.0 → 11.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 +119 -0
  2. package/dist/docs/index.js +1027 -0
  3. package/dist/extract/client.d.ts +54 -0
  4. package/dist/extract/client.js +118 -0
  5. package/dist/extract/index.d.ts +69 -0
  6. package/dist/extract/index.js +622 -0
  7. package/dist/fs/index.d.ts +19 -55
  8. package/dist/fs/index.js +88 -19
  9. package/dist/fs-atomic/index.d.ts +28 -36
  10. package/dist/fs-atomic/index.js +88 -13
  11. package/dist/fs-base/index.d.ts +105 -111
  12. package/dist/fs-base/index.js +188 -12
  13. package/dist/fs-core/index.d.ts +20 -24
  14. package/dist/fs-core/index.js +44 -16
  15. package/dist/fs-fetch/index.d.ts +48 -62
  16. package/dist/fs-fetch/index.js +146 -18
  17. package/dist/fs-size/index.d.ts +16 -28
  18. package/dist/fs-size/index.js +64 -15
  19. package/dist/fs-tmp/index.d.ts +179 -192
  20. package/dist/fs-tmp/index.js +321 -17
  21. package/dist/images/index.d.ts +447 -0
  22. package/dist/images/index.js +899 -0
  23. package/dist/images/workup.d.ts +30 -0
  24. package/dist/images/workup.js +317 -0
  25. package/dist/index.d.ts +20 -22
  26. package/dist/index.js +20 -64
  27. package/dist/ld/index.d.ts +15 -13
  28. package/dist/ld/index.js +56 -6
  29. package/dist/mime/index.d.ts +299 -294
  30. package/dist/mime/index.js +348 -13
  31. package/dist/mixins/index.d.ts +34 -0
  32. package/dist/mixins/index.js +54 -0
  33. package/dist/types/index.d.ts +279 -215
  34. package/dist/types/index.js +11 -6
  35. package/dist/types/stream.d.ts +6 -4
  36. package/dist/types/stream.js +1 -1
  37. package/dist/url/index.d.ts +15 -18
  38. package/dist/url/index.js +21 -8
  39. package/dist/utils/index.d.ts +19 -23
  40. package/dist/utils/index.js +82 -7
  41. package/package.json +33 -13
  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,15 +1,350 @@
1
- import {
2
- MimeService,
3
- extMimeMap,
4
- mimeToExt
5
- } from "../chunk-L2QMQOEJ.js";
6
- import "../chunk-NJHN5OE3.js";
7
- import "../chunk-OT5JEQKW.js";
8
- import "../chunk-PB5A7ZFD.js";
9
- import "../chunk-7QVYU63E.js";
10
- export {
11
- MimeService,
12
- extMimeMap,
13
- mimeToExt
1
+ import { UrlService } from "../url/index.js";
2
+
3
+ //#region src/mime/index.ts
4
+ const extMimeMap = {
5
+ aac: ["audio/aac"],
6
+ abw: ["application/x-abiword"],
7
+ aces: ["image/aces"],
8
+ apng: ["image/apng"],
9
+ arc: ["application/x-freearc"],
10
+ avci: ["image/avci"],
11
+ avif: ["image/avif"],
12
+ avi: ["video/x-msvideo"],
13
+ azw: ["application/vnd.amazon.ebook"],
14
+ bin: ["application/octet-stream", "multipart/voice-message"],
15
+ bmp: ["image/bmp"],
16
+ bz: ["application/x-bzip"],
17
+ bz2: ["application/x-bzip2"],
18
+ c: ["text/x-c"],
19
+ cda: ["application/x-cdf"],
20
+ cjs: ["text/javascript", "application/node"],
21
+ cpp: ["text/x-c++"],
22
+ cs: ["text/x-csharp"],
23
+ csh: ["application/x-csh"],
24
+ css: ["text/css"],
25
+ csv: ["text/csv"],
26
+ cur: ["image/x-icon"],
27
+ doc: ["application/msword"],
28
+ docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
29
+ dpx: ["image/dpx"],
30
+ emf: ["image/emf"],
31
+ eot: ["application/vnd.ms-fontobject"],
32
+ epub: ["application/epub+zip"],
33
+ gif: ["image/gif"],
34
+ glb: ["model/gltf-binary"],
35
+ gltf: ["model/gltf+json"],
36
+ gz: ["application/gzip", "application/x-gzip"],
37
+ heic: ["image/heic"],
38
+ hjif: ["haptics/hjif"],
39
+ hmpg: ["haptics/hmpg"],
40
+ htm: ["text/html"],
41
+ html: ["text/html"],
42
+ ico: ["image/vnd.microsoft.icon", "image/x-icon"],
43
+ ics: ["text/calendar"],
44
+ ivs: ["haptics/ivs"],
45
+ ivt: ["haptics/ivs"],
46
+ jar: ["application/java-archive"],
47
+ java: ["text/x-java"],
48
+ jfif: ["image/jpeg"],
49
+ jif: ["image/jpeg"],
50
+ jpe: ["image/jpeg"],
51
+ jpeg: ["image/jpeg"],
52
+ jpg: ["image/jpeg"],
53
+ js: ["text/javascript", "application/node"],
54
+ json: ["application/json"],
55
+ jsonl: ["application/jsonl", "text/x-jsonl"],
56
+ jsonld: ["application/ld+json"],
57
+ jsonlines: ["application/jsonl", "text/x-jsonl"],
58
+ jsonc: ["application/json", "application/jsonc"],
59
+ json5: ["application/json", "application/json5"],
60
+ ktx: ["image/ktx"],
61
+ ktx2: ["image/ktx2"],
62
+ m3u8: ["application/vnd.apple.mpegurl"],
63
+ m4a: ["audio/mp4"],
64
+ m4s: ["video/mp4"],
65
+ m4v: ["video/mp4"],
66
+ md: ["text/markdown"],
67
+ mdx: ["application/x-mdx"],
68
+ mid: ["audio/midi"],
69
+ midi: ["audio/x-midi"],
70
+ mjs: ["text/javascript"],
71
+ mp3: ["audio/mpeg"],
72
+ mp4: ["video/mp4"],
73
+ mpd: ["application/dash+xml"],
74
+ mpeg: ["video/mpeg"],
75
+ mpkg: ["application/vnd.apple.installer+xml"],
76
+ mtlx: ["application/xml"],
77
+ ndjson: ["application/x-ndjson"],
78
+ node: ["application/node", "text/javascript"],
79
+ obj: [
80
+ "model/obj",
81
+ "application/octet-stream",
82
+ "text/plain"
83
+ ],
84
+ odp: ["application/vnd.oasis.opendocument.presentation"],
85
+ ods: ["application/vnd.oasis.opendocument.spreadsheet"],
86
+ odt: ["application/vnd.oasis.opendocument.text"],
87
+ oga: ["audio/ogg"],
88
+ ogg: ["audio/ogg"],
89
+ ogv: ["video/ogg"],
90
+ ogx: ["application/ogg"],
91
+ opus: ["audio/ogg"],
92
+ otf: ["font/otf"],
93
+ pk1: ["application/octet-stream"],
94
+ png: ["image/png"],
95
+ pdf: ["application/pdf"],
96
+ php: ["text/x-php", "application/x-httpd-php"],
97
+ pjp: ["image/jpeg"],
98
+ pjpeg: ["image/jpeg"],
99
+ pkpass: ["application/vnd.apple.pkpass"],
100
+ ppt: ["application/vnd.ms-powerpoint"],
101
+ pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
102
+ py: ["text/x-python", "text/x-script.python"],
103
+ pyc: ["application/x-python-code"],
104
+ rar: ["application/vnd.rar"],
105
+ rb: ["text/x-ruby"],
106
+ rs: ["text/rust"],
107
+ rtf: ["application/rtf"],
108
+ sh: ["application/x-sh"],
109
+ sql: ["application/sql"],
110
+ sse: ["text/event-stream"],
111
+ svg: ["image/svg+xml"],
112
+ tar: ["application/x-tar"],
113
+ tex: ["text/x-tex"],
114
+ tif: ["image/tiff"],
115
+ tiff: ["image/tiff"],
116
+ toml: ["application/toml"],
117
+ ts: [
118
+ "text/typescript",
119
+ "application/typescript",
120
+ "video/mp2t",
121
+ "video/vnd.dlna.mpeg-tts"
122
+ ],
123
+ ttf: ["application/font-sfnt", "font/ttf"],
124
+ txt: ["text/plain"],
125
+ usdz: ["model/vnd.usdz+zip"],
126
+ vsd: ["application/vnd.visio"],
127
+ vtt: ["text/vtt"],
128
+ wasm: ["application/wasm"],
129
+ wav: ["audio/wav"],
130
+ weba: ["audio/webm"],
131
+ webm: ["video/webm"],
132
+ webmanifest: ["application/manifest+json"],
133
+ webp: ["image/webp"],
134
+ woff: ["font/woff"],
135
+ woff2: ["font/woff2"],
136
+ xhtml: ["application/xhtml+xml"],
137
+ xls: ["application/vnd.ms-excel"],
138
+ xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
139
+ xml: ["application/xml", "text/xml"],
140
+ xul: ["application/vnd.mozilla.xul+xml"],
141
+ yaml: ["application/yaml"],
142
+ yml: ["application/yaml"],
143
+ zip: ["application/zip", "application/x-zip-compressed"],
144
+ "3gp": ["video/3gpp"],
145
+ "3g2": ["video/3gpp2"],
146
+ "7z": ["application/x-7z-compressed"]
14
147
  };
148
+ const mimeToExt = {
149
+ "application/dash+xml": ["mpd"],
150
+ "application/epub+zip": ["epub"],
151
+ "application/font-sfnt": ["ttf"],
152
+ "application/gzip": ["gz"],
153
+ "application/java-archive": ["jar"],
154
+ "application/json": ["json", "jsonc"],
155
+ "application/jsonc": ["jsonc"],
156
+ "application/jsonl": ["jsonl", "jsonlines"],
157
+ "application/json5": ["json5"],
158
+ "application/ld+json": ["jsonld"],
159
+ "application/manifest+json": ["webmanifest"],
160
+ "application/msword": ["doc"],
161
+ "application/node": ["node", "js"],
162
+ "application/octet-stream": ["bin", "obj"],
163
+ "application/ogg": ["ogx"],
164
+ "application/pdf": ["pdf"],
165
+ "application/rtf": ["rtf"],
166
+ "application/sql": ["sql"],
167
+ "application/text": ["md"],
168
+ "application/toml": ["toml"],
169
+ "application/vnd.amazon.ebook": ["azw"],
170
+ "application/vnd.apple.installer+xml": ["mpkg"],
171
+ "application/vnd.apple.mpegurl": ["m3u8"],
172
+ "application/vnd.apple.pkpass": ["pkpass"],
173
+ "application/vnd.json5": ["json5"],
174
+ "application/vnd.mozilla.xul+xml": ["xul"],
175
+ "application/vnd.ms-excel": ["xls"],
176
+ "application/vnd.ms-fontobject": ["eot"],
177
+ "application/vnd.ms-powerpoint": ["ppt"],
178
+ "application/vnd.oasis.opendocument.presentation": ["odp"],
179
+ "application/vnd.oasis.opendocument.spreadsheet": ["ods"],
180
+ "application/vnd.oasis.opendocument.text": ["odt"],
181
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": ["pptx"],
182
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"],
183
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": ["docx"],
184
+ "application/vnd.rar": ["rar"],
185
+ "application/vnd.visio": ["vsd"],
186
+ "application/wasm": ["wasm"],
187
+ "application/x-7z-compressed": ["7z"],
188
+ "application/x-abiword": ["abw"],
189
+ "application/x-bzip": ["bz"],
190
+ "application/x-bzip2": ["bz2"],
191
+ "application/x-cdf": ["cda"],
192
+ "application/x-csh": ["csh"],
193
+ "application/x-freearc": ["arc"],
194
+ "application/x-gzip": ["gz"],
195
+ "application/x-httpd-php": ["php"],
196
+ "application/x-mdx": ["mdx"],
197
+ "application/x-ndjson": ["ndjson"],
198
+ "application/x-python-code": ["pyc"],
199
+ "application/x-sh": ["sh"],
200
+ "application/x-tar": ["tar"],
201
+ "application/x-zip-compressed": ["zip"],
202
+ "application/xhtml+xml": ["xhtml"],
203
+ "application/xml": ["xml"],
204
+ "application/yaml": ["yml", "yaml"],
205
+ "application/zip": ["zip"],
206
+ "audio/aac": ["aac"],
207
+ "audio/midi": ["mid"],
208
+ "audio/mp4": ["m4a"],
209
+ "audio/mpeg": ["mp3"],
210
+ "audio/ogg": [
211
+ "opus",
212
+ "ogg",
213
+ "oga"
214
+ ],
215
+ "audio/wav": ["wav"],
216
+ "audio/webm": ["weba"],
217
+ "audio/x-midi": ["midi"],
218
+ "font/otf": ["otf"],
219
+ "font/ttf": ["ttf"],
220
+ "font/woff": ["woff"],
221
+ "font/woff2": ["woff2"],
222
+ "haptics/hjif": ["hjif"],
223
+ "haptics/hmpg": ["hmpg"],
224
+ "haptics/ivs": ["ivs", "ivt"],
225
+ "image/aces": ["aces"],
226
+ "image/apng": ["apng"],
227
+ "image/avci": ["avci"],
228
+ "image/avif": ["avif"],
229
+ "image/bmp": ["bmp"],
230
+ "image/dpx": ["dpx"],
231
+ "image/emf": ["emf"],
232
+ "image/gif": ["gif"],
233
+ "image/heic": ["heic"],
234
+ "image/jpeg": ["jpg", "jpeg"],
235
+ "image/ktx": ["ktx"],
236
+ "image/ktx2": ["ktx2"],
237
+ "image/png": ["png"],
238
+ "image/svg+xml": ["svg"],
239
+ "image/tiff": ["tiff"],
240
+ "image/vnd.microsoft.icon": ["ico"],
241
+ "image/webp": ["webp"],
242
+ "image/x-icon": ["ico", "cur"],
243
+ "model/gltf-binary": ["glb"],
244
+ "model/gltf+json": ["gltf"],
245
+ "model/obj": ["obj"],
246
+ "model/vnd.usdz+zip": ["usdz"],
247
+ "multipart/voice-message": ["bin"],
248
+ "text/calendar": ["ics"],
249
+ "text/css": ["css"],
250
+ "text/csv": ["csv"],
251
+ "text/event-stream": [
252
+ "sse",
253
+ "ts",
254
+ "rs",
255
+ "py",
256
+ "txt"
257
+ ],
258
+ "text/html": ["html", "htm"],
259
+ "text/javascript": [
260
+ "cjs",
261
+ "js",
262
+ "mjs"
263
+ ],
264
+ "text/markdown": ["md"],
265
+ "text/plain": ["txt"],
266
+ "text/rust": ["rs"],
267
+ "text/typescript": ["ts"],
268
+ "text/vtt": ["vtt"],
269
+ "text/x-c": ["c"],
270
+ "text/x-c++": ["cpp"],
271
+ "text/x-csharp": ["cs"],
272
+ "text/x-java": ["java"],
273
+ "text/x-jsonl": ["jsonl", "jsonlines"],
274
+ "text/x-php": ["php"],
275
+ "text/x-python": ["py"],
276
+ "text/x-ruby": ["rb"],
277
+ "text/x-script.python": ["py"],
278
+ "text/x-tex": ["tex"],
279
+ "text/xml": ["xml"],
280
+ "video/3gpp": ["3gp"],
281
+ "video/3gpp2": ["3g2"],
282
+ "video/mp2t": ["ts"],
283
+ "video/mp4": [
284
+ "mp4",
285
+ "m4v",
286
+ "m4s"
287
+ ],
288
+ "video/mpeg": ["mpeg"],
289
+ "video/ogg": ["ogv"],
290
+ "video/vnd.dlna.mpeg-tts": ["ts"],
291
+ "video/webm": ["weba"],
292
+ "video/x-msvideo": ["avi"]
293
+ };
294
+ var MimeService = class extends UrlService {
295
+ constructor() {
296
+ super();
297
+ }
298
+ mimeTypeObj = extMimeMap;
299
+ toExtObj = mimeToExt;
300
+ compareMimeToExt(p = "mime") {
301
+ let a = {};
302
+ if (p === "mime") {
303
+ for (const [_key, vals] of Object.entries(extMimeMap)) for (const val of vals) a[val] = (a[val] ?? 0) + 1;
304
+ for (const [key, _val] of Object.entries(mimeToExt)) a[key] = (a[key] ?? 0) + 1;
305
+ return Object.fromEntries(Object.entries(a).sort(([_a, aa], [_b, bb]) => bb - aa));
306
+ } else {
307
+ for (const [_key, vals] of Object.entries(mimeToExt)) for (const val of vals) a[val] = (a[val] ?? 0) + 1;
308
+ for (const [key, _val] of Object.entries(extMimeMap)) a[key] = (a[key] ?? 0) + 1;
309
+ return Object.fromEntries(Object.entries(a).sort(([_a, aa], [_b, bb]) => bb - aa));
310
+ }
311
+ }
312
+ mimeToExt(mime) {
313
+ const extensions = this.toExtObj[mime];
314
+ if (extensions.length === 1) return extensions[0];
315
+ if (extensions.length === 2) return extensions[0];
316
+ if (extensions.length === 3) {
317
+ if (mime === "audio/ogg") return "ogg";
318
+ return extensions[0];
319
+ }
320
+ if (extensions.length === 5) return extensions[0];
321
+ return extensions[0];
322
+ }
323
+ assetType(url) {
324
+ const parsed = this.parseUrl(url);
325
+ if (!parsed) return void 0;
326
+ const ext = parsed.pathname.split(/([.])/g)?.reverse()?.[0]?.toLowerCase();
327
+ return ext && ext in this.mimeTypeObj ? ext : void 0;
328
+ }
329
+ getMimes(ext) {
330
+ return this.mimeTypeObj[ext];
331
+ }
332
+ getMimeFor(ext, opts) {
333
+ const mimes = this.getMimes(ext);
334
+ if (mimes.length === 1) return mimes[0];
335
+ if (opts?.type) return mimes.find((mime) => mime.startsWith(opts.type + "/")) ?? mimes[0];
336
+ return mimes[0];
337
+ }
338
+ isMimeFor(ext, mime) {
339
+ return this.getMimes(ext).find((s) => s === mime);
340
+ }
341
+ getMimeTypeForPath(path, opts) {
342
+ const ext = this.assetType(path);
343
+ if (!ext) return "application/octet-stream";
344
+ return this.getMimeFor(ext, opts);
345
+ }
346
+ };
347
+
348
+ //#endregion
349
+ export { MimeService, extMimeMap, mimeToExt };
15
350
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,34 @@
1
+ import { DocMetadataExtractor } from "../docs/index.js";
2
+ import { ImgMetadataExtractor } from "../images/index.js";
3
+ import { Constructor, ExpandedDocSpecs, ExpandedImgSpecs } from "../types/index.js";
4
+
5
+ //#region src/mixins/index.d.ts
6
+ declare function create<Type>(c: new () => Type): Type;
7
+ declare function createInstance<A extends object>(c: new () => A): A;
8
+ /**
9
+ * ImgMixin
10
+ * - instance tries opts.img -> sharedImg -> new ImgMetadataExtractor()
11
+ * - exposes prototype method getImageSpecsWorkup
12
+ */
13
+ declare function ImgMixin<TBase extends Constructor>(Base: TBase): {
14
+ new (...args: any[]): {
15
+ img: ImgMetadataExtractor;
16
+ getImageSpecsWorkup(buffer: Buffer<ArrayBufferLike>, size?: number): ExpandedImgSpecs;
17
+ };
18
+ sharedImg?: ImgMetadataExtractor | undefined;
19
+ setSharedImg(ex: ImgMetadataExtractor): void;
20
+ } & TBase;
21
+ /**
22
+ * DocMixin (same pattern)
23
+ */
24
+ declare function DocMixin<TBase extends Constructor>(Base: TBase): {
25
+ new (...args: any[]): {
26
+ docs: DocMetadataExtractor;
27
+ getDocumentSpecsWorkup(buffer: Buffer<ArrayBufferLike>, contentType?: string): ExpandedDocSpecs;
28
+ };
29
+ sharedDocs?: DocMetadataExtractor | undefined;
30
+ setSharedDocs(ex: DocMetadataExtractor): void;
31
+ } & TBase;
32
+ //#endregion
33
+ export { DocMixin, ImgMixin, create, createInstance };
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { DocMetadataExtractor } from "../docs/index.js";
2
+ import { ImgMetadataExtractor } from "../images/index.js";
3
+
4
+ //#region src/mixins/index.ts
5
+ function create(c) {
6
+ return new c();
7
+ }
8
+ function createInstance(c) {
9
+ return new c();
10
+ }
11
+ /**
12
+ * ImgMixin
13
+ * - instance tries opts.img -> sharedImg -> new ImgMetadataExtractor()
14
+ * - exposes prototype method getImageSpecsWorkup
15
+ */
16
+ function ImgMixin(Base) {
17
+ return class ImgMixed extends Base {
18
+ img;
19
+ static sharedImg;
20
+ constructor(...args) {
21
+ super(...args);
22
+ this.img = args[0]?.img ?? this.constructor.sharedImg ?? new ImgMetadataExtractor();
23
+ }
24
+ getImageSpecsWorkup(buffer, size = 16384) {
25
+ return this.img.getImageSpecsWorkup(buffer, size);
26
+ }
27
+ static setSharedImg(ex) {
28
+ this.sharedImg = ex;
29
+ }
30
+ };
31
+ }
32
+ /**
33
+ * DocMixin (same pattern)
34
+ */
35
+ function DocMixin(Base) {
36
+ return class DocMixed extends Base {
37
+ docs;
38
+ static sharedDocs;
39
+ constructor(...args) {
40
+ super(...args);
41
+ this.docs = args[0]?.docs ?? this.constructor.sharedDocs ?? new DocMetadataExtractor();
42
+ }
43
+ getDocumentSpecsWorkup(buffer, contentType = "application/pdf") {
44
+ return this.docs.getDocumentSpecsWorkup(buffer, contentType);
45
+ }
46
+ static setSharedDocs(ex) {
47
+ this.sharedDocs = ex;
48
+ }
49
+ };
50
+ }
51
+
52
+ //#endregion
53
+ export { DocMixin, ImgMixin, create, createInstance };
54
+ //# sourceMappingURL=index.js.map