cloudflare-next-intl 0.9.2 → 0.9.4
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.
|
@@ -3,10 +3,19 @@ const ANSI_ESCAPE_CODE_PATTERN = /\x1b\[[0-9;]*m/g;
|
|
|
3
3
|
function stripAnsiCodes(value) {
|
|
4
4
|
return value.replace(ANSI_ESCAPE_CODE_PATTERN, '');
|
|
5
5
|
}
|
|
6
|
+
function isReactInternalReference(value) {
|
|
7
|
+
return typeof value === 'function' && '$$typeof' in value;
|
|
8
|
+
}
|
|
6
9
|
function resolveFunctionError(value) {
|
|
10
|
+
if (isReactInternalReference(value)) {
|
|
11
|
+
return '[React internal reference could not be resolved to a value]';
|
|
12
|
+
}
|
|
7
13
|
let result = value;
|
|
8
14
|
try {
|
|
9
15
|
for (let i = 0; i < MAX_FUNCTION_RESOLUTION_ATTEMPTS && typeof result === 'function'; i++) {
|
|
16
|
+
if (isReactInternalReference(result)) {
|
|
17
|
+
return '[React internal reference could not be resolved to a value]';
|
|
18
|
+
}
|
|
10
19
|
result = result();
|
|
11
20
|
}
|
|
12
21
|
return result;
|
|
@@ -49,14 +49,35 @@ function findEntry(srcVal) {
|
|
|
49
49
|
}
|
|
50
50
|
return undefined;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
function toPlainImgAttrs(resolved, src) {
|
|
53
|
+
const { src: _src, alt, width, height, fill: _fill, loader: _loader, quality: _quality, preload: _preload, priority, placeholder: _placeholder, blurDataURL: _blurDataURL, unoptimized: _unoptimized, overrideSrc: _overrideSrc, onLoadingComplete: _onLoadingComplete, layout: _layout, objectFit: _objectFit, objectPosition: _objectPosition, lazyBoundary: _lazyBoundary, lazyRoot: _lazyRoot, loading, style, className, sizes, ...rest } = resolved;
|
|
54
|
+
void _src;
|
|
55
|
+
void _fill;
|
|
56
|
+
void _loader;
|
|
57
|
+
void _quality;
|
|
58
|
+
void _preload;
|
|
59
|
+
void _placeholder;
|
|
60
|
+
void _blurDataURL;
|
|
61
|
+
void _unoptimized;
|
|
62
|
+
void _overrideSrc;
|
|
63
|
+
void _onLoadingComplete;
|
|
64
|
+
void _layout;
|
|
65
|
+
void _objectFit;
|
|
66
|
+
void _objectPosition;
|
|
67
|
+
void _lazyBoundary;
|
|
68
|
+
void _lazyRoot;
|
|
69
|
+
return {
|
|
70
|
+
...rest,
|
|
71
|
+
src,
|
|
72
|
+
alt: alt ?? "",
|
|
73
|
+
width: width,
|
|
74
|
+
height: height,
|
|
75
|
+
className: className,
|
|
76
|
+
style: style,
|
|
77
|
+
sizes: sizes,
|
|
78
|
+
loading: priority ? "eager" : (loading ?? "lazy"),
|
|
79
|
+
fetchPriority: priority ? "high" : "auto",
|
|
80
|
+
};
|
|
60
81
|
}
|
|
61
82
|
function resolveProps(props) {
|
|
62
83
|
let src = props.src;
|
|
@@ -108,12 +129,10 @@ export default function Image(props) {
|
|
|
108
129
|
if (alternates.length === 0) {
|
|
109
130
|
return _jsx(NextImage, { ...resolved });
|
|
110
131
|
}
|
|
111
|
-
const
|
|
112
|
-
const primarySrc = variant?.src ?? String(imgProps.src);
|
|
132
|
+
const primarySrc = variant?.src ?? String(resolved.src);
|
|
113
133
|
const originalSrc = entry?.originalSrc;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
: source.src }, source.src))), _jsx(ImgWithFallback, { ...imgProps, alt: imgProps.alt ?? "", originalSrc: originalSrc })] }));
|
|
134
|
+
const imgProps = toPlainImgAttrs(resolved, primarySrc);
|
|
135
|
+
return (_jsxs("picture", { children: [alternates.map((source) => (_jsx("source", { type: source.type, sizes: imgProps.sizes, srcSet: source.src }, source.src))), _jsx(ImgWithFallback, { ...imgProps, originalSrc: originalSrc })] }));
|
|
117
136
|
}
|
|
118
137
|
export function getImageProps(props) {
|
|
119
138
|
const resolved = resolveProps(props);
|