@d0paminedriven/fs 10.1.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/docs/index.d.ts +151 -0
  2. package/dist/docs/index.js +1163 -0
  3. package/dist/extract/client.d.ts +56 -0
  4. package/dist/extract/client.js +116 -0
  5. package/dist/extract/index.d.ts +66 -0
  6. package/dist/extract/index.js +620 -0
  7. package/dist/fs/index.d.ts +18 -58
  8. package/dist/fs/index.js +89 -19
  9. package/dist/fs-atomic/index.d.ts +25 -39
  10. package/dist/fs-atomic/index.js +94 -13
  11. package/dist/fs-base/index.d.ts +105 -113
  12. package/dist/fs-base/index.js +197 -12
  13. package/dist/fs-core/index.d.ts +18 -26
  14. package/dist/fs-core/index.js +43 -16
  15. package/dist/fs-fetch/index.d.ts +48 -65
  16. package/dist/fs-fetch/index.js +183 -18
  17. package/dist/fs-size/index.d.ts +15 -31
  18. package/dist/fs-size/index.js +63 -15
  19. package/dist/fs-tmp/index.d.ts +178 -195
  20. package/dist/fs-tmp/index.js +320 -17
  21. package/dist/images/index.d.ts +443 -0
  22. package/dist/images/index.js +893 -0
  23. package/dist/images/workup.d.ts +26 -0
  24. package/dist/images/workup.js +316 -0
  25. package/dist/index.d.ts +48 -22
  26. package/dist/index.js +19 -64
  27. package/dist/ld/index.d.ts +14 -16
  28. package/dist/ld/index.js +54 -6
  29. package/dist/mime/index.d.ts +301 -296
  30. package/dist/mime/index.js +348 -13
  31. package/dist/mixins/index.d.ts +30 -0
  32. package/dist/mixins/index.js +54 -0
  33. package/dist/types/index.d.ts +339 -260
  34. package/dist/types/index.js +10 -6
  35. package/dist/types/stream.d.ts +7 -9
  36. package/dist/types/stream.js +1 -1
  37. package/dist/url/index.d.ts +18 -25
  38. package/dist/url/index.js +19 -8
  39. package/dist/utils/index.d.ts +18 -26
  40. package/dist/utils/index.js +80 -7
  41. package/package.json +42 -22
  42. package/dist/chunk-4D2YBCI6.js +0 -163
  43. package/dist/chunk-5CACVZVF.js +0 -386
  44. package/dist/chunk-5H6GE5AO.js +0 -14
  45. package/dist/chunk-7QVYU63E.js +0 -7
  46. package/dist/chunk-DNR5ZI2T.js +0 -75
  47. package/dist/chunk-JZ6JNZZ6.js +0 -77
  48. package/dist/chunk-L2QMQOEJ.js +0 -366
  49. package/dist/chunk-NJHN5OE3.js +0 -33
  50. package/dist/chunk-OHKRQJZH.js +0 -82
  51. package/dist/chunk-OT5JEQKW.js +0 -139
  52. package/dist/chunk-PATMSIQK.js +0 -367
  53. package/dist/chunk-PB5A7ZFD.js +0 -79
  54. package/dist/chunk-VDKUXJE7.js +0 -240
  55. package/dist/chunk-Y5QWE4EG.js +0 -1335
  56. package/dist/chunk-YRCJWFZD.js +0 -107
  57. package/dist/image/index.d.ts +0 -182
  58. package/dist/image/index.js +0 -13
  59. package/dist/image/workup.d.ts +0 -40
  60. package/dist/image/workup.js +0 -12
