@d0paminedriven/fs 6.1.0 → 6.3.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.
@@ -0,0 +1,307 @@
1
+ import {
2
+ UrlService
3
+ } from "./chunk-XHN56MDK.js";
4
+ import {
5
+ __name
6
+ } from "./chunk-7QVYU63E.js";
7
+
8
+ // src/mime/index.ts
9
+ var extMimeMap = {
10
+ aac: ["audio/aac"],
11
+ abw: ["application/x-abiword"],
12
+ aces: ["image/aces"],
13
+ apng: ["image/apng"],
14
+ arc: ["application/x-freearc"],
15
+ avci: ["image/avci"],
16
+ avif: ["image/avif"],
17
+ avi: ["video/x-msvideo"],
18
+ azw: ["application/vnd.amazon.ebook"],
19
+ bin: ["application/octet-stream", "multipart/voice-message"],
20
+ bmp: ["image/bmp"],
21
+ bz: ["application/x-bzip"],
22
+ bz2: ["application/x-bzip2"],
23
+ cda: ["application/x-cdf"],
24
+ cjs: ["application/node", "text/javascript"],
25
+ csh: ["application/x-csh"],
26
+ css: ["text/css"],
27
+ csv: ["text/csv"],
28
+ doc: ["application/msword"],
29
+ docx: [
30
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
31
+ ],
32
+ dpx: ["image/dpx"],
33
+ emf: ["image/emf"],
34
+ eot: ["application/vnd.ms-fontobject"],
35
+ epub: ["application/epub+zip"],
36
+ gif: ["image/gif"],
37
+ glb: ["model/gltf-binary"],
38
+ gltf: ["model/gltf+json"],
39
+ gz: ["application/gzip", "application/x-gzip"],
40
+ hjif: ["haptics/hjif"],
41
+ hmpg: ["haptics/hmpg"],
42
+ htm: ["text/html"],
43
+ html: ["text/html"],
44
+ ico: ["image/vnd.microsoft.icon"],
45
+ ics: ["text/calendar"],
46
+ ivs: ["haptics/ivs"],
47
+ ivt: ["haptics/ivs"],
48
+ jar: ["application/java-archive"],
49
+ jpeg: ["image/jpeg"],
50
+ jpg: ["image/jpeg"],
51
+ js: ["application/node", "text/javascript"],
52
+ json: ["application/json"],
53
+ jsonld: ["application/ld+json"],
54
+ ktx: ["image/ktx"],
55
+ ktx2: ["image/ktx2"],
56
+ m3u8: ["application/vnd.apple.mpegurl"],
57
+ m4a: ["audio/mp4"],
58
+ m4v: ["video/mp4"],
59
+ md: ["text/markdown"],
60
+ mdx: ["application/x-mdx"],
61
+ mid: ["audio/midi"],
62
+ midi: ["audio/x-midi"],
63
+ mjs: ["text/javascript"],
64
+ mp3: ["audio/mpeg"],
65
+ mp4: ["video/mp4"],
66
+ mpeg: ["video/mpeg"],
67
+ mpkg: ["application/vnd.apple.installer+xml"],
68
+ ndjson: ["application/x-ndjson"],
69
+ node: ["application/node", "text/javascript"],
70
+ obj: ["model/obj", "application/octet-stream", "text/plain"],
71
+ odp: ["application/vnd.oasis.opendocument.presentation"],
72
+ ods: ["application/vnd.oasis.opendocument.spreadsheet"],
73
+ odt: ["application/vnd.oasis.opendocument.text"],
74
+ oga: ["audio/ogg"],
75
+ ogg: ["audio/ogg"],
76
+ ogv: ["video/ogg"],
77
+ ogx: ["application/ogg"],
78
+ opus: ["audio/ogg"],
79
+ otf: ["font/otf"],
80
+ png: ["image/png"],
81
+ pdf: ["application/pdf"],
82
+ php: ["application/x-httpd-php"],
83
+ pkpass: ["application/vnd.apple.pkpass"],
84
+ ppt: ["application/vnd.ms-powerpoint"],
85
+ pptx: [
86
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation"
87
+ ],
88
+ py: ["text/x-python"],
89
+ pyc: ["application/x-python-code"],
90
+ rar: ["application/vnd.rar"],
91
+ rs: ["text/rust"],
92
+ rtf: ["application/rtf"],
93
+ sh: ["application/x-sh"],
94
+ sql: ["application/sql"],
95
+ sse: ["text/event-stream"],
96
+ svg: ["image/svg+xml"],
97
+ tar: ["application/x-tar"],
98
+ tif: ["image/tiff"],
99
+ tiff: ["image/tiff"],
100
+ toml: ["application/toml"],
101
+ ts: ["text/typescript", "video/mp2t", "video/vnd.dlna.mpeg-tts"],
102
+ ttf: ["application/font-sfnt", "font/ttf"],
103
+ txt: ["text/plain"],
104
+ usdz: ["model/vnd.usdz+zip"],
105
+ vsd: ["application/vnd.visio"],
106
+ vtt: ["text/vtt"],
107
+ wasm: ["application/wasm"],
108
+ wav: ["audio/wav"],
109
+ weba: ["video/webm"],
110
+ webp: ["image/webp"],
111
+ woff: ["font/woff"],
112
+ woff2: ["font/woff2"],
113
+ xhtml: ["application/xhtml+xml"],
114
+ xls: ["application/vnd.ms-excel"],
115
+ xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
116
+ xml: ["application/xml"],
117
+ xul: ["application/vnd.mozilla.xul+xml"],
118
+ yaml: ["application/yaml"],
119
+ yml: ["application/yaml"],
120
+ zip: ["application/zip", "application/x-zip-compressed"],
121
+ "3gp": ["video/3gpp"],
122
+ "3g2": ["video/3gpp2"],
123
+ "7z": ["application/x-7z-compressed"]
124
+ };
125
+ var mimeToExt = {
126
+ "application/epub+zip": ["epub"],
127
+ "application/font-sfnt": ["ttf"],
128
+ "application/gzip": ["gz"],
129
+ "application/java-archive": ["jar"],
130
+ "application/json": ["json"],
131
+ "application/ld+json": ["jsonld"],
132
+ "application/msword": ["doc"],
133
+ "application/node": ["node", "js"],
134
+ "application/octet-stream": ["bin", "obj"],
135
+ "application/ogg": ["ogx"],
136
+ "application/pdf": ["pdf"],
137
+ "application/rtf": ["rtf"],
138
+ "application/sql": ["sql"],
139
+ "application/toml": ["toml"],
140
+ "application/vnd.amazon.ebook": ["azw"],
141
+ "application/vnd.apple.installer+xml": ["mpkg"],
142
+ "application/vnd.apple.mpegurl": ["m3u8"],
143
+ "application/vnd.apple.pkpass": ["pkpass"],
144
+ "application/vnd.mozilla.xul+xml": ["xul"],
145
+ "application/vnd.ms-excel": ["xls"],
146
+ "application/vnd.ms-fontobject": ["eot"],
147
+ "application/vnd.ms-powerpoint": ["ppt"],
148
+ "application/vnd.oasis.opendocument.presentation": ["odp"],
149
+ "application/vnd.oasis.opendocument.spreadsheet": ["ods"],
150
+ "application/vnd.oasis.opendocument.text": ["odt"],
151
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": [
152
+ "pptx"
153
+ ],
154
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ["xlsx"],
155
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [
156
+ "docx"
157
+ ],
158
+ "application/vnd.rar": ["rar"],
159
+ "application/vnd.visio": ["vsd"],
160
+ "application/wasm": ["wasm"],
161
+ "application/x-7z-compressed": ["7z"],
162
+ "application/x-abiword": ["abw"],
163
+ "application/x-bzip": ["bz"],
164
+ "application/x-bzip2": ["bz2"],
165
+ "application/x-cdf": ["cda"],
166
+ "application/x-csh": ["csh"],
167
+ "application/x-freearc": ["arc"],
168
+ "application/x-gzip": ["gz"],
169
+ "application/x-httpd-php": ["php"],
170
+ "application/x-mdx": ["mdx"],
171
+ "application/x-ndjson": ["ndjson"],
172
+ "application/x-python-code": ["pyc"],
173
+ "application/x-sh": ["sh"],
174
+ "application/x-tar": ["tar"],
175
+ "application/x-zip-compressed": ["zip"],
176
+ "application/xhtml+xml": ["xhtml"],
177
+ "application/xml": ["xml"],
178
+ "application/yaml": ["yml", "yaml"],
179
+ "application/zip": ["zip"],
180
+ "audio/aac": ["aac"],
181
+ "audio/midi": ["mid"],
182
+ "audio/mp4": ["m4a"],
183
+ "audio/mpeg": ["mp3"],
184
+ "audio/ogg": ["opus", "ogg", "oga"],
185
+ "audio/wav": ["wav"],
186
+ "audio/x-midi": ["midi"],
187
+ "font/otf": ["otf"],
188
+ "font/ttf": ["ttf"],
189
+ "font/woff": ["woff"],
190
+ "font/woff2": ["woff2"],
191
+ "haptics/hjif": ["hjif"],
192
+ "haptics/hmpg": ["hmpg"],
193
+ "haptics/ivs": ["ivs", "ivt"],
194
+ "image/aces": ["aces"],
195
+ "image/apng": ["apng"],
196
+ "image/avci": ["avci"],
197
+ "image/avif": ["avif"],
198
+ "image/bmp": ["bmp"],
199
+ "image/dpx": ["dpx"],
200
+ "image/emf": ["emf"],
201
+ "image/gif": ["gif"],
202
+ "image/jpeg": ["jpg", "jpeg"],
203
+ "image/ktx": ["ktx"],
204
+ "image/ktx2": ["ktx2"],
205
+ "image/png": ["png"],
206
+ "image/svg+xml": ["svg"],
207
+ "image/tiff": ["tiff", "tif"],
208
+ "image/vnd.microsoft.icon": ["ico"],
209
+ "image/webp": ["webp"],
210
+ "model/gltf-binary": ["glb"],
211
+ "model/gltf+json": ["gltf"],
212
+ "model/obj": ["obj"],
213
+ "model/vnd.usdz+zip": ["usdz"],
214
+ "multipart/voice-message": ["bin"],
215
+ "text/calendar": ["ics"],
216
+ "text/css": ["css"],
217
+ "text/csv": ["csv"],
218
+ "text/event-stream": ["sse", "ts", "rs", "py", "txt"],
219
+ "text/html": ["html", "htm"],
220
+ "text/javascript": ["cjs", "js", "mjs"],
221
+ "text/markdown": ["md"],
222
+ "text/plain": ["txt"],
223
+ "text/rust": ["rs"],
224
+ "text/typescript": ["ts"],
225
+ "text/vtt": ["vtt"],
226
+ "text/x-python": ["py"],
227
+ "video/3gpp": ["3gp"],
228
+ "video/3gpp2": ["3g2"],
229
+ "video/mp2t": ["ts"],
230
+ "video/mp4": ["mp4", "m4v"],
231
+ "video/mpeg": ["mpeg"],
232
+ "video/ogg": ["ogv"],
233
+ "video/vnd.dlna.mpeg-tts": ["ts"],
234
+ "video/webm": ["weba"],
235
+ "video/x-msvideo": ["avi"]
236
+ };
237
+ var MimeService = class extends UrlService {
238
+ static {
239
+ __name(this, "MimeService");
240
+ }
241
+ constructor() {
242
+ super();
243
+ }
244
+ mimeTypeObj = extMimeMap;
245
+ toExtObj = mimeToExt;
246
+ compareMimeToExt(p = "mime") {
247
+ let a = {};
248
+ if (p === "mime") {
249
+ for (const [_key, vals] of Object.entries(extMimeMap)) {
250
+ for (const val of vals) {
251
+ a[val] = (a[val] ?? 0) + 1;
252
+ }
253
+ }
254
+ for (const [key, _val] of Object.entries(mimeToExt)) {
255
+ a[key] = (a[key] ?? 0) + 1;
256
+ }
257
+ return Object.fromEntries(
258
+ Object.entries(a).sort(([_a, aa], [_b, bb]) => bb - aa)
259
+ );
260
+ } else {
261
+ for (const [_key, vals] of Object.entries(mimeToExt)) {
262
+ for (const val of vals) {
263
+ a[val] = (a[val] ?? 0) + 1;
264
+ }
265
+ }
266
+ for (const [key, _val] of Object.entries(extMimeMap)) {
267
+ a[key] = (a[key] ?? 0) + 1;
268
+ }
269
+ return Object.fromEntries(
270
+ Object.entries(a).sort(([_a, aa], [_b, bb]) => bb - aa)
271
+ );
272
+ }
273
+ }
274
+ assetType(url) {
275
+ const parsed = this.parseUrl(url);
276
+ if (!parsed) return void 0;
277
+ const ext = parsed.pathname.split(/([.])/g)?.reverse()?.[0]?.toLowerCase();
278
+ return ext && ext in this.mimeTypeObj ? ext : void 0;
279
+ }
280
+ getMimes(ext) {
281
+ return this.mimeTypeObj[ext];
282
+ }
283
+ getMimeFor(ext, opts) {
284
+ const mimes = this.getMimes(ext);
285
+ if (mimes.length === 1) return mimes[0];
286
+ if (opts?.type) {
287
+ const found = mimes.find((mime) => mime.startsWith(opts.type + "/"));
288
+ return found ?? mimes[0];
289
+ }
290
+ return mimes[0];
291
+ }
292
+ isMimeFor(ext, mime) {
293
+ return this.getMimes(ext).find((s) => s === mime);
294
+ }
295
+ getMimeTypeForPath(path, opts) {
296
+ const ext = this.assetType(path);
297
+ if (!ext) return "application/octet-stream";
298
+ return this.getMimeFor(ext, opts);
299
+ }
300
+ };
301
+
302
+ export {
303
+ extMimeMap,
304
+ mimeToExt,
305
+ MimeService
306
+ };
307
+ //# sourceMappingURL=chunk-C6AZRX7V.js.map
@@ -31,19 +31,21 @@ var UtilsService = class {
31
31
  b64ToBlob(b64Data) {
32
32
  {
33
33
  const sliceSize = 512;
34
- const typeMatch = b64Data.match(
35
- /^data:(?:image|application|haptics|video|text|font|model|audio|multipart)\/[A-Za-z0-9+-.]+(?:;[^,]+)*;base64,/i
34
+ const typeMatch = /^data:((?:image|application|haptics|video|text|font|model|audio|multipart)\/[A-Za-z0-9+-.]+(?:;[^,]+)*);base64,(.+)$/i.exec(
35
+ b64Data
36
36
  );
37
- const type = typeMatch?.[1];
38
37
  if (!typeMatch) {
39
38
  throw new Error(`${b64Data} is not a valid data Url`);
40
39
  }
41
- const byteCharacters = Buffer.from(b64Data, "base64").toString("utf-8");
40
+ const type = typeMatch[1];
41
+ const base64Data = typeMatch?.[2] ?? "";
42
+ const byteCharacters = Buffer.from(base64Data, "base64").toString(
43
+ "binary"
44
+ );
42
45
  const byteArrays = Array.of();
43
46
  for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
44
47
  const slice = byteCharacters.slice(offset, offset + sliceSize);
45
- const byteNumbers = Array.of();
46
- byteNumbers.push(slice.length);
48
+ const byteNumbers = new Array(slice.length);
47
49
  for (let i = 0; i < slice.length; i++) {
48
50
  byteNumbers[i] = slice.charCodeAt(i);
49
51
  }
@@ -96,16 +98,19 @@ var UtilsService = class {
96
98
  );
97
99
  return typeof sort !== "undefined" ? this.sort(resolve, sort) : resolve;
98
100
  }, "includeTargeted");
99
- countsSorter = /* @__PURE__ */ __name(({
100
- counter,
101
- keySort,
102
- valSort
103
- }) => Object.fromEntries(
104
- Object.entries(counter).sort(
101
+ countsSorter = /* @__PURE__ */ __name((counter, keySort = "ASC", valSort = "DESC") => Object.fromEntries(
102
+ Array.from(Object.entries(counter)).sort(
105
103
  ([aStr, _aNum], [bStr, _bNum]) => keySort === "DESC" ? bStr.localeCompare(aStr) - aStr.localeCompare(bStr) : aStr.localeCompare(bStr) - bStr.localeCompare(aStr)
106
- ).sort(
107
- ([_aStr, aNum], [_bStr, bNum]) => valSort === "ASC" ? aNum - bNum : bNum - aNum
108
- )
104
+ ).sort(([aStr, aNum], [bStr, bNum]) => {
105
+ if (typeof (aNum && bNum) === "number") {
106
+ return valSort === "ASC" ? aNum - bNum : bNum - aNum;
107
+ } else if (typeof (aNum && bNum) === "string") {
108
+ return valSort === "ASC" ? aStr.localeCompare(bStr) - bStr.localeCompare(aStr) : bStr.localeCompare(aStr) - aStr.localeCompare(bStr);
109
+ } else
110
+ throw new Error(
111
+ "only Record<string, string> and Record<string,number> types supported"
112
+ );
113
+ })
109
114
  ), "countsSorter");
110
115
  range(from, to) {
111
116
  const values = Array.of();
@@ -128,4 +133,4 @@ var UtilsService = class {
128
133
  export {
129
134
  UtilsService
130
135
  };
131
- //# sourceMappingURL=chunk-QMN5ZCE4.js.map
136
+ //# sourceMappingURL=chunk-IUGBPDQJ.js.map
@@ -11,4 +11,4 @@ var unitsObj = {
11
11
  export {
12
12
  unitsObj
13
13
  };
14
- //# sourceMappingURL=chunk-4X5DVWVM.js.map
14
+ //# sourceMappingURL=chunk-MXEE2WS7.js.map