@d0paminedriven/fs 6.3.0 → 7.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/README.md +180 -10
- package/dist/{chunk-C6AZRX7V.js → chunk-CN45SMBB.js} +17 -2
- package/dist/{chunk-NGBMZGGU.js → chunk-CTA73JRX.js} +380 -51
- package/dist/{chunk-MXEE2WS7.js → chunk-G27YIWW7.js} +1 -1
- package/dist/{chunk-XHN56MDK.js → chunk-QBG7TFHM.js} +5 -2
- package/dist/fs/index.cjs +521 -49
- package/dist/fs/index.d.cts +105 -10
- package/dist/fs/index.d.ts +105 -10
- package/dist/fs/index.js +5 -4
- package/dist/index.cjs +518 -174
- package/dist/index.js +4 -4
- package/dist/mime/index.cjs +144 -1
- package/dist/mime/index.d.cts +2 -0
- package/dist/mime/index.d.ts +2 -0
- package/dist/mime/index.js +3 -2
- package/dist/types/index.d.cts +9 -1
- package/dist/types/index.d.ts +9 -1
- package/dist/types/index.js +1 -1
- package/dist/url/index.cjs +131 -1
- package/dist/url/index.d.cts +6 -1
- package/dist/url/index.d.ts +6 -1
- package/dist/url/index.js +2 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Fs
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CTA73JRX.js";
|
|
4
4
|
import {
|
|
5
5
|
MimeService,
|
|
6
6
|
extMimeMap,
|
|
7
7
|
mimeToExt
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CN45SMBB.js";
|
|
9
9
|
import {
|
|
10
10
|
unitsObj
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-G27YIWW7.js";
|
|
12
12
|
import {
|
|
13
13
|
UrlService
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-QBG7TFHM.js";
|
|
15
15
|
import {
|
|
16
16
|
UtilsService
|
|
17
17
|
} from "./chunk-IUGBPDQJ.js";
|
package/dist/mime/index.cjs
CHANGED
|
@@ -27,8 +27,136 @@ __export(mime_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(mime_exports);
|
|
29
29
|
|
|
30
|
+
// src/utils/index.ts
|
|
31
|
+
var UtilsService = class {
|
|
32
|
+
static {
|
|
33
|
+
__name(this, "UtilsService");
|
|
34
|
+
}
|
|
35
|
+
chunkArray(arr, maxChunkLength) {
|
|
36
|
+
const chunks = Array.of();
|
|
37
|
+
let currentChunkLength = 0;
|
|
38
|
+
let currentChunk = Array.of();
|
|
39
|
+
for (const [index, val] of arr.entries()) {
|
|
40
|
+
if (val.length + currentChunkLength >= maxChunkLength) {
|
|
41
|
+
if (currentChunk.length) {
|
|
42
|
+
chunks.push(currentChunk);
|
|
43
|
+
}
|
|
44
|
+
currentChunkLength = val.length;
|
|
45
|
+
currentChunk = [val];
|
|
46
|
+
} else {
|
|
47
|
+
currentChunk.push(val);
|
|
48
|
+
currentChunkLength += val.length + 1;
|
|
49
|
+
}
|
|
50
|
+
if (arr.length === index + 1) {
|
|
51
|
+
chunks.push(currentChunk);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return chunks.length ? chunks : [arr];
|
|
55
|
+
}
|
|
56
|
+
b64ToBlob(b64Data) {
|
|
57
|
+
{
|
|
58
|
+
const sliceSize = 512;
|
|
59
|
+
const typeMatch = /^data:((?:image|application|haptics|video|text|font|model|audio|multipart)\/[A-Za-z0-9+-.]+(?:;[^,]+)*);base64,(.+)$/i.exec(
|
|
60
|
+
b64Data
|
|
61
|
+
);
|
|
62
|
+
if (!typeMatch) {
|
|
63
|
+
throw new Error(`${b64Data} is not a valid data Url`);
|
|
64
|
+
}
|
|
65
|
+
const type = typeMatch[1];
|
|
66
|
+
const base64Data = typeMatch?.[2] ?? "";
|
|
67
|
+
const byteCharacters = Buffer.from(base64Data, "base64").toString(
|
|
68
|
+
"binary"
|
|
69
|
+
);
|
|
70
|
+
const byteArrays = Array.of();
|
|
71
|
+
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
72
|
+
const slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
73
|
+
const byteNumbers = new Array(slice.length);
|
|
74
|
+
for (let i = 0; i < slice.length; i++) {
|
|
75
|
+
byteNumbers[i] = slice.charCodeAt(i);
|
|
76
|
+
}
|
|
77
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
78
|
+
byteArrays.push(byteArray);
|
|
79
|
+
}
|
|
80
|
+
const blob = new Blob(byteArrays, { type });
|
|
81
|
+
return blob;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
arrToArrOfArrs = /* @__PURE__ */ __name(({
|
|
85
|
+
arrToFragment = Array.of(),
|
|
86
|
+
arrOfArrsAggregator = Array.of(),
|
|
87
|
+
interval
|
|
88
|
+
}) => new Promise(
|
|
89
|
+
(resolve, _reject) => resolve(
|
|
90
|
+
((interval2) => {
|
|
91
|
+
for (let i = 0; i <= arrToFragment.length; i++) {
|
|
92
|
+
if ((i % interval2 === 0 || i === 0) && i <= arrToFragment.length) {
|
|
93
|
+
let segment = arrToFragment.slice(i, i + interval2);
|
|
94
|
+
arrOfArrsAggregator.push(segment);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})(interval)
|
|
98
|
+
)
|
|
99
|
+
).then((_) => arrOfArrsAggregator), "arrToArrOfArrs");
|
|
100
|
+
extractTuple(obj, props) {
|
|
101
|
+
return [props, obj[props]];
|
|
102
|
+
}
|
|
103
|
+
sort(obj, order) {
|
|
104
|
+
return Object.fromEntries(
|
|
105
|
+
Object.entries(obj).sort(
|
|
106
|
+
([a, _aa], [b, _bb]) => order === "DESC" ? b.localeCompare(a) - a.localeCompare(b) : a.localeCompare(b) - b.localeCompare(a)
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
excludeTargeted = /* @__PURE__ */ __name((obj, props, sort) => {
|
|
111
|
+
const resolve = Object.fromEntries(
|
|
112
|
+
Object.entries(obj).map(([key, val]) => {
|
|
113
|
+
if (props.includes(key)) {
|
|
114
|
+
return ["omit", "omit"];
|
|
115
|
+
} else return [key, val];
|
|
116
|
+
}).filter(([t, _v]) => /omit/.test(t) === false)
|
|
117
|
+
);
|
|
118
|
+
return typeof sort !== "undefined" ? this.sort(resolve, sort) : resolve;
|
|
119
|
+
}, "excludeTargeted");
|
|
120
|
+
includeTargeted = /* @__PURE__ */ __name((obj, props, sort) => {
|
|
121
|
+
const resolve = Object.fromEntries(
|
|
122
|
+
props.map((val) => this.extractTuple(obj, val))
|
|
123
|
+
);
|
|
124
|
+
return typeof sort !== "undefined" ? this.sort(resolve, sort) : resolve;
|
|
125
|
+
}, "includeTargeted");
|
|
126
|
+
countsSorter = /* @__PURE__ */ __name((counter, keySort = "ASC", valSort = "DESC") => Object.fromEntries(
|
|
127
|
+
Array.from(Object.entries(counter)).sort(
|
|
128
|
+
([aStr, _aNum], [bStr, _bNum]) => keySort === "DESC" ? bStr.localeCompare(aStr) - aStr.localeCompare(bStr) : aStr.localeCompare(bStr) - bStr.localeCompare(aStr)
|
|
129
|
+
).sort(([aStr, aNum], [bStr, bNum]) => {
|
|
130
|
+
if (typeof (aNum && bNum) === "number") {
|
|
131
|
+
return valSort === "ASC" ? aNum - bNum : bNum - aNum;
|
|
132
|
+
} else if (typeof (aNum && bNum) === "string") {
|
|
133
|
+
return valSort === "ASC" ? aStr.localeCompare(bStr) - bStr.localeCompare(aStr) : bStr.localeCompare(aStr) - aStr.localeCompare(bStr);
|
|
134
|
+
} else
|
|
135
|
+
throw new Error(
|
|
136
|
+
"only Record<string, string> and Record<string,number> types supported"
|
|
137
|
+
);
|
|
138
|
+
})
|
|
139
|
+
), "countsSorter");
|
|
140
|
+
range(from, to) {
|
|
141
|
+
const values = Array.of();
|
|
142
|
+
for (let i = from; i < to; i++) {
|
|
143
|
+
values.push(i);
|
|
144
|
+
}
|
|
145
|
+
return values;
|
|
146
|
+
}
|
|
147
|
+
isPrimeNumber = /* @__PURE__ */ __name((n) => {
|
|
148
|
+
for (let i = 2; n > i; i++) {
|
|
149
|
+
if (n % i === 0) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return n > 1;
|
|
154
|
+
}, "isPrimeNumber");
|
|
155
|
+
acceptor = /* @__PURE__ */ __name((num) => [...Array(num !== 0 ? num : this.range(num = -101, num = 101)).keys()].reverse().filter(this.isPrimeNumber), "acceptor");
|
|
156
|
+
};
|
|
157
|
+
|
|
30
158
|
// src/url/index.ts
|
|
31
|
-
var UrlService = class {
|
|
159
|
+
var UrlService = class extends UtilsService {
|
|
32
160
|
static {
|
|
33
161
|
__name(this, "UrlService");
|
|
34
162
|
}
|
|
@@ -315,6 +443,21 @@ var MimeService = class extends UrlService {
|
|
|
315
443
|
);
|
|
316
444
|
}
|
|
317
445
|
}
|
|
446
|
+
mimeToExt(mime) {
|
|
447
|
+
const extensions = this.toExtObj[mime];
|
|
448
|
+
if (extensions.length === 1) return extensions[0];
|
|
449
|
+
if (extensions.length === 2) {
|
|
450
|
+
return extensions[0];
|
|
451
|
+
}
|
|
452
|
+
if (extensions.length === 3) {
|
|
453
|
+
if (mime === "audio/ogg") return "ogg";
|
|
454
|
+
return extensions[0];
|
|
455
|
+
}
|
|
456
|
+
if (extensions.length === 5) {
|
|
457
|
+
return "sse";
|
|
458
|
+
}
|
|
459
|
+
return extensions[0];
|
|
460
|
+
}
|
|
318
461
|
assetType(url) {
|
|
319
462
|
const parsed = this.parseUrl(url);
|
|
320
463
|
if (!parsed) return void 0;
|
package/dist/mime/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import { XOR } from '../types/index.cjs';
|
|
|
2
2
|
import { UrlService } from '../url/index.cjs';
|
|
3
3
|
import 'stream';
|
|
4
4
|
import 'buffer';
|
|
5
|
+
import '../utils/index.cjs';
|
|
5
6
|
|
|
6
7
|
declare const extMimeMap: {
|
|
7
8
|
readonly aac: readonly ["audio/aac"];
|
|
@@ -456,6 +457,7 @@ declare class MimeService extends UrlService {
|
|
|
456
457
|
compareMimeToExt(p?: "mime" | "ext"): {
|
|
457
458
|
[k: string]: number;
|
|
458
459
|
};
|
|
460
|
+
mimeToExt(mime: keyof typeof this.toExtObj): "png" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "doc" | "node" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "toml" | "azw" | "mpkg" | "m3u8" | "pkpass" | "xul" | "xls" | "eot" | "ppt" | "odp" | "ods" | "odt" | "pptx" | "xlsx" | "docx" | "rar" | "vsd" | "wasm" | "7z" | "abw" | "bz" | "bz2" | "cda" | "csh" | "arc" | "php" | "mdx" | "ndjson" | "pyc" | "sh" | "tar" | "zip" | "xhtml" | "xml" | "yml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "cjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "mpeg" | "ogv" | "weba" | "avi";
|
|
459
461
|
assetType<const T extends string>(url: T): "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "doc" | "node" | "js" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "toml" | "azw" | "mpkg" | "m3u8" | "pkpass" | "xul" | "xls" | "eot" | "ppt" | "odp" | "ods" | "odt" | "pptx" | "xlsx" | "docx" | "rar" | "vsd" | "wasm" | "7z" | "abw" | "bz" | "bz2" | "cda" | "csh" | "arc" | "php" | "mdx" | "ndjson" | "pyc" | "sh" | "tar" | "zip" | "xhtml" | "xml" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "weba" | "avi" | undefined;
|
|
460
462
|
getMimes<const E extends FileExtension>(ext: E): readonly ["audio/aac"] | readonly ["application/x-abiword"] | readonly ["image/aces"] | readonly ["image/apng"] | readonly ["application/x-freearc"] | readonly ["image/avci"] | readonly ["image/avif"] | readonly ["video/x-msvideo"] | readonly ["application/vnd.amazon.ebook"] | readonly ["application/octet-stream", "multipart/voice-message"] | readonly ["image/bmp"] | readonly ["application/x-bzip"] | readonly ["application/x-bzip2"] | readonly ["application/x-cdf"] | readonly ["application/node", "text/javascript"] | readonly ["application/x-csh"] | readonly ["text/css"] | readonly ["text/csv"] | readonly ["application/msword"] | readonly ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"] | readonly ["image/dpx"] | readonly ["image/emf"] | readonly ["application/vnd.ms-fontobject"] | readonly ["application/epub+zip"] | readonly ["image/gif"] | readonly ["model/gltf-binary"] | readonly ["model/gltf+json"] | readonly ["application/gzip", "application/x-gzip"] | readonly ["haptics/hjif"] | readonly ["haptics/hmpg"] | readonly ["text/html"] | readonly ["image/vnd.microsoft.icon"] | readonly ["text/calendar"] | readonly ["haptics/ivs"] | readonly ["application/java-archive"] | readonly ["image/jpeg"] | readonly ["application/json"] | readonly ["application/ld+json"] | readonly ["image/ktx"] | readonly ["image/ktx2"] | readonly ["application/vnd.apple.mpegurl"] | readonly ["audio/mp4"] | readonly ["video/mp4"] | readonly ["text/markdown"] | readonly ["application/x-mdx"] | readonly ["audio/midi"] | readonly ["audio/x-midi"] | readonly ["text/javascript"] | readonly ["audio/mpeg"] | readonly ["video/mpeg"] | readonly ["application/vnd.apple.installer+xml"] | readonly ["application/x-ndjson"] | readonly ["model/obj", "application/octet-stream", "text/plain"] | readonly ["application/vnd.oasis.opendocument.presentation"] | readonly ["application/vnd.oasis.opendocument.spreadsheet"] | readonly ["application/vnd.oasis.opendocument.text"] | readonly ["audio/ogg"] | readonly ["video/ogg"] | readonly ["application/ogg"] | readonly ["font/otf"] | readonly ["image/png"] | readonly ["application/pdf"] | readonly ["application/x-httpd-php"] | readonly ["application/vnd.apple.pkpass"] | readonly ["application/vnd.ms-powerpoint"] | readonly ["application/vnd.openxmlformats-officedocument.presentationml.presentation"] | readonly ["text/x-python"] | readonly ["application/x-python-code"] | readonly ["application/vnd.rar"] | readonly ["text/rust"] | readonly ["application/rtf"] | readonly ["application/x-sh"] | readonly ["application/sql"] | readonly ["text/event-stream"] | readonly ["image/svg+xml"] | readonly ["application/x-tar"] | readonly ["image/tiff"] | readonly ["application/toml"] | readonly ["text/typescript", "video/mp2t", "video/vnd.dlna.mpeg-tts"] | readonly ["application/font-sfnt", "font/ttf"] | readonly ["text/plain"] | readonly ["model/vnd.usdz+zip"] | readonly ["application/vnd.visio"] | readonly ["text/vtt"] | readonly ["application/wasm"] | readonly ["audio/wav"] | readonly ["video/webm"] | readonly ["image/webp"] | readonly ["font/woff"] | readonly ["font/woff2"] | readonly ["application/xhtml+xml"] | readonly ["application/vnd.ms-excel"] | readonly ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] | readonly ["application/xml"] | readonly ["application/vnd.mozilla.xul+xml"] | readonly ["application/yaml"] | readonly ["application/zip", "application/x-zip-compressed"] | readonly ["video/3gpp"] | readonly ["video/3gpp2"] | readonly ["application/x-7z-compressed"];
|
|
461
463
|
getMimeFor<const E extends FileExtension>(ext: E, opts?: {
|
package/dist/mime/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { XOR } from '../types/index.js';
|
|
|
2
2
|
import { UrlService } from '../url/index.js';
|
|
3
3
|
import 'stream';
|
|
4
4
|
import 'buffer';
|
|
5
|
+
import '../utils/index.js';
|
|
5
6
|
|
|
6
7
|
declare const extMimeMap: {
|
|
7
8
|
readonly aac: readonly ["audio/aac"];
|
|
@@ -456,6 +457,7 @@ declare class MimeService extends UrlService {
|
|
|
456
457
|
compareMimeToExt(p?: "mime" | "ext"): {
|
|
457
458
|
[k: string]: number;
|
|
458
459
|
};
|
|
460
|
+
mimeToExt(mime: keyof typeof this.toExtObj): "png" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "doc" | "node" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "toml" | "azw" | "mpkg" | "m3u8" | "pkpass" | "xul" | "xls" | "eot" | "ppt" | "odp" | "ods" | "odt" | "pptx" | "xlsx" | "docx" | "rar" | "vsd" | "wasm" | "7z" | "abw" | "bz" | "bz2" | "cda" | "csh" | "arc" | "php" | "mdx" | "ndjson" | "pyc" | "sh" | "tar" | "zip" | "xhtml" | "xml" | "yml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "cjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "mpeg" | "ogv" | "weba" | "avi";
|
|
459
461
|
assetType<const T extends string>(url: T): "png" | "jpeg" | "gif" | "bmp" | "webp" | "avif" | "epub" | "ttf" | "gz" | "jar" | "json" | "jsonld" | "doc" | "node" | "js" | "bin" | "obj" | "ogx" | "pdf" | "rtf" | "sql" | "toml" | "azw" | "mpkg" | "m3u8" | "pkpass" | "xul" | "xls" | "eot" | "ppt" | "odp" | "ods" | "odt" | "pptx" | "xlsx" | "docx" | "rar" | "vsd" | "wasm" | "7z" | "abw" | "bz" | "bz2" | "cda" | "csh" | "arc" | "php" | "mdx" | "ndjson" | "pyc" | "sh" | "tar" | "zip" | "xhtml" | "xml" | "yml" | "yaml" | "aac" | "mid" | "m4a" | "mp3" | "opus" | "ogg" | "oga" | "wav" | "midi" | "otf" | "woff" | "woff2" | "hjif" | "hmpg" | "ivs" | "ivt" | "aces" | "apng" | "avci" | "dpx" | "emf" | "jpg" | "ktx" | "ktx2" | "svg" | "tiff" | "tif" | "ico" | "glb" | "gltf" | "usdz" | "ics" | "css" | "csv" | "sse" | "ts" | "rs" | "py" | "txt" | "html" | "htm" | "cjs" | "mjs" | "md" | "vtt" | "3gp" | "3g2" | "mp4" | "m4v" | "mpeg" | "ogv" | "weba" | "avi" | undefined;
|
|
460
462
|
getMimes<const E extends FileExtension>(ext: E): readonly ["audio/aac"] | readonly ["application/x-abiword"] | readonly ["image/aces"] | readonly ["image/apng"] | readonly ["application/x-freearc"] | readonly ["image/avci"] | readonly ["image/avif"] | readonly ["video/x-msvideo"] | readonly ["application/vnd.amazon.ebook"] | readonly ["application/octet-stream", "multipart/voice-message"] | readonly ["image/bmp"] | readonly ["application/x-bzip"] | readonly ["application/x-bzip2"] | readonly ["application/x-cdf"] | readonly ["application/node", "text/javascript"] | readonly ["application/x-csh"] | readonly ["text/css"] | readonly ["text/csv"] | readonly ["application/msword"] | readonly ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"] | readonly ["image/dpx"] | readonly ["image/emf"] | readonly ["application/vnd.ms-fontobject"] | readonly ["application/epub+zip"] | readonly ["image/gif"] | readonly ["model/gltf-binary"] | readonly ["model/gltf+json"] | readonly ["application/gzip", "application/x-gzip"] | readonly ["haptics/hjif"] | readonly ["haptics/hmpg"] | readonly ["text/html"] | readonly ["image/vnd.microsoft.icon"] | readonly ["text/calendar"] | readonly ["haptics/ivs"] | readonly ["application/java-archive"] | readonly ["image/jpeg"] | readonly ["application/json"] | readonly ["application/ld+json"] | readonly ["image/ktx"] | readonly ["image/ktx2"] | readonly ["application/vnd.apple.mpegurl"] | readonly ["audio/mp4"] | readonly ["video/mp4"] | readonly ["text/markdown"] | readonly ["application/x-mdx"] | readonly ["audio/midi"] | readonly ["audio/x-midi"] | readonly ["text/javascript"] | readonly ["audio/mpeg"] | readonly ["video/mpeg"] | readonly ["application/vnd.apple.installer+xml"] | readonly ["application/x-ndjson"] | readonly ["model/obj", "application/octet-stream", "text/plain"] | readonly ["application/vnd.oasis.opendocument.presentation"] | readonly ["application/vnd.oasis.opendocument.spreadsheet"] | readonly ["application/vnd.oasis.opendocument.text"] | readonly ["audio/ogg"] | readonly ["video/ogg"] | readonly ["application/ogg"] | readonly ["font/otf"] | readonly ["image/png"] | readonly ["application/pdf"] | readonly ["application/x-httpd-php"] | readonly ["application/vnd.apple.pkpass"] | readonly ["application/vnd.ms-powerpoint"] | readonly ["application/vnd.openxmlformats-officedocument.presentationml.presentation"] | readonly ["text/x-python"] | readonly ["application/x-python-code"] | readonly ["application/vnd.rar"] | readonly ["text/rust"] | readonly ["application/rtf"] | readonly ["application/x-sh"] | readonly ["application/sql"] | readonly ["text/event-stream"] | readonly ["image/svg+xml"] | readonly ["application/x-tar"] | readonly ["image/tiff"] | readonly ["application/toml"] | readonly ["text/typescript", "video/mp2t", "video/vnd.dlna.mpeg-tts"] | readonly ["application/font-sfnt", "font/ttf"] | readonly ["text/plain"] | readonly ["model/vnd.usdz+zip"] | readonly ["application/vnd.visio"] | readonly ["text/vtt"] | readonly ["application/wasm"] | readonly ["audio/wav"] | readonly ["video/webm"] | readonly ["image/webp"] | readonly ["font/woff"] | readonly ["font/woff2"] | readonly ["application/xhtml+xml"] | readonly ["application/vnd.ms-excel"] | readonly ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] | readonly ["application/xml"] | readonly ["application/vnd.mozilla.xul+xml"] | readonly ["application/yaml"] | readonly ["application/zip", "application/x-zip-compressed"] | readonly ["video/3gpp"] | readonly ["video/3gpp2"] | readonly ["application/x-7z-compressed"];
|
|
461
463
|
getMimeFor<const E extends FileExtension>(ext: E, opts?: {
|
package/dist/mime/index.js
CHANGED
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
MimeService,
|
|
3
3
|
extMimeMap,
|
|
4
4
|
mimeToExt
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-CN45SMBB.js";
|
|
6
|
+
import "../chunk-QBG7TFHM.js";
|
|
7
|
+
import "../chunk-IUGBPDQJ.js";
|
|
7
8
|
import "../chunk-7QVYU63E.js";
|
|
8
9
|
export {
|
|
9
10
|
MimeService,
|
package/dist/types/index.d.cts
CHANGED
|
@@ -315,7 +315,15 @@ type SizeOpts = {
|
|
|
315
315
|
interface ImageSize {
|
|
316
316
|
width: number;
|
|
317
317
|
height: number;
|
|
318
|
-
|
|
318
|
+
format: 'png' | 'jpeg' | 'gif' | 'bmp' | 'webp' | 'avif' | 'unknown';
|
|
319
|
+
frames: number;
|
|
320
|
+
animated: boolean;
|
|
321
|
+
hasAlpha: boolean | null;
|
|
322
|
+
orientation: number | null;
|
|
323
|
+
aspectRatio: number;
|
|
324
|
+
colorSpace: 'rgb' | 'rgba' | 'grayscale' | 'grayscale-alpha' | 'indexed' | 'cmyk' | 'ycbcr' | 'ycck' | 'unknown';
|
|
325
|
+
iccProfile: string | null;
|
|
326
|
+
exifDateTimeOriginal: string | null;
|
|
319
327
|
}
|
|
320
328
|
interface BoxInfo {
|
|
321
329
|
pos: number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -315,7 +315,15 @@ type SizeOpts = {
|
|
|
315
315
|
interface ImageSize {
|
|
316
316
|
width: number;
|
|
317
317
|
height: number;
|
|
318
|
-
|
|
318
|
+
format: 'png' | 'jpeg' | 'gif' | 'bmp' | 'webp' | 'avif' | 'unknown';
|
|
319
|
+
frames: number;
|
|
320
|
+
animated: boolean;
|
|
321
|
+
hasAlpha: boolean | null;
|
|
322
|
+
orientation: number | null;
|
|
323
|
+
aspectRatio: number;
|
|
324
|
+
colorSpace: 'rgb' | 'rgba' | 'grayscale' | 'grayscale-alpha' | 'indexed' | 'cmyk' | 'ycbcr' | 'ycck' | 'unknown';
|
|
325
|
+
iccProfile: string | null;
|
|
326
|
+
exifDateTimeOriginal: string | null;
|
|
319
327
|
}
|
|
320
328
|
interface BoxInfo {
|
|
321
329
|
pos: number;
|
package/dist/types/index.js
CHANGED
package/dist/url/index.cjs
CHANGED
|
@@ -24,7 +24,137 @@ __export(url_exports, {
|
|
|
24
24
|
UrlService: () => UrlService
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(url_exports);
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
// src/utils/index.ts
|
|
29
|
+
var UtilsService = class {
|
|
30
|
+
static {
|
|
31
|
+
__name(this, "UtilsService");
|
|
32
|
+
}
|
|
33
|
+
chunkArray(arr, maxChunkLength) {
|
|
34
|
+
const chunks = Array.of();
|
|
35
|
+
let currentChunkLength = 0;
|
|
36
|
+
let currentChunk = Array.of();
|
|
37
|
+
for (const [index, val] of arr.entries()) {
|
|
38
|
+
if (val.length + currentChunkLength >= maxChunkLength) {
|
|
39
|
+
if (currentChunk.length) {
|
|
40
|
+
chunks.push(currentChunk);
|
|
41
|
+
}
|
|
42
|
+
currentChunkLength = val.length;
|
|
43
|
+
currentChunk = [val];
|
|
44
|
+
} else {
|
|
45
|
+
currentChunk.push(val);
|
|
46
|
+
currentChunkLength += val.length + 1;
|
|
47
|
+
}
|
|
48
|
+
if (arr.length === index + 1) {
|
|
49
|
+
chunks.push(currentChunk);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return chunks.length ? chunks : [arr];
|
|
53
|
+
}
|
|
54
|
+
b64ToBlob(b64Data) {
|
|
55
|
+
{
|
|
56
|
+
const sliceSize = 512;
|
|
57
|
+
const typeMatch = /^data:((?:image|application|haptics|video|text|font|model|audio|multipart)\/[A-Za-z0-9+-.]+(?:;[^,]+)*);base64,(.+)$/i.exec(
|
|
58
|
+
b64Data
|
|
59
|
+
);
|
|
60
|
+
if (!typeMatch) {
|
|
61
|
+
throw new Error(`${b64Data} is not a valid data Url`);
|
|
62
|
+
}
|
|
63
|
+
const type = typeMatch[1];
|
|
64
|
+
const base64Data = typeMatch?.[2] ?? "";
|
|
65
|
+
const byteCharacters = Buffer.from(base64Data, "base64").toString(
|
|
66
|
+
"binary"
|
|
67
|
+
);
|
|
68
|
+
const byteArrays = Array.of();
|
|
69
|
+
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
70
|
+
const slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
71
|
+
const byteNumbers = new Array(slice.length);
|
|
72
|
+
for (let i = 0; i < slice.length; i++) {
|
|
73
|
+
byteNumbers[i] = slice.charCodeAt(i);
|
|
74
|
+
}
|
|
75
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
76
|
+
byteArrays.push(byteArray);
|
|
77
|
+
}
|
|
78
|
+
const blob = new Blob(byteArrays, { type });
|
|
79
|
+
return blob;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
arrToArrOfArrs = /* @__PURE__ */ __name(({
|
|
83
|
+
arrToFragment = Array.of(),
|
|
84
|
+
arrOfArrsAggregator = Array.of(),
|
|
85
|
+
interval
|
|
86
|
+
}) => new Promise(
|
|
87
|
+
(resolve, _reject) => resolve(
|
|
88
|
+
((interval2) => {
|
|
89
|
+
for (let i = 0; i <= arrToFragment.length; i++) {
|
|
90
|
+
if ((i % interval2 === 0 || i === 0) && i <= arrToFragment.length) {
|
|
91
|
+
let segment = arrToFragment.slice(i, i + interval2);
|
|
92
|
+
arrOfArrsAggregator.push(segment);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})(interval)
|
|
96
|
+
)
|
|
97
|
+
).then((_) => arrOfArrsAggregator), "arrToArrOfArrs");
|
|
98
|
+
extractTuple(obj, props) {
|
|
99
|
+
return [props, obj[props]];
|
|
100
|
+
}
|
|
101
|
+
sort(obj, order) {
|
|
102
|
+
return Object.fromEntries(
|
|
103
|
+
Object.entries(obj).sort(
|
|
104
|
+
([a, _aa], [b, _bb]) => order === "DESC" ? b.localeCompare(a) - a.localeCompare(b) : a.localeCompare(b) - b.localeCompare(a)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
excludeTargeted = /* @__PURE__ */ __name((obj, props, sort) => {
|
|
109
|
+
const resolve = Object.fromEntries(
|
|
110
|
+
Object.entries(obj).map(([key, val]) => {
|
|
111
|
+
if (props.includes(key)) {
|
|
112
|
+
return ["omit", "omit"];
|
|
113
|
+
} else return [key, val];
|
|
114
|
+
}).filter(([t, _v]) => /omit/.test(t) === false)
|
|
115
|
+
);
|
|
116
|
+
return typeof sort !== "undefined" ? this.sort(resolve, sort) : resolve;
|
|
117
|
+
}, "excludeTargeted");
|
|
118
|
+
includeTargeted = /* @__PURE__ */ __name((obj, props, sort) => {
|
|
119
|
+
const resolve = Object.fromEntries(
|
|
120
|
+
props.map((val) => this.extractTuple(obj, val))
|
|
121
|
+
);
|
|
122
|
+
return typeof sort !== "undefined" ? this.sort(resolve, sort) : resolve;
|
|
123
|
+
}, "includeTargeted");
|
|
124
|
+
countsSorter = /* @__PURE__ */ __name((counter, keySort = "ASC", valSort = "DESC") => Object.fromEntries(
|
|
125
|
+
Array.from(Object.entries(counter)).sort(
|
|
126
|
+
([aStr, _aNum], [bStr, _bNum]) => keySort === "DESC" ? bStr.localeCompare(aStr) - aStr.localeCompare(bStr) : aStr.localeCompare(bStr) - bStr.localeCompare(aStr)
|
|
127
|
+
).sort(([aStr, aNum], [bStr, bNum]) => {
|
|
128
|
+
if (typeof (aNum && bNum) === "number") {
|
|
129
|
+
return valSort === "ASC" ? aNum - bNum : bNum - aNum;
|
|
130
|
+
} else if (typeof (aNum && bNum) === "string") {
|
|
131
|
+
return valSort === "ASC" ? aStr.localeCompare(bStr) - bStr.localeCompare(aStr) : bStr.localeCompare(aStr) - aStr.localeCompare(bStr);
|
|
132
|
+
} else
|
|
133
|
+
throw new Error(
|
|
134
|
+
"only Record<string, string> and Record<string,number> types supported"
|
|
135
|
+
);
|
|
136
|
+
})
|
|
137
|
+
), "countsSorter");
|
|
138
|
+
range(from, to) {
|
|
139
|
+
const values = Array.of();
|
|
140
|
+
for (let i = from; i < to; i++) {
|
|
141
|
+
values.push(i);
|
|
142
|
+
}
|
|
143
|
+
return values;
|
|
144
|
+
}
|
|
145
|
+
isPrimeNumber = /* @__PURE__ */ __name((n) => {
|
|
146
|
+
for (let i = 2; n > i; i++) {
|
|
147
|
+
if (n % i === 0) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return n > 1;
|
|
152
|
+
}, "isPrimeNumber");
|
|
153
|
+
acceptor = /* @__PURE__ */ __name((num) => [...Array(num !== 0 ? num : this.range(num = -101, num = 101)).keys()].reverse().filter(this.isPrimeNumber), "acceptor");
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// src/url/index.ts
|
|
157
|
+
var UrlService = class extends UtilsService {
|
|
28
158
|
static {
|
|
29
159
|
__name(this, "UrlService");
|
|
30
160
|
}
|
package/dist/url/index.d.cts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { UtilsService } from '../utils/index.cjs';
|
|
2
|
+
import '../types/index.cjs';
|
|
3
|
+
import 'stream';
|
|
4
|
+
import 'buffer';
|
|
5
|
+
|
|
1
6
|
type HandleQueryParamsOrHash<T> = T extends `${infer X}?${string}` ? X : T extends `${infer X}#${string}` ? X : T;
|
|
2
7
|
type SplitForwardSlash<S extends string> = S extends `${infer First}/${infer Rest}` ? [First, ...SplitForwardSlash<Rest>] : S extends "" ? [] : [S];
|
|
3
8
|
type LastSegment<T extends unknown[]> = T extends [...infer _, infer L] ? L : never;
|
|
@@ -12,7 +17,7 @@ type InferExtensionIfPresent<L> = L extends `${string}.${infer F}` ? F : "NO_EXT
|
|
|
12
17
|
* ```
|
|
13
18
|
*/
|
|
14
19
|
type UrlFileExt<S extends string> = InferExtensionIfPresent<LastSegment<SplitForwardSlash<HandleQueryParamsOrHash<S>>>>;
|
|
15
|
-
declare class UrlService {
|
|
20
|
+
declare class UrlService extends UtilsService {
|
|
16
21
|
private URL_REGEX;
|
|
17
22
|
parseUrl(url: string): {
|
|
18
23
|
href: string;
|
package/dist/url/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { UtilsService } from '../utils/index.js';
|
|
2
|
+
import '../types/index.js';
|
|
3
|
+
import 'stream';
|
|
4
|
+
import 'buffer';
|
|
5
|
+
|
|
1
6
|
type HandleQueryParamsOrHash<T> = T extends `${infer X}?${string}` ? X : T extends `${infer X}#${string}` ? X : T;
|
|
2
7
|
type SplitForwardSlash<S extends string> = S extends `${infer First}/${infer Rest}` ? [First, ...SplitForwardSlash<Rest>] : S extends "" ? [] : [S];
|
|
3
8
|
type LastSegment<T extends unknown[]> = T extends [...infer _, infer L] ? L : never;
|
|
@@ -12,7 +17,7 @@ type InferExtensionIfPresent<L> = L extends `${string}.${infer F}` ? F : "NO_EXT
|
|
|
12
17
|
* ```
|
|
13
18
|
*/
|
|
14
19
|
type UrlFileExt<S extends string> = InferExtensionIfPresent<LastSegment<SplitForwardSlash<HandleQueryParamsOrHash<S>>>>;
|
|
15
|
-
declare class UrlService {
|
|
20
|
+
declare class UrlService extends UtilsService {
|
|
16
21
|
private URL_REGEX;
|
|
17
22
|
parseUrl(url: string): {
|
|
18
23
|
href: string;
|
package/dist/url/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d0paminedriven/fs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "convenient fs helpers",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"typescript": "^5.9.2",
|
|
66
66
|
"typescript-eslint": "^8.40.0",
|
|
67
67
|
"@d0paminedriven/eslint-config": "0.1.0",
|
|
68
|
-
"@d0paminedriven/
|
|
69
|
-
"@d0paminedriven/
|
|
68
|
+
"@d0paminedriven/tsconfig": "0.1.0",
|
|
69
|
+
"@d0paminedriven/prettier-config": "0.1.0"
|
|
70
70
|
},
|
|
71
71
|
"prettier": "@d0paminedriven/prettier-config",
|
|
72
72
|
"scripts": {
|