next 16.3.3 → 16.3.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.
- package/dist/bin/next +2 -2
- package/dist/build/index.js +3 -3
- package/dist/build/swc/index.js +1 -1
- package/dist/build/turbopack-analyze/index.js +1 -1
- package/dist/build/turbopack-build/impl.js +1 -1
- package/dist/build/webpack/loaders/next-image-loader/blur.js +2 -1
- package/dist/build/webpack/loaders/next-image-loader/blur.js.map +1 -1
- package/dist/build/webpack-config.js +3 -3
- package/dist/bundle-analyzer/404.html +1 -1
- package/dist/bundle-analyzer/__next.__PAGE__.txt +1 -1
- package/dist/bundle-analyzer/__next._full.txt +1 -1
- package/dist/bundle-analyzer/__next._head.txt +1 -1
- package/dist/bundle-analyzer/__next._index.txt +1 -1
- package/dist/bundle-analyzer/__next._tree.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._full.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._head.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._index.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._not-found.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._tree.txt +1 -1
- package/dist/bundle-analyzer/_not-found.html +1 -1
- package/dist/bundle-analyzer/_not-found.txt +1 -1
- package/dist/bundle-analyzer/index.html +1 -1
- package/dist/bundle-analyzer/index.txt +1 -1
- package/dist/cli/next-build.js +1 -1
- package/dist/cli/next-post-build.js +1 -1
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/legacy/image.js +2 -8
- package/dist/client/legacy/image.js.map +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/turbopack-analyze/index.js +1 -1
- package/dist/esm/build/turbopack-build/impl.js +1 -1
- package/dist/esm/build/webpack/loaders/next-image-loader/blur.js +2 -1
- package/dist/esm/build/webpack/loaders/next-image-loader/blur.js.map +1 -1
- package/dist/esm/build/webpack-config.js +3 -3
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/client/legacy/image.js +2 -8
- package/dist/esm/client/legacy/image.js.map +1 -1
- package/dist/esm/lib/patch-incorrect-lockfile.js +3 -3
- package/dist/esm/lib/typescript/runTypeScriptCli.js +2 -2
- package/dist/esm/lib/typescript/runTypeScriptCli.js.map +1 -1
- package/dist/esm/lib/verify-typescript-setup.js +3 -1
- package/dist/esm/lib/verify-typescript-setup.js.map +1 -1
- package/dist/esm/server/config.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +2 -2
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/image-optimizer.js +2 -2
- package/dist/esm/server/image-optimizer.js.map +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/esm/shared/lib/get-img-props.js +2 -8
- package/dist/esm/shared/lib/get-img-props.js.map +1 -1
- package/dist/experimental/testmode/fetch.js +10 -2
- package/dist/experimental/testmode/fetch.js.map +1 -1
- package/dist/lib/patch-incorrect-lockfile.js +3 -3
- package/dist/lib/typescript/runTypeScriptCli.js +2 -2
- package/dist/lib/typescript/runTypeScriptCli.js.map +1 -1
- package/dist/lib/verify-typescript-setup.js +3 -1
- package/dist/lib/verify-typescript-setup.js.map +1 -1
- package/dist/server/config.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +2 -2
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/image-optimizer.js +2 -2
- package/dist/server/image-optimizer.js.map +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/shared/lib/get-img-props.js +2 -8
- package/dist/shared/lib/get-img-props.js.map +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/swc-load-failure.js +1 -1
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +11 -11
- /package/dist/bundle-analyzer/_next/static/{3H_RXABXBUagMrHyvStjP → Dz6lURlWhsYfti5hT8XRr}/_buildManifest.js +0 -0
- /package/dist/bundle-analyzer/_next/static/{3H_RXABXBUagMrHyvStjP → Dz6lURlWhsYfti5hT8XRr}/_clientMiddlewareManifest.js +0 -0
- /package/dist/bundle-analyzer/_next/static/{3H_RXABXBUagMrHyvStjP → Dz6lURlWhsYfti5hT8XRr}/_ssgManifest.js +0 -0
|
@@ -226,7 +226,6 @@ function generateImgAttrs({ config, src, unoptimized, width, quality, sizes, loa
|
|
|
226
226
|
let heightInt = getInt(height);
|
|
227
227
|
let blurWidth;
|
|
228
228
|
let blurHeight;
|
|
229
|
-
let isStaticAvif = false;
|
|
230
229
|
if (isStaticImport(src)) {
|
|
231
230
|
const staticImageData = isStaticRequire(src) ? src.default : src;
|
|
232
231
|
if (!staticImageData.src) {
|
|
@@ -247,7 +246,6 @@ function generateImgAttrs({ config, src, unoptimized, width, quality, sizes, loa
|
|
|
247
246
|
blurHeight = staticImageData.blurHeight;
|
|
248
247
|
blurDataURL = blurDataURL || staticImageData.blurDataURL;
|
|
249
248
|
staticSrc = staticImageData.src;
|
|
250
|
-
isStaticAvif = /\.avif(?:\?|$)/i.test(staticSrc);
|
|
251
249
|
if (!fill) {
|
|
252
250
|
if (!widthInt && !heightInt) {
|
|
253
251
|
widthInt = staticImageData.width;
|
|
@@ -262,11 +260,6 @@ function generateImgAttrs({ config, src, unoptimized, width, quality, sizes, loa
|
|
|
262
260
|
}
|
|
263
261
|
}
|
|
264
262
|
src = typeof src === 'string' ? src : staticSrc;
|
|
265
|
-
// Generating a blurDataURL requires decoding the source image, so static AVIF
|
|
266
|
-
// imports do not receive one while AVIF input optimization is disabled.
|
|
267
|
-
if (isStaticAvif && placeholder === 'blur' && !blurDataURL) {
|
|
268
|
-
placeholder = 'empty';
|
|
269
|
-
}
|
|
270
263
|
let isLazy = !priority && !preload && (loading === 'lazy' || typeof loading === 'undefined');
|
|
271
264
|
if (!src || src.startsWith('data:') || src.startsWith('blob:')) {
|
|
272
265
|
// https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
|
|
@@ -432,7 +425,8 @@ function generateImgAttrs({ config, src, unoptimized, width, quality, sizes, loa
|
|
|
432
425
|
const VALID_BLUR_EXT = [
|
|
433
426
|
'jpeg',
|
|
434
427
|
'png',
|
|
435
|
-
'webp'
|
|
428
|
+
'webp',
|
|
429
|
+
'avif'
|
|
436
430
|
] // should match next-image-loader
|
|
437
431
|
;
|
|
438
432
|
throw Object.defineProperty(new Error(`Image with src "${src}" has "placeholder='blur'" property but is missing the "blurDataURL" property.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/shared/lib/get-img-props.ts"],"sourcesContent":["import { getAssetToken, getDeploymentId } from './deployment-id'\nimport { getImageBlurSvg } from './image-blur-svg'\nimport { imageConfigDefault } from './image-config'\nimport type {\n ImageConfigComplete,\n ImageLoaderProps,\n ImageLoaderPropsWithConfig,\n} from './image-config'\n\nimport type { CSSProperties, JSX } from 'react'\n\nexport interface StaticImageData {\n src: string\n height: number\n width: number\n blurDataURL?: string\n blurWidth?: number\n blurHeight?: number\n}\n\nexport interface StaticRequire {\n default: StaticImageData\n}\n\nexport type StaticImport = StaticRequire | StaticImageData\n\nexport type ImageProps = Omit<\n JSX.IntrinsicElements['img'],\n 'src' | 'srcSet' | 'ref' | 'alt' | 'width' | 'height' | 'loading'\n> & {\n src: string | StaticImport\n alt: string\n width?: number | `${number}`\n height?: number | `${number}`\n fill?: boolean\n loader?: ImageLoader\n quality?: number | `${number}`\n preload?: boolean\n /**\n * @deprecated Use `preload` prop instead.\n * See https://nextjs.org/docs/app/api-reference/components/image#preload\n */\n priority?: boolean\n loading?: LoadingValue\n placeholder?: PlaceholderValue\n blurDataURL?: string\n unoptimized?: boolean\n overrideSrc?: string\n /**\n * @deprecated Use `onLoad` instead.\n * @see https://nextjs.org/docs/app/api-reference/components/image#onload\n */\n onLoadingComplete?: OnLoadingComplete\n /**\n * @deprecated Use `fill` prop instead of `layout=\"fill\"` or change import to `next/legacy/image`.\n * @see https://nextjs.org/docs/api-reference/next/legacy/image\n */\n layout?: string\n /**\n * @deprecated Use `style` prop instead.\n */\n objectFit?: string\n /**\n * @deprecated Use `style` prop instead.\n */\n objectPosition?: string\n /**\n * @deprecated This prop does not do anything.\n */\n lazyBoundary?: string\n /**\n * @deprecated This prop does not do anything.\n */\n lazyRoot?: string\n}\n\nexport type ImgProps = Omit<ImageProps, 'src' | 'loader'> & {\n loading: LoadingValue\n width: number | undefined\n height: number | undefined\n style: NonNullable<JSX.IntrinsicElements['img']['style']>\n sizes: string | undefined\n srcSet: string | undefined\n src: string\n}\n\nconst VALID_LOADING_VALUES = ['lazy', 'eager', undefined] as const\n\n// Object-fit values that are not valid background-size values\nconst INVALID_BACKGROUND_SIZE_VALUES = [\n '-moz-initial',\n 'fill',\n 'none',\n 'scale-down',\n undefined,\n]\ntype LoadingValue = (typeof VALID_LOADING_VALUES)[number]\ntype ImageConfig = ImageConfigComplete & {\n allSizes: number[]\n output?: 'standalone' | 'export'\n}\n\nexport type ImageLoader = (p: ImageLoaderProps) => string\n\n// Do not export - this is an internal type only\n// because `next.config.js` is only meant for the\n// built-in loaders, not for a custom loader() prop.\ntype ImageLoaderWithConfig = (p: ImageLoaderPropsWithConfig) => string\n\nexport type PlaceholderValue = 'blur' | 'empty' | `data:image/${string}`\nexport type OnLoad = React.ReactEventHandler<HTMLImageElement> | undefined\nexport type OnLoadingComplete = (img: HTMLImageElement) => void\n\nexport type PlaceholderStyle = Partial<\n Pick<\n CSSProperties,\n | 'backgroundSize'\n | 'backgroundPosition'\n | 'backgroundRepeat'\n | 'backgroundImage'\n >\n>\n\nfunction isStaticRequire(\n src: StaticRequire | StaticImageData\n): src is StaticRequire {\n return (src as StaticRequire).default !== undefined\n}\n\nfunction isStaticImageData(\n src: StaticRequire | StaticImageData\n): src is StaticImageData {\n return (src as StaticImageData).src !== undefined\n}\n\nfunction isStaticImport(src: string | StaticImport): src is StaticImport {\n return (\n !!src &&\n typeof src === 'object' &&\n (isStaticRequire(src as StaticImport) ||\n isStaticImageData(src as StaticImport))\n )\n}\n\nconst allImgs = new Map<\n string,\n { src: string; loading: LoadingValue; placeholder: PlaceholderValue }\n>()\nlet perfObserver: PerformanceObserver | undefined\n\nfunction getInt(x: unknown): number | undefined {\n if (typeof x === 'undefined') {\n return x\n }\n if (typeof x === 'number') {\n return Number.isFinite(x) ? x : NaN\n }\n if (typeof x === 'string' && /^[0-9]+$/.test(x)) {\n return parseInt(x, 10)\n }\n return NaN\n}\n\nfunction getWidths(\n { deviceSizes, allSizes }: ImageConfig,\n width: number | undefined,\n sizes: string | undefined\n): { widths: number[]; kind: 'w' | 'x' } {\n if (sizes) {\n // Find all the \"vw\" percent sizes used in the sizes prop\n const viewportWidthRe = /(^|\\s)(1?\\d?\\d)vw/g\n const percentSizes = []\n for (let match; (match = viewportWidthRe.exec(sizes)); match) {\n percentSizes.push(parseInt(match[2]))\n }\n if (percentSizes.length) {\n const smallestRatio = Math.min(...percentSizes) * 0.01\n return {\n widths: allSizes.filter((s) => s >= deviceSizes[0] * smallestRatio),\n kind: 'w',\n }\n }\n return { widths: allSizes, kind: 'w' }\n }\n if (typeof width !== 'number') {\n return { widths: deviceSizes, kind: 'w' }\n }\n\n const widths = [\n ...new Set(\n // > This means that most OLED screens that say they are 3x resolution,\n // > are actually 3x in the green color, but only 1.5x in the red and\n // > blue colors. Showing a 3x resolution image in the app vs a 2x\n // > resolution image will be visually the same, though the 3x image\n // > takes significantly more data. Even true 3x resolution screens are\n // > wasteful as the human eye cannot see that level of detail without\n // > something like a magnifying glass.\n // https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html\n [width, width * 2 /*, width * 3*/].map(\n (w) => allSizes.find((p) => p >= w) || allSizes[allSizes.length - 1]\n )\n ),\n ]\n return { widths, kind: 'x' }\n}\n\ntype GenImgAttrsData = {\n config: ImageConfig\n src: string\n unoptimized: boolean\n loader: ImageLoaderWithConfig\n width?: number\n quality?: number\n sizes?: string\n}\n\ntype GenImgAttrsResult = {\n src: string\n srcSet: string | undefined\n sizes: string | undefined\n}\n\nfunction generateImgAttrs({\n config,\n src,\n unoptimized,\n width,\n quality,\n sizes,\n loader,\n}: GenImgAttrsData): GenImgAttrsResult {\n if (unoptimized) {\n if (src.startsWith('/') && !src.startsWith('//')) {\n let deploymentId = getDeploymentId()\n if (src.includes('/_next/static/immutable') && !getAssetToken()) {\n // immutable static asset and supported by platform, don't add `?dpl=`\n deploymentId = undefined\n } else if (deploymentId) {\n // We unfortunately can't easily use `new URL()` here, because it normalizes the URL which causes\n // double-encoding with the `encodeURIComponent(src)` below\n const qIndex = src.indexOf('?')\n if (qIndex !== -1) {\n const params = new URLSearchParams(src.slice(qIndex + 1))\n const srcDpl = params.get('dpl')\n if (!srcDpl) {\n // src is missing the dpl parameter, but we have a deploymentId, so add it to the src URL\n params.append('dpl', deploymentId)\n src = src.slice(0, qIndex) + '?' + params.toString()\n }\n } else {\n // src is missing the dpl parameter, but we have a deploymentId, so add it to the src URL\n src = src + `?dpl=${deploymentId}`\n }\n }\n }\n return { src, srcSet: undefined, sizes: undefined }\n }\n\n const { widths, kind } = getWidths(config, width, sizes)\n const last = widths.length - 1\n\n return {\n sizes: !sizes && kind === 'w' ? '100vw' : sizes,\n srcSet: widths\n .map(\n (w, i) =>\n `${loader({ config, src, quality, width: w })} ${\n kind === 'w' ? w : i + 1\n }${kind}`\n )\n .join(', '),\n\n // It's intended to keep `src` the last attribute because React updates\n // attributes in order. If we keep `src` the first one, Safari will\n // immediately start to fetch `src`, before `sizes` and `srcSet` are even\n // updated by React. That causes multiple unnecessary requests if `srcSet`\n // and `sizes` are defined.\n // This bug cannot be reproduced in Chrome or Firefox.\n src: loader({ config, src, quality, width: widths[last] }),\n }\n}\n\n/**\n * A shared function, used on both client and server, to generate the props for <img>.\n */\nexport function getImgProps(\n {\n src,\n sizes,\n unoptimized = false,\n priority = false,\n preload = false,\n loading,\n className,\n quality,\n width,\n height,\n fill = false,\n style,\n overrideSrc,\n onLoad,\n onLoadingComplete,\n placeholder = 'empty',\n blurDataURL,\n fetchPriority,\n decoding = 'async',\n layout,\n objectFit,\n objectPosition,\n lazyBoundary,\n lazyRoot,\n ...rest\n }: ImageProps,\n _state: {\n defaultLoader: ImageLoaderWithConfig\n imgConf: ImageConfigComplete\n showAltText?: boolean\n blurComplete?: boolean\n }\n): {\n props: ImgProps\n meta: {\n unoptimized: boolean\n preload: boolean\n placeholder: NonNullable<ImageProps['placeholder']>\n fill: boolean\n }\n} {\n const { imgConf, showAltText, blurComplete, defaultLoader } = _state\n let config: ImageConfig\n let c = imgConf || imageConfigDefault\n if ('allSizes' in c) {\n config = c as ImageConfig\n } else {\n const allSizes = [...c.deviceSizes, ...c.imageSizes].sort((a, b) => a - b)\n const deviceSizes = c.deviceSizes.sort((a, b) => a - b)\n const qualities = c.qualities?.sort((a, b) => a - b)\n config = { ...c, allSizes, deviceSizes, qualities }\n }\n\n if (typeof defaultLoader === 'undefined') {\n throw new Error(\n 'images.loaderFile detected but the file is missing default export.\\nRead more: https://nextjs.org/docs/messages/invalid-images-config'\n )\n }\n let loader: ImageLoaderWithConfig = rest.loader || defaultLoader\n\n // Remove property so it's not spread on <img> element\n delete rest.loader\n delete (rest as any).srcSet\n\n // This special value indicates that the user\n // didn't define a \"loader\" prop or \"loader\" config.\n const isDefaultLoader = '__next_img_default' in loader\n\n if (isDefaultLoader) {\n if (config.loader === 'custom') {\n throw new Error(\n `Image with src \"${src}\" is missing \"loader\" prop.` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader`\n )\n }\n } else {\n // The user defined a \"loader\" prop or config.\n // Since the config object is internal only, we\n // must not pass it to the user-defined \"loader\".\n const customImageLoader = loader as ImageLoader\n loader = (obj) => {\n const { config: _, ...opts } = obj\n return customImageLoader(opts)\n }\n }\n\n if (layout) {\n if (layout === 'fill') {\n fill = true\n }\n const layoutToStyle: Record<string, Record<string, string> | undefined> = {\n intrinsic: { maxWidth: '100%', height: 'auto' },\n responsive: { width: '100%', height: 'auto' },\n }\n const layoutToSizes: Record<string, string | undefined> = {\n responsive: '100vw',\n fill: '100vw',\n }\n const layoutStyle = layoutToStyle[layout]\n if (layoutStyle) {\n style = { ...style, ...layoutStyle }\n }\n const layoutSizes = layoutToSizes[layout]\n if (layoutSizes && !sizes) {\n sizes = layoutSizes\n }\n }\n\n let staticSrc = ''\n let widthInt = getInt(width)\n let heightInt = getInt(height)\n let blurWidth: number | undefined\n let blurHeight: number | undefined\n let isStaticAvif = false\n if (isStaticImport(src)) {\n const staticImageData = isStaticRequire(src) ? src.default : src\n\n if (!staticImageData.src) {\n throw new Error(\n `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(\n staticImageData\n )}`\n )\n }\n if (!staticImageData.height || !staticImageData.width) {\n throw new Error(\n `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(\n staticImageData\n )}`\n )\n }\n\n blurWidth = staticImageData.blurWidth\n blurHeight = staticImageData.blurHeight\n blurDataURL = blurDataURL || staticImageData.blurDataURL\n staticSrc = staticImageData.src\n isStaticAvif = /\\.avif(?:\\?|$)/i.test(staticSrc)\n\n if (!fill) {\n if (!widthInt && !heightInt) {\n widthInt = staticImageData.width\n heightInt = staticImageData.height\n } else if (widthInt && !heightInt) {\n const ratio = widthInt / staticImageData.width\n heightInt = Math.round(staticImageData.height * ratio)\n } else if (!widthInt && heightInt) {\n const ratio = heightInt / staticImageData.height\n widthInt = Math.round(staticImageData.width * ratio)\n }\n }\n }\n src = typeof src === 'string' ? src : staticSrc\n\n // Generating a blurDataURL requires decoding the source image, so static AVIF\n // imports do not receive one while AVIF input optimization is disabled.\n if (isStaticAvif && placeholder === 'blur' && !blurDataURL) {\n placeholder = 'empty'\n }\n\n let isLazy =\n !priority &&\n !preload &&\n (loading === 'lazy' || typeof loading === 'undefined')\n if (!src || src.startsWith('data:') || src.startsWith('blob:')) {\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n unoptimized = true\n isLazy = false\n }\n if (config.unoptimized) {\n unoptimized = true\n }\n if (\n isDefaultLoader &&\n !config.dangerouslyAllowSVG &&\n src.split('?', 1)[0].endsWith('.svg')\n ) {\n // Special case to make svg serve as-is to avoid proxying\n // through the built-in Image Optimization API.\n unoptimized = true\n }\n\n const qualityInt = getInt(quality)\n\n if (process.env.NODE_ENV !== 'production') {\n const { warnOnce } =\n require('./utils/warn-once') as typeof import('./utils/warn-once')\n if (config.output === 'export' && isDefaultLoader && !unoptimized) {\n throw new Error(\n `Image Optimization using the default loader is not compatible with \\`{ output: 'export' }\\`.\n Possible solutions:\n - Remove \\`{ output: 'export' }\\` and run \"next start\" to run server mode including the Image Optimization API.\n - Configure \\`{ images: { unoptimized: true } }\\` in \\`next.config.js\\` to disable the Image Optimization API.\n Read more: https://nextjs.org/docs/messages/export-image-api`\n )\n }\n if (!src) {\n // React doesn't show the stack trace and there's\n // no `src` to help identify which image, so we\n // instead console.error(ref) during mount.\n unoptimized = true\n } else {\n if (fill) {\n if (width) {\n throw new Error(\n `Image with src \"${src}\" has both \"width\" and \"fill\" properties. Only one should be used.`\n )\n }\n if (height) {\n throw new Error(\n `Image with src \"${src}\" has both \"height\" and \"fill\" properties. Only one should be used.`\n )\n }\n if (style?.position && style.position !== 'absolute') {\n throw new Error(\n `Image with src \"${src}\" has both \"fill\" and \"style.position\" properties. Images with \"fill\" always use position absolute - it cannot be modified.`\n )\n }\n if (style?.width && style.width !== '100%') {\n throw new Error(\n `Image with src \"${src}\" has both \"fill\" and \"style.width\" properties. Images with \"fill\" always use width 100% - it cannot be modified.`\n )\n }\n if (style?.height && style.height !== '100%') {\n throw new Error(\n `Image with src \"${src}\" has both \"fill\" and \"style.height\" properties. Images with \"fill\" always use height 100% - it cannot be modified.`\n )\n }\n } else {\n if (typeof widthInt === 'undefined') {\n throw new Error(\n `Image with src \"${src}\" is missing required \"width\" property.`\n )\n } else if (isNaN(widthInt)) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"width\" property. Expected a numeric value in pixels but received \"${width}\".`\n )\n }\n if (typeof heightInt === 'undefined') {\n throw new Error(\n `Image with src \"${src}\" is missing required \"height\" property.`\n )\n } else if (isNaN(heightInt)) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"height\" property. Expected a numeric value in pixels but received \"${height}\".`\n )\n }\n // eslint-disable-next-line no-control-regex\n if (/^[\\x00-\\x20]/.test(src)) {\n throw new Error(\n `Image with src \"${src}\" cannot start with a space or control character. Use src.trimStart() to remove it or encodeURIComponent(src) to keep it.`\n )\n }\n // eslint-disable-next-line no-control-regex\n if (/[\\x00-\\x20]$/.test(src)) {\n throw new Error(\n `Image with src \"${src}\" cannot end with a space or control character. Use src.trimEnd() to remove it or encodeURIComponent(src) to keep it.`\n )\n }\n }\n }\n if (!VALID_LOADING_VALUES.includes(loading)) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"loading\" property. Provided \"${loading}\" should be one of ${VALID_LOADING_VALUES.map(\n String\n ).join(',')}.`\n )\n }\n if (priority && loading === 'lazy') {\n throw new Error(\n `Image with src \"${src}\" has both \"priority\" and \"loading='lazy'\" properties. Only one should be used.`\n )\n }\n if (preload && loading === 'lazy') {\n throw new Error(\n `Image with src \"${src}\" has both \"preload\" and \"loading='lazy'\" properties. Only one should be used.`\n )\n }\n if (preload && priority) {\n throw new Error(\n `Image with src \"${src}\" has both \"preload\" and \"priority\" properties. Only \"preload\" should be used.`\n )\n }\n if (\n placeholder !== 'empty' &&\n placeholder !== 'blur' &&\n !placeholder.startsWith('data:image/')\n ) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"placeholder\" property \"${placeholder}\".`\n )\n }\n if (placeholder !== 'empty') {\n if (widthInt && heightInt && widthInt * heightInt < 1600) {\n warnOnce(\n `Image with src \"${src}\" is smaller than 40x40. Consider removing the \"placeholder\" property to improve performance.`\n )\n }\n }\n if (\n qualityInt &&\n config.qualities &&\n !config.qualities.includes(qualityInt)\n ) {\n warnOnce(\n `Image with src \"${src}\" is using quality \"${qualityInt}\" which is not configured in images.qualities [${config.qualities.join(', ')}]. Please update your config to [${[...config.qualities, qualityInt].sort().join(', ')}].` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-qualities`\n )\n }\n if (placeholder === 'blur' && !blurDataURL) {\n const VALID_BLUR_EXT = ['jpeg', 'png', 'webp'] // should match next-image-loader\n\n throw new Error(\n `Image with src \"${src}\" has \"placeholder='blur'\" property but is missing the \"blurDataURL\" property.\n Possible solutions:\n - Add a \"blurDataURL\" property, the contents should be a small Data URL to represent the image\n - Change the \"src\" property to a static import with one of the supported file types: ${VALID_BLUR_EXT.join(\n ','\n )} (animated images not supported)\n - Remove the \"placeholder\" property, effectively no blur effect\n Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url`\n )\n }\n if ('ref' in rest) {\n warnOnce(\n `Image with src \"${src}\" is using unsupported \"ref\" property. Consider using the \"onLoad\" property instead.`\n )\n }\n\n if (!unoptimized && !isDefaultLoader) {\n const urlStr = loader({\n config,\n src,\n width: widthInt || 400,\n quality: qualityInt || 75,\n })\n let url: URL | undefined\n try {\n url = new URL(urlStr)\n } catch (err) {}\n if (urlStr === src || (url && url.pathname === src && !url.search)) {\n warnOnce(\n `Image with src \"${src}\" has a \"loader\" property that does not implement width. Please implement it or use the \"unoptimized\" property instead.` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader-width`\n )\n }\n }\n\n if (onLoadingComplete) {\n warnOnce(\n `Image with src \"${src}\" is using deprecated \"onLoadingComplete\" property. Please use the \"onLoad\" property instead.`\n )\n }\n\n for (const [legacyKey, legacyValue] of Object.entries({\n layout,\n objectFit,\n objectPosition,\n lazyBoundary,\n lazyRoot,\n })) {\n if (legacyValue) {\n warnOnce(\n `Image with src \"${src}\" has legacy prop \"${legacyKey}\". Did you forget to run the codemod?` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-upgrade-to-13`\n )\n }\n }\n\n if (\n typeof window !== 'undefined' &&\n !perfObserver &&\n window.PerformanceObserver\n ) {\n perfObserver = new PerformanceObserver((entryList) => {\n for (const entry of entryList.getEntries()) {\n // @ts-ignore - missing \"LargestContentfulPaint\" class with \"element\" prop\n const imgSrc = entry?.element?.src || ''\n const lcpImage = allImgs.get(imgSrc)\n if (\n lcpImage &&\n lcpImage.loading === 'lazy' &&\n lcpImage.placeholder === 'empty' &&\n !lcpImage.src.startsWith('data:') &&\n !lcpImage.src.startsWith('blob:')\n ) {\n // https://web.dev/lcp/#measure-lcp-in-javascript\n warnOnce(\n `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.` +\n `\\nRead more: https://nextjs.org/docs/app/api-reference/components/image#loading`\n )\n }\n }\n })\n try {\n perfObserver.observe({\n type: 'largest-contentful-paint',\n buffered: true,\n })\n } catch (err) {\n // Log error but don't crash the app\n console.error(err)\n }\n }\n }\n const imgStyle = Object.assign(\n fill\n ? {\n position: 'absolute',\n height: '100%',\n width: '100%',\n left: 0,\n top: 0,\n right: 0,\n bottom: 0,\n objectFit,\n objectPosition,\n }\n : {},\n showAltText ? {} : { color: 'transparent' },\n style\n )\n\n const backgroundImage =\n !blurComplete && placeholder !== 'empty'\n ? placeholder === 'blur'\n ? `url(\"data:image/svg+xml;charset=utf-8,${getImageBlurSvg({\n widthInt,\n heightInt,\n blurWidth,\n blurHeight,\n blurDataURL: blurDataURL || '', // assume not undefined\n objectFit: imgStyle.objectFit,\n })}\")`\n : `url(\"${placeholder}\")` // assume `data:image/`\n : null\n\n const backgroundSize = !INVALID_BACKGROUND_SIZE_VALUES.includes(\n imgStyle.objectFit\n )\n ? imgStyle.objectFit\n : imgStyle.objectFit === 'fill'\n ? '100% 100%' // the background-size equivalent of `fill`\n : 'cover'\n\n let placeholderStyle: PlaceholderStyle = backgroundImage\n ? {\n backgroundSize,\n backgroundPosition: imgStyle.objectPosition || '50% 50%',\n backgroundRepeat: 'no-repeat',\n backgroundImage,\n }\n : {}\n\n if (process.env.NODE_ENV === 'development') {\n if (\n placeholderStyle.backgroundImage &&\n placeholder === 'blur' &&\n blurDataURL?.startsWith('/')\n ) {\n // During `next dev`, we don't want to generate blur placeholders with webpack\n // because it can delay starting the dev server. Instead, `next-image-loader.js`\n // will inline a special url to lazily generate the blur placeholder at request time.\n placeholderStyle.backgroundImage = `url(\"${blurDataURL}\")`\n }\n }\n\n const imgAttributes = generateImgAttrs({\n config,\n src,\n unoptimized,\n width: widthInt,\n quality: qualityInt,\n sizes,\n loader,\n })\n\n const loadingFinal = isLazy ? 'lazy' : loading\n\n if (process.env.NODE_ENV !== 'production') {\n if (typeof window !== 'undefined') {\n let fullUrl: URL\n try {\n fullUrl = new URL(imgAttributes.src)\n } catch (e) {\n fullUrl = new URL(imgAttributes.src, window.location.href)\n }\n allImgs.set(fullUrl.href, { src, loading: loadingFinal, placeholder })\n }\n }\n\n const props: ImgProps = {\n ...rest,\n loading: loadingFinal,\n fetchPriority,\n width: widthInt,\n height: heightInt,\n decoding,\n className,\n style: { ...imgStyle, ...placeholderStyle },\n sizes: imgAttributes.sizes,\n srcSet: imgAttributes.srcSet,\n src: overrideSrc || imgAttributes.src,\n }\n const meta = { unoptimized, preload: preload || priority, placeholder, fill }\n return { props, meta }\n}\n"],"names":["getAssetToken","getDeploymentId","getImageBlurSvg","imageConfigDefault","VALID_LOADING_VALUES","undefined","INVALID_BACKGROUND_SIZE_VALUES","isStaticRequire","src","default","isStaticImageData","isStaticImport","allImgs","Map","perfObserver","getInt","x","Number","isFinite","NaN","test","parseInt","getWidths","deviceSizes","allSizes","width","sizes","viewportWidthRe","percentSizes","match","exec","push","length","smallestRatio","Math","min","widths","filter","s","kind","Set","map","w","find","p","generateImgAttrs","config","unoptimized","quality","loader","startsWith","deploymentId","includes","qIndex","indexOf","params","URLSearchParams","slice","srcDpl","get","append","toString","srcSet","last","i","join","getImgProps","priority","preload","loading","className","height","fill","style","overrideSrc","onLoad","onLoadingComplete","placeholder","blurDataURL","fetchPriority","decoding","layout","objectFit","objectPosition","lazyBoundary","lazyRoot","rest","_state","imgConf","showAltText","blurComplete","defaultLoader","c","imageSizes","sort","a","b","qualities","Error","isDefaultLoader","customImageLoader","obj","_","opts","layoutToStyle","intrinsic","maxWidth","responsive","layoutToSizes","layoutStyle","layoutSizes","staticSrc","widthInt","heightInt","blurWidth","blurHeight","isStaticAvif","staticImageData","JSON","stringify","ratio","round","isLazy","dangerouslyAllowSVG","split","endsWith","qualityInt","process","env","NODE_ENV","warnOnce","require","output","position","isNaN","String","VALID_BLUR_EXT","urlStr","url","URL","err","pathname","search","legacyKey","legacyValue","Object","entries","window","PerformanceObserver","entryList","entry","getEntries","imgSrc","element","lcpImage","observe","type","buffered","console","error","imgStyle","assign","left","top","right","bottom","color","backgroundImage","backgroundSize","placeholderStyle","backgroundPosition","backgroundRepeat","imgAttributes","loadingFinal","fullUrl","e","location","href","set","props","meta"],"mappings":"AAAA,SAASA,aAAa,EAAEC,eAAe,QAAQ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cesContent":["import { getAssetToken, getDeploymentId } from './deployment-id'\nimport { getImageBlurSvg } from './image-blur-svg'\nimport { imageConfigDefault } from './image-config'\nimport type {\n ImageConfigComplete,\n ImageLoaderProps,\n ImageLoaderPropsWithConfig,\n} from './image-config'\n\nimport type { CSSProperties, JSX } from 'react'\n\nexport interface StaticImageData {\n src: string\n height: number\n width: number\n blurDataURL?: string\n blurWidth?: number\n blurHeight?: number\n}\n\nexport interface StaticRequire {\n default: StaticImageData\n}\n\nexport type StaticImport = StaticRequire | StaticImageData\n\nexport type ImageProps = Omit<\n JSX.IntrinsicElements['img'],\n 'src' | 'srcSet' | 'ref' | 'alt' | 'width' | 'height' | 'loading'\n> & {\n src: string | StaticImport\n alt: string\n width?: number | `${number}`\n height?: number | `${number}`\n fill?: boolean\n loader?: ImageLoader\n quality?: number | `${number}`\n preload?: boolean\n /**\n * @deprecated Use `preload` prop instead.\n * See https://nextjs.org/docs/app/api-reference/components/image#preload\n */\n priority?: boolean\n loading?: LoadingValue\n placeholder?: PlaceholderValue\n blurDataURL?: string\n unoptimized?: boolean\n overrideSrc?: string\n /**\n * @deprecated Use `onLoad` instead.\n * @see https://nextjs.org/docs/app/api-reference/components/image#onload\n */\n onLoadingComplete?: OnLoadingComplete\n /**\n * @deprecated Use `fill` prop instead of `layout=\"fill\"` or change import to `next/legacy/image`.\n * @see https://nextjs.org/docs/api-reference/next/legacy/image\n */\n layout?: string\n /**\n * @deprecated Use `style` prop instead.\n */\n objectFit?: string\n /**\n * @deprecated Use `style` prop instead.\n */\n objectPosition?: string\n /**\n * @deprecated This prop does not do anything.\n */\n lazyBoundary?: string\n /**\n * @deprecated This prop does not do anything.\n */\n lazyRoot?: string\n}\n\nexport type ImgProps = Omit<ImageProps, 'src' | 'loader'> & {\n loading: LoadingValue\n width: number | undefined\n height: number | undefined\n style: NonNullable<JSX.IntrinsicElements['img']['style']>\n sizes: string | undefined\n srcSet: string | undefined\n src: string\n}\n\nconst VALID_LOADING_VALUES = ['lazy', 'eager', undefined] as const\n\n// Object-fit values that are not valid background-size values\nconst INVALID_BACKGROUND_SIZE_VALUES = [\n '-moz-initial',\n 'fill',\n 'none',\n 'scale-down',\n undefined,\n]\ntype LoadingValue = (typeof VALID_LOADING_VALUES)[number]\ntype ImageConfig = ImageConfigComplete & {\n allSizes: number[]\n output?: 'standalone' | 'export'\n}\n\nexport type ImageLoader = (p: ImageLoaderProps) => string\n\n// Do not export - this is an internal type only\n// because `next.config.js` is only meant for the\n// built-in loaders, not for a custom loader() prop.\ntype ImageLoaderWithConfig = (p: ImageLoaderPropsWithConfig) => string\n\nexport type PlaceholderValue = 'blur' | 'empty' | `data:image/${string}`\nexport type OnLoad = React.ReactEventHandler<HTMLImageElement> | undefined\nexport type OnLoadingComplete = (img: HTMLImageElement) => void\n\nexport type PlaceholderStyle = Partial<\n Pick<\n CSSProperties,\n | 'backgroundSize'\n | 'backgroundPosition'\n | 'backgroundRepeat'\n | 'backgroundImage'\n >\n>\n\nfunction isStaticRequire(\n src: StaticRequire | StaticImageData\n): src is StaticRequire {\n return (src as StaticRequire).default !== undefined\n}\n\nfunction isStaticImageData(\n src: StaticRequire | StaticImageData\n): src is StaticImageData {\n return (src as StaticImageData).src !== undefined\n}\n\nfunction isStaticImport(src: string | StaticImport): src is StaticImport {\n return (\n !!src &&\n typeof src === 'object' &&\n (isStaticRequire(src as StaticImport) ||\n isStaticImageData(src as StaticImport))\n )\n}\n\nconst allImgs = new Map<\n string,\n { src: string; loading: LoadingValue; placeholder: PlaceholderValue }\n>()\nlet perfObserver: PerformanceObserver | undefined\n\nfunction getInt(x: unknown): number | undefined {\n if (typeof x === 'undefined') {\n return x\n }\n if (typeof x === 'number') {\n return Number.isFinite(x) ? x : NaN\n }\n if (typeof x === 'string' && /^[0-9]+$/.test(x)) {\n return parseInt(x, 10)\n }\n return NaN\n}\n\nfunction getWidths(\n { deviceSizes, allSizes }: ImageConfig,\n width: number | undefined,\n sizes: string | undefined\n): { widths: number[]; kind: 'w' | 'x' } {\n if (sizes) {\n // Find all the \"vw\" percent sizes used in the sizes prop\n const viewportWidthRe = /(^|\\s)(1?\\d?\\d)vw/g\n const percentSizes = []\n for (let match; (match = viewportWidthRe.exec(sizes)); match) {\n percentSizes.push(parseInt(match[2]))\n }\n if (percentSizes.length) {\n const smallestRatio = Math.min(...percentSizes) * 0.01\n return {\n widths: allSizes.filter((s) => s >= deviceSizes[0] * smallestRatio),\n kind: 'w',\n }\n }\n return { widths: allSizes, kind: 'w' }\n }\n if (typeof width !== 'number') {\n return { widths: deviceSizes, kind: 'w' }\n }\n\n const widths = [\n ...new Set(\n // > This means that most OLED screens that say they are 3x resolution,\n // > are actually 3x in the green color, but only 1.5x in the red and\n // > blue colors. Showing a 3x resolution image in the app vs a 2x\n // > resolution image will be visually the same, though the 3x image\n // > takes significantly more data. Even true 3x resolution screens are\n // > wasteful as the human eye cannot see that level of detail without\n // > something like a magnifying glass.\n // https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html\n [width, width * 2 /*, width * 3*/].map(\n (w) => allSizes.find((p) => p >= w) || allSizes[allSizes.length - 1]\n )\n ),\n ]\n return { widths, kind: 'x' }\n}\n\ntype GenImgAttrsData = {\n config: ImageConfig\n src: string\n unoptimized: boolean\n loader: ImageLoaderWithConfig\n width?: number\n quality?: number\n sizes?: string\n}\n\ntype GenImgAttrsResult = {\n src: string\n srcSet: string | undefined\n sizes: string | undefined\n}\n\nfunction generateImgAttrs({\n config,\n src,\n unoptimized,\n width,\n quality,\n sizes,\n loader,\n}: GenImgAttrsData): GenImgAttrsResult {\n if (unoptimized) {\n if (src.startsWith('/') && !src.startsWith('//')) {\n let deploymentId = getDeploymentId()\n if (src.includes('/_next/static/immutable') && !getAssetToken()) {\n // immutable static asset and supported by platform, don't add `?dpl=`\n deploymentId = undefined\n } else if (deploymentId) {\n // We unfortunately can't easily use `new URL()` here, because it normalizes the URL which causes\n // double-encoding with the `encodeURIComponent(src)` below\n const qIndex = src.indexOf('?')\n if (qIndex !== -1) {\n const params = new URLSearchParams(src.slice(qIndex + 1))\n const srcDpl = params.get('dpl')\n if (!srcDpl) {\n // src is missing the dpl parameter, but we have a deploymentId, so add it to the src URL\n params.append('dpl', deploymentId)\n src = src.slice(0, qIndex) + '?' + params.toString()\n }\n } else {\n // src is missing the dpl parameter, but we have a deploymentId, so add it to the src URL\n src = src + `?dpl=${deploymentId}`\n }\n }\n }\n return { src, srcSet: undefined, sizes: undefined }\n }\n\n const { widths, kind } = getWidths(config, width, sizes)\n const last = widths.length - 1\n\n return {\n sizes: !sizes && kind === 'w' ? '100vw' : sizes,\n srcSet: widths\n .map(\n (w, i) =>\n `${loader({ config, src, quality, width: w })} ${\n kind === 'w' ? w : i + 1\n }${kind}`\n )\n .join(', '),\n\n // It's intended to keep `src` the last attribute because React updates\n // attributes in order. If we keep `src` the first one, Safari will\n // immediately start to fetch `src`, before `sizes` and `srcSet` are even\n // updated by React. That causes multiple unnecessary requests if `srcSet`\n // and `sizes` are defined.\n // This bug cannot be reproduced in Chrome or Firefox.\n src: loader({ config, src, quality, width: widths[last] }),\n }\n}\n\n/**\n * A shared function, used on both client and server, to generate the props for <img>.\n */\nexport function getImgProps(\n {\n src,\n sizes,\n unoptimized = false,\n priority = false,\n preload = false,\n loading,\n className,\n quality,\n width,\n height,\n fill = false,\n style,\n overrideSrc,\n onLoad,\n onLoadingComplete,\n placeholder = 'empty',\n blurDataURL,\n fetchPriority,\n decoding = 'async',\n layout,\n objectFit,\n objectPosition,\n lazyBoundary,\n lazyRoot,\n ...rest\n }: ImageProps,\n _state: {\n defaultLoader: ImageLoaderWithConfig\n imgConf: ImageConfigComplete\n showAltText?: boolean\n blurComplete?: boolean\n }\n): {\n props: ImgProps\n meta: {\n unoptimized: boolean\n preload: boolean\n placeholder: NonNullable<ImageProps['placeholder']>\n fill: boolean\n }\n} {\n const { imgConf, showAltText, blurComplete, defaultLoader } = _state\n let config: ImageConfig\n let c = imgConf || imageConfigDefault\n if ('allSizes' in c) {\n config = c as ImageConfig\n } else {\n const allSizes = [...c.deviceSizes, ...c.imageSizes].sort((a, b) => a - b)\n const deviceSizes = c.deviceSizes.sort((a, b) => a - b)\n const qualities = c.qualities?.sort((a, b) => a - b)\n config = { ...c, allSizes, deviceSizes, qualities }\n }\n\n if (typeof defaultLoader === 'undefined') {\n throw new Error(\n 'images.loaderFile detected but the file is missing default export.\\nRead more: https://nextjs.org/docs/messages/invalid-images-config'\n )\n }\n let loader: ImageLoaderWithConfig = rest.loader || defaultLoader\n\n // Remove property so it's not spread on <img> element\n delete rest.loader\n delete (rest as any).srcSet\n\n // This special value indicates that the user\n // didn't define a \"loader\" prop or \"loader\" config.\n const isDefaultLoader = '__next_img_default' in loader\n\n if (isDefaultLoader) {\n if (config.loader === 'custom') {\n throw new Error(\n `Image with src \"${src}\" is missing \"loader\" prop.` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader`\n )\n }\n } else {\n // The user defined a \"loader\" prop or config.\n // Since the config object is internal only, we\n // must not pass it to the user-defined \"loader\".\n const customImageLoader = loader as ImageLoader\n loader = (obj) => {\n const { config: _, ...opts } = obj\n return customImageLoader(opts)\n }\n }\n\n if (layout) {\n if (layout === 'fill') {\n fill = true\n }\n const layoutToStyle: Record<string, Record<string, string> | undefined> = {\n intrinsic: { maxWidth: '100%', height: 'auto' },\n responsive: { width: '100%', height: 'auto' },\n }\n const layoutToSizes: Record<string, string | undefined> = {\n responsive: '100vw',\n fill: '100vw',\n }\n const layoutStyle = layoutToStyle[layout]\n if (layoutStyle) {\n style = { ...style, ...layoutStyle }\n }\n const layoutSizes = layoutToSizes[layout]\n if (layoutSizes && !sizes) {\n sizes = layoutSizes\n }\n }\n\n let staticSrc = ''\n let widthInt = getInt(width)\n let heightInt = getInt(height)\n let blurWidth: number | undefined\n let blurHeight: number | undefined\n if (isStaticImport(src)) {\n const staticImageData = isStaticRequire(src) ? src.default : src\n\n if (!staticImageData.src) {\n throw new Error(\n `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(\n staticImageData\n )}`\n )\n }\n if (!staticImageData.height || !staticImageData.width) {\n throw new Error(\n `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(\n staticImageData\n )}`\n )\n }\n\n blurWidth = staticImageData.blurWidth\n blurHeight = staticImageData.blurHeight\n blurDataURL = blurDataURL || staticImageData.blurDataURL\n staticSrc = staticImageData.src\n\n if (!fill) {\n if (!widthInt && !heightInt) {\n widthInt = staticImageData.width\n heightInt = staticImageData.height\n } else if (widthInt && !heightInt) {\n const ratio = widthInt / staticImageData.width\n heightInt = Math.round(staticImageData.height * ratio)\n } else if (!widthInt && heightInt) {\n const ratio = heightInt / staticImageData.height\n widthInt = Math.round(staticImageData.width * ratio)\n }\n }\n }\n src = typeof src === 'string' ? src : staticSrc\n\n let isLazy =\n !priority &&\n !preload &&\n (loading === 'lazy' || typeof loading === 'undefined')\n if (!src || src.startsWith('data:') || src.startsWith('blob:')) {\n // https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n unoptimized = true\n isLazy = false\n }\n if (config.unoptimized) {\n unoptimized = true\n }\n if (\n isDefaultLoader &&\n !config.dangerouslyAllowSVG &&\n src.split('?', 1)[0].endsWith('.svg')\n ) {\n // Special case to make svg serve as-is to avoid proxying\n // through the built-in Image Optimization API.\n unoptimized = true\n }\n\n const qualityInt = getInt(quality)\n\n if (process.env.NODE_ENV !== 'production') {\n const { warnOnce } =\n require('./utils/warn-once') as typeof import('./utils/warn-once')\n if (config.output === 'export' && isDefaultLoader && !unoptimized) {\n throw new Error(\n `Image Optimization using the default loader is not compatible with \\`{ output: 'export' }\\`.\n Possible solutions:\n - Remove \\`{ output: 'export' }\\` and run \"next start\" to run server mode including the Image Optimization API.\n - Configure \\`{ images: { unoptimized: true } }\\` in \\`next.config.js\\` to disable the Image Optimization API.\n Read more: https://nextjs.org/docs/messages/export-image-api`\n )\n }\n if (!src) {\n // React doesn't show the stack trace and there's\n // no `src` to help identify which image, so we\n // instead console.error(ref) during mount.\n unoptimized = true\n } else {\n if (fill) {\n if (width) {\n throw new Error(\n `Image with src \"${src}\" has both \"width\" and \"fill\" properties. Only one should be used.`\n )\n }\n if (height) {\n throw new Error(\n `Image with src \"${src}\" has both \"height\" and \"fill\" properties. Only one should be used.`\n )\n }\n if (style?.position && style.position !== 'absolute') {\n throw new Error(\n `Image with src \"${src}\" has both \"fill\" and \"style.position\" properties. Images with \"fill\" always use position absolute - it cannot be modified.`\n )\n }\n if (style?.width && style.width !== '100%') {\n throw new Error(\n `Image with src \"${src}\" has both \"fill\" and \"style.width\" properties. Images with \"fill\" always use width 100% - it cannot be modified.`\n )\n }\n if (style?.height && style.height !== '100%') {\n throw new Error(\n `Image with src \"${src}\" has both \"fill\" and \"style.height\" properties. Images with \"fill\" always use height 100% - it cannot be modified.`\n )\n }\n } else {\n if (typeof widthInt === 'undefined') {\n throw new Error(\n `Image with src \"${src}\" is missing required \"width\" property.`\n )\n } else if (isNaN(widthInt)) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"width\" property. Expected a numeric value in pixels but received \"${width}\".`\n )\n }\n if (typeof heightInt === 'undefined') {\n throw new Error(\n `Image with src \"${src}\" is missing required \"height\" property.`\n )\n } else if (isNaN(heightInt)) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"height\" property. Expected a numeric value in pixels but received \"${height}\".`\n )\n }\n // eslint-disable-next-line no-control-regex\n if (/^[\\x00-\\x20]/.test(src)) {\n throw new Error(\n `Image with src \"${src}\" cannot start with a space or control character. Use src.trimStart() to remove it or encodeURIComponent(src) to keep it.`\n )\n }\n // eslint-disable-next-line no-control-regex\n if (/[\\x00-\\x20]$/.test(src)) {\n throw new Error(\n `Image with src \"${src}\" cannot end with a space or control character. Use src.trimEnd() to remove it or encodeURIComponent(src) to keep it.`\n )\n }\n }\n }\n if (!VALID_LOADING_VALUES.includes(loading)) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"loading\" property. Provided \"${loading}\" should be one of ${VALID_LOADING_VALUES.map(\n String\n ).join(',')}.`\n )\n }\n if (priority && loading === 'lazy') {\n throw new Error(\n `Image with src \"${src}\" has both \"priority\" and \"loading='lazy'\" properties. Only one should be used.`\n )\n }\n if (preload && loading === 'lazy') {\n throw new Error(\n `Image with src \"${src}\" has both \"preload\" and \"loading='lazy'\" properties. Only one should be used.`\n )\n }\n if (preload && priority) {\n throw new Error(\n `Image with src \"${src}\" has both \"preload\" and \"priority\" properties. Only \"preload\" should be used.`\n )\n }\n if (\n placeholder !== 'empty' &&\n placeholder !== 'blur' &&\n !placeholder.startsWith('data:image/')\n ) {\n throw new Error(\n `Image with src \"${src}\" has invalid \"placeholder\" property \"${placeholder}\".`\n )\n }\n if (placeholder !== 'empty') {\n if (widthInt && heightInt && widthInt * heightInt < 1600) {\n warnOnce(\n `Image with src \"${src}\" is smaller than 40x40. Consider removing the \"placeholder\" property to improve performance.`\n )\n }\n }\n if (\n qualityInt &&\n config.qualities &&\n !config.qualities.includes(qualityInt)\n ) {\n warnOnce(\n `Image with src \"${src}\" is using quality \"${qualityInt}\" which is not configured in images.qualities [${config.qualities.join(', ')}]. Please update your config to [${[...config.qualities, qualityInt].sort().join(', ')}].` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-unconfigured-qualities`\n )\n }\n if (placeholder === 'blur' && !blurDataURL) {\n const VALID_BLUR_EXT = ['jpeg', 'png', 'webp', 'avif'] // should match next-image-loader\n\n throw new Error(\n `Image with src \"${src}\" has \"placeholder='blur'\" property but is missing the \"blurDataURL\" property.\n Possible solutions:\n - Add a \"blurDataURL\" property, the contents should be a small Data URL to represent the image\n - Change the \"src\" property to a static import with one of the supported file types: ${VALID_BLUR_EXT.join(\n ','\n )} (animated images not supported)\n - Remove the \"placeholder\" property, effectively no blur effect\n Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url`\n )\n }\n if ('ref' in rest) {\n warnOnce(\n `Image with src \"${src}\" is using unsupported \"ref\" property. Consider using the \"onLoad\" property instead.`\n )\n }\n\n if (!unoptimized && !isDefaultLoader) {\n const urlStr = loader({\n config,\n src,\n width: widthInt || 400,\n quality: qualityInt || 75,\n })\n let url: URL | undefined\n try {\n url = new URL(urlStr)\n } catch (err) {}\n if (urlStr === src || (url && url.pathname === src && !url.search)) {\n warnOnce(\n `Image with src \"${src}\" has a \"loader\" property that does not implement width. Please implement it or use the \"unoptimized\" property instead.` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader-width`\n )\n }\n }\n\n if (onLoadingComplete) {\n warnOnce(\n `Image with src \"${src}\" is using deprecated \"onLoadingComplete\" property. Please use the \"onLoad\" property instead.`\n )\n }\n\n for (const [legacyKey, legacyValue] of Object.entries({\n layout,\n objectFit,\n objectPosition,\n lazyBoundary,\n lazyRoot,\n })) {\n if (legacyValue) {\n warnOnce(\n `Image with src \"${src}\" has legacy prop \"${legacyKey}\". Did you forget to run the codemod?` +\n `\\nRead more: https://nextjs.org/docs/messages/next-image-upgrade-to-13`\n )\n }\n }\n\n if (\n typeof window !== 'undefined' &&\n !perfObserver &&\n window.PerformanceObserver\n ) {\n perfObserver = new PerformanceObserver((entryList) => {\n for (const entry of entryList.getEntries()) {\n // @ts-ignore - missing \"LargestContentfulPaint\" class with \"element\" prop\n const imgSrc = entry?.element?.src || ''\n const lcpImage = allImgs.get(imgSrc)\n if (\n lcpImage &&\n lcpImage.loading === 'lazy' &&\n lcpImage.placeholder === 'empty' &&\n !lcpImage.src.startsWith('data:') &&\n !lcpImage.src.startsWith('blob:')\n ) {\n // https://web.dev/lcp/#measure-lcp-in-javascript\n warnOnce(\n `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.` +\n `\\nRead more: https://nextjs.org/docs/app/api-reference/components/image#loading`\n )\n }\n }\n })\n try {\n perfObserver.observe({\n type: 'largest-contentful-paint',\n buffered: true,\n })\n } catch (err) {\n // Log error but don't crash the app\n console.error(err)\n }\n }\n }\n const imgStyle = Object.assign(\n fill\n ? {\n position: 'absolute',\n height: '100%',\n width: '100%',\n left: 0,\n top: 0,\n right: 0,\n bottom: 0,\n objectFit,\n objectPosition,\n }\n : {},\n showAltText ? {} : { color: 'transparent' },\n style\n )\n\n const backgroundImage =\n !blurComplete && placeholder !== 'empty'\n ? placeholder === 'blur'\n ? `url(\"data:image/svg+xml;charset=utf-8,${getImageBlurSvg({\n widthInt,\n heightInt,\n blurWidth,\n blurHeight,\n blurDataURL: blurDataURL || '', // assume not undefined\n objectFit: imgStyle.objectFit,\n })}\")`\n : `url(\"${placeholder}\")` // assume `data:image/`\n : null\n\n const backgroundSize = !INVALID_BACKGROUND_SIZE_VALUES.includes(\n imgStyle.objectFit\n )\n ? imgStyle.objectFit\n : imgStyle.objectFit === 'fill'\n ? '100% 100%' // the background-size equivalent of `fill`\n : 'cover'\n\n let placeholderStyle: PlaceholderStyle = backgroundImage\n ? {\n backgroundSize,\n backgroundPosition: imgStyle.objectPosition || '50% 50%',\n backgroundRepeat: 'no-repeat',\n backgroundImage,\n }\n : {}\n\n if (process.env.NODE_ENV === 'development') {\n if (\n placeholderStyle.backgroundImage &&\n placeholder === 'blur' &&\n blurDataURL?.startsWith('/')\n ) {\n // During `next dev`, we don't want to generate blur placeholders with webpack\n // because it can delay starting the dev server. Instead, `next-image-loader.js`\n // will inline a special url to lazily generate the blur placeholder at request time.\n placeholderStyle.backgroundImage = `url(\"${blurDataURL}\")`\n }\n }\n\n const imgAttributes = generateImgAttrs({\n config,\n src,\n unoptimized,\n width: widthInt,\n quality: qualityInt,\n sizes,\n loader,\n })\n\n const loadingFinal = isLazy ? 'lazy' : loading\n\n if (process.env.NODE_ENV !== 'production') {\n if (typeof window !== 'undefined') {\n let fullUrl: URL\n try {\n fullUrl = new URL(imgAttributes.src)\n } catch (e) {\n fullUrl = new URL(imgAttributes.src, window.location.href)\n }\n allImgs.set(fullUrl.href, { src, loading: loadingFinal, placeholder })\n }\n }\n\n const props: ImgProps = {\n ...rest,\n loading: loadingFinal,\n fetchPriority,\n width: widthInt,\n height: heightInt,\n decoding,\n className,\n style: { ...imgStyle, ...placeholderStyle },\n sizes: imgAttributes.sizes,\n srcSet: imgAttributes.srcSet,\n src: overrideSrc || imgAttributes.src,\n }\n const meta = { unoptimized, preload: preload || priority, placeholder, fill }\n return { props, meta }\n}\n"],"names":["getAssetToken","getDeploymentId","getImageBlurSvg","imageConfigDefault","VALID_LOADING_VALUES","undefined","INVALID_BACKGROUND_SIZE_VALUES","isStaticRequire","src","default","isStaticImageData","isStaticImport","allImgs","Map","perfObserver","getInt","x","Number","isFinite","NaN","test","parseInt","getWidths","deviceSizes","allSizes","width","sizes","viewportWidthRe","percentSizes","match","exec","push","length","smallestRatio","Math","min","widths","filter","s","kind","Set","map","w","find","p","generateImgAttrs","config","unoptimized","quality","loader","startsWith","deploymentId","includes","qIndex","indexOf","params","URLSearchParams","slice","srcDpl","get","append","toString","srcSet","last","i","join","getImgProps","priority","preload","loading","className","height","fill","style","overrideSrc","onLoad","onLoadingComplete","placeholder","blurDataURL","fetchPriority","decoding","layout","objectFit","objectPosition","lazyBoundary","lazyRoot","rest","_state","imgConf","showAltText","blurComplete","defaultLoader","c","imageSizes","sort","a","b","qualities","Error","isDefaultLoader","customImageLoader","obj","_","opts","layoutToStyle","intrinsic","maxWidth","responsive","layoutToSizes","layoutStyle","layoutSizes","staticSrc","widthInt","heightInt","blurWidth","blurHeight","staticImageData","JSON","stringify","ratio","round","isLazy","dangerouslyAllowSVG","split","endsWith","qualityInt","process","env","NODE_ENV","warnOnce","require","output","position","isNaN","String","VALID_BLUR_EXT","urlStr","url","URL","err","pathname","search","legacyKey","legacyValue","Object","entries","window","PerformanceObserver","entryList","entry","getEntries","imgSrc","element","lcpImage","observe","type","buffered","console","error","imgStyle","assign","left","top","right","bottom","color","backgroundImage","backgroundSize","placeholderStyle","backgroundPosition","backgroundRepeat","imgAttributes","loadingFinal","full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IAChCzF,gBAAgB,UAChBC,aAAa5B,WAAW,MACxB;YACA,8EAA8E;YAC9E,gFAAgF;YAChF,qFAAqF;YACrFsH,iBAAiBF,eAAe,GAAG,CAAC,KAAK,EAAExF,YAAY,EAAE,CAAC;QAC5D;IACF;IAEA,MAAM6F,gBAAgB9H,iBAAiB;QACrCC;QACAtC;QACAuC;QACAtB,OAAOuF;QACPhE,SAAS6E;QACTnG;QACAuB;IACF;IAEA,MAAM2H,eAAenD,SAAS,SAASpD;IAEvC,IAAIyD,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,OAAOkB,WAAW,aAAa;YACjC,IAAI2B;YACJ,IAAI;gBACFA,UAAU,IAAInC,IAAIiC,cAAcnK,GAAG;YACrC,EAAE,OAAOsK,GAAG;gBACVD,UAAU,IAAInC,IAAIiC,cAAcnK,GAAG,EAAE0I,OAAO6B,QAAQ,CAACC,IAAI;YAC3D;YACApK,QAAQqK,GAAG,CAACJ,QAAQG,IAAI,EAAE;gBAAExK;gBAAK6D,SAASuG;gBAAc/F;YAAY;QACtE;IACF;IAEA,MAAMqG,QAAkB;QACtB,GAAG5F,IAAI;QACPjB,SAASuG;QACT7F;QACAtD,OAAOuF;QACPzC,QAAQ0C;QACRjC;QACAV;QACAG,OAAO;YAAE,GAAGsF,QAAQ;YAAE,GAAGS,gBAAgB;QAAC;QAC1C9I,OAAOiJ,cAAcjJ,KAAK;QAC1BoC,QAAQ6G,cAAc7G,MAAM;QAC5BtD,KAAKkE,eAAeiG,cAAcnK,GAAG;IACvC;IACA,MAAM2K,OAAO;QAAEpI;QAAaqB,SAASA,WAAWD;QAAUU;QAAaL;IAAK;IAC5E,OAAO;QAAE0G;QAAOC;IAAK;AACvB","ignoreList":[0]}
|
|
@@ -83,11 +83,19 @@ function buildResponse(proxyResponse) {
|
|
|
83
83
|
headers: new Headers(headers)
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
+
function passthroughFetch(originalFetch, request) {
|
|
87
|
+
// Mark the request so the ClientRequest interception in `httpget.ts` sends it
|
|
88
|
+
// to the real server instead of intercepting it again. @mswjs/interceptors
|
|
89
|
+
// intercepts at the TCP level, so an unmarked passthrough would re-enter the
|
|
90
|
+
// interception listener from within itself, recursing indefinitely.
|
|
91
|
+
request.headers.set('next-test-internal', '1');
|
|
92
|
+
return originalFetch(request);
|
|
93
|
+
}
|
|
86
94
|
async function handleFetch(originalFetch, request) {
|
|
87
95
|
const testInfo = (0, _context.getTestReqInfo)(request, reader);
|
|
88
96
|
if (!testInfo) {
|
|
89
97
|
// Passthrough non-test requests.
|
|
90
|
-
return originalFetch
|
|
98
|
+
return passthroughFetch(originalFetch, request);
|
|
91
99
|
}
|
|
92
100
|
const { testData, proxyPort } = testInfo;
|
|
93
101
|
const proxyRequest = await buildProxyRequest(testData, request);
|
|
@@ -118,7 +126,7 @@ async function handleFetch(originalFetch, request) {
|
|
|
118
126
|
const { api } = proxyResponse;
|
|
119
127
|
switch(api){
|
|
120
128
|
case 'continue':
|
|
121
|
-
return originalFetch
|
|
129
|
+
return passthroughFetch(originalFetch, request);
|
|
122
130
|
case 'abort':
|
|
123
131
|
case 'unhandled':
|
|
124
132
|
throw Object.defineProperty(new Error(`Proxy request aborted [${request.method} ${request.url}]`), "__NEXT_ERROR_CODE", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/experimental/testmode/fetch.ts"],"sourcesContent":["import type {\n ProxyFetchRequest,\n ProxyFetchResponse,\n ProxyResponse,\n} from './proxy'\nimport { getTestReqInfo, type TestRequestReader } from './context'\n\ntype Fetch = typeof fetch\ntype FetchInputArg = Parameters<Fetch>[0]\ntype FetchInitArg = Parameters<Fetch>[1]\n\nexport const reader: TestRequestReader<Request> = {\n url(req) {\n return req.url\n },\n header(req, name) {\n return req.headers.get(name)\n },\n}\n\nfunction getTestStack(): string {\n let stack = (new Error().stack ?? '').split('\\n')\n // Skip the first line and find first non-empty line.\n for (let i = 1; i < stack.length; i++) {\n if (stack[i].length > 0) {\n stack = stack.slice(i)\n break\n }\n }\n // Filter out franmework lines.\n stack = stack.filter((f) => !f.includes('/next/dist/'))\n // At most 5 lines.\n stack = stack.slice(0, 5)\n // Cleanup some internal info and trim.\n stack = stack.map((s) => s.replace('webpack-internal:///(rsc)/', '').trim())\n return stack.join(' ')\n}\n\nasync function buildProxyRequest(\n testData: string,\n request: Request\n): Promise<ProxyFetchRequest> {\n const {\n url,\n method,\n headers,\n body,\n cache,\n credentials,\n integrity,\n mode,\n redirect,\n referrer,\n referrerPolicy,\n } = request\n return {\n testData,\n api: 'fetch',\n request: {\n url,\n method,\n headers: [...Array.from(headers), ['next-test-stack', getTestStack()]],\n body: body\n ? Buffer.from(await request.arrayBuffer()).toString('base64')\n : null,\n cache,\n credentials,\n integrity,\n mode,\n redirect,\n referrer,\n referrerPolicy,\n },\n }\n}\n\nfunction buildResponse(proxyResponse: ProxyFetchResponse): Response {\n const { status, headers, body } = proxyResponse.response\n return new Response(body ? Buffer.from(body, 'base64') : null, {\n status,\n headers: new Headers(headers),\n })\n}\n\nexport async function handleFetch(\n originalFetch: Fetch,\n request: Request\n): Promise<Response> {\n const testInfo = getTestReqInfo(request, reader)\n if (!testInfo) {\n // Passthrough non-test requests.\n return originalFetch
|
|
1
|
+
{"version":3,"sources":["../../../src/experimental/testmode/fetch.ts"],"sourcesContent":["import type {\n ProxyFetchRequest,\n ProxyFetchResponse,\n ProxyResponse,\n} from './proxy'\nimport { getTestReqInfo, type TestRequestReader } from './context'\n\ntype Fetch = typeof fetch\ntype FetchInputArg = Parameters<Fetch>[0]\ntype FetchInitArg = Parameters<Fetch>[1]\n\nexport const reader: TestRequestReader<Request> = {\n url(req) {\n return req.url\n },\n header(req, name) {\n return req.headers.get(name)\n },\n}\n\nfunction getTestStack(): string {\n let stack = (new Error().stack ?? '').split('\\n')\n // Skip the first line and find first non-empty line.\n for (let i = 1; i < stack.length; i++) {\n if (stack[i].length > 0) {\n stack = stack.slice(i)\n break\n }\n }\n // Filter out franmework lines.\n stack = stack.filter((f) => !f.includes('/next/dist/'))\n // At most 5 lines.\n stack = stack.slice(0, 5)\n // Cleanup some internal info and trim.\n stack = stack.map((s) => s.replace('webpack-internal:///(rsc)/', '').trim())\n return stack.join(' ')\n}\n\nasync function buildProxyRequest(\n testData: string,\n request: Request\n): Promise<ProxyFetchRequest> {\n const {\n url,\n method,\n headers,\n body,\n cache,\n credentials,\n integrity,\n mode,\n redirect,\n referrer,\n referrerPolicy,\n } = request\n return {\n testData,\n api: 'fetch',\n request: {\n url,\n method,\n headers: [...Array.from(headers), ['next-test-stack', getTestStack()]],\n body: body\n ? Buffer.from(await request.arrayBuffer()).toString('base64')\n : null,\n cache,\n credentials,\n integrity,\n mode,\n redirect,\n referrer,\n referrerPolicy,\n },\n }\n}\n\nfunction buildResponse(proxyResponse: ProxyFetchResponse): Response {\n const { status, headers, body } = proxyResponse.response\n return new Response(body ? Buffer.from(body, 'base64') : null, {\n status,\n headers: new Headers(headers),\n })\n}\n\nfunction passthroughFetch(\n originalFetch: Fetch,\n request: Request\n): Promise<Response> {\n // Mark the request so the ClientRequest interception in `httpget.ts` sends it\n // to the real server instead of intercepting it again. @mswjs/interceptors\n // intercepts at the TCP level, so an unmarked passthrough would re-enter the\n // interception listener from within itself, recursing indefinitely.\n request.headers.set('next-test-internal', '1')\n return originalFetch(request)\n}\n\nexport async function handleFetch(\n originalFetch: Fetch,\n request: Request\n): Promise<Response> {\n const testInfo = getTestReqInfo(request, reader)\n if (!testInfo) {\n // Passthrough non-test requests.\n return passthroughFetch(originalFetch, request)\n }\n\n const { testData, proxyPort } = testInfo\n const proxyRequest = await buildProxyRequest(testData, request)\n\n const resp = await originalFetch(`http://localhost:${proxyPort}`, {\n method: 'POST',\n body: JSON.stringify(proxyRequest),\n // The header lets the ClientRequest interception in `httpget.ts` identify\n // this request as part of the test proxy protocol. @mswjs/interceptors\n // intercepts at the TCP level, so this request would otherwise be\n // intercepted again when it's sent from within an interception listener,\n // recursing indefinitely.\n headers: {\n 'next-test-internal': '1',\n },\n next: {\n // @ts-ignore\n internal: true,\n },\n })\n if (!resp.ok) {\n throw new Error(`Proxy request failed: ${resp.status}`)\n }\n\n const proxyResponse = (await resp.json()) as ProxyResponse\n const { api } = proxyResponse\n switch (api) {\n case 'continue':\n return passthroughFetch(originalFetch, request)\n case 'abort':\n case 'unhandled':\n throw new Error(\n `Proxy request aborted [${request.method} ${request.url}]`\n )\n case 'fetch':\n return buildResponse(proxyResponse)\n default:\n return api satisfies never\n }\n}\n\nexport function interceptFetch(originalFetch: Fetch) {\n global.fetch = function testFetch(\n input: FetchInputArg,\n init?: FetchInitArg\n ): Promise<Response> {\n // Passthrough internal requests.\n // @ts-ignore\n if (init?.next?.internal) {\n return originalFetch(input, init)\n }\n return handleFetch(originalFetch, new Request(input, init))\n }\n return () => {\n global.fetch = originalFetch\n }\n}\n"],"names":["handleFetch","interceptFetch","reader","url","req","header","name","headers","get","getTestStack","stack","Error","split","i","length","slice","filter","f","includes","map","s","replace","trim","join","buildProxyRequest","testData","request","method","body","cache","credentials","integrity","mode","redirect","referrer","referrerPolicy","api","Array","from","Buffer","arrayBuffer","toString","buildResponse","proxyResponse","status","response","Response","Headers","passthroughFetch","originalFetch","set","testInfo","getTestReqInfo","proxyPort","proxyRequest","resp","JSON","stringify","next","internal","ok","json","global","fetch","testFetch","input","init","Request"],"mappings":";;;;;;;;;;;;;;;;IAgGsBA,WAAW;eAAXA;;IAkDNC,cAAc;eAAdA;;IAvIHC,MAAM;eAANA;;;yBAN0C;AAMhD,MAAMA,SAAqC;IAChDC,KAAIC,GAAG;QACL,OAAOA,IAAID,GAAG;IAChB;IACAE,QAAOD,GAAG,EAAEE,IAAI;QACd,OAAOF,IAAIG,OAAO,CAACC,GAAG,CAACF;IACzB;AACF;AAEA,SAASG;IACP,IAAIC,QAAQ,AAAC,CAAA,IAAIC,QAAQD,KAAK,IAAI,EAAC,EAAGE,KAAK,CAAC;IAC5C,qDAAqD;IACrD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egD,aAAoB;IACjDa,OAAOC,KAAK,GAAG,SAASC,UACtBC,KAAoB,EACpBC,IAAmB;YAIfA;QAFJ,iCAAiC;QACjC,aAAa;QACb,IAAIA,yBAAAA,aAAAA,KAAMR,IAAI,qBAAVQ,WAAYP,QAAQ,EAAE;YACxB,OAAOV,cAAcgB,OAAOC;QAC9B;QACA,OAAOlE,YAAYiD,eAAe,IAAIkB,QAAQF,OAAOC;IACvD;IACA,OAAO;QACLJ,OAAOC,KAAK,GAAGd;IACjB;AACF","ignoreList":[0]}
|
|
@@ -72,7 +72,7 @@ async function fetchPkgInfo(pkg) {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
const data = await res.json();
|
|
75
|
-
const versionData = data.versions["16.3.
|
|
75
|
+
const versionData = data.versions["16.3.4"];
|
|
76
76
|
return {
|
|
77
77
|
os: versionData.os,
|
|
78
78
|
cpu: versionData.cpu,
|
|
@@ -100,7 +100,7 @@ async function patchIncorrectLockfile(dir) {
|
|
|
100
100
|
const expectedSwcPkgs = Object.keys(_packagejson.optionalDependencies || {}).filter((pkg)=>pkg.startsWith('@next/swc-'));
|
|
101
101
|
const patchDependency = (pkg, pkgData)=>{
|
|
102
102
|
lockfileParsed.dependencies[pkg] = {
|
|
103
|
-
version: "16.3.
|
|
103
|
+
version: "16.3.4",
|
|
104
104
|
resolved: pkgData.tarball,
|
|
105
105
|
integrity: pkgData.integrity,
|
|
106
106
|
optional: true
|
|
@@ -108,7 +108,7 @@ async function patchIncorrectLockfile(dir) {
|
|
|
108
108
|
};
|
|
109
109
|
const patchPackage = (pkg, pkgData)=>{
|
|
110
110
|
lockfileParsed.packages[pkg] = {
|
|
111
|
-
version: "16.3.
|
|
111
|
+
version: "16.3.4",
|
|
112
112
|
resolved: pkgData.tarball,
|
|
113
113
|
integrity: pkgData.integrity,
|
|
114
114
|
cpu: pkgData.cpu,
|
|
@@ -44,7 +44,7 @@ function _interop_require_default(obj) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
function getTypeScriptPackageInfo(baseDir) {
|
|
47
|
-
var _packageJson_bin;
|
|
47
|
+
var _packageJson_bin, _Object_entries_find;
|
|
48
48
|
let packageJsonPath;
|
|
49
49
|
try {
|
|
50
50
|
packageJsonPath = (0, _resolvefrom.resolveFrom)(baseDir, 'typescript/package.json');
|
|
@@ -54,7 +54,7 @@ function getTypeScriptPackageInfo(baseDir) {
|
|
|
54
54
|
const packageJson = JSON.parse((0, _nodefs.readFileSync)(packageJsonPath, 'utf8'));
|
|
55
55
|
const packageDir = _nodepath.default.dirname(packageJsonPath);
|
|
56
56
|
const apiPath = _nodepath.default.join(packageDir, 'lib', 'typescript.js');
|
|
57
|
-
const tscBin = typeof packageJson.bin === 'string' ? packageJson.bin : (_packageJson_bin = packageJson.bin) == null ? void 0 : _packageJson_bin.tsc;
|
|
57
|
+
const tscBin = typeof packageJson.bin === 'string' ? packageJson.bin : ((_packageJson_bin = packageJson.bin) == null ? void 0 : _packageJson_bin.tsc) ?? ((_Object_entries_find = Object.entries(packageJson.bin ?? {}).find(([name])=>/^tsc\d+$/.test(name))) == null ? void 0 : _Object_entries_find[1]);
|
|
58
58
|
const tscBinPath = tscBin ? _nodepath.default.resolve(packageDir, tscBin) : undefined;
|
|
59
59
|
let tscPath = tscBinPath;
|
|
60
60
|
if (tscBinPath && (0, _nodefs.existsSync)(tscBinPath) && packageJson.type === 'module' && _nodepath.default.extname(tscBinPath) === '') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/typescript/runTypeScriptCli.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport path from 'node:path'\nimport { spawnSync } from 'node:child_process'\n\nimport spawn from 'next/dist/compiled/cross-spawn'\n\nimport { bold } from '../picocolors'\nimport { resolveFrom } from '../resolve-from'\n\nexport interface TypeScriptPackageInfo {\n packageJsonPath: string\n packageDir: string\n version: string\n apiPath?: string\n tscPath?: string\n}\n\nexport function getTypeScriptPackageInfo(\n baseDir: string\n): TypeScriptPackageInfo | null {\n let packageJsonPath: string\n try {\n packageJsonPath = resolveFrom(baseDir, 'typescript/package.json')\n } catch {\n return null\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n version: string\n type?: string\n bin?: string | Record<string, string>\n }\n const packageDir = path.dirname(packageJsonPath)\n const apiPath = path.join(packageDir, 'lib', 'typescript.js')\n const tscBin =\n typeof packageJson.bin === 'string' ? packageJson.bin : packageJson.bin?.tsc\n const tscBinPath = tscBin ? path.resolve(packageDir, tscBin) : undefined\n let tscPath = tscBinPath\n\n if (\n tscBinPath &&\n existsSync(tscBinPath) &&\n packageJson.type === 'module' &&\n path.extname(tscBinPath) === ''\n ) {\n // TypeScript 7's extensionless ESM bin wrapper cannot be used as Node's\n // main entry point on Node.js 20.9. Its imported JS entry is the same CLI\n // wrapper and works across all supported Node.js versions.\n const tscJsPath = path.join(packageDir, 'lib', 'tsc.js')\n if (existsSync(tscJsPath)) {\n tscPath = tscJsPath\n }\n }\n\n return {\n packageJsonPath,\n packageDir,\n version: packageJson.version,\n apiPath: existsSync(apiPath) ? apiPath : undefined,\n tscPath: tscPath && existsSync(tscPath) ? tscPath : undefined,\n }\n}\n\nexport function hasNativeTypeScriptPreview(baseDir: string): boolean {\n try {\n resolveFrom(baseDir, '@typescript/native-preview/package.json')\n return true\n } catch {\n return false\n }\n}\n\nexport function getTypeScriptApiMissingError(version: string): Error {\n return new Error(\n `TypeScript ${version} does not provide the compiler API required by Next.js. ` +\n `Set ${bold('experimental.useTypeScriptCli')} back to true in your Next.js config to use the TypeScript CLI, ` +\n `or install TypeScript 6 instead.`\n )\n}\n\nexport interface TypeScriptCliResult {\n exitCode: number\n signal: NodeJS.Signals | null\n stdout: string\n stderr: string\n}\n\nconst terminationSignals: NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGHUP']\n\nexport function runTypeScriptCli({\n cwd,\n tscPath,\n args,\n captureOutput = false,\n onFirstOutput,\n}: {\n cwd: string\n tscPath: string\n args: string[]\n /**\n * Accumulate stdout/stderr into the resolved result instead of forwarding it\n * to this process's stdout/stderr (for e.g. parsing `--showConfig` output).\n */\n captureOutput?: boolean\n /**\n * Called once, on the first chunk of forwarded output. Used to stop the build\n * spinner before `tsc`'s diagnostics appear. Not called when capturing.\n */\n onFirstOutput?: () => void\n}): Promise<TypeScriptCliResult> {\n return new Promise((resolve, reject) => {\n const child = spawn(process.execPath, [tscPath, ...args], {\n cwd,\n // TypeScript 7's Node wrapper starts the native compiler synchronously\n // on older Node.js releases. A separate process group lets termination\n // reach both processes instead of orphaning the native compiler.\n detached: process.platform !== 'win32',\n shell: false,\n stdio: ['ignore', 'pipe', 'pipe'],\n env: {\n ...process.env,\n // Piping stdio makes `tsc` disable colored/pretty diagnostics. Restore\n // them when we are forwarding output to a TTY (not capturing it for\n // parsing, e.g. `--showConfig`).\n ...(!captureOutput && process.stdout.isTTY\n ? { FORCE_COLOR: '1' }\n : undefined),\n },\n })\n\n let stdout = ''\n let stderr = ''\n\n child.stdout?.setEncoding('utf8')\n child.stderr?.setEncoding('utf8')\n\n if (captureOutput) {\n child.stdout?.on('data', (chunk: string) => {\n stdout += chunk\n })\n child.stderr?.on('data', (chunk: string) => {\n stderr += chunk\n })\n } else {\n const forward = (dest: NodeJS.WriteStream, chunk: string) => {\n onFirstOutput?.()\n onFirstOutput = undefined // ensure we don't call it again\n dest.write(chunk)\n }\n\n child.stdout?.on('data', (chunk: string) => {\n forward(process.stdout, chunk)\n })\n child.stderr?.on('data', (chunk: string) => {\n forward(process.stderr, chunk)\n })\n }\n\n let terminationRequested = false\n const terminateChild = () => {\n if (terminationRequested || child.killed || child.pid === undefined) {\n return\n }\n terminationRequested = true\n\n // The native compiler ignores SIGTERM and SIGINT, so send a kill signal.\n // Target the whole process group so the signal reaches the native compiler whether\n // it is a grandchild or a direct child.\n // https://github.com/microsoft/typescript-go/pull/4592 should improve this in the long run\n if (process.platform === 'win32') {\n spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], {\n stdio: 'ignore',\n windowsHide: true,\n })\n } else {\n try {\n // https://www.youtube.com/watch?v=Fow7iUaKrq4\n process.kill(-child.pid, 'SIGKILL')\n } catch {\n // The process may have exited between the lifecycle event and kill.\n }\n }\n }\n const terminateOnExit = () => terminateChild()\n process.once('exit', terminateOnExit)\n\n const handler = () => {\n terminateChild()\n process.exit(1)\n }\n for (const signal of terminationSignals) {\n process.once(signal, handler)\n }\n\n const cleanup = () => {\n process.off('exit', terminateOnExit)\n for (const signal of terminationSignals) {\n process.off(signal, handler)\n }\n }\n\n let settled = false\n const finish = (settle: () => void) => {\n if (settled) {\n return\n }\n settled = true\n cleanup()\n settle()\n }\n\n child.on('error', (error) => {\n finish(() => reject(error))\n })\n child.on('close', (code, signal) => {\n finish(() => {\n resolve({\n exitCode: code ?? 1,\n signal,\n stdout,\n stderr,\n })\n })\n })\n })\n}\n\nexport async function getTypeScriptConfigurationCli({\n baseDir,\n tsConfigPath,\n tscPath,\n}: {\n baseDir: string\n tsConfigPath: string\n tscPath: string\n}): Promise<{ compilerOptions: Record<string, any> }> {\n const result = await runTypeScriptCli({\n cwd: baseDir,\n tscPath,\n args: ['--showConfig', '--project', tsConfigPath, '--pretty', 'false'],\n captureOutput: true,\n })\n\n if (result.exitCode !== 0) {\n throw new Error(\n [result.stdout, result.stderr].filter(Boolean).join('\\n').trim()\n )\n }\n\n try {\n return JSON.parse(result.stdout)\n } catch (cause) {\n throw new Error(`Could not parse output from TypeScript's --showConfig.`, {\n cause,\n })\n }\n}\n"],"names":["getTypeScriptApiMissingError","getTypeScriptConfigurationCli","getTypeScriptPackageInfo","hasNativeTypeScriptPreview","runTypeScriptCli","baseDir","packageJson","packageJsonPath","resolveFrom","JSON","parse","readFileSync","packageDir","path","dirname","apiPath","join","tscBin","bin","tsc","tscBinPath","resolve","undefined","tscPath","existsSync","type","extname","tscJsPath","version","Error","bold","terminationSignals","cwd","args","captureOutput","onFirstOutput","Promise","reject","child","spawn","process","execPath","detached","platform","shell","stdio","env","stdout","isTTY","FORCE_COLOR","stderr","setEncoding","on","chunk","forward","dest","write","terminationRequested","terminateChild","killed","pid","spawnSync","String","windowsHide","kill","terminateOnExit","once","handler","exit","signal","cleanup","off","settled","finish","settle","error","code","exitCode","tsConfigPath","result","filter","Boolean","trim","cause"],"mappings":";;;;;;;;;;;;;;;;;;IAwEgBA,4BAA4B;eAA5BA;;IA2JMC,6BAA6B;eAA7BA;;IAlNNC,wBAAwB;eAAxBA;;IA8CAC,0BAA0B;eAA1BA;;IA0BAC,gBAAgB;eAAhBA;;;wBAzFyB;iEACxB;mCACS;mEAER;4BAEG;6BACO;;;;;;AAUrB,SAASF,yBACdG,OAAe;QAiB2CC;IAf1D,IAAIC;IACJ,IAAI;QACFA,kBAAkBC,IAAAA,wBAAW,EAACH,SAAS;IACzC,EAAE,OAAM;QACN,OAAO;IACT;IAEA,MAAMC,cAAcG,KAAKC,KAAK,CAACC,IAAAA,oBAAY,EAACJ,iBAAiB;IAK7D,MAAMK,aAAaC,iBAAI,CAACC,OAAO,CAACP;IAChC,MAAMQ,UAAUF,iBAAI,CAACG,IAAI,CAACJ,YAAY,OAAO;IAC7C,MAAMK,SACJ,OAAOX,YAAYY,GAAG,KAAK,WAAWZ,YAAYY,GAAG,IAAGZ,mBAAAA,YAAYY,GAAG,qBAAfZ,iBAAiBa,GAAG;IAC9E,MAAMC,aAAaH,SAASJ,iBAAI,CAACQ,OAAO,CAACT,YAAYK,UAAUK;IAC/D,IAAIC,UAAUH;IAEd,IACEA,cACAI,IAAAA,kBAAU,EAACJ,eACXd,YAAYmB,IAAI,KAAK,YACrBZ,iBAAI,CAACa,OAAO,CAACN,gBAAgB,IAC7B;QACA,wEAAwE;QACxE,0EAA0E;QAC1E,2DAA2D;QAC3D,MAAMO,YAAYd,iBAAI,CAACG,IAAI,CAACJ,YAAY,OAAO;QAC/C,IAAIY,IAAAA,kBAAU,EAACG,YAAY;YACzBJ,UAAUI;QACZ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C,EAAE;YACxEsD;QACF,IAFM,qBAAA;mBAAA;wBAAA;0BAAA;QAEL;IACH;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/typescript/runTypeScriptCli.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport path from 'node:path'\nimport { spawnSync } from 'node:child_process'\n\nimport spawn from 'next/dist/compiled/cross-spawn'\n\nimport { bold } from '../picocolors'\nimport { resolveFrom } from '../resolve-from'\n\nexport interface TypeScriptPackageInfo {\n packageJsonPath: string\n packageDir: string\n version: string\n apiPath?: string\n tscPath?: string\n}\n\nexport function getTypeScriptPackageInfo(\n baseDir: string\n): TypeScriptPackageInfo | null {\n let packageJsonPath: string\n try {\n packageJsonPath = resolveFrom(baseDir, 'typescript/package.json')\n } catch {\n return null\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {\n version: string\n type?: string\n bin?: string | Record<string, string>\n }\n const packageDir = path.dirname(packageJsonPath)\n const apiPath = path.join(packageDir, 'lib', 'typescript.js')\n const tscBin =\n typeof packageJson.bin === 'string'\n ? packageJson.bin\n : (packageJson.bin?.tsc ??\n Object.entries(packageJson.bin ?? {}).find(([name]) =>\n /^tsc\\d+$/.test(name)\n )?.[1])\n const tscBinPath = tscBin ? path.resolve(packageDir, tscBin) : undefined\n let tscPath = tscBinPath\n\n if (\n tscBinPath &&\n existsSync(tscBinPath) &&\n packageJson.type === 'module' &&\n path.extname(tscBinPath) === ''\n ) {\n // TypeScript 7's extensionless ESM bin wrapper cannot be used as Node's\n // main entry point on Node.js 20.9. Its imported JS entry is the same CLI\n // wrapper and works across all supported Node.js versions.\n const tscJsPath = path.join(packageDir, 'lib', 'tsc.js')\n if (existsSync(tscJsPath)) {\n tscPath = tscJsPath\n }\n }\n\n return {\n packageJsonPath,\n packageDir,\n version: packageJson.version,\n apiPath: existsSync(apiPath) ? apiPath : undefined,\n tscPath: tscPath && existsSync(tscPath) ? tscPath : undefined,\n }\n}\n\nexport function hasNativeTypeScriptPreview(baseDir: string): boolean {\n try {\n resolveFrom(baseDir, '@typescript/native-preview/package.json')\n return true\n } catch {\n return false\n }\n}\n\nexport function getTypeScriptApiMissingError(version: string): Error {\n return new Error(\n `TypeScript ${version} does not provide the compiler API required by Next.js. ` +\n `Set ${bold('experimental.useTypeScriptCli')} back to true in your Next.js config to use the TypeScript CLI, ` +\n `or install TypeScript 6 instead.`\n )\n}\n\nexport interface TypeScriptCliResult {\n exitCode: number\n signal: NodeJS.Signals | null\n stdout: string\n stderr: string\n}\n\nconst terminationSignals: NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGHUP']\n\nexport function runTypeScriptCli({\n cwd,\n tscPath,\n args,\n captureOutput = false,\n onFirstOutput,\n}: {\n cwd: string\n tscPath: string\n args: string[]\n /**\n * Accumulate stdout/stderr into the resolved result instead of forwarding it\n * to this process's stdout/stderr (for e.g. parsing `--showConfig` output).\n */\n captureOutput?: boolean\n /**\n * Called once, on the first chunk of forwarded output. Used to stop the build\n * spinner before `tsc`'s diagnostics appear. Not called when capturing.\n */\n onFirstOutput?: () => void\n}): Promise<TypeScriptCliResult> {\n return new Promise((resolve, reject) => {\n const child = spawn(process.execPath, [tscPath, ...args], {\n cwd,\n // TypeScript 7's Node wrapper starts the native compiler synchronously\n // on older Node.js releases. A separate process group lets termination\n // reach both processes instead of orphaning the native compiler.\n detached: process.platform !== 'win32',\n shell: false,\n stdio: ['ignore', 'pipe', 'pipe'],\n env: {\n ...process.env,\n // Piping stdio makes `tsc` disable colored/pretty diagnostics. Restore\n // them when we are forwarding output to a TTY (not capturing it for\n // parsing, e.g. `--showConfig`).\n ...(!captureOutput && process.stdout.isTTY\n ? { FORCE_COLOR: '1' }\n : undefined),\n },\n })\n\n let stdout = ''\n let stderr = ''\n\n child.stdout?.setEncoding('utf8')\n child.stderr?.setEncoding('utf8')\n\n if (captureOutput) {\n child.stdout?.on('data', (chunk: string) => {\n stdout += chunk\n })\n child.stderr?.on('data', (chunk: string) => {\n stderr += chunk\n })\n } else {\n const forward = (dest: NodeJS.WriteStream, chunk: string) => {\n onFirstOutput?.()\n onFirstOutput = undefined // ensure we don't call it again\n dest.write(chunk)\n }\n\n child.stdout?.on('data', (chunk: string) => {\n forward(process.stdout, chunk)\n })\n child.stderr?.on('data', (chunk: string) => {\n forward(process.stderr, chunk)\n })\n }\n\n let terminationRequested = false\n const terminateChild = () => {\n if (terminationRequested || child.killed || child.pid === undefined) {\n return\n }\n terminationRequested = true\n\n // The native compiler ignores SIGTERM and SIGINT, so send a kill signal.\n // Target the whole process group so the signal reaches the native compiler whether\n // it is a grandchild or a direct child.\n // https://github.com/microsoft/typescript-go/pull/4592 should improve this in the long run\n if (process.platform === 'win32') {\n spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], {\n stdio: 'ignore',\n windowsHide: true,\n })\n } else {\n try {\n // https://www.youtube.com/watch?v=Fow7iUaKrq4\n process.kill(-child.pid, 'SIGKILL')\n } catch {\n // The process may have exited between the lifecycle event and kill.\n }\n }\n }\n const terminateOnExit = () => terminateChild()\n process.once('exit', terminateOnExit)\n\n const handler = () => {\n terminateChild()\n process.exit(1)\n }\n for (const signal of terminationSignals) {\n process.once(signal, handler)\n }\n\n const cleanup = () => {\n process.off('exit', terminateOnExit)\n for (const signal of terminationSignals) {\n process.off(signal, handler)\n }\n }\n\n let settled = false\n const finish = (settle: () => void) => {\n if (settled) {\n return\n }\n settled = true\n cleanup()\n settle()\n }\n\n child.on('error', (error) => {\n finish(() => reject(error))\n })\n child.on('close', (code, signal) => {\n finish(() => {\n resolve({\n exitCode: code ?? 1,\n signal,\n stdout,\n stderr,\n })\n })\n })\n })\n}\n\nexport async function getTypeScriptConfigurationCli({\n baseDir,\n tsConfigPath,\n tscPath,\n}: {\n baseDir: string\n tsConfigPath: string\n tscPath: string\n}): Promise<{ compilerOptions: Record<string, any> }> {\n const result = await runTypeScriptCli({\n cwd: baseDir,\n tscPath,\n args: ['--showConfig', '--project', tsConfigPath, '--pretty', 'false'],\n captureOutput: true,\n })\n\n if (result.exitCode !== 0) {\n throw new Error(\n [result.stdout, result.stderr].filter(Boolean).join('\\n').trim()\n )\n }\n\n try {\n return JSON.parse(result.stdout)\n } catch (cause) {\n throw new Error(`Could not parse output from TypeScript's --showConfig.`, {\n cause,\n })\n }\n}\n"],"names":["getTypeScriptApiMissingError","getTypeScriptConfigurationCli","getTypeScriptPackageInfo","hasNativeTypeScriptPreview","runTypeScriptCli","baseDir","packageJson","Object","packageJsonPath","resolveFrom","JSON","parse","readFileSync","packageDir","path","dirname","apiPath","join","tscBin","bin","tsc","entries","find","name","test","tscBinPath","resolve","undefined","tscPath","existsSync","type","extname","tscJsPath","version","Error","bold","terminationSignals","cwd","args","captureOutput","onFirstOutput","Promise","reject","child","spawn","process","execPath","detached","platform","shell","stdio","env","stdout","isTTY","FORCE_COLOR","stderr","setEncoding","on","chunk","forward","dest","write","terminationRequested","terminateChild","killed","pid","spawnSync","String","windowsHide","kill","terminateOnExit","once","handler","exit","signal","cleanup","off","settled","finish","settle","error","code","exitCode","tsConfigPath","result","filter","Boolean","trim","cause"],"mappings":";;;;;;;;;;;;;;;;;;IA6EgBA,4BAA4B;eAA5BA;;IA2JMC,6BAA6B;eAA7BA;;IAvNNC,wBAAwB;eAAxBA;;IAmDAC,0BAA0B;eAA1BA;;IA0BAC,gBAAgB;eAAhBA;;;wBA9FyB;iEACxB;mCACS;mEAER;4BAEG;6BACO;;;;;;AAUrB,SAASF,yBACdG,OAAe;QAmBRC,kBACDC;IAlBN,IAAIC;IACJ,IAAI;QACFA,kBAAkBC,IAAAA,wBAAW,EAACJ,SAAS;IACzC,EAAE,OAAM;QACN,OAAO;IACT;IAEA,MAAMC,cAAcI,KAAKC,KAAK,CAACC,IAAAA,oBAAY,EAACJ,iBAAiB;IAK7D,MAAMK,aAAaC,iBAAI,CAACC,OAAO,CAACP;IAChC,MAAMQ,UAAUF,iBAAI,CAACG,IAAI,CAACJ,YAAY,OAAO;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,QAAQ;oBACNwD,UAAUD,QAAQ;oBAClBP;oBACAtB;oBACAG;gBACF;YACF;QACF;IACF;AACF;AAEO,eAAetD,8BAA8B,EAClDI,OAAO,EACP8E,YAAY,EACZvD,OAAO,EAKR;IACC,MAAMwD,SAAS,MAAMhF,iBAAiB;QACpCiC,KAAKhC;QACLuB;QACAU,MAAM;YAAC;YAAgB;YAAa6C;YAAc;YAAY;SAAQ;QACtE5C,eAAe;IACjB;IAEA,IAAI6C,OAAOF,QAAQ,KAAK,GAAG;QACzB,MAAM,qBAEL,CAFK,IAAIhD,MACR;YAACkD,OAAOhC,MAAM;YAAEgC,OAAO7B,MAAM;SAAC,CAAC8B,MAAM,CAACC,SAASrE,IAAI,CAAC,MAAMsE,IAAI,KAD1D,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,IAAI;QACF,OAAO7E,KAAKC,KAAK,CAACyE,OAAOhC,MAAM;IACjC,EAAE,OAAOoC,OAAO;QACd,MAAM,qBAEJ,CAFI,IAAItD,MAAM,CAAC,sDAAsD,CAAC,EAAE;YACxEsD;QACF,IAFM,qBAAA;mBAAA;wBAAA;0BAAA;QAEL;IACH;AACF","ignoreList":[0]}
|
|
@@ -86,7 +86,9 @@ const typescriptApiPackage = {
|
|
|
86
86
|
exportsRestrict: true
|
|
87
87
|
};
|
|
88
88
|
const typescriptCliPackage = {
|
|
89
|
-
|
|
89
|
+
// The CLI path is resolved from the package's bin metadata after this initial
|
|
90
|
+
// package-presence check, since aliased TypeScript packages may rename it.
|
|
91
|
+
file: 'typescript/package.json',
|
|
90
92
|
pkg: 'typescript',
|
|
91
93
|
exportsRestrict: true
|
|
92
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type {\n MissingDependency,\n NecessaryDependencies,\n} from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\nimport {\n getTypeScriptApiMissingError,\n getTypeScriptPackageInfo,\n hasNativeTypeScriptPreview,\n} from './typescript/runTypeScriptCli'\n\nconst typescriptApiPackage: MissingDependency = {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n install: 'typescript@^6.0.0',\n exportsRestrict: true,\n}\n\nconst typescriptCliPackage: MissingDependency = {\n file: 'typescript/bin/tsc',\n pkg: 'typescript',\n exportsRestrict: true,\n}\n\nconst requiredTypePackages: MissingDependency[] = [\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyAndRunTypeScript({\n dir,\n distDir,\n cacheDir,\n strictRouteTypes,\n tsconfigPath,\n shouldRunTypeCheck,\n typedRoutes,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n appDir,\n pagesDir,\n debugBuildPaths,\n useTypeScriptCli = false,\n onFirstCliOutput,\n}: {\n dir: string\n distDir: string\n cacheDir?: string\n strictRouteTypes: boolean\n tsconfigPath: string | undefined\n shouldRunTypeCheck: boolean\n typedRoutes: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n appDir?: string\n pagesDir?: string\n debugBuildPaths?: { app?: string[]; pages?: string[] }\n useTypeScriptCli?: boolean\n /**\n * Called once when the CLI checker first produces output, so the caller can\n * stop the build spinner. Only used on the in-process CLI path.\n */\n onFirstCliOutput?: () => void\n}): Promise<{\n result?: TypeCheckResult\n version: string | null\n typeCheckMode: 'typescript-api' | 'typescript-cli'\n}> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n const typeCheckMode = useTypeScriptCli ? 'typescript-cli' : 'typescript-api'\n\n // Construct intentDirs from appDir and pagesDir for getTypeScriptIntent\n const intentDirs = [pagesDir, appDir].filter(Boolean) as string[]\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null, typeCheckMode }\n }\n\n // Check if @typescript/native-preview is installed as an alternative\n const hasNativePreview = hasNativeTypeScriptPreview(dir)\n const installedTypeScript = getTypeScriptPackageInfo(dir)\n\n if (\n !useTypeScriptCli &&\n !hasNativePreview &&\n installedTypeScript &&\n !installedTypeScript.apiPath\n ) {\n throw getTypeScriptApiMissingError(installedTypeScript.version)\n }\n\n const requiredPackages: MissingDependency[] = [\n useTypeScriptCli ? typescriptCliPackage : typescriptApiPackage,\n ...requiredTypePackages,\n ]\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n // If @typescript/native-preview is installed and only the typescript package is missing,\n // we can skip auto-installing typescript since the native preview provides TS compilation.\n // However, we still need @types/react and @types/node for type checking.\n if (!useTypeScriptCli && hasNativePreview && deps.missing?.length > 0) {\n const missingWithoutTypescript = deps.missing.filter(\n (dep) => dep.pkg !== 'typescript'\n )\n const onlyTypescriptMissing =\n deps.missing.length === 1 && deps.missing[0].pkg === 'typescript'\n\n if (onlyTypescriptMissing) {\n // @typescript/native-preview is installed and only typescript is missing\n // Skip installation and return early - the project can use the native preview\n log.info(\n `Detected ${bold('@typescript/native-preview')} as TypeScript compiler. ` +\n `Some Next.js TypeScript features (like type checking during build) require the standard ${bold('typescript')} package.`\n )\n\n // Still write type declarations since they don't require the typescript package\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n strictRouteTypes,\n typedRoutes,\n })\n\n return { version: null, typeCheckMode }\n }\n\n // If there are other missing deps besides typescript, only install those\n if (\n missingWithoutTypescript.length > 0 &&\n missingWithoutTypescript.length < deps.missing.length\n ) {\n deps.missing = missingWithoutTypescript\n }\n }\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n ) +\n '\\n'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n const typeScriptPackage = getTypeScriptPackageInfo(dir)\n const typeScriptPath = useTypeScriptCli\n ? typeScriptPackage?.tscPath\n : typeScriptPackage?.apiPath\n\n if (!typeScriptPackage || !typeScriptPath) {\n missingDepsError(\n dir,\n deps.missing.length > 0\n ? deps.missing\n : [useTypeScriptCli ? typescriptCliPackage : typescriptApiPackage]\n )\n }\n\n const typescriptVersion = typeScriptPackage.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n strictRouteTypes\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n strictRouteTypes,\n typedRoutes,\n })\n\n let result\n if (shouldRunTypeCheck) {\n if (useTypeScriptCli) {\n if (debugBuildPaths) {\n log.warn(\n '`experimental.useTypeScriptCli` checks the complete TypeScript project; `--debug-build-paths` does not limit type checking.'\n )\n }\n\n const { runTypeCheckCli } =\n require('./typescript/runTypeCheckCli') as typeof import('./typescript/runTypeCheckCli')\n result = await runTypeCheckCli({\n baseDir: dir,\n tsConfigPath: resolvedTsConfigPath,\n tscPath: typeScriptPath,\n cacheDir,\n onFirstOutput: onFirstCliOutput,\n })\n } else {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n // Install native bindings so that code frame rendering works in the worker\n const { installBindings } =\n require('../build/swc/install-bindings') as typeof import('../build/swc/install-bindings')\n await installBindings()\n\n const typescript = (await Promise.resolve(\n require(typeScriptPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir,\n { app: appDir, pages: pagesDir },\n debugBuildPaths\n )\n }\n }\n return { result, version: typescriptVersion, typeCheckMode }\n } catch (err) {\n // Print the user-facing message here and rethrow. This function runs both\n // in-process (next dev / next test / next typegen, and the CLI type-check\n // during build) and inside a jest worker (the TypeScript-API type-check\n // during build). A thrown error does not survive the worker boundary — the\n // parent only sees `Call retries were exceeded` — so the message must be\n // printed on this side. The caller decides what to do with the throw (exit,\n // or tolerate it as `next dev` does on re-verification).\n if (err instanceof CompileError) {\n // The checker already printed its diagnostics.\n console.error(red('Failed to type check.\\n'))\n if (err.message) {\n console.error(err.message)\n }\n } else if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n throw err\n }\n}\n\n/**\n * Worker entrypoint used by `next build` for the TypeScript-API type-check.\n * `verifyAndRunTypeScript` has already printed any error, so on failure we exit\n * the worker directly rather than rethrowing: a thrown error would be retried by\n * jest-worker and surface in the parent as the unhelpful\n * `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\nexport async function verifyAndRunTypeScriptInWorker(\n options: Parameters<typeof verifyAndRunTypeScript>[0]\n): ReturnType<typeof verifyAndRunTypeScript> {\n try {\n return await verifyAndRunTypeScript(options)\n } catch {\n // The error was already printed by `verifyAndRunTypeScript`.\n // Kill the worker with a non-zero exit code.\n process.exit(1)\n }\n}\n"],"names":["verifyAndRunTypeScript","verifyAndRunTypeScriptInWorker","typescriptApiPackage","file","pkg","install","exportsRestrict","typescriptCliPackage","requiredTypePackages","dir","distDir","cacheDir","strictRouteTypes","tsconfigPath","shouldRunTypeCheck","typedRoutes","disableStaticImages","hasAppDir","hasPagesDir","appDir","pagesDir","debugBuildPaths","useTypeScriptCli","onFirstCliOutput","tsConfigFileName","resolvedTsConfigPath","path","join","typeCheckMode","intentDirs","filter","Boolean","deps","intent","getTypeScriptIntent","version","hasNativePreview","hasNativeTypeScriptPreview","installedTypeScript","getTypeScriptPackageInfo","apiPath","getTypeScriptApiMissingError","requiredPackages","hasNecessaryDependencies","missing","length","missingWithoutTypescript","dep","onlyTypescriptMissing","log","info","bold","writeAppTypeDeclarations","baseDir","imageImportsEnabled","isCI","missingDepsError","console","yellow","cyan","installDependencies","catch","err","error","command","typeScriptPackage","typeScriptPath","tscPath","typescriptVersion","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","result","runTypeCheckCli","require","tsConfigPath","onFirstOutput","runTypeCheck","installBindings","typescript","Promise","resolve","app","pages","CompileError","red","message","Error","options","process","exit"],"mappings":";;;;;;;;;;;;;;;IAmDsBA,sBAAsB;eAAtBA;;IAiRAC,8BAA8B;eAA9BA;;;4BApUkB;6DACvB;0CAEwB;+D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;QAC7CC,QAAQC,IAAI,CAAC;IACf;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type {\n MissingDependency,\n NecessaryDependencies,\n} from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\nimport {\n getTypeScriptApiMissingError,\n getTypeScriptPackageInfo,\n hasNativeTypeScriptPreview,\n} from './typescript/runTypeScriptCli'\n\nconst typescriptApiPackage: MissingDependency = {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n install: 'typescript@^6.0.0',\n exportsRestrict: true,\n}\n\nconst typescriptCliPackage: MissingDependency = {\n // The CLI path is resolved from the package's bin metadata after this initial\n // package-presence check, since aliased TypeScript packages may rename it.\n file: 'typescript/package.json',\n pkg: 'typescript',\n exportsRestrict: true,\n}\n\nconst requiredTypePackages: MissingDependency[] = [\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyAndRunTypeScript({\n dir,\n distDir,\n cacheDir,\n strictRouteTypes,\n tsconfigPath,\n shouldRunTypeCheck,\n typedRoutes,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n appDir,\n pagesDir,\n debugBuildPaths,\n useTypeScriptCli = false,\n onFirstCliOutput,\n}: {\n dir: string\n distDir: string\n cacheDir?: string\n strictRouteTypes: boolean\n tsconfigPath: string | undefined\n shouldRunTypeCheck: boolean\n typedRoutes: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n appDir?: string\n pagesDir?: string\n debugBuildPaths?: { app?: string[]; pages?: string[] }\n useTypeScriptCli?: boolean\n /**\n * Called once when the CLI checker first produces output, so the caller can\n * stop the build spinner. Only used on the in-process CLI path.\n */\n onFirstCliOutput?: () => void\n}): Promise<{\n result?: TypeCheckResult\n version: string | null\n typeCheckMode: 'typescript-api' | 'typescript-cli'\n}> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n const typeCheckMode = useTypeScriptCli ? 'typescript-cli' : 'typescript-api'\n\n // Construct intentDirs from appDir and pagesDir for getTypeScriptIntent\n const intentDirs = [pagesDir, appDir].filter(Boolean) as string[]\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null, typeCheckMode }\n }\n\n // Check if @typescript/native-preview is installed as an alternative\n const hasNativePreview = hasNativeTypeScriptPreview(dir)\n const installedTypeScript = getTypeScriptPackageInfo(dir)\n\n if (\n !useTypeScriptCli &&\n !hasNativePreview &&\n installedTypeScript &&\n !installedTypeScript.apiPath\n ) {\n throw getTypeScriptApiMissingError(installedTypeScript.version)\n }\n\n const requiredPackages: MissingDependency[] = [\n useTypeScriptCli ? typescriptCliPackage : typescriptApiPackage,\n ...requiredTypePackages,\n ]\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n // If @typescript/native-preview is installed and only the typescript package is missing,\n // we can skip auto-installing typescript since the native preview provides TS compilation.\n // However, we still need @types/react and @types/node for type checking.\n if (!useTypeScriptCli && hasNativePreview && deps.missing?.length > 0) {\n const missingWithoutTypescript = deps.missing.filter(\n (dep) => dep.pkg !== 'typescript'\n )\n const onlyTypescriptMissing =\n deps.missing.length === 1 && deps.missing[0].pkg === 'typescript'\n\n if (onlyTypescriptMissing) {\n // @typescript/native-preview is installed and only typescript is missing\n // Skip installation and return early - the project can use the native preview\n log.info(\n `Detected ${bold('@typescript/native-preview')} as TypeScript compiler. ` +\n `Some Next.js TypeScript features (like type checking during build) require the standard ${bold('typescript')} package.`\n )\n\n // Still write type declarations since they don't require the typescript package\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n strictRouteTypes,\n typedRoutes,\n })\n\n return { version: null, typeCheckMode }\n }\n\n // If there are other missing deps besides typescript, only install those\n if (\n missingWithoutTypescript.length > 0 &&\n missingWithoutTypescript.length < deps.missing.length\n ) {\n deps.missing = missingWithoutTypescript\n }\n }\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n ) +\n '\\n'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n const typeScriptPackage = getTypeScriptPackageInfo(dir)\n const typeScriptPath = useTypeScriptCli\n ? typeScriptPackage?.tscPath\n : typeScriptPackage?.apiPath\n\n if (!typeScriptPackage || !typeScriptPath) {\n missingDepsError(\n dir,\n deps.missing.length > 0\n ? deps.missing\n : [useTypeScriptCli ? typescriptCliPackage : typescriptApiPackage]\n )\n }\n\n const typescriptVersion = typeScriptPackage.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n strictRouteTypes\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n strictRouteTypes,\n typedRoutes,\n })\n\n let result\n if (shouldRunTypeCheck) {\n if (useTypeScriptCli) {\n if (debugBuildPaths) {\n log.warn(\n '`experimental.useTypeScriptCli` checks the complete TypeScript project; `--debug-build-paths` does not limit type checking.'\n )\n }\n\n const { runTypeCheckCli } =\n require('./typescript/runTypeCheckCli') as typeof import('./typescript/runTypeCheckCli')\n result = await runTypeCheckCli({\n baseDir: dir,\n tsConfigPath: resolvedTsConfigPath,\n tscPath: typeScriptPath,\n cacheDir,\n onFirstOutput: onFirstCliOutput,\n })\n } else {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n // Install native bindings so that code frame rendering works in the worker\n const { installBindings } =\n require('../build/swc/install-bindings') as typeof import('../build/swc/install-bindings')\n await installBindings()\n\n const typescript = (await Promise.resolve(\n require(typeScriptPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir,\n { app: appDir, pages: pagesDir },\n debugBuildPaths\n )\n }\n }\n return { result, version: typescriptVersion, typeCheckMode }\n } catch (err) {\n // Print the user-facing message here and rethrow. This function runs both\n // in-process (next dev / next test / next typegen, and the CLI type-check\n // during build) and inside a jest worker (the TypeScript-API type-check\n // during build). A thrown error does not survive the worker boundary — the\n // parent only sees `Call retries were exceeded` — so the message must be\n // printed on this side. The caller decides what to do with the throw (exit,\n // or tolerate it as `next dev` does on re-verification).\n if (err instanceof CompileError) {\n // The checker already printed its diagnostics.\n console.error(red('Failed to type check.\\n'))\n if (err.message) {\n console.error(err.message)\n }\n } else if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n throw err\n }\n}\n\n/**\n * Worker entrypoint used by `next build` for the TypeScript-API type-check.\n * `verifyAndRunTypeScript` has already printed any error, so on failure we exit\n * the worker directly rather than rethrowing: a thrown error would be retried by\n * jest-worker and surface in the parent as the unhelpful\n * `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\nexport async function verifyAndRunTypeScriptInWorker(\n options: Parameters<typeof verifyAndRunTypeScript>[0]\n): ReturnType<typeof verifyAndRunTypeScript> {\n try {\n return await verifyAndRunTypeScript(options)\n } catch {\n // The error was already printed by `verifyAndRunTypeScript`.\n // Kill the worker with a non-zero exit code.\n process.exit(1)\n }\n}\n"],"names":["verifyAndRunTypeScript","verifyAndRunTypeScriptInWorker","typescriptApiPackage","file","pkg","install","exportsRestrict","typescriptCliPackage","requiredTypePackages","dir","distDir","cacheDir","strictRouteTypes","tsconfigPath","shouldRunTypeCheck","typedRoutes","disableStaticImages","hasAppDir","hasPagesDir","appDir","pagesDir","debugBuildPaths","useTypeScriptCli","onFirstCliOutput","tsConfigFileName","resolvedTsConfigPath","path","join","typeCheckMode","intentDirs","filter","Boolean","deps","intent","getTypeScriptIntent","version","hasNativePreview","hasNativeTypeScriptPreview","installedTypeScript","getTypeScriptPackageInfo","apiPath","getTypeScriptApiMissingError","requiredPackages","hasNecessaryDependencies","missing","length","missingWithoutTypescript","dep","onlyTypescriptMissing","log","info","bold","writeAppTypeDeclarations","baseDir","imageImportsEnabled","isCI","missingDepsError","console","yellow","cyan","installDependencies","catch","err","error","command","typeScriptPackage","typeScriptPath","tscPath","typescriptVersion","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","result","runTypeCheckCli","require","tsConfigPath","onFirstOutput","runTypeCheck","installBindings","typescript","Promise","resolve","app","pages","CompileError","red","message","Error","options","process","exit"],"mappings":";;;;;;;;;;;;;;;IAqDsBA,sBAAsB;eAAtBA;;IAiRAC,8BAA8B;eAA9BA;;;4BAtUkB;6DACvB;0CAEwB;+DAKtB;8BACU;6DACR;qCAEe;0CAEK;4CACE;qCACP;wBACf;wCACY;kCAK1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEP,MAAMC,uBAA0C;IAC9CC,MAAM;IACNC,KAAK;IACLC,SAAS;IACTC,iBAAiB;AACnB;AAEA,MAAMC,uBAA0C;IAC9C,8EAA8E;IAC9E,2EAA2E;IAC3EJ,MAAM;IACNC,KAAK;IACLE,iBAAiB;AACnB;AAEA,MAAME,uBAA4C;IAChD;QACEL,MAAM;QACNC,KAAK;QACLE,iBAAiB;IACnB;IACA;QACEH,MAAM;QACNC,KAAK;QACLE,iBAAiB;IACnB;CACD;AAEM,eAAeN,uBAAuB,EAC3CS,GAAG,EACHC,OAAO,EACPC,QAAQ,EACRC,gBAAgB,EAChBC,YAAY,EACZC,kBAAkB,EAClBC,WAAW,EACXC,mBAAmB,EACnBC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,QAAQ,EACRC,eAAe,EACfC,mBAAmB,KAAK,EACxBC,gBAAgB,EAqBjB;IAKC,MAAMC,mBAAmBX,gBAAgB;IACzC,MAAMY,uBAAuBC,aAAI,CAACC,IAAI,CAAClB,KAAKe;IAC5C,MAAMI,gBAAgBN,mBAAmB,mBAAmB;IAE5D,wEAAwE;IACxE,MAAMO,aAAa;QAACT;QAAUD;KAAO,CAACW,MAAM,CAACC;IAE7C,IAAI;YAkC2CC,eAsCzCA;QAvEJ,wCAAwC;QACxC,MAAMC,SAAS,MAAMC,IAAAA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EAAE;gBACf/B,QAAQM,KAAK,CAACD,IAAI0B,OAAO;YAC3B;QACF,OAAO,IAAI1B,eAAe2B,OAAO;YAC/BhC,QAAQM,KAAK,CAACD,IAAI0B,OAAO;QAC3B,OAAO;YACL/B,QAAQM,KAAK,CAACD;QAChB;QACA,MAAMA;IACR;AACF;AASO,eAAe7D,+BACpByF,OAAqD;IAErD,IAAI;QACF,OAAO,MAAM1F,uBAAuB0F;IACtC,EAAE,OAAM;QACN,6DAA6D;QAC7D,6CAA6C;QAC7CC,QAAQC,IAAI,CAAC;IACf;AACF","ignoreList":[0]}
|
package/dist/server/config.js
CHANGED
|
@@ -302,7 +302,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
|
|
|
302
302
|
}
|
|
303
303
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
|
304
304
|
const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
|
305
|
-
version: "16.3.
|
|
305
|
+
version: "16.3.4"
|
|
306
306
|
});
|
|
307
307
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
308
308
|
// of the current `next dev` invocation.
|
|
@@ -362,7 +362,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
|
|
|
362
362
|
writeRoutesHashesManifest: false,
|
|
363
363
|
currentNodeJsVersion,
|
|
364
364
|
isPersistentCachingEnabled: (0, _utils2.isFileSystemCacheEnabledForDev)(opts.nextConfig),
|
|
365
|
-
nextVersion: "16.3.
|
|
365
|
+
nextVersion: "16.3.4",
|
|
366
366
|
serverHmr: serverFastRefresh
|
|
367
367
|
}, {
|
|
368
368
|
turbopackMemoryEviction: opts.nextConfig.experimental.turbopackMemoryEvictionMode,
|
|
@@ -234,7 +234,7 @@ class HotReloaderWebpack {
|
|
|
234
234
|
this.previewProps = previewProps;
|
|
235
235
|
this.rewrites = rewrites;
|
|
236
236
|
this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
|
237
|
-
version: "16.3.
|
|
237
|
+
version: "16.3.4"
|
|
238
238
|
});
|
|
239
239
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
240
240
|
// of the current `next dev` invocation.
|