@@ -0,0 +1,26 @@
1
+ import { Readable } from "node:stream";
2
+ import { BoxInfo, ImageSpecs } from "../types/index.js";
3
+ export declare class ImgMetadataExtractorWorkup {
4
+ protected readBytes(stream: Readable, bytes: number): Promise<Buffer<ArrayBufferLike>>;
5
+ parseExif(buffer: Buffer, app1Pos: number, app1Size: number): {
6
+ orientation: number | null;
7
+ dateTimeOriginal: string | null;
8
+ };
9
+ parseXmpFromAvif(buffer: Buffer, meta: BoxInfo, _ipco: BoxInfo): string | null;
10
+ readVarSize(buffer: Buffer, pos: number, size: number): number;
11
+ findBox(buffer: Buffer, type: string, start?: number, end?: number): BoxInfo | null;
12
+ mapChrmToColorSpace(chrm: {
13
+ white_x: number;
14
+ white_y: number;
15
+ red_x: number;
16
+ red_y: number;
17
+ green_x: number;
18
+ green_y: number;
19
+ blue_x: number;
20
+ blue_y: number;
21
+ }, fallback: ImageSpecs["colorSpace"]): "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
22
+ xmpToColorSpaceWorkup<const T extends ImageSpecs["colorSpace"] | "prophoto rgb" | "display p3" | "adobe rgb (1998)" | "rgb" | "grayscale", const V extends "iccprofile" | "colormode">(space: T, target: V): `<photoshop:${V}>${T}</photoshop:${V}>`;
23
+ mapXmpToColorSpace(xmpText: string, fallback: ImageSpecs["colorSpace"]): "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
24
+ mapProfileToColorSpace(profileName: string | null, fallback: ImageSpecs["colorSpace"]): "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
25
+ }
26
+ //# sourceMappingURL=workup.d.ts.map
@@ -0,0 +1,316 @@
1
+ // src/images/workup.ts
2
+ var ImgMetadataExtractorWorkup = class {
3
+ async readBytes(stream, bytes) {
4
+ return new Promise((resolve, reject) => {
5
+ const chunks = Array.of();
6
+ let totalBytes = 0;
7
+ const cleanup = () => {
8
+ stream.removeAllListeners();
9
+ stream.destroy();
10
+ };
11
+ stream.on("error", (err) => {
12
+ cleanup();
13
+ reject(err);
14
+ });
15
+ stream.on("data", (chunk) => {
16
+ const remaining = bytes - totalBytes;
17
+ if (chunk.length <= remaining) {
18
+ chunks.push(chunk);
19
+ totalBytes += chunk.length;
20
+ } else {
21
+ chunks.push(chunk.subarray(0, remaining));
22
+ totalBytes = bytes;
23
+ }
24
+ if (totalBytes >= bytes) {
25
+ cleanup();
26
+ resolve(Buffer.concat(chunks));
27
+ }
28
+ });
29
+ stream.on("end", () => {
30
+ cleanup();
31
+ resolve(Buffer.concat(chunks));
32
+ });
33
+ });
34
+ }
35
+ parseExif(buffer, app1Pos, app1Size) {
36
+ const segmentStart = app1Pos + 4;
37
+ const segmentEnd = app1Pos + 2 + app1Size;
38
+ if (segmentEnd - segmentStart < 16 || segmentEnd > buffer.length) return {
39
+ orientation: null,
40
+ dateTimeOriginal: null
41
+ };
42
+ const headerEnd = Math.min(segmentStart + 6, segmentEnd, buffer.length);
43
+ if (headerEnd - segmentStart < 6) return {
44
+ orientation: null,
45
+ dateTimeOriginal: null
46
+ };
47
+ if (buffer.toString("ascii", segmentStart, headerEnd) !== "Exif\0\0") return {
48
+ orientation: null,
49
+ dateTimeOriginal: null
50
+ };
51
+ const tiffStart = segmentStart + 6;
52
+ const tiffEnd = segmentEnd;
53
+ if (tiffEnd - tiffStart < 8) return {
54
+ orientation: null,
55
+ dateTimeOriginal: null
56
+ };
57
+ const byteOrder = buffer.toString("ascii", tiffStart, tiffStart + 2);
58
+ const littleEndian = byteOrder === "II";
59
+ if (!littleEndian && !(byteOrder === "MM")) return {
60
+ orientation: null,
61
+ dateTimeOriginal: null
62
+ };
63
+ const readUInt16 = (pos) => {
64
+ if (pos < 0 || pos + 2 > tiffEnd || pos + 2 > buffer.length) return null;
65
+ return littleEndian ? buffer.readUInt16LE(pos) : buffer.readUInt16BE(pos);
66
+ };
67
+ const readUInt32 = (pos) => {
68
+ if (pos < 0 || pos + 4 > tiffEnd || pos + 4 > buffer.length) return null;
69
+ return littleEndian ? buffer.readUInt32LE(pos) : buffer.readUInt32BE(pos);
70
+ };
71
+ if (readUInt16(tiffStart + 2) !== 42) return {
72
+ orientation: null,
73
+ dateTimeOriginal: null
74
+ };
75
+ const ifd0Offset = readUInt32(tiffStart + 4);
76
+ if (ifd0Offset === null || ifd0Offset < 8) return {
77
+ orientation: null,
78
+ dateTimeOriginal: null
79
+ };
80
+ const ifd0Pos = tiffStart + ifd0Offset;
81
+ if (ifd0Pos + 2 > tiffEnd) return {
82
+ orientation: null,
83
+ dateTimeOriginal: null
84
+ };
85
+ const numEntries = readUInt16(ifd0Pos);
86
+ if (numEntries === null || numEntries === 0 || numEntries > 500) return {
87
+ orientation: null,
88
+ dateTimeOriginal: null
89
+ };
90
+ let orientation = null;
91
+ let dateTimeOriginal = null;
92
+ const ifdDataStart = ifd0Pos + 2;
93
+ if (ifdDataStart + numEntries * 12 > tiffEnd) {
94
+ const maxEntries = Math.floor((tiffEnd - ifdDataStart) / 12);
95
+ if (maxEntries <= 0) return {
96
+ orientation,
97
+ dateTimeOriginal
98
+ };
99
+ for (let i = 0; i < maxEntries; i++) {
100
+ const entryPos = ifdDataStart + i * 12;
101
+ const tag = readUInt16(entryPos);
102
+ const type = readUInt16(entryPos + 2);
103
+ const count = readUInt32(entryPos + 4);
104
+ if (tag === null || type === null || count === null) continue;
105
+ if (tag === 274 && type === 3 && count === 1) {
106
+ orientation = readUInt16(entryPos + 8);
107
+ if (orientation && (orientation < 1 || orientation > 8)) orientation = null;
108
+ }
109
+ if (tag === 36867 && type === 2 && count === 20) {
110
+ const offset = readUInt32(entryPos + 8);
111
+ if (offset !== null) {
112
+ const stringPos = tiffStart + offset;
113
+ const stringEnd = stringPos + 19;
114
+ if (stringEnd <= tiffEnd && stringEnd <= buffer.length) try {
115
+ dateTimeOriginal = buffer.toString("ascii", stringPos, stringEnd);
116
+ if (!/^\d{4}:\d{2}:\d{2} \d{2}:\d{2}:\d{2}/.test(dateTimeOriginal)) dateTimeOriginal = null;
117
+ } catch {
118
+ dateTimeOriginal = null;
119
+ }
120
+ }
121
+ }
122
+ }
123
+ } else for (let i = 0; i < numEntries; i++) {
124
+ const entryPos = ifdDataStart + i * 12;
125
+ const tag = readUInt16(entryPos);
126
+ const type = readUInt16(entryPos + 2);
127
+ const count = readUInt32(entryPos + 4);
128
+ if (tag === null || type === null || count === null) continue;
129
+ if (tag === 274 && type === 3 && count === 1) {
130
+ orientation = readUInt16(entryPos + 8);
131
+ if (orientation && (orientation < 1 || orientation > 8)) orientation = null;
132
+ } else if (tag === 36867 && type === 2 && count === 20) {
133
+ const offset = readUInt32(entryPos + 8);
134
+ if (offset !== null) {
135
+ const stringPos = tiffStart + offset;
136
+ const stringEnd = stringPos + 19;
137
+ if (stringEnd <= tiffEnd && stringEnd <= buffer.length) try {
138
+ const extracted = buffer.toString("ascii", stringPos, stringEnd);
139
+ if (/^\d{4}:\d{2}:\d{2} \d{2}:\d{2}:\d{2}/.test(extracted)) dateTimeOriginal = extracted;
140
+ } catch {
141
+ console.warn("invalid ascii data");
142
+ }
143
+ }
144
+ }
145
+ }
146
+ return {
147
+ orientation,
148
+ dateTimeOriginal
149
+ };
150
+ }
151
+ parseXmpFromAvif(buffer, meta, _ipco) {
152
+ const iinf = this.findBox(buffer, "iinf", meta.pos + 4, meta.pos + meta.size);
153
+ if (!iinf) return null;
154
+ let pos = iinf.pos;
155
+ const version = buffer[pos++];
156
+ const itemCount = version === 0 ? buffer.readUInt16BE(pos) : buffer.readUInt32BE(pos);
157
+ pos += version === 0 ? 2 : 4;
158
+ let xmpItemId;
159
+ for (let i = 0; i < itemCount; i++) {
160
+ const infeStart = pos;
161
+ const infeSize = buffer.readUInt32BE(pos);
162
+ if (buffer.toString("ascii", pos + 4, pos + 8) !== "infe") break;
163
+ pos += 8;
164
+ const infeVersion = buffer?.[pos++];
165
+ if (!infeVersion) return null;
166
+ const itemId = infeVersion < 2 ? buffer.readUInt16BE(pos) : buffer.readUInt32BE(pos);
167
+ pos += infeVersion < 2 ? 2 : 4;
168
+ pos += 2;
169
+ const itemType = buffer.toString("ascii", pos, pos + 4);
170
+ pos += 4;
171
+ let nameEnd = pos;
172
+ while (buffer[nameEnd] !== 0 && nameEnd < infeStart + infeSize) nameEnd++;
173
+ pos = nameEnd + 1;
174
+ if (itemType === "mime") {
175
+ let ctEnd = pos;
176
+ while (buffer[ctEnd] !== 0 && ctEnd < infeStart + infeSize) ctEnd++;
177
+ if (buffer.toString("ascii", pos, ctEnd) === "application/rdf+xml") {
178
+ xmpItemId = itemId;
179
+ break;
180
+ }
181
+ pos = ctEnd + 1;
182
+ }
183
+ pos = infeStart + infeSize;
184
+ }
185
+ if (!xmpItemId) return null;
186
+ const iloc = this.findBox(buffer, "iloc", meta.pos + 4, meta.pos + meta.size);
187
+ if (!iloc) return null;
188
+ pos = iloc.pos;
189
+ const ilocVersion = buffer[pos++];
190
+ const sizes = buffer?.[pos++];
191
+ if (!sizes) return null;
192
+ const offsetSize = sizes >> 4 & 15;
193
+ const lengthSize = sizes & 15;
194
+ let indexSize = 0;
195
+ if (ilocVersion === 1 || ilocVersion === 2) {
196
+ const indexSizes = buffer?.[pos++];
197
+ if (!indexSizes) return null;
198
+ indexSize = indexSizes >> 4 & 15;
199
+ }
200
+ if (!ilocVersion) return null;
201
+ const buffpos = buffer?.[pos++];
202
+ if (!buffpos) return null;
203
+ const baseOffsetSize = ilocVersion < 2 ? 0 : buffpos >> 4 & 15;
204
+ const itemCountIloc = ilocVersion < 2 ? buffer.readUInt16BE(pos) : buffer.readUInt32BE(pos);
205
+ pos += ilocVersion < 2 ? 2 : 4;
206
+ let xmpOffset = 0;
207
+ let xmpLength = 0;
208
+ for (let i = 0; i < itemCountIloc; i++) {
209
+ const curItemId = ilocVersion < 2 ? buffer.readUInt16BE(pos) : buffer.readUInt32BE(pos);
210
+ pos += ilocVersion < 2 ? 2 : 4;
211
+ if (curItemId !== xmpItemId) {
212
+ if (ilocVersion === 1 || ilocVersion === 2) pos += 2;
213
+ pos += 2;
214
+ pos += baseOffsetSize;
215
+ const extentCount = buffer.readUInt16BE(pos);
216
+ pos += 2;
217
+ for (let e = 0; e < extentCount; e++) {
218
+ if (indexSize > 0) pos += indexSize;
219
+ pos += offsetSize + lengthSize;
220
+ }
221
+ continue;
222
+ }
223
+ if (ilocVersion === 1 || ilocVersion === 2) {
224
+ const constructionMethod = buffer.readUInt16BE(pos);
225
+ pos += 2;
226
+ if (constructionMethod !== 0) return null;
227
+ }
228
+ pos += 2;
229
+ const baseOffset = this.readVarSize(buffer, pos, baseOffsetSize);
230
+ pos += baseOffsetSize;
231
+ const extentCount = buffer.readUInt16BE(pos);
232
+ pos += 2;
233
+ if (extentCount !== 1) return null;
234
+ if (indexSize > 0) pos += indexSize;
235
+ const extentOffset = this.readVarSize(buffer, pos, offsetSize);
236
+ pos += offsetSize;
237
+ const extentLength = this.readVarSize(buffer, pos, lengthSize);
238
+ xmpOffset = baseOffset + extentOffset;
239
+ xmpLength = extentLength;
240
+ break;
241
+ }
242
+ if (xmpOffset === 0 || xmpLength === 0 || xmpOffset + xmpLength > buffer.length) return null;
243
+ return buffer.toString("utf8", xmpOffset, xmpOffset + xmpLength);
244
+ }
245
+ readVarSize(buffer, pos, size) {
246
+ if (size === 0) return 0;
247
+ if (size === 1 && buffer?.[pos]) return buffer?.[pos];
248
+ if (size === 2) return buffer.readUInt16BE(pos);
249
+ if (size === 3) {
250
+ const pos1 = buffer?.[pos + 1], pos2 = buffer?.[pos + 2];
251
+ if (buffer?.[pos] && pos1 && pos2) return buffer[pos] << 16 | pos1 << 8 | pos2;
252
+ throw new Error("Invalid var size");
253
+ }
254
+ if (size === 4) return buffer.readUInt32BE(pos);
255
+ if (size === 8) return Number(buffer.readBigUInt64BE(pos));
256
+ throw new Error("Invalid var size");
257
+ }
258
+ findBox(buffer, type, start = 0, end = buffer.length) {
259
+ let pos = start;
260
+ while (pos < end) {
261
+ let boxSize = buffer.readUInt32BE(pos);
262
+ const boxType = buffer.toString("ascii", pos + 4, pos + 8);
263
+ let hdrSize = 8;
264
+ if (boxSize === 1) {
265
+ boxSize = Number(buffer.readBigUInt64BE(pos + 8));
266
+ hdrSize = 16;
267
+ } else if (boxSize === 0) boxSize = end - pos;
268
+ if (boxType === type) return {
269
+ pos: pos + hdrSize,
270
+ size: boxSize - hdrSize
271
+ };
272
+ pos += boxSize;
273
+ }
274
+ return null;
275
+ }
276
+ mapChrmToColorSpace(chrm, fallback) {
277
+ const tol = 100;
278
+ if (Math.abs(chrm.white_x - 31270) < tol && Math.abs(chrm.white_y - 32900) < tol && Math.abs(chrm.red_x - 64e3) < tol && Math.abs(chrm.red_y - 33e3) < tol && Math.abs(chrm.green_x - 3e4) < tol && Math.abs(chrm.green_y - 6e4) < tol && Math.abs(chrm.blue_x - 15e3) < tol && Math.abs(chrm.blue_y - 6e3) < tol) return "srgb";
279
+ if (Math.abs(chrm.white_x - 31270) < tol && Math.abs(chrm.white_y - 32900) < tol && Math.abs(chrm.red_x - 64e3) < tol && Math.abs(chrm.red_y - 33e3) < tol && Math.abs(chrm.green_x - 21e3) < tol && Math.abs(chrm.green_y - 71e3) < tol && Math.abs(chrm.blue_x - 15e3) < tol && Math.abs(chrm.blue_y - 6e3) < tol) return "adobe_rgb";
280
+ if (Math.abs(chrm.white_x - 31270) < tol && Math.abs(chrm.white_y - 32900) < tol && Math.abs(chrm.red_x - 68e3) < tol && Math.abs(chrm.red_y - 32e3) < tol && Math.abs(chrm.green_x - 26500) < tol && Math.abs(chrm.green_y - 69e3) < tol && Math.abs(chrm.blue_x - 15e3) < tol && Math.abs(chrm.blue_y - 6e3) < tol) return "display_p3";
281
+ if (Math.abs(chrm.white_x - 34590) < tol && Math.abs(chrm.white_y - 35850) < tol && Math.abs(chrm.red_x - 73470) < tol && Math.abs(chrm.red_y - 26530) < tol && Math.abs(chrm.green_x - 15960) < tol && Math.abs(chrm.green_y - 85040) < tol && Math.abs(chrm.blue_x - 3600) < tol && Math.abs(chrm.blue_y - 1e3) < tol) return "prophoto_rgb";
282
+ if (Math.abs(chrm.white_x - 31270) < tol && Math.abs(chrm.white_y - 32900) < tol && Math.abs(chrm.red_x - 70800) < tol && Math.abs(chrm.red_y - 29200) < tol && Math.abs(chrm.green_x - 17e3) < tol && Math.abs(chrm.green_y - 79700) < tol && Math.abs(chrm.blue_x - 13100) < tol && Math.abs(chrm.blue_y - 4600) < tol) return "rec2020";
283
+ return fallback;
284
+ }
285
+ xmpToColorSpaceWorkup(space, target) {
286
+ return `<photoshop:${target}>${space}</photoshop:${target}>`;
287
+ }
288
+ mapXmpToColorSpace(xmpText, fallback) {
289
+ const lower = xmpText.toLowerCase();
290
+ if (lower.includes(this.xmpToColorSpaceWorkup("srgb", "iccprofile"))) return "srgb";
291
+ if (lower.includes(this.xmpToColorSpaceWorkup("adobe rgb (1998)", "iccprofile"))) return "adobe_rgb";
292
+ if (lower.includes(this.xmpToColorSpaceWorkup("display p3", "iccprofile"))) return "display_p3";
293
+ if (lower.includes(this.xmpToColorSpaceWorkup("prophoto rgb", "iccprofile"))) return "prophoto_rgb";
294
+ if (lower.includes(this.xmpToColorSpaceWorkup("rgb", "colormode")) && lower.includes("adobe rgb")) return "adobe_rgb";
295
+ if (lower.includes(this.xmpToColorSpaceWorkup("grayscale", "colormode"))) return "gray";
296
+ return fallback;
297
+ }
298
+ mapProfileToColorSpace(profileName, fallback) {
299
+ if (!profileName || profileName === "embedded" || profileName.toLowerCase().includes("icc profile")) return fallback;
300
+ const lower = profileName.toLowerCase();
301
+ if (lower.includes("srgb") || lower.includes("iec61966") || lower.includes("srgb2014")) return "srgb";
302
+ if (lower.includes("display p3") || lower.includes("display-p3") || lower.includes("dci-p3") || lower.includes("p3")) return "display_p3";
303
+ if (lower.includes("adobe rgb") || lower.includes("adobergb") || lower.includes("adobe rgb (1998)")) return "adobe_rgb";
304
+ if (lower.includes("prophoto rgb") || lower.includes("prophoto") || lower.includes("romm rgb") || lower.includes("romm") || lower.includes("iso 22028")) return "prophoto_rgb";
305
+ if (lower.includes("rec2020") || lower.includes("bt.2020") || lower.includes("bt2020") || lower.includes("bt.2100") || lower.includes("itur_2100")) return "rec2020";
306
+ if (lower.includes("rec709") || lower.includes("bt.709") || lower.includes("bt709")) return "rec709";
307
+ if (lower.includes("cmyk")) return "cmyk";
308
+ if (lower.includes("lab")) return "lab";
309
+ if (lower.includes("xyz")) return "xyz";
310
+ if (lower.includes("gray") || lower.includes("grey") || lower.includes("monochrome") || lower.includes("gamma") || lower.includes("gamma 2.2") || lower.includes("dot gain")) return "gray";
311
+ return fallback;
312
+ }
313
+ };
314
+ export { ImgMetadataExtractorWorkup };
315
+
316
+ //# sourceMappingURL=workup.js.map
package/dist/index.d.ts CHANGED
@@ -1,22 +1,48 @@
1
- export { default as Fs } from './fs/index.js';
2
- export { FsAtomic } from './fs-atomic/index.js';
3
- export { FsBase } from './fs-base/index.js';
4
- export { FsCore } from './fs-core/index.js';
5
- export { FsFetch } from './fs-fetch/index.js';
6
- export { FsSize } from './fs-size/index.js';
7
- export { FsTmp } from './fs-tmp/index.js';
8
- export { ImageService } from './image/index.js';
9
- export { ImageServiceWorkup } from './image/workup.js';
10
- export { LevenshteinDistance } from './ld/index.js';
11
- export { AllMimeTypes, FileExtension, FileExtensionToMimeType, InferTopLevelPresent, MimeService, MimeTopLevelType, MimeType, MimeTypeToFileExtension, PresentMimeTopLevelTypes, extMimeMap, mimeToExt } from './mime/index.js';
12
- export { Abortable, ArrFieldReplacer, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BoxInfo, BufferEncodingUnion, CTR, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, DX, DeepPartial, DeepPartialFields, DeepReplace, Depth, Dict, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, Expect, Extends, FieldToConditionallyNever, IOType, ImageSpecs, InferDepth, InjectScriptsProps, IsExact, IsOptional, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, NoParamCallback, ObjEncodingOptions, OmitSrc, OnlyOptional, OnlyRequired, OpenMode, ParsedUrlInfo, ProcessEnv, ProcessEnvOptions, RTC, ReadDirOptions, ReadDirOptionsEntity, ReadDirProps, RemoveFields, RequireNested, RequiredToConditional, Rm, RmOptions, Signals, SizeOpts, StdioOptions, TCN, TypedArray, Unenumerate, Unit, UnwrapPromise, Without, WriteFileAsyncDataType, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamOptions, WriteStreamProps, WriteableDataType, XOR, unitsObj } from './types/index.js';
13
- export { AsyncIter, Bin, Streamable, WebRS } from './types/stream.js';
14
- export { HandleQueryParamsOrHash, InferExtensionIfPresent, LastSegment, SplitForwardSlash, UrlFileExt, UrlService } from './url/index.js';
15
- export { UtilsService } from './utils/index.js';
16
- import '@d0paminedriven/metadata';
17
- import 'sharp';
18
- import 'stream';
19
- import 'fs';
20
- import 'node:stream';
21
- import 'stream/web';
22
- import 'dotenv-expand';
1
+ import Fs from "./fs/index.js";
2
+ import { FsAtomic } from "./fs-atomic/index.js";
3
+ import { FsBase } from "./fs-base/index.js";
4
+ import { FsCore } from "./fs-core/index.js";
5
+ import { FsFetch } from "./fs-fetch/index.js";
6
+ import { FsSize } from "./fs-size/index.js";
7
+ import { FsTmp } from "./fs-tmp/index.js";
8
+ import { ExtractClient } from "./extract/client.js";
9
+ import { Extract } from "./extract/index.js";
10
+ import { DocMixin, ImgMixin, create, createInstance } from "./mixins/index.js";
11
+ import { DocMetadataExtractor } from "./docs/index.js";
12
+ import { ImgMetadataExtractor } from "./images/index.js";
13
+ import { ImgMetadataExtractorWorkup } from "./images/workup.js";
14
+ import { LevenshteinDistance } from "./ld/index.js";
15
+ import { AllMimeTypes, FileExtension, FileExtensionToMimeType, InferTopLevelPresent, MimeService, MimeTopLevelType, MimeType, MimeTypeToFileExtension, PresentMimeTopLevelTypes, extMimeMap, mimeToExt } from "./mime/index.js";
16
+ import { Abortable, ArrFieldReplacer, ArrayBufferView, ArrayOrReadOnlyArray, BashEnv, BoxInfo, BufferEncodingUnion, CTR, CommonExecOptions, CommonOptions, ConditionalPromise, ConditionalToRequired, Constructor, DX, DeepPartial, DeepPartialFields, DeepReplace, Depth, Dict, DocSpecs, Equal, ExcludeFieldEnumerable, ExecSyncOptions, ExecSyncOptionsWithBufferEncoding, ExecSyncOptionsWithStringEncoding, ExecuteCommandProps, ExpandedDocSpecs, ExpandedImgSpecs, Expect, Extends, ExtractorHardenedOptions, ExtractorOptions, FieldToConditionallyNever, IOType, ImageSpecs, InferDepth, InjectScriptsProps, IsExact, IsOptional, MkDirOptions, MkDirSyncOptions, MkDirSyncProps, Mode, NoParamCallback, ObjEncodingOptions, OmitSrc, OnlyOptional, OnlyRequired, OpenMode, ParsedUrlInfo, PdfDocSpecs, PresentationDocSpecs, ProcessEnv, ProcessEnvOptions, RTC, ReadDirOptions, ReadDirOptionsEntity, ReadDirProps, RemoveFields, RequireNested, RequiredToConditional, Rm, RmOptions, Signals, SizeOpts, SpreadSheetDocSpecs, StdioOptions, TCN, TypedArray, Unenumerate, Unit, UnwrapPromise, Without, WriteFileAsyncDataType, WriteFileAsyncOptions, WriteFileAsyncProps, WriteStreamOptions, WriteStreamProps, WriteableDataType, XOR, ZipEntry, unitsObj } from "./types/index.js";
17
+ import { AsyncIter, Bin, Streamable, WebRS } from "./types/stream.js";
18
+ import { HandleQueryParamsOrHash, InferExtensionIfPresent, LastSegment, SplitForwardSlash, UrlFileExt, UrlService } from "./url/index.js";
19
+ import { UtilsService } from "./utils/index.js";
20
+ declare global {
21
+ interface JSON {
22
+ parse<T = unknown>(text: string, reviver?: (this: any, key: string, value: any) => any): T;
23
+ }
24
+ interface Body {
25
+ json<T = unknown>(): Promise<T>;
26
+ }
27
+ interface Response {
28
+ json<T = unknown>(): Promise<T>;
29
+ }
30
+ namespace NodeJS {
31
+ interface ProcessEnv {
32
+ HOME?: string;
33
+ HOSTTYPE?: string;
34
+ OLDPWD?: string;
35
+ PWD?: string;
36
+ PATH?: string;
37
+ USER?: string;
38
+ SHLVL?: string;
39
+ LOGNAME?: string;
40
+ EDITOR?: string;
41
+ SHELL?: string;
42
+ TERM?: string;
43
+ TERM_PROGRAM?: string;
44
+ }
45
+ }
46
+ }
47
+ export { type Abortable, type AllMimeTypes, type ArrFieldReplacer, type ArrayBufferView, type ArrayOrReadOnlyArray, type AsyncIter, type BashEnv, type Bin, type BoxInfo, type BufferEncodingUnion, type CTR, type CommonExecOptions, type CommonOptions, type ConditionalPromise, type ConditionalToRequired, type Constructor, type DX, type DeepPartial, type DeepPartialFields, type DeepReplace, type Depth, type Dict, DocMetadataExtractor, DocMixin, type DocSpecs, type Equal, type ExcludeFieldEnumerable, type ExecSyncOptions, type ExecSyncOptionsWithBufferEncoding, type ExecSyncOptionsWithStringEncoding, type ExecuteCommandProps, type ExpandedDocSpecs, type ExpandedImgSpecs, type Expect, type Extends, Extract, ExtractClient, type ExtractorHardenedOptions, type ExtractorOptions, type FieldToConditionallyNever, type FileExtension, type FileExtensionToMimeType, Fs, FsAtomic, FsBase, FsCore, FsFetch, FsSize, FsTmp, type HandleQueryParamsOrHash, type IOType, type ImageSpecs, ImgMetadataExtractor, ImgMetadataExtractorWorkup, ImgMixin, type InferDepth, type InferExtensionIfPresent, type InferTopLevelPresent, type InjectScriptsProps, type IsExact, type IsOptional, type LastSegment, LevenshteinDistance, MimeService, type MimeTopLevelType, type MimeType, type MimeTypeToFileExtension, type MkDirOptions, type MkDirSyncOptions, type MkDirSyncProps, type Mode, type NoParamCallback, type ObjEncodingOptions, type OmitSrc, type OnlyOptional, type OnlyRequired, type OpenMode, type ParsedUrlInfo, type PdfDocSpecs, type PresentMimeTopLevelTypes, type PresentationDocSpecs, type ProcessEnv, type ProcessEnvOptions, type RTC, type ReadDirOptions, type ReadDirOptionsEntity, type ReadDirProps, type RemoveFields, type RequireNested, type RequiredToConditional, type Rm, type RmOptions, type Signals, type SizeOpts, type SplitForwardSlash, type SpreadSheetDocSpecs, type StdioOptions, type Streamable, type TCN, type TypedArray, type Unenumerate, type Unit, type UnwrapPromise, type UrlFileExt, UrlService, UtilsService, type WebRS, type Without, type WriteFileAsyncDataType, type WriteFileAsyncOptions, type WriteFileAsyncProps, type WriteStreamOptions, type WriteStreamProps, type WriteableDataType, type XOR, type ZipEntry, create, createInstance, extMimeMap, mimeToExt, unitsObj };
48
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,64 +1,19 @@
1
- import {
2
- Fs
3
- } from "./chunk-JZ6JNZZ6.js";
4
- import {
5
- FsFetch
6
- } from "./chunk-4D2YBCI6.js";
7
- import {
8
- FsTmp
9
- } from "./chunk-PATMSIQK.js";
10
- import {
11
- FsCore
12
- } from "./chunk-OHKRQJZH.js";
13
- import {
14
- FsSize
15
- } from "./chunk-DNR5ZI2T.js";
16
- import {
17
- unitsObj
18
- } from "./chunk-5H6GE5AO.js";
19
- import {
20
- FsAtomic
21
- } from "./chunk-YRCJWFZD.js";
22
- import {
23
- FsBase
24
- } from "./chunk-VDKUXJE7.js";
25
- import {
26
- ImageService
27
- } from "./chunk-Y5QWE4EG.js";
28
- import {
29
- ImageServiceWorkup
30
- } from "./chunk-5CACVZVF.js";
31
- import {
32
- MimeService,
33
- extMimeMap,
34
- mimeToExt
35
- } from "./chunk-L2QMQOEJ.js";
36
- import {
37
- UrlService
38
- } from "./chunk-NJHN5OE3.js";
39
- import {
40
- UtilsService
41
- } from "./chunk-OT5JEQKW.js";
42
- import {
43
- LevenshteinDistance
44
- } from "./chunk-PB5A7ZFD.js";
45
- import "./chunk-7QVYU63E.js";
46
- export {
47
- Fs,
48
- FsAtomic,
49
- FsBase,
50
- FsCore,
51
- FsFetch,
52
- FsSize,
53
- FsTmp,
54
- ImageService,
55
- ImageServiceWorkup,
56
- LevenshteinDistance,
57
- MimeService,
58
- UrlService,
59
- UtilsService,
60
- extMimeMap,
61
- mimeToExt,
62
- unitsObj
63
- };
64
- //# sourceMappingURL=index.js.map
1
+ import Fs from "./fs/index.js";
2
+ import { FsAtomic } from "./fs-atomic/index.js";
3
+ import { FsBase } from "./fs-base/index.js";
4
+ import { FsCore } from "./fs-core/index.js";
5
+ import { FsFetch } from "./fs-fetch/index.js";
6
+ import { FsSize } from "./fs-size/index.js";
7
+ import { FsTmp } from "./fs-tmp/index.js";
8
+ import { ExtractClient } from "./extract/client.js";
9
+ import { Extract } from "./extract/index.js";
10
+ import { DocMixin, ImgMixin, create, createInstance } from "./mixins/index.js";
11
+ import { DocMetadataExtractor } from "./docs/index.js";
12
+ import { ImgMetadataExtractor } from "./images/index.js";
13
+ import { ImgMetadataExtractorWorkup } from "./images/workup.js";
14
+ import { LevenshteinDistance } from "./ld/index.js";
15
+ import { MimeService, extMimeMap, mimeToExt } from "./mime/index.js";
16
+ import { unitsObj } from "./types/index.js";
17
+ import { UrlService } from "./url/index.js";
18
+ import { UtilsService } from "./utils/index.js";
19
+ export { DocMetadataExtractor, DocMixin, Extract, ExtractClient, Fs, FsAtomic, FsBase, FsCore, FsFetch, FsSize, FsTmp, ImgMetadataExtractor, ImgMetadataExtractorWorkup, ImgMixin, LevenshteinDistance, MimeService, UrlService, UtilsService, create, createInstance, extMimeMap, mimeToExt, unitsObj };
@@ -1,17 +1,15 @@
1
- import { Extract } from '@d0paminedriven/metadata';
2
-
3
- declare class LevenshteinDistance extends Extract {
4
- constructor();
5
- private createMatrix;
6
- private inBounds;
7
- private getCell;
8
- private setCell;
9
- /**
10
- * Computes the Levenshtein distance between two strings, i.e.,
11
- * the minimum number of single-character edits (insertions,
12
- * deletions, or substitutions) needed to transform `a` into `b`.
13
- */
14
- calculate(a?: string | null, b?: string | null): number;
1
+ import { Extract } from "../extract/index.js";
2
+ export declare class LevenshteinDistance extends Extract {
3
+ constructor();
4
+ private createMatrix;
5
+ private inBounds;
6
+ private getCell;
7
+ private setCell;
8
+ /**
9
+ * Computes the Levenshtein distance between two strings, i.e.,
10
+ * the minimum number of single-character edits (insertions,
11
+ * deletions, or substitutions) needed to transform `a` into `b`.
12
+ */
13
+ calculateLD(a?: string | null, b?: string | null): number;
15
14
  }
16
-
17
- export { LevenshteinDistance };
15
+ //# sourceMappingURL=index.d.ts.map
package/dist/ld/index.js CHANGED
@@ -1,8 +1,56 @@
1
- import {
2
- LevenshteinDistance
3
- } from "../chunk-PB5A7ZFD.js";
4
- import "../chunk-7QVYU63E.js";
5
- export {
6
- LevenshteinDistance
1
+ import { Extract } from "../extract/index.js";
2
+ // src/ld/index.ts
3
+ var LevenshteinDistance = class extends Extract {
4
+ constructor() {
5
+ super();
6
+ }
7
+ createMatrix(rows, cols, initialValue) {
8
+ const matrix = Array.of();
9
+ for (let r = 0; r < rows; r++) {
10
+ const row = new Array(cols).fill(initialValue);
11
+ matrix.push(row);
12
+ }
13
+ return matrix;
14
+ }
15
+ inBounds(matrix, row, col) {
16
+ if (!matrix[row]) return false;
17
+ return row >= 0 && row < matrix.length && col >= 0 && col < matrix[row].length;
18
+ }
19
+ getCell(matrix, row, col) {
20
+ if (!matrix[row]) throw new Error(`getRow: row does not exist`);
21
+ if (!this.inBounds(matrix, row, col) || !matrix[row][col]) return 0;
22
+ return matrix[row][col];
23
+ }
24
+ setCell(matrix, row, col, value) {
25
+ if (!matrix[row]) return false;
26
+ if (!this.inBounds(matrix, row, col)) return false;
27
+ matrix[row][col] = value;
28
+ return true;
29
+ }
30
+ /**
31
+ * Computes the Levenshtein distance between two strings, i.e.,
32
+ * the minimum number of single-character edits (insertions,
33
+ * deletions, or substitutions) needed to transform `a` into `b`.
34
+ */
35
+ calculateLD(a, b) {
36
+ const strA = a ?? "";
37
+ const strB = b ?? "";
38
+ const dp = this.createMatrix(strA.length + 1, strB.length + 1, 0);
39
+ for (let i = 0; i < dp.length; i++) for (let j = 0; j < (dp[i] ?? []).length; j++) if (i === 0) this.setCell(dp, i, j, j);
40
+ else if (j === 0) this.setCell(dp, i, j, i);
41
+ else if (strA[i - 1] === strB[j - 1]) {
42
+ const diag = this.getCell(dp, i - 1, j - 1);
43
+ this.setCell(dp, i, j, diag);
44
+ } else {
45
+ const top = this.getCell(dp, i - 1, j);
46
+ const left = this.getCell(dp, i, j - 1);
47
+ const diag = this.getCell(dp, i - 1, j - 1);
48
+ const val = 1 + Math.min(top, left, diag);
49
+ this.setCell(dp, i, j, val);
50
+ }
51
+ return this.getCell(dp, strA.length, strB.length);
52
+ }
7
53
  };
54
+ export { LevenshteinDistance };
55
+
8
56
  //# sourceMappingURL=index.js.map