next 15.4.2-canary.52 → 15.4.2-canary.53

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.

Potentially problematic release.


This version of next might be problematic. Click here for more details.

Files changed (45) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +2 -2
  3. package/dist/build/swc/index.js +1 -1
  4. package/dist/build/webpack-config.js +2 -2
  5. package/dist/client/app-bootstrap.js +1 -1
  6. package/dist/client/index.js +1 -1
  7. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
  8. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
  9. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
  10. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
  11. package/dist/compiled/next-server/pages-api.runtime.prod.js +1 -1
  12. package/dist/compiled/next-server/pages-api.runtime.prod.js.map +1 -1
  13. package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
  14. package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
  15. package/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
  16. package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
  17. package/dist/compiled/next-server/pages.runtime.prod.js +1 -1
  18. package/dist/compiled/next-server/pages.runtime.prod.js.map +1 -1
  19. package/dist/esm/build/index.js +2 -2
  20. package/dist/esm/build/swc/index.js +1 -1
  21. package/dist/esm/build/webpack-config.js +2 -2
  22. package/dist/esm/client/app-bootstrap.js +1 -1
  23. package/dist/esm/client/index.js +1 -1
  24. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  25. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  26. package/dist/esm/server/lib/app-info-log.js +1 -1
  27. package/dist/esm/server/lib/router-utils/route-types-utils.js +10 -10
  28. package/dist/esm/server/lib/router-utils/route-types-utils.js.map +1 -1
  29. package/dist/esm/server/lib/router-utils/typegen.js +87 -33
  30. package/dist/esm/server/lib/router-utils/typegen.js.map +1 -1
  31. package/dist/esm/server/lib/start-server.js +1 -1
  32. package/dist/esm/shared/lib/canary-only.js +1 -1
  33. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  34. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  35. package/dist/server/lib/app-info-log.js +1 -1
  36. package/dist/server/lib/router-utils/route-types-utils.js +10 -10
  37. package/dist/server/lib/router-utils/route-types-utils.js.map +1 -1
  38. package/dist/server/lib/router-utils/typegen.js +87 -33
  39. package/dist/server/lib/router-utils/typegen.js.map +1 -1
  40. package/dist/server/lib/start-server.js +1 -1
  41. package/dist/shared/lib/canary-only.js +1 -1
  42. package/dist/telemetry/anonymous-meta.js +1 -1
  43. package/dist/telemetry/events/session-stopped.js +2 -2
  44. package/dist/telemetry/events/version.js +2 -2
  45. package/package.json +15 -15
@@ -299,7 +299,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
299
299
  const nextBuildSpan = trace('next-build', undefined, {
300
300
  buildMode: experimentalBuildMode,
301
301
  isTurboBuild: String(isTurbopack),
302
- version: "15.4.2-canary.52"
302
+ version: "15.4.2-canary.53"
303
303
  });
304
304
  NextBuildContext.nextBuildSpan = nextBuildSpan;
305
305
  NextBuildContext.dir = dir;
@@ -754,7 +754,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
754
754
  // Files outside of the distDir can be "type": "module"
755
755
  await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
756
756
  // These are written to distDir, so they need to come after creating and cleaning distDr.
757
- await recordFrameworkVersion("15.4.2-canary.52");
757
+ await recordFrameworkVersion("15.4.2-canary.53");
758
758
  await updateBuildDiagnostics({
759
759
  buildStage: 'start'
760
760
  });
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
11
11
  import { getDefineEnv } from '../define-env';
12
12
  import { getReactCompilerLoader } from '../get-babel-loader-config';
13
13
  import { throwTurbopackInternalError } from '../../shared/lib/turbopack/internal-error';
14
- const nextVersion = "15.4.2-canary.52";
14
+ const nextVersion = "15.4.2-canary.53";
15
15
  const ArchName = arch();
16
16
  const PlatformName = platform();
