@socialtip/asset-proxy-url-parser 0.5.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/CHANGELOG.md +39 -0
- package/README.md +78 -0
- package/dist/crypto.d.ts +8 -0
- package/dist/crypto.js +32 -0
- package/dist/crypto.js.map +1 -0
- package/dist/error.d.ts +17 -0
- package/dist/error.js +17 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/info-parse.d.ts +98 -0
- package/dist/info-parse.js +187 -0
- package/dist/info-parse.js.map +1 -0
- package/dist/parse.d.ts +581 -0
- package/dist/parse.js +1085 -0
- package/dist/parse.js.map +1 -0
- package/dist/signature.d.ts +15 -0
- package/dist/signature.js +42 -0
- package/dist/signature.js.map +1 -0
- package/package.json +30 -0
- package/src/crypto.ts +53 -0
- package/src/error.ts +23 -0
- package/src/index.ts +36 -0
- package/src/info-parse.ts +275 -0
- package/src/parse.ts +1426 -0
- package/src/signature.ts +59 -0
- package/tsconfig.build.json +8 -0
- package/tsconfig.json +17 -0
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
declare const resizingType: z.ZodEnum<{
|
|
3
|
+
fill: "fill";
|
|
4
|
+
fit: "fit";
|
|
5
|
+
"fill-down": "fill-down";
|
|
6
|
+
force: "force";
|
|
7
|
+
auto: "auto";
|
|
8
|
+
}>;
|
|
9
|
+
export type ResizingType = z.output<typeof resizingType>;
|
|
10
|
+
declare const cpuAlgorithms: readonly ["nearest", "linear", "cubic", "lanczos2", "lanczos3"];
|
|
11
|
+
declare const gpuScalers: readonly ["scale_cuda", "scale_npp"];
|
|
12
|
+
type CpuAlgorithm = (typeof cpuAlgorithms)[number];
|
|
13
|
+
type GpuScaler = (typeof gpuScalers)[number];
|
|
14
|
+
export type ResizingAlgorithm = {
|
|
15
|
+
mode: "cpu";
|
|
16
|
+
algorithm: CpuAlgorithm;
|
|
17
|
+
} | {
|
|
18
|
+
mode: "gpu";
|
|
19
|
+
scaler: GpuScaler;
|
|
20
|
+
algorithm?: CpuAlgorithm;
|
|
21
|
+
};
|
|
22
|
+
declare const videoFormat: z.ZodEnum<{
|
|
23
|
+
mp4: "mp4";
|
|
24
|
+
webm: "webm";
|
|
25
|
+
}>;
|
|
26
|
+
declare const imageFormat: z.ZodEnum<{
|
|
27
|
+
jpg: "jpg";
|
|
28
|
+
png: "png";
|
|
29
|
+
webp: "webp";
|
|
30
|
+
avif: "avif";
|
|
31
|
+
gif: "gif";
|
|
32
|
+
}>;
|
|
33
|
+
declare const outputFormat: z.ZodUnion<readonly [z.ZodEnum<{
|
|
34
|
+
mp4: "mp4";
|
|
35
|
+
webm: "webm";
|
|
36
|
+
}>, z.ZodEnum<{
|
|
37
|
+
jpg: "jpg";
|
|
38
|
+
png: "png";
|
|
39
|
+
webp: "webp";
|
|
40
|
+
avif: "avif";
|
|
41
|
+
gif: "gif";
|
|
42
|
+
}>]>;
|
|
43
|
+
export type VideoFormat = z.output<typeof videoFormat>;
|
|
44
|
+
export type ImageFormat = z.output<typeof imageFormat>;
|
|
45
|
+
export type OutputFormat = z.output<typeof outputFormat>;
|
|
46
|
+
export type MediaType = "video" | "image";
|
|
47
|
+
declare const compassGravity: z.ZodEnum<{
|
|
48
|
+
no: "no";
|
|
49
|
+
so: "so";
|
|
50
|
+
ea: "ea";
|
|
51
|
+
we: "we";
|
|
52
|
+
noea: "noea";
|
|
53
|
+
nowe: "nowe";
|
|
54
|
+
soea: "soea";
|
|
55
|
+
sowe: "sowe";
|
|
56
|
+
ce: "ce";
|
|
57
|
+
}>;
|
|
58
|
+
export type CompassGravity = z.output<typeof compassGravity>;
|
|
59
|
+
declare const focusPointGravity: z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"fp">;
|
|
61
|
+
x: z.ZodNumber;
|
|
62
|
+
y: z.ZodNumber;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
export type FocusPointGravity = z.output<typeof focusPointGravity>;
|
|
65
|
+
declare const gravitySchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
66
|
+
no: "no";
|
|
67
|
+
so: "so";
|
|
68
|
+
ea: "ea";
|
|
69
|
+
we: "we";
|
|
70
|
+
noea: "noea";
|
|
71
|
+
nowe: "nowe";
|
|
72
|
+
soea: "soea";
|
|
73
|
+
sowe: "sowe";
|
|
74
|
+
ce: "ce";
|
|
75
|
+
}>, z.ZodObject<{
|
|
76
|
+
type: z.ZodLiteral<"fp">;
|
|
77
|
+
x: z.ZodNumber;
|
|
78
|
+
y: z.ZodNumber;
|
|
79
|
+
}, z.core.$strip>]>;
|
|
80
|
+
export type Gravity = z.output<typeof gravitySchema>;
|
|
81
|
+
declare const resizeOptions: z.ZodObject<{
|
|
82
|
+
type: z.ZodEnum<{
|
|
83
|
+
fill: "fill";
|
|
84
|
+
fit: "fit";
|
|
85
|
+
"fill-down": "fill-down";
|
|
86
|
+
force: "force";
|
|
87
|
+
auto: "auto";
|
|
88
|
+
}>;
|
|
89
|
+
width: z.ZodNumber;
|
|
90
|
+
height: z.ZodNumber;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
export type ResizeOptions = z.output<typeof resizeOptions>;
|
|
93
|
+
export declare const SHORTHANDS: Record<string, string>;
|
|
94
|
+
/** All processing options for an asset-proxy URL. Defined as an explicit interface so JSDoc is preserved in declaration output. */
|
|
95
|
+
export interface ParsedUrlInput {
|
|
96
|
+
/** Resize dimensions and mode (fit, fill, fill-down, force, auto). */
|
|
97
|
+
resize?: ResizeOptions;
|
|
98
|
+
/** Scaling algorithm — CPU interpolation (e.g. lanczos3) or GPU scaler (scale_cuda, scale_npp). */
|
|
99
|
+
resizingAlgorithm?: ResizingAlgorithm;
|
|
100
|
+
/** The source image/video URL to process. */
|
|
101
|
+
sourceUrl: string;
|
|
102
|
+
/** Output format: jpg, png, webp, avif, gif, mp4, webm. */
|
|
103
|
+
outputFormat: OutputFormat;
|
|
104
|
+
/** Minimum output width — upscales if the result would be narrower. */
|
|
105
|
+
minWidth?: number;
|
|
106
|
+
/** Minimum output height — upscales if the result would be shorter. */
|
|
107
|
+
minHeight?: number;
|
|
108
|
+
/** Pad undersized images to fill the target resize dimensions. */
|
|
109
|
+
extend?: {
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
gravity: CompassGravity;
|
|
112
|
+
};
|
|
113
|
+
/** Extend the image to match the target aspect ratio. */
|
|
114
|
+
extendAspectRatio?: {
|
|
115
|
+
enabled: boolean;
|
|
116
|
+
gravity: CompassGravity;
|
|
117
|
+
};
|
|
118
|
+
/** Output framerate in fps (video only). */
|
|
119
|
+
framerate?: number;
|
|
120
|
+
/** Limit output duration in seconds (video only). */
|
|
121
|
+
cut?: number;
|
|
122
|
+
/** Strip audio from video output. */
|
|
123
|
+
mute?: boolean;
|
|
124
|
+
/** Remove uniform borders from an image via cropdetect. */
|
|
125
|
+
trim?: {
|
|
126
|
+
/** Colour similarity tolerance (0–255). */
|
|
127
|
+
threshold: number;
|
|
128
|
+
/** Hex colour to trim. Auto-detected if omitted. */
|
|
129
|
+
colour?: string;
|
|
130
|
+
/** Trim equal amounts from left and right. */
|
|
131
|
+
equalHor: boolean;
|
|
132
|
+
/** Trim equal amounts from top and bottom. */
|
|
133
|
+
equalVert: boolean;
|
|
134
|
+
};
|
|
135
|
+
/** Brightness adjustment (-255 to 255, 0 = no change). */
|
|
136
|
+
brightness: number;
|
|
137
|
+
/** Contrast multiplier (1 = no change). */
|
|
138
|
+
contrast: number;
|
|
139
|
+
/** Saturation multiplier (1 = no change). */
|
|
140
|
+
saturation: number;
|
|
141
|
+
/** Convert to monochrome with optional intensity and base colour. */
|
|
142
|
+
monochrome?: {
|
|
143
|
+
intensity: number;
|
|
144
|
+
colour: string;
|
|
145
|
+
};
|
|
146
|
+
/** Apply duotone effect with two colours. */
|
|
147
|
+
duotone?: {
|
|
148
|
+
intensity: number;
|
|
149
|
+
colour1: string;
|
|
150
|
+
colour2: string;
|
|
151
|
+
};
|
|
152
|
+
/** Output quality 1–100 for lossy formats (JPEG, WebP, AVIF). */
|
|
153
|
+
quality?: number;
|
|
154
|
+
/** Per-format quality overrides: { jpg: 80, webp: 90, ... }. */
|
|
155
|
+
formatQuality?: Record<string, number>;
|
|
156
|
+
/** Autoquality: dssim (target DSSIM) or size (target bytes). */
|
|
157
|
+
autoquality?: {
|
|
158
|
+
method: "dssim" | "size";
|
|
159
|
+
target: number;
|
|
160
|
+
min: number;
|
|
161
|
+
max: number;
|
|
162
|
+
allowedError: number;
|
|
163
|
+
};
|
|
164
|
+
/** Max output size in bytes — degrades quality to fit. */
|
|
165
|
+
maxBytes?: number;
|
|
166
|
+
/** JPEG encoder options. */
|
|
167
|
+
jpegOptions?: {
|
|
168
|
+
progressive: boolean;
|
|
169
|
+
noSubsample: boolean;
|
|
170
|
+
trellisQuant: boolean;
|
|
171
|
+
overshootDeringing: boolean;
|
|
172
|
+
optimizeScans: boolean;
|
|
173
|
+
quantTable?: number;
|
|
174
|
+
};
|
|
175
|
+
/** PNG encoder options. */
|
|
176
|
+
pngOptions?: {
|
|
177
|
+
interlaced: boolean;
|
|
178
|
+
quantize: boolean;
|
|
179
|
+
quantizationColours?: number;
|
|
180
|
+
};
|
|
181
|
+
/** WebP encoder options. */
|
|
182
|
+
webpOptions?: {
|
|
183
|
+
compression?: number;
|
|
184
|
+
smartSubsample: boolean;
|
|
185
|
+
preset?: string;
|
|
186
|
+
};
|
|
187
|
+
/** AVIF encoder options. */
|
|
188
|
+
avifOptions?: {
|
|
189
|
+
subsample?: string;
|
|
190
|
+
};
|
|
191
|
+
/** Gaussian blur sigma. */
|
|
192
|
+
blur?: number;
|
|
193
|
+
/** Sharpening sigma. */
|
|
194
|
+
sharpen?: number;
|
|
195
|
+
/** Pixelate block size in pixels. */
|
|
196
|
+
pixelate?: number;
|
|
197
|
+
/** Unsharp masking: mode (auto/always/none), weight, divider. */
|
|
198
|
+
unsharpMasking?: {
|
|
199
|
+
mode: string;
|
|
200
|
+
weight: number;
|
|
201
|
+
divider: number;
|
|
202
|
+
};
|
|
203
|
+
/** Colour overlay with opacity. */
|
|
204
|
+
colorize?: {
|
|
205
|
+
opacity: number;
|
|
206
|
+
colour: string;
|
|
207
|
+
keepAlpha: boolean;
|
|
208
|
+
};
|
|
209
|
+
/** Gradient overlay from transparent to colour. */
|
|
210
|
+
gradient?: {
|
|
211
|
+
opacity: number;
|
|
212
|
+
colour: string;
|
|
213
|
+
direction: string;
|
|
214
|
+
start: number;
|
|
215
|
+
stop: number;
|
|
216
|
+
};
|
|
217
|
+
/** Rotation angle: 0, 90, 180, or 270 degrees. */
|
|
218
|
+
rotate?: number;
|
|
219
|
+
/** Flip the image horizontally and/or vertically. */
|
|
220
|
+
flip?: {
|
|
221
|
+
horizontal: boolean;
|
|
222
|
+
vertical: boolean;
|
|
223
|
+
};
|
|
224
|
+
/** Rotate based on EXIF orientation data. */
|
|
225
|
+
autoRotate?: boolean;
|
|
226
|
+
/** Background colour (RGB) for padding, extend, and alpha flattening. */
|
|
227
|
+
background?: {
|
|
228
|
+
r: number;
|
|
229
|
+
g: number;
|
|
230
|
+
b: number;
|
|
231
|
+
};
|
|
232
|
+
/** Background opacity (0–1). */
|
|
233
|
+
backgroundAlpha?: number;
|
|
234
|
+
/** Canvas padding in pixels: top, right, bottom, left. */
|
|
235
|
+
padding?: {
|
|
236
|
+
top: number;
|
|
237
|
+
right: number;
|
|
238
|
+
bottom: number;
|
|
239
|
+
left: number;
|
|
240
|
+
};
|
|
241
|
+
/** Remove EXIF and other metadata from the output. */
|
|
242
|
+
stripMetadata?: boolean;
|
|
243
|
+
/** Preserve copyright metadata when stripping. */
|
|
244
|
+
keepCopyright?: boolean;
|
|
245
|
+
/** Convert ICC colour profile to sRGB and remove it. */
|
|
246
|
+
stripColorProfile?: boolean;
|
|
247
|
+
/** Output DPI metadata value. */
|
|
248
|
+
dpi?: number;
|
|
249
|
+
/** Prefer embedded thumbnail over full image (HEIC/AVIF). */
|
|
250
|
+
enforceThumbnail?: boolean;
|
|
251
|
+
/** Extract video frame at this second. */
|
|
252
|
+
videoThumbnailSecond?: number;
|
|
253
|
+
/** Use only keyframes for video thumbnails. */
|
|
254
|
+
videoThumbnailKeyframes?: boolean;
|
|
255
|
+
/** Video animation config. */
|
|
256
|
+
videoThumbnailAnimation?: {
|
|
257
|
+
/** Interval in seconds between sampled video frames (0 = auto). */
|
|
258
|
+
step: number;
|
|
259
|
+
/** Delay between animation frames in milliseconds. */
|
|
260
|
+
delay: number;
|
|
261
|
+
/** Maximum number of output frames (0 = unlimited). */
|
|
262
|
+
frames: number;
|
|
263
|
+
/** Target frame width in pixels (0 = derive from aspect ratio). */
|
|
264
|
+
frameWidth: number;
|
|
265
|
+
/** Target frame height in pixels (0 = derive from aspect ratio). */
|
|
266
|
+
frameHeight: number;
|
|
267
|
+
/** Pad frames with black to match exact frameWidth/frameHeight. */
|
|
268
|
+
extendFrame: boolean;
|
|
269
|
+
/** Remove unused frames from the animation. */
|
|
270
|
+
trim: boolean;
|
|
271
|
+
/** Crop-fill to exact frameWidth/frameHeight instead of fitting. */
|
|
272
|
+
fill: boolean;
|
|
273
|
+
/** Horizontal crop anchor for fill mode (0–1, default 0.5). */
|
|
274
|
+
focusX: number;
|
|
275
|
+
/** Vertical crop anchor for fill mode (0–1, default 0.5). */
|
|
276
|
+
focusY: number;
|
|
277
|
+
};
|
|
278
|
+
/** Extract a region before resizing (width, height, optional gravity). */
|
|
279
|
+
crop?: {
|
|
280
|
+
width: number;
|
|
281
|
+
height: number;
|
|
282
|
+
gravity?: Gravity;
|
|
283
|
+
};
|
|
284
|
+
/** Crop to a target aspect ratio (width/height as a float). */
|
|
285
|
+
cropAspectRatio?: number;
|
|
286
|
+
/** Anchor point for crop: compass direction or focus point. */
|
|
287
|
+
gravity?: Gravity;
|
|
288
|
+
/** Allow upscaling when the image is smaller than the target. */
|
|
289
|
+
enlarge?: boolean;
|
|
290
|
+
/** Automatically select the most efficient output format. */
|
|
291
|
+
bestFormat?: boolean;
|
|
292
|
+
/** Skip processing when the source extension matches one of these formats. */
|
|
293
|
+
skipProcessing?: string[];
|
|
294
|
+
/** Return the source without any processing. */
|
|
295
|
+
raw?: boolean;
|
|
296
|
+
/** Ignored cache-busting value. */
|
|
297
|
+
cacheBuster?: string;
|
|
298
|
+
/** Unix timestamp after which the URL returns 404. */
|
|
299
|
+
expires?: number;
|
|
300
|
+
/** Override the download filename in Content-Disposition. */
|
|
301
|
+
filename?: string;
|
|
302
|
+
/** When true, set Content-Disposition: attachment. */
|
|
303
|
+
returnAttachment?: boolean;
|
|
304
|
+
/** Fallback image URL (base64url-encoded) to serve when the source fails. */
|
|
305
|
+
fallbackImageUrl?: string;
|
|
306
|
+
/** Expected checksum of the source image. */
|
|
307
|
+
hashsum?: {
|
|
308
|
+
type: string;
|
|
309
|
+
hash: string;
|
|
310
|
+
};
|
|
311
|
+
/** Max source resolution in megapixels. */
|
|
312
|
+
maxSrcResolution?: number;
|
|
313
|
+
/** Max source file size in bytes. */
|
|
314
|
+
maxSrcFileSize?: number;
|
|
315
|
+
/** Max animation frames. */
|
|
316
|
+
maxAnimationFrames?: number;
|
|
317
|
+
/** Max animation frame resolution in megapixels. */
|
|
318
|
+
maxAnimationFrameResolution?: number;
|
|
319
|
+
/** Max result width or height in pixels. */
|
|
320
|
+
maxResultDimension?: number;
|
|
321
|
+
}
|
|
322
|
+
/** Zod schema for runtime validation of parsed asset-proxy URL options. The `ParsedUrlInput` interface is the authoritative type definition; this schema validates against it at compile time via `satisfies`. */
|
|
323
|
+
export declare const parsedUrlSchema: z.ZodObject<{
|
|
324
|
+
resize: z.ZodOptional<z.ZodObject<{
|
|
325
|
+
type: z.ZodEnum<{
|
|
326
|
+
fill: "fill";
|
|
327
|
+
fit: "fit";
|
|
328
|
+
"fill-down": "fill-down";
|
|
329
|
+
force: "force";
|
|
330
|
+
auto: "auto";
|
|
331
|
+
}>;
|
|
332
|
+
width: z.ZodNumber;
|
|
333
|
+
height: z.ZodNumber;
|
|
334
|
+
}, z.core.$strip>>;
|
|
335
|
+
resizingAlgorithm: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
336
|
+
mode: z.ZodLiteral<"cpu">;
|
|
337
|
+
algorithm: z.ZodEnum<{
|
|
338
|
+
nearest: "nearest";
|
|
339
|
+
linear: "linear";
|
|
340
|
+
cubic: "cubic";
|
|
341
|
+
lanczos2: "lanczos2";
|
|
342
|
+
lanczos3: "lanczos3";
|
|
343
|
+
}>;
|
|
344
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
345
|
+
mode: z.ZodLiteral<"gpu">;
|
|
346
|
+
scaler: z.ZodEnum<{
|
|
347
|
+
scale_cuda: "scale_cuda";
|
|
348
|
+
scale_npp: "scale_npp";
|
|
349
|
+
}>;
|
|
350
|
+
algorithm: z.ZodOptional<z.ZodEnum<{
|
|
351
|
+
nearest: "nearest";
|
|
352
|
+
linear: "linear";
|
|
353
|
+
cubic: "cubic";
|
|
354
|
+
lanczos2: "lanczos2";
|
|
355
|
+
lanczos3: "lanczos3";
|
|
356
|
+
}>>;
|
|
357
|
+
}, z.core.$strip>]>>;
|
|
358
|
+
sourceUrl: z.ZodString;
|
|
359
|
+
outputFormat: z.ZodUnion<readonly [z.ZodEnum<{
|
|
360
|
+
mp4: "mp4";
|
|
361
|
+
webm: "webm";
|
|
362
|
+
}>, z.ZodEnum<{
|
|
363
|
+
jpg: "jpg";
|
|
364
|
+
png: "png";
|
|
365
|
+
webp: "webp";
|
|
366
|
+
avif: "avif";
|
|
367
|
+
gif: "gif";
|
|
368
|
+
}>]>;
|
|
369
|
+
minWidth: z.ZodOptional<z.ZodNumber>;
|
|
370
|
+
minHeight: z.ZodOptional<z.ZodNumber>;
|
|
371
|
+
extend: z.ZodOptional<z.ZodObject<{
|
|
372
|
+
enabled: z.ZodBoolean;
|
|
373
|
+
gravity: z.ZodEnum<{
|
|
374
|
+
no: "no";
|
|
375
|
+
so: "so";
|
|
376
|
+
ea: "ea";
|
|
377
|
+
we: "we";
|
|
378
|
+
noea: "noea";
|
|
379
|
+
nowe: "nowe";
|
|
380
|
+
soea: "soea";
|
|
381
|
+
sowe: "sowe";
|
|
382
|
+
ce: "ce";
|
|
383
|
+
}>;
|
|
384
|
+
}, z.core.$strip>>;
|
|
385
|
+
extendAspectRatio: z.ZodOptional<z.ZodObject<{
|
|
386
|
+
enabled: z.ZodBoolean;
|
|
387
|
+
gravity: z.ZodEnum<{
|
|
388
|
+
no: "no";
|
|
389
|
+
so: "so";
|
|
390
|
+
ea: "ea";
|
|
391
|
+
we: "we";
|
|
392
|
+
noea: "noea";
|
|
393
|
+
nowe: "nowe";
|
|
394
|
+
soea: "soea";
|
|
395
|
+
sowe: "sowe";
|
|
396
|
+
ce: "ce";
|
|
397
|
+
}>;
|
|
398
|
+
}, z.core.$strip>>;
|
|
399
|
+
framerate: z.ZodOptional<z.ZodNumber>;
|
|
400
|
+
cut: z.ZodOptional<z.ZodNumber>;
|
|
401
|
+
mute: z.ZodOptional<z.ZodBoolean>;
|
|
402
|
+
trim: z.ZodOptional<z.ZodObject<{
|
|
403
|
+
threshold: z.ZodNumber;
|
|
404
|
+
colour: z.ZodOptional<z.ZodString>;
|
|
405
|
+
equalHor: z.ZodBoolean;
|
|
406
|
+
equalVert: z.ZodBoolean;
|
|
407
|
+
}, z.core.$strip>>;
|
|
408
|
+
brightness: z.ZodNumber;
|
|
409
|
+
contrast: z.ZodNumber;
|
|
410
|
+
saturation: z.ZodNumber;
|
|
411
|
+
monochrome: z.ZodOptional<z.ZodObject<{
|
|
412
|
+
intensity: z.ZodNumber;
|
|
413
|
+
colour: z.ZodString;
|
|
414
|
+
}, z.core.$strip>>;
|
|
415
|
+
duotone: z.ZodOptional<z.ZodObject<{
|
|
416
|
+
intensity: z.ZodNumber;
|
|
417
|
+
colour1: z.ZodString;
|
|
418
|
+
colour2: z.ZodString;
|
|
419
|
+
}, z.core.$strip>>;
|
|
420
|
+
quality: z.ZodOptional<z.ZodNumber>;
|
|
421
|
+
formatQuality: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
422
|
+
autoquality: z.ZodOptional<z.ZodObject<{
|
|
423
|
+
method: z.ZodEnum<{
|
|
424
|
+
size: "size";
|
|
425
|
+
dssim: "dssim";
|
|
426
|
+
}>;
|
|
427
|
+
target: z.ZodNumber;
|
|
428
|
+
min: z.ZodNumber;
|
|
429
|
+
max: z.ZodNumber;
|
|
430
|
+
allowedError: z.ZodNumber;
|
|
431
|
+
}, z.core.$strip>>;
|
|
432
|
+
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
433
|
+
jpegOptions: z.ZodOptional<z.ZodObject<{
|
|
434
|
+
progressive: z.ZodBoolean;
|
|
435
|
+
noSubsample: z.ZodBoolean;
|
|
436
|
+
trellisQuant: z.ZodBoolean;
|
|
437
|
+
overshootDeringing: z.ZodBoolean;
|
|
438
|
+
optimizeScans: z.ZodBoolean;
|
|
439
|
+
quantTable: z.ZodOptional<z.ZodNumber>;
|
|
440
|
+
}, z.core.$strip>>;
|
|
441
|
+
pngOptions: z.ZodOptional<z.ZodObject<{
|
|
442
|
+
interlaced: z.ZodBoolean;
|
|
443
|
+
quantize: z.ZodBoolean;
|
|
444
|
+
quantizationColours: z.ZodOptional<z.ZodNumber>;
|
|
445
|
+
}, z.core.$strip>>;
|
|
446
|
+
webpOptions: z.ZodOptional<z.ZodObject<{
|
|
447
|
+
compression: z.ZodOptional<z.ZodNumber>;
|
|
448
|
+
smartSubsample: z.ZodBoolean;
|
|
449
|
+
preset: z.ZodOptional<z.ZodString>;
|
|
450
|
+
}, z.core.$strip>>;
|
|
451
|
+
avifOptions: z.ZodOptional<z.ZodObject<{
|
|
452
|
+
subsample: z.ZodOptional<z.ZodString>;
|
|
453
|
+
}, z.core.$strip>>;
|
|
454
|
+
blur: z.ZodOptional<z.ZodNumber>;
|
|
455
|
+
sharpen: z.ZodOptional<z.ZodNumber>;
|
|
456
|
+
pixelate: z.ZodOptional<z.ZodNumber>;
|
|
457
|
+
unsharpMasking: z.ZodOptional<z.ZodObject<{
|
|
458
|
+
mode: z.ZodString;
|
|
459
|
+
weight: z.ZodNumber;
|
|
460
|
+
divider: z.ZodNumber;
|
|
461
|
+
}, z.core.$strip>>;
|
|
462
|
+
colorize: z.ZodOptional<z.ZodObject<{
|
|
463
|
+
opacity: z.ZodNumber;
|
|
464
|
+
colour: z.ZodString;
|
|
465
|
+
keepAlpha: z.ZodBoolean;
|
|
466
|
+
}, z.core.$strip>>;
|
|
467
|
+
gradient: z.ZodOptional<z.ZodObject<{
|
|
468
|
+
opacity: z.ZodNumber;
|
|
469
|
+
colour: z.ZodString;
|
|
470
|
+
direction: z.ZodString;
|
|
471
|
+
start: z.ZodNumber;
|
|
472
|
+
stop: z.ZodNumber;
|
|
473
|
+
}, z.core.$strip>>;
|
|
474
|
+
rotate: z.ZodOptional<z.ZodNumber>;
|
|
475
|
+
flip: z.ZodOptional<z.ZodObject<{
|
|
476
|
+
horizontal: z.ZodBoolean;
|
|
477
|
+
vertical: z.ZodBoolean;
|
|
478
|
+
}, z.core.$strip>>;
|
|
479
|
+
autoRotate: z.ZodOptional<z.ZodBoolean>;
|
|
480
|
+
background: z.ZodOptional<z.ZodObject<{
|
|
481
|
+
r: z.ZodNumber;
|
|
482
|
+
g: z.ZodNumber;
|
|
483
|
+
b: z.ZodNumber;
|
|
484
|
+
}, z.core.$strip>>;
|
|
485
|
+
backgroundAlpha: z.ZodOptional<z.ZodNumber>;
|
|
486
|
+
padding: z.ZodOptional<z.ZodObject<{
|
|
487
|
+
top: z.ZodNumber;
|
|
488
|
+
right: z.ZodNumber;
|
|
489
|
+
bottom: z.ZodNumber;
|
|
490
|
+
left: z.ZodNumber;
|
|
491
|
+
}, z.core.$strip>>;
|
|
492
|
+
stripMetadata: z.ZodOptional<z.ZodBoolean>;
|
|
493
|
+
keepCopyright: z.ZodOptional<z.ZodBoolean>;
|
|
494
|
+
stripColorProfile: z.ZodOptional<z.ZodBoolean>;
|
|
495
|
+
dpi: z.ZodOptional<z.ZodNumber>;
|
|
496
|
+
enforceThumbnail: z.ZodOptional<z.ZodBoolean>;
|
|
497
|
+
videoThumbnailSecond: z.ZodOptional<z.ZodNumber>;
|
|
498
|
+
videoThumbnailKeyframes: z.ZodOptional<z.ZodBoolean>;
|
|
499
|
+
videoThumbnailAnimation: z.ZodOptional<z.ZodObject<{
|
|
500
|
+
step: z.ZodNumber;
|
|
501
|
+
delay: z.ZodNumber;
|
|
502
|
+
frames: z.ZodNumber;
|
|
503
|
+
frameWidth: z.ZodNumber;
|
|
504
|
+
frameHeight: z.ZodNumber;
|
|
505
|
+
extendFrame: z.ZodBoolean;
|
|
506
|
+
trim: z.ZodBoolean;
|
|
507
|
+
fill: z.ZodBoolean;
|
|
508
|
+
focusX: z.ZodNumber;
|
|
509
|
+
focusY: z.ZodNumber;
|
|
510
|
+
}, z.core.$strip>>;
|
|
511
|
+
crop: z.ZodOptional<z.ZodObject<{
|
|
512
|
+
width: z.ZodNumber;
|
|
513
|
+
height: z.ZodNumber;
|
|
514
|
+
gravity: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
515
|
+
no: "no";
|
|
516
|
+
so: "so";
|
|
517
|
+
ea: "ea";
|
|
518
|
+
we: "we";
|
|
519
|
+
noea: "noea";
|
|
520
|
+
nowe: "nowe";
|
|
521
|
+
soea: "soea";
|
|
522
|
+
sowe: "sowe";
|
|
523
|
+
ce: "ce";
|
|
524
|
+
}>, z.ZodObject<{
|
|
525
|
+
type: z.ZodLiteral<"fp">;
|
|
526
|
+
x: z.ZodNumber;
|
|
527
|
+
y: z.ZodNumber;
|
|
528
|
+
}, z.core.$strip>]>>;
|
|
529
|
+
}, z.core.$strip>>;
|
|
530
|
+
cropAspectRatio: z.ZodOptional<z.ZodNumber>;
|
|
531
|
+
gravity: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
532
|
+
no: "no";
|
|
533
|
+
so: "so";
|
|
534
|
+
ea: "ea";
|
|
535
|
+
we: "we";
|
|
536
|
+
noea: "noea";
|
|
537
|
+
nowe: "nowe";
|
|
538
|
+
soea: "soea";
|
|
539
|
+
sowe: "sowe";
|
|
540
|
+
ce: "ce";
|
|
541
|
+
}>, z.ZodObject<{
|
|
542
|
+
type: z.ZodLiteral<"fp">;
|
|
543
|
+
x: z.ZodNumber;
|
|
544
|
+
y: z.ZodNumber;
|
|
545
|
+
}, z.core.$strip>]>>;
|
|
546
|
+
enlarge: z.ZodOptional<z.ZodBoolean>;
|
|
547
|
+
bestFormat: z.ZodOptional<z.ZodBoolean>;
|
|
548
|
+
skipProcessing: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
549
|
+
raw: z.ZodOptional<z.ZodBoolean>;
|
|
550
|
+
cacheBuster: z.ZodOptional<z.ZodString>;
|
|
551
|
+
expires: z.ZodOptional<z.ZodNumber>;
|
|
552
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
553
|
+
returnAttachment: z.ZodOptional<z.ZodBoolean>;
|
|
554
|
+
fallbackImageUrl: z.ZodOptional<z.ZodString>;
|
|
555
|
+
hashsum: z.ZodOptional<z.ZodObject<{
|
|
556
|
+
type: z.ZodString;
|
|
557
|
+
hash: z.ZodString;
|
|
558
|
+
}, z.core.$strip>>;
|
|
559
|
+
maxSrcResolution: z.ZodOptional<z.ZodNumber>;
|
|
560
|
+
maxSrcFileSize: z.ZodOptional<z.ZodNumber>;
|
|
561
|
+
maxAnimationFrames: z.ZodOptional<z.ZodNumber>;
|
|
562
|
+
maxAnimationFrameResolution: z.ZodOptional<z.ZodNumber>;
|
|
563
|
+
maxResultDimension: z.ZodOptional<z.ZodNumber>;
|
|
564
|
+
}, z.core.$strip>;
|
|
565
|
+
/** Fully parsed URL with all processing options validated. */
|
|
566
|
+
export type ParsedUrl = z.output<typeof parsedUrlSchema>;
|
|
567
|
+
export type ImageUrl = ParsedUrl & {
|
|
568
|
+
outputFormat: ImageFormat;
|
|
569
|
+
};
|
|
570
|
+
export type VideoUrl = ParsedUrl & {
|
|
571
|
+
outputFormat: VideoFormat;
|
|
572
|
+
};
|
|
573
|
+
export declare function isImageUrl(parsed: ParsedUrl): parsed is ImageUrl;
|
|
574
|
+
export declare function isVideoUrl(parsed: ParsedUrl): parsed is VideoUrl;
|
|
575
|
+
export interface ParseOptions {
|
|
576
|
+
/** AES-256-CBC key for decrypting `/enc/` source URLs. */
|
|
577
|
+
encryptionKey?: Buffer;
|
|
578
|
+
}
|
|
579
|
+
/** Parses an imgproxy-format processing path (after signature has been stripped). Supports `/<options>/plain/<source_url>[@<format>]` and `/<options>/enc/<encrypted_source_url>[@<format>]`. */
|
|
580
|
+
export declare function parseProcessingUrl(path: string, options?: ParseOptions): ParsedUrl;
|
|
581
|
+
export {};
|