@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
@@ -1,107 +0,0 @@
1
- import {
2
- FsBase
3
- } from "./chunk-VDKUXJE7.js";
4
- import {
5
- __name
6
- } from "./chunk-7QVYU63E.js";
7
-
8
- // src/fs-atomic/index.ts
9
- import fsSync from "fs";
10
- import fsAsync from "fs/promises";
11
- import { execSync } from "child_process";
12
- import { join, relative, resolve } from "path";
13
- var FsAtomic = class extends FsBase {
14
- constructor(cwd) {
15
- super(cwd ??= process.cwd());
16
- this.cwd = cwd;
17
- }
18
- static {
19
- __name(this, "FsAtomic");
20
- }
21
- executeCommand = /* @__PURE__ */ __name(({
22
- command,
23
- ...options
24
- }) => Buffer.from(execSync(command, { ...options }).toJSON().data).toString(
25
- "utf-8"
26
- ), "executeCommand");
27
- mkdirSync(path, options = { mode: 511, recursive: true }) {
28
- return fsSync.mkdirSync(relative(this.cwd, path), options);
29
- }
30
- generateDirIfDNE(path, options = { mode: 511, recursive: true }) {
31
- if (this.exists(path)) return;
32
- else {
33
- return this.mkdirSync(path, options);
34
- }
35
- }
36
- fileToBuffer = /* @__PURE__ */ __name((path) => Buffer.from(fsSync.readFileSync(relative(this.cwd, path)).toJSON().data), "fileToBuffer");
37
- fileToBufferAsync = /* @__PURE__ */ __name(async (path) => {
38
- return await fsAsync.readFile(relative(this.cwd, path));
39
- }, "fileToBufferAsync");
40
- dirContainsDir(readDir, targetDir, options) {
41
- return this.readDir(readDir, options).filter((t) => t.split(".").length === 1).includes(targetDir);
42
- }
43
- rmFile(filePath, options = {
44
- force: true,
45
- maxRetries: 0,
46
- recursive: true,
47
- retryDelay: 100
48
- }) {
49
- if (this.exists(filePath)) {
50
- if (this.isRootPathTargeted(filePath)) {
51
- fsSync.rmSync(resolve(join(this.cwd, filePath)), options);
52
- } else fsSync.rmSync(resolve(this.cwd, filePath), options);
53
- } else return;
54
- }
55
- /**
56
- * Removes files and directories (modeled on the standard POSIX `rm` utility).
57
- * To get a behavior similar to the `rm -rf` Unix command, use options `{ recursive: true, force: true }`.
58
- * @return Fulfills with `undefined` upon success.
59
- */
60
- async rmdir(dir, options = {
61
- maxRetries: 0,
62
- retryDelay: 100,
63
- recursive: true,
64
- force: true
65
- }) {
66
- const resolved = relative(this.cwd, dir);
67
- if (this.exists(dir)) {
68
- return await fsAsync.rm(relative(this.cwd, dir), options);
69
- } else {
70
- throw new Error(`directory ${resolved} does not exist`);
71
- }
72
- }
73
- rmDirSync(dir, options = {
74
- force: true,
75
- recursive: true,
76
- maxRetries: 0,
77
- retryDelay: 100
78
- }, callback = (err) => err?.message ? console.error(err.message) : console.error(`directory ${dir} does not exist`)) {
79
- const resolved = resolve(this.cwd, dir);
80
- if (this.exists(dir)) {
81
- return fsSync.rm(resolved, options, callback);
82
- } else {
83
- throw new Error(`directory ${resolved} does not exist`);
84
- }
85
- }
86
- existsTmp(path) {
87
- return this.exists(resolve(this.tmpDir, path));
88
- }
89
- mkdirTmp(path, options = { mode: 511, recursive: true }) {
90
- return this.mkdirSync(resolve(this.tmpDir, path), options);
91
- }
92
- generateDirIfDNETmp(path, options) {
93
- if (this.existsTmp(path)) return;
94
- else {
95
- return this.mkdirTmp(path, options);
96
- }
97
- }
98
- rmTmpFile(filename) {
99
- const tmpPath = resolve(this.tmpDir, filename);
100
- this.rmFile(tmpPath);
101
- }
102
- };
103
-
104
- export {
105
- FsAtomic
106
- };
107
- //# sourceMappingURL=chunk-YRCJWFZD.js.map
@@ -1,182 +0,0 @@
1
- import * as _d0paminedriven_metadata from '@d0paminedriven/metadata';
2
- import { Readable } from 'node:stream';
3
- import { ImageSpecs } from '../types/index.js';
4
- import { ImageServiceWorkup } from './workup.js';
5
- import 'stream';
6
- import 'fs';
7
- import '../mime/index.js';
8
- import '../url/index.js';
9
- import '../utils/index.js';
10
- import '../ld/index.js';
11
-
12
- declare class ImageService extends ImageServiceWorkup {
13
- cwd: string;
14
- constructor(cwd: string);
15
- /**
16
- * Extract image metadata from a stream, reading only ~4KB for most formats
17
- * Automatically handles PNG, JPEG, GIF, BMP, WebP, and AVIF
18
- */
19
- extractFromStream(stream: Readable, size?: number): Promise<ImageSpecs>;
20
- /**
21
- * Extract metadata from file path using streaming (memory efficient)
22
- */
23
- extractFromPath(filePath: string, size?: number): Promise<ImageSpecs>;
24
- private isPNG;
25
- private isJPEG;
26
- private isGIF;
27
- private isBMP;
28
- private isWebP;
29
- private isAVIF;
30
- private extractPNGFromBuffer;
31
- private extractJPEGFromBuffer;
32
- private extractGIFFromBuffer;
33
- private extractBMPFromBuffer;
34
- private extractWebPFromBuffer;
35
- private extractAVIFFromBuffer;
36
- extractViaStream(stream: Readable, size?: number): Promise<_d0paminedriven_metadata.ExpandedImgSpecs>;
37
- extractViaPath(filePath: string, size?: number): Promise<_d0paminedriven_metadata.ExpandedImgSpecs>;
38
- /**
39
- * Probe image from various sources
40
- * Handles local Buffer, remote URL, or S3 object
41
- */
42
- extractRemoteFs(source: Buffer | string, size?: number, timeout?: number): Promise<ImageSpecs>;
43
- /**
44
- * Fetch minimal bytes from remote URL using Range header
45
- * This is the KEY optimization - only fetch what we need!
46
- */
47
- private knownToBlock;
48
- private fetchMinimalBufferFs;
49
- getImageSpecsWorkupFs(rawbuffer: Buffer<ArrayBufferLike>, size?: number): {
50
- width: number;
51
- height: number;
52
- format: "apng" | "png";
53
- frames: number;
54
- animated: boolean;
55
- hasAlpha: boolean;
56
- colorModel: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed";
57
- orientation: null;
58
- aspectRatio: number;
59
- colorSpace: "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
60
- iccProfile: string | null;
61
- exifDateTimeOriginal: string | null;
62
- } | {
63
- width: number;
64
- height: number;
65
- format: "jpeg";
66
- frames: number;
67
- animated: false;
68
- hasAlpha: false;
69
- orientation: number | null;
70
- aspectRatio: number;
71
- colorSpace: "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
72
- colorModel: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed" | "cmyk" | "ycbcr" | "ycck" | "vector" | "lab";
73
- iccProfile: string | null;
74
- exifDateTimeOriginal: string | null;
75
- } | {
76
- width: number;
77
- height: number;
78
- format: "gif";
79
- frames: number;
80
- animated: boolean;
81
- hasAlpha: null;
82
- orientation: null;
83
- aspectRatio: number;
84
- colorModel: "indexed";
85
- colorSpace: "unknown";
86
- iccProfile: null;
87
- exifDateTimeOriginal: null;
88
- } | {
89
- width: number;
90
- height: number;
91
- format: "bmp";
92
- frames: number;
93
- animated: false;
94
- hasAlpha: null;
95
- orientation: number;
96
- aspectRatio: number;
97
- colorModel: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed" | "cmyk" | "ycbcr" | "ycck" | "vector" | "lab";
98
- colorSpace: "unknown";
99
- iccProfile: null;
100
- exifDateTimeOriginal: null;
101
- } | {
102
- width: number;
103
- height: number;
104
- format: "webp";
105
- frames: number;
106
- animated: boolean;
107
- hasAlpha: boolean;
108
- colorModel: "unknown" | "rgb" | "rgba";
109
- orientation: null;
110
- aspectRatio: number;
111
- colorSpace: "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
112
- iccProfile: string | null;
113
- exifDateTimeOriginal: null;
114
- } | {
115
- width: number;
116
- height: number;
117
- format: "avif";
118
- frames: number;
119
- animated: boolean;
120
- colorModel: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed" | "cmyk" | "ycbcr" | "ycck" | "vector" | "lab";
121
- hasAlpha: true | null;
122
- orientation: null;
123
- aspectRatio: number;
124
- colorSpace: "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
125
- iccProfile: string | null;
126
- exifDateTimeOriginal: string | null;
127
- } | {
128
- width: number;
129
- height: number;
130
- format: "heic";
131
- frames: number;
132
- animated: boolean;
133
- colorModel: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed" | "cmyk" | "ycbcr" | "ycck" | "vector" | "lab";
134
- hasAlpha: true | null;
135
- orientation: null;
136
- aspectRatio: number;
137
- colorSpace: "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
138
- iccProfile: string | null;
139
- exifDateTimeOriginal: string | null;
140
- } | {
141
- width: number;
142
- height: number;
143
- format: "svg";
144
- frames: number;
145
- animated: boolean;
146
- hasAlpha: true;
147
- orientation: null;
148
- aspectRatio: number;
149
- colorModel: "vector";
150
- colorSpace: "srgb";
151
- iccProfile: null;
152
- exifDateTimeOriginal: null;
153
- } | {
154
- width: number;
155
- height: number;
156
- format: "ico";
157
- frames: number;
158
- animated: false;
159
- hasAlpha: true | null;
160
- orientation: null;
161
- aspectRatio: number;
162
- colorModel: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed" | "cmyk" | "ycbcr" | "ycck" | "vector" | "lab";
163
- colorSpace: "srgb";
164
- iccProfile: null;
165
- exifDateTimeOriginal: null;
166
- } | {
167
- width: number;
168
- height: number;
169
- format: "tiff";
170
- frames: number;
171
- animated: false;
172
- hasAlpha: boolean;
173
- orientation: number | null;
174
- aspectRatio: number;
175
- colorModel: "unknown" | "rgb" | "rgba" | "grayscale" | "grayscale-alpha" | "indexed" | "cmyk" | "ycbcr" | "ycck" | "vector" | "lab";
176
- colorSpace: "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
177
- iccProfile: string | null;
178
- exifDateTimeOriginal: string | null;
179
- };
180
- }
181
-
182
- export { ImageService };
@@ -1,13 +0,0 @@
1
- import {
2
- ImageService
3
- } from "../chunk-Y5QWE4EG.js";
4
- import "../chunk-5CACVZVF.js";
5
- import "../chunk-L2QMQOEJ.js";
6
- import "../chunk-NJHN5OE3.js";
7
- import "../chunk-OT5JEQKW.js";
8
- import "../chunk-PB5A7ZFD.js";
9
- import "../chunk-7QVYU63E.js";
10
- export {
11
- ImageService
12
- };
13
- //# sourceMappingURL=index.js.map
@@ -1,40 +0,0 @@
1
- import { Readable } from 'stream';
2
- import { BoxInfo, ImageSpecs } from '../types/index.js';
3
- import { MimeService } from '../mime/index.js';
4
- import 'fs';
5
- import '../url/index.js';
6
- import '../utils/index.js';
7
- import '../ld/index.js';
8
- import '@d0paminedriven/metadata';
9
-
10
- declare class ImageServiceWorkup extends MimeService {
11
- cwd: string;
12
- constructor(cwd: string);
13
- /**
14
- * Read exactly N bytes from a stream, returning a Buffer
15
- * Closes stream after reading or on error
16
- */
17
- readBytes(stream: Readable, bytes: number): Promise<Buffer>;
18
- parseExif(buffer: Buffer, app1Pos: number, app1Size: number): {
19
- orientation: number | null;
20
- dateTimeOriginal: string | null;
21
- };
22
- parseXmpFromAvif(buffer: Buffer, meta: BoxInfo, _ipco: BoxInfo): string | null;
23
- readVarSize(buffer: Buffer, pos: number, size: number): number;
24
- findBox(buffer: Buffer, type: string, start?: number, end?: number): BoxInfo | null;
25
- mapChrmToColorSpace(chrm: {
26
- white_x: number;
27
- white_y: number;
28
- red_x: number;
29
- red_y: number;
30
- green_x: number;
31
- green_y: number;
32
- blue_x: number;
33
- blue_y: number;
34
- }, fallback: ImageSpecs["colorSpace"]): "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
35
- 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}>`;
36
- mapXmpToColorSpace(xmpText: string, fallback: ImageSpecs["colorSpace"]): "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
37
- mapProfileToColorSpace(profileName: string | null, fallback: ImageSpecs["colorSpace"]): "unknown" | "cmyk" | "lab" | "srgb" | "display_p3" | "adobe_rgb" | "prophoto_rgb" | "rec2020" | "rec709" | "xyz" | "gray";
38
- }
39
-
40
- export { ImageServiceWorkup };
@@ -1,12 +0,0 @@
1
- import {
2
- ImageServiceWorkup
3
- } from "../chunk-5CACVZVF.js";
4
- import "../chunk-L2QMQOEJ.js";
5
- import "../chunk-NJHN5OE3.js";
6
- import "../chunk-OT5JEQKW.js";
7
- import "../chunk-PB5A7ZFD.js";
8
- import "../chunk-7QVYU63E.js";
9
- export {
10
- ImageServiceWorkup
11
- };
12
- //# sourceMappingURL=workup.js.map