17
17
  function infoLog(...args) {
@@ -1608,7 +1608,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1608
1608
  isClient && new CopyFilePlugin({
1609
1609
  // file path to build output of `@next/polyfill-nomodule`
1610
1610
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1611
- cacheKey: "15.4.2-canary.52",
1611
+ cacheKey: "15.4.2-canary.53",
1612
1612
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1613
1613
  minimize: false,
1614
1614
  info: {
@@ -1787,7 +1787,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1787
1787
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1788
1788
  // - Next.js version
1789
1789
  // - next.config.js keys that affect compilation
1790
- version: `${__dirname}|${"15.4.2-canary.52"}|${configVars}`,
1790
+ version: `${__dirname}|${"15.4.2-canary.53"}|${configVars}`,
1791
1791
  cacheDirectory: path.join(distDir, 'cache', 'webpack'),
1792
1792
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1793
1793
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
@@ -4,7 +4,7 @@
4
4
  * - Polyfills
5
5
  * - next/script with `beforeInteractive` strategy
6
6
  */ import { setAttributesFromProps } from './set-attributes-from-props';
7
- const version = "15.4.2-canary.52";
7
+ const version = "15.4.2-canary.53";
8
8
  window.next = {
9
9
  version,
10
10
  appDir: true
@@ -26,7 +26,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
26
26
  import { onRecoverableError } from './react-client-callbacks/on-recoverable-error';
27
27
  import tracer from './tracing/tracer';
28
28
  import { isNextRouterError } from './components/is-next-router-error';
29
- export const version = "15.4.2-canary.52";
29
+ export const version = "15.4.2-canary.53";
30
30
  export let router;
31
31
  export const emitter = mitt();
32
32
  const looseToArray = (input)=>[].slice.call(input);
@@ -89,7 +89,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
89
89
  }
90
90
  const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
91
91
  const hotReloaderSpan = trace('hot-reloader', undefined, {
92
- version: "15.4.2-canary.52"
92
+ version: "15.4.2-canary.53"
93
93
  });
94
94
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
95
95
  // of the current `next dev` invocation.
@@ -186,7 +186,7 @@ export default class HotReloaderWebpack {
186
186
  this.previewProps = previewProps;
187
187
  this.rewrites = rewrites;
188
188
  this.hotReloaderSpan = trace('hot-reloader', undefined, {
189
- version: "15.4.2-canary.52"
189
+ version: "15.4.2-canary.53"
190
190
  });
191
191
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
192
192
  // of the current `next dev` invocation.
@@ -12,7 +12,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
12
12
  } else {
13
13
  bundlerSuffix = '';
14
14
  }
15
- Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.2-canary.52"}`))}${bundlerSuffix}`);
15
+ Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.2-canary.53"}`))}${bundlerSuffix}`);
16
16
  if (appUrl) {
17
17
  Log.bootstrap(`- Local: ${appUrl}`);
18
18
  }
@@ -111,30 +111,30 @@ export function convertCustomRouteSource(source) {
111
111
  appRouteHandlerRoutes: {},
112
112
  redirectRoutes: {},
113
113
  rewriteRoutes: {},
114
- appRouteHandlers: new Set(appRouteHandlers.map(({ filePath })=>filePath)),
115
- pageApiRoutes: new Set(pageApiRoutes.map(({ filePath })=>filePath)),
116
- appPagePaths: new Set(appRoutes.map(({ filePath })=>filePath)),
117
- pagesRouterPagePaths: new Set(pageRoutes.map(({ filePath })=>filePath)),
118
- layoutPaths: new Set(layoutRoutes.map(({ filePath })=>filePath)),
114
+ appRouteHandlers: new Set(appRouteHandlers.map(({ filePath })=>getRelativePath(filePath))),
115
+ pageApiRoutes: new Set(pageApiRoutes.map(({ filePath })=>getRelativePath(filePath))),
116
+ appPagePaths: new Set(appRoutes.map(({ filePath })=>getRelativePath(filePath))),
117
+ pagesRouterPagePaths: new Set(pageRoutes.map(({ filePath })=>getRelativePath(filePath))),
118
+ layoutPaths: new Set(layoutRoutes.map(({ filePath })=>getRelativePath(filePath))),
119
119
  filePathToRoute: new Map([
120
120
  ...appRoutes.map(({ route, filePath })=>[
121
- filePath,
121
+ getRelativePath(filePath),
122
122
  resolveInterceptingRoute(route)
123
123
  ]),
124
124
  ...layoutRoutes.map(({ route, filePath })=>[
125
- filePath,
125
+ getRelativePath(filePath),
126
126
  resolveInterceptingRoute(route)
127
127
  ]),
128
128
  ...appRouteHandlers.map(({ route, filePath })=>[
129
- filePath,
129
+ getRelativePath(filePath),
130
130
  resolveInterceptingRoute(route)
131
131
  ]),
132
132
  ...pageRoutes.map(({ route, filePath })=>[
133
- filePath,
133
+ getRelativePath(filePath),
134
134
  route
135
135
  ]),
136
136
  ...pageApiRoutes.map(({ route, filePath })=>[
137
- filePath,
137
+ getRelativePath(filePath),
138
138
  route
139
139
  ])
140
140
  ])
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/server/lib/router-utils/route-types-utils.ts"],"sourcesContent":["import path from 'path'\nimport {\n getRouteRegex,\n type Group,\n} from '../../../shared/lib/router/utils/route-regex'\nimport type { NextConfigComplete } from '../../config-shared'\n\nimport fs from 'fs'\nimport {\n generateRouteTypesFile,\n generateLinkTypesFile,\n generateValidatorFile,\n} from './typegen'\nimport { tryToParsePath } from '../../../lib/try-to-parse-path'\nimport {\n extractInterceptionRouteInformation,\n isInterceptionRouteAppPath,\n} from '../../../shared/lib/router/utils/interception-routes'\n\ninterface RouteInfo {\n path: string\n groups: { [groupName: string]: Group }\n}\n\nexport interface RouteTypesManifest {\n appRoutes: Record<string, RouteInfo>\n pageRoutes: Record<string, RouteInfo>\n layoutRoutes: Record<string, RouteInfo & { slots: string[] }>\n appRouteHandlerRoutes: Record<string, RouteInfo>\n /** Map of redirect source => RouteInfo */\n redirectRoutes: Record<string, RouteInfo>\n /** Map of rewrite source => RouteInfo */\n rewriteRoutes: Record<string, RouteInfo>\n /** File paths for validation */\n appPagePaths: Set<string>\n pagesRouterPagePaths: Set<string>\n layoutPaths: Set<string>\n appRouteHandlers: Set<string>\n pageApiRoutes: Set<string>\n /** Direct mapping from file paths to routes for validation */\n filePathToRoute: Map<string, string>\n}\n\n// Convert a custom-route source string (`/blog/:slug`, `/docs/:path*`, ...)\n// into the bracket-syntax used by other Next.js route helpers so that we can\n// reuse `getRouteRegex()` to extract groups.\nexport function convertCustomRouteSource(source: string): string[] {\n const parseResult = tryToParsePath(source)\n\n if (parseResult.error || !parseResult.tokens) {\n // Fallback to original source if parsing fails\n return source.startsWith('/') ? [source] : ['/' + source]\n }\n\n const possibleNormalizedRoutes = ['']\n let slugCnt = 1\n\n function append(suffix: string) {\n for (let i = 0; i < possibleNormalizedRoutes.length; i++) {\n possibleNormalizedRoutes[i] += suffix\n }\n }\n\n function fork(suffix: string) {\n const currentLength = possibleNormalizedRoutes.length\n for (let i = 0; i < currentLength; i++) {\n possibleNormalizedRoutes.push(possibleNormalizedRoutes[i] + suffix)\n }\n }\n\n for (const token of parseResult.tokens) {\n if (typeof token === 'object') {\n // Make sure the slug is always named.\n const slug = token.name || (slugCnt++ === 1 ? 'slug' : `slug${slugCnt}`)\n if (token.modifier === '*') {\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.modifier === '+') {\n append(`${token.prefix}[...${slug}]`)\n } else if (token.modifier === '') {\n if (token.pattern === '[^\\\\/#\\\\?]+?') {\n // A safe slug\n append(`${token.prefix}[${slug}]`)\n } else if (token.pattern === '.*') {\n // An optional catch-all slug\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.pattern === '.+') {\n // A catch-all slug\n append(`${token.prefix}[...${slug}]`)\n } else {\n // Other regex patterns are not supported. Skip this route.\n return []\n }\n } else if (token.modifier === '?') {\n if (/^[a-zA-Z0-9_/]*$/.test(token.pattern)) {\n // An optional slug with plain text only, fork the route.\n append(token.prefix)\n fork(token.pattern)\n } else {\n // Optional modifier `?` and regex patterns are not supported.\n return []\n }\n }\n } else if (typeof token === 'string') {\n append(token)\n }\n }\n\n // Ensure leading slash\n return possibleNormalizedRoutes.map((route) =>\n route.startsWith('/') ? route : '/' + route\n )\n}\n\n/**\n * Extracts route parameters from a route pattern\n */\nexport function extractRouteParams(route: string) {\n const regex = getRouteRegex(route)\n return regex.groups\n}\n\n/**\n * Resolves an intercepting route to its canonical equivalent\n * Example: /gallery/test/(..)photo/[id] -> /gallery/photo/[id]\n */\nfunction resolveInterceptingRoute(route: string): string {\n // Reuse centralized interception route normalization logic\n try {\n if (!isInterceptionRouteAppPath(route)) return route\n const { interceptedRoute } = extractInterceptionRouteInformation(route)\n return interceptedRoute\n } catch {\n // If parsing fails, fall back to the original route\n return route\n }\n}\n\n/**\n * Creates a route types manifest from processed route data\n * (used for both build and dev)\n */\nexport async function createRouteTypesManifest({\n dir,\n pageRoutes,\n appRoutes,\n appRouteHandlers,\n pageApiRoutes,\n layoutRoutes,\n slots,\n redirects,\n rewrites,\n validatorFilePath,\n}: {\n dir: string\n pageRoutes: Array<{ route: string; filePath: string }>\n appRoutes: Array<{ route: string; filePath: string }>\n appRouteHandlers: Array<{ route: string; filePath: string }>\n pageApiRoutes: Array<{ route: string; filePath: string }>\n layoutRoutes: Array<{ route: string; filePath: string }>\n slots: Array<{ name: string; parent: string }>\n redirects?: NextConfigComplete['redirects']\n rewrites?: NextConfigComplete['rewrites']\n validatorFilePath?: string\n}): Promise<RouteTypesManifest> {\n // Helper function to calculate the correct relative path\n const getRelativePath = (filePath: string) => {\n if (validatorFilePath) {\n // For validator generation, calculate path relative to validator directory\n return path.relative(path.dirname(validatorFilePath), filePath)\n }\n // For other uses, calculate path relative to project directory\n return path.relative(dir, filePath)\n }\n\n const manifest: RouteTypesManifest = {\n appRoutes: {},\n pageRoutes: {},\n layoutRoutes: {},\n appRouteHandlerRoutes: {},\n redirectRoutes: {},\n rewriteRoutes: {},\n appRouteHandlers: new Set(appRouteHandlers.map(({ filePath }) => filePath)),\n pageApiRoutes: new Set(pageApiRoutes.map(({ filePath }) => filePath)),\n appPagePaths: new Set(appRoutes.map(({ filePath }) => filePath)),\n pagesRouterPagePaths: new Set(pageRoutes.map(({ filePath }) => filePath)),\n layoutPaths: new Set(layoutRoutes.map(({ filePath }) => filePath)),\n filePathToRoute: new Map([\n ...appRoutes.map(\n ({ route, filePath }) =>\n [filePath, resolveInterceptingRoute(route)] as [string, string]\n ),\n ...layoutRoutes.map(\n ({ route, filePath }) =>\n [filePath, resolveInterceptingRoute(route)] as [string, string]\n ),\n ...appRouteHandlers.map(\n ({ route, filePath }) =>\n [filePath, resolveInterceptingRoute(route)] as [string, string]\n ),\n ...pageRoutes.map(\n ({ route, filePath }) => [filePath, route] as [string, string]\n ),\n ...pageApiRoutes.map(\n ({ route, filePath }) => [filePath, route] as [string, string]\n ),\n ]),\n }\n\n // Process page routes\n for (const { route, filePath } of pageRoutes) {\n manifest.pageRoutes[route] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(route),\n }\n }\n\n // Process layout routes\n for (const { route, filePath } of layoutRoutes) {\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.layoutRoutes[resolvedRoute]) {\n manifest.layoutRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n slots: [],\n }\n }\n }\n\n // Process slots\n for (const slot of slots) {\n if (manifest.layoutRoutes[slot.parent]) {\n manifest.layoutRoutes[slot.parent].slots.push(slot.name)\n }\n }\n\n // Process app routes\n for (const { route, filePath } of appRoutes) {\n // Don't include metadata routes or pages\n if (\n !filePath.endsWith('page.ts') &&\n !filePath.endsWith('page.tsx') &&\n !filePath.endsWith('.mdx') &&\n !filePath.endsWith('.md')\n ) {\n continue\n }\n\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRoutes[resolvedRoute]) {\n manifest.appRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process app route handlers\n for (const { route, filePath } of appRouteHandlers) {\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRouteHandlerRoutes[resolvedRoute]) {\n manifest.appRouteHandlerRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process redirects\n if (typeof redirects === 'function') {\n const rd = await redirects()\n\n for (const item of rd) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.redirectRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n // Process rewrites\n if (typeof rewrites === 'function') {\n const rw = await rewrites()\n\n const allSources = Array.isArray(rw)\n ? rw\n : [\n ...(rw?.beforeFiles || []),\n ...(rw?.afterFiles || []),\n ...(rw?.fallback || []),\n ]\n\n for (const item of allSources) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.rewriteRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n return manifest\n}\n\nexport async function writeRouteTypesManifest(\n manifest: RouteTypesManifest,\n filePath: string,\n config: NextConfigComplete\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n // Write the main routes.d.ts file\n await fs.promises.writeFile(filePath, generateRouteTypesFile(manifest))\n\n // Write the link.d.ts file if typedRoutes is enabled\n if (config.experimental?.typedRoutes === true) {\n const linkTypesPath = path.join(dirname, 'link.d.ts')\n await fs.promises.writeFile(linkTypesPath, generateLinkTypesFile(manifest))\n }\n}\n\nexport async function writeValidatorFile(\n manifest: RouteTypesManifest,\n filePath: string\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n await fs.promises.writeFile(filePath, generateValidatorFile(manifest))\n}\n"],"names":["path","getRouteRegex","fs","generateRouteTypesFile","generateLinkTypesFile","generateValidatorFile","tryToParsePath","extractInterceptionRouteInformation","isInterceptionRouteAppPath","convertCustomRouteSource","source","parseResult","error","tokens","startsWith","possibleNormalizedRoutes","slugCnt","append","suffix","i","length","fork","currentLength","push","token","slug","name","modifier","prefix","pattern","test","map","route","extractRouteParams","regex","groups","resolveInterceptingRoute","interceptedRoute","createRouteTypesManifest","dir","pageRoutes","appRoutes","appRouteHandlers","pageApiRoutes","layoutRoutes","slots","redirects","rewrites","validatorFilePath","getRelativePath","filePath","relative","dirname","manifest","appRouteHandlerRoutes","redirectRoutes","rewriteRoutes","Set","appPagePaths","pagesRouterPagePaths","layoutPaths","filePathToRoute","Map","resolvedRoute","slot","parent","endsWith","rd","item","possibleRoutes","rw","allSources","Array","isArray","beforeFiles","afterFiles","fallback","writeRouteTypesManifest","config","existsSync","promises","mkdir","recursive","writeFile","experimental","typedRoutes","linkTypesPath","join","writeValidatorFile"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SACEC,aAAa,QAER,+CAA8C;AAGrD,OAAOC,QAAQ,KAAI;AACnB,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,qBAAqB,QAChB,YAAW;AAClB,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SACEC,mCAAmC,EACnCC,0BAA0B,QACrB,uDAAsD;AA0B7D,4EAA4E;AAC5E,6EAA6E;AAC7E,6CAA6C;AAC7C,OAAO,SAASC,yBAAyBC,MAAc;IACrD,MA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CAACF;IAE7B,IAAI,CAAChD,GAAG6E,UAAU,CAAC3B,UAAU;QAC3B,MAAMlD,GAAG8E,QAAQ,CAACC,KAAK,CAAC7B,SAAS;YAAE8B,WAAW;QAAK;IACrD;IAEA,kCAAkC;IAClC,MAAMhF,GAAG8E,QAAQ,CAACG,SAAS,CAACjC,UAAU/C,uBAAuBkD;IAE7D,qDAAqD;IACrD,IAAIyB,EAAAA,uBAAAA,OAAOM,YAAY,qBAAnBN,qBAAqBO,WAAW,MAAK,MAAM;QAC7C,MAAMC,gBAAgBtF,KAAKuF,IAAI,CAACnC,SAAS;QACzC,MAAMlD,GAAG8E,QAAQ,CAACG,SAAS,CAACG,eAAelF,sBAAsBiD;IACnE;AACF;AAEA,OAAO,eAAemC,mBACpBnC,QAA4B,EAC5BH,QAAgB;IAEhB,MAAME,UAAUpD,KAAKoD,OAAO,CAACF;IAE7B,IAAI,CAAChD,GAAG6E,UAAU,CAAC3B,UAAU;QAC3B,MAAMlD,GAAG8E,QAAQ,CAACC,KAAK,CAAC7B,SAAS;YAAE8B,WAAW;QAAK;IACrD;IAEA,MAAMhF,GAAG8E,QAAQ,CAACG,SAAS,CAACjC,UAAU7C,sBAAsBgD;AAC9D","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/server/lib/router-utils/route-types-utils.ts"],"sourcesContent":["import path from 'path'\nimport {\n getRouteRegex,\n type Group,\n} from '../../../shared/lib/router/utils/route-regex'\nimport type { NextConfigComplete } from '../../config-shared'\n\nimport fs from 'fs'\nimport {\n generateRouteTypesFile,\n generateLinkTypesFile,\n generateValidatorFile,\n} from './typegen'\nimport { tryToParsePath } from '../../../lib/try-to-parse-path'\nimport {\n extractInterceptionRouteInformation,\n isInterceptionRouteAppPath,\n} from '../../../shared/lib/router/utils/interception-routes'\n\ninterface RouteInfo {\n path: string\n groups: { [groupName: string]: Group }\n}\n\nexport interface RouteTypesManifest {\n appRoutes: Record<string, RouteInfo>\n pageRoutes: Record<string, RouteInfo>\n layoutRoutes: Record<string, RouteInfo & { slots: string[] }>\n appRouteHandlerRoutes: Record<string, RouteInfo>\n /** Map of redirect source => RouteInfo */\n redirectRoutes: Record<string, RouteInfo>\n /** Map of rewrite source => RouteInfo */\n rewriteRoutes: Record<string, RouteInfo>\n /** File paths for validation */\n appPagePaths: Set<string>\n pagesRouterPagePaths: Set<string>\n layoutPaths: Set<string>\n appRouteHandlers: Set<string>\n pageApiRoutes: Set<string>\n /** Direct mapping from file paths to routes for validation */\n filePathToRoute: Map<string, string>\n}\n\n// Convert a custom-route source string (`/blog/:slug`, `/docs/:path*`, ...)\n// into the bracket-syntax used by other Next.js route helpers so that we can\n// reuse `getRouteRegex()` to extract groups.\nexport function convertCustomRouteSource(source: string): string[] {\n const parseResult = tryToParsePath(source)\n\n if (parseResult.error || !parseResult.tokens) {\n // Fallback to original source if parsing fails\n return source.startsWith('/') ? [source] : ['/' + source]\n }\n\n const possibleNormalizedRoutes = ['']\n let slugCnt = 1\n\n function append(suffix: string) {\n for (let i = 0; i < possibleNormalizedRoutes.length; i++) {\n possibleNormalizedRoutes[i] += suffix\n }\n }\n\n function fork(suffix: string) {\n const currentLength = possibleNormalizedRoutes.length\n for (let i = 0; i < currentLength; i++) {\n possibleNormalizedRoutes.push(possibleNormalizedRoutes[i] + suffix)\n }\n }\n\n for (const token of parseResult.tokens) {\n if (typeof token === 'object') {\n // Make sure the slug is always named.\n const slug = token.name || (slugCnt++ === 1 ? 'slug' : `slug${slugCnt}`)\n if (token.modifier === '*') {\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.modifier === '+') {\n append(`${token.prefix}[...${slug}]`)\n } else if (token.modifier === '') {\n if (token.pattern === '[^\\\\/#\\\\?]+?') {\n // A safe slug\n append(`${token.prefix}[${slug}]`)\n } else if (token.pattern === '.*') {\n // An optional catch-all slug\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.pattern === '.+') {\n // A catch-all slug\n append(`${token.prefix}[...${slug}]`)\n } else {\n // Other regex patterns are not supported. Skip this route.\n return []\n }\n } else if (token.modifier === '?') {\n if (/^[a-zA-Z0-9_/]*$/.test(token.pattern)) {\n // An optional slug with plain text only, fork the route.\n append(token.prefix)\n fork(token.pattern)\n } else {\n // Optional modifier `?` and regex patterns are not supported.\n return []\n }\n }\n } else if (typeof token === 'string') {\n append(token)\n }\n }\n\n // Ensure leading slash\n return possibleNormalizedRoutes.map((route) =>\n route.startsWith('/') ? route : '/' + route\n )\n}\n\n/**\n * Extracts route parameters from a route pattern\n */\nexport function extractRouteParams(route: string) {\n const regex = getRouteRegex(route)\n return regex.groups\n}\n\n/**\n * Resolves an intercepting route to its canonical equivalent\n * Example: /gallery/test/(..)photo/[id] -> /gallery/photo/[id]\n */\nfunction resolveInterceptingRoute(route: string): string {\n // Reuse centralized interception route normalization logic\n try {\n if (!isInterceptionRouteAppPath(route)) return route\n const { interceptedRoute } = extractInterceptionRouteInformation(route)\n return interceptedRoute\n } catch {\n // If parsing fails, fall back to the original route\n return route\n }\n}\n\n/**\n * Creates a route types manifest from processed route data\n * (used for both build and dev)\n */\nexport async function createRouteTypesManifest({\n dir,\n pageRoutes,\n appRoutes,\n appRouteHandlers,\n pageApiRoutes,\n layoutRoutes,\n slots,\n redirects,\n rewrites,\n validatorFilePath,\n}: {\n dir: string\n pageRoutes: Array<{ route: string; filePath: string }>\n appRoutes: Array<{ route: string; filePath: string }>\n appRouteHandlers: Array<{ route: string; filePath: string }>\n pageApiRoutes: Array<{ route: string; filePath: string }>\n layoutRoutes: Array<{ route: string; filePath: string }>\n slots: Array<{ name: string; parent: string }>\n redirects?: NextConfigComplete['redirects']\n rewrites?: NextConfigComplete['rewrites']\n validatorFilePath?: string\n}): Promise<RouteTypesManifest> {\n // Helper function to calculate the correct relative path\n const getRelativePath = (filePath: string) => {\n if (validatorFilePath) {\n // For validator generation, calculate path relative to validator directory\n return path.relative(path.dirname(validatorFilePath), filePath)\n }\n // For other uses, calculate path relative to project directory\n return path.relative(dir, filePath)\n }\n\n const manifest: RouteTypesManifest = {\n appRoutes: {},\n pageRoutes: {},\n layoutRoutes: {},\n appRouteHandlerRoutes: {},\n redirectRoutes: {},\n rewriteRoutes: {},\n appRouteHandlers: new Set(\n appRouteHandlers.map(({ filePath }) => getRelativePath(filePath))\n ),\n pageApiRoutes: new Set(\n pageApiRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n appPagePaths: new Set(\n appRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n pagesRouterPagePaths: new Set(\n pageRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n layoutPaths: new Set(\n layoutRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n filePathToRoute: new Map([\n ...appRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...layoutRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...appRouteHandlers.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...pageRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), route] as [string, string]\n ),\n ...pageApiRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), route] as [string, string]\n ),\n ]),\n }\n\n // Process page routes\n for (const { route, filePath } of pageRoutes) {\n manifest.pageRoutes[route] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(route),\n }\n }\n\n // Process layout routes\n for (const { route, filePath } of layoutRoutes) {\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.layoutRoutes[resolvedRoute]) {\n manifest.layoutRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n slots: [],\n }\n }\n }\n\n // Process slots\n for (const slot of slots) {\n if (manifest.layoutRoutes[slot.parent]) {\n manifest.layoutRoutes[slot.parent].slots.push(slot.name)\n }\n }\n\n // Process app routes\n for (const { route, filePath } of appRoutes) {\n // Don't include metadata routes or pages\n if (\n !filePath.endsWith('page.ts') &&\n !filePath.endsWith('page.tsx') &&\n !filePath.endsWith('.mdx') &&\n !filePath.endsWith('.md')\n ) {\n continue\n }\n\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRoutes[resolvedRoute]) {\n manifest.appRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process app route handlers\n for (const { route, filePath } of appRouteHandlers) {\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRouteHandlerRoutes[resolvedRoute]) {\n manifest.appRouteHandlerRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process redirects\n if (typeof redirects === 'function') {\n const rd = await redirects()\n\n for (const item of rd) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.redirectRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n // Process rewrites\n if (typeof rewrites === 'function') {\n const rw = await rewrites()\n\n const allSources = Array.isArray(rw)\n ? rw\n : [\n ...(rw?.beforeFiles || []),\n ...(rw?.afterFiles || []),\n ...(rw?.fallback || []),\n ]\n\n for (const item of allSources) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.rewriteRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n return manifest\n}\n\nexport async function writeRouteTypesManifest(\n manifest: RouteTypesManifest,\n filePath: string,\n config: NextConfigComplete\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n // Write the main routes.d.ts file\n await fs.promises.writeFile(filePath, generateRouteTypesFile(manifest))\n\n // Write the link.d.ts file if typedRoutes is enabled\n if (config.experimental?.typedRoutes === true) {\n const linkTypesPath = path.join(dirname, 'link.d.ts')\n await fs.promises.writeFile(linkTypesPath, generateLinkTypesFile(manifest))\n }\n}\n\nexport async function writeValidatorFile(\n manifest: RouteTypesManifest,\n filePath: string\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n await fs.promises.writeFile(filePath, generateValidatorFile(manifest))\n}\n"],"names":["path","getRouteRegex","fs","generateRouteTypesFile","generateLinkTypesFile","generateValidatorFile","tryToParsePath","extractInterceptionRouteInformation","isInterceptionRouteAppPath","convertCustomRouteSource","source","parseResult","error","tokens","startsWith","possibleNormalizedRoutes","slugCnt","append","suffix","i","length","fork","currentLength","push","token","slug","name","modifier","prefix","pattern","test","map","route","extractRouteParams","regex","groups","resolveInterceptingRoute","interceptedRoute","createRouteTypesManifest","dir","pageRoutes","appRoutes","appRouteHandlers","pageApiRoutes","layoutRoutes","slots","redirects","rewrites","validatorFilePath","getRelativePath","filePath","relative","dirname","manifest","appRouteHandlerRoutes","redirectRoutes","rewriteRoutes","Set","appPagePaths","pagesRouterPagePaths","layoutPaths","filePathToRoute","Map","resolvedRoute","slot","parent","endsWith","rd","item","possibleRoutes","rw","allSources","Array","isArray","beforeFiles","afterFiles","fallback","writeRouteTypesManifest","config","existsSync","promises","mkdir","recursive","writeFile","experimental","typedRoutes","linkTypesPath","join","writeValidatorFile"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SACEC,aAAa,QAER,+CAA8C;AAGrD,OAAOC,QAAQ,KAAI;AACnB,SACEC,sBAAsB,EACtBC,qBAAqB,EACrBC,qBAAqB,QAChB,YAAW;AAClB,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SACEC,mCAAmC,EACnCC,0BAA0B,QACrB,uDAAsD;AA0B7D,4EAA4E;AAC5E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mBAAmBD;gBAC7B;YACF;QACF;IACF;IAEA,OAAOqB;AACT;AAEA,OAAO,eAAewB,wBACpBxB,QAA4B,EAC5BH,QAAgB,EAChB4B,MAA0B;QAYtBA;IAVJ,MAAM1B,UAAUpD,KAAKoD,OAAO,CAACF;IAE7B,IAAI,CAAChD,GAAG6E,UAAU,CAAC3B,UAAU;QAC3B,MAAMlD,GAAG8E,QAAQ,CAACC,KAAK,CAAC7B,SAAS;YAAE8B,WAAW;QAAK;IACrD;IAEA,kCAAkC;IAClC,MAAMhF,GAAG8E,QAAQ,CAACG,SAAS,CAACjC,UAAU/C,uBAAuBkD;IAE7D,qDAAqD;IACrD,IAAIyB,EAAAA,uBAAAA,OAAOM,YAAY,qBAAnBN,qBAAqBO,WAAW,MAAK,MAAM;QAC7C,MAAMC,gBAAgBtF,KAAKuF,IAAI,CAACnC,SAAS;QACzC,MAAMlD,GAAG8E,QAAQ,CAACG,SAAS,CAACG,eAAelF,sBAAsBiD;IACnE;AACF;AAEA,OAAO,eAAemC,mBACpBnC,QAA4B,EAC5BH,QAAgB;IAEhB,MAAME,UAAUpD,KAAKoD,OAAO,CAACF;IAE7B,IAAI,CAAChD,GAAG6E,UAAU,CAAC3B,UAAU;QAC3B,MAAMlD,GAAG8E,QAAQ,CAACC,KAAK,CAAC7B,SAAS;YAAE8B,WAAW;QAAK;IACrD;IAEA,MAAMhF,GAAG8E,QAAQ,CAACG,SAAS,CAACjC,UAAU7C,sBAAsBgD;AAC9D","ignoreList":[0]}
@@ -14,10 +14,9 @@ function generateRouteTypes(routesManifest) {
14
14
  }
15
15
  // Generate AppRouteHandlerRoutes union type for route handlers
16
16
  const appRouteHandlerRoutes = Object.keys(routesManifest.appRouteHandlerRoutes).sort();
17
- if (appRouteHandlerRoutes.length > 0) {
17
+ const hasAppRouteHandlers = appRouteHandlerRoutes.length > 0;
18
+ if (hasAppRouteHandlers) {
18
19
  result += `type AppRouteHandlerRoutes = ${appRouteHandlerRoutes.map((route)=>JSON.stringify(route)).join(' | ')}\n`;
19
- } else {
20
- result += 'type AppRouteHandlerRoutes = never\n';
21
20
  }
22
21
  // Generate PageRoutes union type
23
22
  if (pageRoutes.length > 0) {
@@ -43,7 +42,18 @@ function generateRouteTypes(routesManifest) {
43
42
  } else {
44
43
  result += 'type RewriteRoutes = never\n';
45
44
  }
46
- result += 'type Routes = AppRoutes | AppRouteHandlerRoutes | PageRoutes | LayoutRoutes | RedirectRoutes | RewriteRoutes\n';
45
+ // Only include AppRouteHandlerRoutes in Routes union if there are actual route handlers
46
+ const routeUnionParts = [
47
+ 'AppRoutes',
48
+ 'PageRoutes',
49
+ 'LayoutRoutes',
50
+ 'RedirectRoutes',
51
+ 'RewriteRoutes'
52
+ ];
53
+ if (hasAppRouteHandlers) {
54
+ routeUnionParts.push('AppRouteHandlerRoutes');
55
+ }
56
+ result += `type Routes = ${routeUnionParts.join(' | ')}\n`;
47
57
  return result;
48
58
  }
49
59
  function generateParamTypes(routesManifest) {
@@ -309,15 +319,11 @@ export function generateValidatorFile(routesManifest) {
309
319
  const pagesRouterPageValidations = generateValidations(Array.from(routesManifest.pagesRouterPagePaths).sort(), 'PagesPageConfig');
310
320
  const pagesApiRouteValidations = generateValidations(Array.from(routesManifest.pageApiRoutes).sort(), 'ApiRouteConfig');
311
321
  const layoutValidations = generateValidations(Array.from(routesManifest.layoutPaths).sort(), 'LayoutConfig', routesManifest.filePathToRoute);
312
- return `// This file is generated automatically by Next.js
313
- // Do not edit this file manually
314
- // This file validates that all pages and layouts export the correct types
315
-
316
- import type { AppRoutes, AppRouteHandlerRoutes, LayoutRoutes, ParamMap } from "./routes.js"
317
- import type { ResolvingMetadata, ResolvingViewport } from "next/dist/lib/metadata/types/metadata-interface.js"
318
- import type { NextRequest } from 'next/server.js'
319
-
320
- type AppPageConfig<Route extends AppRoutes = AppRoutes> = {
322
+ const hasAppRouteHandlers = Object.keys(routesManifest.appRouteHandlerRoutes).length > 0;
323
+ // Build type definitions based on what's actually used
324
+ let typeDefinitions = '';
325
+ if (appPageValidations) {
326
+ typeDefinitions += `type AppPageConfig<Route extends AppRoutes = AppRoutes> = {
321
327
  default: React.ComponentType<{ params: Promise<ParamMap[Route]> } & any> | ((props: { params: Promise<ParamMap[Route]> } & any) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)
322
328
  generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]
323
329
  generateMetadata?: (
@@ -332,7 +338,10 @@ type AppPageConfig<Route extends AppRoutes = AppRoutes> = {
332
338
  viewport?: any
333
339
  }
334
340
 
335
- type PagesPageConfig = {
341
+ `;
342
+ }
343
+ if (pagesRouterPageValidations) {
344
+ typeDefinitions += `type PagesPageConfig = {
336
345
  default: React.ComponentType<any> | ((props: any) => React.ReactNode | Promise<React.ReactNode> | never | void)
337
346
  getStaticProps?: (context: any) => Promise<any> | any
338
347
  getStaticPaths?: (context: any) => Promise<any> | any
@@ -350,7 +359,10 @@ type PagesPageConfig = {
350
359
  }
351
360
  }
352
361
 
353
- type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
362
+ `;
363
+ }
364
+ if (layoutValidations) {
365
+ typeDefinitions += `type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
354
366
  default: React.ComponentType<LayoutProps<Route>> | ((props: LayoutProps<Route>) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)
355
367
  generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]
356
368
  generateMetadata?: (
@@ -365,7 +377,10 @@ type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {
365
377
  viewport?: any
366
378
  }
367
379
 
368
- type RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRoutes> = {
380
+ `;
381
+ }
382
+ if (appRouteHandlerValidations) {
383
+ typeDefinitions += `type RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRoutes> = {
369
384
  GET?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void
370
385
  POST?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void
371
386
  PUT?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void
@@ -375,7 +390,10 @@ type RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRou
375
390
  OPTIONS?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void
376
391
  }
377
392
 
378
- type ApiRouteConfig = {
393
+ `;
394
+ }
395
+ if (pagesApiRouteValidations) {
396
+ typeDefinitions += `type ApiRouteConfig = {
379
397
  default: (req: any, res: any) => Promise<void> | void | Promise<Response> | Response
380
398
  config?: {
381
399
  api?: {
@@ -388,6 +406,27 @@ type ApiRouteConfig = {
388
406
  }
389
407
  }
390
408
 
409
+ `;
410
+ }
411
+ // Build import statement based on what's actually needed
412
+ const routeImports = [
413
+ 'AppRoutes',
414
+ 'LayoutRoutes',
415
+ 'ParamMap'
416
+ ];
417
+ if (hasAppRouteHandlers) {
418
+ routeImports.push('AppRouteHandlerRoutes');
419
+ }
420
+ const routeImportStatement = routeImports.length > 0 ? `import type { ${routeImports.join(', ')} } from "./routes.js"` : '';
421
+ const nextRequestImport = hasAppRouteHandlers ? "import type { NextRequest } from 'next/server.js'\n" : '';
422
+ return `// This file is generated automatically by Next.js
423
+ // Do not edit this file manually
424
+ // This file validates that all pages and layouts export the correct types
425
+
426
+ ${routeImportStatement}
427
+ import type { ResolvingMetadata, ResolvingViewport } from "next/dist/lib/metadata/types/metadata-interface.js"
428
+ ${nextRequestImport}
429
+ ${typeDefinitions}
391
430
  ${appPageValidations}
392
431
 
393
432
  ${appRouteHandlerValidations}
@@ -403,6 +442,35 @@ export function generateRouteTypesFile(routesManifest) {
403
442
  const routeTypes = generateRouteTypes(routesManifest);
404
443
  const paramTypes = generateParamTypes(routesManifest);
405
444
  const layoutSlotMap = generateLayoutSlotMap(routesManifest);
445
+ const hasAppRouteHandlers = Object.keys(routesManifest.appRouteHandlerRoutes).length > 0;
446
+ // Build export statement based on what's actually generated
447
+ const routeExports = [
448
+ 'AppRoutes',
449
+ 'PageRoutes',
450
+ 'LayoutRoutes',
451
+ 'RedirectRoutes',
452
+ 'RewriteRoutes',
453
+ 'ParamMap'
454
+ ];
455
+ if (hasAppRouteHandlers) {
456
+ routeExports.push('AppRouteHandlerRoutes');
457
+ }
458
+ const exportStatement = `export type { ${routeExports.join(', ')} }`;
459
+ const routeContextInterface = hasAppRouteHandlers ? `
460
+
461
+ /**
462
+ * Context for Next.js App Router route handlers
463
+ * @example
464
+ * \`\`\`tsx
465
+ * export async function GET(request: NextRequest, context: RouteContext<'/api/users/[id]'>) {
466
+ * const { id } = await context.params
467
+ * return Response.json({ id })
468
+ * }
469
+ * \`\`\`
470
+ */
471
+ interface RouteContext<AppRouteHandlerRoute extends AppRouteHandlerRoutes> {
472
+ params: Promise<ParamMap[AppRouteHandlerRoute]>
473
+ }` : '';
406
474
  return `// This file is generated automatically by Next.js
407
475
  // Do not edit this file manually
408
476
 
@@ -414,7 +482,7 @@ export type ParamsOf<Route extends Routes> = ParamMap[Route]
414
482
 
415
483
  ${layoutSlotMap}
416
484
 
417
- export type { AppRoutes, AppRouteHandlerRoutes, PageRoutes, LayoutRoutes, RedirectRoutes, RewriteRoutes, ParamMap }
485
+ ${exportStatement}
418
486
 
419
487
  declare global {
420
488
  /**
@@ -446,21 +514,7 @@ declare global {
446
514
  children: React.ReactNode
447
515
  } & {
448
516
  [K in LayoutSlotMap[LayoutRoute]]: React.ReactNode
449
- }
450
-
451
- /**
452
- * Context for Next.js App Router route handlers
453
- * @example
454
- * \`\`\`tsx
455
- * export async function GET(request: NextRequest, context: RouteContext<'/api/users/[id]'>) {
456
- * const { id } = await context.params
457
- * return Response.json({ id })
458
- * }
459
- * \`\`\`
460
- */
461
- interface RouteContext<AppRouteHandlerRoute extends AppRouteHandlerRoutes> {
462
- params: Promise<ParamMap[AppRouteHandlerRoute]>
463
- }
517
+ }${routeContextInterface}
464
518
  }
465
519
  `;
466
520
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/server/lib/router-utils/typegen.ts"],"sourcesContent":["import type { RouteTypesManifest } from './route-types-utils'\nimport { isDynamicRoute } from '../../../shared/lib/router/utils/is-dynamic'\n\nfunction generateRouteTypes(routesManifest: RouteTypesManifest): string {\n const appRoutes = Object.keys(routesManifest.appRoutes).sort()\n const pageRoutes = Object.keys(routesManifest.pageRoutes).sort()\n const layoutRoutes = Object.keys(routesManifest.layoutRoutes).sort()\n const redirectRoutes = Object.keys(routesManifest.redirectRoutes).sort()\n const rewriteRoutes = Object.keys(routesManifest.rewriteRoutes).sort()\n\n let result = ''\n\n // Generate AppRoutes union type (pages only)\n if (appRoutes.length > 0) {\n result += `type AppRoutes = ${appRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type AppRoutes = never\\n'\n }\n\n // Generate AppRouteHandlerRoutes union type for route handlers\n const appRouteHandlerRoutes = Object.keys(\n routesManifest.appRouteHandlerRoutes\n ).sort()\n\n if (appRouteHandlerRoutes.length > 0) {\n result += `type AppRouteHandlerRoutes = ${appRouteHandlerRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type AppRouteHandlerRoutes = never\\n'\n }\n\n // Generate PageRoutes union type\n if (pageRoutes.length > 0) {\n result += `type PageRoutes = ${pageRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type PageRoutes = never\\n'\n }\n\n // Generate LayoutRoutes union type\n if (layoutRoutes.length > 0) {\n result += `type LayoutRoutes = ${layoutRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type LayoutRoutes = never\\n'\n }\n\n // Generate RedirectRoutes union type\n if (redirectRoutes.length > 0) {\n result += `type RedirectRoutes = ${redirectRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RedirectRoutes = never\\n'\n }\n\n // Generate RewriteRoutes union type\n if (rewriteRoutes.length > 0) {\n result += `type RewriteRoutes = ${rewriteRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RewriteRoutes = never\\n'\n }\n\n result +=\n 'type Routes = AppRoutes | AppRouteHandlerRoutes | PageRoutes | LayoutRoutes | RedirectRoutes | RewriteRoutes\\n'\n\n return result\n}\n\nfunction generateParamTypes(routesManifest: RouteTypesManifest): string {\n const allRoutes = {\n ...routesManifest.appRoutes,\n ...routesManifest.appRouteHandlerRoutes,\n ...routesManifest.pageRoutes,\n ...routesManifest.layoutRoutes,\n ...routesManifest.redirectRoutes,\n ...routesManifest.rewriteRoutes,\n }\n\n let paramTypes = 'interface ParamMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedRoutes = Object.entries(allRoutes).sort(([a], [b]) =>\n a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedRoutes) {\n const { groups } = routeInfo\n\n // For static routes (no dynamic segments), we can produce an empty parameter map.\n if (!isDynamicRoute(route) || Object.keys(groups ?? {}).length === 0) {\n paramTypes += ` ${JSON.stringify(route)}: {}\\n`\n continue\n }\n\n let paramType = '{'\n\n // Process each group based on its properties\n for (const [key, group] of Object.entries(groups)) {\n const escapedKey = JSON.stringify(key)\n if (group.repeat) {\n // Catch-all parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string[];`\n } else {\n paramType += ` ${escapedKey}: string[];`\n }\n } else {\n // Regular parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string;`\n } else {\n paramType += ` ${escapedKey}: string;`\n }\n }\n }\n\n paramType += ' }'\n\n paramTypes += ` ${JSON.stringify(route)}: ${paramType}\\n`\n }\n\n paramTypes += '}\\n'\n return paramTypes\n}\n\nfunction generateLayoutSlotMap(routesManifest: RouteTypesManifest): string {\n let slotMap = 'interface LayoutSlotMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedLayoutRoutes = Object.entries(routesManifest.layoutRoutes).sort(\n ([a], [b]) => a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedLayoutRoutes) {\n if ('slots' in routeInfo) {\n const slots = routeInfo.slots.sort()\n if (slots.length > 0) {\n slotMap += ` ${JSON.stringify(route)}: ${slots.map((slot) => JSON.stringify(slot)).join(' | ')}\\n`\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n }\n\n slotMap += '}\\n'\n return slotMap\n}\n\n// Helper function to format routes to route types (matches the plugin logic exactly)\nfunction formatRouteToRouteType(route: string) {\n const isDynamic = isDynamicRoute(route)\n if (isDynamic) {\n route = route\n .split('/')\n .map((part) => {\n if (part.startsWith('[') && part.endsWith(']')) {\n if (part.startsWith('[...')) {\n // /[...slug]\n return `\\${CatchAllSlug<T>}`\n } else if (part.startsWith('[[...') && part.endsWith(']]')) {\n // /[[...slug]]\n return `\\${OptionalCatchAllSlug<T>}`\n }\n // /[slug]\n return `\\${SafeSlug<T>}`\n }\n return part\n })\n .join('/')\n }\n\n return {\n isDynamic,\n routeType: route,\n }\n}\n\n// Helper function to serialize route types (matches the plugin logic exactly)\nfunction serializeRouteTypes(routeTypes: string[]) {\n // route collection is not deterministic, this makes the output of the file deterministic\n return routeTypes\n .sort()\n .map((route) => `\\n | \\`${route}\\``)\n .join('')\n}\n\nexport function generateLinkTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n // Generate serialized static and dynamic routes for the internal namespace\n const allRoutes = {\n ...routesManifest.appRoutes,\n ...routesManifest.pageRoutes,\n ...routesManifest.redirectRoutes,\n ...routesManifest.rewriteRoutes,\n }\n\n const staticRouteTypes: string[] = []\n const dynamicRouteTypes: string[] = []\n\n // Process each route using the same logic as the plugin\n for (const route of Object.keys(allRoutes)) {\n const { isDynamic, routeType } = formatRouteToRouteType(route)\n if (isDynamic) {\n dynamicRouteTypes.push(routeType)\n } else {\n staticRouteTypes.push(routeType)\n }\n }\n\n const serializedStaticRouteTypes = serializeRouteTypes(staticRouteTypes)\n const serializedDynamicRouteTypes = serializeRouteTypes(dynamicRouteTypes)\n\n // If both StaticRoutes and DynamicRoutes are empty, fallback to type 'string & {}'.\n const routeTypesFallback =\n !serializedStaticRouteTypes && !serializedDynamicRouteTypes\n ? 'string & {}'\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n// Type definitions for Next.js routes\n\n/**\n * Internal types used by the Next.js router and Link component.\n * These types are not meant to be used directly.\n * @internal\n */\ndeclare namespace __next_route_internal_types__ {\n type SearchOrHash = \\`?\\${string}\\` | \\`#\\${string}\\`\n type WithProtocol = \\`\\${string}:\\${string}\\`\n\n type Suffix = '' | SearchOrHash\n\n type SafeSlug<S extends string> = S extends \\`\\${string}/\\${string}\\`\n ? never\n : S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type CatchAllSlug<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type OptionalCatchAllSlug<S extends string> =\n S extends \\`\\${string}\\${SearchOrHash}\\` ? never : S\n\n type StaticRoutes = ${serializedStaticRouteTypes || 'never'}\n type DynamicRoutes<T extends string = string> = ${\n serializedDynamicRouteTypes || 'never'\n }\n\n type RouteImpl<T> = ${\n routeTypesFallback ||\n `\n ${\n // This keeps autocompletion working for static routes.\n '| StaticRoutes'\n }\n | SearchOrHash\n | WithProtocol\n | \\`\\${StaticRoutes}\\${SearchOrHash}\\`\n | (T extends \\`\\${DynamicRoutes<infer _>}\\${Suffix}\\` ? T : never)\n `\n }\n}\n\ndeclare module 'next' {\n export { default } from 'next/types.js'\n export * from 'next/types.js'\n\n export type Route<T extends string = string> =\n __next_route_internal_types__.RouteImpl<T>\n}\n\ndeclare module 'next/link' {\n import type { LinkProps as OriginalLinkProps } from 'next/dist/client/link.js'\n import type { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'\n import type { UrlObject } from 'url'\n\n type LinkRestProps = Omit<\n Omit<\n DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n >,\n keyof OriginalLinkProps\n > &\n OriginalLinkProps,\n 'href'\n >\n\n export type LinkProps<RouteInferType> = LinkRestProps & {\n /**\n * The path or URL to navigate to. This is the only required prop. It can also be an object.\n * @see https://nextjs.org/docs/api-reference/next/link\n */\n href: __next_route_internal_types__.RouteImpl<RouteInferType> | UrlObject\n }\n\n export default function Link<RouteType>(props: LinkProps<RouteType>): JSX.Element\n}\n\ndeclare module 'next/navigation' {\n export * from 'next/dist/client/components/navigation.js'\n\n import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n interface AppRouterInstance extends OriginalAppRouterInstance {\n /**\n * Navigate to the provided href.\n * Pushes a new history entry.\n */\n push<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Navigate to the provided href.\n * Replaces the current history entry.\n */\n replace<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Prefetch the provided href.\n */\n prefetch<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>): void\n }\n\n export function useRouter(): AppRouterInstance;\n}\n\ndeclare module 'next/form' {\n import type { FormProps as OriginalFormProps } from 'next/dist/client/form.js'\n\n type FormRestProps = Omit<OriginalFormProps, 'action'>\n\n export type FormProps<RouteInferType> = {\n /**\n * \\`action\\` can be either a \\`string\\` or a function.\n * - If \\`action\\` is a string, it will be interpreted as a path or URL to navigate to when the form is submitted.\n * The path will be prefetched when the form becomes visible.\n * - If \\`action\\` is a function, it will be called when the form is submitted. See the [React docs](https://react.dev/reference/react-dom/components/form#props) for more.\n */\n action: __next_route_internal_types__.RouteImpl<RouteInferType> | ((formData: FormData) => void)\n } & FormRestProps\n\n export default function Form<RouteType>(props: FormProps<RouteType>): JSX.Element\n}\n`\n}\n\nexport function generateValidatorFile(\n routesManifest: RouteTypesManifest\n): string {\n const generateValidations = (\n paths: string[],\n type:\n | 'AppPageConfig'\n | 'PagesPageConfig'\n | 'LayoutConfig'\n | 'RouteHandlerConfig'\n | 'ApiRouteConfig',\n pathToRouteMap?: Map<string, string>\n ) =>\n paths\n .sort()\n // Only validate TypeScript files - JavaScript files have too many type inference limitations\n .filter(\n (filePath) => filePath.endsWith('.ts') || filePath.endsWith('.tsx')\n )\n .filter(\n // Don't include metadata routes or pages\n // (e.g. /manifest.webmanifest)\n (filePath) =>\n type !== 'AppPageConfig' ||\n filePath.endsWith('page.ts') ||\n filePath.endsWith('page.tsx')\n )\n .map((filePath) => {\n // Keep the file extension for TypeScript imports to support node16 module resolution\n const importPath = filePath\n const route = pathToRouteMap?.get(filePath)\n const typeWithRoute =\n route &&\n (type === 'AppPageConfig' ||\n type === 'LayoutConfig' ||\n type === 'RouteHandlerConfig')\n ? `${type}<${JSON.stringify(route)}>`\n : type\n return `// Validate ${filePath}\n{\n const handler = {} as typeof import(${JSON.stringify(\n importPath.replace(/\\.tsx?$/, '.js')\n )})\n handler satisfies ${typeWithRoute}\n}`\n })\n .join('\\n\\n')\n\n // Use direct mappings from the manifest\n\n // Generate validations for different route types\n const appPageValidations = generateValidations(\n Array.from(routesManifest.appPagePaths).sort(),\n 'AppPageConfig',\n routesManifest.filePathToRoute\n )\n const appRouteHandlerValidations = generateValidations(\n Array.from(routesManifest.appRouteHandlers).sort(),\n 'RouteHandlerConfig',\n routesManifest.filePathToRoute\n )\n const pagesRouterPageValidations = generateValidations(\n Array.from(routesManifest.pagesRouterPagePaths).sort(),\n 'PagesPageConfig'\n )\n const pagesApiRouteValidations = generateValidations(\n Array.from(routesManifest.pageApiRoutes).sort(),\n 'ApiRouteConfig'\n )\n const layoutValidations = generateValidations(\n Array.from(routesManifest.layoutPaths).sort(),\n 'LayoutConfig',\n routesManifest.filePathToRoute\n )\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n// This file validates that all pages and layouts export the correct types\n\nimport type { AppRoutes, AppRouteHandlerRoutes, LayoutRoutes, ParamMap } from \"./routes.js\"\nimport type { ResolvingMetadata, ResolvingViewport } from \"next/dist/lib/metadata/types/metadata-interface.js\"\nimport type { NextRequest } from 'next/server.js'\n\ntype AppPageConfig<Route extends AppRoutes = AppRoutes> = {\n default: React.ComponentType<{ params: Promise<ParamMap[Route]> } & any> | ((props: { params: Promise<ParamMap[Route]> } & any) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\ntype PagesPageConfig = {\n default: React.ComponentType<any> | ((props: any) => React.ReactNode | Promise<React.ReactNode> | never | void)\n getStaticProps?: (context: any) => Promise<any> | any\n getStaticPaths?: (context: any) => Promise<any> | any\n getServerSideProps?: (context: any) => Promise<any> | any\n getInitialProps?: (context: any) => Promise<any> | any\n /**\n * Segment configuration for legacy Pages Router pages.\n * Validated at build-time by parsePagesSegmentConfig.\n */\n config?: {\n amp?: boolean | 'hybrid'\n maxDuration?: number\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n regions?: string[]\n }\n}\n\ntype LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {\n default: React.ComponentType<LayoutProps<Route>> | ((props: LayoutProps<Route>) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\ntype RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRoutes> = {\n GET?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n POST?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n PUT?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n PATCH?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n DELETE?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n HEAD?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n OPTIONS?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n}\n\ntype ApiRouteConfig = {\n default: (req: any, res: any) => Promise<void> | void | Promise<Response> | Response\n config?: {\n api?: {\n bodyParser?: boolean | { sizeLimit?: string }\n responseLimit?: string | number\n externalResolver?: boolean\n }\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n maxDuration?: number\n }\n}\n\n${appPageValidations}\n\n${appRouteHandlerValidations}\n\n${pagesRouterPageValidations}\n\n${pagesApiRouteValidations}\n\n${layoutValidations}\n`\n}\n\nexport function generateRouteTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n const routeTypes = generateRouteTypes(routesManifest)\n const paramTypes = generateParamTypes(routesManifest)\n const layoutSlotMap = generateLayoutSlotMap(routesManifest)\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n${routeTypes}\n\n${paramTypes}\n\nexport type ParamsOf<Route extends Routes> = ParamMap[Route]\n\n${layoutSlotMap}\n\nexport type { AppRoutes, AppRouteHandlerRoutes, PageRoutes, LayoutRoutes, RedirectRoutes, RewriteRoutes, ParamMap }\n\ndeclare global {\n /**\n * Props for Next.js App Router page components\n * @example\n * \\`\\`\\`tsx\n * export default function Page(props: PageProps<'/blog/[slug]'>) {\n * const { slug } = await props.params\n * return <div>Blog post: {slug}</div>\n * }\n * \\`\\`\\`\n */\n interface PageProps<AppRoute extends AppRoutes> {\n params: Promise<ParamMap[AppRoute]>\n searchParams: Promise<Record<string, string | string[] | undefined>>\n }\n\n /**\n * Props for Next.js App Router layout components\n * @example\n * \\`\\`\\`tsx\n * export default function Layout(props: LayoutProps<'/dashboard'>) {\n * return <div>{props.children}</div>\n * }\n * \\`\\`\\`\n */\n type LayoutProps<LayoutRoute extends LayoutRoutes> = {\n params: Promise<ParamMap[LayoutRoute]>\n children: React.ReactNode\n } & {\n [K in LayoutSlotMap[LayoutRoute]]: React.ReactNode\n }\n\n /**\n * Context for Next.js App Router route handlers\n * @example\n * \\`\\`\\`tsx\n * export async function GET(request: NextRequest, context: RouteContext<'/api/users/[id]'>) {\n * const { id } = await context.params\n * return Response.json({ id })\n * }\n * \\`\\`\\`\n */\n interface RouteContext<AppRouteHandlerRoute extends AppRouteHandlerRoutes> {\n params: Promise<ParamMap[AppRouteHandlerRoute]>\n }\n}\n`\n}\n"],"names":["isDynamicRoute","generateRouteTypes","routesManifest","appRoutes","Object","keys","sort","pageRoutes","layoutRoutes","redirectRoutes","rewriteRoutes","result","length","map","route","JSON","stringify","join","appRouteHandlerRoutes","generateParamTypes","allRoutes","paramTypes","sortedRoutes","entries","a","b","localeCompare","routeInfo","groups","paramType","key","group","escapedKey","repeat","optional","generateLayoutSlotMap","slotMap","sortedLayoutRoutes","slots","slot","formatRouteToRouteType","isDynamic","split","part","startsWith","endsWith","routeType","serializeRouteTypes","routeTypes","generateLinkTypesFile","staticRouteTypes","dynamicRouteTypes","push","serializedStaticRouteTypes","serializedDynamicRouteTypes","routeTypesFallback","generateValidatorFile","generateValidations","paths","type","pathToRouteMap","filter","filePath","importPath","get","typeWithRoute","replace","appPageValidations","Array","from","appPagePaths","filePathToRoute","appRouteHandlerValidations","appRouteHandlers","pagesRouterPageValidations","pagesRouterPagePaths","pagesApiRouteValidations","pageApiRoutes","layoutValidations","layoutPaths","generateRouteTypesFile","layoutSlotMap"],"mappings":"AACA,SAASA,cAAc,QAAQ,8CAA6C;AAE5E,SAASC,mBAAmBC,cAAkC;IAC5D,MAAMC,YAAYC,OAAOC,IAAI,CAACH,eAAeC,SAAS,EAAEG,IAAI;IAC5D,MAAMC,aAAaH,OAAOC,IAAI,CAACH,eAAeK,UAAU,EAAED,IAAI;IAC9D,MAAME,eAAeJ,OAAOC,IAAI,CAACH,eAAeM,YAAY,EAAEF,IAAI;IAClE,MAAMG,iBAAiBL,OAAOC,IAAI,CAACH,eAAeO,cAAc,EAAEH,IAAI;IACtE,MAAMI,gBAAgBN,OAAOC,IAAI,CAACH,eAAeQ,aAAa,EAAEJ,IAAI;IAEpE,IAAIK,SAAS;IAEb,6CAA6C;IAC7C,IAAIR,UAAUS,MAAM,GAAG,GAAG;QACxBD,UAAU,CAAC,iBAAiB,EAAER,UAAUU,GAAG,CAAC,CAACC,QAAUC,KAAKC,SAAS,CAACF,QAAQG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/F,OAAO;QACLN,UAAU;IACZ;IAEA,+DAA+D;IAC/D,MAAMO,wBAAwBd,OAAOC,IAAI,CACvCH,eAAegB,qBAAqB,EACpCZ,IAAI;IAEN,IAAIY,sBAAsBN,MAAM,GAAG,GAAG;QACpCD,UAAU,CAAC,6BAA6B,EAAEO,sBAAsBL,GAAG,CAAC,CAACC,QAAUC,KAAKC,SAAS,CAACF,QAAQG,IAAI,CAAC,OAAO,EAAE,CAAC;IACvH,OAAO;QACLN,UAAU;IACZ;IAEA,iCAAiC;IACjC,IAAIJ,WAAWK,MAAM,GAAG,GAAG;QACzBD,UAAU,CAAC,kBAAkB,EAAEJ,WAAWM,GAAG,CAAC,CAACC,QAAUC,KAAKC,SAAS,CAACF,QAAQG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+E,gBAAgB9C,sBAAsBjC;IAE5C,OAAO,CAAC;;;AAGV,EAAE8C,WAAW;;AAEb,EAAE3B,WAAW;;;;AAIb,EAAE4D,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDhB,CAAC;AACD","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/server/lib/router-utils/typegen.ts"],"sourcesContent":["import type { RouteTypesManifest } from './route-types-utils'\nimport { isDynamicRoute } from '../../../shared/lib/router/utils/is-dynamic'\n\nfunction generateRouteTypes(routesManifest: RouteTypesManifest): string {\n const appRoutes = Object.keys(routesManifest.appRoutes).sort()\n const pageRoutes = Object.keys(routesManifest.pageRoutes).sort()\n const layoutRoutes = Object.keys(routesManifest.layoutRoutes).sort()\n const redirectRoutes = Object.keys(routesManifest.redirectRoutes).sort()\n const rewriteRoutes = Object.keys(routesManifest.rewriteRoutes).sort()\n\n let result = ''\n\n // Generate AppRoutes union type (pages only)\n if (appRoutes.length > 0) {\n result += `type AppRoutes = ${appRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type AppRoutes = never\\n'\n }\n\n // Generate AppRouteHandlerRoutes union type for route handlers\n const appRouteHandlerRoutes = Object.keys(\n routesManifest.appRouteHandlerRoutes\n ).sort()\n\n const hasAppRouteHandlers = appRouteHandlerRoutes.length > 0\n\n if (hasAppRouteHandlers) {\n result += `type AppRouteHandlerRoutes = ${appRouteHandlerRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n }\n\n // Generate PageRoutes union type\n if (pageRoutes.length > 0) {\n result += `type PageRoutes = ${pageRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type PageRoutes = never\\n'\n }\n\n // Generate LayoutRoutes union type\n if (layoutRoutes.length > 0) {\n result += `type LayoutRoutes = ${layoutRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type LayoutRoutes = never\\n'\n }\n\n // Generate RedirectRoutes union type\n if (redirectRoutes.length > 0) {\n result += `type RedirectRoutes = ${redirectRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RedirectRoutes = never\\n'\n }\n\n // Generate RewriteRoutes union type\n if (rewriteRoutes.length > 0) {\n result += `type RewriteRoutes = ${rewriteRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RewriteRoutes = never\\n'\n }\n\n // Only include AppRouteHandlerRoutes in Routes union if there are actual route handlers\n const routeUnionParts = [\n 'AppRoutes',\n 'PageRoutes',\n 'LayoutRoutes',\n 'RedirectRoutes',\n 'RewriteRoutes',\n ]\n if (hasAppRouteHandlers) {\n routeUnionParts.push('AppRouteHandlerRoutes')\n }\n\n result += `type Routes = ${routeUnionParts.join(' | ')}\\n`\n\n return result\n}\n\nfunction generateParamTypes(routesManifest: RouteTypesManifest): string {\n const allRoutes = {\n ...routesManifest.appRoutes,\n ...routesManifest.appRouteHandlerRoutes,\n ...routesManifest.pageRoutes,\n ...routesManifest.layoutRoutes,\n ...routesManifest.redirectRoutes,\n ...routesManifest.rewriteRoutes,\n }\n\n let paramTypes = 'interface ParamMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedRoutes = Object.entries(allRoutes).sort(([a], [b]) =>\n a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedRoutes) {\n const { groups } = routeInfo\n\n // For static routes (no dynamic segments), we can produce an empty parameter map.\n if (!isDynamicRoute(route) || Object.keys(groups ?? {}).length === 0) {\n paramTypes += ` ${JSON.stringify(route)}: {}\\n`\n continue\n }\n\n let paramType = '{'\n\n // Process each group based on its properties\n for (const [key, group] of Object.entries(groups)) {\n const escapedKey = JSON.stringify(key)\n if (group.repeat) {\n // Catch-all parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string[];`\n } else {\n paramType += ` ${escapedKey}: string[];`\n }\n } else {\n // Regular parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string;`\n } else {\n paramType += ` ${escapedKey}: string;`\n }\n }\n }\n\n paramType += ' }'\n\n paramTypes += ` ${JSON.stringify(route)}: ${paramType}\\n`\n }\n\n paramTypes += '}\\n'\n return paramTypes\n}\n\nfunction generateLayoutSlotMap(routesManifest: RouteTypesManifest): string {\n let slotMap = 'interface LayoutSlotMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedLayoutRoutes = Object.entries(routesManifest.layoutRoutes).sort(\n ([a], [b]) => a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedLayoutRoutes) {\n if ('slots' in routeInfo) {\n const slots = routeInfo.slots.sort()\n if (slots.length > 0) {\n slotMap += ` ${JSON.stringify(route)}: ${slots.map((slot) => JSON.stringify(slot)).join(' | ')}\\n`\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n }\n\n slotMap += '}\\n'\n return slotMap\n}\n\n// Helper function to format routes to route types (matches the plugin logic exactly)\nfunction formatRouteToRouteType(route: string) {\n const isDynamic = isDynamicRoute(route)\n if (isDynamic) {\n route = route\n .split('/')\n .map((part) => {\n if (part.startsWith('[') && part.endsWith(']')) {\n if (part.startsWith('[...')) {\n // /[...slug]\n return `\\${CatchAllSlug<T>}`\n } else if (part.startsWith('[[...') && part.endsWith(']]')) {\n // /[[...slug]]\n return `\\${OptionalCatchAllSlug<T>}`\n }\n // /[slug]\n return `\\${SafeSlug<T>}`\n }\n return part\n })\n .join('/')\n }\n\n return {\n isDynamic,\n routeType: route,\n }\n}\n\n// Helper function to serialize route types (matches the plugin logic exactly)\nfunction serializeRouteTypes(routeTypes: string[]) {\n // route collection is not deterministic, this makes the output of the file deterministic\n return routeTypes\n .sort()\n .map((route) => `\\n | \\`${route}\\``)\n .join('')\n}\n\nexport function generateLinkTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n // Generate serialized static and dynamic routes for the internal namespace\n const allRoutes = {\n ...routesManifest.appRoutes,\n ...routesManifest.pageRoutes,\n ...routesManifest.redirectRoutes,\n ...routesManifest.rewriteRoutes,\n }\n\n const staticRouteTypes: string[] = []\n const dynamicRouteTypes: string[] = []\n\n // Process each route using the same logic as the plugin\n for (const route of Object.keys(allRoutes)) {\n const { isDynamic, routeType } = formatRouteToRouteType(route)\n if (isDynamic) {\n dynamicRouteTypes.push(routeType)\n } else {\n staticRouteTypes.push(routeType)\n }\n }\n\n const serializedStaticRouteTypes = serializeRouteTypes(staticRouteTypes)\n const serializedDynamicRouteTypes = serializeRouteTypes(dynamicRouteTypes)\n\n // If both StaticRoutes and DynamicRoutes are empty, fallback to type 'string & {}'.\n const routeTypesFallback =\n !serializedStaticRouteTypes && !serializedDynamicRouteTypes\n ? 'string & {}'\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n// Type definitions for Next.js routes\n\n/**\n * Internal types used by the Next.js router and Link component.\n * These types are not meant to be used directly.\n * @internal\n */\ndeclare namespace __next_route_internal_types__ {\n type SearchOrHash = \\`?\\${string}\\` | \\`#\\${string}\\`\n type WithProtocol = \\`\\${string}:\\${string}\\`\n\n type Suffix = '' | SearchOrHash\n\n type SafeSlug<S extends string> = S extends \\`\\${string}/\\${string}\\`\n ? never\n : S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type CatchAllSlug<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type OptionalCatchAllSlug<S extends string> =\n S extends \\`\\${string}\\${SearchOrHash}\\` ? never : S\n\n type StaticRoutes = ${serializedStaticRouteTypes || 'never'}\n type DynamicRoutes<T extends string = string> = ${\n serializedDynamicRouteTypes || 'never'\n }\n\n type RouteImpl<T> = ${\n routeTypesFallback ||\n `\n ${\n // This keeps autocompletion working for static routes.\n '| StaticRoutes'\n }\n | SearchOrHash\n | WithProtocol\n | \\`\\${StaticRoutes}\\${SearchOrHash}\\`\n | (T extends \\`\\${DynamicRoutes<infer _>}\\${Suffix}\\` ? T : never)\n `\n }\n}\n\ndeclare module 'next' {\n export { default } from 'next/types.js'\n export * from 'next/types.js'\n\n export type Route<T extends string = string> =\n __next_route_internal_types__.RouteImpl<T>\n}\n\ndeclare module 'next/link' {\n import type { LinkProps as OriginalLinkProps } from 'next/dist/client/link.js'\n import type { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'\n import type { UrlObject } from 'url'\n\n type LinkRestProps = Omit<\n Omit<\n DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n >,\n keyof OriginalLinkProps\n > &\n OriginalLinkProps,\n 'href'\n >\n\n export type LinkProps<RouteInferType> = LinkRestProps & {\n /**\n * The path or URL to navigate to. This is the only required prop. It can also be an object.\n * @see https://nextjs.org/docs/api-reference/next/link\n */\n href: __next_route_internal_types__.RouteImpl<RouteInferType> | UrlObject\n }\n\n export default function Link<RouteType>(props: LinkProps<RouteType>): JSX.Element\n}\n\ndeclare module 'next/navigation' {\n export * from 'next/dist/client/components/navigation.js'\n\n import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n interface AppRouterInstance extends OriginalAppRouterInstance {\n /**\n * Navigate to the provided href.\n * Pushes a new history entry.\n */\n push<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Navigate to the provided href.\n * Replaces the current history entry.\n */\n replace<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Prefetch the provided href.\n */\n prefetch<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>): void\n }\n\n export function useRouter(): AppRouterInstance;\n}\n\ndeclare module 'next/form' {\n import type { FormProps as OriginalFormProps } from 'next/dist/client/form.js'\n\n type FormRestProps = Omit<OriginalFormProps, 'action'>\n\n export type FormProps<RouteInferType> = {\n /**\n * \\`action\\` can be either a \\`string\\` or a function.\n * - If \\`action\\` is a string, it will be interpreted as a path or URL to navigate to when the form is submitted.\n * The path will be prefetched when the form becomes visible.\n * - If \\`action\\` is a function, it will be called when the form is submitted. See the [React docs](https://react.dev/reference/react-dom/components/form#props) for more.\n */\n action: __next_route_internal_types__.RouteImpl<RouteInferType> | ((formData: FormData) => void)\n } & FormRestProps\n\n export default function Form<RouteType>(props: FormProps<RouteType>): JSX.Element\n}\n`\n}\n\nexport function generateValidatorFile(\n routesManifest: RouteTypesManifest\n): string {\n const generateValidations = (\n paths: string[],\n type:\n | 'AppPageConfig'\n | 'PagesPageConfig'\n | 'LayoutConfig'\n | 'RouteHandlerConfig'\n | 'ApiRouteConfig',\n pathToRouteMap?: Map<string, string>\n ) =>\n paths\n .sort()\n // Only validate TypeScript files - JavaScript files have too many type inference limitations\n .filter(\n (filePath) => filePath.endsWith('.ts') || filePath.endsWith('.tsx')\n )\n .filter(\n // Don't include metadata routes or pages\n // (e.g. /manifest.webmanifest)\n (filePath) =>\n type !== 'AppPageConfig' ||\n filePath.endsWith('page.ts') ||\n filePath.endsWith('page.tsx')\n )\n .map((filePath) => {\n // Keep the file extension for TypeScript imports to support node16 module resolution\n const importPath = filePath\n const route = pathToRouteMap?.get(filePath)\n const typeWithRoute =\n route &&\n (type === 'AppPageConfig' ||\n type === 'LayoutConfig' ||\n type === 'RouteHandlerConfig')\n ? `${type}<${JSON.stringify(route)}>`\n : type\n return `// Validate ${filePath}\n{\n const handler = {} as typeof import(${JSON.stringify(\n importPath.replace(/\\.tsx?$/, '.js')\n )})\n handler satisfies ${typeWithRoute}\n}`\n })\n .join('\\n\\n')\n\n // Use direct mappings from the manifest\n\n // Generate validations for different route types\n const appPageValidations = generateValidations(\n Array.from(routesManifest.appPagePaths).sort(),\n 'AppPageConfig',\n routesManifest.filePathToRoute\n )\n const appRouteHandlerValidations = generateValidations(\n Array.from(routesManifest.appRouteHandlers).sort(),\n 'RouteHandlerConfig',\n routesManifest.filePathToRoute\n )\n const pagesRouterPageValidations = generateValidations(\n Array.from(routesManifest.pagesRouterPagePaths).sort(),\n 'PagesPageConfig'\n )\n const pagesApiRouteValidations = generateValidations(\n Array.from(routesManifest.pageApiRoutes).sort(),\n 'ApiRouteConfig'\n )\n const layoutValidations = generateValidations(\n Array.from(routesManifest.layoutPaths).sort(),\n 'LayoutConfig',\n routesManifest.filePathToRoute\n )\n\n const hasAppRouteHandlers =\n Object.keys(routesManifest.appRouteHandlerRoutes).length > 0\n\n // Build type definitions based on what's actually used\n let typeDefinitions = ''\n\n if (appPageValidations) {\n typeDefinitions += `type AppPageConfig<Route extends AppRoutes = AppRoutes> = {\n default: React.ComponentType<{ params: Promise<ParamMap[Route]> } & any> | ((props: { params: Promise<ParamMap[Route]> } & any) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\n`\n }\n\n if (pagesRouterPageValidations) {\n typeDefinitions += `type PagesPageConfig = {\n default: React.ComponentType<any> | ((props: any) => React.ReactNode | Promise<React.ReactNode> | never | void)\n getStaticProps?: (context: any) => Promise<any> | any\n getStaticPaths?: (context: any) => Promise<any> | any\n getServerSideProps?: (context: any) => Promise<any> | any\n getInitialProps?: (context: any) => Promise<any> | any\n /**\n * Segment configuration for legacy Pages Router pages.\n * Validated at build-time by parsePagesSegmentConfig.\n */\n config?: {\n amp?: boolean | 'hybrid'\n maxDuration?: number\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n regions?: string[]\n }\n}\n\n`\n }\n\n if (layoutValidations) {\n typeDefinitions += `type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {\n default: React.ComponentType<LayoutProps<Route>> | ((props: LayoutProps<Route>) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\n`\n }\n\n if (appRouteHandlerValidations) {\n typeDefinitions += `type RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRoutes> = {\n GET?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n POST?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n PUT?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n PATCH?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n DELETE?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n HEAD?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n OPTIONS?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response> | Response | Promise<void> | void\n}\n\n`\n }\n\n if (pagesApiRouteValidations) {\n typeDefinitions += `type ApiRouteConfig = {\n default: (req: any, res: any) => Promise<void> | void | Promise<Response> | Response\n config?: {\n api?: {\n bodyParser?: boolean | { sizeLimit?: string }\n responseLimit?: string | number\n externalResolver?: boolean\n }\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n maxDuration?: number\n }\n}\n\n`\n }\n\n // Build import statement based on what's actually needed\n const routeImports = ['AppRoutes', 'LayoutRoutes', 'ParamMap']\n if (hasAppRouteHandlers) {\n routeImports.push('AppRouteHandlerRoutes')\n }\n\n const routeImportStatement =\n routeImports.length > 0\n ? `import type { ${routeImports.join(', ')} } from \"./routes.js\"`\n : ''\n\n const nextRequestImport = hasAppRouteHandlers\n ? \"import type { NextRequest } from 'next/server.js'\\n\"\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n// This file validates that all pages and layouts export the correct types\n\n${routeImportStatement}\nimport type { ResolvingMetadata, ResolvingViewport } from \"next/dist/lib/metadata/types/metadata-interface.js\"\n${nextRequestImport}\n${typeDefinitions}\n${appPageValidations}\n\n${appRouteHandlerValidations}\n\n${pagesRouterPageValidations}\n\n${pagesApiRouteValidations}\n\n${layoutValidations}\n`\n}\n\nexport function generateRouteTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n const routeTypes = generateRouteTypes(routesManifest)\n const paramTypes = generateParamTypes(routesManifest)\n const layoutSlotMap = generateLayoutSlotMap(routesManifest)\n\n const hasAppRouteHandlers =\n Object.keys(routesManifest.appRouteHandlerRoutes).length > 0\n\n // Build export statement based on what's actually generated\n const routeExports = [\n 'AppRoutes',\n 'PageRoutes',\n 'LayoutRoutes',\n 'RedirectRoutes',\n 'RewriteRoutes',\n 'ParamMap',\n ]\n if (hasAppRouteHandlers) {\n routeExports.push('AppRouteHandlerRoutes')\n }\n\n const exportStatement = `export type { ${routeExports.join(', ')} }`\n\n const routeContextInterface = hasAppRouteHandlers\n ? `\n\n /**\n * Context for Next.js App Router route handlers\n * @example\n * \\`\\`\\`tsx\n * export async function GET(request: NextRequest, context: RouteContext<'/api/users/[id]'>) {\n * const { id } = await context.params\n * return Response.json({ id })\n * }\n * \\`\\`\\`\n */\n interface RouteContext<AppRouteHandlerRoute extends AppRouteHandlerRoutes> {\n params: Promise<ParamMap[AppRouteHandlerRoute]>\n }`\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n${routeTypes}\n\n${paramTypes}\n\nexport type ParamsOf<Route extends Routes> = ParamMap[Route]\n\n${layoutSlotMap}\n\n${exportStatement}\n\ndeclare global {\n /**\n * Props for Next.js App Router page components\n * @example\n * \\`\\`\\`tsx\n * export default function Page(props: PageProps<'/blog/[slug]'>) {\n * const { slug } = await props.params\n * return <div>Blog post: {slug}</div>\n * }\n * \\`\\`\\`\n */\n interface PageProps<AppRoute extends AppRoutes> {\n params: Promise<ParamMap[AppRoute]>\n searchParams: Promise<Record<string, string | string[] | undefined>>\n }\n\n /**\n * Props for Next.js App Router layout components\n * @example\n * \\`\\`\\`tsx\n * export default function Layout(props: LayoutProps<'/dashboard'>) {\n * return <div>{props.children}</div>\n * }\n * \\`\\`\\`\n */\n type LayoutProps<LayoutRoute extends LayoutRoutes> = {\n params: Promise<ParamMap[LayoutRoute]>\n children: React.ReactNode\n } & {\n [K in LayoutSlotMap[LayoutRoute]]: React.ReactNode\n }${routeContextInterface}\n}\n`\n}\n"],"names":["isDynamicRoute","generateRouteTypes","routesManifest","appRoutes","Object","keys","sort","pageRoutes","layoutRoutes","redirectRoutes","rewriteRoutes","result","length","map","route","JSON","stringify","join","appRouteHandlerRoutes","hasAppRouteHandlers","routeUnionParts","push","generateParamTypes","allRoutes","paramTypes","sortedRoutes","entries","a","b","localeCompare","routeInfo","groups","paramType","key","group","escapedKey","repeat","optional","generateLayoutSlotMap","slotMap","sortedLayoutRoutes","slots","slot","formatRouteToRouteType","isDynamic","split","part","startsWith","endsWith","routeType","serializeRouteTypes","routeTypes","generateLinkTypesFile","staticRouteTypes","dynamicRouteTypes","serializedStaticRouteTypes","serializedDynamicRouteTypes","routeTypesFallback","generateValidatorFile","generateValidations","paths","type","pathToRouteMap","filter","filePath","importPath","get","typeWithRoute","replace","appPageValidations","Array","from","appPagePaths","filePathToRoute","appRouteHandlerValidations","appRouteHandlers","pagesRouterPageValidations","pagesRouterPagePaths","pagesApiRouteValidations","pageApiRoutes","layoutValidations","layoutPaths","typeDefinitions","routeImports","routeImportStatement","nextRequestImport","generateRouteTypesFile","layoutSlotMap","routeExports","exportStatement","routeContextInterface"],"mappings":"AAC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AE+D,cAAc;;AAEhB,EAAEE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCf,EAAEC,sBAAsB;;AAE3B,CAAC;AACD","ignoreList":[0]}
@@ -111,7 +111,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
111
111
  export async function startServer(serverOptions) {
112
112
  const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
113
113
  let { port } = serverOptions;
114
- process.title = `next-server (v${"15.4.2-canary.52"})`;
114
+ process.title = `next-server (v${"15.4.2-canary.53"})`;
115
115
  let handlersReady = ()=>{};
116
116
  let handlersError = ()=>{};
117
117
  let handlersPromise = new Promise((resolve, reject)=>{
@@ -1,6 +1,6 @@
1
1
  export function isStableBuild() {
2
2
  var _process_env___NEXT_VERSION;
3
- return !((_process_env___NEXT_VERSION = "15.4.2-canary.52") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
3
+ return !((_process_env___NEXT_VERSION = "15.4.2-canary.53") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
4
4
  }
5
5
  export class CanaryOnlyError extends Error {
6
6
  constructor(arg){
@@ -145,7 +145,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
145
145
  }
146
146
  const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
147
147
  const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
148
- version: "15.4.2-canary.52"
148
+ version: "15.4.2-canary.53"
149
149
  });
150
150
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
151
151
  // of the current `next dev` invocation.