@lonik/oh-image 2.2.1 → 2.2.2

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.
@@ -1,30 +1,34 @@
1
- import { s as ImageLoaderOptions } from "./index-Dk2EZWhe.js";
1
+ import { s as ImageLoaderOptions } from "./index-BXVRSiZA.js";
2
2
  import { n as BaseLoaderOptions, r as BaseLoaderTransforms, t as BaseGlobalLoaderOptions } from "./base-loader-options-C1EZVxmE.js";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/loaders/cloudflare/cloudflare-options.d.ts
6
6
  type CloudflareTransforms = BaseLoaderTransforms & Partial<{
7
- anim?: boolean;
8
- background?: string;
9
- blur?: number;
10
- brightness?: number;
11
- compression?: boolean;
12
- contrast?: number;
13
- dpr?: number;
14
- dprs?: number[];
15
- fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
16
- format?: "auto" | "avif" | "webp" | "json";
17
- gamma?: number;
18
- gravity?: "auto" | "left" | "right" | "top" | "bottom" | string;
19
- height?: number;
20
- width?: number;
21
- widths?: number[];
22
- maxWidth?: number;
23
- metadata?: "keep" | "copyright" | "none";
24
- quality?: number;
25
- rotate?: number;
26
- sharpen?: number;
27
- trim?: string;
7
+ anim: boolean;
8
+ background: string;
9
+ blur: number;
10
+ brightness: number;
11
+ compression: "fast";
12
+ contrast: number;
13
+ dpr: number;
14
+ flip: "h" | "v" | "hv";
15
+ fit: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
16
+ format: "auto" | "avif" | "webp" | "jpeg" | "baseline-jpeg";
17
+ gamma: number;
18
+ gravity: "auto" | "left" | "right" | "top" | "bottom" | string;
19
+ height: number;
20
+ width: number;
21
+ maxWidth: number;
22
+ metadata: "keep" | "copyright" | "none";
23
+ quality: number | "high" | "medium-high" | "medium-low" | "low";
24
+ rotate: number;
25
+ sharpen: number;
26
+ trim: [number, number, number, number];
27
+ zoom: number;
28
+ saturation: number;
29
+ segment: "foreground";
30
+ onerror: "redirect";
31
+ "slow-connection-quality": number;
28
32
  }>;
29
33
  type CloudflareOptions = BaseLoaderOptions<CloudflareTransforms>;
30
34
  type CloudflareGlobalOptions = BaseGlobalLoaderOptions<CloudflareTransforms>;
@@ -1,4 +1,4 @@
1
- import { t as loaderFactory } from "./loader-factory-dkIeg239.js";
1
+ import { t as loaderFactory } from "./loader-factory-C1301CZd.js";
2
2
 
3
3
  //#region src/loaders/cloudflare/cloudflare-loader.tsx
4
4
  const { useLoaderContext: useCloudflareContext, LoaderProvider: CloudflareLoaderProvider, useLoader: useCloudflareLoader } = loaderFactory({
@@ -9,7 +9,9 @@ const { useLoaderContext: useCloudflareContext, LoaderProvider: CloudflareLoader
9
9
  }
10
10
  }, {
11
11
  optionSeparator: "=",
12
- paramSeparator: ","
12
+ paramSeparator: ",",
13
+ passBooleanValue: true,
14
+ customResolver: { trim: (key, value) => `${key}=${value.join(";")}` }
13
15
  }, ({ path, params, imageOptions }) => `${path}/cdn-cgi/image/${params}/${imageOptions.src}`);
14
16
 
15
17
  //#endregion
@@ -1,6 +1,6 @@
1
- import { s as ImageLoaderOptions } from "./index-Dk2EZWhe.js";
1
+ import { s as ImageLoaderOptions } from "./index-BXVRSiZA.js";
2
2
  import { n as BaseLoaderOptions, r as BaseLoaderTransforms, t as BaseGlobalLoaderOptions } from "./base-loader-options-C1EZVxmE.js";
