{"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  generateValidatorFileStrict,\n  generateRouteTypesFileStrict,\n} from './typegen'\nimport { tryToParsePath } from '../../../lib/try-to-parse-path'\nimport {\n  extractInterceptionRouteInformation,\n  isInterceptionRouteAppPath,\n} from '../../../shared/lib/router/utils/interception-routes'\nimport {\n  UNDERSCORE_GLOBAL_ERROR_ROUTE,\n  UNDERSCORE_NOT_FOUND_ROUTE,\n} from '../../../shared/lib/entry-constants'\nimport { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'\nimport type { RouteInfo, SlotInfo } from '../../../build/file-classifier'\n\n// Internal route info with extracted params for the manifest\ninterface ManifestRouteInfo {\n  path: string\n  groups: { [groupName: string]: Group }\n}\n\nexport interface RouteTypesManifest {\n  appRoutes: Record<string, ManifestRouteInfo>\n  pageRoutes: Record<string, ManifestRouteInfo>\n  layoutRoutes: Record<string, ManifestRouteInfo & { slots: string[] }>\n  appRouteHandlerRoutes: Record<string, ManifestRouteInfo>\n  /** Map of redirect source => ManifestRouteInfo */\n  redirectRoutes: Record<string, ManifestRouteInfo>\n  /** Map of rewrite source => ManifestRouteInfo */\n  rewriteRoutes: Record<string, ManifestRouteInfo>\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: RouteInfo[]\n  appRoutes: RouteInfo[]\n  appRouteHandlers: RouteInfo[]\n  pageApiRoutes: RouteInfo[]\n  layoutRoutes: RouteInfo[]\n  slots: SlotInfo[]\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 normalizePathSep(\n        path.relative(path.dirname(validatorFilePath), filePath)\n      )\n    }\n    // For other uses, calculate path relative to project directory\n    return normalizePathSep(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 (exclude internal app error/not-found layouts)\n  for (const { route, filePath } of layoutRoutes) {\n    if (\n      route === UNDERSCORE_GLOBAL_ERROR_ROUTE ||\n      route === UNDERSCORE_NOT_FOUND_ROUTE\n    )\n      continue\n    // Use the resolved route (for interception routes, this gives us the canonical route)\n    const resolvedRoute = resolveInterceptingRoute(route)\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 (exclude internal app routes)\n  for (const { route, filePath } of appRoutes) {\n    if (\n      route === UNDERSCORE_GLOBAL_ERROR_ROUTE ||\n      route === UNDERSCORE_NOT_FOUND_ROUTE\n    )\n      continue\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(\n    filePath,\n    config.experimental.strictRouteTypes\n      ? generateRouteTypesFileStrict(manifest)\n      : generateRouteTypesFile(manifest)\n  )\n\n  // Write the link.d.ts file if typedRoutes is enabled\n  if (config.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  strict: boolean\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(\n    filePath,\n    strict\n      ? generateValidatorFileStrict(manifest)\n      : generateValidatorFile(manifest)\n  )\n}\n"],"names":["path","getRouteRegex","fs","generateRouteTypesFile","generateLinkTypesFile","generateValidatorFile","generateValidatorFileStrict","generateRouteTypesFileStrict","tryToParsePath","extractInterceptionRouteInformation","isInterceptionRouteAppPath","UNDERSCORE_GLOBAL_ERROR_ROUTE","UNDERSCORE_NOT_FOUND_ROUTE","normalizePathSep","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","strictRouteTypes","typedRoutes","linkTypesPath","join","writeValidat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