@openuiai/next 16.2.0 → 16.3.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.
Files changed (221) hide show
  1. package/dist/bin/next +2 -2
  2. package/dist/build/get-babel-loader-config.js +1 -1
  3. package/dist/build/get-babel-loader-config.js.map +1 -1
  4. package/dist/build/index.js +3 -3
  5. package/dist/build/webpack-config.js +6 -4
  6. package/dist/build/webpack-config.js.map +1 -1
  7. package/dist/cache/cache-control.js +22 -0
  8. package/dist/cache/cache-control.js.map +1 -0
  9. package/dist/cache/clone-response.js +77 -0
  10. package/dist/cache/clone-response.js.map +1 -0
  11. package/dist/cache/dedupe-fetch.js +123 -0
  12. package/dist/cache/dedupe-fetch.js.map +1 -0
  13. package/dist/cache/lazy-result.js +46 -0
  14. package/dist/cache/lazy-result.js.map +1 -0
  15. package/dist/cache/lru-cache.js +177 -0
  16. package/dist/cache/lru-cache.js.map +1 -0
  17. package/dist/client/app-bootstrap.js +1 -1
  18. package/dist/client/index.js +1 -1
  19. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  20. package/dist/concurrency/batcher.js +65 -0
  21. package/dist/concurrency/batcher.js.map +1 -0
  22. package/dist/concurrency/coalesced-function.js +39 -0
  23. package/dist/concurrency/coalesced-function.js.map +1 -0
  24. package/dist/concurrency/scheduler.js +64 -0
  25. package/dist/concurrency/scheduler.js.map +1 -0
  26. package/dist/concurrency/wait.js +19 -0
  27. package/dist/concurrency/wait.js.map +1 -0
  28. package/dist/concurrency/with-promise-cache.js +24 -0
  29. package/dist/concurrency/with-promise-cache.js.map +1 -0
  30. package/dist/config/detect-typo.js +51 -0
  31. package/dist/config/detect-typo.js.map +1 -0
  32. package/dist/config/find-config.js +102 -0
  33. package/dist/config/find-config.js.map +1 -0
  34. package/dist/config/get-package-version.js +118 -0
  35. package/dist/config/get-package-version.js.map +1 -0
  36. package/dist/config/get-project-dir.js +51 -0
  37. package/dist/config/get-project-dir.js.map +1 -0
  38. package/dist/config/install-dependencies.js +40 -0
  39. package/dist/config/install-dependencies.js.map +1 -0
  40. package/dist/config/needs-experimental-react.js +16 -0
  41. package/dist/config/needs-experimental-react.js.map +1 -0
  42. package/dist/config/static-env.js +92 -0
  43. package/dist/config/static-env.js.map +1 -0
  44. package/dist/constants/constants.js +397 -0
  45. package/dist/constants/constants.js.map +1 -0
  46. package/dist/errors/compile-error.js +14 -0
  47. package/dist/errors/compile-error.js.map +1 -0
  48. package/dist/errors/error-source.js +36 -0
  49. package/dist/errors/error-source.js.map +1 -0
  50. package/dist/errors/error-telemetry-utils.js +42 -0
  51. package/dist/errors/error-telemetry-utils.js.map +1 -0
  52. package/dist/errors/fatal-error.js +14 -0
  53. package/dist/errors/fatal-error.js.map +1 -0
  54. package/dist/errors/format-server-error.js +74 -0
  55. package/dist/errors/format-server-error.js.map +1 -0
  56. package/dist/errors/invariant-error.js +18 -0
  57. package/dist/errors/invariant-error.js.map +1 -0
  58. package/dist/errors/is-error.js +65 -0
  59. package/dist/errors/is-error.js.map +1 -0
  60. package/dist/errors/no-fallback-error.js +18 -0
  61. package/dist/errors/no-fallback-error.js.map +1 -0
  62. package/dist/esm/build/get-babel-loader-config.js +1 -1
  63. package/dist/esm/build/get-babel-loader-config.js.map +1 -1
  64. package/dist/esm/build/index.js +3 -3
  65. package/dist/esm/build/webpack-config.js +6 -4
  66. package/dist/esm/build/webpack-config.js.map +1 -1
  67. package/dist/esm/client/app-bootstrap.js +1 -1
  68. package/dist/esm/client/index.js +1 -1
  69. package/dist/esm/lib/metadata/resolvers/resolve-url.js +1 -1
  70. package/dist/esm/lib/metadata/resolvers/resolve-url.js.map +1 -1
  71. package/dist/esm/lib/worker.js +1 -1
  72. package/dist/esm/lib/worker.js.map +1 -1
  73. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  74. package/dist/esm/server/lib/app-info-log.js +1 -1
  75. package/dist/esm/server/lib/start-server.js +1 -1
  76. package/dist/esm/server/websocket/setup.js +1 -1
  77. package/dist/esm/server/websocket/setup.js.map +1 -1
  78. package/dist/esm/server/websocket/types.js +1 -1
  79. package/dist/esm/server/websocket/types.js.map +1 -1
  80. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  81. package/dist/filesystem/file-exists.js +53 -0
  82. package/dist/filesystem/file-exists.js.map +1 -0
  83. package/dist/filesystem/find-pages-dir.js +65 -0
  84. package/dist/filesystem/find-pages-dir.js.map +1 -0
  85. package/dist/filesystem/find-root.js +118 -0
  86. package/dist/filesystem/find-root.js.map +1 -0
  87. package/dist/filesystem/get-files-in-dir.js +33 -0
  88. package/dist/filesystem/get-files-in-dir.js.map +1 -0
  89. package/dist/filesystem/multi-file-writer.js +75 -0
  90. package/dist/filesystem/multi-file-writer.js.map +1 -0
  91. package/dist/filesystem/realpath.js +20 -0
  92. package/dist/filesystem/realpath.js.map +1 -0
  93. package/dist/filesystem/recursive-copy.js +76 -0
  94. package/dist/filesystem/recursive-copy.js.map +1 -0
  95. package/dist/filesystem/recursive-delete.js +137 -0
  96. package/dist/filesystem/recursive-delete.js.map +1 -0
  97. package/dist/filesystem/recursive-readdir.js +124 -0
  98. package/dist/filesystem/recursive-readdir.js.map +1 -0
  99. package/dist/filesystem/rename.js +87 -0
  100. package/dist/filesystem/rename.js.map +1 -0
  101. package/dist/filesystem/write-atomic.js +28 -0
  102. package/dist/filesystem/write-atomic.js.map +1 -0
  103. package/dist/fonts/font-utils.js +43 -0
  104. package/dist/fonts/font-utils.js.map +1 -0
  105. package/dist/fonts/get-preloadable-fonts.js +39 -0
  106. package/dist/fonts/get-preloadable-fonts.js.map +1 -0
  107. package/dist/hash/bloom-filter.js +85 -0
  108. package/dist/hash/bloom-filter.js.map +1 -0
  109. package/dist/hash/etag.js +56 -0
  110. package/dist/hash/etag.js.map +1 -0
  111. package/dist/hash/fnv1a.js +56 -0
  112. package/dist/hash/fnv1a.js.map +1 -0
  113. package/dist/hash/hash.js +39 -0
  114. package/dist/hash/hash.js.map +1 -0
  115. package/dist/hostname/format-hostname.js +16 -0
  116. package/dist/hostname/format-hostname.js.map +1 -0
  117. package/dist/hostname/get-hostname.js +23 -0
  118. package/dist/hostname/get-hostname.js.map +1 -0
  119. package/dist/hostname/get-network-host.js +44 -0
  120. package/dist/hostname/get-network-host.js.map +1 -0
  121. package/dist/hostname/is-ipv6.js +41 -0
  122. package/dist/hostname/is-ipv6.js.map +1 -0
  123. package/dist/image/find-closest-quality.js +19 -0
  124. package/dist/image/find-closest-quality.js.map +1 -0
  125. package/dist/image/get-img-props.js +573 -0
  126. package/dist/image/get-img-props.js.map +1 -0
  127. package/dist/image/image-blur-svg.js +22 -0
  128. package/dist/image/image-blur-svg.js.map +1 -0
  129. package/dist/image/image-config-context.shared-runtime.js +19 -0
  130. package/dist/image/image-config-context.shared-runtime.js.map +1 -0
  131. package/dist/image/image-config.js +74 -0
  132. package/dist/image/image-config.js.map +1 -0
  133. package/dist/image/image-loader.js +91 -0
  134. package/dist/image/image-loader.js.map +1 -0
  135. package/dist/image/image-optimizer.js +1019 -0
  136. package/dist/image/image-optimizer.js.map +1 -0
  137. package/dist/image/match-local-pattern.js +46 -0
  138. package/dist/image/match-local-pattern.js.map +1 -0
  139. package/dist/image/match-remote-pattern.js +63 -0
  140. package/dist/image/match-remote-pattern.js.map +1 -0
  141. package/dist/image/mime-type.js +20 -0
  142. package/dist/image/mime-type.js.map +1 -0
  143. package/dist/lib/metadata/resolvers/resolve-url.js +1 -1
  144. package/dist/lib/metadata/resolvers/resolve-url.js.map +1 -1
  145. package/dist/lib/worker.js +1 -1
  146. package/dist/lib/worker.js.map +1 -1
  147. package/dist/memory/gc-observer.js +53 -0
  148. package/dist/memory/gc-observer.js.map +1 -0
  149. package/dist/memory/shutdown.js +29 -0
  150. package/dist/memory/shutdown.js.map +1 -0
  151. package/dist/memory/startup.js +47 -0
  152. package/dist/memory/startup.js.map +1 -0
  153. package/dist/memory/trace.js +109 -0
  154. package/dist/memory/trace.js.map +1 -0
  155. package/dist/module/client-and-server-references.js +54 -0
  156. package/dist/module/client-and-server-references.js.map +1 -0
  157. package/dist/module/format-dynamic-import-path.js +24 -0
  158. package/dist/module/format-dynamic-import-path.js.map +1 -0
  159. package/dist/module/interop-default.js +15 -0
  160. package/dist/module/interop-default.js.map +1 -0
  161. package/dist/module/resolve-from.js +79 -0
  162. package/dist/module/resolve-from.js.map +1 -0
  163. package/dist/module/semver-noop.js +18 -0
  164. package/dist/module/semver-noop.js.map +1 -0
  165. package/dist/object/deep-freeze.js +30 -0
  166. package/dist/object/deep-freeze.js.map +1 -0
  167. package/dist/object/deep-readonly.js +10 -0
  168. package/dist/object/deep-readonly.js.map +1 -0
  169. package/dist/object/is-plain-object.js +42 -0
  170. package/dist/object/is-plain-object.js.map +1 -0
  171. package/dist/object/non-nullable.js +15 -0
  172. package/dist/object/non-nullable.js.map +1 -0
  173. package/dist/object/pick.js +19 -0
  174. package/dist/object/pick.js.map +1 -0
  175. package/dist/process/setup-exception-listeners.js +11 -0
  176. package/dist/process/setup-exception-listeners.js.map +1 -0
  177. package/dist/promise/detached-promise.js +32 -0
  178. package/dist/promise/detached-promise.js.map +1 -0
  179. package/dist/promise/is-thenable.js +20 -0
  180. package/dist/promise/is-thenable.js.map +1 -0
  181. package/dist/promise/promise-with-resolvers.js +26 -0
  182. package/dist/promise/promise-with-resolvers.js.map +1 -0
  183. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  184. package/dist/server/lib/app-info-log.js +1 -1
  185. package/dist/server/lib/start-server.js +1 -1
  186. package/dist/server/websocket/setup.js +1 -1
  187. package/dist/server/websocket/setup.js.map +1 -1
  188. package/dist/server/websocket/types.js +1 -1
  189. package/dist/server/websocket/types.js.map +1 -1
  190. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  191. package/dist/string/encode-uri-path.js +15 -0
  192. package/dist/string/encode-uri-path.js.map +1 -0
  193. package/dist/string/escape-regexp.js +22 -0
  194. package/dist/string/escape-regexp.js.map +1 -0
  195. package/dist/string/normalize-path.js +21 -0
  196. package/dist/string/normalize-path.js.map +1 -0
  197. package/dist/string/oxford-comma-list.js +15 -0
  198. package/dist/string/oxford-comma-list.js.map +1 -0
  199. package/dist/string/pretty-bytes.js +74 -0
  200. package/dist/string/pretty-bytes.js.map +1 -0
  201. package/dist/telemetry/anonymous-meta.js +1 -1
  202. package/dist/telemetry/events/session-stopped.js +2 -2
  203. package/dist/telemetry/events/version.js +2 -2
  204. package/dist/typescript/diagnosticFormatter.js +240 -0
  205. package/dist/typescript/diagnosticFormatter.js.map +1 -0
  206. package/dist/typescript/getTypeScriptConfiguration.js +73 -0
  207. package/dist/typescript/getTypeScriptConfiguration.js.map +1 -0
  208. package/dist/typescript/getTypeScriptIntent.js +52 -0
  209. package/dist/typescript/getTypeScriptIntent.js.map +1 -0
  210. package/dist/typescript/missingDependencyError.js +27 -0
  211. package/dist/typescript/missingDependencyError.js.map +1 -0
  212. package/dist/typescript/runTypeCheck.js +95 -0
  213. package/dist/typescript/runTypeCheck.js.map +1 -0
  214. package/dist/typescript/writeAppTypeDeclarations.js +65 -0
  215. package/dist/typescript/writeAppTypeDeclarations.js.map +1 -0
  216. package/dist/typescript/writeConfigurationDefaults.js +403 -0
  217. package/dist/typescript/writeConfigurationDefaults.js.map +1 -0
  218. package/dist/validation/is-serializable-props.js +106 -0
  219. package/dist/validation/is-serializable-props.js.map +1 -0
  220. package/index.d.ts +2 -2
  221. package/package.json +2 -1
