@lonik/oh-image 2.5.0 → 2.7.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.
@@ -1,6 +1,7 @@
1
- import { s as ImageLoaderOptions } from "./index-DObZcazO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-CVQjMJcC.js";
3
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/contentful/contentful-options.d.ts
6
7
  type ContentfulTransforms = Partial<{
@@ -38,6 +39,6 @@ declare const useContentfulContext: () => ContentfulGlobalOptions, ContentfulLoa
38
39
  ...props
39
40
  }: {
40
41
  children: React.ReactNode;
41
- } & Partial<ContentfulGlobalOptions>) => react_jsx_runtime2.JSX.Element, useContentfulLoader: (options?: ContentfulGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
42
+ } & Partial<ContentfulGlobalOptions>) => react_jsx_runtime8.JSX.Element, useContentfulLoader: (options?: ContentfulGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
42
43
  //#endregion
43
44
  export { ContentfulGlobalOptions, ContentfulLoaderProvider, ContentfulOptions, ContentfulTransforms, useContentfulContext, useContentfulLoader };
@@ -1,4 +1,4 @@
1
- import { t as loaderFactory } from "./loader-factory-C6GaON4i.js";
1
+ import { t as loaderFactory } from "./loader-factory-6EOKnqj1.js";
2
2
 
3
3
  //#region src/loaders/contentful/contentful-loader.tsx
4
4
  const { useLoaderContext: useContentfulContext, LoaderProvider: ContentfulLoaderProvider, useLoader: useContentfulLoader } = loaderFactory({
@@ -1,5 +1,6 @@
1
- import { s as ImageLoaderOptions } from "./index-DObZcazO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-CVQjMJcC.js";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
3
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/imgproxy/imgproxy-options.d.ts
package/dist/imgproxy.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as loaderFactory } from "./loader-factory-C6GaON4i.js";
1
+ import { t as loaderFactory } from "./loader-factory-6EOKnqj1.js";
2
2
 
3
3
  //#region src/loaders/imgproxy/imgproxy-loader.tsx
4
4
  const { useLoaderContext: useImgproxyContext, LoaderProvider: ImgproxyLoaderProvider, useLoader: useImgproxyLoader } = loaderFactory({
@@ -0,0 +1,52 @@
1
+ import { r as ImageProps, t as ImageLoader } from "./types-BEgZ3W30.js";
2
+ import * as react_jsx_runtime6 from "react/jsx-runtime";
3
+
4
+ //#region src/react/image.d.ts
5
+ declare function Image(props: ImageProps): react_jsx_runtime6.JSX.Element;
6
+ //#endregion
7
+ //#region src/react/image-factory.d.ts
8
+ declare function __imageFactory(defaultProps: any): (props: any) => react_jsx_runtime6.JSX.Element;
9
+ //#endregion
10
+ //#region src/react/use-img-loaded.d.ts
11
+ /**
12
+ * A hook that tracks whether an image element has finished loading.
13
+ *
14
+ * Handles all edge cases:
15
+ * - Image already cached/complete on mount
16
+ * - Normal load via event listener
17
+ * - Errors (resets to `false`)
18
+ * - `src` changes (resets to `false` until the new source loads)
19
+ * - Element unmount / ref set to `null`
20
+ *
21
+ * @returns `[ref, isLoaded]` — attach the ref callback to an `<img>` element.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * function Avatar({ src }: { src: string }) {
26
+ * const [imgRef, isLoaded] = useImgLoaded(src);
27
+ * return (
28
+ * <img
29
+ * ref={imgRef}
30
+ * src={src}
31
+ * style={{ opacity: isLoaded ? 1 : 0 }}
32
+ * />
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ declare function useImgLoaded(src: string | undefined): [(img: HTMLImageElement | null) => void, boolean];
38
+ //#endregion
39
+ //#region src/react/image-context.d.ts
40
+ interface ImageContextValue extends Pick<ImageProps, "placeholder" | "breakpoints" | "loader"> {
41
+ breakpoints: number[];
42
+ loader: ImageLoader | null;
43
+ }
44
+ declare function useImageContext(): ImageContextValue;
45
+ declare function ImageProvider({
46
+ children,
47
+ ...props
48
+ }: {
49
+ children: React.ReactNode;
50
+ } & Partial<ImageContextValue>): react_jsx_runtime6.JSX.Element;
51
+ //#endregion
52
+ export { Image as a, __imageFactory as i, useImageContext as n, useImgLoaded as r, ImageProvider as t };
package/dist/kontent.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { s as ImageLoaderOptions } from "./index-DObZcazO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-CVQjMJcC.js";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
3
4
  import * as react_jsx_runtime7 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/kontent/kontent-options.d.ts
package/dist/kontent.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as loaderFactory } from "./loader-factory-C6GaON4i.js";
1
+ import { t as loaderFactory } from "./loader-factory-6EOKnqj1.js";
2
2
 
3
3
  //#region src/loaders/kontent/kontent-loader.tsx
4
4
  const { useLoaderContext: useKontentContext, LoaderProvider: KontentLoaderProvider, useLoader: useKontentLoader } = loaderFactory({
@@ -0,0 +1,26 @@
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+
6
+ //#region src/loaders/netlify/netlify-options.d.ts
7
+ type NetlifyTransforms = Partial<{
8
+ w: number;
9
+ h: number;
10
+ fit: "contain" | "cover" | "fill";
11
+ position: "top" | "bottom" | "left" | "right" | "center";
12
+ fm: "avif" | "webp" | "jpg" | "png" | "gif" | "blurhash";
13
+ q: number;
14
+ }>;
15
+ type NetlifyOptions = BaseLoaderOptions<NetlifyTransforms>;
16
+ type NetlifyGlobalOptions = BaseGlobalLoaderOptions<NetlifyTransforms>;
17
+ //#endregion
18
+ //#region src/loaders/netlify/netlify-loader.d.ts
19
+ declare const useNetlifyContext: () => NetlifyGlobalOptions, NetlifyLoaderProvider: ({
20
+ children,
21
+ ...props
22
+ }: {
23
+ children: React.ReactNode;
24
+ } & Partial<NetlifyGlobalOptions>) => react_jsx_runtime0.JSX.Element, useNetlifyLoader: (options?: NetlifyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
25
+ //#endregion
26
+ export { NetlifyGlobalOptions, NetlifyLoaderProvider, NetlifyOptions, NetlifyTransforms, useNetlifyContext, useNetlifyLoader };
@@ -0,0 +1,20 @@
1
+ import { t as loaderFactory } from "./loader-factory-6EOKnqj1.js";
2
+
3
+ //#region src/loaders/netlify/netlify-loader.tsx
4
+ const { useLoaderContext: useNetlifyContext, LoaderProvider: NetlifyLoaderProvider, useLoader: useNetlifyLoader } = loaderFactory({
5
+ path: "/.netlify/images",
6
+ transforms: { fm: "webp" },
7
+ placeholder: { fm: "blurhash" }
8
+ }, {
9
+ optionSeparator: "=",
10
+ paramSeparator: "&",
11
+ widthKey: "w",
12
+ heightKey: "h"
13
+ }, ({ path, params, imageOptions }) => {
14
+ const searchParams = new URLSearchParams(params);
15
+ searchParams.set("url", imageOptions.src);
16
+ return `${path}?${searchParams.toString()}`;
17
+ });
18
+
19
+ //#endregion
20
+ export { NetlifyLoaderProvider, useNetlifyContext, useNetlifyLoader };
package/dist/react.d.ts CHANGED
@@ -1,2 +1,3 @@
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-DObZcazO.js";
1
+ import { n as ImageLoaderOptions, r as ImageProps, t as ImageLoader } from "./types-BEgZ3W30.js";
2
+ import { a as Image, i as __imageFactory, n as useImageContext, r as useImgLoaded, t as ImageProvider } from "./index-C-1t5-gk.js";
2
3
  export { Image, ImageLoader, ImageLoaderOptions, ImageProps, ImageProvider, __imageFactory, useImageContext, useImgLoaded };
@@ -0,0 +1,31 @@
1
+ import { ImgHTMLAttributes } from "react";
2
+
3
+ //#region src/react/types.d.ts
4
+ interface ImageLoaderOptions {
5
+ src: string;
6
+ width?: number | null | undefined;
7
+ height?: number | null | undefined;
8
+ isPlaceholder?: boolean;
9
+ }
10
+ type ImageLoader = (options: ImageLoaderOptions) => string | undefined;
11
+ interface ImageProps extends Partial<Pick<ImgHTMLAttributes<HTMLImageElement>, "fetchPriority" | "decoding" | "loading" | "srcSet" | "className" | "sizes" | "style">> {
12
+ /** Alternative text for the image, required for accessibility. Use an empty string for decorative images. */
13
+ alt: string;
14
+ /** Configures the Image component to load the image immediately. */
15
+ priority?: boolean;
16
+ /** */
17
+ src: string;
18
+ /** The URL of the placeholder image to display while loading. */
19
+ placeholder?: string | undefined | boolean | null;
20
+ /**
21
+ * Sets the image to "fill mode", which eliminates the height/width requirement and adds
22
+ * styles such that the image fills its containing element.
23
+ */
24
+ fill?: boolean;
25
+ loader?: ImageLoader | null;
26
+ width?: number | undefined;
27
+ height?: number | undefined;
28
+ breakpoints?: number[];
29
+ }
30
+ //#endregion
31
+ export { ImageLoaderOptions as n, ImageProps as r, ImageLoader as t };
@@ -1,6 +1,7 @@
1
- import { s as ImageLoaderOptions } from "./index-DObZcazO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-CVQjMJcC.js";
3
- import * as react_jsx_runtime6 from "react/jsx-runtime";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/wordpress/wordpress-options.d.ts
6
7
  type WordpressTransforms = Partial<{
@@ -30,6 +31,6 @@ declare const useWordpressContext: () => WordpressGlobalOptions, WordpressLoader
30
31
  ...props
31
32
  }: {
32
33
  children: React.ReactNode;
33
- } & Partial<WordpressGlobalOptions>) => react_jsx_runtime6.JSX.Element, useWordpressLoader: (options?: WordpressGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
34
+ } & Partial<WordpressGlobalOptions>) => react_jsx_runtime1.JSX.Element, useWordpressLoader: (options?: WordpressGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
34
35
  //#endregion
35
36
  export { WordpressGlobalOptions, WordpressLoaderProvider, WordpressOptions, WordpressTransforms, useWordpressContext, useWordpressLoader };
package/dist/wordpress.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as loaderFactory } from "./loader-factory-C6GaON4i.js";
1
+ import { t as loaderFactory } from "./loader-factory-6EOKnqj1.js";
2
2
 
3
3
  //#region src/loaders/wordpress/wordpress-loader.tsx
4
4
  const { useLoaderContext: useWordpressContext, LoaderProvider: WordpressLoaderProvider, useLoader: useWordpressLoader } = loaderFactory({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lonik/oh-image",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.7.0",
5
5
  "description": "A React component library for optimized image handling.",
6
6
  "author": "Luka Onikadze <lukonik@gmail.com>",
7
7
  "license": "MIT",
@@ -48,6 +48,10 @@
48
48
  "types": "./dist/wordpress.d.ts",
49
49
  "default": "./dist/wordpress.js"
50
50
  },
51
+ "./netlify": {
52
+ "types": "./dist/netlify.d.ts",
53
+ "default": "./dist/netlify.js"
54
+ },
51
55
  "./client": {
52
56
  "types": "./dist/client.d.ts"
53
57
  }
@@ -77,6 +81,7 @@
77
81
  "sharp": ">=0.34.5"
78
82
  },
79
83
  "devDependencies": {
84
+ "@cloudinary/url-gen": "^1.22.0",
80
85
  "@commitlint/config-conventional": "^20.4.1",
81
86
  "@eslint/js": "^9.39.2",
82
87
  "@tailwindcss/vite": "^4.1.18",
@@ -1,80 +0,0 @@
1
- import { ImgHTMLAttributes } from "react";
2
- import * as react_jsx_runtime3 from "react/jsx-runtime";
3
-
4
- //#region src/react/types.d.ts
5
- interface ImageLoaderOptions {
6
- src: string;
7
- width?: number | null | undefined;
8
- height?: number | null | undefined;
9
- isPlaceholder?: boolean;
10
- }
11
- type ImageLoader = (options: ImageLoaderOptions) => string | undefined;
12
- interface ImageProps extends Partial<Pick<ImgHTMLAttributes<HTMLImageElement>, "fetchPriority" | "decoding" | "loading" | "srcSet" | "className" | "sizes" | "style">> {
13
- /** Alternative text for the image, required for accessibility. Use an empty string for decorative images. */
14
- alt: string;
15
- /** Configures the Image component to load the image immediately. */
16
- priority?: boolean;
17
- /** */
18
- src: string;
19
- /** The URL of the placeholder image to display while loading. */
20
- placeholder?: string | undefined | boolean | null;
21
- /**
22
- * Sets the image to "fill mode", which eliminates the height/width requirement and adds
23
- * styles such that the image fills its containing element.
24
- */
25
- fill?: boolean;
26
- loader?: ImageLoader | null;
27
- width?: number | undefined;
28
- height?: number | undefined;
29
- breakpoints?: number[];
30
- }
31
- //#endregion
32
- //#region src/react/image.d.ts
33
- declare function Image(props: ImageProps): react_jsx_runtime3.JSX.Element;
34
- //#endregion
35
- //#region src/react/image-factory.d.ts
36
- declare function __imageFactory(defaultProps: any): (props: any) => react_jsx_runtime3.JSX.Element;
37
- //#endregion
38
- //#region src/react/use-img-loaded.d.ts
39
- /**
40
- * A hook that tracks whether an image element has finished loading.
41
- *
42
- * Handles all edge cases:
43
- * - Image already cached/complete on mount
44
- * - Normal load via event listener
45
- * - Errors (resets to `false`)
46
- * - `src` changes (resets to `false` until the new source loads)
47
- * - Element unmount / ref set to `null`
48
- *
49
- * @returns `[ref, isLoaded]` — attach the ref callback to an `<img>` element.
50
- *
51
- * @example
52
- * ```tsx
53
- * function Avatar({ src }: { src: string }) {
54
- * const [imgRef, isLoaded] = useImgLoaded(src);
55
- * return (
56
- * <img
57
- * ref={imgRef}
58
- * src={src}
59
- * style={{ opacity: isLoaded ? 1 : 0 }}
60
- * />
61
- * );
62
- * }
63
- * ```
64
- */
65
- declare function useImgLoaded(src: string | undefined): [(img: HTMLImageElement | null) => void, boolean];
66
- //#endregion
67
- //#region src/react/image-context.d.ts
68
- interface ImageContextValue extends Pick<ImageProps, "placeholder" | "breakpoints" | "loader"> {
69
- breakpoints: number[];
70
- loader: ImageLoader | null;
71
- }
72
- declare function useImageContext(): ImageContextValue;
73
- declare function ImageProvider({
74
- children,
75
- ...props
76
- }: {
77
- children: React.ReactNode;
78
- } & Partial<ImageContextValue>): react_jsx_runtime3.JSX.Element;
79
- //#endregion
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 };