cloudflare-next-intl 0.9.0 → 0.9.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.
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ export interface ImgWithFallbackProps extends React.ImgHTMLAttributes<HTMLImageElement> {
3
+ originalSrc?: string;
4
+ }
5
+ export declare function ImgWithFallback({ originalSrc, ...imgProps }: ImgWithFallbackProps): React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export function ImgWithFallback({ originalSrc, ...imgProps }) {
4
+ const onError = (event) => {
5
+ const img = event.currentTarget;
6
+ if (originalSrc && img.src !== originalSrc && !img.src.endsWith(originalSrc)) {
7
+ img.srcset = "";
8
+ img.src = originalSrc;
9
+ }
10
+ };
11
+ return _jsx("img", { ...imgProps, onError: onError });
12
+ }
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import NextImage, { getImageProps as nextGetImageProps } from "next/image";
3
3
  import { getImageBlurSvg } from "./blur_svg.js";
4
+ import { ImgWithFallback } from "./img_with_fallback.js";
4
5
  function pickVariant(entry, requestedWidth) {
5
6
  if (!requestedWidth || !entry.variants || entry.variants.length === 0) {
6
7
  return entry;
@@ -110,16 +111,9 @@ export default function Image(props) {
110
111
  const { props: imgProps } = nextGetImageProps(resolved);
111
112
  const primarySrc = variant?.src ?? String(imgProps.src);
112
113
  const originalSrc = entry?.originalSrc;
113
- const onError = (event) => {
114
- const img = event.currentTarget;
115
- if (originalSrc && img.src !== originalSrc && !img.src.endsWith(originalSrc)) {
116
- img.srcset = "";
117
- img.src = originalSrc;
118
- }
119
- };
120
114
  return (_jsxs("picture", { children: [alternates.map((source) => (_jsx("source", { type: source.type, sizes: imgProps.sizes, srcSet: imgProps.srcSet
121
115
  ? retargetSrcSet(imgProps.srcSet, primarySrc, source.src)
122
- : source.src }, source.src))), _jsx("img", { ...imgProps, alt: imgProps.alt ?? "", onError: onError })] }));
116
+ : source.src }, source.src))), _jsx(ImgWithFallback, { ...imgProps, alt: imgProps.alt ?? "", originalSrc: originalSrc })] }));
123
117
  }
124
118
  export function getImageProps(props) {
125
119
  const resolved = resolveProps(props);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -297,7 +297,7 @@
297
297
  "embedded-postgres": "^18.4.0-beta.17",
298
298
  "jose": "^6.2.8",
299
299
  "pg": "^8.23.0",
300
- "sharp": "^0.34.5"
300
+ "sharp": "^0.34.5 || ^0.35.0"
301
301
  },
302
302
  "peerDependencies": {
303
303
  "@firebase/app": "0.x",