@@ -0,0 +1,573 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getImgProps", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getImgProps;
9
+ }
10
+ });
11
+ const _warnonce = require("../shared/lib/utils/warn-once");
12
+ const _imageblursvg = require("./image-blur-svg");
13
+ const _imageconfig = require("./image-config");
14
+ const VALID_LOADING_VALUES = [
15
+ 'lazy',
16
+ 'eager',
17
+ undefined
18
+ ];
19
+ // Object-fit values that are not valid background-size values
20
+ const INVALID_BACKGROUND_SIZE_VALUES = [
21
+ '-moz-initial',
22
+ 'fill',
23
+ 'none',
24
+ 'scale-down',
25
+ undefined
26
+ ];
27
+ function isStaticRequire(src) {
28
+ return src.default !== undefined;
29
+ }
30
+ function isStaticImageData(src) {
31
+ return src.src !== undefined;
32
+ }
33
+ function isStaticImport(src) {
34
+ return !!src && typeof src === 'object' && (isStaticRequire(src) || isStaticImageData(src));
35
+ }
36
+ const allImgs = new Map();
37
+ let perfObserver;
38
+ function getInt(x) {
39
+ if (typeof x === 'undefined') {
40
+ return x;
41
+ }
42
+ if (typeof x === 'number') {
43
+ return Number.isFinite(x) ? x : NaN;
44
+ }
45
+ if (typeof x === 'string' && /^[0-9]+$/.test(x)) {
46
+ return parseInt(x, 10);
47
+ }
48
+ return NaN;
49
+ }
50
+ function getWidths({ deviceSizes, allSizes }, width, sizes) {
51
+ if (sizes) {
52
+ // Find all the "vw" percent sizes used in the sizes prop
53
+ const viewportWidthRe = /(^|\s)(1?\d?\d)vw/g;
54
+ const percentSizes = [];
55
+ for(let match; match = viewportWidthRe.exec(sizes); match){
56
+ percentSizes.push(parseInt(match[2]));
57
+ }
58
+ if (percentSizes.length) {
59
+ const smallestRatio = Math.min(...percentSizes) * 0.01;
60
+ return {
61
+ widths: allSizes.filter((s)=>s >= deviceSizes[0] * smallestRatio),
62
+ kind: 'w'
63
+ };
64
+ }
65
+ return {
66
+ widths: allSizes,
67
+ kind: 'w'
68
+ };
69
+ }
70
+ if (typeof width !== 'number') {
71
+ return {
72
+ widths: deviceSizes,
73
+ kind: 'w'
74
+ };
75
+ }
76
+ const widths = [
77
+ ...new Set(// > This means that most OLED screens that say they are 3x resolution,
78
+ // > are actually 3x in the green color, but only 1.5x in the red and
79
+ // > blue colors. Showing a 3x resolution image in the app vs a 2x
80
+ // > resolution image will be visually the same, though the 3x image
81
+ // > takes significantly more data. Even true 3x resolution screens are
82
+ // > wasteful as the human eye cannot see that level of detail without
83
+ // > something like a magnifying glass.
84
+ // https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html
85
+ [
86
+ width,
87
+ width * 2 /*, width * 3*/
88
+ ].map((w)=>allSizes.find((p)=>p >= w) || allSizes[allSizes.length - 1]))
89
+ ];
90
+ return {
91
+ widths,
92
+ kind: 'x'
93
+ };
94
+ }
95
+ function generateImgAttrs({ config, src, unoptimized, width, quality, sizes, loader }) {
96
+ if (unoptimized) {
97
+ return {
98
+ src,
99
+ srcSet: undefined,
100
+ sizes: undefined
101
+ };
102
+ }
103
+ const { widths, kind } = getWidths(config, width, sizes);
104
+ const last = widths.length - 1;
105
+ return {
106
+ sizes: !sizes && kind === 'w' ? '100vw' : sizes,
107
+ srcSet: widths.map((w, i)=>`${loader({
108
+ config,
109
+ src,
110
+ quality,
111
+ width: w
112
+ })} ${kind === 'w' ? w : i + 1}${kind}`).join(', '),
113
+ // It's intended to keep `src` the last attribute because React updates
114
+ // attributes in order. If we keep `src` the first one, Safari will
115
+ // immediately start to fetch `src`, before `sizes` and `srcSet` are even
116
+ // updated by React. That causes multiple unnecessary requests if `srcSet`
117
+ // and `sizes` are defined.
118
+ // This bug cannot be reproduced in Chrome or Firefox.
119
+ src: loader({
120
+ config,
121
+ src,
122
+ quality,
123
+ width: widths[last]
124
+ })
125
+ };
126
+ }
127
+ function getImgProps({ src, sizes, unoptimized = false, priority = false, preload = false, loading, className, quality, width, height, fill = false, style, overrideSrc, onLoad, onLoadingComplete, placeholder = 'empty', blurDataURL, fetchPriority, decoding = 'async', layout, objectFit, objectPosition, lazyBoundary, lazyRoot, ...rest }, _state) {
128
+ const { imgConf, showAltText, blurComplete, defaultLoader } = _state;
129
+ let config;
130
+ let c = imgConf || _imageconfig.imageConfigDefault;
131
+ if ('allSizes' in c) {
132
+ config = c;
133
+ } else {
134
+ const allSizes = [
135
+ ...c.deviceSizes,
136
+ ...c.imageSizes
137
+ ].sort((a, b)=>a - b);
138
+ const deviceSizes = c.deviceSizes.sort((a, b)=>a - b);
139
+ const qualities = c.qualities?.sort((a, b)=>a - b);
140
+ config = {
141
+ ...c,
142
+ allSizes,
143
+ deviceSizes,
144
+ qualities
145
+ };
146
+ }
147
+ if (typeof defaultLoader === 'undefined') {
148
+ throw Object.defineProperty(new Error('images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config'), "__NEXT_ERROR_CODE", {
149
+ value: "E163",
150
+ enumerable: false,
151
+ configurable: true
152
+ });
153
+ }
154
+ let loader = rest.loader || defaultLoader;
155
+ // Remove property so it's not spread on <img> element
156
+ delete rest.loader;
157
+ delete rest.srcSet;
158
+ // This special value indicates that the user
159
+ // didn't define a "loader" prop or "loader" config.
160
+ const isDefaultLoader = '__next_img_default' in loader;
161
+ if (isDefaultLoader) {
162
+ if (config.loader === 'custom') {
163
+ throw Object.defineProperty(new Error(`Image with src "${src}" is missing "loader" prop.` + `\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader`), "__NEXT_ERROR_CODE", {
164
+ value: "E252",
165
+ enumerable: false,
166
+ configurable: true
167
+ });
168
+ }
169
+ } else {
170
+ // The user defined a "loader" prop or config.
171
+ // Since the config object is internal only, we
172
+ // must not pass it to the user-defined "loader".
173
+ const customImageLoader = loader;
174
+ loader = (obj)=>{
175
+ const { config: _, ...opts } = obj;
176
+ return customImageLoader(opts);
177
+ };
178
+ }
179
+ if (layout) {
180
+ if (layout === 'fill') {
181
+ fill = true;
182
+ }
183
+ const layoutToStyle = {
184
+ intrinsic: {
185
+ maxWidth: '100%',
186
+ height: 'auto'
187
+ },
188
+ responsive: {
189
+ width: '100%',
190
+ height: 'auto'
191
+ }
192
+ };
193
+ const layoutToSizes = {
194
+ responsive: '100vw',
195
+ fill: '100vw'
196
+ };
197
+ const layoutStyle = layoutToStyle[layout];
198
+ if (layoutStyle) {
199
+ style = {
200
+ ...style,
201
+ ...layoutStyle
202
+ };
203
+ }
204
+ const layoutSizes = layoutToSizes[layout];
205
+ if (layoutSizes && !sizes) {
206
+ sizes = layoutSizes;
207
+ }
208
+ }
209
+ let staticSrc = '';
210
+ let widthInt = getInt(width);
211
+ let heightInt = getInt(height);
212
+ let blurWidth;
213
+ let blurHeight;
214
+ if (isStaticImport(src)) {
215
+ const staticImageData = isStaticRequire(src) ? src.default : src;
216
+ if (!staticImageData.src) {
217
+ throw Object.defineProperty(new Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received ${JSON.stringify(staticImageData)}`), "__NEXT_ERROR_CODE", {
218
+ value: "E460",
219
+ enumerable: false,
220
+ configurable: true
221
+ });
222
+ }
223
+ if (!staticImageData.height || !staticImageData.width) {
224
+ throw Object.defineProperty(new Error(`An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received ${JSON.stringify(staticImageData)}`), "__NEXT_ERROR_CODE", {
225
+ value: "E48",
226
+ enumerable: false,
227
+ configurable: true
228
+ });
229
+ }
230
+ blurWidth = staticImageData.blurWidth;
231
+ blurHeight = staticImageData.blurHeight;
232
+ blurDataURL = blurDataURL || staticImageData.blurDataURL;
233
+ staticSrc = staticImageData.src;
234
+ if (!fill) {
235
+ if (!widthInt && !heightInt) {
236
+ widthInt = staticImageData.width;
237
+ heightInt = staticImageData.height;
238
+ } else if (widthInt && !heightInt) {
239
+ const ratio = widthInt / staticImageData.width;
240
+ heightInt = Math.round(staticImageData.height * ratio);
241
+ } else if (!widthInt && heightInt) {
242
+ const ratio = heightInt / staticImageData.height;
243
+ widthInt = Math.round(staticImageData.width * ratio);
244
+ }
245
+ }
246
+ }
247
+ src = typeof src === 'string' ? src : staticSrc;
248
+ let isLazy = !priority && !preload && (loading === 'lazy' || typeof loading === 'undefined');
249
+ if (!src || src.startsWith('data:') || src.startsWith('blob:')) {
250
+ // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
251
+ unoptimized = true;
252
+ isLazy = false;
253
+ }
254
+ if (config.unoptimized) {
255
+ unoptimized = true;
256
+ }
257
+ if (isDefaultLoader && !config.dangerouslyAllowSVG && src.split('?', 1)[0].endsWith('.svg')) {
258
+ // Special case to make svg serve as-is to avoid proxying
259
+ // through the built-in Image Optimization API.
260
+ unoptimized = true;
261
+ }
262
+ const qualityInt = getInt(quality);
263
+ if (process.env.NODE_ENV !== 'production') {
264
+ if (config.output === 'export' && isDefaultLoader && !unoptimized) {
265
+ throw Object.defineProperty(new Error(`Image Optimization using the default loader is not compatible with \`{ output: 'export' }\`.
266
+ Possible solutions:
267
+ - Remove \`{ output: 'export' }\` and run "next start" to run server mode including the Image Optimization API.
268
+ - Configure \`{ images: { unoptimized: true } }\` in \`next.config.js\` to disable the Image Optimization API.
269
+ Read more: https://nextjs.org/docs/messages/export-image-api`), "__NEXT_ERROR_CODE", {
270
+ value: "E500",
271
+ enumerable: false,
272
+ configurable: true
273
+ });
274
+ }
275
+ if (!src) {
276
+ // React doesn't show the stack trace and there's
277
+ // no `src` to help identify which image, so we
278
+ // instead console.error(ref) during mount.
279
+ unoptimized = true;
280
+ } else {
281
+ if (fill) {
282
+ if (width) {
283
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "width" and "fill" properties. Only one should be used.`), "__NEXT_ERROR_CODE", {
284
+ value: "E96",
285
+ enumerable: false,
286
+ configurable: true
287
+ });
288
+ }
289
+ if (height) {
290
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "height" and "fill" properties. Only one should be used.`), "__NEXT_ERROR_CODE", {
291
+ value: "E115",
292
+ enumerable: false,
293
+ configurable: true
294
+ });
295
+ }
296
+ if (style?.position && style.position !== 'absolute') {
297
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "fill" and "style.position" properties. Images with "fill" always use position absolute - it cannot be modified.`), "__NEXT_ERROR_CODE", {
298
+ value: "E216",
299
+ enumerable: false,
300
+ configurable: true
301
+ });
302
+ }
303
+ if (style?.width && style.width !== '100%') {
304
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "fill" and "style.width" properties. Images with "fill" always use width 100% - it cannot be modified.`), "__NEXT_ERROR_CODE", {
305
+ value: "E73",
306
+ enumerable: false,
307
+ configurable: true
308
+ });
309
+ }
310
+ if (style?.height && style.height !== '100%') {
311
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "fill" and "style.height" properties. Images with "fill" always use height 100% - it cannot be modified.`), "__NEXT_ERROR_CODE", {
312
+ value: "E404",
313
+ enumerable: false,
314
+ configurable: true
315
+ });
316
+ }
317
+ } else {
318
+ if (typeof widthInt === 'undefined') {
319
+ throw Object.defineProperty(new Error(`Image with src "${src}" is missing required "width" property.`), "__NEXT_ERROR_CODE", {
320
+ value: "E451",
321
+ enumerable: false,
322
+ configurable: true
323
+ });
324
+ } else if (isNaN(widthInt)) {
325
+ throw Object.defineProperty(new Error(`Image with src "${src}" has invalid "width" property. Expected a numeric value in pixels but received "${width}".`), "__NEXT_ERROR_CODE", {
326
+ value: "E66",
327
+ enumerable: false,
328
+ configurable: true
329
+ });
330
+ }
331
+ if (typeof heightInt === 'undefined') {
332
+ throw Object.defineProperty(new Error(`Image with src "${src}" is missing required "height" property.`), "__NEXT_ERROR_CODE", {
333
+ value: "E397",
334
+ enumerable: false,
335
+ configurable: true
336
+ });
337
+ } else if (isNaN(heightInt)) {
338
+ throw Object.defineProperty(new Error(`Image with src "${src}" has invalid "height" property. Expected a numeric value in pixels but received "${height}".`), "__NEXT_ERROR_CODE", {
339
+ value: "E444",
340
+ enumerable: false,
341
+ configurable: true
342
+ });
343
+ }
344
+ // eslint-disable-next-line no-control-regex
345
+ if (/^[\x00-\x20]/.test(src)) {
346
+ throw Object.defineProperty(new Error(`Image with src "${src}" cannot start with a space or control character. Use src.trimStart() to remove it or encodeURIComponent(src) to keep it.`), "__NEXT_ERROR_CODE", {
347
+ value: "E176",
348
+ enumerable: false,
349
+ configurable: true
350
+ });
351
+ }
352
+ // eslint-disable-next-line no-control-regex
353
+ if (/[\x00-\x20]$/.test(src)) {
354
+ throw Object.defineProperty(new Error(`Image with src "${src}" cannot end with a space or control character. Use src.trimEnd() to remove it or encodeURIComponent(src) to keep it.`), "__NEXT_ERROR_CODE", {
355
+ value: "E21",
356
+ enumerable: false,
357
+ configurable: true
358
+ });
359
+ }
360
+ }
361
+ }
362
+ if (!VALID_LOADING_VALUES.includes(loading)) {
363
+ throw Object.defineProperty(new Error(`Image with src "${src}" has invalid "loading" property. Provided "${loading}" should be one of ${VALID_LOADING_VALUES.map(String).join(',')}.`), "__NEXT_ERROR_CODE", {
364
+ value: "E357",
365
+ enumerable: false,
366
+ configurable: true
367
+ });
368
+ }
369
+ if (priority && loading === 'lazy') {
370
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "priority" and "loading='lazy'" properties. Only one should be used.`), "__NEXT_ERROR_CODE", {
371
+ value: "E218",
372
+ enumerable: false,
373
+ configurable: true
374
+ });
375
+ }
376
+ if (preload && loading === 'lazy') {
377
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "preload" and "loading='lazy'" properties. Only one should be used.`), "__NEXT_ERROR_CODE", {
378
+ value: "E803",
379
+ enumerable: false,
380
+ configurable: true
381
+ });
382
+ }
383
+ if (preload && priority) {
384
+ throw Object.defineProperty(new Error(`Image with src "${src}" has both "preload" and "priority" properties. Only "preload" should be used.`), "__NEXT_ERROR_CODE", {
385
+ value: "E802",
386
+ enumerable: false,
387
+ configurable: true
388
+ });
389
+ }
390
+ if (placeholder !== 'empty' && placeholder !== 'blur' && !placeholder.startsWith('data:image/')) {
391
+ throw Object.defineProperty(new Error(`Image with src "${src}" has invalid "placeholder" property "${placeholder}".`), "__NEXT_ERROR_CODE", {
392
+ value: "E431",
393
+ enumerable: false,
394
+ configurable: true
395
+ });
396
+ }
397
+ if (placeholder !== 'empty') {
398
+ if (widthInt && heightInt && widthInt * heightInt < 1600) {
399
+ (0, _warnonce.warnOnce)(`Image with src "${src}" is smaller than 40x40. Consider removing the "placeholder" property to improve performance.`);
400
+ }
401
+ }
402
+ if (qualityInt && config.qualities && !config.qualities.includes(qualityInt)) {
403
+ (0, _warnonce.warnOnce)(`Image with src "${src}" is using quality "${qualityInt}" which is not configured in images.qualities [${config.qualities.join(', ')}]. Please update your config to [${[
404
+ ...config.qualities,
405
+ qualityInt
406
+ ].sort().join(', ')}].` + `\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-qualities`);
407
+ }
408
+ if (placeholder === 'blur' && !blurDataURL) {
409
+ const VALID_BLUR_EXT = [
410
+ 'jpeg',
411
+ 'png',
412
+ 'webp',
413
+ 'avif'
414
+ ] // should match next-image-loader
415
+ ;
416
+ throw Object.defineProperty(new Error(`Image with src "${src}" has "placeholder='blur'" property but is missing the "blurDataURL" property.
417
+ Possible solutions:
418
+ - Add a "blurDataURL" property, the contents should be a small Data URL to represent the image
419
+ - Change the "src" property to a static import with one of the supported file types: ${VALID_BLUR_EXT.join(',')} (animated images not supported)
420
+ - Remove the "placeholder" property, effectively no blur effect
421
+ Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url`), "__NEXT_ERROR_CODE", {
422
+ value: "E371",
423
+ enumerable: false,
424
+ configurable: true
425
+ });
426
+ }
427
+ if ('ref' in rest) {
428
+ (0, _warnonce.warnOnce)(`Image with src "${src}" is using unsupported "ref" property. Consider using the "onLoad" property instead.`);
429
+ }
430
+ if (!unoptimized && !isDefaultLoader) {
431
+ const urlStr = loader({
432
+ config,
433
+ src,
434
+ width: widthInt || 400,
435
+ quality: qualityInt || 75
436
+ });
437
+ let url;
438
+ try {
439
+ url = new URL(urlStr);
440
+ } catch (err) {}
441
+ if (urlStr === src || url && url.pathname === src && !url.search) {
442
+ (0, _warnonce.warnOnce)(`Image with src "${src}" has a "loader" property that does not implement width. Please implement it or use the "unoptimized" property instead.` + `\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader-width`);
443
+ }
444
+ }
445
+ if (onLoadingComplete) {
446
+ (0, _warnonce.warnOnce)(`Image with src "${src}" is using deprecated "onLoadingComplete" property. Please use the "onLoad" property instead.`);
447
+ }
448
+ for (const [legacyKey, legacyValue] of Object.entries({
449
+ layout,
450
+ objectFit,
451
+ objectPosition,
452
+ lazyBoundary,
453
+ lazyRoot
454
+ })){
455
+ if (legacyValue) {
456
+ (0, _warnonce.warnOnce)(`Image with src "${src}" has legacy prop "${legacyKey}". Did you forget to run the codemod?` + `\nRead more: https://nextjs.org/docs/messages/next-image-upgrade-to-13`);
457
+ }
458
+ }
459
+ if (typeof window !== 'undefined' && !perfObserver && window.PerformanceObserver) {
460
+ perfObserver = new PerformanceObserver((entryList)=>{
461
+ for (const entry of entryList.getEntries()){
462
+ // @ts-ignore - missing "LargestContentfulPaint" class with "element" prop
463
+ const imgSrc = entry?.element?.src || '';
464
+ const lcpImage = allImgs.get(imgSrc);
465
+ if (lcpImage && lcpImage.loading === 'lazy' && lcpImage.placeholder === 'empty' && !lcpImage.src.startsWith('data:') && !lcpImage.src.startsWith('blob:')) {
466
+ // https://web.dev/lcp/#measure-lcp-in-javascript
467
+ (0, _warnonce.warnOnce)(`Image with src "${lcpImage.src}" was detected as the Largest Contentful Paint (LCP). Please add the \`loading="eager"\` property if this image is above the fold.` + `\nRead more: https://nextjs.org/docs/app/api-reference/components/image#loading`);
468
+ }
469
+ }
470
+ });
471
+ try {
472
+ perfObserver.observe({
473
+ type: 'largest-contentful-paint',
474
+ buffered: true
475
+ });
476
+ } catch (err) {
477
+ // Log error but don't crash the app
478
+ console.error(err);
479
+ }
480
+ }
481
+ }
482
+ const imgStyle = Object.assign(fill ? {
483
+ position: 'absolute',
484
+ height: '100%',
485
+ width: '100%',
486
+ left: 0,
487
+ top: 0,
488
+ right: 0,
489
+ bottom: 0,
490
+ objectFit,
491
+ objectPosition
492
+ } : {}, showAltText ? {} : {
493
+ color: 'transparent'
494
+ }, style);
495
+ const backgroundImage = !blurComplete && placeholder !== 'empty' ? placeholder === 'blur' ? `url("data:image/svg+xml;charset=utf-8,${(0, _imageblursvg.getImageBlurSvg)({
496
+ widthInt,
497
+ heightInt,
498
+ blurWidth,
499
+ blurHeight,
500
+ blurDataURL: blurDataURL || '',
501
+ objectFit: imgStyle.objectFit
502
+ })}")` : `url("${placeholder}")` // assume `data:image/`
503
+ : null;
504
+ const backgroundSize = !INVALID_BACKGROUND_SIZE_VALUES.includes(imgStyle.objectFit) ? imgStyle.objectFit : imgStyle.objectFit === 'fill' ? '100% 100%' // the background-size equivalent of `fill`
505
+ : 'cover';
506
+ let placeholderStyle = backgroundImage ? {
507
+ backgroundSize,
508
+ backgroundPosition: imgStyle.objectPosition || '50% 50%',
509
+ backgroundRepeat: 'no-repeat',
510
+ backgroundImage
511
+ } : {};
512
+ if (process.env.NODE_ENV === 'development') {
513
+ if (placeholderStyle.backgroundImage && placeholder === 'blur' && blurDataURL?.startsWith('/')) {
514
+ // During `next dev`, we don't want to generate blur placeholders with webpack
515
+ // because it can delay starting the dev server. Instead, `next-image-loader.js`
516
+ // will inline a special url to lazily generate the blur placeholder at request time.
517
+ placeholderStyle.backgroundImage = `url("${blurDataURL}")`;
518
+ }
519
+ }
520
+ const imgAttributes = generateImgAttrs({
521
+ config,
522
+ src,
523
+ unoptimized,
524
+ width: widthInt,
525
+ quality: qualityInt,
526
+ sizes,
527
+ loader
528
+ });
529
+ const loadingFinal = isLazy ? 'lazy' : loading;
530
+ if (process.env.NODE_ENV !== 'production') {
531
+ if (typeof window !== 'undefined') {
532
+ let fullUrl;
533
+ try {
534
+ fullUrl = new URL(imgAttributes.src);
535
+ } catch (e) {
536
+ fullUrl = new URL(imgAttributes.src, window.location.href);
537
+ }
538
+ allImgs.set(fullUrl.href, {
539
+ src,
540
+ loading: loadingFinal,
541
+ placeholder
542
+ });
543
+ }
544
+ }
545
+ const props = {
546
+ ...rest,
547
+ loading: loadingFinal,
548
+ fetchPriority,
549
+ width: widthInt,
550
+ height: heightInt,
551
+ decoding,
552
+ className,
553
+ style: {
554
+ ...imgStyle,
555
+ ...placeholderStyle
556
+ },
557
+ sizes: imgAttributes.sizes,
558
+ srcSet: imgAttributes.srcSet,
559
+ src: overrideSrc || imgAttributes.src
560
+ };
561
+ const meta = {
562
+ unoptimized,
563
+ preload: preload || priority,
564
+ placeholder,
565
+ fill
566
+ };
567
+ return {
568
+ props,
569
+ meta
570
+ };
571
+ }
572
+
573
+ //# sourceMappingURL=get-img-props.js.map