@d0paminedriven/fs 0.2.0 → 1.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.
- package/dist/{chunk-MZZJMVSV.js → chunk-MFKSUNKN.js} +94 -32
- package/dist/fs/index.cjs +93 -31
- package/dist/fs/index.d.cts +139 -8
- package/dist/fs/index.d.ts +139 -8
- package/dist/fs/index.js +1 -1
- package/dist/index.cjs +93 -31
- package/dist/index.js +1 -1
- package/package.json +7 -7
|
@@ -319,11 +319,22 @@ var Fs = class {
|
|
|
319
319
|
/* end url */
|
|
320
320
|
get gzVal() {
|
|
321
321
|
return ["application/x-gzip", "application/gzip"].reduce(
|
|
322
|
-
(
|
|
322
|
+
(union) => union
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
get objVal() {
|
|
326
|
+
return ["application/octet-stream", "text/plain", "model/obj"].reduce((union) => union);
|
|
327
|
+
}
|
|
328
|
+
get tsVal() {
|
|
329
|
+
return ["text/typescript", "video/mp2t", "video/vnd.dlna.mpeg-tts"].reduce((union) => union);
|
|
330
|
+
}
|
|
331
|
+
get ttfVal() {
|
|
332
|
+
return ["application/font-sfnt", "font/ttf"].reduce(
|
|
333
|
+
(union) => union
|
|
323
334
|
);
|
|
324
335
|
}
|
|
325
336
|
get zipVal() {
|
|
326
|
-
return ["application/zip", "application/x-zip-compressed"].reduce((
|
|
337
|
+
return ["application/zip", "application/x-zip-compressed"].reduce((union) => union);
|
|
327
338
|
}
|
|
328
339
|
get mimeTypeObj() {
|
|
329
340
|
return {
|
|
@@ -348,6 +359,8 @@ var Fs = class {
|
|
|
348
359
|
eot: "application/vnd.ms-fontobject",
|
|
349
360
|
epub: "application/epub+zip",
|
|
350
361
|
gif: "image/gif",
|
|
362
|
+
glb: "model/gltf-binary",
|
|
363
|
+
gltf: "model/gltf+json",
|
|
351
364
|
gz: this.gzVal,
|
|
352
365
|
htm: "text/html",
|
|
353
366
|
html: "text/html",
|
|
@@ -360,6 +373,8 @@ var Fs = class {
|
|
|
360
373
|
json: "application/json",
|
|
361
374
|
jsonld: "application/ld+json",
|
|
362
375
|
m3u8: "application/vnd.apple.mpegurl",
|
|
376
|
+
m4a: "audio/mp4",
|
|
377
|
+
m4v: "video/mp4",
|
|
363
378
|
md: "text/markdown",
|
|
364
379
|
mdx: "application/x-mdx",
|
|
365
380
|
mid: "audio/midi",
|
|
@@ -370,10 +385,12 @@ var Fs = class {
|
|
|
370
385
|
mpeg: "video/mpeg",
|
|
371
386
|
mpkg: "application/vnd.apple.installer+xml",
|
|
372
387
|
ndjson: "application/x-ndjson",
|
|
388
|
+
obj: this.objVal,
|
|
373
389
|
odp: "application/vnd.oasis.opendocument.presentation",
|
|
374
390
|
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
375
391
|
odt: "application/vnd.oasis.opendocument.text",
|
|
376
392
|
oga: "audio/ogg",
|
|
393
|
+
ogg: "audio/ogg",
|
|
377
394
|
ogv: "video/ogg",
|
|
378
395
|
ogx: "application/ogg",
|
|
379
396
|
opus: "audio/ogg",
|
|
@@ -384,6 +401,8 @@ var Fs = class {
|
|
|
384
401
|
pkpass: "application/vnd.apple.pkpass",
|
|
385
402
|
ppt: "application/vnd.ms-powerpoint",
|
|
386
403
|
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
404
|
+
py: "text/x-python",
|
|
405
|
+
pyc: "application/x-python-code",
|
|
387
406
|
rar: "application/vnd.rar",
|
|
388
407
|
rtf: "application/rtf",
|
|
389
408
|
sh: "application/x-sh",
|
|
@@ -391,10 +410,12 @@ var Fs = class {
|
|
|
391
410
|
tar: "application/x-tar",
|
|
392
411
|
tif: "image/tiff",
|
|
393
412
|
tiff: "image/tiff",
|
|
394
|
-
ts:
|
|
395
|
-
ttf:
|
|
413
|
+
ts: this.tsVal,
|
|
414
|
+
ttf: this.ttfVal,
|
|
396
415
|
txt: "text/plain",
|
|
397
416
|
vsd: "application/vnd.visio",
|
|
417
|
+
vtt: "text/vtt",
|
|
418
|
+
wasm: "application/wasm",
|
|
398
419
|
wav: "audio/wav",
|
|
399
420
|
weba: "video/webm",
|
|
400
421
|
webp: "image/webp",
|
|
@@ -412,18 +433,20 @@ var Fs = class {
|
|
|
412
433
|
};
|
|
413
434
|
}
|
|
414
435
|
assetType(url) {
|
|
415
|
-
|
|
436
|
+
const u = this.parseUrl(url);
|
|
437
|
+
return u.pathname?.split(/([.])/gim)?.reverse()?.[0];
|
|
416
438
|
}
|
|
417
439
|
getMime(input) {
|
|
418
440
|
return this.mimeTypeObj[input];
|
|
419
441
|
}
|
|
442
|
+
hmm = /* @__PURE__ */ __name((input) => {
|
|
443
|
+
return this.mimeTypeObj[input];
|
|
444
|
+
}, "hmm");
|
|
420
445
|
async assetToBuffer(path) {
|
|
421
446
|
const [fetcher] = await Promise.all([
|
|
422
447
|
fetch(path).then((t) => t.arrayBuffer())
|
|
423
448
|
]);
|
|
424
|
-
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(
|
|
425
|
-
Buffer.from(fetcher).toJSON().data
|
|
426
|
-
).toString("base64")}`;
|
|
449
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(fetcher).toString("base64")}`;
|
|
427
450
|
const extension = this.assetType(path);
|
|
428
451
|
return {
|
|
429
452
|
b64encodedData,
|
|
@@ -431,27 +454,34 @@ var Fs = class {
|
|
|
431
454
|
};
|
|
432
455
|
}
|
|
433
456
|
async assetToBufferView(path) {
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
457
|
+
const response = await fetch(path);
|
|
458
|
+
if (!response.ok) {
|
|
459
|
+
throw new Error(`Failed to fetch asset: ${response.statusText}`);
|
|
460
|
+
}
|
|
461
|
+
const reader = response.body?.getReader();
|
|
462
|
+
if (reader) {
|
|
463
|
+
const chunks = [];
|
|
464
|
+
while (true) {
|
|
465
|
+
const { done, value } = await reader.read();
|
|
466
|
+
if (done) break;
|
|
467
|
+
if (value) chunks.push(value);
|
|
442
468
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
b64encodedData,
|
|
453
|
-
|
|
454
|
-
|
|
469
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
470
|
+
const completeBuffer = new Uint8Array(totalLength);
|
|
471
|
+
let offset = 0;
|
|
472
|
+
for (const chunk of chunks) {
|
|
473
|
+
completeBuffer.set(chunk, offset);
|
|
474
|
+
offset += chunk.length;
|
|
475
|
+
}
|
|
476
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(completeBuffer).toString("base64")}`;
|
|
477
|
+
const extension = this.assetType(path);
|
|
478
|
+
return { b64encodedData, extension };
|
|
479
|
+
} else {
|
|
480
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
481
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(arrayBuffer).toString("base64")}`;
|
|
482
|
+
const extension = this.assetType(path);
|
|
483
|
+
return { b64encodedData, extension };
|
|
484
|
+
}
|
|
455
485
|
}
|
|
456
486
|
formatHelper(f) {
|
|
457
487
|
if (/([A-Za-z]+-[A-Za-z]+)/g.test(f) === true) {
|
|
@@ -460,7 +490,7 @@ var Fs = class {
|
|
|
460
490
|
} else return f.substring(0, 1).toUpperCase().concat(f.substring(1));
|
|
461
491
|
}
|
|
462
492
|
range(from, to) {
|
|
463
|
-
const values =
|
|
493
|
+
const values = Array.of();
|
|
464
494
|
for (let i = from; i < to; i++) {
|
|
465
495
|
values.push(i);
|
|
466
496
|
}
|
|
@@ -500,10 +530,9 @@ var Fs = class {
|
|
|
500
530
|
{
|
|
501
531
|
const sliceSize = 512;
|
|
502
532
|
const typeMatch = b64Data.match(
|
|
503
|
-
/^data:(image|application|video|text|font)\/[A-Za-z0-9+-.]+;base64,/
|
|
533
|
+
/^data:(image|application|video|text|model|font)\/[A-Za-z0-9+-.]+;base64,/
|
|
504
534
|
);
|
|
505
535
|
const type = typeMatch?.[1];
|
|
506
|
-
console.log(type ?? "");
|
|
507
536
|
if (!typeMatch) {
|
|
508
537
|
throw new Error(`${b64Data} is not a valid data Url`);
|
|
509
538
|
}
|
|
@@ -523,9 +552,42 @@ var Fs = class {
|
|
|
523
552
|
return blob;
|
|
524
553
|
}
|
|
525
554
|
}
|
|
555
|
+
cleanDataUrl(props) {
|
|
556
|
+
return props.replace(
|
|
557
|
+
/^data:(image|application|video|text|font|model|audio)\/[A-Za-z0-9+-.]+;base64,/,
|
|
558
|
+
""
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
*
|
|
563
|
+
* @param inputUrl remote url to fetch data from
|
|
564
|
+
* @param outputPath desired output path relative to the cwd
|
|
565
|
+
* @param useDetectedExtension optional, defaults to true
|
|
566
|
+
*
|
|
567
|
+
* if `useDetectedExtension` is false you must include the file extension in your output path →
|
|
568
|
+
*
|
|
569
|
+
* 🚫 'public/assets/image-1'
|
|
570
|
+
*
|
|
571
|
+
* ✅ 'public/assets/image-1.png'
|
|
572
|
+
*/
|
|
573
|
+
async fetchRemoteWriteLocal(inputUrl, outputPath, useDetectedExtension = true) {
|
|
574
|
+
try {
|
|
575
|
+
const result = await this.assetToBufferView(inputUrl);
|
|
576
|
+
const cleanData = this.cleanDataUrl(result.b64encodedData);
|
|
577
|
+
const formattedPath = useDetectedExtension ? `${outputPath}.${result.extension}` : outputPath;
|
|
578
|
+
if (/\./g.test(formattedPath) === false) {
|
|
579
|
+
throw new Error(
|
|
580
|
+
"either add false as the third argument in `fetchRemoteWriteLocal` [input, output, use-detected-file-extension (defaults to true)]"
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
this.withWs(formattedPath, Buffer.from(cleanData, "base64"));
|
|
584
|
+
} catch (err) {
|
|
585
|
+
return console.error(err);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
526
588
|
};
|
|
527
589
|
|
|
528
590
|
export {
|
|
529
591
|
Fs
|
|
530
592
|
};
|
|
531
|
-
//# sourceMappingURL=chunk-
|
|
593
|
+
//# sourceMappingURL=chunk-MFKSUNKN.js.map
|
package/dist/fs/index.cjs
CHANGED
|
@@ -360,11 +360,22 @@ var Fs = class {
|
|
|
360
360
|
/* end url */
|
|
361
361
|
get gzVal() {
|
|
362
362
|
return ["application/x-gzip", "application/gzip"].reduce(
|
|
363
|
-
(
|
|
363
|
+
(union) => union
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
get objVal() {
|
|
367
|
+
return ["application/octet-stream", "text/plain", "model/obj"].reduce((union) => union);
|
|
368
|
+
}
|
|
369
|
+
get tsVal() {
|
|
370
|
+
return ["text/typescript", "video/mp2t", "video/vnd.dlna.mpeg-tts"].reduce((union) => union);
|
|
371
|
+
}
|
|
372
|
+
get ttfVal() {
|
|
373
|
+
return ["application/font-sfnt", "font/ttf"].reduce(
|
|
374
|
+
(union) => union
|
|
364
375
|
);
|
|
365
376
|
}
|
|
366
377
|
get zipVal() {
|
|
367
|
-
return ["application/zip", "application/x-zip-compressed"].reduce((
|
|
378
|
+
return ["application/zip", "application/x-zip-compressed"].reduce((union) => union);
|
|
368
379
|
}
|
|
369
380
|
get mimeTypeObj() {
|
|
370
381
|
return {
|
|
@@ -389,6 +400,8 @@ var Fs = class {
|
|
|
389
400
|
eot: "application/vnd.ms-fontobject",
|
|
390
401
|
epub: "application/epub+zip",
|
|
391
402
|
gif: "image/gif",
|
|
403
|
+
glb: "model/gltf-binary",
|
|
404
|
+
gltf: "model/gltf+json",
|
|
392
405
|
gz: this.gzVal,
|
|
393
406
|
htm: "text/html",
|
|
394
407
|
html: "text/html",
|
|
@@ -401,6 +414,8 @@ var Fs = class {
|
|
|
401
414
|
json: "application/json",
|
|
402
415
|
jsonld: "application/ld+json",
|
|
403
416
|
m3u8: "application/vnd.apple.mpegurl",
|
|
417
|
+
m4a: "audio/mp4",
|
|
418
|
+
m4v: "video/mp4",
|
|
404
419
|
md: "text/markdown",
|
|
405
420
|
mdx: "application/x-mdx",
|
|
406
421
|
mid: "audio/midi",
|
|
@@ -411,10 +426,12 @@ var Fs = class {
|
|
|
411
426
|
mpeg: "video/mpeg",
|
|
412
427
|
mpkg: "application/vnd.apple.installer+xml",
|
|
413
428
|
ndjson: "application/x-ndjson",
|
|
429
|
+
obj: this.objVal,
|
|
414
430
|
odp: "application/vnd.oasis.opendocument.presentation",
|
|
415
431
|
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
416
432
|
odt: "application/vnd.oasis.opendocument.text",
|
|
417
433
|
oga: "audio/ogg",
|
|
434
|
+
ogg: "audio/ogg",
|
|
418
435
|
ogv: "video/ogg",
|
|
419
436
|
ogx: "application/ogg",
|
|
420
437
|
opus: "audio/ogg",
|
|
@@ -425,6 +442,8 @@ var Fs = class {
|
|
|
425
442
|
pkpass: "application/vnd.apple.pkpass",
|
|
426
443
|
ppt: "application/vnd.ms-powerpoint",
|
|
427
444
|
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
445
|
+
py: "text/x-python",
|
|
446
|
+
pyc: "application/x-python-code",
|
|
428
447
|
rar: "application/vnd.rar",
|
|
429
448
|
rtf: "application/rtf",
|
|
430
449
|
sh: "application/x-sh",
|
|
@@ -432,10 +451,12 @@ var Fs = class {
|
|
|
432
451
|
tar: "application/x-tar",
|
|
433
452
|
tif: "image/tiff",
|
|
434
453
|
tiff: "image/tiff",
|
|
435
|
-
ts:
|
|
436
|
-
ttf:
|
|
454
|
+
ts: this.tsVal,
|
|
455
|
+
ttf: this.ttfVal,
|
|
437
456
|
txt: "text/plain",
|
|
438
457
|
vsd: "application/vnd.visio",
|
|
458
|
+
vtt: "text/vtt",
|
|
459
|
+
wasm: "application/wasm",
|
|
439
460
|
wav: "audio/wav",
|
|
440
461
|
weba: "video/webm",
|
|
441
462
|
webp: "image/webp",
|
|
@@ -453,18 +474,20 @@ var Fs = class {
|
|
|
453
474
|
};
|
|
454
475
|
}
|
|
455
476
|
assetType(url) {
|
|
456
|
-
|
|
477
|
+
const u = this.parseUrl(url);
|
|
478
|
+
return u.pathname?.split(/([.])/gim)?.reverse()?.[0];
|
|
457
479
|
}
|
|
458
480
|
getMime(input) {
|
|
459
481
|
return this.mimeTypeObj[input];
|
|
460
482
|
}
|
|
483
|
+
hmm = /* @__PURE__ */ __name((input) => {
|
|
484
|
+
return this.mimeTypeObj[input];
|
|
485
|
+
}, "hmm");
|
|
461
486
|
async assetToBuffer(path) {
|
|
462
487
|
const [fetcher] = await Promise.all([
|
|
463
488
|
fetch(path).then((t) => t.arrayBuffer())
|
|
464
489
|
]);
|
|
465
|
-
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(
|
|
466
|
-
Buffer.from(fetcher).toJSON().data
|
|
467
|
-
).toString("base64")}`;
|
|
490
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(fetcher).toString("base64")}`;
|
|
468
491
|
const extension = this.assetType(path);
|
|
469
492
|
return {
|
|
470
493
|
b64encodedData,
|
|
@@ -472,27 +495,34 @@ var Fs = class {
|
|
|
472
495
|
};
|
|
473
496
|
}
|
|
474
497
|
async assetToBufferView(path) {
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
498
|
+
const response = await fetch(path);
|
|
499
|
+
if (!response.ok) {
|
|
500
|
+
throw new Error(`Failed to fetch asset: ${response.statusText}`);
|
|
501
|
+
}
|
|
502
|
+
const reader = response.body?.getReader();
|
|
503
|
+
if (reader) {
|
|
504
|
+
const chunks = [];
|
|
505
|
+
while (true) {
|
|
506
|
+
const { done, value } = await reader.read();
|
|
507
|
+
if (done) break;
|
|
508
|
+
if (value) chunks.push(value);
|
|
483
509
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
b64encodedData,
|
|
494
|
-
|
|
495
|
-
|
|
510
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
511
|
+
const completeBuffer = new Uint8Array(totalLength);
|
|
512
|
+
let offset = 0;
|
|
513
|
+
for (const chunk of chunks) {
|
|
514
|
+
completeBuffer.set(chunk, offset);
|
|
515
|
+
offset += chunk.length;
|
|
516
|
+
}
|
|
517
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(completeBuffer).toString("base64")}`;
|
|
518
|
+
const extension = this.assetType(path);
|
|
519
|
+
return { b64encodedData, extension };
|
|
520
|
+
} else {
|
|
521
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
522
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(arrayBuffer).toString("base64")}`;
|
|
523
|
+
const extension = this.assetType(path);
|
|
524
|
+
return { b64encodedData, extension };
|
|
525
|
+
}
|
|
496
526
|
}
|
|
497
527
|
formatHelper(f) {
|
|
498
528
|
if (/([A-Za-z]+-[A-Za-z]+)/g.test(f) === true) {
|
|
@@ -501,7 +531,7 @@ var Fs = class {
|
|
|
501
531
|
} else return f.substring(0, 1).toUpperCase().concat(f.substring(1));
|
|
502
532
|
}
|
|
503
533
|
range(from, to) {
|
|
504
|
-
const values =
|
|
534
|
+
const values = Array.of();
|
|
505
535
|
for (let i = from; i < to; i++) {
|
|
506
536
|
values.push(i);
|
|
507
537
|
}
|
|
@@ -541,10 +571,9 @@ var Fs = class {
|
|
|
541
571
|
{
|
|
542
572
|
const sliceSize = 512;
|
|
543
573
|
const typeMatch = b64Data.match(
|
|
544
|
-
/^data:(image|application|video|text|font)\/[A-Za-z0-9+-.]+;base64,/
|
|
574
|
+
/^data:(image|application|video|text|model|font)\/[A-Za-z0-9+-.]+;base64,/
|
|
545
575
|
);
|
|
546
576
|
const type = typeMatch?.[1];
|
|
547
|
-
console.log(type ?? "");
|
|
548
577
|
if (!typeMatch) {
|
|
549
578
|
throw new Error(`${b64Data} is not a valid data Url`);
|
|
550
579
|
}
|
|
@@ -564,5 +593,38 @@ var Fs = class {
|
|
|
564
593
|
return blob;
|
|
565
594
|
}
|
|
566
595
|
}
|
|
596
|
+
cleanDataUrl(props) {
|
|
597
|
+
return props.replace(
|
|
598
|
+
/^data:(image|application|video|text|font|model|audio)\/[A-Za-z0-9+-.]+;base64,/,
|
|
599
|
+
""
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
*
|
|
604
|
+
* @param inputUrl remote url to fetch data from
|
|
605
|
+
* @param outputPath desired output path relative to the cwd
|
|
606
|
+
* @param useDetectedExtension optional, defaults to true
|
|
607
|
+
*
|
|
608
|
+
* if `useDetectedExtension` is false you must include the file extension in your output path →
|
|
609
|
+
*
|
|
610
|
+
* 🚫 'public/assets/image-1'
|
|
611
|
+
*
|
|
612
|
+
* ✅ 'public/assets/image-1.png'
|
|
613
|
+
*/
|
|
614
|
+
async fetchRemoteWriteLocal(inputUrl, outputPath, useDetectedExtension = true) {
|
|
615
|
+
try {
|
|
616
|
+
const result = await this.assetToBufferView(inputUrl);
|
|
617
|
+
const cleanData = this.cleanDataUrl(result.b64encodedData);
|
|
618
|
+
const formattedPath = useDetectedExtension ? `${outputPath}.${result.extension}` : outputPath;
|
|
619
|
+
if (/\./g.test(formattedPath) === false) {
|
|
620
|
+
throw new Error(
|
|
621
|
+
"either add false as the third argument in `fetchRemoteWriteLocal` [input, output, use-detected-file-extension (defaults to true)]"
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
this.withWs(formattedPath, Buffer.from(cleanData, "base64"));
|
|
625
|
+
} catch (err) {
|
|
626
|
+
return console.error(err);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
567
629
|
};
|
|
568
630
|
//# sourceMappingURL=index.cjs.map
|
package/dist/fs/index.d.cts
CHANGED
|
@@ -55,6 +55,9 @@ declare class Fs {
|
|
|
55
55
|
get URL_REGEX(): RegExp;
|
|
56
56
|
parseUrl(url: string): ParsedUrlInfo;
|
|
57
57
|
get gzVal(): "application/x-gzip" | "application/gzip";
|
|
58
|
+
get objVal(): "application/octet-stream" | "text/plain" | "model/obj";
|
|
59
|
+
get tsVal(): "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
60
|
+
get ttfVal(): "application/font-sfnt" | "font/ttf";
|
|
58
61
|
get zipVal(): "application/zip" | "application/x-zip-compressed";
|
|
59
62
|
get mimeTypeObj(): {
|
|
60
63
|
readonly aac: "audio/aac";
|
|
@@ -78,6 +81,8 @@ declare class Fs {
|
|
|
78
81
|
readonly eot: "application/vnd.ms-fontobject";
|
|
79
82
|
readonly epub: "application/epub+zip";
|
|
80
83
|
readonly gif: "image/gif";
|
|
84
|
+
readonly glb: "model/gltf-binary";
|
|
85
|
+
readonly gltf: "model/gltf+json";
|
|
81
86
|
readonly gz: "application/x-gzip" | "application/gzip";
|
|
82
87
|
readonly htm: "text/html";
|
|
83
88
|
readonly html: "text/html";
|
|
@@ -90,6 +95,8 @@ declare class Fs {
|
|
|
90
95
|
readonly json: "application/json";
|
|
91
96
|
readonly jsonld: "application/ld+json";
|
|
92
97
|
readonly m3u8: "application/vnd.apple.mpegurl";
|
|
98
|
+
readonly m4a: "audio/mp4";
|
|
99
|
+
readonly m4v: "video/mp4";
|
|
93
100
|
readonly md: "text/markdown";
|
|
94
101
|
readonly mdx: "application/x-mdx";
|
|
95
102
|
readonly mid: "audio/midi";
|
|
@@ -100,10 +107,12 @@ declare class Fs {
|
|
|
100
107
|
readonly mpeg: "video/mpeg";
|
|
101
108
|
readonly mpkg: "application/vnd.apple.installer+xml";
|
|
102
109
|
readonly ndjson: "application/x-ndjson";
|
|
110
|
+
readonly obj: "application/octet-stream" | "text/plain" | "model/obj";
|
|
103
111
|
readonly odp: "application/vnd.oasis.opendocument.presentation";
|
|
104
112
|
readonly ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
105
113
|
readonly odt: "application/vnd.oasis.opendocument.text";
|
|
106
114
|
readonly oga: "audio/ogg";
|
|
115
|
+
readonly ogg: "audio/ogg";
|
|
107
116
|
readonly ogv: "video/ogg";
|
|
108
117
|
readonly ogx: "application/ogg";
|
|
109
118
|
readonly opus: "audio/ogg";
|
|
@@ -114,6 +123,8 @@ declare class Fs {
|
|
|
114
123
|
readonly pkpass: "application/vnd.apple.pkpass";
|
|
115
124
|
readonly ppt: "application/vnd.ms-powerpoint";
|
|
116
125
|
readonly pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
126
|
+
readonly py: "text/x-python";
|
|
127
|
+
readonly pyc: "application/x-python-code";
|
|
117
128
|
readonly rar: "application/vnd.rar";
|
|
118
129
|
readonly rtf: "application/rtf";
|
|
119
130
|
readonly sh: "application/x-sh";
|
|
@@ -121,10 +132,12 @@ declare class Fs {
|
|
|
121
132
|
readonly tar: "application/x-tar";
|
|
122
133
|
readonly tif: "image/tiff";
|
|
123
134
|
readonly tiff: "image/tiff";
|
|
124
|
-
readonly ts: "video/mp2t";
|
|
125
|
-
readonly ttf: "font/ttf";
|
|
135
|
+
readonly ts: "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
136
|
+
readonly ttf: "application/font-sfnt" | "font/ttf";
|
|
126
137
|
readonly txt: "text/plain";
|
|
127
138
|
readonly vsd: "application/vnd.visio";
|
|
139
|
+
readonly vtt: "text/vtt";
|
|
140
|
+
readonly wasm: "application/wasm";
|
|
128
141
|
readonly wav: "audio/wav";
|
|
129
142
|
readonly weba: "video/webm";
|
|
130
143
|
readonly webp: "image/webp";
|
|
@@ -163,6 +176,8 @@ declare class Fs {
|
|
|
163
176
|
readonly eot: "application/vnd.ms-fontobject";
|
|
164
177
|
readonly epub: "application/epub+zip";
|
|
165
178
|
readonly gif: "image/gif";
|
|
179
|
+
readonly glb: "model/gltf-binary";
|
|
180
|
+
readonly gltf: "model/gltf+json";
|
|
166
181
|
readonly gz: "application/x-gzip" | "application/gzip";
|
|
167
182
|
readonly htm: "text/html";
|
|
168
183
|
readonly html: "text/html";
|
|
@@ -175,6 +190,8 @@ declare class Fs {
|
|
|
175
190
|
readonly json: "application/json";
|
|
176
191
|
readonly jsonld: "application/ld+json";
|
|
177
192
|
readonly m3u8: "application/vnd.apple.mpegurl";
|
|
193
|
+
readonly m4a: "audio/mp4";
|
|
194
|
+
readonly m4v: "video/mp4";
|
|
178
195
|
readonly md: "text/markdown";
|
|
179
196
|
readonly mdx: "application/x-mdx";
|
|
180
197
|
readonly mid: "audio/midi";
|
|
@@ -185,10 +202,12 @@ declare class Fs {
|
|
|
185
202
|
readonly mpeg: "video/mpeg";
|
|
186
203
|
readonly mpkg: "application/vnd.apple.installer+xml";
|
|
187
204
|
readonly ndjson: "application/x-ndjson";
|
|
205
|
+
readonly obj: "application/octet-stream" | "text/plain" | "model/obj";
|
|
188
206
|
readonly odp: "application/vnd.oasis.opendocument.presentation";
|
|
189
207
|
readonly ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
190
208
|
readonly odt: "application/vnd.oasis.opendocument.text";
|
|
191
209
|
readonly oga: "audio/ogg";
|
|
210
|
+
readonly ogg: "audio/ogg";
|
|
192
211
|
readonly ogv: "video/ogg";
|
|
193
212
|
readonly ogx: "application/ogg";
|
|
194
213
|
readonly opus: "audio/ogg";
|
|
@@ -199,6 +218,8 @@ declare class Fs {
|
|
|
199
218
|
readonly pkpass: "application/vnd.apple.pkpass";
|
|
200
219
|
readonly ppt: "application/vnd.ms-powerpoint";
|
|
201
220
|
readonly pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
221
|
+
readonly py: "text/x-python";
|
|
222
|
+
readonly pyc: "application/x-python-code";
|
|
202
223
|
readonly rar: "application/vnd.rar";
|
|
203
224
|
readonly rtf: "application/rtf";
|
|
204
225
|
readonly sh: "application/x-sh";
|
|
@@ -206,10 +227,12 @@ declare class Fs {
|
|
|
206
227
|
readonly tar: "application/x-tar";
|
|
207
228
|
readonly tif: "image/tiff";
|
|
208
229
|
readonly tiff: "image/tiff";
|
|
209
|
-
readonly ts: "video/mp2t";
|
|
210
|
-
readonly ttf: "font/ttf";
|
|
230
|
+
readonly ts: "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
231
|
+
readonly ttf: "application/font-sfnt" | "font/ttf";
|
|
211
232
|
readonly txt: "text/plain";
|
|
212
233
|
readonly vsd: "application/vnd.visio";
|
|
234
|
+
readonly vtt: "text/vtt";
|
|
235
|
+
readonly wasm: "application/wasm";
|
|
213
236
|
readonly wav: "audio/wav";
|
|
214
237
|
readonly weba: "video/webm";
|
|
215
238
|
readonly webp: "image/webp";
|
|
@@ -225,13 +248,107 @@ declare class Fs {
|
|
|
225
248
|
readonly "3g2": "video/3gpp2";
|
|
226
249
|
readonly "7z": "application/x-7z-compressed";
|
|
227
250
|
}[S];
|
|
251
|
+
hmm: <const T extends ReturnType<typeof this.assetType>>(input: T) => {
|
|
252
|
+
readonly aac: "audio/aac";
|
|
253
|
+
readonly abw: "application/x-abiword";
|
|
254
|
+
readonly apng: "image/apng";
|
|
255
|
+
readonly arc: "application/x-freearc";
|
|
256
|
+
readonly avif: "image/avif";
|
|
257
|
+
readonly avi: "video/x-msvideo";
|
|
258
|
+
readonly azw: "application/vnd.amazon.ebook";
|
|
259
|
+
readonly bin: "application/octet-stream";
|
|
260
|
+
readonly bmp: "image/bmp";
|
|
261
|
+
readonly bz: "application/x-bzip";
|
|
262
|
+
readonly bz2: "application/x-bzip2";
|
|
263
|
+
readonly cda: "application/x-cdf";
|
|
264
|
+
readonly cjs: "application/javascript";
|
|
265
|
+
readonly csh: "application/x-csh";
|
|
266
|
+
readonly css: "text/css";
|
|
267
|
+
readonly csv: "text/csv";
|
|
268
|
+
readonly doc: "application/msword";
|
|
269
|
+
readonly docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
270
|
+
readonly eot: "application/vnd.ms-fontobject";
|
|
271
|
+
readonly epub: "application/epub+zip";
|
|
272
|
+
readonly gif: "image/gif";
|
|
273
|
+
readonly glb: "model/gltf-binary";
|
|
274
|
+
readonly gltf: "model/gltf+json";
|
|
275
|
+
readonly gz: "application/x-gzip" | "application/gzip";
|
|
276
|
+
readonly htm: "text/html";
|
|
277
|
+
readonly html: "text/html";
|
|
278
|
+
readonly ico: "image/vnd.microsoft.icon";
|
|
279
|
+
readonly ics: "text/calendar";
|
|
280
|
+
readonly jar: "application/java-archive";
|
|
281
|
+
readonly jpeg: "image/jpeg";
|
|
282
|
+
readonly jpg: "image/jpeg";
|
|
283
|
+
readonly js: "text/javascript";
|
|
284
|
+
readonly json: "application/json";
|
|
285
|
+
readonly jsonld: "application/ld+json";
|
|
286
|
+
readonly m3u8: "application/vnd.apple.mpegurl";
|
|
287
|
+
readonly m4a: "audio/mp4";
|
|
288
|
+
readonly m4v: "video/mp4";
|
|
289
|
+
readonly md: "text/markdown";
|
|
290
|
+
readonly mdx: "application/x-mdx";
|
|
291
|
+
readonly mid: "audio/midi";
|
|
292
|
+
readonly midi: "audio/x-midi";
|
|
293
|
+
readonly mjs: "text/javascript";
|
|
294
|
+
readonly mp3: "audio/mpeg";
|
|
295
|
+
readonly mp4: "video/mp4";
|
|
296
|
+
readonly mpeg: "video/mpeg";
|
|
297
|
+
readonly mpkg: "application/vnd.apple.installer+xml";
|
|
298
|
+
readonly ndjson: "application/x-ndjson";
|
|
299
|
+
readonly obj: "application/octet-stream" | "text/plain" | "model/obj";
|
|
300
|
+
readonly odp: "application/vnd.oasis.opendocument.presentation";
|
|
301
|
+
readonly ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
302
|
+
readonly odt: "application/vnd.oasis.opendocument.text";
|
|
303
|
+
readonly oga: "audio/ogg";
|
|
304
|
+
readonly ogg: "audio/ogg";
|
|
305
|
+
readonly ogv: "video/ogg";
|
|
306
|
+
readonly ogx: "application/ogg";
|
|
307
|
+
readonly opus: "audio/ogg";
|
|
308
|
+
readonly otf: "font/otf";
|
|
309
|
+
readonly png: "image/png";
|
|
310
|
+
readonly pdf: "application/pdf";
|
|
311
|
+
readonly php: "application/x-httpd-php";
|
|
312
|
+
readonly pkpass: "application/vnd.apple.pkpass";
|
|
313
|
+
readonly ppt: "application/vnd.ms-powerpoint";
|
|
314
|
+
readonly pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
315
|
+
readonly py: "text/x-python";
|
|
316
|
+
readonly pyc: "application/x-python-code";
|
|
317
|
+
readonly rar: "application/vnd.rar";
|
|
318
|
+
readonly rtf: "application/rtf";
|
|
319
|
+
readonly sh: "application/x-sh";
|
|
320
|
+
readonly svg: "image/svg+xml";
|
|
321
|
+
readonly tar: "application/x-tar";
|
|
322
|
+
readonly tif: "image/tiff";
|
|
323
|
+
readonly tiff: "image/tiff";
|
|
324
|
+
readonly ts: "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
325
|
+
readonly ttf: "application/font-sfnt" | "font/ttf";
|
|
326
|
+
readonly txt: "text/plain";
|
|
327
|
+
readonly vsd: "application/vnd.visio";
|
|
328
|
+
readonly vtt: "text/vtt";
|
|
329
|
+
readonly wasm: "application/wasm";
|
|
330
|
+
readonly wav: "audio/wav";
|
|
331
|
+
readonly weba: "video/webm";
|
|
332
|
+
readonly webp: "image/webp";
|
|
333
|
+
readonly woff: "font/woff";
|
|
334
|
+
readonly woff2: "font/woff2";
|
|
335
|
+
readonly xhtml: "application/xhtml+xml";
|
|
336
|
+
readonly xls: "application/vnd.ms-excel";
|
|
337
|
+
readonly xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
338
|
+
readonly xml: "application/xml";
|
|
339
|
+
readonly xul: "application/vnd.mozilla.xul+xml";
|
|
340
|
+
readonly zip: "application/zip" | "application/x-zip-compressed";
|
|
341
|
+
readonly "3gp": "video/3gpp";
|
|
342
|
+
readonly "3g2": "video/3gpp2";
|
|
343
|
+
readonly "7z": "application/x-7z-compressed";
|
|
344
|
+
}[T];
|
|
228
345
|
assetToBuffer<const T extends string>(path: T): Promise<{
|
|
229
|
-
readonly b64encodedData: `data:application/x-gzip;base64, ${string}` | `data:application/gzip;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/apng;base64, ${string}` | `data:application/x-freearc;base64, ${string}` | `data:image/avif;base64, ${string}` | `data:video/x-msvideo;base64, ${string}` | `data:application/vnd.amazon.ebook;base64, ${string}` | `data:
|
|
230
|
-
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "gz" | "htm" | "html" | "ico" | "ics" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "odp" | "ods" | "odt" | "oga" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "rar" | "rtf" | "sh" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
346
|
+
readonly b64encodedData: `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/apng;base64, ${string}` | `data:application/x-freearc;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/javascript;base64, ${string}` | `data:application/x-csh;base64, ${string}` | `data:text/css;base64, ${string}` | `data:text/csv;base64, ${string}` | `data:application/msword;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64, ${string}` | `data: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/html;base64, ${string}` | `data:image/vnd.microsoft.icon;base64, ${string}` | `data:text/calendar;base64, ${string}` | `data:application/java-archive;base64, ${string}` | `data:image/jpeg;base64, ${string}` | `data:text/javascript;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:image/svg+xml;base64, ${string}` | `data:application/x-tar;base64, ${string}` | `data:image/tiff;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:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
|
|
347
|
+
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "htm" | "html" | "ico" | "ics" | "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" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
231
348
|
}>;
|
|
232
349
|
assetToBufferView<const T extends string>(path: T): Promise<{
|
|
233
|
-
readonly b64encodedData:
|
|
234
|
-
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "gz" | "htm" | "html" | "ico" | "ics" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "odp" | "ods" | "odt" | "oga" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "rar" | "rtf" | "sh" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
350
|
+
readonly b64encodedData: string;
|
|
351
|
+
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "htm" | "html" | "ico" | "ics" | "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" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
235
352
|
}>;
|
|
236
353
|
formatHelper<const T extends string>(f: T): string;
|
|
237
354
|
range(from: number, to: number): number[];
|
|
@@ -239,6 +356,20 @@ declare class Fs {
|
|
|
239
356
|
acceptor: (num: number) => number[];
|
|
240
357
|
chunkArray<T extends number>(arr: string[], maxChunkLength: T): string[][];
|
|
241
358
|
b64ToBlob<const T extends string>(b64Data: T): Blob;
|
|
359
|
+
cleanDataUrl<const C extends string>(props: C): string;
|
|
360
|
+
/**
|
|
361
|
+
*
|
|
362
|
+
* @param inputUrl remote url to fetch data from
|
|
363
|
+
* @param outputPath desired output path relative to the cwd
|
|
364
|
+
* @param useDetectedExtension optional, defaults to true
|
|
365
|
+
*
|
|
366
|
+
* if `useDetectedExtension` is false you must include the file extension in your output path →
|
|
367
|
+
*
|
|
368
|
+
* 🚫 'public/assets/image-1'
|
|
369
|
+
*
|
|
370
|
+
* ✅ 'public/assets/image-1.png'
|
|
371
|
+
*/
|
|
372
|
+
fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
|
|
242
373
|
}
|
|
243
374
|
|
|
244
375
|
export = Fs;
|
package/dist/fs/index.d.ts
CHANGED
|
@@ -55,6 +55,9 @@ declare class Fs {
|
|
|
55
55
|
get URL_REGEX(): RegExp;
|
|
56
56
|
parseUrl(url: string): ParsedUrlInfo;
|
|
57
57
|
get gzVal(): "application/x-gzip" | "application/gzip";
|
|
58
|
+
get objVal(): "application/octet-stream" | "text/plain" | "model/obj";
|
|
59
|
+
get tsVal(): "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
60
|
+
get ttfVal(): "application/font-sfnt" | "font/ttf";
|
|
58
61
|
get zipVal(): "application/zip" | "application/x-zip-compressed";
|
|
59
62
|
get mimeTypeObj(): {
|
|
60
63
|
readonly aac: "audio/aac";
|
|
@@ -78,6 +81,8 @@ declare class Fs {
|
|
|
78
81
|
readonly eot: "application/vnd.ms-fontobject";
|
|
79
82
|
readonly epub: "application/epub+zip";
|
|
80
83
|
readonly gif: "image/gif";
|
|
84
|
+
readonly glb: "model/gltf-binary";
|
|
85
|
+
readonly gltf: "model/gltf+json";
|
|
81
86
|
readonly gz: "application/x-gzip" | "application/gzip";
|
|
82
87
|
readonly htm: "text/html";
|
|
83
88
|
readonly html: "text/html";
|
|
@@ -90,6 +95,8 @@ declare class Fs {
|
|
|
90
95
|
readonly json: "application/json";
|
|
91
96
|
readonly jsonld: "application/ld+json";
|
|
92
97
|
readonly m3u8: "application/vnd.apple.mpegurl";
|
|
98
|
+
readonly m4a: "audio/mp4";
|
|
99
|
+
readonly m4v: "video/mp4";
|
|
93
100
|
readonly md: "text/markdown";
|
|
94
101
|
readonly mdx: "application/x-mdx";
|
|
95
102
|
readonly mid: "audio/midi";
|
|
@@ -100,10 +107,12 @@ declare class Fs {
|
|
|
100
107
|
readonly mpeg: "video/mpeg";
|
|
101
108
|
readonly mpkg: "application/vnd.apple.installer+xml";
|
|
102
109
|
readonly ndjson: "application/x-ndjson";
|
|
110
|
+
readonly obj: "application/octet-stream" | "text/plain" | "model/obj";
|
|
103
111
|
readonly odp: "application/vnd.oasis.opendocument.presentation";
|
|
104
112
|
readonly ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
105
113
|
readonly odt: "application/vnd.oasis.opendocument.text";
|
|
106
114
|
readonly oga: "audio/ogg";
|
|
115
|
+
readonly ogg: "audio/ogg";
|
|
107
116
|
readonly ogv: "video/ogg";
|
|
108
117
|
readonly ogx: "application/ogg";
|
|
109
118
|
readonly opus: "audio/ogg";
|
|
@@ -114,6 +123,8 @@ declare class Fs {
|
|
|
114
123
|
readonly pkpass: "application/vnd.apple.pkpass";
|
|
115
124
|
readonly ppt: "application/vnd.ms-powerpoint";
|
|
116
125
|
readonly pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
126
|
+
readonly py: "text/x-python";
|
|
127
|
+
readonly pyc: "application/x-python-code";
|
|
117
128
|
readonly rar: "application/vnd.rar";
|
|
118
129
|
readonly rtf: "application/rtf";
|
|
119
130
|
readonly sh: "application/x-sh";
|
|
@@ -121,10 +132,12 @@ declare class Fs {
|
|
|
121
132
|
readonly tar: "application/x-tar";
|
|
122
133
|
readonly tif: "image/tiff";
|
|
123
134
|
readonly tiff: "image/tiff";
|
|
124
|
-
readonly ts: "video/mp2t";
|
|
125
|
-
readonly ttf: "font/ttf";
|
|
135
|
+
readonly ts: "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
136
|
+
readonly ttf: "application/font-sfnt" | "font/ttf";
|
|
126
137
|
readonly txt: "text/plain";
|
|
127
138
|
readonly vsd: "application/vnd.visio";
|
|
139
|
+
readonly vtt: "text/vtt";
|
|
140
|
+
readonly wasm: "application/wasm";
|
|
128
141
|
readonly wav: "audio/wav";
|
|
129
142
|
readonly weba: "video/webm";
|
|
130
143
|
readonly webp: "image/webp";
|
|
@@ -163,6 +176,8 @@ declare class Fs {
|
|
|
163
176
|
readonly eot: "application/vnd.ms-fontobject";
|
|
164
177
|
readonly epub: "application/epub+zip";
|
|
165
178
|
readonly gif: "image/gif";
|
|
179
|
+
readonly glb: "model/gltf-binary";
|
|
180
|
+
readonly gltf: "model/gltf+json";
|
|
166
181
|
readonly gz: "application/x-gzip" | "application/gzip";
|
|
167
182
|
readonly htm: "text/html";
|
|
168
183
|
readonly html: "text/html";
|
|
@@ -175,6 +190,8 @@ declare class Fs {
|
|
|
175
190
|
readonly json: "application/json";
|
|
176
191
|
readonly jsonld: "application/ld+json";
|
|
177
192
|
readonly m3u8: "application/vnd.apple.mpegurl";
|
|
193
|
+
readonly m4a: "audio/mp4";
|
|
194
|
+
readonly m4v: "video/mp4";
|
|
178
195
|
readonly md: "text/markdown";
|
|
179
196
|
readonly mdx: "application/x-mdx";
|
|
180
197
|
readonly mid: "audio/midi";
|
|
@@ -185,10 +202,12 @@ declare class Fs {
|
|
|
185
202
|
readonly mpeg: "video/mpeg";
|
|
186
203
|
readonly mpkg: "application/vnd.apple.installer+xml";
|
|
187
204
|
readonly ndjson: "application/x-ndjson";
|
|
205
|
+
readonly obj: "application/octet-stream" | "text/plain" | "model/obj";
|
|
188
206
|
readonly odp: "application/vnd.oasis.opendocument.presentation";
|
|
189
207
|
readonly ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
190
208
|
readonly odt: "application/vnd.oasis.opendocument.text";
|
|
191
209
|
readonly oga: "audio/ogg";
|
|
210
|
+
readonly ogg: "audio/ogg";
|
|
192
211
|
readonly ogv: "video/ogg";
|
|
193
212
|
readonly ogx: "application/ogg";
|
|
194
213
|
readonly opus: "audio/ogg";
|
|
@@ -199,6 +218,8 @@ declare class Fs {
|
|
|
199
218
|
readonly pkpass: "application/vnd.apple.pkpass";
|
|
200
219
|
readonly ppt: "application/vnd.ms-powerpoint";
|
|
201
220
|
readonly pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
221
|
+
readonly py: "text/x-python";
|
|
222
|
+
readonly pyc: "application/x-python-code";
|
|
202
223
|
readonly rar: "application/vnd.rar";
|
|
203
224
|
readonly rtf: "application/rtf";
|
|
204
225
|
readonly sh: "application/x-sh";
|
|
@@ -206,10 +227,12 @@ declare class Fs {
|
|
|
206
227
|
readonly tar: "application/x-tar";
|
|
207
228
|
readonly tif: "image/tiff";
|
|
208
229
|
readonly tiff: "image/tiff";
|
|
209
|
-
readonly ts: "video/mp2t";
|
|
210
|
-
readonly ttf: "font/ttf";
|
|
230
|
+
readonly ts: "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
231
|
+
readonly ttf: "application/font-sfnt" | "font/ttf";
|
|
211
232
|
readonly txt: "text/plain";
|
|
212
233
|
readonly vsd: "application/vnd.visio";
|
|
234
|
+
readonly vtt: "text/vtt";
|
|
235
|
+
readonly wasm: "application/wasm";
|
|
213
236
|
readonly wav: "audio/wav";
|
|
214
237
|
readonly weba: "video/webm";
|
|
215
238
|
readonly webp: "image/webp";
|
|
@@ -225,13 +248,107 @@ declare class Fs {
|
|
|
225
248
|
readonly "3g2": "video/3gpp2";
|
|
226
249
|
readonly "7z": "application/x-7z-compressed";
|
|
227
250
|
}[S];
|
|
251
|
+
hmm: <const T extends ReturnType<typeof this.assetType>>(input: T) => {
|
|
252
|
+
readonly aac: "audio/aac";
|
|
253
|
+
readonly abw: "application/x-abiword";
|
|
254
|
+
readonly apng: "image/apng";
|
|
255
|
+
readonly arc: "application/x-freearc";
|
|
256
|
+
readonly avif: "image/avif";
|
|
257
|
+
readonly avi: "video/x-msvideo";
|
|
258
|
+
readonly azw: "application/vnd.amazon.ebook";
|
|
259
|
+
readonly bin: "application/octet-stream";
|
|
260
|
+
readonly bmp: "image/bmp";
|
|
261
|
+
readonly bz: "application/x-bzip";
|
|
262
|
+
readonly bz2: "application/x-bzip2";
|
|
263
|
+
readonly cda: "application/x-cdf";
|
|
264
|
+
readonly cjs: "application/javascript";
|
|
265
|
+
readonly csh: "application/x-csh";
|
|
266
|
+
readonly css: "text/css";
|
|
267
|
+
readonly csv: "text/csv";
|
|
268
|
+
readonly doc: "application/msword";
|
|
269
|
+
readonly docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
270
|
+
readonly eot: "application/vnd.ms-fontobject";
|
|
271
|
+
readonly epub: "application/epub+zip";
|
|
272
|
+
readonly gif: "image/gif";
|
|
273
|
+
readonly glb: "model/gltf-binary";
|
|
274
|
+
readonly gltf: "model/gltf+json";
|
|
275
|
+
readonly gz: "application/x-gzip" | "application/gzip";
|
|
276
|
+
readonly htm: "text/html";
|
|
277
|
+
readonly html: "text/html";
|
|
278
|
+
readonly ico: "image/vnd.microsoft.icon";
|
|
279
|
+
readonly ics: "text/calendar";
|
|
280
|
+
readonly jar: "application/java-archive";
|
|
281
|
+
readonly jpeg: "image/jpeg";
|
|
282
|
+
readonly jpg: "image/jpeg";
|
|
283
|
+
readonly js: "text/javascript";
|
|
284
|
+
readonly json: "application/json";
|
|
285
|
+
readonly jsonld: "application/ld+json";
|
|
286
|
+
readonly m3u8: "application/vnd.apple.mpegurl";
|
|
287
|
+
readonly m4a: "audio/mp4";
|
|
288
|
+
readonly m4v: "video/mp4";
|
|
289
|
+
readonly md: "text/markdown";
|
|
290
|
+
readonly mdx: "application/x-mdx";
|
|
291
|
+
readonly mid: "audio/midi";
|
|
292
|
+
readonly midi: "audio/x-midi";
|
|
293
|
+
readonly mjs: "text/javascript";
|
|
294
|
+
readonly mp3: "audio/mpeg";
|
|
295
|
+
readonly mp4: "video/mp4";
|
|
296
|
+
readonly mpeg: "video/mpeg";
|
|
297
|
+
readonly mpkg: "application/vnd.apple.installer+xml";
|
|
298
|
+
readonly ndjson: "application/x-ndjson";
|
|
299
|
+
readonly obj: "application/octet-stream" | "text/plain" | "model/obj";
|
|
300
|
+
readonly odp: "application/vnd.oasis.opendocument.presentation";
|
|
301
|
+
readonly ods: "application/vnd.oasis.opendocument.spreadsheet";
|
|
302
|
+
readonly odt: "application/vnd.oasis.opendocument.text";
|
|
303
|
+
readonly oga: "audio/ogg";
|
|
304
|
+
readonly ogg: "audio/ogg";
|
|
305
|
+
readonly ogv: "video/ogg";
|
|
306
|
+
readonly ogx: "application/ogg";
|
|
307
|
+
readonly opus: "audio/ogg";
|
|
308
|
+
readonly otf: "font/otf";
|
|
309
|
+
readonly png: "image/png";
|
|
310
|
+
readonly pdf: "application/pdf";
|
|
311
|
+
readonly php: "application/x-httpd-php";
|
|
312
|
+
readonly pkpass: "application/vnd.apple.pkpass";
|
|
313
|
+
readonly ppt: "application/vnd.ms-powerpoint";
|
|
314
|
+
readonly pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
315
|
+
readonly py: "text/x-python";
|
|
316
|
+
readonly pyc: "application/x-python-code";
|
|
317
|
+
readonly rar: "application/vnd.rar";
|
|
318
|
+
readonly rtf: "application/rtf";
|
|
319
|
+
readonly sh: "application/x-sh";
|
|
320
|
+
readonly svg: "image/svg+xml";
|
|
321
|
+
readonly tar: "application/x-tar";
|
|
322
|
+
readonly tif: "image/tiff";
|
|
323
|
+
readonly tiff: "image/tiff";
|
|
324
|
+
readonly ts: "text/typescript" | "video/mp2t" | "video/vnd.dlna.mpeg-tts";
|
|
325
|
+
readonly ttf: "application/font-sfnt" | "font/ttf";
|
|
326
|
+
readonly txt: "text/plain";
|
|
327
|
+
readonly vsd: "application/vnd.visio";
|
|
328
|
+
readonly vtt: "text/vtt";
|
|
329
|
+
readonly wasm: "application/wasm";
|
|
330
|
+
readonly wav: "audio/wav";
|
|
331
|
+
readonly weba: "video/webm";
|
|
332
|
+
readonly webp: "image/webp";
|
|
333
|
+
readonly woff: "font/woff";
|
|
334
|
+
readonly woff2: "font/woff2";
|
|
335
|
+
readonly xhtml: "application/xhtml+xml";
|
|
336
|
+
readonly xls: "application/vnd.ms-excel";
|
|
337
|
+
readonly xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
338
|
+
readonly xml: "application/xml";
|
|
339
|
+
readonly xul: "application/vnd.mozilla.xul+xml";
|
|
340
|
+
readonly zip: "application/zip" | "application/x-zip-compressed";
|
|
341
|
+
readonly "3gp": "video/3gpp";
|
|
342
|
+
readonly "3g2": "video/3gpp2";
|
|
343
|
+
readonly "7z": "application/x-7z-compressed";
|
|
344
|
+
}[T];
|
|
228
345
|
assetToBuffer<const T extends string>(path: T): Promise<{
|
|
229
|
-
readonly b64encodedData: `data:application/x-gzip;base64, ${string}` | `data:application/gzip;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/apng;base64, ${string}` | `data:application/x-freearc;base64, ${string}` | `data:image/avif;base64, ${string}` | `data:video/x-msvideo;base64, ${string}` | `data:application/vnd.amazon.ebook;base64, ${string}` | `data:
|
|
230
|
-
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "gz" | "htm" | "html" | "ico" | "ics" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "odp" | "ods" | "odt" | "oga" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "rar" | "rtf" | "sh" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
346
|
+
readonly b64encodedData: `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/apng;base64, ${string}` | `data:application/x-freearc;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/javascript;base64, ${string}` | `data:application/x-csh;base64, ${string}` | `data:text/css;base64, ${string}` | `data:text/csv;base64, ${string}` | `data:application/msword;base64, ${string}` | `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64, ${string}` | `data: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/html;base64, ${string}` | `data:image/vnd.microsoft.icon;base64, ${string}` | `data:text/calendar;base64, ${string}` | `data:application/java-archive;base64, ${string}` | `data:image/jpeg;base64, ${string}` | `data:text/javascript;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:image/svg+xml;base64, ${string}` | `data:application/x-tar;base64, ${string}` | `data:image/tiff;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:video/3gpp;base64, ${string}` | `data:video/3gpp2;base64, ${string}` | `data:application/x-7z-compressed;base64, ${string}`;
|
|
347
|
+
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "htm" | "html" | "ico" | "ics" | "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" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
231
348
|
}>;
|
|
232
349
|
assetToBufferView<const T extends string>(path: T): Promise<{
|
|
233
|
-
readonly b64encodedData:
|
|
234
|
-
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "gz" | "htm" | "html" | "ico" | "ics" | "jar" | "jpeg" | "jpg" | "js" | "json" | "jsonld" | "m3u8" | "md" | "mdx" | "mid" | "midi" | "mjs" | "mp3" | "mp4" | "mpeg" | "mpkg" | "ndjson" | "odp" | "ods" | "odt" | "oga" | "ogv" | "ogx" | "opus" | "otf" | "png" | "pdf" | "php" | "pkpass" | "ppt" | "pptx" | "rar" | "rtf" | "sh" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
350
|
+
readonly b64encodedData: string;
|
|
351
|
+
readonly extension: "aac" | "abw" | "apng" | "arc" | "avif" | "avi" | "azw" | "bin" | "bmp" | "bz" | "bz2" | "cda" | "cjs" | "csh" | "css" | "csv" | "doc" | "docx" | "eot" | "epub" | "gif" | "glb" | "gltf" | "gz" | "htm" | "html" | "ico" | "ics" | "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" | "svg" | "tar" | "tif" | "tiff" | "ts" | "ttf" | "txt" | "vsd" | "vtt" | "wasm" | "wav" | "weba" | "webp" | "woff" | "woff2" | "xhtml" | "xls" | "xlsx" | "xml" | "xul" | "zip" | "3gp" | "3g2" | "7z";
|
|
235
352
|
}>;
|
|
236
353
|
formatHelper<const T extends string>(f: T): string;
|
|
237
354
|
range(from: number, to: number): number[];
|
|
@@ -239,6 +356,20 @@ declare class Fs {
|
|
|
239
356
|
acceptor: (num: number) => number[];
|
|
240
357
|
chunkArray<T extends number>(arr: string[], maxChunkLength: T): string[][];
|
|
241
358
|
b64ToBlob<const T extends string>(b64Data: T): Blob;
|
|
359
|
+
cleanDataUrl<const C extends string>(props: C): string;
|
|
360
|
+
/**
|
|
361
|
+
*
|
|
362
|
+
* @param inputUrl remote url to fetch data from
|
|
363
|
+
* @param outputPath desired output path relative to the cwd
|
|
364
|
+
* @param useDetectedExtension optional, defaults to true
|
|
365
|
+
*
|
|
366
|
+
* if `useDetectedExtension` is false you must include the file extension in your output path →
|
|
367
|
+
*
|
|
368
|
+
* 🚫 'public/assets/image-1'
|
|
369
|
+
*
|
|
370
|
+
* ✅ 'public/assets/image-1.png'
|
|
371
|
+
*/
|
|
372
|
+
fetchRemoteWriteLocal<const I extends string, const O extends string>(inputUrl: I, outputPath: O, useDetectedExtension?: boolean): Promise<void>;
|
|
242
373
|
}
|
|
243
374
|
|
|
244
375
|
export { Fs as default };
|
package/dist/fs/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -363,11 +363,22 @@ var Fs = class {
|
|
|
363
363
|
/* end url */
|
|
364
364
|
get gzVal() {
|
|
365
365
|
return ["application/x-gzip", "application/gzip"].reduce(
|
|
366
|
-
(
|
|
366
|
+
(union) => union
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
get objVal() {
|
|
370
|
+
return ["application/octet-stream", "text/plain", "model/obj"].reduce((union) => union);
|
|
371
|
+
}
|
|
372
|
+
get tsVal() {
|
|
373
|
+
return ["text/typescript", "video/mp2t", "video/vnd.dlna.mpeg-tts"].reduce((union) => union);
|
|
374
|
+
}
|
|
375
|
+
get ttfVal() {
|
|
376
|
+
return ["application/font-sfnt", "font/ttf"].reduce(
|
|
377
|
+
(union) => union
|
|
367
378
|
);
|
|
368
379
|
}
|
|
369
380
|
get zipVal() {
|
|
370
|
-
return ["application/zip", "application/x-zip-compressed"].reduce((
|
|
381
|
+
return ["application/zip", "application/x-zip-compressed"].reduce((union) => union);
|
|
371
382
|
}
|
|
372
383
|
get mimeTypeObj() {
|
|
373
384
|
return {
|
|
@@ -392,6 +403,8 @@ var Fs = class {
|
|
|
392
403
|
eot: "application/vnd.ms-fontobject",
|
|
393
404
|
epub: "application/epub+zip",
|
|
394
405
|
gif: "image/gif",
|
|
406
|
+
glb: "model/gltf-binary",
|
|
407
|
+
gltf: "model/gltf+json",
|
|
395
408
|
gz: this.gzVal,
|
|
396
409
|
htm: "text/html",
|
|
397
410
|
html: "text/html",
|
|
@@ -404,6 +417,8 @@ var Fs = class {
|
|
|
404
417
|
json: "application/json",
|
|
405
418
|
jsonld: "application/ld+json",
|
|
406
419
|
m3u8: "application/vnd.apple.mpegurl",
|
|
420
|
+
m4a: "audio/mp4",
|
|
421
|
+
m4v: "video/mp4",
|
|
407
422
|
md: "text/markdown",
|
|
408
423
|
mdx: "application/x-mdx",
|
|
409
424
|
mid: "audio/midi",
|
|
@@ -414,10 +429,12 @@ var Fs = class {
|
|
|
414
429
|
mpeg: "video/mpeg",
|
|
415
430
|
mpkg: "application/vnd.apple.installer+xml",
|
|
416
431
|
ndjson: "application/x-ndjson",
|
|
432
|
+
obj: this.objVal,
|
|
417
433
|
odp: "application/vnd.oasis.opendocument.presentation",
|
|
418
434
|
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
419
435
|
odt: "application/vnd.oasis.opendocument.text",
|
|
420
436
|
oga: "audio/ogg",
|
|
437
|
+
ogg: "audio/ogg",
|
|
421
438
|
ogv: "video/ogg",
|
|
422
439
|
ogx: "application/ogg",
|
|
423
440
|
opus: "audio/ogg",
|
|
@@ -428,6 +445,8 @@ var Fs = class {
|
|
|
428
445
|
pkpass: "application/vnd.apple.pkpass",
|
|
429
446
|
ppt: "application/vnd.ms-powerpoint",
|
|
430
447
|
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
448
|
+
py: "text/x-python",
|
|
449
|
+
pyc: "application/x-python-code",
|
|
431
450
|
rar: "application/vnd.rar",
|
|
432
451
|
rtf: "application/rtf",
|
|
433
452
|
sh: "application/x-sh",
|
|
@@ -435,10 +454,12 @@ var Fs = class {
|
|
|
435
454
|
tar: "application/x-tar",
|
|
436
455
|
tif: "image/tiff",
|
|
437
456
|
tiff: "image/tiff",
|
|
438
|
-
ts:
|
|
439
|
-
ttf:
|
|
457
|
+
ts: this.tsVal,
|
|
458
|
+
ttf: this.ttfVal,
|
|
440
459
|
txt: "text/plain",
|
|
441
460
|
vsd: "application/vnd.visio",
|
|
461
|
+
vtt: "text/vtt",
|
|
462
|
+
wasm: "application/wasm",
|
|
442
463
|
wav: "audio/wav",
|
|
443
464
|
weba: "video/webm",
|
|
444
465
|
webp: "image/webp",
|
|
@@ -456,18 +477,20 @@ var Fs = class {
|
|
|
456
477
|
};
|
|
457
478
|
}
|
|
458
479
|
assetType(url) {
|
|
459
|
-
|
|
480
|
+
const u = this.parseUrl(url);
|
|
481
|
+
return u.pathname?.split(/([.])/gim)?.reverse()?.[0];
|
|
460
482
|
}
|
|
461
483
|
getMime(input) {
|
|
462
484
|
return this.mimeTypeObj[input];
|
|
463
485
|
}
|
|
486
|
+
hmm = /* @__PURE__ */ __name((input) => {
|
|
487
|
+
return this.mimeTypeObj[input];
|
|
488
|
+
}, "hmm");
|
|
464
489
|
async assetToBuffer(path) {
|
|
465
490
|
const [fetcher] = await Promise.all([
|
|
466
491
|
fetch(path).then((t) => t.arrayBuffer())
|
|
467
492
|
]);
|
|
468
|
-
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(
|
|
469
|
-
Buffer.from(fetcher).toJSON().data
|
|
470
|
-
).toString("base64")}`;
|
|
493
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(fetcher).toString("base64")}`;
|
|
471
494
|
const extension = this.assetType(path);
|
|
472
495
|
return {
|
|
473
496
|
b64encodedData,
|
|
@@ -475,27 +498,34 @@ var Fs = class {
|
|
|
475
498
|
};
|
|
476
499
|
}
|
|
477
500
|
async assetToBufferView(path) {
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
501
|
+
const response = await fetch(path);
|
|
502
|
+
if (!response.ok) {
|
|
503
|
+
throw new Error(`Failed to fetch asset: ${response.statusText}`);
|
|
504
|
+
}
|
|
505
|
+
const reader = response.body?.getReader();
|
|
506
|
+
if (reader) {
|
|
507
|
+
const chunks = [];
|
|
508
|
+
while (true) {
|
|
509
|
+
const { done, value } = await reader.read();
|
|
510
|
+
if (done) break;
|
|
511
|
+
if (value) chunks.push(value);
|
|
486
512
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
b64encodedData,
|
|
497
|
-
|
|
498
|
-
|
|
513
|
+
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
514
|
+
const completeBuffer = new Uint8Array(totalLength);
|
|
515
|
+
let offset = 0;
|
|
516
|
+
for (const chunk of chunks) {
|
|
517
|
+
completeBuffer.set(chunk, offset);
|
|
518
|
+
offset += chunk.length;
|
|
519
|
+
}
|
|
520
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(completeBuffer).toString("base64")}`;
|
|
521
|
+
const extension = this.assetType(path);
|
|
522
|
+
return { b64encodedData, extension };
|
|
523
|
+
} else {
|
|
524
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
525
|
+
const b64encodedData = `data:${this.getMime(this.assetType(path))};base64, ${Buffer.from(arrayBuffer).toString("base64")}`;
|
|
526
|
+
const extension = this.assetType(path);
|
|
527
|
+
return { b64encodedData, extension };
|
|
528
|
+
}
|
|
499
529
|
}
|
|
500
530
|
formatHelper(f) {
|
|
501
531
|
if (/([A-Za-z]+-[A-Za-z]+)/g.test(f) === true) {
|
|
@@ -504,7 +534,7 @@ var Fs = class {
|
|
|
504
534
|
} else return f.substring(0, 1).toUpperCase().concat(f.substring(1));
|
|
505
535
|
}
|
|
506
536
|
range(from, to) {
|
|
507
|
-
const values =
|
|
537
|
+
const values = Array.of();
|
|
508
538
|
for (let i = from; i < to; i++) {
|
|
509
539
|
values.push(i);
|
|
510
540
|
}
|
|
@@ -544,10 +574,9 @@ var Fs = class {
|
|
|
544
574
|
{
|
|
545
575
|
const sliceSize = 512;
|
|
546
576
|
const typeMatch = b64Data.match(
|
|
547
|
-
/^data:(image|application|video|text|font)\/[A-Za-z0-9+-.]+;base64,/
|
|
577
|
+
/^data:(image|application|video|text|model|font)\/[A-Za-z0-9+-.]+;base64,/
|
|
548
578
|
);
|
|
549
579
|
const type = typeMatch?.[1];
|
|
550
|
-
console.log(type ?? "");
|
|
551
580
|
if (!typeMatch) {
|
|
552
581
|
throw new Error(`${b64Data} is not a valid data Url`);
|
|
553
582
|
}
|
|
@@ -567,6 +596,39 @@ var Fs = class {
|
|
|
567
596
|
return blob;
|
|
568
597
|
}
|
|
569
598
|
}
|
|
599
|
+
cleanDataUrl(props) {
|
|
600
|
+
return props.replace(
|
|
601
|
+
/^data:(image|application|video|text|font|model|audio)\/[A-Za-z0-9+-.]+;base64,/,
|
|
602
|
+
""
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
*
|
|
607
|
+
* @param inputUrl remote url to fetch data from
|
|
608
|
+
* @param outputPath desired output path relative to the cwd
|
|
609
|
+
* @param useDetectedExtension optional, defaults to true
|
|
610
|
+
*
|
|
611
|
+
* if `useDetectedExtension` is false you must include the file extension in your output path →
|
|
612
|
+
*
|
|
613
|
+
* 🚫 'public/assets/image-1'
|
|
614
|
+
*
|
|
615
|
+
* ✅ 'public/assets/image-1.png'
|
|
616
|
+
*/
|
|
617
|
+
async fetchRemoteWriteLocal(inputUrl, outputPath, useDetectedExtension = true) {
|
|
618
|
+
try {
|
|
619
|
+
const result = await this.assetToBufferView(inputUrl);
|
|
620
|
+
const cleanData = this.cleanDataUrl(result.b64encodedData);
|
|
621
|
+
const formattedPath = useDetectedExtension ? `${outputPath}.${result.extension}` : outputPath;
|
|
622
|
+
if (/\./g.test(formattedPath) === false) {
|
|
623
|
+
throw new Error(
|
|
624
|
+
"either add false as the third argument in `fetchRemoteWriteLocal` [input, output, use-detected-file-extension (defaults to true)]"
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
this.withWs(formattedPath, Buffer.from(cleanData, "base64"));
|
|
628
|
+
} catch (err) {
|
|
629
|
+
return console.error(err);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
570
632
|
};
|
|
571
633
|
// Annotate the CommonJS export names for ESM import in node:
|
|
572
634
|
0 && (module.exports = {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d0paminedriven/fs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "convenient fs helpers",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@microsoft/api-extractor": "^7.52.
|
|
42
|
-
"@swc/core": "^1.11.
|
|
43
|
-
"@swc/wasm": "^1.11.
|
|
44
|
-
"@types/node": "^22.13.
|
|
41
|
+
"@microsoft/api-extractor": "^7.52.2",
|
|
42
|
+
"@swc/core": "^1.11.13",
|
|
43
|
+
"@swc/wasm": "^1.11.13",
|
|
44
|
+
"@types/node": "^22.13.13",
|
|
45
45
|
"chokidar": "^4.0.3",
|
|
46
46
|
"dotenv": "^16.4.7",
|
|
47
47
|
"dotenv-cli": "^8.0.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"tsx": "latest",
|
|
56
56
|
"typescript": "latest",
|
|
57
57
|
"typescript-eslint": "latest",
|
|
58
|
-
"@portfolio/
|
|
58
|
+
"@portfolio/eslint-config": "1.0.0",
|
|
59
59
|
"@portfolio/tsconfig": "0.1.0",
|
|
60
|
-
"@portfolio/
|
|
60
|
+
"@portfolio/prettier-config": "0.1.0"
|
|
61
61
|
},
|
|
62
62
|
"prettier": "@portfolio/prettier-config",
|
|
63
63
|
"scripts": {
|