3
- import * as react_jsx_runtime3 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/loaders/cloudinary/cloudinary-options.d.ts
6
6
  type BACKGROUND_MODE = "border" | "predominant" | "border_contrast" | "predominant_contrast" | "predominant_gradient" | "predominant_gradient_contrast" | "border_gradient" | "border_gradient_contrast";
@@ -106,6 +106,6 @@ declare const useCloudinaryContext: () => CloudinaryGlobalOptions, CloudinaryLoa
106
106
  ...props
107
107
  }: {
108
108
  children: React.ReactNode;
109
- } & Partial<CloudinaryGlobalOptions>) => react_jsx_runtime3.JSX.Element, useCloudinaryLoader: (options?: CloudinaryGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
109
+ } & Partial<CloudinaryGlobalOptions>) => react_jsx_runtime0.JSX.Element, useCloudinaryLoader: (options?: CloudinaryGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
110
110
  //#endregion
111
111
  export { CloudinaryGlobalOptions, CloudinaryLoaderProvider, CloudinaryOptions, CloudinaryTransforms, useCloudinaryContext, useCloudinaryLoader };
@@ -1,4 +1,4 @@
1
- import { t as loaderFactory } from "./loader-factory-dkIeg239.js";
1
+ import { t as loaderFactory } from "./loader-factory-C1301CZd.js";
2
2
 
3
3
  //#region src/loaders/cloudinary/cloudinary-loader.tsx
4
4
  function customResolver(key, value) {
@@ -17,13 +17,13 @@ const { useLoaderContext: useCloudinaryContext, LoaderProvider: CloudinaryLoader
17
17
  widthKey: "w",
18
18
  heightKey: "h",
19
19
  orders: {
20
- b_auto: [
20
+ b_auto: { orders: [
21
21
  "mode",
22
22
  "number",
23
23
  "direction",
24
24
  "color"
25
- ],
26
- b_gen_fill: ["prompt", "seed"]
25
+ ] },
26
+ b_gen_fill: { orders: ["prompt", "seed"] }
27
27
  },
28
28
  customResolver: {
29
29
  art: customResolver,
@@ -1,11 +1,12 @@
1
- import { s as ImageLoaderOptions } from "./index-Dk2EZWhe.js";
1
+ import { s as ImageLoaderOptions } from "./index-BXVRSiZA.js";
2
2
  import { n as BaseLoaderOptions, r as BaseLoaderTransforms, t as BaseGlobalLoaderOptions } from "./base-loader-options-C1EZVxmE.js";
3
- import * as react_jsx_runtime4 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/loaders/imgproxy/imgproxy-options.d.ts
6
6
  type ResizeType = "fit" | "fill" | "fill-down" | "force" | "auto";
7
7
  type ResizeAlgorithm = "nearest" | "linear" | "cubic" | "lanczos2" | "lanczos3";
8
8
  type GravityType = "no" | "so" | "ea" | "we" | "noea" | "nowe" | "soea" | "sowe" | "ce";
9
+ type HashSumTypes = "none" | "md5" | "sha1" | "sha256" | "sha512";
9
10
  interface ResizeOptions {
10
11
  resizing_type?: ResizeType;
11
12
  width?: number;
@@ -31,7 +32,7 @@ interface GravityOptions {
31
32
  interface CropOptions {
32
33
  width: number;
33
34
  height: number;
34
- gravity?: GravityType;
35
+ gravity?: GravityOptions;
35
36
  }
36
37
  interface TrimOptions {
37
38
  threshold: number;
@@ -57,11 +58,11 @@ interface AdjustOptions {
57
58
  }
58
59
  interface BlurDetectionsOptions {
59
60
  sigma: number;
60
- class_names: string[];
61
+ class_names?: string[];
61
62
  }
62
63
  interface DrawDetectionsOptions {
63
64
  draw: boolean;
64
- class_names: string[];
65
+ class_names?: string[];
65
66
  }
66
67
  interface WatermarkOptions {
67
68
  opacity: number;
@@ -75,7 +76,7 @@ interface WatermarkSizeOptions {
75
76
  height: number;
76
77
  }
77
78
  interface UnsharpeningOptions {
78
- mode?: string;
79
+ mode: "auto" | "sharpen" | "none" | "always";
79
80
  weight?: number;
80
81
  dividor?: number;
81
82
  }
@@ -104,47 +105,47 @@ type ImgproxyTransforms = BaseLoaderTransforms & Partial<{
104
105
  * Defines the resizing type, width, height, enlarge, and extend.
105
106
  * All arguments are optional and can be omitted to use their default values.
106
107
  */
107
- resize?: ResizeOptions;
108
+ resize: ResizeOptions;
108
109
  /**
109
110
  * Defines the width, height, enlarge, and extend.
110
111
  * All arguments are optional and can be omitted to use their default values.
111
112
  */
112
- size?: SizeOptions;
113
+ size: SizeOptions;
113
114
  /**
114
115
  * Defines how imgproxy will resize the source image.
115
116
  * Default: fit
116
117
  */
117
- resizing_type?: ResizeType;
118
+ resizing_type: ResizeType;
118
119
  /**
119
120
  * Defines the algorithm that imgproxy will use for resizing.
120
121
  * Default: lanczos3
121
122
  */
122
- resizing_algorithm?: ResizeAlgorithm;
123
+ resizing_algorithm: ResizeAlgorithm;
123
124
  /**
124
125
  * Defines the width of the resulting image.
125
126
  * Default: 0
126
127
  */
127
- width?: number;
128
+ width: number;
128
129
  /**
129
130
  * Defines the height of the resulting image.
130
131
  * Default: 0
131
132
  */
132
- height?: number;
133
+ height: number;
133
134
  /**
134
135
  * Defines the minimum width of the resulting image.
135
136
  * Default: 0
136
137
  */
137
- "min-width"?: number;
138
+ "min-width": number;
138
139
  /**
139
140
  * Defines the minimum height of the resulting image.
140
141
  * Default: 0
141
142
  */
142
- "min-height"?: number;
143
+ "min-height": number;
143
144
  /**
144
145
  * When set, imgproxy will multiply the image dimensions according to these factors.
145
146
  * Default: 1
146
147
  */
147
- zoom?: number | {
148
+ zoom: number | {
148
149
  x: number;
149
150
  y: number;
150
151
  };
@@ -152,215 +153,226 @@ type ImgproxyTransforms = BaseLoaderTransforms & Partial<{
152
153
  * When set, imgproxy will multiply the image dimensions according to this factor for HiDPI (Retina) devices.
153
154
  * Default: 1
154
155
  */
155
- dpr?: number;
156
+ dpr: number;
156
157
  /**
157
158
  * When set to true, imgproxy will enlarge the image if it is smaller than the given size.
158
159
  * Default: false
159
160
  */
160
- enlarge?: boolean;
161
+ enlarge: boolean;
161
162
  /**
162
163
  * When set to true, imgproxy will extend the image if it is smaller than the given size.
163
164
  * Can also specify gravity.
164
165
  * Default: false:ce:0:0
165
166
  */
166
- extend?: boolean | ExtendOptions;
167
- /**
168
- * When imgproxy needs to cut some parts of the image, it is guided by the gravity option.
169
- * Default: ce:0:0
170
- */
171
- gravity?: GravityOptions;
172
- /**
173
- * Defines an area of the image to be processed (crop before resize).
174
- */
175
- crop?: CropOptions;
167
+ extend: boolean | ExtendOptions;
168
+ gravity: GravityOptions;
169
+ crop: CropOptions;
176
170
  /**
177
171
  * Removes surrounding background.
178
172
  */
179
- trim?: TrimOptions;
173
+ trim: TrimOptions;
180
174
  /**
181
175
  * Defines padding size.
182
176
  */
183
- padding?: PaddingOptions;
177
+ padding: PaddingOptions;
184
178
  /**
185
179
  * When set to true, imgproxy will automatically rotate images based on the EXIF Orientation parameter.
186
180
  */
187
- auto_rotate?: boolean;
181
+ auto_rotate: boolean;
188
182
  /**
189
183
  * Rotates the image on the specified angle.
190
184
  * Default: 0
191
185
  */
192
- rotate?: number;
186
+ rotate: number;
193
187
  /**
194
188
  * When set, imgproxy will fill the resulting image background with the specified color.
195
189
  * Default: disabled
196
190
  */
197
- background?: string | BackgroundOptions;
191
+ background: string | BackgroundOptions;
198
192
  /**
199
193
  * Adds an alpha channel to background.
200
194
  * Default: 1
201
195
  */
202
- background_alpha?: number;
196
+ background_alpha: number;
203
197
  /**
204
198
  * Defines the brightness, contrast, and saturation.
205
199
  */
206
- adjust?: AdjustOptions;
200
+ adjust: AdjustOptions;
207
201
  /**
208
202
  * When set, imgproxy will adjust brightness of the resulting image.
209
203
  * Default: 0
210
204
  */
211
- brightness?: number;
205
+ brightness: number;
212
206
  /**
213
207
  * When set, imgproxy will adjust the contrast of the resulting image.
214
208
  * Default: 1
215
209
  */
216
- contrast?: number;
210
+ contrast: number;
217
211
  /**
218
212
  * When set, imgproxy will adjust saturation of the resulting image.
219
213
  * Default: 1
220
214
  */
221
- saturation?: number;
215
+ saturation: number;
222
216
  /**
223
217
  * When set, imgproxy will apply a gaussian blur filter to the resulting image.
224
218
  * Default: disabled
225
219
  */
226
- blur?: number;
220
+ blur: number;
227
221
  /**
228
222
  * When set, imgproxy will apply the sharpen filter to the resulting image.
229
223
  * Default: disabled
230
224
  */
231
- sharpen?: number;
225
+ sharpen: number;
232
226
  /**
233
227
  * When set, imgproxy will apply the pixelate filter to the resulting image.
234
228
  * Default: disabled
235
229
  */
236
- pixelate?: number;
230
+ pixelate: number;
237
231
  /**
238
232
  * Allows redefining unsharpening options.
239
233
  */
240
- unsharpening?: UnsharpeningOptions;
234
+ unsharpening: UnsharpeningOptions;
241
235
  /**
242
236
  * imgproxy detects objects of the provided classes and blurs them.
243
237
  */
244
- blur_detections?: BlurDetectionsOptions;
238
+ blur_detections: BlurDetectionsOptions;
245
239
  /**
246
240
  * When draw is set to true, imgproxy detects objects of the provided classes and draws their bounding boxes.
247
241
  */
248
- draw_detections?: DrawDetectionsOptions;
242
+ draw_detections: DrawDetectionsOptions;
249
243
  /**
250
244
  * Places a watermark on the processed image.
251
245
  * Default: disabled
252
246
  */
253
- watermark?: WatermarkOptions;
247
+ watermark: WatermarkOptions;
254
248
  /**
255
249
  * When set, imgproxy will use the image from the specified URL as a watermark.
256
250
  * Default: blank
257
251
  */
258
- watermark_url?: string;
252
+ watermark_url: string;
259
253
  /**
260
254
  * When set, imgproxy will generate an image from the provided text and use it as a watermark.
261
255
  * Default: blank
262
256
  */
263
- watermark_text?: string;
257
+ watermark_text: string;
264
258
  /**
265
259
  * Defines the desired width and height of the watermark.
266
260
  * Default: 0:0
267
261
  */
268
- watermark_size?: WatermarkSizeOptions;
269
- /**
270
- * When set, imgproxy will prepend a <style> node with the provided content to the <svg> node.
271
- * Default: blank
272
- */
273
- style?: string;
262
+ watermark_size: WatermarkSizeOptions;
263
+ style: string;
274
264
  /**
275
265
  * When set to true, imgproxy will strip the metadata (EXIF, IPTC, etc.) on JPEG and WebP output images.
276
266
  */
277
- strip_metadata?: boolean;
267
+ strip_metadata: boolean;
278
268
  /**
279
269
  * When set to true, imgproxy will not remove copyright info while stripping metadata.
280
270
  */
281
- keep_copyright?: boolean;
271
+ keep_copyright: boolean;
282
272
  /**
283
273
  * When set to true, imgproxy will transform the embedded color profile (ICC) to sRGB and remove it from the image.
284
274
  */
285
- strip_color_profile?: boolean;
275
+ strip_color_profile: boolean;
286
276
  /**
287
277
  * When set to true and the source image has an embedded thumbnail, imgproxy will always use the embedded thumbnail.
288
278
  */
289
- enforce_thumbnail?: boolean;
279
+ enforce_thumbnail: boolean;
290
280
  /**
291
281
  * When set to true, imgproxy will return attachment in the Content-Disposition header.
292
282
  */
293
- return_attachment?: boolean;
283
+ return_attachment: boolean;
294
284
  /**
295
285
  * Redefines quality of the resulting image, as a percentage.
296
286
  * Default: 0
297
287
  */
298
- quality?: number;
288
+ quality: number;
299
289
  /**
300
290
  * Adds or redefines IMGPROXY_FORMAT_QUALITY values.
301
291
  */
302
- format_quality?: Record<string, number>;
292
+ format_quality: Record<string, number>;
303
293
  /**
304
294
  * Redefines autoquality settings.
305
295
  */
306
- autoquality?: AutoqualityOptions;
296
+ autoquality: AutoqualityOptions;
307
297
  /**
308
298
  * When set, imgproxy automatically degrades the quality of the image until the image size is under the specified amount of bytes.
309
299
  * Default: 0
310
300
  */
311
- max_bytes?: number;
301
+ max_bytes: number;
312
302
  /**
313
303
  * Allows redefining JPEG saving options.
314
304
  */
315
- jpeg_options?: JpegOptions;
305
+ jpeg_options: JpegOptions;
316
306
  /**
317
307
  * Allows redefining PNG saving options.
318
308
  */
319
- png_options?: PngOptions;
309
+ png_options: PngOptions;
320
310
  /**
321
311
  * Specifies the resulting image format.
322
312
  * Default: jpg
323
313
  */
324
- format?: string;
325
- /**
326
- * When a source image supports pagination or animation, this option allows specifying the page to use it on.
327
- * Default: 0
328
- */
329
- page?: number;
314
+ format: string;
330
315
  /**
331
316
  * Allows redefining IMGPROXY_VIDEO_THUMBNAIL_SECOND config.
332
317
  */
333
- video_thumbnail_second?: number;
318
+ video_thumbnail_second: number;
334
319
  /**
335
320
  * You can use a custom fallback image by specifying its URL.
336
321
  * Default: blank
337
322
  */
338
- fallback_image_url?: string;
323
+ fallback_image_url: string;
339
324
  /**
340
325
  * When set, imgproxy will skip the processing of the listed formats.
341
326
  * Default: empty
342
327
  */
343
- skip_processing?: string[];
328
+ skip_processing: string[];
344
329
  /**
345
330
  * Cache buster doesn't affect image processing but its changing allows for bypassing the CDN, proxy server and browser cache.
346
331
  * Default: empty
347
332
  */
348
- cachebuster?: string;
333
+ cachebuster: string;
349
334
  /**
350
335
  * When set, imgproxy will check the provided unix timestamp and return 404 when expired.
351
336
  * Default: empty
352
337
  */
353
- expires?: number;
338
+ expires: number;
354
339
  /**
355
340
  * Defines a filename for the Content-Disposition header.
356
341
  * Default: empty
357
342
  */
358
- filename?: string;
343
+ filename: string;
359
344
  /**
360
345
  * Defines a list of presets to be used by imgproxy.
361
346
  * Default: empty
362
347
  */
363
- preset?: string[];
348
+ preset: string[];
349
+ dpi: number;
350
+ duotone: {
351
+ intensity?: number;
352
+ color1?: string;
353
+ color2?: string;
354
+ };
355
+ extend_aspect_ratio: {
356
+ extend: boolean;
357
+ gravity?: GravityOptions;
358
+ };
359
+ gradient: {
360
+ opacity: number;
361
+ color?: string;
362
+ direction?: string;
363
+ start?: number;
364
+ stop?: number;
365
+ };
366
+ hashsum: {
367
+ type: HashSumTypes;
368
+ hashsum: string;
369
+ };
370
+ monochrome: {
371
+ intensity: number;
372
+ color?: string;
373
+ };
374
+ raw: boolean;
375
+ watermark_shadow: number;
364
376
  }>;
365
377
  type ImgproxyOptions = BaseLoaderOptions<ImgproxyTransforms>;
366
378
  type ImgproxyGlobalOptions = BaseGlobalLoaderOptions<ImgproxyTransforms>;
@@ -371,6 +383,6 @@ declare const useImgproxyContext: () => ImgproxyGlobalOptions, ImgproxyLoaderPro
371
383
  ...props
372
384
  }: {
373
385
  children: React.ReactNode;
374
- } & Partial<ImgproxyGlobalOptions>) => react_jsx_runtime4.JSX.Element, useImgproxyLoader: (options?: ImgproxyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
386
+ } & Partial<ImgproxyGlobalOptions>) => react_jsx_runtime1.JSX.Element, useImgproxyLoader: (options?: ImgproxyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
375
387
  //#endregion
376
388
  export { ImgproxyGlobalOptions, ImgproxyLoaderProvider, ImgproxyOptions, ImgproxyTransforms, useImgproxyContext, useImgproxyLoader };
package/dist/imgproxy.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as loaderFactory } from "./loader-factory-dkIeg239.js";
1
+ import { t as loaderFactory } from "./loader-factory-C1301CZd.js";
2
2
 
3
3
  //#region src/loaders/imgproxy/imgproxy-loader.tsx
4
4
  const { useLoaderContext: useImgproxyContext, LoaderProvider: ImgproxyLoaderProvider, useLoader: useImgproxyLoader } = loaderFactory({
@@ -8,91 +8,124 @@ const { useLoaderContext: useImgproxyContext, LoaderProvider: ImgproxyLoaderProv
8
8
  format: "webp"
9
9
  }
10
10
  }, {
11
+ passBooleanValue: true,
11
12
  optionSeparator: ":",
12
13
  paramSeparator: "/",
14
+ customResolver: { format_quality: (key, value) => {
15
+ return `${key}:${Object.entries(value).flatMap((entry) => entry).join(":")}`;
16
+ } },
13
17
  orders: {
14
- resize: [
18
+ hashsum: { orders: ["type", "hashsum"] },
19
+ duotone: { orders: [
20
+ "intensity",
21
+ "color1",
22
+ "color2"
23
+ ] },
24
+ gradient: { orders: [
25
+ "opacity",
26
+ "color",
27
+ "direction",
28
+ "start",
29
+ "stop"
30
+ ] },
31
+ monochrome: { orders: ["intensity", "color"] },
32
+ extend_aspect_ratio: {
33
+ orders: ["extend", "gravity"],
34
+ childrenOrders: { gravity: { orders: [
35
+ "type",
36
+ "x_offset",
37
+ "y_offset"
38
+ ] } }
39
+ },
40
+ resize: { orders: [
15
41
  "resizing_type",
16
42
  "width",
17
43
  "height",
18
44
  "enlarge",
19
45
  "extend"
20
- ],
21
- size: [
46
+ ] },
47
+ size: { orders: [
22
48
  "width",
23
49
  "height",
24
50
  "enlarge",
25
51
  "extend"
26
- ],
27
- extend: ["extend", "gravity"],
28
- gravity: [
52
+ ] },
53
+ extend: { orders: ["extend", "gravity"] },
54
+ gravity: { orders: [
29
55
  "type",
30
56
  "x_offset",
31
57
  "y_offset"
32
- ],
33
- crop: [
34
- "width",
35
- "height",
36
- "gravity"
37
- ],
38
- trim: [
58
+ ] },
59
+ crop: {
60
+ orders: [
61
+ "width",
62
+ "height",
63
+ "gravity"
64
+ ],
65
+ childrenOrders: { gravity: { orders: [
66
+ "type",
67
+ "x_offset",
68
+ "y_offset"
69
+ ] } }
70
+ },
71
+ trim: { orders: [
39
72
  "threshold",
40
73
  "color",
41
74
  "equal_hor",
42
75
  "equal_ver"
43
- ],
44
- padding: [
76
+ ] },
77
+ padding: { orders: [
45
78
  "top",
46
79
  "right",
47
80
  "bottom",
48
81
  "left"
49
- ],
50
- background: [
82
+ ] },
83
+ background: { orders: [
51
84
  "r",
52
85
  "g",
53
86
  "b"
54
- ],
55
- adjust: [
87
+ ] },
88
+ adjust: { orders: [
56
89
  "brightness",
57
90
  "contrast",
58
91
  "saturation"
59
- ],
60
- blur_detections: ["sigma", "class_names"],
61
- draw_detections: ["draw", "class_names"],
62
- watermark: [
92
+ ] },
93
+ blur_detections: { orders: ["sigma", "class_names"] },
94
+ draw_detections: { orders: ["draw", "class_names"] },
95
+ watermark: { orders: [
63
96
  "opacity",
64
97
  "position",
65
98
  "x_offset",
66
99
  "y_offset",
67
100
  "scale"
68
- ],
69
- watermark_size: ["width", "height"],
70
- unsharpening: [
101
+ ] },
102
+ watermark_size: { orders: ["width", "height"] },
103
+ unsharpening: { orders: [
71
104
  "mode",
72
105
  "weight",
73
106
  "dividor"
74
- ],
75
- autoquality: [
107
+ ] },
108
+ autoquality: { orders: [
76
109
  "method",
77
110
  "target",
78
111
  "min_quality",
79
112
  "max_quality",
80
113
  "allowed_error"
81
- ],
82
- jpeg_options: [
114
+ ] },
115
+ jpeg_options: { orders: [
83
116
  "progressive",
84
117
  "no_subsample",
85
118
  "trellis_quant",
86
119
  "overshoot_deringing",
87
120
  "optimize_scans",
88
121
  "quant_table"
89
- ],
90
- png_options: [
122
+ ] },
123
+ png_options: { orders: [
91
124
  "interlaced",
92
125
  "quantize",
93
126
  "quantization_colors"
94
- ],
95
- zoom: ["x", "y"]
127
+ ] },
128
+ zoom: { orders: ["x", "y"] }
96
129
  }
97
130
  }, ({ path, params, imageOptions }) => `${path}/${params}/plain/${imageOptions.src}`);
98
131
 
@@ -1,5 +1,5 @@
1
1
  import { ImgHTMLAttributes } from "react";
2
- import * as react_jsx_runtime1 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime4 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/react/types.d.ts
5
5
  interface ImageLoaderOptions {
@@ -30,10 +30,10 @@ interface ImageProps extends Partial<Pick<ImgHTMLAttributes<HTMLImageElement>, "
30
30
  }
31
31
  //#endregion
32
32
  //#region src/react/image.d.ts
33
- declare function Image(props: ImageProps): react_jsx_runtime1.JSX.Element;
33
+ declare function Image(props: ImageProps): react_jsx_runtime4.JSX.Element;
34
34
  //#endregion
35
35
  //#region src/react/image-factory.d.ts
36
- declare function __imageFactory(defaultProps: any): (props: any) => react_jsx_runtime1.JSX.Element;
36
+ declare function __imageFactory(defaultProps: any): (props: any) => react_jsx_runtime4.JSX.Element;
37
37
  //#endregion
38
38
  //#region src/react/use-img-loaded.d.ts
39
39
  /**
@@ -75,6 +75,6 @@ declare function ImageProvider({
75
75
  ...props
76
76
  }: {
77
77
  children: React.ReactNode;
78
- } & Partial<ImageContextValue>): react_jsx_runtime1.JSX.Element;
78
+ } & Partial<ImageContextValue>): react_jsx_runtime4.JSX.Element;
79
79
  //#endregion
80
80
  export { Image as a, ImageProps as c, __imageFactory as i, useImageContext as n, ImageLoader as o, useImgLoaded as r, ImageLoaderOptions as s, ImageProvider as t };
@@ -3,11 +3,26 @@ import { jsx } from "react/jsx-runtime";
3
3
 
4
4
  //#region src/loaders/transforms-resolver.ts
5
5
  const stringifyOptions = (opCode, values, separator) => {
6
- return [opCode, ...values.map((v) => v == null ? "" : encodeURIComponent(v))].join(separator);
6
+ return [opCode, ...values.map((v) => {
7
+ if (v == null) return "";
8
+ if (Array.isArray(v)) return v.map((val) => encodeURIComponent(val)).join(separator);
9
+ return encodeURIComponent(v);
10
+ })].join(separator);
7
11
  };
8
- const resolveObjectParam = (key, value, order, separator) => {
9
- if (!order) return;
10
- return stringifyOptions(key, order.map((k) => value[k]), separator);
12
+ const resolveObjectParam = (key, value, orderConfig, separator) => {
13
+ if (!orderConfig) return;
14
+ const { orders, childrenOrders } = orderConfig;
15
+ return [key, ...orders.map((k) => {
16
+ const val = value[k];
17
+ if (val === void 0 || val === null) return "";
18
+ if (childrenOrders && childrenOrders[k] && typeof val === "object" && !Array.isArray(val)) return childrenOrders[k].orders.map((childKey) => val[childKey]).map((v) => {
19
+ if (v == null) return "";
20
+ if (Array.isArray(v)) return v.map((val$1) => encodeURIComponent(String(val$1))).join(separator);
21
+ return encodeURIComponent(String(v));
22
+ }).join(separator);
23
+ if (Array.isArray(val)) return val.map((v) => encodeURIComponent(String(v))).join(separator);
24
+ return encodeURIComponent(String(val));
25
+ })].join(separator);
11
26
  };
12
27
  function resolveTransform(transforms, config) {
13
28
  if (!transforms) return [];
@@ -26,13 +41,16 @@ function resolveTransform(transforms, config) {
26
41
  }
27
42
  switch (type) {
28
43
  case "boolean":
29
- if (value === true) params.push(key);
44
+ if (value === true) if (config.passBooleanValue) params.push(stringifyOptions(key, [value], config.optionSeparator));
45
+ else params.push(key);
30
46
  break;
31
- case "object": {
32
- const objectParams = resolveObjectParam(key, value, config?.orders?.[key], config.optionSeparator);
33
- if (objectParams) params.push(objectParams);
47
+ case "object":
48
+ if (Array.isArray(value)) params.push(stringifyOptions(key, [value], config.optionSeparator));
49
+ else {
50
+ const objectParams = resolveObjectParam(key, value, config?.orders?.[key], config.optionSeparator);
51
+ if (objectParams) params.push(objectParams);
52
+ }
34
53
  break;
35
- }
36
54
  default:
37
55
  params.push(stringifyOptions(key, [value], config.optionSeparator));
38
56
  break;
package/dist/react.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as Image, c as ImageProps, i as __imageFactory, n as useImageContext, o as ImageLoader, r as useImgLoaded, s as ImageLoaderOptions, t as ImageProvider } from "./index-Dk2EZWhe.js";
1
+ import { a as Image, c as ImageProps, i as __imageFactory, n as useImageContext, o as ImageLoader, r as useImgLoaded, s as ImageLoaderOptions, t as ImageProvider } from "./index-BXVRSiZA.js";
2
2
  export { Image, ImageLoader, ImageLoaderOptions, ImageProps, ImageProvider, __imageFactory, useImageContext, useImgLoaded };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lonik/oh-image",
3
3
  "type": "module",
4
- "version": "2.2.1",
4
+ "version": "2.2.2",
5
5
  "description": "A React component library for optimized image handling.",
6
6
  "author": "Luka Onikadze <lukonik@gmail.com>",
7
7
  "license": "MIT",
@@ -97,9 +97,11 @@
97
97
  "vite": "^7.3.0",
98
98
  "vite-plugin-inspect": "^11.3.3",
99
99
  "vite-tsconfig-paths": "^6.1.1",
100
- "vitest": "^4.0.16"
100
+ "vitest": "^4.0.16",
101
+ "vitest-browser-react": "^2.0.5"
101
102
  },
102
103
  "dependencies": {
104
+ "@vitest/browser-playwright": "^4.0.18",
103
105
  "p-limit": "^7.3.0",
104
106
  "query-string": "^9.3.1"
105
107
  },