@lonik/oh-image 2.3.1 → 2.4.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/dist/cloudflare.d.ts +2 -2
- package/dist/cloudflare.js +1 -1
- package/dist/cloudinary.d.ts +4 -4
- package/dist/cloudinary.js +1 -1
- package/dist/contentful.d.ts +43 -0
- package/dist/contentful.js +20 -0
- package/dist/imgproxy.d.ts +4 -4
- package/dist/imgproxy.js +1 -1
- package/dist/{index-5t1nN_1J.d.ts → index-IjVrRcXi.d.ts} +4 -4
- package/dist/kontent.d.ts +4 -4
- package/dist/kontent.js +3 -1
- package/dist/{loader-factory-JhrhUvkg.js → loader-factory-CQDWe0k2.js} +8 -7
- package/dist/react.d.ts +1 -1
- package/package.json +5 -1
- /package/dist/{base-loader-options-BzrruYJ4.d.ts → base-loader-options-TbE7SU6o.d.ts} +0 -0
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as ImageLoaderOptions } from "./index-
|
|
2
|
-
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-
|
|
1
|
+
import { s as ImageLoaderOptions } from "./index-IjVrRcXi.js";
|
|
2
|
+
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-TbE7SU6o.js";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/loaders/cloudflare/cloudflare-options.d.ts
|
package/dist/cloudflare.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as loaderFactory } from "./loader-factory-
|
|
1
|
+
import { t as loaderFactory } from "./loader-factory-CQDWe0k2.js";
|
|
2
2
|
|
|
3
3
|
//#region src/loaders/cloudflare/cloudflare-loader.tsx
|
|
4
4
|
const { useLoaderContext: useCloudflareContext, LoaderProvider: CloudflareLoaderProvider, useLoader: useCloudflareLoader } = loaderFactory({
|
package/dist/cloudinary.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as ImageLoaderOptions } from "./index-
|
|
2
|
-
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-
|
|
3
|
-
import * as
|
|
1
|
+
import { s as ImageLoaderOptions } from "./index-IjVrRcXi.js";
|
|
2
|
+
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-TbE7SU6o.js";
|
|
3
|
+
import * as react_jsx_runtime1 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>) =>
|
|
109
|
+
} & Partial<CloudinaryGlobalOptions>) => react_jsx_runtime1.JSX.Element, useCloudinaryLoader: (options?: CloudinaryGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
|
|
110
110
|
//#endregion
|
|
111
111
|
export { CloudinaryGlobalOptions, CloudinaryLoaderProvider, CloudinaryOptions, CloudinaryTransforms, useCloudinaryContext, useCloudinaryLoader };
|
package/dist/cloudinary.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { s as ImageLoaderOptions } from "./index-IjVrRcXi.js";
|
|
2
|
+
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-TbE7SU6o.js";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/loaders/contentful/contentful-options.d.ts
|
|
6
|
+
type ContentfulTransforms = Partial<{
|
|
7
|
+
/**
|
|
8
|
+
* convert the image to a specific format
|
|
9
|
+
*/
|
|
10
|
+
fm: "jpg" | "png" | "webp" | "gif" | "avif" | "tiff";
|
|
11
|
+
/**
|
|
12
|
+
* converts image format to specific type
|
|
13
|
+
* progressive: for jpg image
|
|
14
|
+
* png8: for png image
|
|
15
|
+
*/
|
|
16
|
+
fl: "progressive" | "png8";
|
|
17
|
+
/** width of the image */
|
|
18
|
+
w: number;
|
|
19
|
+
/** height of the image */
|
|
20
|
+
h: number;
|
|
21
|
+
/** resizing behavior */
|
|
22
|
+
fit: "pad" | "fill" | "scale" | "crop" | "thumb";
|
|
23
|
+
/** focus area */
|
|
24
|
+
f: "center" | "top" | "right" | "left" | "bottom" | "top_right" | "top_left" | "bottom_right" | "bottom_left" | "face";
|
|
25
|
+
/** corner radius */
|
|
26
|
+
r: number | "max";
|
|
27
|
+
/** quality of image */
|
|
28
|
+
q: number;
|
|
29
|
+
/** background color */
|
|
30
|
+
bg: string;
|
|
31
|
+
}>;
|
|
32
|
+
type ContentfulOptions = BaseLoaderOptions<ContentfulTransforms>;
|
|
33
|
+
type ContentfulGlobalOptions = BaseGlobalLoaderOptions<ContentfulTransforms>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/loaders/contentful/contentful-loader.d.ts
|
|
36
|
+
declare const useContentfulContext: () => ContentfulGlobalOptions, ContentfulLoaderProvider: ({
|
|
37
|
+
children,
|
|
38
|
+
...props
|
|
39
|
+
}: {
|
|
40
|
+
children: React.ReactNode;
|
|
41
|
+
} & Partial<ContentfulGlobalOptions>) => react_jsx_runtime0.JSX.Element, useContentfulLoader: (options?: ContentfulGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ContentfulGlobalOptions, ContentfulLoaderProvider, ContentfulOptions, ContentfulTransforms, useContentfulContext, useContentfulLoader };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { t as loaderFactory } from "./loader-factory-CQDWe0k2.js";
|
|
2
|
+
|
|
3
|
+
//#region src/loaders/contentful/contentful-loader.tsx
|
|
4
|
+
const { useLoaderContext: useContentfulContext, LoaderProvider: ContentfulLoaderProvider, useLoader: useContentfulLoader } = loaderFactory({
|
|
5
|
+
transforms: { fm: "webp" },
|
|
6
|
+
placeholder: {
|
|
7
|
+
q: 10,
|
|
8
|
+
fm: "webp"
|
|
9
|
+
}
|
|
10
|
+
}, {
|
|
11
|
+
optionSeparator: "=",
|
|
12
|
+
paramSeparator: "&",
|
|
13
|
+
widthKey: "w",
|
|
14
|
+
heightKey: "h",
|
|
15
|
+
passBooleanValue: true,
|
|
16
|
+
customResolver: {}
|
|
17
|
+
}, ({ path, params, imageOptions }) => `${path}/${imageOptions.src}?${params}`);
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ContentfulLoaderProvider, useContentfulContext, useContentfulLoader };
|
package/dist/imgproxy.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as ImageLoaderOptions } from "./index-
|
|
2
|
-
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-
|
|
3
|
-
import * as
|
|
1
|
+
import { s as ImageLoaderOptions } from "./index-IjVrRcXi.js";
|
|
2
|
+
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-TbE7SU6o.js";
|
|
3
|
+
import * as react_jsx_runtime6 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";
|
|
@@ -383,6 +383,6 @@ declare const useImgproxyContext: () => ImgproxyGlobalOptions, ImgproxyLoaderPro
|
|
|
383
383
|
...props
|
|
384
384
|
}: {
|
|
385
385
|
children: React.ReactNode;
|
|
386
|
-
} & Partial<ImgproxyGlobalOptions>) =>
|
|
386
|
+
} & Partial<ImgproxyGlobalOptions>) => react_jsx_runtime6.JSX.Element, useImgproxyLoader: (options?: ImgproxyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
|
|
387
387
|
//#endregion
|
|
388
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-
|
|
1
|
+
import { t as loaderFactory } from "./loader-factory-CQDWe0k2.js";
|
|
2
2
|
|
|
3
3
|
//#region src/loaders/imgproxy/imgproxy-loader.tsx
|
|
4
4
|
const { useLoaderContext: useImgproxyContext, LoaderProvider: ImgproxyLoaderProvider, useLoader: useImgproxyLoader } = loaderFactory({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImgHTMLAttributes } from "react";
|
|
2
|
-
import * as
|
|
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):
|
|
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) =>
|
|
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>):
|
|
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 };
|
package/dist/kontent.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as ImageLoaderOptions } from "./index-
|
|
2
|
-
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-
|
|
3
|
-
import * as
|
|
1
|
+
import { s as ImageLoaderOptions } from "./index-IjVrRcXi.js";
|
|
2
|
+
import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-TbE7SU6o.js";
|
|
3
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/loaders/kontent/kontent-options.d.ts
|
|
6
6
|
type KontentTransforms = Partial<{
|
|
@@ -43,6 +43,6 @@ declare const useKontentContext: () => KontentGlobalOptions, KontentLoaderProvid
|
|
|
43
43
|
...props
|
|
44
44
|
}: {
|
|
45
45
|
children: React.ReactNode;
|
|
46
|
-
} & Partial<KontentGlobalOptions>) =>
|
|
46
|
+
} & Partial<KontentGlobalOptions>) => react_jsx_runtime2.JSX.Element, useKontentLoader: (options?: KontentGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
|
|
47
47
|
//#endregion
|
|
48
48
|
export { KontentGlobalOptions, KontentLoaderProvider, KontentOptions, KontentTransforms, useKontentContext, useKontentLoader };
|
package/dist/kontent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as loaderFactory } from "./loader-factory-
|
|
1
|
+
import { t as loaderFactory } from "./loader-factory-CQDWe0k2.js";
|
|
2
2
|
|
|
3
3
|
//#region src/loaders/kontent/kontent-loader.tsx
|
|
4
4
|
const { useLoaderContext: useKontentContext, LoaderProvider: KontentLoaderProvider, useLoader: useKontentLoader } = loaderFactory({
|
|
@@ -8,6 +8,8 @@ const { useLoaderContext: useKontentContext, LoaderProvider: KontentLoaderProvid
|
|
|
8
8
|
auto: "format"
|
|
9
9
|
}
|
|
10
10
|
}, {
|
|
11
|
+
widthKey: "w",
|
|
12
|
+
heightKey: "h",
|
|
11
13
|
optionSeparator: "=",
|
|
12
14
|
paramSeparator: "&",
|
|
13
15
|
passBooleanValue: true,
|
|
@@ -86,20 +86,21 @@ function loaderFactory(defaults, config, urlResolver) {
|
|
|
86
86
|
return (imageOptions) => {
|
|
87
87
|
const defaultTransform = imageOptions.isPlaceholder ? context.placeholder : context.transforms;
|
|
88
88
|
const optionTransforms = imageOptions.isPlaceholder ? options?.placeholder : options?.transforms;
|
|
89
|
-
const transforms = {
|
|
90
|
-
...defaultTransform,
|
|
91
|
-
...optionTransforms
|
|
92
|
-
};
|
|
93
89
|
const params = [];
|
|
90
|
+
const sizes = {};
|
|
94
91
|
if (imageOptions.width) {
|
|
95
92
|
const widthKey = config.widthKey ?? "width";
|
|
96
|
-
|
|
93
|
+
sizes[widthKey] = imageOptions.width;
|
|
97
94
|
}
|
|
98
95
|
if (imageOptions.height) {
|
|
99
96
|
const heightKey = config.heightKey ?? "height";
|
|
100
|
-
|
|
97
|
+
sizes[heightKey] = imageOptions.height;
|
|
101
98
|
}
|
|
102
|
-
const resolvedTransforms = resolveTransform(
|
|
99
|
+
const resolvedTransforms = resolveTransform({
|
|
100
|
+
...sizes,
|
|
101
|
+
...defaultTransform,
|
|
102
|
+
...optionTransforms
|
|
103
|
+
}, config);
|
|
103
104
|
return urlResolver({
|
|
104
105
|
imageOptions,
|
|
105
106
|
params: [...params, ...resolvedTransforms].join(config.paramSeparator),
|
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-
|
|
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-IjVrRcXi.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.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"description": "A React component library for optimized image handling.",
|
|
6
6
|
"author": "Luka Onikadze <lukonik@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"types": "./dist/kontent.d.ts",
|
|
41
41
|
"default": "./dist/kontent.js"
|
|
42
42
|
},
|
|
43
|
+
"./contentful": {
|
|
44
|
+
"types": "./dist/contentful.d.ts",
|
|
45
|
+
"default": "./dist/contentful.js"
|
|
46
|
+
},
|
|
43
47
|
"./client": {
|
|
44
48
|
"types": "./dist/client.d.ts"
|
|
45
49
|
}
|
|
File without changes
|