ipx 3.1.1 → 4.0.0-alpha.1
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 +67 -42
- package/dist/_chunks/libs/@fastify/accept-negotiator.mjs +1 -0
- package/dist/_chunks/libs/boolbase.mjs +1 -0
- package/dist/_chunks/libs/css-select.mjs +6 -0
- package/dist/_chunks/libs/css-tree.mjs +126 -0
- package/dist/_chunks/libs/csso.mjs +3 -0
- package/dist/_chunks/libs/etag.mjs +1 -0
- package/dist/_chunks/libs/h3.mjs +2 -0
- package/dist/_chunks/libs/image-meta.mjs +3 -0
- package/dist/_chunks/libs/sax.mjs +10 -0
- package/dist/_chunks/libs/svgo.mjs +78 -0
- package/dist/_chunks/libs/ufo.mjs +1 -0
- package/dist/_chunks/node-fs.mjs +728 -0
- package/dist/_chunks/rolldown-runtime.mjs +46 -0
- package/dist/_chunks/svgo-node.mjs +11 -0
- package/dist/cli.d.mts +1 -2
- package/dist/cli.mjs +76 -58
- package/dist/index.d.mts +226 -320
- package/dist/index.mjs +44 -48
- package/package.json +43 -48
- package/bin/ipx.mjs +0 -2
- package/dist/cli.cjs +0 -63
- package/dist/cli.d.cts +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/index.cjs +0 -62
- package/dist/index.d.cts +0 -397
- package/dist/index.d.ts +0 -397
- package/dist/shared/ipx.CXJeaylD.mjs +0 -764
- package/dist/shared/ipx.GUc23orS.cjs +0 -778
package/dist/index.d.mts
CHANGED
|
@@ -1,74 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { NodeHttpHandler, Server, ServerOptions } from "srvx";
|
|
2
|
+
import { Color, KernelEnum, Sharp, SharpOptions } from "sharp";
|
|
3
|
+
import { ImageMeta } from "image-meta";
|
|
4
|
+
import { Config } from "svgo";
|
|
5
|
+
import { Driver, Storage } from "unstorage";
|
|
6
6
|
|
|
7
|
+
//#region src/types.d.ts
|
|
7
8
|
interface HandlerContext {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Optional quality setting for the output image, affects compression in certain formats.
|
|
11
|
+
* @optional
|
|
12
|
+
*/
|
|
13
|
+
quality?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Specifies the method to fit the image to the dimensions provided, e.g., 'contain', 'cover'.
|
|
16
|
+
* @optional
|
|
17
|
+
*/
|
|
18
|
+
fit?: "contain" | "cover" | "fill" | "inside" | "outside";
|
|
19
|
+
/**
|
|
20
|
+
* The position used for cropping or positioning, specified as a number or string.
|
|
21
|
+
* @optional
|
|
22
|
+
*/
|
|
23
|
+
position?: number | string;
|
|
24
|
+
/**
|
|
25
|
+
* Background colour to be used if necessary, provided as a colour object. See {@link Color}.
|
|
26
|
+
* @optional
|
|
27
|
+
*/
|
|
28
|
+
background?: Color;
|
|
29
|
+
/**
|
|
30
|
+
* Specifies whether to enlarge the image if it is smaller than the desired size.
|
|
31
|
+
* @optional
|
|
32
|
+
*/
|
|
33
|
+
enlarge?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The type of kernel to use for image operations such as resizing. See {@link KernelEnum}.
|
|
36
|
+
* @optional
|
|
37
|
+
*/
|
|
38
|
+
kernel?: keyof KernelEnum;
|
|
39
|
+
/**
|
|
40
|
+
* Metadata about the image being processed.
|
|
41
|
+
*/
|
|
42
|
+
meta: ImageMeta;
|
|
42
43
|
}
|
|
43
44
|
interface Handler {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
/**
|
|
46
|
+
* An array of functions that convert the given string arguments into usable forms.
|
|
47
|
+
*/
|
|
48
|
+
args: ((argument: string) => any)[];
|
|
49
|
+
/**
|
|
50
|
+
* Defines the order in which this handler should be applied relative to other handlers.
|
|
51
|
+
* @optional
|
|
52
|
+
*/
|
|
53
|
+
order?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Function to apply the effects of this handler to the image pipeline.
|
|
56
|
+
* @param {HandlerContext} context - The current image processing context. See {@link HandlerContext}.
|
|
57
|
+
* @param {Sharp} pipe - The Sharp instance to use for image processing. See {@link Sharp}.
|
|
58
|
+
* @param {...any} arguments_ - Transformed arguments to use in the handler.
|
|
59
|
+
*/
|
|
60
|
+
apply: (context: HandlerContext, pipe: Sharp, ...arguments_: any[]) => any;
|
|
60
61
|
}
|
|
61
62
|
type IPXStorageMeta = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The modification time of the stored item.
|
|
65
|
+
* @optional
|
|
66
|
+
*/
|
|
67
|
+
mtime?: Date | number | string;
|
|
68
|
+
/**
|
|
69
|
+
* The maximum age (in seconds) at which the stored item should be considered fresh.
|
|
70
|
+
* @optional
|
|
71
|
+
*/
|
|
72
|
+
maxAge?: number | string;
|
|
72
73
|
};
|
|
73
74
|
/**
|
|
74
75
|
* Options specific to image saving operations.
|
|
@@ -76,145 +77,79 @@ type IPXStorageMeta = {
|
|
|
76
77
|
type IPXStorageOptions = Record<string, unknown>;
|
|
77
78
|
type MaybePromise<T> = T | Promise<T>;
|
|
78
79
|
interface IPXStorage {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
/**
|
|
81
|
+
* A descriptive name for the storage type.
|
|
82
|
+
*/
|
|
83
|
+
name: string;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves metadata for an image identified by 'id'.
|
|
86
|
+
* @param {string} id - The identifier for the image.
|
|
87
|
+
* @param {IPXStorageOptions} [opts] - Optional metadata retrieval options. See {@link IPXStorageOptions}.
|
|
88
|
+
* @returns {MaybePromise<IPXStorageMeta | undefined>} A promise or direct return of the metadata, or undefined if not found. See {@link IPXStorageMeta}.
|
|
89
|
+
*/
|
|
90
|
+
getMeta: (id: string, opts?: IPXStorageOptions) => MaybePromise<IPXStorageMeta | undefined>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the actual data for an image identified by 'id'.
|
|
93
|
+
* @param {string} id - The identifier for the image.
|
|
94
|
+
* @param {IPXStorageOptions} [opts] - Optional options for the data retrieval. See {@link IPXStorageOptions}.
|
|
95
|
+
* @returns {MaybePromise<Buffer | ArrayBuffer | undefined>} A promise or direct return of the image data as an ArrayBuffer, or undefined if not found. See {@link ArrayBuffer}.
|
|
96
|
+
*/
|
|
97
|
+
getData: (id: string, opts?: IPXStorageOptions) => MaybePromise<Buffer | ArrayBuffer | undefined>;
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
declare const fit: Handler;
|
|
101
|
-
declare const position: Handler;
|
|
102
|
-
declare const background: Handler;
|
|
103
|
-
declare const enlarge: Handler;
|
|
104
|
-
declare const kernel: Handler;
|
|
105
|
-
declare const width: Handler;
|
|
106
|
-
declare const height: Handler;
|
|
107
|
-
declare const resize: Handler;
|
|
108
|
-
declare const trim: Handler;
|
|
109
|
-
declare const extend: Handler;
|
|
110
|
-
declare const extract: Handler;
|
|
111
|
-
declare const rotate: Handler;
|
|
112
|
-
declare const flip: Handler;
|
|
113
|
-
declare const flop: Handler;
|
|
114
|
-
declare const sharpen: Handler;
|
|
115
|
-
declare const median: Handler;
|
|
116
|
-
declare const blur: Handler;
|
|
117
|
-
declare const flatten: Handler;
|
|
118
|
-
declare const gamma: Handler;
|
|
119
|
-
declare const negate: Handler;
|
|
120
|
-
declare const normalize: Handler;
|
|
121
|
-
declare const threshold: Handler;
|
|
122
|
-
declare const modulate: Handler;
|
|
123
|
-
declare const tint: Handler;
|
|
124
|
-
declare const grayscale: Handler;
|
|
125
|
-
declare const crop: Handler;
|
|
126
|
-
declare const q: Handler;
|
|
127
|
-
declare const b: Handler;
|
|
128
|
-
declare const w: Handler;
|
|
129
|
-
declare const h: Handler;
|
|
130
|
-
declare const s: Handler;
|
|
131
|
-
declare const pos: Handler;
|
|
132
|
-
|
|
133
|
-
declare const Handlers_b: typeof b;
|
|
134
|
-
declare const Handlers_background: typeof background;
|
|
135
|
-
declare const Handlers_blur: typeof blur;
|
|
136
|
-
declare const Handlers_crop: typeof crop;
|
|
137
|
-
declare const Handlers_enlarge: typeof enlarge;
|
|
138
|
-
declare const Handlers_extend: typeof extend;
|
|
139
|
-
declare const Handlers_extract: typeof extract;
|
|
140
|
-
declare const Handlers_fit: typeof fit;
|
|
141
|
-
declare const Handlers_flatten: typeof flatten;
|
|
142
|
-
declare const Handlers_flip: typeof flip;
|
|
143
|
-
declare const Handlers_flop: typeof flop;
|
|
144
|
-
declare const Handlers_gamma: typeof gamma;
|
|
145
|
-
declare const Handlers_grayscale: typeof grayscale;
|
|
146
|
-
declare const Handlers_h: typeof h;
|
|
147
|
-
declare const Handlers_height: typeof height;
|
|
148
|
-
declare const Handlers_kernel: typeof kernel;
|
|
149
|
-
declare const Handlers_median: typeof median;
|
|
150
|
-
declare const Handlers_modulate: typeof modulate;
|
|
151
|
-
declare const Handlers_negate: typeof negate;
|
|
152
|
-
declare const Handlers_normalize: typeof normalize;
|
|
153
|
-
declare const Handlers_pos: typeof pos;
|
|
154
|
-
declare const Handlers_position: typeof position;
|
|
155
|
-
declare const Handlers_q: typeof q;
|
|
156
|
-
declare const Handlers_quality: typeof quality;
|
|
157
|
-
declare const Handlers_resize: typeof resize;
|
|
158
|
-
declare const Handlers_rotate: typeof rotate;
|
|
159
|
-
declare const Handlers_s: typeof s;
|
|
160
|
-
declare const Handlers_sharpen: typeof sharpen;
|
|
161
|
-
declare const Handlers_threshold: typeof threshold;
|
|
162
|
-
declare const Handlers_tint: typeof tint;
|
|
163
|
-
declare const Handlers_trim: typeof trim;
|
|
164
|
-
declare const Handlers_w: typeof w;
|
|
165
|
-
declare const Handlers_width: typeof width;
|
|
166
|
-
declare namespace Handlers {
|
|
167
|
-
export {
|
|
168
|
-
Handlers_b as b,
|
|
169
|
-
Handlers_background as background,
|
|
170
|
-
Handlers_blur as blur,
|
|
171
|
-
Handlers_crop as crop,
|
|
172
|
-
Handlers_enlarge as enlarge,
|
|
173
|
-
Handlers_extend as extend,
|
|
174
|
-
Handlers_extract as extract,
|
|
175
|
-
Handlers_fit as fit,
|
|
176
|
-
Handlers_flatten as flatten,
|
|
177
|
-
Handlers_flip as flip,
|
|
178
|
-
Handlers_flop as flop,
|
|
179
|
-
Handlers_gamma as gamma,
|
|
180
|
-
Handlers_grayscale as grayscale,
|
|
181
|
-
Handlers_h as h,
|
|
182
|
-
Handlers_height as height,
|
|
183
|
-
Handlers_kernel as kernel,
|
|
184
|
-
Handlers_median as median,
|
|
185
|
-
Handlers_modulate as modulate,
|
|
186
|
-
Handlers_negate as negate,
|
|
187
|
-
Handlers_normalize as normalize,
|
|
188
|
-
Handlers_pos as pos,
|
|
189
|
-
Handlers_position as position,
|
|
190
|
-
Handlers_q as q,
|
|
191
|
-
Handlers_quality as quality,
|
|
192
|
-
Handlers_resize as resize,
|
|
193
|
-
Handlers_rotate as rotate,
|
|
194
|
-
Handlers_s as s,
|
|
195
|
-
Handlers_sharpen as sharpen,
|
|
196
|
-
Handlers_threshold as threshold,
|
|
197
|
-
Handlers_tint as tint,
|
|
198
|
-
Handlers_trim as trim,
|
|
199
|
-
Handlers_w as w,
|
|
200
|
-
Handlers_width as width,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
type HandlerName = keyof typeof Handlers;
|
|
205
|
-
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/ipx.d.ts
|
|
206
101
|
type IPXSourceMeta = {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
102
|
+
/**
|
|
103
|
+
* The modification time of the source. Used for cache validation.
|
|
104
|
+
* @optional
|
|
105
|
+
*/
|
|
106
|
+
mtime?: Date;
|
|
107
|
+
/**
|
|
108
|
+
* The maximum age (in seconds) that the source should be considered fresh.
|
|
109
|
+
* @optional
|
|
110
|
+
*/
|
|
111
|
+
maxAge?: number;
|
|
217
112
|
};
|
|
113
|
+
type FormatModifier = "jpeg" | "jpg" | "png" | "webp" | "avif" | "gif" | "heif" | "tiff" | "auto" | (string & {});
|
|
114
|
+
interface IPXModifiers {
|
|
115
|
+
format: FormatModifier;
|
|
116
|
+
f: FormatModifier;
|
|
117
|
+
fit: "contain" | "cover" | "fill" | "inside" | "outside" | (string & {});
|
|
118
|
+
resize: string;
|
|
119
|
+
s: string;
|
|
120
|
+
quality: number | string;
|
|
121
|
+
q: number | string;
|
|
122
|
+
background: string;
|
|
123
|
+
b: string;
|
|
124
|
+
position: string;
|
|
125
|
+
pos: string;
|
|
126
|
+
enlarge: true | "true";
|
|
127
|
+
kernel: "nearest" | "cubic" | "mitchell" | "lanczos2" | "lanczos3" | (string & {});
|
|
128
|
+
trim: number | string;
|
|
129
|
+
extend: string;
|
|
130
|
+
extract: string;
|
|
131
|
+
crop: string;
|
|
132
|
+
rotate: number | string;
|
|
133
|
+
flip: true | "true";
|
|
134
|
+
flop: true | "true";
|
|
135
|
+
sharpen: number | string;
|
|
136
|
+
median: number | string;
|
|
137
|
+
blur: number | string;
|
|
138
|
+
flatten: true | "true";
|
|
139
|
+
gamma: string;
|
|
140
|
+
negate: true | "true";
|
|
141
|
+
normalize: true | "true";
|
|
142
|
+
threshold: number | string;
|
|
143
|
+
modulate: string;
|
|
144
|
+
tint: number | string;
|
|
145
|
+
grayscale: true | "true";
|
|
146
|
+
animated: true | "true";
|
|
147
|
+
a: true | "true";
|
|
148
|
+
width: string | number;
|
|
149
|
+
w: string | number;
|
|
150
|
+
height: string | number;
|
|
151
|
+
h: string | number;
|
|
152
|
+
}
|
|
218
153
|
/**
|
|
219
154
|
* A function type that defines an IPX image processing instance.
|
|
220
155
|
*
|
|
@@ -232,44 +167,44 @@ type IPXSourceMeta = {
|
|
|
232
167
|
* - `process`: A method that returns a promise resolving to an object containing the processed image data, metadata,
|
|
233
168
|
* and format. The image data can be in the form of a `buffer` or a string, depending on the format and processing.
|
|
234
169
|
*/
|
|
235
|
-
type IPX = (id: string, modifiers?: Partial<
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
170
|
+
type IPX = (id: string, modifiers?: Partial<IPXModifiers>, requestOptions?: any) => {
|
|
171
|
+
getSourceMeta: () => Promise<IPXSourceMeta>;
|
|
172
|
+
process: () => Promise<{
|
|
173
|
+
data: Buffer | string;
|
|
174
|
+
meta?: ImageMeta;
|
|
175
|
+
format?: string;
|
|
176
|
+
}>;
|
|
242
177
|
};
|
|
243
178
|
type IPXOptions = {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
179
|
+
/**
|
|
180
|
+
* Default cache duration in seconds. If not specified, a default of 1 minute is used.
|
|
181
|
+
* @optional
|
|
182
|
+
*/
|
|
183
|
+
maxAge?: number;
|
|
184
|
+
/**
|
|
185
|
+
* A mapping of URL aliases to their corresponding URLs, used to simplify resource identifiers.
|
|
186
|
+
* @optional
|
|
187
|
+
*/
|
|
188
|
+
alias?: Record<string, string>;
|
|
189
|
+
/**
|
|
190
|
+
* Configuration options for the Sharp image processing library.
|
|
191
|
+
* @optional
|
|
192
|
+
*/
|
|
193
|
+
sharpOptions?: SharpOptions;
|
|
194
|
+
/**
|
|
195
|
+
* Primary storage backend for handling image assets.
|
|
196
|
+
*/
|
|
197
|
+
storage: IPXStorage;
|
|
198
|
+
/**
|
|
199
|
+
* An optional secondary storage backend used when images are fetched via HTTP.
|
|
200
|
+
* @optional
|
|
201
|
+
*/
|
|
202
|
+
httpStorage?: IPXStorage;
|
|
203
|
+
/**
|
|
204
|
+
* Configuration for the SVGO library used when processing SVG images.
|
|
205
|
+
* @optional
|
|
206
|
+
*/
|
|
207
|
+
svgo?: false | Config;
|
|
273
208
|
};
|
|
274
209
|
/**
|
|
275
210
|
* Creates an IPX image processing instance with the specified options.
|
|
@@ -278,70 +213,40 @@ type IPXOptions = {
|
|
|
278
213
|
* @throws {Error} If critical options such as storage are missing or incorrectly configured.
|
|
279
214
|
*/
|
|
280
215
|
declare function createIPX(userOptions: IPXOptions): IPX;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
declare function createIPXH3Handler(ipx: IPX): h3.EventHandler<h3.EventHandlerRequest, Promise<string | void | Buffer<ArrayBufferLike> | {
|
|
290
|
-
error: {
|
|
291
|
-
message: string;
|
|
292
|
-
};
|
|
293
|
-
}>>;
|
|
294
|
-
/**
|
|
295
|
-
* Creates an H3 application configured to handle image processing using a supplied IPX instance.
|
|
296
|
-
* @param {IPX} ipx - An IPX instance to handle image handling requests.
|
|
297
|
-
* @returns {any} An H3 application configured to use the IPX image handler.
|
|
298
|
-
*/
|
|
299
|
-
declare function createIPXH3App(ipx: IPX): h3.App;
|
|
300
|
-
/**
|
|
301
|
-
* Creates a web server that can handle IPX image processing requests using an H3 application.
|
|
302
|
-
* @param {IPX} ipx - An IPX instance configured for the server. See {@link IPX}.
|
|
303
|
-
* @returns {any} A web handler suitable for use with web server environments that support the H3 library.
|
|
304
|
-
*/
|
|
305
|
-
declare function createIPXWebServer(ipx: IPX): h3.WebHandler;
|
|
306
|
-
/**
|
|
307
|
-
* Creates a web server that can handle IPX image processing requests using an H3 application.
|
|
308
|
-
* @param {IPX} ipx - An IPX instance configured for the server. See {@link IPX}.
|
|
309
|
-
* @returns {any} A web handler suitable for use with web server environments that support the H3 library.
|
|
310
|
-
*/
|
|
311
|
-
declare function createIPXNodeServer(ipx: IPX): h3.NodeListener;
|
|
312
|
-
/**
|
|
313
|
-
* Creates a simple server that can handle IPX image processing requests using an H3 application.
|
|
314
|
-
* @param {IPX} ipx - An IPX instance configured for the server.
|
|
315
|
-
* @returns {any} A handler suitable for plain HTTP server environments that support the H3 library.
|
|
316
|
-
*/
|
|
317
|
-
declare function createIPXPlainServer(ipx: IPX): h3.PlainHandler;
|
|
318
|
-
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/server.d.ts
|
|
218
|
+
type FetchHandler = (request: Request | string | URL) => Response | Promise<Response>;
|
|
219
|
+
declare function createIPXFetchHandler(ipx: IPX): FetchHandler;
|
|
220
|
+
declare function createIPXNodeHandler(ipx: IPX): NodeHttpHandler;
|
|
221
|
+
declare function serveIPX(ipx: IPX, opts?: Omit<ServerOptions, "fetch">): Server;
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/storage/http.d.ts
|
|
319
224
|
type HTTPStorageOptions = {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Custom options for fetch operations, such as headers or method overrides.
|
|
227
|
+
* @optional
|
|
228
|
+
*/
|
|
229
|
+
fetchOptions?: RequestInit;
|
|
230
|
+
/**
|
|
231
|
+
* Default maximum age (in seconds) for cache control. If not specified, defaults to the environment setting or 300 seconds.
|
|
232
|
+
* @optional
|
|
233
|
+
*/
|
|
234
|
+
maxAge?: number;
|
|
235
|
+
/**
|
|
236
|
+
* Whitelist of domains from which resource fetching is allowed. Can be a single string or an array of strings.
|
|
237
|
+
* @optional
|
|
238
|
+
*/
|
|
239
|
+
domains?: string | string[];
|
|
240
|
+
/**
|
|
241
|
+
* If set to true, allows retrieval from any domain. Overrides the domain whitelist.
|
|
242
|
+
* @optional
|
|
243
|
+
*/
|
|
244
|
+
allowAllDomains?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* If set to true, ignore the cache control header in responses and use the default or specified maxAge.
|
|
247
|
+
* @optional
|
|
248
|
+
*/
|
|
249
|
+
ignoreCacheControl?: boolean;
|
|
345
250
|
};
|
|
346
251
|
/**
|
|
347
252
|
* Creates an HTTP storage handler for IPX that fetches image data from external URLs.
|
|
@@ -352,18 +257,19 @@ type HTTPStorageOptions = {
|
|
|
352
257
|
* @throws {H3Error} If validation of the requested URL fails due to a missing hostname or denied host access. See {@link H3Error}.
|
|
353
258
|
*/
|
|
354
259
|
declare function ipxHttpStorage(_options?: HTTPStorageOptions): IPXStorage;
|
|
355
|
-
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/storage/node-fs.d.ts
|
|
356
262
|
type NodeFSSOptions = {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
263
|
+
/**
|
|
264
|
+
* The directory or list of directories from which to serve files. If not specified, the current directory is used by default.
|
|
265
|
+
* @optional
|
|
266
|
+
*/
|
|
267
|
+
dir?: string | string[];
|
|
268
|
+
/**
|
|
269
|
+
* The directory or list of directories from which to serve files. If not specified, the current directory is used by default.
|
|
270
|
+
* @optional
|
|
271
|
+
*/
|
|
272
|
+
maxAge?: number;
|
|
367
273
|
};
|
|
368
274
|
/**
|
|
369
275
|
* Creates a file system storage handler for IPX that allows images to be served from local directories specified in the options.
|
|
@@ -374,13 +280,14 @@ type NodeFSSOptions = {
|
|
|
374
280
|
* @throws {H3Error} If there is a problem accessing the file system module or resolving/reading files. See {@link H3Error}.
|
|
375
281
|
*/
|
|
376
282
|
declare function ipxFSStorage(_options?: NodeFSSOptions): IPXStorage;
|
|
377
|
-
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/storage/unstorage.d.ts
|
|
378
285
|
type UnstorageIPXStorageOptions = {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Optional prefix to be placed in front of each storage key, which can help to name or categorise stored items.
|
|
288
|
+
* @optional
|
|
289
|
+
*/
|
|
290
|
+
prefix?: string;
|
|
384
291
|
};
|
|
385
292
|
/**
|
|
386
293
|
* Adapts an Unstorage driver or storage system to comply with the IPXStorage interface required by IPX.
|
|
@@ -392,6 +299,5 @@ type UnstorageIPXStorageOptions = {
|
|
|
392
299
|
* @throws {H3Error} If there is a problem retrieving or converting the storage data, detailed error information is thrown. See {@link H3Error}.
|
|
393
300
|
*/
|
|
394
301
|
declare function unstorageToIPXStorage(storage: Storage | Driver, _options?: UnstorageIPXStorageOptions | string): IPXStorage;
|
|
395
|
-
|
|
396
|
-
export {
|
|
397
|
-
export type { HTTPStorageOptions, Handler, HandlerContext, IPX, IPXOptions, IPXStorage, IPXStorageMeta, IPXStorageOptions, NodeFSSOptions, UnstorageIPXStorageOptions };
|
|
302
|
+
//#endregion
|
|
303
|
+
export { type HTTPStorageOptions, type Handler, type HandlerContext, type IPX, type IPXModifiers, type IPXOptions, type IPXStorage, type IPXStorageMeta, type IPXStorageOptions, type NodeFSSOptions, type UnstorageIPXStorageOptions, createIPX, createIPXFetchHandler, createIPXNodeHandler, ipxFSStorage, ipxHttpStorage, serveIPX, unstorageToIPXStorage };
|