vinext 0.0.47 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/README.md +1 -1
  2. package/dist/build/layout-classification.js +3 -1
  3. package/dist/build/layout-classification.js.map +1 -1
  4. package/dist/build/prerender.js +10 -10
  5. package/dist/build/prerender.js.map +1 -1
  6. package/dist/build/report.d.ts +8 -4
  7. package/dist/build/report.js +17 -7
  8. package/dist/build/report.js.map +1 -1
  9. package/dist/build/run-prerender.d.ts +5 -0
  10. package/dist/build/run-prerender.js +4 -1
  11. package/dist/build/run-prerender.js.map +1 -1
  12. package/dist/build/server-manifest.js +2 -7
  13. package/dist/build/server-manifest.js.map +1 -1
  14. package/dist/build/standalone.js +3 -5
  15. package/dist/build/standalone.js.map +1 -1
  16. package/dist/check.js +45 -29
  17. package/dist/check.js.map +1 -1
  18. package/dist/cli-args.d.ts +3 -1
  19. package/dist/cli-args.js +18 -1
  20. package/dist/cli-args.js.map +1 -1
  21. package/dist/cli.js +9 -1
  22. package/dist/cli.js.map +1 -1
  23. package/dist/config/config-matchers.js +46 -37
  24. package/dist/config/config-matchers.js.map +1 -1
  25. package/dist/deploy.d.ts +18 -2
  26. package/dist/deploy.js +47 -4
  27. package/dist/deploy.js.map +1 -1
  28. package/dist/entries/app-rsc-entry.js +11 -9
  29. package/dist/entries/app-rsc-entry.js.map +1 -1
  30. package/dist/entries/app-rsc-manifest.js +4 -1
  31. package/dist/entries/app-rsc-manifest.js.map +1 -1
  32. package/dist/entries/pages-client-entry.js +3 -2
  33. package/dist/entries/pages-client-entry.js.map +1 -1
  34. package/dist/entries/pages-server-entry.js +21 -62
  35. package/dist/entries/pages-server-entry.js.map +1 -1
  36. package/dist/entries/runtime-entry-module.d.ts +12 -3
  37. package/dist/entries/runtime-entry-module.js +15 -4
  38. package/dist/entries/runtime-entry-module.js.map +1 -1
  39. package/dist/index.js +12 -7
  40. package/dist/index.js.map +1 -1
  41. package/dist/init.d.ts +1 -1
  42. package/dist/init.js +2 -2
  43. package/dist/init.js.map +1 -1
  44. package/dist/plugins/og-assets.js +15 -16
  45. package/dist/plugins/og-assets.js.map +1 -1
  46. package/dist/plugins/rsc-client-shim-excludes.d.ts +2 -1
  47. package/dist/plugins/rsc-client-shim-excludes.js +10 -1
  48. package/dist/plugins/rsc-client-shim-excludes.js.map +1 -1
  49. package/dist/routing/app-route-graph.d.ts +90 -4
  50. package/dist/routing/app-route-graph.js +210 -7
  51. package/dist/routing/app-route-graph.js.map +1 -1
  52. package/dist/routing/app-router.d.ts +15 -3
  53. package/dist/routing/app-router.js +20 -23
  54. package/dist/routing/app-router.js.map +1 -1
  55. package/dist/routing/file-matcher.d.ts +3 -1
  56. package/dist/routing/file-matcher.js +6 -1
  57. package/dist/routing/file-matcher.js.map +1 -1
  58. package/dist/routing/pages-router.js +10 -19
  59. package/dist/routing/pages-router.js.map +1 -1
  60. package/dist/routing/route-matching.d.ts +28 -0
  61. package/dist/routing/route-matching.js +44 -0
  62. package/dist/routing/route-matching.js.map +1 -0
  63. package/dist/routing/route-pattern.js +4 -1
  64. package/dist/routing/route-pattern.js.map +1 -1
  65. package/dist/routing/route-trie.d.ts +8 -0
  66. package/dist/routing/route-trie.js +12 -1
  67. package/dist/routing/route-trie.js.map +1 -1
  68. package/dist/routing/route-validation.js +3 -4
  69. package/dist/routing/route-validation.js.map +1 -1
  70. package/dist/routing/utils.d.ts +8 -1
  71. package/dist/routing/utils.js +25 -2
  72. package/dist/routing/utils.js.map +1 -1
  73. package/dist/server/api-handler.js +2 -8
  74. package/dist/server/api-handler.js.map +1 -1
  75. package/dist/server/app-browser-entry.js +66 -49
  76. package/dist/server/app-browser-entry.js.map +1 -1
  77. package/dist/server/app-browser-navigation-controller.d.ts +7 -5
  78. package/dist/server/app-browser-navigation-controller.js +43 -35
  79. package/dist/server/app-browser-navigation-controller.js.map +1 -1
  80. package/dist/server/app-browser-state.d.ts +33 -15
  81. package/dist/server/app-browser-state.js +52 -59
  82. package/dist/server/app-browser-state.js.map +1 -1
  83. package/dist/server/app-browser-visible-commit.d.ts +68 -0
  84. package/dist/server/app-browser-visible-commit.js +182 -0
  85. package/dist/server/app-browser-visible-commit.js.map +1 -0
  86. package/dist/server/app-client-reference-preloader.d.ts +15 -0
  87. package/dist/server/app-client-reference-preloader.js +46 -0
  88. package/dist/server/app-client-reference-preloader.js.map +1 -0
  89. package/dist/server/app-elements-wire.d.ts +130 -0
  90. package/dist/server/app-elements-wire.js +205 -0
  91. package/dist/server/app-elements-wire.js.map +1 -0
  92. package/dist/server/app-elements.d.ts +2 -84
  93. package/dist/server/app-elements.js +3 -102
  94. package/dist/server/app-elements.js.map +1 -1
  95. package/dist/server/app-fallback-renderer.d.ts +1 -1
  96. package/dist/server/app-middleware.d.ts +2 -1
  97. package/dist/server/app-middleware.js +34 -11
  98. package/dist/server/app-middleware.js.map +1 -1
  99. package/dist/server/app-page-boundary-render.d.ts +1 -1
  100. package/dist/server/app-page-boundary-render.js +8 -5
  101. package/dist/server/app-page-boundary-render.js.map +1 -1
  102. package/dist/server/app-page-boundary.js +2 -1
  103. package/dist/server/app-page-boundary.js.map +1 -1
  104. package/dist/server/app-page-cache.d.ts +1 -0
  105. package/dist/server/app-page-cache.js +8 -13
  106. package/dist/server/app-page-cache.js.map +1 -1
  107. package/dist/server/app-page-dispatch.d.ts +2 -1
  108. package/dist/server/app-page-dispatch.js +18 -10
  109. package/dist/server/app-page-dispatch.js.map +1 -1
  110. package/dist/server/app-page-element-builder.d.ts +1 -1
  111. package/dist/server/app-page-element-builder.js +8 -5
  112. package/dist/server/app-page-element-builder.js.map +1 -1
  113. package/dist/server/app-page-execution.d.ts +23 -5
  114. package/dist/server/app-page-execution.js +39 -24
  115. package/dist/server/app-page-execution.js.map +1 -1
  116. package/dist/server/app-page-head.js +2 -1
  117. package/dist/server/app-page-head.js.map +1 -1
  118. package/dist/server/app-page-method.js +2 -5
  119. package/dist/server/app-page-method.js.map +1 -1
  120. package/dist/server/app-page-probe.d.ts +1 -1
  121. package/dist/server/app-page-probe.js +5 -1
  122. package/dist/server/app-page-probe.js.map +1 -1
  123. package/dist/server/app-page-render.d.ts +1 -1
  124. package/dist/server/app-page-render.js +38 -3
  125. package/dist/server/app-page-render.js.map +1 -1
  126. package/dist/server/app-page-request.d.ts +0 -1
  127. package/dist/server/app-page-request.js +7 -10
  128. package/dist/server/app-page-request.js.map +1 -1
  129. package/dist/server/app-page-response.js +3 -2
  130. package/dist/server/app-page-response.js.map +1 -1
  131. package/dist/server/app-page-route-wiring.d.ts +5 -2
  132. package/dist/server/app-page-route-wiring.js +15 -12
  133. package/dist/server/app-page-route-wiring.js.map +1 -1
  134. package/dist/server/app-page-stream.d.ts +7 -0
  135. package/dist/server/app-page-stream.js +9 -2
  136. package/dist/server/app-page-stream.js.map +1 -1
  137. package/dist/server/app-prerender-endpoints.js +3 -2
  138. package/dist/server/app-prerender-endpoints.js.map +1 -1
  139. package/dist/server/app-route-handler-cache.js +2 -1
  140. package/dist/server/app-route-handler-cache.js.map +1 -1
  141. package/dist/server/app-route-handler-dispatch.js +6 -5
  142. package/dist/server/app-route-handler-dispatch.js.map +1 -1
  143. package/dist/server/app-route-handler-policy.js +13 -13
  144. package/dist/server/app-route-handler-policy.js.map +1 -1
  145. package/dist/server/app-route-handler-response.js +2 -1
  146. package/dist/server/app-route-handler-response.js.map +1 -1
  147. package/dist/server/app-route-handler-runtime.d.ts +9 -1
  148. package/dist/server/app-route-handler-runtime.js +11 -1
  149. package/dist/server/app-route-handler-runtime.js.map +1 -1
  150. package/dist/server/app-router-entry.js +9 -4
  151. package/dist/server/app-router-entry.js.map +1 -1
  152. package/dist/server/app-rsc-cache-busting.d.ts +34 -0
  153. package/dist/server/app-rsc-cache-busting.js +137 -0
  154. package/dist/server/app-rsc-cache-busting.js.map +1 -0
  155. package/dist/server/app-rsc-handler.js +22 -11
  156. package/dist/server/app-rsc-handler.js.map +1 -1
  157. package/dist/server/app-rsc-request-normalization.d.ts +4 -2
  158. package/dist/server/app-rsc-request-normalization.js +10 -6
  159. package/dist/server/app-rsc-request-normalization.js.map +1 -1
  160. package/dist/server/app-rsc-response-finalizer.js +1 -1
  161. package/dist/server/app-rsc-route-matching.js +8 -4
  162. package/dist/server/app-rsc-route-matching.js.map +1 -1
  163. package/dist/server/app-segment-config.js +4 -0
  164. package/dist/server/app-segment-config.js.map +1 -1
  165. package/dist/server/app-server-action-execution.js +43 -51
  166. package/dist/server/app-server-action-execution.js.map +1 -1
  167. package/dist/server/app-ssr-entry.js +21 -20
  168. package/dist/server/app-ssr-entry.js.map +1 -1
  169. package/dist/server/artifact-compatibility.d.ts +44 -0
  170. package/dist/server/artifact-compatibility.js +82 -0
  171. package/dist/server/artifact-compatibility.js.map +1 -0
  172. package/dist/server/cache-proof.d.ts +200 -0
  173. package/dist/server/cache-proof.js +342 -0
  174. package/dist/server/cache-proof.js.map +1 -0
  175. package/dist/server/dev-origin-check.js +8 -4
  176. package/dist/server/dev-origin-check.js.map +1 -1
  177. package/dist/server/dev-server.js +6 -16
  178. package/dist/server/dev-server.js.map +1 -1
  179. package/dist/server/http-error-responses.d.ts +67 -0
  180. package/dist/server/http-error-responses.js +77 -0
  181. package/dist/server/http-error-responses.js.map +1 -0
  182. package/dist/server/image-optimization.js +2 -1
  183. package/dist/server/image-optimization.js.map +1 -1
  184. package/dist/server/metadata-route-response.js +6 -5
  185. package/dist/server/metadata-route-response.js.map +1 -1
  186. package/dist/server/metadata-routes.d.ts +1 -0
  187. package/dist/server/metadata-routes.js +6 -0
  188. package/dist/server/metadata-routes.js.map +1 -1
  189. package/dist/server/middleware-matcher.js +2 -2
  190. package/dist/server/middleware-matcher.js.map +1 -1
  191. package/dist/server/middleware-response-headers.js +21 -0
  192. package/dist/server/middleware-response-headers.js.map +1 -1
  193. package/dist/server/middleware-runtime.js +3 -3
  194. package/dist/server/middleware-runtime.js.map +1 -1
  195. package/dist/server/navigation-trace.d.ts +33 -0
  196. package/dist/server/navigation-trace.js +35 -0
  197. package/dist/server/navigation-trace.js.map +1 -0
  198. package/dist/server/next-error-digest.d.ts +44 -0
  199. package/dist/server/next-error-digest.js +40 -0
  200. package/dist/server/next-error-digest.js.map +1 -0
  201. package/dist/server/pages-api-route.js +4 -7
  202. package/dist/server/pages-api-route.js.map +1 -1
  203. package/dist/server/pages-node-compat.js +4 -16
  204. package/dist/server/pages-node-compat.js.map +1 -1
  205. package/dist/server/pages-page-response.d.ts +2 -8
  206. package/dist/server/pages-page-response.js +44 -14
  207. package/dist/server/pages-page-response.js.map +1 -1
  208. package/dist/server/prod-server.d.ts +6 -0
  209. package/dist/server/prod-server.js +28 -21
  210. package/dist/server/prod-server.js.map +1 -1
  211. package/dist/server/request-pipeline.d.ts +42 -1
  212. package/dist/server/request-pipeline.js +97 -17
  213. package/dist/server/request-pipeline.js.map +1 -1
  214. package/dist/shims/cache-runtime.d.ts +2 -2
  215. package/dist/shims/cache-runtime.js +3 -6
  216. package/dist/shims/cache-runtime.js.map +1 -1
  217. package/dist/shims/cache.js +3 -5
  218. package/dist/shims/cache.js.map +1 -1
  219. package/dist/shims/fetch-cache.js +2 -3
  220. package/dist/shims/fetch-cache.js.map +1 -1
  221. package/dist/shims/head-state.js +2 -3
  222. package/dist/shims/head-state.js.map +1 -1
  223. package/dist/shims/headers.js +4 -44
  224. package/dist/shims/headers.js.map +1 -1
  225. package/dist/shims/i18n-state.js +2 -3
  226. package/dist/shims/i18n-state.js.map +1 -1
  227. package/dist/shims/internal/als-registry.d.ts +15 -0
  228. package/dist/shims/internal/als-registry.js +55 -0
  229. package/dist/shims/internal/als-registry.js.map +1 -0
  230. package/dist/shims/internal/cookie-serialize.d.ts +46 -0
  231. package/dist/shims/internal/cookie-serialize.js +51 -0
  232. package/dist/shims/internal/cookie-serialize.js.map +1 -0
  233. package/dist/shims/link.js +31 -26
  234. package/dist/shims/link.js.map +1 -1
  235. package/dist/shims/metadata.d.ts +26 -1
  236. package/dist/shims/metadata.js +94 -4
  237. package/dist/shims/metadata.js.map +1 -1
  238. package/dist/shims/navigation-state.js +2 -3
  239. package/dist/shims/navigation-state.js.map +1 -1
  240. package/dist/shims/navigation.d.ts +2 -7
  241. package/dist/shims/navigation.js +44 -36
  242. package/dist/shims/navigation.js.map +1 -1
  243. package/dist/shims/request-context.js +2 -4
  244. package/dist/shims/request-context.js.map +1 -1
  245. package/dist/shims/router-state.js +2 -3
  246. package/dist/shims/router-state.js.map +1 -1
  247. package/dist/shims/router.js +2 -2
  248. package/dist/shims/router.js.map +1 -1
  249. package/dist/shims/server.js +5 -30
  250. package/dist/shims/server.js.map +1 -1
  251. package/dist/shims/slot.d.ts +1 -1
  252. package/dist/shims/slot.js +5 -4
  253. package/dist/shims/slot.js.map +1 -1
  254. package/dist/shims/thenable-params.d.ts +5 -2
  255. package/dist/shims/thenable-params.js +26 -6
  256. package/dist/shims/thenable-params.js.map +1 -1
  257. package/dist/shims/unified-request-context.js +2 -14
  258. package/dist/shims/unified-request-context.js.map +1 -1
  259. package/dist/utils/base-path.d.ts +7 -1
  260. package/dist/utils/base-path.js +12 -1
  261. package/dist/utils/base-path.js.map +1 -1
  262. package/dist/utils/query.d.ts +8 -1
  263. package/dist/utils/query.js +12 -1
  264. package/dist/utils/query.js.map +1 -1
  265. package/dist/utils/safe-json-file.d.ts +18 -0
  266. package/dist/utils/safe-json-file.js +25 -0
  267. package/dist/utils/safe-json-file.js.map +1 -0
  268. package/dist/utils/text-stream.d.ts +29 -0
  269. package/dist/utils/text-stream.js +66 -0
  270. package/dist/utils/text-stream.js.map +1 -0
  271. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"app-route-graph.js","names":[],"sources":["../../src/routing/app-route-graph.ts"],"sourcesContent":["/**\n * App Router route graph construction.\n *\n * Scans app/ directories and materializes route metadata before the request-time\n * matcher consumes it. Keep request matching and cache ownership in app-router.ts.\n */\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport { compareRoutes, decodeRouteSegment } from \"./utils.js\";\nimport { scanWithExtensions, type ValidFileMatcher } from \"./file-matcher.js\";\nimport { validateRoutePatterns } from \"./route-validation.js\";\n\nexport type InterceptingRoute = {\n /** The interception convention: \".\" | \"..\" | \"../..\" | \"...\" */\n convention: string;\n /** The URL pattern this intercepts (e.g. \"/photos/:id\") */\n targetPattern: string;\n /** Absolute path to the intercepting page component */\n pagePath: string;\n /** Absolute layout paths inside the intercepting route tree, outermost to innermost */\n layoutPaths: string[];\n /** Parameter names for dynamic segments */\n params: string[];\n};\n\nexport type ParallelSlot = {\n /** Stable slot identity (name + owning directory), used for route serialization keys. */\n key: string;\n /** Slot name (e.g. \"team\" from @team) */\n name: string;\n /** Absolute path to the @slot directory that owns this slot. Internal routing metadata. */\n ownerDir: string;\n /** Absolute path to the slot's page component */\n pagePath: string | null;\n /** Absolute path to the slot's default.tsx fallback */\n defaultPath: string | null;\n /** Absolute path to the slot's layout component (wraps slot content) */\n layoutPath: string | null;\n /** Absolute path to the slot's loading component */\n loadingPath: string | null;\n /** Absolute path to the slot's error component */\n errorPath: string | null;\n /** Intercepting routes within this slot */\n interceptingRoutes: InterceptingRoute[];\n /**\n * The layout index (0-based, in route.layouts[]) that this slot belongs to.\n * Slots are passed as props to the layout at their directory level, not\n * necessarily the innermost layout. -1 means \"innermost\" (legacy default).\n */\n layoutIndex: number;\n /**\n * Filesystem segments from the slot's root directory to its active page.\n * Used at render time to compute segments for useSelectedLayoutSegment(slotName).\n * For a page at the slot root (@team/page.tsx), this is [].\n * For a sub-page (@team/members/page.tsx), this is [\"members\"].\n * null when the slot has no active page (showing default.tsx fallback).\n */\n routeSegments: string[] | null;\n /**\n * Full URL pattern parts for the slot's active page (owner prefix +\n * slot-relative pattern). Set when an inherited slot mirrors a sub-page\n * whose param names may differ from the route's. The runtime matches the\n * request URL against these parts to extract slot-specific params.\n */\n slotPatternParts?: string[];\n /**\n * Param names captured by `slotPatternParts`, in order of appearance.\n * Used at runtime to decide whether to extract slot-specific params or\n * reuse the route's matched params.\n */\n slotParamNames?: string[];\n};\n\nexport type AppRoute = {\n /** URL pattern, e.g. \"/\" or \"/about\" or \"/blog/:slug\" */\n pattern: string;\n /** Absolute file path to the page component */\n pagePath: string | null;\n /** Absolute file path to the route handler (route.ts) */\n routePath: string | null;\n /** Ordered list of layout files from root to leaf */\n layouts: string[];\n /** Ordered list of all discovered template files from root to leaf (not necessarily aligned 1:1 with layouts) */\n templates: string[];\n /** Parallel route slots (from @slot directories at the route's directory level) */\n parallelSlots: ParallelSlot[];\n /** Loading component path */\n loadingPath: string | null;\n /** Error component path (leaf directory only) */\n errorPath: string | null;\n /**\n * Per-layout error boundary paths, aligned with the layouts array.\n * Each entry is the error.tsx at the same directory level as the\n * corresponding layout (or null if that level has no error.tsx).\n * Used to interleave ErrorBoundary components with layouts so that\n * ancestor error boundaries catch errors from descendant segments.\n */\n layoutErrorPaths: (string | null)[];\n /** Not-found component path (nearest, walking up from page dir) */\n notFoundPath: string | null;\n /**\n * Not-found component paths per layout level (aligned with layouts array).\n * Each entry is the not-found.tsx at that layout's directory, or null.\n * Used to create per-layout NotFoundBoundary so that notFound() thrown from\n * a layout is caught by the parent layout's boundary (matching Next.js behavior).\n */\n notFoundPaths: (string | null)[];\n /**\n * Forbidden component paths per layout level (aligned with layouts array).\n * Each entry is the forbidden.tsx at that layout's directory, or null.\n * Used to create per-layout ForbiddenBoundary.\n */\n forbiddenPaths: (string | null)[];\n /** Forbidden component path (403) at the route's directory level */\n forbiddenPath: string | null;\n /** Unauthorized component path (401) at the route's directory level */\n unauthorizedPath: string | null;\n /** Unauthorized component paths per layout level (aligned with layouts array). */\n unauthorizedPaths: (string | null)[];\n /**\n * Filesystem segments from app/ root to the route's directory.\n * Includes route groups and dynamic segments (as template strings like \"[id]\").\n * Used at render time to compute the child segments for useSelectedLayoutSegments().\n */\n routeSegments: string[];\n /** Tree position (directory depth from app/ root) for each template. */\n templateTreePositions?: number[];\n /**\n * Tree position (directory depth from app/ root) for each layout.\n * Used to slice routeSegments and determine which segments are below each layout.\n * For example, root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.\n * Unlike the old layoutSegmentDepths, this counts ALL directory levels including\n * route groups and parallel slots.\n */\n layoutTreePositions: number[];\n /** Whether this is a dynamic route */\n isDynamic: boolean;\n /** Parameter names for dynamic segments */\n params: string[];\n /** Dynamic parameter names captured by the route's root layout. */\n rootParamNames?: string[];\n /** Pre-split pattern segments (computed once at scan time, reused per request) */\n patternParts: string[];\n};\n\nexport async function buildAppRouteGraph(\n appDir: string,\n matcher: ValidFileMatcher,\n): Promise<{ routes: AppRoute[] }> {\n // Find all page.tsx and route.ts files, excluding @slot directories\n // (slot pages are not standalone routes — they're rendered as props of their parent layout)\n // and _private folders (Next.js convention for colocated non-route files).\n const routes: AppRoute[] = [];\n\n const excludeDir = (name: string) => name.startsWith(\"@\") || name.startsWith(\"_\");\n\n // Process page files in a single pass\n // Use function form of exclude for Node < 22.14 compatibility (string arrays require >= 22.14)\n for await (const file of scanWithExtensions(\"**/page\", appDir, matcher.extensions, excludeDir)) {\n const route = fileToAppRoute(file, appDir, \"page\", matcher);\n if (route) routes.push(route);\n }\n\n // Process route handler files (API routes) in a single pass\n for await (const file of scanWithExtensions(\"**/route\", appDir, matcher.extensions, excludeDir)) {\n const route = fileToAppRoute(file, appDir, \"route\", matcher);\n if (route) routes.push(route);\n }\n\n // Layouts with parallel slot pages are valid route entries even when the\n // segment has no children page. Next.js uses this for modal/feed patterns\n // like app/user/[id]/layout + @feed/page + @modal/default.\n const routePatterns = new Set(routes.map((route) => route.pattern));\n for await (const file of scanWithExtensions(\n \"**/layout\",\n appDir,\n matcher.extensions,\n excludeDir,\n )) {\n const dir = path.dirname(file);\n const routeDir = dir === \".\" ? appDir : path.join(appDir, dir);\n if (!hasParallelSlotDirectory(routeDir)) continue;\n if (discoverParallelSlots(routeDir, appDir, matcher).length === 0) continue;\n\n const route = directoryToAppRoute(dir, appDir, matcher, null, null);\n if (!route || routePatterns.has(route.pattern)) continue;\n\n routes.push(route);\n routePatterns.add(route.pattern);\n }\n\n // Discover sub-routes created by nested pages within parallel slots.\n // In Next.js, pages nested inside @slot directories create additional URL routes.\n // For example, @audience/demographics/page.tsx at app/parallel-routes/ creates\n // a route at /parallel-routes/demographics.\n const slotSubRoutes = discoverSlotSubRoutes(routes, matcher);\n routes.push(...slotSubRoutes);\n\n validatePageRouteConflicts(routes, appDir);\n validateRoutePatterns(routes.map((route) => route.pattern));\n const interceptTargetPatterns = [\n ...new Set(\n routes.flatMap((route) =>\n route.parallelSlots.flatMap((slot) =>\n slot.interceptingRoutes.map((intercept) => intercept.targetPattern),\n ),\n ),\n ),\n ];\n validateRoutePatterns(interceptTargetPatterns);\n\n // Sort: static routes first, then dynamic, then catch-all\n routes.sort(compareRoutes);\n\n return { routes };\n}\n\nfunction hasParallelSlotDirectory(dir: string): boolean {\n try {\n return fs\n .readdirSync(dir, { withFileTypes: true })\n .some((entry) => entry.isDirectory() && entry.name.startsWith(\"@\"));\n } catch {\n return false;\n }\n}\n\nfunction validatePageRouteConflicts(routes: AppRoute[], appDir: string): void {\n const byPattern = new Map<string, { pagePath: string | null; routePath: string | null }>();\n\n // validateRoutePatterns() would also reject page/route pairs because they\n // share a URL pattern. Keep this pass first so the error names both files.\n for (const route of routes) {\n const entry = byPattern.get(route.pattern);\n if (!entry) {\n byPattern.set(route.pattern, {\n pagePath: route.pagePath,\n routePath: route.routePath,\n });\n continue;\n }\n\n if (!entry.pagePath && route.pagePath) {\n entry.pagePath = route.pagePath;\n }\n if (!entry.routePath && route.routePath) {\n entry.routePath = route.routePath;\n }\n }\n\n for (const [pattern, entry] of byPattern) {\n if (!entry.pagePath || !entry.routePath) continue;\n\n throw new Error(\n `Conflicting route and page at ${pattern}: route at ${formatAppFilePath(\n entry.routePath,\n appDir,\n )} and page at ${formatAppFilePath(entry.pagePath, appDir)}`,\n );\n }\n}\n\nfunction formatAppFilePath(filePath: string, appDir: string): string {\n const relativePath = path.relative(appDir, filePath).replace(/\\\\/g, \"/\");\n const parsedPath = path.parse(relativePath);\n const withoutExtension = path.join(parsedPath.dir, parsedPath.name).replace(/\\\\/g, \"/\");\n return withoutExtension.startsWith(\"/\") ? withoutExtension : `/${withoutExtension}`;\n}\n\n/**\n * Discover sub-routes created by nested pages within parallel slots.\n *\n * In Next.js, pages nested inside @slot directories create additional URL routes.\n * For example, given:\n * app/parallel-routes/@audience/demographics/page.tsx\n * This creates a route at /parallel-routes/demographics where:\n * - children slot → parent's default.tsx\n * - @audience slot → @audience/demographics/page.tsx (matched)\n * - other slots → their default.tsx (fallback)\n */\nfunction discoverSlotSubRoutes(routes: AppRoute[], matcher: ValidFileMatcher): AppRoute[] {\n const syntheticRoutes: AppRoute[] = [];\n\n // O(1) lookup for existing routes by pattern — avoids O(n) routes.find() per sub-path per parent.\n // Updated as new synthetic routes are pushed so that later parents can see earlier synthetic entries.\n const routesByPattern = new Map<string, AppRoute>(routes.map((r) => [r.pattern, r]));\n\n const applySlotSubPages = (\n route: AppRoute,\n slotPages: Map<string, string>,\n rawSegments: string[],\n ): void => {\n route.parallelSlots = route.parallelSlots.map((slot) => {\n const subPage = slotPages.get(slot.key);\n if (subPage !== undefined) {\n return { ...slot, pagePath: subPage, routeSegments: rawSegments };\n }\n return slot;\n });\n };\n\n for (const parentRoute of routes) {\n if (parentRoute.parallelSlots.length === 0) continue;\n if (!parentRoute.pagePath) continue;\n\n const parentPageDir = path.dirname(parentRoute.pagePath);\n\n // Collect sub-paths from all slots.\n // Map: normalized visible sub-path -> slot pages, raw filesystem segments (for routeSegments),\n // and the pre-computed convertedSubRoute (to avoid a redundant re-conversion in the merge loop).\n const subPathMap = new Map<\n string,\n {\n // Raw filesystem segments (with route groups, @slots, etc.) used for routeSegments so\n // that useSelectedLayoutSegments() sees the correct segment list at runtime.\n rawSegments: string[];\n // Pre-computed URL parts, params, isDynamic from convertSegmentsToRouteParts.\n converted: { urlSegments: string[]; params: string[]; isDynamic: boolean };\n slotPages: Map<string, string>;\n }\n >();\n\n for (const slot of parentRoute.parallelSlots) {\n // Only scan sub-pages from slots owned by this route directory.\n // Inherited slots with the same name live in different owner dirs.\n if (path.dirname(slot.ownerDir) !== parentPageDir) {\n continue;\n }\n const slotDir = slot.ownerDir;\n if (!fs.existsSync(slotDir)) continue;\n\n const subPages = findSlotSubPages(slotDir, matcher);\n for (const { relativePath, pagePath } of subPages) {\n const subSegments = relativePath.split(path.sep);\n const convertedSubRoute = convertSegmentsToRouteParts(subSegments);\n if (!convertedSubRoute) continue;\n\n const { urlSegments } = convertedSubRoute;\n const normalizedSubPath = urlSegments.join(\"/\");\n let subPathEntry = subPathMap.get(normalizedSubPath);\n\n if (!subPathEntry) {\n subPathEntry = {\n rawSegments: subSegments,\n converted: convertedSubRoute,\n slotPages: new Map(),\n };\n subPathMap.set(normalizedSubPath, subPathEntry);\n }\n\n const existingSlotPage = subPathEntry.slotPages.get(slot.key);\n if (existingSlotPage) {\n const pattern = joinRoutePattern(parentRoute.pattern, normalizedSubPath);\n throw new Error(\n `You cannot have two routes that resolve to the same path (\"${pattern}\").`,\n );\n }\n\n subPathEntry.slotPages.set(slot.key, pagePath);\n }\n }\n\n if (subPathMap.size === 0) continue;\n\n // Find the default.tsx for the children slot at the parent directory\n const childrenDefault = findFile(parentPageDir, \"default\", matcher);\n if (!childrenDefault) continue;\n\n for (const { rawSegments, converted: convertedSubRoute, slotPages } of subPathMap.values()) {\n const {\n urlSegments: urlParts,\n params: subParams,\n isDynamic: subIsDynamic,\n } = convertedSubRoute;\n\n const subUrlPath = urlParts.join(\"/\");\n const pattern = joinRoutePattern(parentRoute.pattern, subUrlPath);\n\n const existingRoute = routesByPattern.get(pattern);\n if (existingRoute) {\n if (existingRoute.routePath && !existingRoute.pagePath) {\n throw new Error(\n `You cannot have two routes that resolve to the same path (\"${pattern}\").`,\n );\n }\n applySlotSubPages(existingRoute, slotPages, rawSegments);\n continue;\n }\n\n // Build parallel slots for this sub-route: matching slots get the sub-page,\n // non-matching slots get null pagePath (rendering falls back to defaultPath)\n const subSlots: ParallelSlot[] = parentRoute.parallelSlots.map((slot) => {\n const subPage = slotPages.get(slot.key);\n return {\n ...slot,\n pagePath: subPage || null,\n routeSegments: subPage ? rawSegments : null,\n };\n });\n\n const newRoute: AppRoute = {\n pattern,\n pagePath: childrenDefault, // children slot uses parent's default.tsx as page\n routePath: null,\n layouts: parentRoute.layouts,\n templates: parentRoute.templates,\n parallelSlots: subSlots,\n loadingPath: parentRoute.loadingPath,\n errorPath: parentRoute.errorPath,\n layoutErrorPaths: parentRoute.layoutErrorPaths,\n notFoundPath: parentRoute.notFoundPath,\n notFoundPaths: parentRoute.notFoundPaths,\n forbiddenPaths: parentRoute.forbiddenPaths,\n forbiddenPath: parentRoute.forbiddenPath,\n unauthorizedPath: parentRoute.unauthorizedPath,\n unauthorizedPaths: parentRoute.unauthorizedPaths,\n routeSegments: [...parentRoute.routeSegments, ...rawSegments],\n templateTreePositions: parentRoute.templateTreePositions,\n layoutTreePositions: parentRoute.layoutTreePositions,\n isDynamic: parentRoute.isDynamic || subIsDynamic,\n params: [...parentRoute.params, ...subParams],\n rootParamNames: parentRoute.rootParamNames,\n patternParts: [...parentRoute.patternParts, ...urlParts],\n };\n syntheticRoutes.push(newRoute);\n routesByPattern.set(pattern, newRoute);\n }\n }\n\n return syntheticRoutes;\n}\n\n/**\n * Find all page files in subdirectories of a parallel slot directory.\n * Returns relative paths (from the slot dir) and absolute page paths.\n * Skips the root page.tsx (already handled as the slot's main page)\n * and intercepting route directories.\n */\ntype SlotSubPageEntry = { relativePath: string; pagePath: string };\n\n// Per-build memo: a slot directory's sub-pages depend only on the directory\n// contents and the matcher's accepted extensions. Inherited slots get scanned\n// once per descendant route, so without memoization a route N segments deep\n// pays O(N) full subtree walks for every shared ancestor slot.\n//\n// Keyed by matcher (one matcher per build) so the cache is naturally scoped\n// to a single build run and gets collected when the build finishes — no\n// cross-build pollution in long-lived dev servers.\nconst findSlotSubPagesCache = new WeakMap<ValidFileMatcher, Map<string, SlotSubPageEntry[]>>();\n\nfunction findSlotSubPages(slotDir: string, matcher: ValidFileMatcher): SlotSubPageEntry[] {\n let perMatcher = findSlotSubPagesCache.get(matcher);\n if (!perMatcher) {\n perMatcher = new Map();\n findSlotSubPagesCache.set(matcher, perMatcher);\n }\n const cached = perMatcher.get(slotDir);\n if (cached) return cached;\n\n const results: SlotSubPageEntry[] = [];\n\n function scan(dir: string): void {\n if (!fs.existsSync(dir)) return;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n // Skip intercepting route directories\n if (matchInterceptConvention(entry.name)) continue;\n // Skip private folders (prefixed with _)\n if (entry.name.startsWith(\"_\")) continue;\n\n const subDir = path.join(dir, entry.name);\n const page = findFile(subDir, \"page\", matcher);\n if (page) {\n const relativePath = path.relative(slotDir, subDir);\n results.push({ relativePath, pagePath: page });\n }\n // Continue scanning deeper for nested sub-pages\n scan(subDir);\n }\n }\n\n scan(slotDir);\n perMatcher.set(slotDir, results);\n return results;\n}\n\n/**\n * Convert a file path relative to app/ into an AppRoute.\n */\nfunction fileToAppRoute(\n file: string,\n appDir: string,\n type: \"page\" | \"route\",\n matcher: ValidFileMatcher,\n): AppRoute | null {\n // Remove the filename (page.tsx or route.ts)\n const dir = path.dirname(file);\n return directoryToAppRoute(\n dir,\n appDir,\n matcher,\n type === \"page\" ? path.join(appDir, file) : null,\n type === \"route\" ? path.join(appDir, file) : null,\n );\n}\n\nfunction directoryToAppRoute(\n dir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n pagePath: string | null,\n routePath: string | null,\n): AppRoute | null {\n const segments = dir === \".\" ? [] : dir.split(path.sep);\n\n const params: string[] = [];\n let isDynamic = false;\n\n const convertedRoute = convertSegmentsToRouteParts(segments);\n if (!convertedRoute) return null;\n\n const { urlSegments, params: routeParams, isDynamic: routeIsDynamic } = convertedRoute;\n params.push(...routeParams);\n isDynamic = routeIsDynamic;\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n\n // Discover layouts and templates from root to leaf\n const layouts = discoverLayouts(segments, appDir, matcher);\n const templates = discoverTemplates(segments, appDir, matcher);\n const templateTreePositions = computeLayoutTreePositions(appDir, templates);\n\n // Compute the tree position (directory depth) for each layout.\n const layoutTreePositions = computeLayoutTreePositions(appDir, layouts);\n\n // Discover per-layout error boundaries (aligned with layouts array).\n // In Next.js, each segment independently wraps its children with an ErrorBoundary.\n // This array enables interleaving error boundaries with layouts in the rendering.\n const layoutErrorPaths = discoverLayoutAlignedErrors(segments, appDir, matcher);\n\n // Discover loading, error in the route's directory\n const routeDir = dir === \".\" ? appDir : path.join(appDir, dir);\n const loadingPath = findFile(routeDir, \"loading\", matcher);\n const errorPath = findFile(routeDir, \"error\", matcher);\n\n // Discover not-found/forbidden/unauthorized: walk from route directory up to root (nearest wins).\n const notFoundPath = discoverBoundaryFile(segments, appDir, \"not-found\", matcher);\n const forbiddenPath = discoverBoundaryFile(segments, appDir, \"forbidden\", matcher);\n const unauthorizedPath = discoverBoundaryFile(segments, appDir, \"unauthorized\", matcher);\n\n // Discover per-layout not-found files (one per layout directory).\n // These are used for per-layout NotFoundBoundary to match Next.js behavior where\n // notFound() thrown from a layout is caught by the parent layout's boundary.\n const notFoundPaths = discoverBoundaryFilePerLayout(layouts, \"not-found\", matcher);\n const forbiddenPaths = discoverBoundaryFilePerLayout(layouts, \"forbidden\", matcher);\n const unauthorizedPaths = discoverBoundaryFilePerLayout(layouts, \"unauthorized\", matcher);\n\n // Discover parallel slots (@team, @analytics, etc.).\n // Slots at the route's own directory use page.tsx; slots at ancestor directories\n // (inherited from parent layouts) use default.tsx as fallback.\n const parallelSlots = discoverInheritedParallelSlots(segments, appDir, routeDir, matcher);\n\n return {\n pattern: pattern === \"/\" ? \"/\" : pattern,\n pagePath,\n routePath,\n layouts,\n templates,\n parallelSlots,\n loadingPath,\n errorPath,\n layoutErrorPaths,\n notFoundPath,\n notFoundPaths,\n forbiddenPaths,\n forbiddenPath,\n unauthorizedPath,\n unauthorizedPaths,\n routeSegments: segments,\n templateTreePositions,\n layoutTreePositions,\n isDynamic,\n params,\n rootParamNames: computeRootParamNames(segments, layoutTreePositions),\n patternParts: urlSegments,\n };\n}\n\nfunction dynamicParamNameFromSegment(segment: string): string | null {\n if (segment.startsWith(\"[[...\") && segment.endsWith(\"]]\")) return segment.slice(5, -2);\n if (segment.startsWith(\"[...\") && segment.endsWith(\"]\")) return segment.slice(4, -1);\n if (segment.startsWith(\"[\") && segment.endsWith(\"]\")) return segment.slice(1, -1);\n return null;\n}\n\nexport function computeRootParamNames(\n routeSegments: readonly string[],\n layoutTreePositions: readonly number[],\n): string[] {\n const rootLayoutPosition = layoutTreePositions[0];\n if (rootLayoutPosition == null || rootLayoutPosition <= 0) return [];\n\n const names: string[] = [];\n for (const segment of routeSegments.slice(0, rootLayoutPosition)) {\n const name = dynamicParamNameFromSegment(segment);\n if (name && !names.includes(name)) names.push(name);\n }\n return names;\n}\n\n/**\n * Compute the tree position (directory depth from app root) for each layout.\n * Root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.\n * Counts ALL directory levels including route groups and parallel slots.\n */\nfunction computeLayoutTreePositions(appDir: string, layouts: string[]): number[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n if (layoutDir === appDir) return 0;\n const relative = path.relative(appDir, layoutDir);\n return relative.split(path.sep).length;\n });\n}\n\n/**\n * Discover all layout files from root to the given directory.\n * Each level of the directory tree may have a layout.tsx.\n */\nfunction discoverLayouts(segments: string[], appDir: string, matcher: ValidFileMatcher): string[] {\n const layouts: string[] = [];\n\n // Check root layout\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) layouts.push(rootLayout);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) layouts.push(layout);\n }\n\n return layouts;\n}\n\n/**\n * Discover all template files from root to the given directory.\n * Each level of the directory tree may have a template.tsx.\n * Templates are like layouts but re-mount on navigation.\n */\nfunction discoverTemplates(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): string[] {\n const templates: string[] = [];\n\n // Check root template\n const rootTemplate = findFile(appDir, \"template\", matcher);\n if (rootTemplate) templates.push(rootTemplate);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const template = findFile(currentDir, \"template\", matcher);\n if (template) templates.push(template);\n }\n\n return templates;\n}\n\n/**\n * Discover error.tsx files aligned with the layouts array.\n * Walks the same directory levels as discoverLayouts and, for each level\n * that contributes a layout entry, checks whether error.tsx also exists.\n * Returns an array of the same length as discoverLayouts() would return,\n * with the error path (or null) at each corresponding layout level.\n *\n * This enables interleaving ErrorBoundary components with layouts in the\n * rendering tree, matching Next.js behavior where each segment independently\n * wraps its children with an error boundary.\n */\nfunction discoverLayoutAlignedErrors(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n const errors: (string | null)[] = [];\n\n // Root level (only if root has a layout — matching discoverLayouts logic)\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) {\n errors.push(findFile(appDir, \"error\", matcher));\n }\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) {\n errors.push(findFile(currentDir, \"error\", matcher));\n }\n }\n\n return errors;\n}\n\n/**\n * Discover the nearest boundary file (not-found, forbidden, unauthorized)\n * by walking from the route's directory up to the app root.\n * Returns the first (closest) file found, or null.\n */\nfunction discoverBoundaryFile(\n segments: string[],\n appDir: string,\n fileName: string,\n matcher: ValidFileMatcher,\n): string | null {\n // Build all directory paths from leaf to root\n const dirs: string[] = [];\n let dir = appDir;\n dirs.push(dir);\n for (const segment of segments) {\n dir = path.join(dir, segment);\n dirs.push(dir);\n }\n\n // Walk from leaf (last) to root (first)\n for (let i = dirs.length - 1; i >= 0; i--) {\n const f = findFile(dirs[i], fileName, matcher);\n if (f) return f;\n }\n return null;\n}\n\n/**\n * Discover boundary files (not-found, forbidden, unauthorized) at each layout directory.\n * Returns an array aligned with the layouts array, where each entry is the boundary\n * file at that layout's directory, or null if none exists there.\n *\n * This is used for per-layout error boundaries. In Next.js, each layout level\n * has its own boundary that wraps the layout's children. When notFound() is thrown\n * from a layout, it propagates up to the parent layout's boundary.\n */\nfunction discoverBoundaryFilePerLayout(\n layouts: string[],\n fileName: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n return findFile(layoutDir, fileName, matcher);\n });\n}\n\n/**\n * Discover parallel slots inherited from ancestor directories.\n *\n * In Next.js, parallel slots belong to the layout that defines them. When a\n * child route is rendered, its parent layout's slots must still be present.\n * If the child doesn't have matching content in a slot, the slot's default.tsx\n * is rendered instead.\n *\n * Walk from appDir through each segment to the route's directory. At each level\n * that has @slot dirs, collect them. Slots at the route's own directory level\n * use page.tsx; slots at ancestor levels use default.tsx only.\n */\nfunction discoverInheritedParallelSlots(\n segments: string[],\n appDir: string,\n routeDir: string,\n matcher: ValidFileMatcher,\n): ParallelSlot[] {\n const slotMap = new Map<string, ParallelSlot>();\n\n // Walk from appDir through each segment, tracking layout indices.\n // layoutIndex tracks which position in the route's layouts[] array corresponds\n // to a given directory. Only directories with a layout.tsx file increment.\n // segmentIndex aligns each entry with `segments`: dirsToCheck[i] is reached\n // after consuming segments[0..i-1], so segments.slice(i) are the segments\n // below this directory (used to mirror inherited slot sub-pages).\n let currentDir = appDir;\n const dirsToCheck: { dir: string; layoutIdx: number; segmentIndex: number }[] = [];\n let layoutIdx = findFile(appDir, \"layout\", matcher) ? 0 : -1;\n dirsToCheck.push({ dir: appDir, layoutIdx, segmentIndex: 0 });\n\n for (let i = 0; i < segments.length; i++) {\n currentDir = path.join(currentDir, segments[i]);\n if (findFile(currentDir, \"layout\", matcher)) {\n layoutIdx++;\n }\n dirsToCheck.push({ dir: currentDir, layoutIdx, segmentIndex: i + 1 });\n }\n\n const routeHasLayout = layoutIdx >= 0;\n\n for (const { dir, layoutIdx: lvlLayoutIdx, segmentIndex } of dirsToCheck) {\n // Once a route has a root layout below app/, slots discovered before that\n // layout are above the root and cannot be owned by any layout in this route.\n // Layout-less routes keep their legacy slot metadata here; validation is separate.\n if (lvlLayoutIdx < 0 && routeHasLayout) continue;\n\n const isOwnDir = dir === routeDir;\n const slotLayoutIdx = Math.max(lvlLayoutIdx, 0);\n const slotsAtLevel = discoverParallelSlots(dir, appDir, matcher);\n const segmentsBelow = segments.slice(segmentIndex);\n\n for (const slot of slotsAtLevel) {\n if (isOwnDir) {\n // At the route's own directory: use page.tsx (normal behavior)\n slot.layoutIndex = slotLayoutIdx;\n slotMap.set(slot.key, slot);\n } else {\n // At an ancestor directory: the slot's own page.tsx belongs to the\n // parent route. Look for a mirrored sub-page at @slot/<segments-below>\n // (e.g. @breadcrumbs/about/page.tsx for /about), falling back to\n // default.tsx when no mirror exists. The mirror search also accepts\n // pattern-compatible matches (e.g. slot's [name] for route's [id]) so\n // the runtime can extract slot-specific params via slotPatternParts.\n const mirror = findMirroredSlotPage(slot.ownerDir, segmentsBelow, matcher);\n let slotPatternParts: string[] | undefined;\n let slotParamNames: string[] | undefined;\n if (mirror) {\n const ownerSegments = segments.slice(0, segmentIndex);\n const ownerUrl = convertSegmentsToRouteParts([...ownerSegments]);\n slotPatternParts = [...(ownerUrl?.urlSegments ?? []), ...mirror.slotUrlSegments];\n slotParamNames = [...(ownerUrl?.params ?? []), ...mirror.slotParamNames];\n }\n const inheritedSlot: ParallelSlot = {\n ...slot,\n pagePath: mirror?.pagePath ?? null,\n layoutIndex: slotLayoutIdx,\n routeSegments: mirror?.segments ?? null,\n slotPatternParts,\n slotParamNames,\n // defaultPath, loadingPath, errorPath, interceptingRoutes remain\n };\n slotMap.set(slot.key, inheritedSlot);\n }\n }\n }\n\n return Array.from(slotMap.values());\n}\n\n/**\n * Look for a page file inside a parallel slot directory that mirrors the\n * route's path below the slot's owner. The match falls through two tiers:\n * 1. Literal filesystem path — fast path when route and slot share shape.\n * 2. Scored pattern compatibility — enumerate sub-pages, accept those\n * whose URL pattern can match the route's URL space (slot dynamic\n * markers may have different names than the route's, and slot\n * catch-alls may subsume the route), and pick the most-specific via\n * `scoreSlotPattern`. Exact URL-parts equality (e.g. through route\n * groups appearing on only one side, like `(marketing)/about` ↔\n * `@breadcrumbs/about`) naturally wins because all literal segments\n * score highest.\n *\n * Returns the slot sub-page's absolute path, its raw filesystem segments\n * (for `routeSegments`), and its URL parts / param names (for\n * `slotPatternParts` / `slotParamNames`). Returns null when no mirror matches.\n */\nfunction findMirroredSlotPage(\n slotDir: string,\n segmentsBelow: readonly string[],\n matcher: ValidFileMatcher,\n): {\n pagePath: string;\n segments: string[];\n slotUrlSegments: string[];\n slotParamNames: string[];\n} | null {\n if (segmentsBelow.length === 0) return null;\n\n // Convert once: both tiers need the URL form of the route's segments below\n // this directory.\n const routeUrl = convertSegmentsToRouteParts([...segmentsBelow]);\n\n // Tier 1: literal filesystem match.\n const literalDir = path.join(slotDir, ...segmentsBelow);\n const literalPage = findFile(literalDir, \"page\", matcher);\n if (literalPage) {\n return {\n pagePath: literalPage,\n segments: [...segmentsBelow],\n slotUrlSegments: routeUrl?.urlSegments ?? [],\n slotParamNames: routeUrl?.params ?? [],\n };\n }\n\n if (!routeUrl || routeUrl.urlSegments.length === 0) return null;\n\n // Tier 2: enumerate slot sub-pages and pick the most-specific compatible\n // pattern. Exact URL-parts matches naturally win the score.\n type Candidate = {\n pagePath: string;\n segments: string[];\n slotUrlSegments: string[];\n slotParamNames: string[];\n score: number;\n };\n let best: Candidate | null = null;\n for (const { relativePath, pagePath } of findSlotSubPages(slotDir, matcher)) {\n const slotSegments = relativePath.split(path.sep);\n const slotUrl = convertSegmentsToRouteParts(slotSegments);\n if (!slotUrl) continue;\n if (!patternsCompatible(slotUrl.urlSegments, routeUrl.urlSegments)) continue;\n const score = scoreSlotPattern(slotUrl.urlSegments);\n if (!best || score > best.score) {\n best = {\n pagePath,\n segments: slotSegments,\n slotUrlSegments: slotUrl.urlSegments,\n slotParamNames: slotUrl.params,\n score,\n };\n }\n }\n\n return best;\n}\n\n/**\n * Whether a slot pattern can match the same URL space as the route's URL\n * parts (where the route's parts are themselves a pattern, since a route\n * file like `[id]/page.tsx` produces `:id`).\n *\n * - `:name+` (catch-all) consumes one-or-more remaining segments.\n * - `:name*` (optional catch-all) consumes zero-or-more.\n * - `:name` (single dynamic) consumes exactly one segment, matching any\n * route segment (literal or dynamic).\n * - Literal slot segments must equal the route's segment exactly; a literal\n * slot segment paired with a dynamic route segment is rejected because we\n * can't know statically whether the runtime value will equal the literal.\n * This also means a literal slot sub-page never matches a catch-all route\n * (e.g. slot `about/page.tsx` is not bound to a route `[...slug]`) — the\n * catch-all might or might not resolve to \"about\" at request time.\n */\nfunction patternsCompatible(slotParts: readonly string[], routeParts: readonly string[]): boolean {\n let i = 0;\n let j = 0;\n while (i < slotParts.length) {\n const sp = slotParts[i];\n if (sp.endsWith(\"+\")) return j < routeParts.length;\n if (sp.endsWith(\"*\")) return true;\n if (j >= routeParts.length) return false;\n const rp = routeParts[j];\n if (sp.startsWith(\":\")) {\n i++;\n j++;\n continue;\n }\n if (rp.startsWith(\":\")) return false;\n if (sp !== rp) return false;\n i++;\n j++;\n }\n return j === routeParts.length;\n}\n\n/**\n * Score a slot pattern by specificity so the most-specific match wins:\n * literal > single dynamic > catch-all > optional catch-all.\n *\n * Required catch-all (`:name+`, ≥1 segment) is more constrained than the\n * optional variant (`:name*`, ≥0 segments), so it scores higher.\n */\nfunction scoreSlotPattern(urlSegments: readonly string[]): number {\n let score = 0;\n for (const seg of urlSegments) {\n if (seg.endsWith(\"*\")) score += 1;\n else if (seg.endsWith(\"+\")) score += 2;\n else if (seg.startsWith(\":\")) score += 3;\n else score += 4;\n }\n return score;\n}\n\n/**\n * Discover parallel route slots (@team, @analytics, etc.) in a directory.\n * Returns a ParallelSlot for each @-prefixed subdirectory that has a page or default component.\n */\nfunction discoverParallelSlots(\n dir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n): ParallelSlot[] {\n if (!fs.existsSync(dir)) return [];\n\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n const slots: ParallelSlot[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n\n const slotName = entry.name.slice(1); // \"@team\" -> \"team\"\n const slotDir = path.join(dir, entry.name);\n\n const pagePath = findFile(slotDir, \"page\", matcher);\n const defaultPath = findFile(slotDir, \"default\", matcher);\n const interceptingRoutes = discoverInterceptingRoutes(slotDir, dir, appDir, matcher);\n\n // Only include slots that have at least a page, default, or intercepting route\n if (!pagePath && !defaultPath && interceptingRoutes.length === 0) continue;\n\n slots.push({\n key: `${slotName}@${path.relative(appDir, slotDir).replace(/\\\\/g, \"/\")}`,\n name: slotName,\n ownerDir: slotDir,\n pagePath,\n defaultPath,\n layoutPath: findFile(slotDir, \"layout\", matcher),\n loadingPath: findFile(slotDir, \"loading\", matcher),\n errorPath: findFile(slotDir, \"error\", matcher),\n interceptingRoutes,\n layoutIndex: -1, // Will be set by discoverInheritedParallelSlots\n routeSegments: pagePath ? [] : null,\n });\n }\n\n return slots;\n}\n\n/**\n * The interception convention prefix patterns.\n * (.) — same level, (..) — one level up, (..)(..)\" — two levels up, (...) — root\n */\nconst INTERCEPT_PATTERNS = [\n { prefix: \"(...)\", convention: \"...\" },\n { prefix: \"(..)(..)\", convention: \"../..\" },\n { prefix: \"(..)\", convention: \"..\" },\n { prefix: \"(.)\", convention: \".\" },\n] as const;\n\n/**\n * Discover intercepting routes inside a parallel slot directory.\n *\n * Intercepting routes use conventions like (.)photo, (..)feed, (...), etc.\n * They intercept navigation to another route and render within the slot instead.\n *\n * @param slotDir - The parallel slot directory (e.g. app/feed/@modal)\n * @param routeDir - The directory of the route that owns this slot (e.g. app/feed)\n * @param appDir - The root app directory\n */\nfunction discoverInterceptingRoutes(\n slotDir: string,\n routeDir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n): InterceptingRoute[] {\n if (!fs.existsSync(slotDir)) return [];\n\n const results: InterceptingRoute[] = [];\n\n // Recursively scan for page files inside intercepting directories\n scanForInterceptingPages(slotDir, routeDir, appDir, results, matcher);\n\n return results;\n}\n\n/**\n * Recursively scan a directory tree for page.tsx files that are inside\n * intercepting route directories.\n */\nfunction scanForInterceptingPages(\n currentDir: string,\n routeDir: string,\n appDir: string,\n results: InterceptingRoute[],\n matcher: ValidFileMatcher,\n): void {\n if (!fs.existsSync(currentDir)) return;\n\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n // Skip private folders (prefixed with _)\n if (entry.name.startsWith(\"_\")) continue;\n\n // Check if this directory name starts with an interception convention\n const interceptMatch = matchInterceptConvention(entry.name);\n\n if (interceptMatch) {\n // This directory is the start of an intercepting route\n // e.g. \"(.)photos\" means intercept same-level \"photos\" route\n const restOfName = entry.name.slice(interceptMatch.prefix.length);\n const interceptDir = path.join(currentDir, entry.name);\n\n // Find page files within this intercepting directory tree\n collectInterceptingPages(\n interceptDir,\n interceptDir,\n interceptMatch.convention,\n restOfName,\n routeDir,\n appDir,\n results,\n matcher,\n );\n } else {\n // Regular subdirectory — keep scanning for intercepting dirs\n scanForInterceptingPages(\n path.join(currentDir, entry.name),\n routeDir,\n appDir,\n results,\n matcher,\n );\n }\n }\n}\n\n/**\n * Match a directory name against interception convention prefixes.\n */\nfunction matchInterceptConvention(name: string): { prefix: string; convention: string } | null {\n for (const pattern of INTERCEPT_PATTERNS) {\n if (name.startsWith(pattern.prefix)) {\n return pattern;\n }\n }\n return null;\n}\n\n/**\n * Collect page.tsx files inside an intercepting route directory tree\n * and compute their target URL patterns.\n */\nfunction collectInterceptingPages(\n currentDir: string,\n interceptRoot: string,\n convention: string,\n interceptSegment: string,\n routeDir: string,\n appDir: string,\n results: InterceptingRoute[],\n matcher: ValidFileMatcher,\n parentLayoutPaths: readonly string[] = [],\n): void {\n const currentLayoutPath = findFile(currentDir, \"layout\", matcher);\n const layoutPaths = currentLayoutPath\n ? [...parentLayoutPaths, currentLayoutPath]\n : parentLayoutPaths;\n\n // Check for page.tsx in current directory\n const page = findFile(currentDir, \"page\", matcher);\n if (page) {\n const targetPattern = computeInterceptTarget(\n convention,\n interceptSegment,\n currentDir,\n interceptRoot,\n routeDir,\n appDir,\n );\n if (targetPattern) {\n results.push({\n convention,\n layoutPaths: [...layoutPaths],\n targetPattern: targetPattern.pattern,\n pagePath: page,\n params: targetPattern.params,\n });\n }\n }\n\n // Recurse into subdirectories for nested intercepting routes\n if (!fs.existsSync(currentDir)) return;\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n // Skip private folders (prefixed with _)\n if (entry.name.startsWith(\"_\")) continue;\n collectInterceptingPages(\n path.join(currentDir, entry.name),\n interceptRoot,\n convention,\n interceptSegment,\n routeDir,\n appDir,\n results,\n matcher,\n layoutPaths,\n );\n }\n}\n\n/**\n * Check whether a path segment is invisible in the URL (route groups, parallel slots, \".\").\n *\n * Used by computeInterceptTarget, convertSegmentsToRouteParts, and\n * hasRemainingVisibleSegments — keep this the single source of truth.\n */\nfunction isInvisibleSegment(segment: string): boolean {\n if (segment === \".\") return true;\n if (segment.startsWith(\"(\") && segment.endsWith(\")\")) return true;\n if (segment.startsWith(\"@\")) return true;\n return false;\n}\n\n/**\n * Compute the target URL pattern for an intercepting route.\n *\n * Interception conventions (..), (..)(..)\" climb by *visible route segments*\n * (not filesystem directories). Route groups like (marketing) and parallel\n * slots like @modal are invisible and must be skipped when counting levels.\n *\n * - (.) same level: resolve relative to routeDir\n * - (..) one level up: climb 1 visible segment\n * - (..)(..) two levels up: climb 2 visible segments\n * - (...) root: resolve from appDir\n */\nfunction computeInterceptTarget(\n convention: string,\n interceptSegment: string,\n currentDir: string,\n interceptRoot: string,\n routeDir: string,\n appDir: string,\n): { pattern: string; params: string[] } | null {\n // Determine the base segments for target resolution.\n // We work on route segments (not filesystem paths) so that route groups\n // and parallel slots are properly skipped when climbing.\n const routeSegments = path.relative(appDir, routeDir).split(path.sep).filter(Boolean);\n\n let baseParts: string[];\n switch (convention) {\n case \".\":\n baseParts = routeSegments;\n break;\n case \"..\":\n case \"../..\": {\n const levelsToClimb = convention === \"..\" ? 1 : 2;\n let climbed = 0;\n let cutIndex = routeSegments.length;\n while (cutIndex > 0 && climbed < levelsToClimb) {\n cutIndex--;\n if (!isInvisibleSegment(routeSegments[cutIndex])) {\n climbed++;\n }\n }\n if (climbed < levelsToClimb) {\n const interceptionRoute = formatInterceptionRoutePath(\n routeSegments,\n convention,\n interceptSegment,\n path.relative(interceptRoot, currentDir).split(path.sep).filter(Boolean),\n );\n if (convention === \"..\") {\n throw new Error(\n `Invalid interception route: ${interceptionRoute}. Cannot use (..) marker at the root level, use (.) instead.`,\n );\n }\n throw new Error(\n `Invalid interception route: ${interceptionRoute}. Cannot use (..)(..) marker at the root level or one level up.`,\n );\n }\n baseParts = routeSegments.slice(0, cutIndex);\n break;\n }\n case \"...\":\n baseParts = [];\n break;\n default:\n return null;\n }\n\n // Add the intercept segment and any nested path segments\n const nestedParts = path.relative(interceptRoot, currentDir).split(path.sep).filter(Boolean);\n const allSegments = [...baseParts, interceptSegment, ...nestedParts];\n\n const convertedTarget = convertSegmentsToRouteParts(allSegments);\n if (!convertedTarget) return null;\n\n const { urlSegments, params } = convertedTarget;\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n return { pattern: pattern === \"/\" ? \"/\" : pattern, params };\n}\n\nfunction formatInterceptionRoutePath(\n routeSegments: string[],\n convention: string,\n interceptSegment: string,\n nestedParts: string[],\n): string {\n const marker = markerForInterceptionConvention(convention);\n const convertedRoute = convertSegmentsToRouteParts(routeSegments);\n const prefix = convertedRoute\n ? convertedRoute.urlSegments\n : routeSegments.filter((segment) => !isInvisibleSegment(segment));\n const routePath = [...prefix, `${marker}${interceptSegment}`, ...nestedParts]\n .filter(Boolean)\n .join(\"/\");\n return routePath ? `/${routePath}` : \"/\";\n}\n\nfunction markerForInterceptionConvention(convention: string): string {\n switch (convention) {\n case \".\":\n return \"(.)\";\n case \"..\":\n return \"(..)\";\n case \"../..\":\n return \"(..)(..)\";\n case \"...\":\n return \"(...)\";\n default:\n return \"\";\n }\n}\n\n/**\n * Find a file by name (without extension) in a directory.\n * Checks configured pageExtensions.\n */\nfunction findFile(dir: string, name: string, matcher: ValidFileMatcher): string | null {\n for (const ext of matcher.dottedExtensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\n}\n\n/**\n * Convert filesystem path segments to URL route parts, skipping invisible segments\n * (route groups, @slots, \".\") and converting dynamic segment syntax to Express-style\n * patterns (e.g. \"[id]\" → \":id\", \"[...slug]\" → \":slug+\").\n */\nfunction convertSegmentsToRouteParts(\n segments: string[],\n): { urlSegments: string[]; params: string[]; isDynamic: boolean } | null {\n const urlSegments: string[] = [];\n const params: string[] = [];\n let isDynamic = false;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n\n if (isInvisibleSegment(segment)) continue;\n\n // Catch-all segments are only valid in terminal URL position.\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n if (hasRemainingVisibleSegments(segments, i + 1)) return null;\n isDynamic = true;\n params.push(catchAllMatch[1]);\n urlSegments.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n if (hasRemainingVisibleSegments(segments, i + 1)) return null;\n isDynamic = true;\n params.push(optionalCatchAllMatch[1]);\n urlSegments.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n\n const dynamicMatch = segment.match(/^\\[([\\w-]+)\\]$/);\n if (dynamicMatch) {\n isDynamic = true;\n params.push(dynamicMatch[1]);\n urlSegments.push(`:${dynamicMatch[1]}`);\n continue;\n }\n\n urlSegments.push(decodeRouteSegment(segment));\n }\n\n return { urlSegments, params, isDynamic };\n}\n\nfunction hasRemainingVisibleSegments(segments: string[], startIndex: number): boolean {\n for (let i = startIndex; i < segments.length; i++) {\n if (!isInvisibleSegment(segments[i])) return true;\n }\n return false;\n}\n\nfunction joinRoutePattern(basePattern: string, subPath: string): string {\n if (!subPath) return basePattern;\n return basePattern === \"/\" ? `/${subPath}` : `${basePattern}/${subPath}`;\n}\n"],"mappings":";;;;;;;;;;;;AAiJA,eAAsB,mBACpB,QACA,SACiC;CAIjC,MAAM,SAAqB,EAAE;CAE7B,MAAM,cAAc,SAAiB,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,IAAI;AAIjF,YAAW,MAAM,QAAQ,mBAAmB,WAAW,QAAQ,QAAQ,YAAY,WAAW,EAAE;EAC9F,MAAM,QAAQ,eAAe,MAAM,QAAQ,QAAQ,QAAQ;AAC3D,MAAI,MAAO,QAAO,KAAK,MAAM;;AAI/B,YAAW,MAAM,QAAQ,mBAAmB,YAAY,QAAQ,QAAQ,YAAY,WAAW,EAAE;EAC/F,MAAM,QAAQ,eAAe,MAAM,QAAQ,SAAS,QAAQ;AAC5D,MAAI,MAAO,QAAO,KAAK,MAAM;;CAM/B,MAAM,gBAAgB,IAAI,IAAI,OAAO,KAAK,UAAU,MAAM,QAAQ,CAAC;AACnE,YAAW,MAAM,QAAQ,mBACvB,aACA,QACA,QAAQ,YACR,WACD,EAAE;EACD,MAAM,MAAM,KAAK,QAAQ,KAAK;EAC9B,MAAM,WAAW,QAAQ,MAAM,SAAS,KAAK,KAAK,QAAQ,IAAI;AAC9D,MAAI,CAAC,yBAAyB,SAAS,CAAE;AACzC,MAAI,sBAAsB,UAAU,QAAQ,QAAQ,CAAC,WAAW,EAAG;EAEnE,MAAM,QAAQ,oBAAoB,KAAK,QAA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AI,YAAY,IAAI,SAAS,QAAQ,IAC5C,KAAI,CAAC,mBAAmB,SAAS,GAAG,CAAE,QAAO;AAE/C,QAAO;;AAGT,SAAS,iBAAiB,aAAqB,SAAyB;AACtE,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,gBAAgB,MAAM,IAAI,YAAY,GAAG,YAAY,GAAG"}
1
+ {"version":3,"file":"app-route-graph.js","names":[],"sources":["../../src/routing/app-route-graph.ts"],"sourcesContent":["/**\n * App Router route graph construction.\n *\n * Scans app/ directories and materializes route metadata before the request-time\n * matcher consumes it. Keep request matching and cache ownership in app-router.ts.\n */\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport { createHash } from \"node:crypto\";\nimport { compareRoutes, decodeRouteSegment } from \"./utils.js\";\nimport { scanWithExtensions, type ValidFileMatcher } from \"./file-matcher.js\";\nimport { validateRoutePatterns } from \"./route-validation.js\";\n\nexport type InterceptingRoute = {\n /** The interception convention: \".\" | \"..\" | \"../..\" | \"...\" */\n convention: string;\n /** The URL pattern this intercepts (e.g. \"/photos/:id\") */\n targetPattern: string;\n /** Absolute path to the intercepting page component */\n pagePath: string;\n /** Absolute layout paths inside the intercepting route tree, outermost to innermost */\n layoutPaths: string[];\n /** Parameter names for dynamic segments */\n params: string[];\n};\n\nexport type ParallelSlot = {\n /** Graph-owned semantic slot identity. Required on AppRouteGraphParallelSlot. */\n id?: string;\n /** Stable slot identity (name + owning directory), used for route serialization keys. */\n key: string;\n /** Slot name (e.g. \"team\" from @team) */\n name: string;\n /** Absolute path to the @slot directory that owns this slot. Internal routing metadata. */\n ownerDir: string;\n /** Absolute path to the slot's page component */\n pagePath: string | null;\n /** Absolute path to the slot's default.tsx fallback */\n defaultPath: string | null;\n /** Absolute path to the slot's layout component (wraps slot content) */\n layoutPath: string | null;\n /** Absolute path to the slot's loading component */\n loadingPath: string | null;\n /** Absolute path to the slot's error component */\n errorPath: string | null;\n /** Intercepting routes within this slot */\n interceptingRoutes: InterceptingRoute[];\n /**\n * The layout index (0-based, in route.layouts[]) that this slot belongs to.\n * Slots are passed as props to the layout at their directory level, not\n * necessarily the innermost layout. -1 means \"innermost\" (legacy default).\n */\n layoutIndex: number;\n /**\n * Filesystem segments from the slot's root directory to its active page.\n * Used at render time to compute segments for useSelectedLayoutSegment(slotName).\n * For a page at the slot root (@team/page.tsx), this is [].\n * For a sub-page (@team/members/page.tsx), this is [\"members\"].\n * null when the slot has no active page (showing default.tsx fallback).\n */\n routeSegments: string[] | null;\n /**\n * Full URL pattern parts for the slot's active page (owner prefix +\n * slot-relative pattern). Set when an inherited slot mirrors a sub-page\n * whose param names may differ from the route's. The runtime matches the\n * request URL against these parts to extract slot-specific params.\n */\n slotPatternParts?: string[];\n /**\n * Param names captured by `slotPatternParts`, in order of appearance.\n * Used at runtime to decide whether to extract slot-specific params or\n * reuse the route's matched params.\n */\n slotParamNames?: string[];\n};\n\nexport type AppRoute = {\n /** Graph-owned semantic identities. Required on AppRouteGraphRoute. */\n ids?: AppRouteSemanticIds;\n /** URL pattern, e.g. \"/\" or \"/about\" or \"/blog/:slug\" */\n pattern: string;\n /** Absolute file path to the page component */\n pagePath: string | null;\n /** Absolute file path to the route handler (route.ts) */\n routePath: string | null;\n /** Ordered list of layout files from root to leaf */\n layouts: string[];\n /** Ordered list of all discovered template files from root to leaf (not necessarily aligned 1:1 with layouts) */\n templates: string[];\n /** Parallel route slots (from @slot directories at the route's directory level) */\n parallelSlots: ParallelSlot[];\n /** Loading component path */\n loadingPath: string | null;\n /** Error component path (leaf directory only) */\n errorPath: string | null;\n /**\n * Per-layout error boundary paths, aligned with the layouts array.\n * Each entry is the error.tsx at the same directory level as the\n * corresponding layout (or null if that level has no error.tsx).\n * Used to interleave ErrorBoundary components with layouts so that\n * ancestor error boundaries catch errors from descendant segments.\n */\n layoutErrorPaths: (string | null)[];\n /** Not-found component path (nearest, walking up from page dir) */\n notFoundPath: string | null;\n /**\n * Not-found component paths per layout level (aligned with layouts array).\n * Each entry is the not-found.tsx at that layout's directory, or null.\n * Used to create per-layout NotFoundBoundary so that notFound() thrown from\n * a layout is caught by the parent layout's boundary (matching Next.js behavior).\n */\n notFoundPaths: (string | null)[];\n /**\n * Forbidden component paths per layout level (aligned with layouts array).\n * Each entry is the forbidden.tsx at that layout's directory, or null.\n * Used to create per-layout ForbiddenBoundary.\n */\n forbiddenPaths: (string | null)[];\n /** Forbidden component path (403) at the route's directory level */\n forbiddenPath: string | null;\n /** Unauthorized component path (401) at the route's directory level */\n unauthorizedPath: string | null;\n /** Unauthorized component paths per layout level (aligned with layouts array). */\n unauthorizedPaths: (string | null)[];\n /**\n * Filesystem segments from app/ root to the route's directory.\n * Includes route groups and dynamic segments (as template strings like \"[id]\").\n * Used at render time to compute the child segments for useSelectedLayoutSegments().\n */\n routeSegments: string[];\n /** Tree position (directory depth from app/ root) for each template. */\n templateTreePositions?: number[];\n /**\n * Tree position (directory depth from app/ root) for each layout.\n * Used to slice routeSegments and determine which segments are below each layout.\n * For example, root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.\n * Unlike the old layoutSegmentDepths, this counts ALL directory levels including\n * route groups and parallel slots.\n */\n layoutTreePositions: number[];\n /** Whether this is a dynamic route */\n isDynamic: boolean;\n /** Parameter names for dynamic segments */\n params: string[];\n /** Dynamic parameter names captured by the route's root layout. */\n rootParamNames?: string[];\n /** Pre-split pattern segments (computed once at scan time, reused per request) */\n patternParts: string[];\n};\n\nexport type AppRouteSemanticIds = {\n route: string;\n page: string | null;\n routeHandler: string | null;\n rootBoundary: RootBoundaryId | null;\n layouts: readonly string[];\n templates: readonly string[];\n /**\n * Bridge map for the current route metadata shape: keyed by `slot.key`\n * (`name@relative/path` infrastructure id), value is the graph-owned semantic slot id.\n */\n slots: Readonly<Record<string, string>>;\n};\n\nexport type AppRouteGraphParallelSlot = ParallelSlot & {\n id: string;\n};\n\nexport type AppRouteGraphRoute = Omit<AppRoute, \"ids\" | \"parallelSlots\" | \"rootParamNames\"> & {\n ids: AppRouteSemanticIds;\n parallelSlots: AppRouteGraphParallelSlot[];\n rootParamNames: string[];\n};\n\ntype Flavor<T, Brand extends string> = T & { readonly __flavor?: Brand };\n\nexport type GraphVersion = Flavor<string, \"GraphVersion\">;\nexport type RootBoundaryId = Flavor<string, \"RootBoundaryId\">;\n\nexport type RouteManifestRoute = {\n id: string;\n pattern: string;\n patternParts: readonly string[];\n isDynamic: boolean;\n paramNames: readonly string[];\n rootParamNames: readonly string[];\n rootBoundaryId: RootBoundaryId | null;\n pageId: string | null;\n routeHandlerId: string | null;\n layoutIds: readonly string[];\n templateIds: readonly string[];\n slotIds: readonly string[];\n};\n\nexport type RouteManifestPage = {\n id: string;\n routeId: string;\n pattern: string;\n};\n\nexport type RouteManifestRouteHandler = {\n id: string;\n routeId: string;\n pattern: string;\n};\n\nexport type RouteManifestLayout = {\n id: string;\n treePath: string;\n rootBoundaryId: RootBoundaryId | null;\n};\n\nexport type RouteManifestTemplate = {\n id: string;\n treePath: string;\n rootBoundaryId: RootBoundaryId | null;\n};\n\nexport type RouteManifestSlot = {\n id: string;\n key: string;\n name: string;\n};\n\nexport type RouteManifestRootBoundary = {\n id: RootBoundaryId;\n layoutId: string;\n treePath: string;\n};\n\nexport type StaticSegmentGraph = {\n routes: ReadonlyMap<string, RouteManifestRoute>;\n pages: ReadonlyMap<string, RouteManifestPage>;\n routeHandlers: ReadonlyMap<string, RouteManifestRouteHandler>;\n layouts: ReadonlyMap<string, RouteManifestLayout>;\n templates: ReadonlyMap<string, RouteManifestTemplate>;\n slots: ReadonlyMap<string, RouteManifestSlot>;\n rootBoundaries: ReadonlyMap<RootBoundaryId, RouteManifestRootBoundary>;\n};\n\nexport type RouteManifest = {\n graphVersion: GraphVersion;\n segmentGraph: StaticSegmentGraph;\n};\n\nfunction createAppRouteGraphRouteId(pattern: string): string {\n return `route:${pattern}`;\n}\n\nfunction createAppRouteGraphPageId(pattern: string): string {\n return `page:${pattern}`;\n}\n\nfunction createAppRouteGraphRouteHandlerId(pattern: string): string {\n return `route-handler:${pattern}`;\n}\n\nfunction createAppRouteGraphLayoutId(treePath: string): string {\n return `layout:${treePath}`;\n}\n\nfunction createAppRouteGraphTemplateId(treePath: string): string {\n return `template:${treePath}`;\n}\n\nfunction createAppRouteGraphSlotId(slotName: string, ownerTreePath: string): string {\n return `slot:${slotName}:${ownerTreePath}`;\n}\n\nfunction createAppRouteGraphRootBoundaryId(treePath: string): RootBoundaryId {\n return `root-boundary:${treePath}`;\n}\n\nfunction compareStableStrings(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\nfunction sortedMapValues<T>(map: ReadonlyMap<string, T>): T[] {\n return Array.from(map.entries())\n .sort(([left], [right]) => compareStableStrings(left, right))\n .map(([, value]) => value);\n}\n\nfunction createRouteManifest(routes: readonly AppRouteGraphRoute[]): RouteManifest {\n const segmentGraph = createStaticSegmentGraph(routes);\n\n return {\n graphVersion: createRouteManifestGraphVersion(segmentGraph),\n segmentGraph,\n };\n}\n\nfunction createStaticSegmentGraph(routes: readonly AppRouteGraphRoute[]): StaticSegmentGraph {\n const routeEntries = new Map<string, RouteManifestRoute>();\n const pages = new Map<string, RouteManifestPage>();\n const routeHandlers = new Map<string, RouteManifestRouteHandler>();\n const layouts = new Map<string, RouteManifestLayout>();\n const templates = new Map<string, RouteManifestTemplate>();\n const slots = new Map<string, RouteManifestSlot>();\n const rootBoundaries = new Map<RootBoundaryId, RouteManifestRootBoundary>();\n\n for (const route of routes) {\n routeEntries.set(route.ids.route, {\n id: route.ids.route,\n pattern: route.pattern,\n patternParts: [...route.patternParts],\n isDynamic: route.isDynamic,\n paramNames: [...route.params],\n rootParamNames: [...route.rootParamNames],\n rootBoundaryId: route.ids.rootBoundary,\n pageId: route.ids.page,\n routeHandlerId: route.ids.routeHandler,\n layoutIds: [...route.ids.layouts],\n templateIds: [...route.ids.templates],\n slotIds: route.parallelSlots.map((slot) => slot.id).sort(compareStableStrings),\n });\n\n if (route.ids.page) {\n pages.set(route.ids.page, {\n id: route.ids.page,\n routeId: route.ids.route,\n pattern: route.pattern,\n });\n }\n\n if (route.ids.routeHandler) {\n routeHandlers.set(route.ids.routeHandler, {\n id: route.ids.routeHandler,\n routeId: route.ids.route,\n pattern: route.pattern,\n });\n }\n\n for (const [index, layoutId] of route.ids.layouts.entries()) {\n const treePosition = route.layoutTreePositions[index];\n assertRouteManifestTreePosition(\"layout\", route, layoutId, treePosition);\n\n const treePath = createAppRouteGraphTreePath(route.routeSegments, treePosition);\n const existingLayout = layouts.get(layoutId);\n if (existingLayout) {\n assertRouteManifestRootBoundary(\"layout\", route, layoutId, existingLayout.rootBoundaryId);\n }\n layouts.set(layoutId, {\n id: layoutId,\n treePath,\n rootBoundaryId: route.ids.rootBoundary,\n });\n\n if (index === 0 && route.ids.rootBoundary) {\n rootBoundaries.set(route.ids.rootBoundary, {\n id: route.ids.rootBoundary,\n layoutId,\n treePath,\n });\n }\n }\n\n for (const [index, templateId] of route.ids.templates.entries()) {\n const treePosition = route.templateTreePositions?.[index];\n assertRouteManifestTreePosition(\"template\", route, templateId, treePosition);\n\n const existingTemplate = templates.get(templateId);\n if (existingTemplate) {\n assertRouteManifestRootBoundary(\n \"template\",\n route,\n templateId,\n existingTemplate.rootBoundaryId,\n );\n }\n templates.set(templateId, {\n id: templateId,\n treePath: createAppRouteGraphTreePath(route.routeSegments, treePosition),\n rootBoundaryId: route.ids.rootBoundary,\n });\n }\n\n // Slots are boundary-agnostic in this minimal read model; unlike layouts\n // and templates, they do not carry rootBoundaryId facts to guard.\n for (const slot of route.parallelSlots) {\n slots.set(slot.id, {\n id: slot.id,\n key: slot.key,\n name: slot.name,\n });\n }\n }\n\n return {\n routes: routeEntries,\n pages,\n routeHandlers,\n layouts,\n templates,\n slots,\n rootBoundaries,\n };\n}\n\nfunction assertRouteManifestTreePosition(\n kind: \"layout\" | \"template\",\n route: AppRouteGraphRoute,\n id: string,\n treePosition: number | undefined,\n): asserts treePosition is number {\n if (treePosition !== undefined) return;\n\n throw new Error(\n `[vinext] App route graph invariant violated: missing ${kind} tree position for ${id} on ${route.pattern}`,\n );\n}\n\nfunction assertRouteManifestRootBoundary(\n kind: \"layout\" | \"template\",\n route: AppRouteGraphRoute,\n id: string,\n existingRootBoundaryId: RootBoundaryId | null,\n): void {\n if (existingRootBoundaryId === route.ids.rootBoundary) return;\n\n throw new Error(\n `[vinext] App route graph invariant violated: ${kind} ${id} is shared across root boundaries (${existingRootBoundaryId ?? \"none\"} and ${route.ids.rootBoundary ?? \"none\"}) on ${route.pattern}`,\n );\n}\n\nfunction createRouteManifestGraphVersion(segmentGraph: StaticSegmentGraph): GraphVersion {\n // The manifest hash is canonical only if top-level map keys are sorted and\n // inner route arrays keep their own semantic order: layoutIds/templateIds in\n // tree-position order, and slotIds in compareStableStrings order.\n const stableShape = {\n routes: sortedMapValues(segmentGraph.routes),\n pages: sortedMapValues(segmentGraph.pages),\n routeHandlers: sortedMapValues(segmentGraph.routeHandlers),\n layouts: sortedMapValues(segmentGraph.layouts),\n templates: sortedMapValues(segmentGraph.templates),\n slots: sortedMapValues(segmentGraph.slots),\n rootBoundaries: sortedMapValues(segmentGraph.rootBoundaries),\n };\n return `graph:${createHash(\"sha256\").update(JSON.stringify(stableShape)).digest(\"hex\")}`;\n}\n\nexport async function buildAppRouteGraph(\n appDir: string,\n matcher: ValidFileMatcher,\n): Promise<{ routes: AppRouteGraphRoute[]; routeManifest: RouteManifest }> {\n // Find all page.tsx and route.ts files, excluding @slot directories\n // (slot pages are not standalone routes — they're rendered as props of their parent layout)\n // and _private folders (Next.js convention for colocated non-route files).\n const routes: AppRouteGraphRoute[] = [];\n\n const excludeDir = (name: string) => name.startsWith(\"@\") || name.startsWith(\"_\");\n\n // Process page files in a single pass\n // Use function form of exclude for Node < 22.14 compatibility (string arrays require >= 22.14)\n for await (const file of scanWithExtensions(\"**/page\", appDir, matcher.extensions, excludeDir)) {\n const route = fileToAppRoute(file, appDir, \"page\", matcher);\n if (route) routes.push(route);\n }\n\n // Process route handler files (API routes) in a single pass\n for await (const file of scanWithExtensions(\"**/route\", appDir, matcher.extensions, excludeDir)) {\n const route = fileToAppRoute(file, appDir, \"route\", matcher);\n if (route) routes.push(route);\n }\n\n // Layouts with parallel slot pages are valid route entries even when the\n // segment has no children page. Next.js uses this for modal/feed patterns\n // like app/user/[id]/layout + @feed/page + @modal/default.\n const routePatterns = new Set(routes.map((route) => route.pattern));\n for await (const file of scanWithExtensions(\n \"**/layout\",\n appDir,\n matcher.extensions,\n excludeDir,\n )) {\n const dir = path.dirname(file);\n const routeDir = dir === \".\" ? appDir : path.join(appDir, dir);\n if (!hasParallelSlotDirectory(routeDir)) continue;\n if (discoverParallelSlots(routeDir, appDir, matcher).length === 0) continue;\n\n const route = directoryToAppRoute(dir, appDir, matcher, null, null);\n if (!route || routePatterns.has(route.pattern)) continue;\n\n routes.push(route);\n routePatterns.add(route.pattern);\n }\n\n // Discover sub-routes created by nested pages within parallel slots.\n // In Next.js, pages nested inside @slot directories create additional URL routes.\n // For example, @audience/demographics/page.tsx at app/parallel-routes/ creates\n // a route at /parallel-routes/demographics.\n const slotSubRoutes = discoverSlotSubRoutes(routes, matcher);\n routes.push(...slotSubRoutes);\n\n validatePageRouteConflicts(routes, appDir);\n validateRoutePatterns(routes.map((route) => route.pattern));\n const interceptTargetPatterns = [\n ...new Set(\n routes.flatMap((route) =>\n route.parallelSlots.flatMap((slot) =>\n slot.interceptingRoutes.map((intercept) => intercept.targetPattern),\n ),\n ),\n ),\n ];\n validateRoutePatterns(interceptTargetPatterns);\n\n // Sort: static routes first, then dynamic, then catch-all\n routes.sort(compareRoutes);\n\n return { routes, routeManifest: createRouteManifest(routes) };\n}\n\nfunction hasParallelSlotDirectory(dir: string): boolean {\n try {\n return fs\n .readdirSync(dir, { withFileTypes: true })\n .some((entry) => entry.isDirectory() && entry.name.startsWith(\"@\"));\n } catch {\n return false;\n }\n}\n\nfunction validatePageRouteConflicts(routes: readonly AppRoute[], appDir: string): void {\n const byPattern = new Map<string, { pagePath: string | null; routePath: string | null }>();\n\n // validateRoutePatterns() would also reject page/route pairs because they\n // share a URL pattern. Keep this pass first so the error names both files.\n for (const route of routes) {\n const entry = byPattern.get(route.pattern);\n if (!entry) {\n byPattern.set(route.pattern, {\n pagePath: route.pagePath,\n routePath: route.routePath,\n });\n continue;\n }\n\n if (!entry.pagePath && route.pagePath) {\n entry.pagePath = route.pagePath;\n }\n if (!entry.routePath && route.routePath) {\n entry.routePath = route.routePath;\n }\n }\n\n for (const [pattern, entry] of byPattern) {\n if (!entry.pagePath || !entry.routePath) continue;\n\n throw new Error(\n `Conflicting route and page at ${pattern}: route at ${formatAppFilePath(\n entry.routePath,\n appDir,\n )} and page at ${formatAppFilePath(entry.pagePath, appDir)}`,\n );\n }\n}\n\nfunction formatAppFilePath(filePath: string, appDir: string): string {\n const relativePath = path.relative(appDir, filePath).replace(/\\\\/g, \"/\");\n const parsedPath = path.parse(relativePath);\n const withoutExtension = path.join(parsedPath.dir, parsedPath.name).replace(/\\\\/g, \"/\");\n return withoutExtension.startsWith(\"/\") ? withoutExtension : `/${withoutExtension}`;\n}\n\n/**\n * Discover sub-routes created by nested pages within parallel slots.\n *\n * In Next.js, pages nested inside @slot directories create additional URL routes.\n * For example, given:\n * app/parallel-routes/@audience/demographics/page.tsx\n * This creates a route at /parallel-routes/demographics where:\n * - children slot → parent's default.tsx\n * - @audience slot → @audience/demographics/page.tsx (matched)\n * - other slots → their default.tsx (fallback)\n */\nfunction discoverSlotSubRoutes(\n routes: AppRouteGraphRoute[],\n matcher: ValidFileMatcher,\n): AppRouteGraphRoute[] {\n const syntheticRoutes: AppRouteGraphRoute[] = [];\n\n // O(1) lookup for existing routes by pattern — avoids O(n) routes.find() per sub-path per parent.\n // Updated as new synthetic routes are pushed so that later parents can see earlier synthetic entries.\n const routesByPattern = new Map<string, AppRoute>(routes.map((r) => [r.pattern, r]));\n\n const applySlotSubPages = (\n route: AppRoute,\n slotPages: Map<string, string>,\n rawSegments: string[],\n ): void => {\n route.parallelSlots = route.parallelSlots.map((slot) => {\n const subPage = slotPages.get(slot.key);\n if (subPage !== undefined) {\n return { ...slot, pagePath: subPage, routeSegments: rawSegments };\n }\n return slot;\n });\n };\n\n for (const parentRoute of routes) {\n if (parentRoute.parallelSlots.length === 0) continue;\n\n // Only page-bearing routes or layout-only UI routes (not route handlers)\n // can own nested parallel-slot sub-routes.\n const isLayoutOnlyUiRoute =\n !parentRoute.pagePath && !parentRoute.routePath && parentRoute.layouts.length > 0;\n if (!parentRoute.pagePath && !isLayoutOnlyUiRoute) continue;\n\n // For page-bearing routes, the route directory is the page's directory.\n // For layout-only routes (no page.tsx), proxy the route directory through\n // the innermost layout — it lives at the same filesystem level as the route.\n const parentPageDir = parentRoute.pagePath\n ? path.dirname(parentRoute.pagePath)\n : path.dirname(parentRoute.layouts[parentRoute.layouts.length - 1]);\n\n // Collect sub-paths from all slots.\n // Map: normalized visible sub-path -> slot pages, raw filesystem segments (for routeSegments),\n // and the pre-computed convertedSubRoute (to avoid a redundant re-conversion in the merge loop).\n const subPathMap = new Map<\n string,\n {\n // Raw filesystem segments (with route groups, @slots, etc.) used for routeSegments so\n // that useSelectedLayoutSegments() sees the correct segment list at runtime.\n rawSegments: string[];\n // Pre-computed URL parts, params, isDynamic from convertSegmentsToRouteParts.\n converted: { urlSegments: string[]; params: string[]; isDynamic: boolean };\n slotPages: Map<string, string>;\n }\n >();\n\n for (const slot of parentRoute.parallelSlots) {\n // Only scan sub-pages from slots owned by this route directory.\n // Inherited slots with the same name live in different owner dirs.\n if (path.dirname(slot.ownerDir) !== parentPageDir) {\n continue;\n }\n const slotDir = slot.ownerDir;\n if (!fs.existsSync(slotDir)) continue;\n\n const subPages = findSlotSubPages(slotDir, matcher);\n for (const { relativePath, pagePath } of subPages) {\n const subSegments = relativePath.split(path.sep);\n const convertedSubRoute = convertSegmentsToRouteParts(subSegments);\n if (!convertedSubRoute) continue;\n\n const { urlSegments } = convertedSubRoute;\n const normalizedSubPath = urlSegments.join(\"/\");\n let subPathEntry = subPathMap.get(normalizedSubPath);\n\n if (!subPathEntry) {\n subPathEntry = {\n rawSegments: subSegments,\n converted: convertedSubRoute,\n slotPages: new Map(),\n };\n subPathMap.set(normalizedSubPath, subPathEntry);\n }\n\n const existingSlotPage = subPathEntry.slotPages.get(slot.key);\n if (existingSlotPage) {\n const pattern = joinRoutePattern(parentRoute.pattern, normalizedSubPath);\n throw new Error(\n `You cannot have two routes that resolve to the same path (\"${pattern}\").`,\n );\n }\n\n subPathEntry.slotPages.set(slot.key, pagePath);\n }\n }\n\n if (subPathMap.size === 0) continue;\n\n // Find the default.tsx for the children slot at the parent directory.\n // When the parent route has a children page, a default.tsx is required so\n // the synthetic sub-route has a fallback for the children slot. Layout-only\n // parent routes (no page.tsx) do not need a default — the children slot was\n // never occupied at the parent level, so the sub-route simply renders null.\n const childrenDefault = findFile(parentPageDir, \"default\", matcher);\n if (parentRoute.pagePath && !childrenDefault) continue;\n\n for (const { rawSegments, converted: convertedSubRoute, slotPages } of subPathMap.values()) {\n const {\n urlSegments: urlParts,\n params: subParams,\n isDynamic: subIsDynamic,\n } = convertedSubRoute;\n\n const subUrlPath = urlParts.join(\"/\");\n const pattern = joinRoutePattern(parentRoute.pattern, subUrlPath);\n\n const existingRoute = routesByPattern.get(pattern);\n if (existingRoute) {\n if (existingRoute.routePath && !existingRoute.pagePath) {\n throw new Error(\n `You cannot have two routes that resolve to the same path (\"${pattern}\").`,\n );\n }\n applySlotSubPages(existingRoute, slotPages, rawSegments);\n continue;\n }\n\n // Skip synthetic routes that would structurally conflict with an existing\n // route (same shape, different param names). The slot content is handled\n // by findMirroredSlotPage for the existing route instead.\n // Scan routesByPattern (not just the original routes array) so synthetic\n // routes created earlier in this loop are also visible.\n const syntheticParts = [...parentRoute.patternParts, ...urlParts];\n const hasStructuralConflict = Array.from(routesByPattern.values()).some((r) =>\n patternsStructurallyEquivalent(r.patternParts, syntheticParts),\n );\n if (hasStructuralConflict) continue;\n\n // Build parallel slots for this sub-route: matching slots get the sub-page,\n // non-matching slots get null pagePath (rendering falls back to defaultPath)\n const subSlots: AppRouteGraphParallelSlot[] = parentRoute.parallelSlots.map((slot) => {\n const subPage = slotPages.get(slot.key);\n return {\n ...slot,\n pagePath: subPage || null,\n routeSegments: subPage ? rawSegments : null,\n };\n });\n\n const newRoute: AppRouteGraphRoute = {\n ids: createAppRouteSemanticIds({\n pattern,\n pagePath: childrenDefault,\n routePath: null,\n routeSegments: [...parentRoute.routeSegments, ...rawSegments],\n layoutTreePositions: parentRoute.layoutTreePositions,\n templateTreePositions: parentRoute.templateTreePositions,\n slots: subSlots,\n }),\n pattern,\n pagePath: childrenDefault, // children slot uses parent's default.tsx as page\n routePath: null,\n layouts: parentRoute.layouts,\n templates: parentRoute.templates,\n parallelSlots: subSlots,\n loadingPath: parentRoute.loadingPath,\n errorPath: parentRoute.errorPath,\n layoutErrorPaths: parentRoute.layoutErrorPaths,\n notFoundPath: parentRoute.notFoundPath,\n notFoundPaths: parentRoute.notFoundPaths,\n forbiddenPaths: parentRoute.forbiddenPaths,\n forbiddenPath: parentRoute.forbiddenPath,\n unauthorizedPath: parentRoute.unauthorizedPath,\n unauthorizedPaths: parentRoute.unauthorizedPaths,\n routeSegments: [...parentRoute.routeSegments, ...rawSegments],\n templateTreePositions: parentRoute.templateTreePositions,\n layoutTreePositions: parentRoute.layoutTreePositions,\n isDynamic: parentRoute.isDynamic || subIsDynamic,\n params: [...parentRoute.params, ...subParams],\n rootParamNames: parentRoute.rootParamNames,\n patternParts: [...parentRoute.patternParts, ...urlParts],\n };\n syntheticRoutes.push(newRoute);\n routesByPattern.set(pattern, newRoute);\n }\n }\n\n return syntheticRoutes;\n}\n\n/**\n * Find all page files in subdirectories of a parallel slot directory.\n * Returns relative paths (from the slot dir) and absolute page paths.\n * Skips the root page.tsx (already handled as the slot's main page)\n * and intercepting route directories.\n */\ntype SlotSubPageEntry = { relativePath: string; pagePath: string };\n\n// Per-build memo: a slot directory's sub-pages depend only on the directory\n// contents and the matcher's accepted extensions. Inherited slots get scanned\n// once per descendant route, so without memoization a route N segments deep\n// pays O(N) full subtree walks for every shared ancestor slot.\n//\n// Keyed by matcher (one matcher per build) so the cache is naturally scoped\n// to a single build run and gets collected when the build finishes — no\n// cross-build pollution in long-lived dev servers.\nconst findSlotSubPagesCache = new WeakMap<ValidFileMatcher, Map<string, SlotSubPageEntry[]>>();\n\nfunction findSlotSubPages(slotDir: string, matcher: ValidFileMatcher): SlotSubPageEntry[] {\n let perMatcher = findSlotSubPagesCache.get(matcher);\n if (!perMatcher) {\n perMatcher = new Map();\n findSlotSubPagesCache.set(matcher, perMatcher);\n }\n const cached = perMatcher.get(slotDir);\n if (cached) return cached;\n\n const results: SlotSubPageEntry[] = [];\n\n function scan(dir: string): void {\n if (!fs.existsSync(dir)) return;\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n // Skip intercepting route directories\n if (matchInterceptConvention(entry.name)) continue;\n // Skip private folders (prefixed with _)\n if (entry.name.startsWith(\"_\")) continue;\n\n const subDir = path.join(dir, entry.name);\n const page = findFile(subDir, \"page\", matcher);\n if (page) {\n const relativePath = path.relative(slotDir, subDir);\n results.push({ relativePath, pagePath: page });\n }\n // Continue scanning deeper for nested sub-pages\n scan(subDir);\n }\n }\n\n scan(slotDir);\n perMatcher.set(slotDir, results);\n return results;\n}\n\n/**\n * Convert a file path relative to app/ into an AppRoute.\n */\nfunction fileToAppRoute(\n file: string,\n appDir: string,\n type: \"page\" | \"route\",\n matcher: ValidFileMatcher,\n): AppRouteGraphRoute | null {\n // Remove the filename (page.tsx or route.ts)\n const dir = path.dirname(file);\n return directoryToAppRoute(\n dir,\n appDir,\n matcher,\n type === \"page\" ? path.join(appDir, file) : null,\n type === \"route\" ? path.join(appDir, file) : null,\n );\n}\n\nfunction directoryToAppRoute(\n dir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n pagePath: string | null,\n routePath: string | null,\n): AppRouteGraphRoute | null {\n const segments = dir === \".\" ? [] : dir.split(path.sep);\n\n const params: string[] = [];\n let isDynamic = false;\n\n const convertedRoute = convertSegmentsToRouteParts(segments);\n if (!convertedRoute) return null;\n\n const { urlSegments, params: routeParams, isDynamic: routeIsDynamic } = convertedRoute;\n params.push(...routeParams);\n isDynamic = routeIsDynamic;\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n\n // Discover layouts and templates from root to leaf\n const layouts = discoverLayouts(segments, appDir, matcher);\n const templates = discoverTemplates(segments, appDir, matcher);\n const templateTreePositions = computeLayoutTreePositions(appDir, templates);\n\n // Compute the tree position (directory depth) for each layout.\n const layoutTreePositions = computeLayoutTreePositions(appDir, layouts);\n\n // Discover per-layout error boundaries (aligned with layouts array).\n // In Next.js, each segment independently wraps its children with an ErrorBoundary.\n // This array enables interleaving error boundaries with layouts in the rendering.\n const layoutErrorPaths = discoverLayoutAlignedErrors(segments, appDir, matcher);\n\n // Discover loading, error in the route's directory\n const routeDir = dir === \".\" ? appDir : path.join(appDir, dir);\n const loadingPath = findFile(routeDir, \"loading\", matcher);\n const errorPath = findFile(routeDir, \"error\", matcher);\n\n // Discover not-found/forbidden/unauthorized: walk from route directory up to root (nearest wins).\n const notFoundPath = discoverBoundaryFile(segments, appDir, \"not-found\", matcher);\n const forbiddenPath = discoverBoundaryFile(segments, appDir, \"forbidden\", matcher);\n const unauthorizedPath = discoverBoundaryFile(segments, appDir, \"unauthorized\", matcher);\n\n // Discover per-layout not-found files (one per layout directory).\n // These are used for per-layout NotFoundBoundary to match Next.js behavior where\n // notFound() thrown from a layout is caught by the parent layout's boundary.\n const notFoundPaths = discoverBoundaryFilePerLayout(layouts, \"not-found\", matcher);\n const forbiddenPaths = discoverBoundaryFilePerLayout(layouts, \"forbidden\", matcher);\n const unauthorizedPaths = discoverBoundaryFilePerLayout(layouts, \"unauthorized\", matcher);\n\n // Discover parallel slots (@team, @analytics, etc.).\n // Slots at the route's own directory use page.tsx; slots at ancestor directories\n // (inherited from parent layouts) use default.tsx as fallback.\n const parallelSlots = discoverInheritedParallelSlots(segments, appDir, routeDir, matcher);\n\n return {\n ids: createAppRouteSemanticIds({\n pattern: pattern === \"/\" ? \"/\" : pattern,\n pagePath,\n routePath,\n routeSegments: segments,\n layoutTreePositions,\n templateTreePositions,\n slots: parallelSlots,\n }),\n pattern: pattern === \"/\" ? \"/\" : pattern,\n pagePath,\n routePath,\n layouts,\n templates,\n parallelSlots,\n loadingPath,\n errorPath,\n layoutErrorPaths,\n notFoundPath,\n notFoundPaths,\n forbiddenPaths,\n forbiddenPath,\n unauthorizedPath,\n unauthorizedPaths,\n routeSegments: segments,\n templateTreePositions,\n layoutTreePositions,\n isDynamic,\n params,\n rootParamNames: computeRootParamNames(segments, layoutTreePositions),\n patternParts: urlSegments,\n };\n}\n\nfunction dynamicParamNameFromSegment(segment: string): string | null {\n if (segment.startsWith(\"[[...\") && segment.endsWith(\"]]\")) return segment.slice(5, -2);\n if (segment.startsWith(\"[...\") && segment.endsWith(\"]\")) return segment.slice(4, -1);\n if (segment.startsWith(\"[\") && segment.endsWith(\"]\")) return segment.slice(1, -1);\n return null;\n}\n\nexport function computeRootParamNames(\n routeSegments: readonly string[],\n layoutTreePositions: readonly number[],\n): string[] {\n const rootLayoutPosition = layoutTreePositions[0];\n if (rootLayoutPosition == null || rootLayoutPosition <= 0) return [];\n\n const names: string[] = [];\n for (const segment of routeSegments.slice(0, rootLayoutPosition)) {\n const name = dynamicParamNameFromSegment(segment);\n if (name && !names.includes(name)) names.push(name);\n }\n return names;\n}\n\nfunction resolveRootBoundaryId(\n routeSegments: readonly string[],\n layoutTreePositions: readonly number[],\n): RootBoundaryId | null {\n const rootLayoutPosition = layoutTreePositions[0];\n if (rootLayoutPosition === undefined) return null;\n\n // Position 0 is the app root layout and still owns a real root boundary.\n // Only a missing layout position means the route is layoutless.\n return createAppRouteGraphRootBoundaryId(\n createAppRouteGraphTreePath(routeSegments, rootLayoutPosition),\n );\n}\n\nfunction createAppRouteSemanticIds(input: {\n pattern: string;\n pagePath: string | null;\n routePath: string | null;\n routeSegments: readonly string[];\n layoutTreePositions: readonly number[];\n templateTreePositions?: readonly number[];\n slots: readonly AppRouteGraphParallelSlot[];\n}): AppRouteSemanticIds {\n const slots: Record<string, string> = {};\n for (const slot of input.slots) {\n slots[slot.key] = slot.id;\n }\n\n return {\n route: createAppRouteGraphRouteId(input.pattern),\n page: input.pagePath ? createAppRouteGraphPageId(input.pattern) : null,\n routeHandler: input.routePath ? createAppRouteGraphRouteHandlerId(input.pattern) : null,\n rootBoundary: resolveRootBoundaryId(input.routeSegments, input.layoutTreePositions),\n layouts: input.layoutTreePositions.map((treePosition) =>\n createAppRouteGraphLayoutId(createAppRouteGraphTreePath(input.routeSegments, treePosition)),\n ),\n templates: (input.templateTreePositions ?? []).map((treePosition) =>\n createAppRouteGraphTemplateId(createAppRouteGraphTreePath(input.routeSegments, treePosition)),\n ),\n slots,\n };\n}\n\nfunction createAppRouteGraphTreePath(\n routeSegments: readonly string[],\n treePosition: number,\n): string {\n const treePathSegments = routeSegments.slice(0, treePosition);\n if (treePathSegments.length === 0) {\n return \"/\";\n }\n return `/${treePathSegments.join(\"/\")}`;\n}\n\n/**\n * Compute the tree position (directory depth from app root) for each layout.\n * Root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.\n * Counts ALL directory levels including route groups and parallel slots.\n */\nfunction computeLayoutTreePositions(appDir: string, layouts: string[]): number[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n if (layoutDir === appDir) return 0;\n const relative = path.relative(appDir, layoutDir);\n return relative.split(path.sep).length;\n });\n}\n\n/**\n * Discover all layout files from root to the given directory.\n * Each level of the directory tree may have a layout.tsx.\n */\nfunction discoverLayouts(segments: string[], appDir: string, matcher: ValidFileMatcher): string[] {\n const layouts: string[] = [];\n\n // Check root layout\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) layouts.push(rootLayout);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) layouts.push(layout);\n }\n\n return layouts;\n}\n\n/**\n * Discover all template files from root to the given directory.\n * Each level of the directory tree may have a template.tsx.\n * Templates are like layouts but re-mount on navigation.\n */\nfunction discoverTemplates(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): string[] {\n const templates: string[] = [];\n\n // Check root template\n const rootTemplate = findFile(appDir, \"template\", matcher);\n if (rootTemplate) templates.push(rootTemplate);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const template = findFile(currentDir, \"template\", matcher);\n if (template) templates.push(template);\n }\n\n return templates;\n}\n\n/**\n * Discover error.tsx files aligned with the layouts array.\n * Walks the same directory levels as discoverLayouts and, for each level\n * that contributes a layout entry, checks whether error.tsx also exists.\n * Returns an array of the same length as discoverLayouts() would return,\n * with the error path (or null) at each corresponding layout level.\n *\n * This enables interleaving ErrorBoundary components with layouts in the\n * rendering tree, matching Next.js behavior where each segment independently\n * wraps its children with an error boundary.\n */\nfunction discoverLayoutAlignedErrors(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n const errors: (string | null)[] = [];\n\n // Root level (only if root has a layout — matching discoverLayouts logic)\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) {\n errors.push(findFile(appDir, \"error\", matcher));\n }\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) {\n errors.push(findFile(currentDir, \"error\", matcher));\n }\n }\n\n return errors;\n}\n\n/**\n * Discover the nearest boundary file (not-found, forbidden, unauthorized)\n * by walking from the route's directory up to the app root.\n * Returns the first (closest) file found, or null.\n */\nfunction discoverBoundaryFile(\n segments: string[],\n appDir: string,\n fileName: string,\n matcher: ValidFileMatcher,\n): string | null {\n // Build all directory paths from leaf to root\n const dirs: string[] = [];\n let dir = appDir;\n dirs.push(dir);\n for (const segment of segments) {\n dir = path.join(dir, segment);\n dirs.push(dir);\n }\n\n // Walk from leaf (last) to root (first)\n for (let i = dirs.length - 1; i >= 0; i--) {\n const f = findFile(dirs[i], fileName, matcher);\n if (f) return f;\n }\n return null;\n}\n\n/**\n * Discover boundary files (not-found, forbidden, unauthorized) at each layout directory.\n * Returns an array aligned with the layouts array, where each entry is the boundary\n * file at that layout's directory, or null if none exists there.\n *\n * This is used for per-layout error boundaries. In Next.js, each layout level\n * has its own boundary that wraps the layout's children. When notFound() is thrown\n * from a layout, it propagates up to the parent layout's boundary.\n */\nfunction discoverBoundaryFilePerLayout(\n layouts: string[],\n fileName: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n return findFile(layoutDir, fileName, matcher);\n });\n}\n\n/**\n * Discover parallel slots inherited from ancestor directories.\n *\n * In Next.js, parallel slots belong to the layout that defines them. When a\n * child route is rendered, its parent layout's slots must still be present.\n * If the child doesn't have matching content in a slot, the slot's default.tsx\n * is rendered instead.\n *\n * Walk from appDir through each segment to the route's directory. At each level\n * that has @slot dirs, collect them. Slots at the route's own directory level\n * use page.tsx; slots at ancestor levels use default.tsx only.\n */\nfunction discoverInheritedParallelSlots(\n segments: string[],\n appDir: string,\n routeDir: string,\n matcher: ValidFileMatcher,\n): AppRouteGraphParallelSlot[] {\n const slotMap = new Map<string, AppRouteGraphParallelSlot>();\n\n // Walk from appDir through each segment, tracking layout indices.\n // layoutIndex tracks which position in the route's layouts[] array corresponds\n // to a given directory. Only directories with a layout.tsx file increment.\n // segmentIndex aligns each entry with `segments`: dirsToCheck[i] is reached\n // after consuming segments[0..i-1], so segments.slice(i) are the segments\n // below this directory (used to mirror inherited slot sub-pages).\n let currentDir = appDir;\n const dirsToCheck: { dir: string; layoutIdx: number; segmentIndex: number }[] = [];\n let layoutIdx = findFile(appDir, \"layout\", matcher) ? 0 : -1;\n dirsToCheck.push({ dir: appDir, layoutIdx, segmentIndex: 0 });\n\n for (let i = 0; i < segments.length; i++) {\n currentDir = path.join(currentDir, segments[i]);\n if (findFile(currentDir, \"layout\", matcher)) {\n layoutIdx++;\n }\n dirsToCheck.push({ dir: currentDir, layoutIdx, segmentIndex: i + 1 });\n }\n\n const routeHasLayout = layoutIdx >= 0;\n\n for (const { dir, layoutIdx: lvlLayoutIdx, segmentIndex } of dirsToCheck) {\n // Once a route has a root layout below app/, slots discovered before that\n // layout are above the root and cannot be owned by any layout in this route.\n // Layout-less routes keep their legacy slot metadata here; validation is separate.\n if (lvlLayoutIdx < 0 && routeHasLayout) continue;\n\n const isOwnDir = dir === routeDir;\n const slotLayoutIdx = Math.max(lvlLayoutIdx, 0);\n const slotsAtLevel = discoverParallelSlots(dir, appDir, matcher);\n const segmentsBelow = segments.slice(segmentIndex);\n\n for (const slot of slotsAtLevel) {\n if (isOwnDir) {\n // At the route's own directory: use page.tsx (normal behavior)\n slot.layoutIndex = slotLayoutIdx;\n slotMap.set(slot.key, slot);\n } else {\n // At an ancestor directory: the slot's own page.tsx belongs to the\n // parent route. Look for a mirrored sub-page at @slot/<segments-below>\n // (e.g. @breadcrumbs/about/page.tsx for /about), falling back to\n // default.tsx when no mirror exists. The mirror search also accepts\n // pattern-compatible matches (e.g. slot's [name] for route's [id]) so\n // the runtime can extract slot-specific params via slotPatternParts.\n const mirror = findMirroredSlotPage(slot.ownerDir, segmentsBelow, matcher);\n let slotPatternParts: string[] | undefined;\n let slotParamNames: string[] | undefined;\n if (mirror) {\n const ownerSegments = segments.slice(0, segmentIndex);\n const ownerUrl = convertSegmentsToRouteParts([...ownerSegments]);\n slotPatternParts = [...(ownerUrl?.urlSegments ?? []), ...mirror.slotUrlSegments];\n slotParamNames = [...(ownerUrl?.params ?? []), ...mirror.slotParamNames];\n }\n const inheritedSlot: AppRouteGraphParallelSlot = {\n ...slot,\n pagePath: mirror?.pagePath ?? null,\n layoutIndex: slotLayoutIdx,\n routeSegments: mirror?.segments ?? null,\n slotPatternParts,\n slotParamNames,\n // defaultPath, loadingPath, errorPath, interceptingRoutes remain\n };\n slotMap.set(slot.key, inheritedSlot);\n }\n }\n }\n\n return Array.from(slotMap.values());\n}\n\n/**\n * Look for a page file inside a parallel slot directory that mirrors the\n * route's path below the slot's owner. The match falls through two tiers:\n * 1. Literal filesystem path — fast path when route and slot share shape.\n * 2. Scored pattern compatibility — enumerate sub-pages, accept those\n * whose URL pattern can match the route's URL space (slot dynamic\n * markers may have different names than the route's, and slot\n * catch-alls may subsume the route), and pick the most-specific via\n * `scoreSlotPattern`. Exact URL-parts equality (e.g. through route\n * groups appearing on only one side, like `(marketing)/about` ↔\n * `@breadcrumbs/about`) naturally wins because all literal segments\n * score highest.\n *\n * Returns the slot sub-page's absolute path, its raw filesystem segments\n * (for `routeSegments`), and its URL parts / param names (for\n * `slotPatternParts` / `slotParamNames`). Returns null when no mirror matches.\n */\nfunction findMirroredSlotPage(\n slotDir: string,\n segmentsBelow: readonly string[],\n matcher: ValidFileMatcher,\n): {\n pagePath: string;\n segments: string[];\n slotUrlSegments: string[];\n slotParamNames: string[];\n} | null {\n if (segmentsBelow.length === 0) return null;\n\n // Convert once: both tiers need the URL form of the route's segments below\n // this directory.\n const routeUrl = convertSegmentsToRouteParts([...segmentsBelow]);\n\n // Tier 1: literal filesystem match.\n const literalDir = path.join(slotDir, ...segmentsBelow);\n const literalPage = findFile(literalDir, \"page\", matcher);\n if (literalPage) {\n return {\n pagePath: literalPage,\n segments: [...segmentsBelow],\n slotUrlSegments: routeUrl?.urlSegments ?? [],\n slotParamNames: routeUrl?.params ?? [],\n };\n }\n\n if (!routeUrl || routeUrl.urlSegments.length === 0) return null;\n\n // Tier 2: enumerate slot sub-pages and pick the most-specific compatible\n // pattern. Exact URL-parts matches naturally win the score.\n type Candidate = {\n pagePath: string;\n segments: string[];\n slotUrlSegments: string[];\n slotParamNames: string[];\n score: number;\n };\n let best: Candidate | null = null;\n for (const { relativePath, pagePath } of findSlotSubPages(slotDir, matcher)) {\n const slotSegments = relativePath.split(path.sep);\n const slotUrl = convertSegmentsToRouteParts(slotSegments);\n if (!slotUrl) continue;\n if (!patternsCompatible(slotUrl.urlSegments, routeUrl.urlSegments)) continue;\n const score = scoreSlotPattern(slotUrl.urlSegments);\n if (!best || score > best.score) {\n best = {\n pagePath,\n segments: slotSegments,\n slotUrlSegments: slotUrl.urlSegments,\n slotParamNames: slotUrl.params,\n score,\n };\n }\n }\n\n return best;\n}\n\n/**\n * Whether a slot pattern can match the same URL space as the route's URL\n * parts (where the route's parts are themselves a pattern, since a route\n * file like `[id]/page.tsx` produces `:id`).\n *\n * - `:name+` (catch-all) consumes one-or-more remaining segments.\n * - `:name*` (optional catch-all) consumes zero-or-more.\n * - `:name` (single dynamic) consumes exactly one segment, matching any\n * route segment (literal or dynamic).\n * - Literal slot segments must equal the route's segment exactly; a literal\n * slot segment paired with a dynamic route segment is rejected because we\n * can't know statically whether the runtime value will equal the literal.\n * This also means a literal slot sub-page never matches a catch-all route\n * (e.g. slot `about/page.tsx` is not bound to a route `[...slug]`) — the\n * catch-all might or might not resolve to \"about\" at request time.\n */\nfunction patternsCompatible(slotParts: readonly string[], routeParts: readonly string[]): boolean {\n let i = 0;\n let j = 0;\n while (i < slotParts.length) {\n const sp = slotParts[i];\n if (sp.endsWith(\"+\")) return j < routeParts.length;\n if (sp.endsWith(\"*\")) return true;\n if (j >= routeParts.length) return false;\n const rp = routeParts[j];\n if (sp.startsWith(\":\")) {\n i++;\n j++;\n continue;\n }\n if (rp.startsWith(\":\")) return false;\n if (sp !== rp) return false;\n i++;\n j++;\n }\n return j === routeParts.length;\n}\n\n/**\n * Score a slot pattern by specificity so the most-specific match wins:\n * literal > single dynamic > catch-all > optional catch-all.\n *\n * Required catch-all (`:name+`, ≥1 segment) is more constrained than the\n * optional variant (`:name*`, ≥0 segments), so it scores higher.\n */\nfunction scoreSlotPattern(urlSegments: readonly string[]): number {\n let score = 0;\n for (const seg of urlSegments) {\n if (seg.endsWith(\"*\")) score += 1;\n else if (seg.endsWith(\"+\")) score += 2;\n else if (seg.startsWith(\":\")) score += 3;\n else score += 4;\n }\n return score;\n}\n\n/**\n * Map a pattern segment to the tree-node type used by Next.js' route\n * validator. Two segments are structurally equivalent iff they share the\n * same tree-node type.\n */\nfunction segmentTreeNodeType(seg: string): string {\n if (!seg.startsWith(\":\")) return `literal:${seg}`;\n if (seg.endsWith(\"*\")) return \"optionalCatchAll\";\n if (seg.endsWith(\"+\")) return \"catchAll\";\n return \"dynamic\";\n}\n\nfunction patternsStructurallyEquivalent(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (segmentTreeNodeType(a[i]) !== segmentTreeNodeType(b[i])) return false;\n }\n return true;\n}\n\n/**\n * Discover parallel route slots (@team, @analytics, etc.) in a directory.\n * Returns a ParallelSlot for each @-prefixed subdirectory that has a page or default component.\n */\nfunction discoverParallelSlots(\n dir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n): AppRouteGraphParallelSlot[] {\n if (!fs.existsSync(dir)) return [];\n\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n const slots: AppRouteGraphParallelSlot[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n\n const slotName = entry.name.slice(1); // \"@team\" -> \"team\"\n const slotDir = path.join(dir, entry.name);\n\n const pagePath = findFile(slotDir, \"page\", matcher);\n const defaultPath = findFile(slotDir, \"default\", matcher);\n const interceptingRoutes = discoverInterceptingRoutes(slotDir, dir, appDir, matcher);\n\n // Only include slots that have at least a page, default, or intercepting route\n if (!pagePath && !defaultPath && interceptingRoutes.length === 0) continue;\n\n const ownerSegments = path\n .relative(appDir, dir)\n .split(path.sep)\n .filter((segment) => segment.length > 0);\n const ownerTreePath = createAppRouteGraphTreePath(ownerSegments, ownerSegments.length);\n\n slots.push({\n id: createAppRouteGraphSlotId(slotName, ownerTreePath),\n key: `${slotName}@${path.relative(appDir, slotDir).replace(/\\\\/g, \"/\")}`,\n name: slotName,\n ownerDir: slotDir,\n pagePath,\n defaultPath,\n layoutPath: findFile(slotDir, \"layout\", matcher),\n loadingPath: findFile(slotDir, \"loading\", matcher),\n errorPath: findFile(slotDir, \"error\", matcher),\n interceptingRoutes,\n layoutIndex: -1, // Will be set by discoverInheritedParallelSlots\n routeSegments: pagePath ? [] : null,\n });\n }\n\n return slots;\n}\n\n/**\n * The interception convention prefix patterns.\n * (.) — same level, (..) — one level up, (..)(..)\" — two levels up, (...) — root\n */\nconst INTERCEPT_PATTERNS = [\n { prefix: \"(...)\", convention: \"...\" },\n { prefix: \"(..)(..)\", convention: \"../..\" },\n { prefix: \"(..)\", convention: \"..\" },\n { prefix: \"(.)\", convention: \".\" },\n] as const;\n\n/**\n * Discover intercepting routes inside a parallel slot directory.\n *\n * Intercepting routes use conventions like (.)photo, (..)feed, (...), etc.\n * They intercept navigation to another route and render within the slot instead.\n *\n * @param slotDir - The parallel slot directory (e.g. app/feed/@modal)\n * @param routeDir - The directory of the route that owns this slot (e.g. app/feed)\n * @param appDir - The root app directory\n */\nfunction discoverInterceptingRoutes(\n slotDir: string,\n routeDir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n): InterceptingRoute[] {\n if (!fs.existsSync(slotDir)) return [];\n\n const results: InterceptingRoute[] = [];\n\n // Recursively scan for page files inside intercepting directories\n scanForInterceptingPages(slotDir, routeDir, appDir, results, matcher);\n\n return results;\n}\n\n/**\n * Recursively scan a directory tree for page.tsx files that are inside\n * intercepting route directories.\n */\nfunction scanForInterceptingPages(\n currentDir: string,\n routeDir: string,\n appDir: string,\n results: InterceptingRoute[],\n matcher: ValidFileMatcher,\n): void {\n if (!fs.existsSync(currentDir)) return;\n\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n // Skip private folders (prefixed with _)\n if (entry.name.startsWith(\"_\")) continue;\n\n // Check if this directory name starts with an interception convention\n const interceptMatch = matchInterceptConvention(entry.name);\n\n if (interceptMatch) {\n // This directory is the start of an intercepting route\n // e.g. \"(.)photos\" means intercept same-level \"photos\" route\n const restOfName = entry.name.slice(interceptMatch.prefix.length);\n const interceptDir = path.join(currentDir, entry.name);\n\n // Find page files within this intercepting directory tree\n collectInterceptingPages(\n interceptDir,\n interceptDir,\n interceptMatch.convention,\n restOfName,\n routeDir,\n appDir,\n results,\n matcher,\n );\n } else {\n // Regular subdirectory — keep scanning for intercepting dirs\n scanForInterceptingPages(\n path.join(currentDir, entry.name),\n routeDir,\n appDir,\n results,\n matcher,\n );\n }\n }\n}\n\n/**\n * Match a directory name against interception convention prefixes.\n */\nfunction matchInterceptConvention(name: string): { prefix: string; convention: string } | null {\n for (const pattern of INTERCEPT_PATTERNS) {\n if (name.startsWith(pattern.prefix)) {\n return pattern;\n }\n }\n return null;\n}\n\n/**\n * Collect page.tsx files inside an intercepting route directory tree\n * and compute their target URL patterns.\n */\nfunction collectInterceptingPages(\n currentDir: string,\n interceptRoot: string,\n convention: string,\n interceptSegment: string,\n routeDir: string,\n appDir: string,\n results: InterceptingRoute[],\n matcher: ValidFileMatcher,\n parentLayoutPaths: readonly string[] = [],\n): void {\n const currentLayoutPath = findFile(currentDir, \"layout\", matcher);\n const layoutPaths = currentLayoutPath\n ? [...parentLayoutPaths, currentLayoutPath]\n : parentLayoutPaths;\n\n // Check for page.tsx in current directory\n const page = findFile(currentDir, \"page\", matcher);\n if (page) {\n const targetPattern = computeInterceptTarget(\n convention,\n interceptSegment,\n currentDir,\n interceptRoot,\n routeDir,\n appDir,\n );\n if (targetPattern) {\n results.push({\n convention,\n layoutPaths: [...layoutPaths],\n targetPattern: targetPattern.pattern,\n pagePath: page,\n params: targetPattern.params,\n });\n }\n }\n\n // Recurse into subdirectories for nested intercepting routes\n if (!fs.existsSync(currentDir)) return;\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n // Skip private folders (prefixed with _)\n if (entry.name.startsWith(\"_\")) continue;\n collectInterceptingPages(\n path.join(currentDir, entry.name),\n interceptRoot,\n convention,\n interceptSegment,\n routeDir,\n appDir,\n results,\n matcher,\n layoutPaths,\n );\n }\n}\n\n/**\n * Check whether a path segment is invisible in the URL (route groups, parallel slots, \".\").\n *\n * Used by computeInterceptTarget, convertSegmentsToRouteParts, and\n * hasRemainingVisibleSegments — keep this the single source of truth.\n */\nfunction isInvisibleSegment(segment: string): boolean {\n if (segment === \".\") return true;\n if (segment.startsWith(\"(\") && segment.endsWith(\")\")) return true;\n if (segment.startsWith(\"@\")) return true;\n return false;\n}\n\n/**\n * Compute the target URL pattern for an intercepting route.\n *\n * Interception conventions (..), (..)(..)\" climb by *visible route segments*\n * (not filesystem directories). Route groups like (marketing) and parallel\n * slots like @modal are invisible and must be skipped when counting levels.\n *\n * - (.) same level: resolve relative to routeDir\n * - (..) one level up: climb 1 visible segment\n * - (..)(..) two levels up: climb 2 visible segments\n * - (...) root: resolve from appDir\n */\nfunction computeInterceptTarget(\n convention: string,\n interceptSegment: string,\n currentDir: string,\n interceptRoot: string,\n routeDir: string,\n appDir: string,\n): { pattern: string; params: string[] } | null {\n // Determine the base segments for target resolution.\n // We work on route segments (not filesystem paths) so that route groups\n // and parallel slots are properly skipped when climbing.\n const routeSegments = path.relative(appDir, routeDir).split(path.sep).filter(Boolean);\n\n let baseParts: string[];\n switch (convention) {\n case \".\":\n baseParts = routeSegments;\n break;\n case \"..\":\n case \"../..\": {\n const levelsToClimb = convention === \"..\" ? 1 : 2;\n let climbed = 0;\n let cutIndex = routeSegments.length;\n while (cutIndex > 0 && climbed < levelsToClimb) {\n cutIndex--;\n if (!isInvisibleSegment(routeSegments[cutIndex])) {\n climbed++;\n }\n }\n if (climbed < levelsToClimb) {\n const interceptionRoute = formatInterceptionRoutePath(\n routeSegments,\n convention,\n interceptSegment,\n path.relative(interceptRoot, currentDir).split(path.sep).filter(Boolean),\n );\n if (convention === \"..\") {\n throw new Error(\n `Invalid interception route: ${interceptionRoute}. Cannot use (..) marker at the root level, use (.) instead.`,\n );\n }\n throw new Error(\n `Invalid interception route: ${interceptionRoute}. Cannot use (..)(..) marker at the root level or one level up.`,\n );\n }\n baseParts = routeSegments.slice(0, cutIndex);\n break;\n }\n case \"...\":\n baseParts = [];\n break;\n default:\n return null;\n }\n\n // Add the intercept segment and any nested path segments\n const nestedParts = path.relative(interceptRoot, currentDir).split(path.sep).filter(Boolean);\n const allSegments = [...baseParts, interceptSegment, ...nestedParts];\n\n const convertedTarget = convertSegmentsToRouteParts(allSegments);\n if (!convertedTarget) return null;\n\n const { urlSegments, params } = convertedTarget;\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n return { pattern: pattern === \"/\" ? \"/\" : pattern, params };\n}\n\nfunction formatInterceptionRoutePath(\n routeSegments: string[],\n convention: string,\n interceptSegment: string,\n nestedParts: string[],\n): string {\n const marker = markerForInterceptionConvention(convention);\n const convertedRoute = convertSegmentsToRouteParts(routeSegments);\n const prefix = convertedRoute\n ? convertedRoute.urlSegments\n : routeSegments.filter((segment) => !isInvisibleSegment(segment));\n const routePath = [...prefix, `${marker}${interceptSegment}`, ...nestedParts]\n .filter(Boolean)\n .join(\"/\");\n return routePath ? `/${routePath}` : \"/\";\n}\n\nfunction markerForInterceptionConvention(convention: string): string {\n switch (convention) {\n case \".\":\n return \"(.)\";\n case \"..\":\n return \"(..)\";\n case \"../..\":\n return \"(..)(..)\";\n case \"...\":\n return \"(...)\";\n default:\n return \"\";\n }\n}\n\n/**\n * Find a file by name (without extension) in a directory.\n * Checks configured pageExtensions.\n */\nfunction findFile(dir: string, name: string, matcher: ValidFileMatcher): string | null {\n for (const ext of matcher.dottedExtensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\n}\n\n/**\n * Convert filesystem path segments to URL route parts, skipping invisible segments\n * (route groups, @slots, \".\") and converting dynamic segment syntax to Express-style\n * patterns (e.g. \"[id]\" → \":id\", \"[...slug]\" → \":slug+\").\n */\nfunction convertSegmentsToRouteParts(\n segments: string[],\n): { urlSegments: string[]; params: string[]; isDynamic: boolean } | null {\n const urlSegments: string[] = [];\n const params: string[] = [];\n let isDynamic = false;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n\n if (isInvisibleSegment(segment)) continue;\n\n // Catch-all segments are only valid in terminal URL position.\n // Matches Next.js PARAMETER_PATTERN: any non-] chars inside brackets.\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/utils/get-dynamic-param.ts\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([^\\]]+)\\]$/);\n if (catchAllMatch) {\n if (hasRemainingVisibleSegments(segments, i + 1)) return null;\n // Guard: names ending in + or * would collide with internal pattern\n // modifiers (:name+ catch-all, :name* optional-catch-all).\n if (catchAllMatch[1].endsWith(\"+\") || catchAllMatch[1].endsWith(\"*\")) return null;\n isDynamic = true;\n params.push(catchAllMatch[1]);\n urlSegments.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([^\\]]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n if (hasRemainingVisibleSegments(segments, i + 1)) return null;\n if (optionalCatchAllMatch[1].endsWith(\"+\") || optionalCatchAllMatch[1].endsWith(\"*\"))\n return null;\n isDynamic = true;\n params.push(optionalCatchAllMatch[1]);\n urlSegments.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n\n const dynamicMatch = segment.match(/^\\[([^\\]]+)\\]$/);\n if (dynamicMatch) {\n if (dynamicMatch[1].endsWith(\"+\") || dynamicMatch[1].endsWith(\"*\")) return null;\n isDynamic = true;\n params.push(dynamicMatch[1]);\n urlSegments.push(`:${dynamicMatch[1]}`);\n continue;\n }\n\n urlSegments.push(decodeRouteSegment(segment));\n }\n\n return { urlSegments, params, isDynamic };\n}\n\nfunction hasRemainingVisibleSegments(segments: string[], startIndex: number): boolean {\n for (let i = startIndex; i < segments.length; i++) {\n if (!isInvisibleSegment(segments[i])) return true;\n }\n return false;\n}\n\nfunction joinRoutePattern(basePattern: string, subPath: string): string {\n if (!subPath) return basePattern;\n return basePattern === \"/\" ? `/${subPath}` : `${basePattern}/${subPath}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAqPA,SAAS,2BAA2B,SAAyB;AAC3D,QAAO,SAAS;;AAGlB,SAAS,0BAA0B,SAAyB;AAC1D,QAAO,QAAQ;;AAGjB,SAAS,kCAAkC,SAAyB;AAClE,QAAO,iBAAiB;;AAG1B,SAAS,4BAA4B,UAA0B;AAC7D,QAAO,UAAU;;AAGnB,SAAS,8BAA8B,UAA0B;AAC/D,QAAO,YAAY;;AAGrB,SAAS,0BAA0B,UAAkB,eAA+B;AAClF,QAAO,QAAQ,SAAS,GAAG;;AAG7B,SAAS,kCAAkC,UAAkC;AAC3E,QAAO,iBAAiB;;AAG1B,SAAS,qBAAqB,MAAc,OAAuB;AACjE,KAAI,OAAO,MAAO,QAAO;AACzB,KAAI,OAAO,MAAO,QAAO;AACzB,QAAO;;AAGT,SAAS,gBAAmB,KAAkC;AAC5D,QAAO,MAAM,KAAK,IAAI,SAAS,CAAC,CAC7B,MAAM,CAAC,OAAO,CAAC,WAAW,qBAAqB,MAAM,MAAM,CAAC,CAC5D,KAAK,GAAG,WAAW,MAAM;;AAG9B,SAAS,oBAAoB,QAAsD;CACjF,MAAM,eAAe,yBAAyB,OAAO;AAErD,QAAO;EACL,cAAc,gCAAgC,aAAa;EAC3D;EACD;;AAGH,SAAS,yBAAyB,QAA2D;CAC3F,MAAM,+BAAe,IAAI,KAAiC;CAC1D,MAAM,wBAAQ,IAAI,KAAgC;CAClD,MAAM,gCAAgB,IAAI,KAAwC;CAClE,MAAM,0BAAU,IAAI,KAAkC;CACtD,MAAM,4BAAY,IAAI,KAAoC;CAC1D,MAAM,wBAAQ,IAAI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O,KAAK,cAAc,GAAG;AAC7B,eAAY,KAAK,IAAI,cAAc,GAAG,GAAG;AACzC;;EAGF,MAAM,wBAAwB,QAAQ,MAAM,2BAA2B;AACvE,MAAI,uBAAuB;AACzB,OAAI,4BAA4B,UAAU,IAAI,EAAE,CAAE,QAAO;AACzD,OAAI,sBAAsB,GAAG,SAAS,IAAI,IAAI,sBAAsB,GAAG,SAAS,IAAI,CAClF,QAAO;AACT,eAAY;AACZ,UAAO,KAAK,sBAAsB,GAAG;AACrC,eAAY,KAAK,IAAI,sBAAsB,GAAG,GAAG;AACjD;;EAGF,MAAM,eAAe,QAAQ,MAAM,iBAAiB;AACpD,MAAI,cAAc;AAChB,OAAI,aAAa,GAAG,SAAS,IAAI,IAAI,aAAa,GAAG,SAAS,IAAI,CAAE,QAAO;AAC3E,eAAY;AACZ,UAAO,KAAK,aAAa,GAAG;AAC5B,eAAY,KAAK,IAAI,aAAa,KAAK;AACvC;;AAGF,cAAY,KAAK,mBAAmB,QAAQ,CAAC;;AAG/C,QAAO;EAAE;EAAa;EAAQ;EAAW;;AAG3C,SAAS,4BAA4B,UAAoB,YAA6B;AACpF,MAAK,IAAI,IAAI,YAAY,IAAI,SAAS,QAAQ,IAC5C,KAAI,CAAC,mBAAmB,SAAS,GAAG,CAAE,QAAO;AAE/C,QAAO;;AAGT,SAAS,iBAAiB,aAAqB,SAAyB;AACtE,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,gBAAgB,MAAM,IAAI,YAAY,GAAG,YAAY,GAAG"}
@@ -1,12 +1,24 @@
1
1
  import { ValidFileMatcher } from "./file-matcher.js";
2
- import { AppRoute, computeRootParamNames } from "./app-route-graph.js";
2
+ import { AppRoute, AppRouteGraphRoute, RouteManifest, computeRootParamNames } from "./app-route-graph.js";
3
3
 
4
4
  //#region src/routing/app-router.d.ts
5
+ type AppRouteGraph = {
6
+ routes: AppRouteGraphRoute[];
7
+ routeManifest: RouteManifest;
8
+ };
5
9
  declare function invalidateAppRouteCache(): void;
10
+ /**
11
+ * Scan the app/ directory and return the route graph.
12
+ * TODO(#726): Layer 4 should consume this read model directly once the
13
+ * navigation planner owns route graph facts.
14
+ *
15
+ * @internal
16
+ */
17
+ declare function appRouteGraph(appDir: string, pageExtensions?: readonly string[], matcher?: ValidFileMatcher): Promise<AppRouteGraph>;
6
18
  /**
7
19
  * Scan the app/ directory and return a list of routes.
8
20
  */
9
- declare function appRouter(appDir: string, pageExtensions?: readonly string[], matcher?: ValidFileMatcher): Promise<AppRoute[]>;
21
+ declare function appRouter(appDir: string, pageExtensions?: readonly string[], matcher?: ValidFileMatcher): Promise<AppRouteGraphRoute[]>;
10
22
  /**
11
23
  * Match a URL against App Router routes.
12
24
  */
@@ -15,5 +27,5 @@ declare function matchAppRoute(url: string, routes: AppRoute[]): {
15
27
  params: Record<string, string | string[]>;
16
28
  } | null;
17
29
  //#endregion
18
- export { type AppRoute, appRouter, computeRootParamNames, invalidateAppRouteCache, matchAppRoute };
30
+ export { type AppRoute, appRouteGraph, appRouter, computeRootParamNames, invalidateAppRouteCache, matchAppRoute };
19
31
  //# sourceMappingURL=app-router.d.ts.map
@@ -1,6 +1,5 @@
1
- import { normalizePathnameForRouteMatch } from "./utils.js";
2
1
  import { createValidFileMatcher } from "./file-matcher.js";
3
- import { buildRouteTrie, trieMatch } from "./route-trie.js";
2
+ import { createRouteTrieCache, matchRouteWithTrie } from "./route-matching.js";
4
3
  import { buildAppRouteGraph, computeRootParamNames } from "./app-route-graph.js";
5
4
  //#region src/routing/app-router.ts
6
5
  /**
@@ -18,47 +17,45 @@ import { buildAppRouteGraph, computeRootParamNames } from "./app-route-graph.js"
18
17
  * - Error: app/error.tsx -> ErrorBoundary
19
18
  * - Not Found: app/not-found.tsx
20
19
  */
21
- let cachedRoutes = null;
20
+ let cachedGraph = null;
22
21
  let cachedAppDir = null;
23
22
  let cachedPageExtensionsKey = null;
24
23
  function invalidateAppRouteCache() {
25
- cachedRoutes = null;
24
+ cachedGraph = null;
26
25
  cachedAppDir = null;
27
26
  cachedPageExtensionsKey = null;
28
27
  }
29
28
  /**
30
- * Scan the app/ directory and return a list of routes.
29
+ * Scan the app/ directory and return the route graph.
30
+ * TODO(#726): Layer 4 should consume this read model directly once the
31
+ * navigation planner owns route graph facts.
32
+ *
33
+ * @internal
31
34
  */
32
- async function appRouter(appDir, pageExtensions, matcher) {
35
+ async function appRouteGraph(appDir, pageExtensions, matcher) {
33
36
  matcher ??= createValidFileMatcher(pageExtensions);
34
37
  const pageExtensionsKey = JSON.stringify(matcher.extensions);
35
- if (cachedRoutes && cachedAppDir === appDir && cachedPageExtensionsKey === pageExtensionsKey) return cachedRoutes;
38
+ if (cachedGraph && cachedAppDir === appDir && cachedPageExtensionsKey === pageExtensionsKey) return cachedGraph;
36
39
  const graph = await buildAppRouteGraph(appDir, matcher);
37
- cachedRoutes = graph.routes;
40
+ cachedGraph = graph;
38
41
  cachedAppDir = appDir;
39
42
  cachedPageExtensionsKey = pageExtensionsKey;
40
- return graph.routes;
43
+ return graph;
41
44
  }
42
- const appTrieCache = /* @__PURE__ */ new WeakMap();
43
- function getOrBuildAppTrie(routes) {
44
- let trie = appTrieCache.get(routes);
45
- if (!trie) {
46
- trie = buildRouteTrie(routes);
47
- appTrieCache.set(routes, trie);
48
- }
49
- return trie;
45
+ /**
46
+ * Scan the app/ directory and return a list of routes.
47
+ */
48
+ async function appRouter(appDir, pageExtensions, matcher) {
49
+ return (await appRouteGraph(appDir, pageExtensions, matcher)).routes;
50
50
  }
51
+ const appTrieCache = createRouteTrieCache();
51
52
  /**
52
53
  * Match a URL against App Router routes.
53
54
  */
54
55
  function matchAppRoute(url, routes) {
55
- const pathname = url.split("?")[0];
56
- let normalizedUrl = pathname === "/" ? "/" : pathname.replace(/\/$/, "");
57
- normalizedUrl = normalizePathnameForRouteMatch(normalizedUrl);
58
- const urlParts = normalizedUrl.split("/").filter(Boolean);
59
- return trieMatch(getOrBuildAppTrie(routes), urlParts);
56
+ return matchRouteWithTrie(url, routes, appTrieCache);
60
57
  }
61
58
  //#endregion
62
- export { appRouter, computeRootParamNames, invalidateAppRouteCache, matchAppRoute };
59
+ export { appRouteGraph, appRouter, computeRootParamNames, invalidateAppRouteCache, matchAppRoute };
63
60
 
64
61
  //# sourceMappingURL=app-router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-router.js","names":[],"sources":["../../src/routing/app-router.ts"],"sourcesContent":["/**\n * App Router file-system routing.\n *\n * Scans the app/ directory following Next.js App Router conventions:\n * - app/page.tsx -> /\n * - app/about/page.tsx -> /about\n * - app/blog/[slug]/page.tsx -> /blog/:slug\n * - app/[...catchAll]/page.tsx -> /:catchAll+\n * - app/route.ts -> / (API route)\n * - app/(group)/page.tsx -> / (route groups are transparent)\n * - Layouts: app/layout.tsx wraps all children\n * - Loading: app/loading.tsx -> Suspense fallback\n * - Error: app/error.tsx -> ErrorBoundary\n * - Not Found: app/not-found.tsx\n */\nimport { normalizePathnameForRouteMatch } from \"./utils.js\";\nimport { createValidFileMatcher, type ValidFileMatcher } from \"./file-matcher.js\";\nimport { buildRouteTrie, trieMatch, type TrieNode } from \"./route-trie.js\";\nimport { buildAppRouteGraph, type AppRoute } from \"./app-route-graph.js\";\nexport type { AppRoute } from \"./app-route-graph.js\";\nexport { computeRootParamNames } from \"./app-route-graph.js\";\n\n// Cache for app routes\nlet cachedRoutes: AppRoute[] | null = null;\nlet cachedAppDir: string | null = null;\nlet cachedPageExtensionsKey: string | null = null;\n\nexport function invalidateAppRouteCache(): void {\n cachedRoutes = null;\n cachedAppDir = null;\n cachedPageExtensionsKey = null;\n}\n\n/**\n * Scan the app/ directory and return a list of routes.\n */\nexport async function appRouter(\n appDir: string,\n pageExtensions?: readonly string[],\n matcher?: ValidFileMatcher,\n): Promise<AppRoute[]> {\n matcher ??= createValidFileMatcher(pageExtensions);\n const pageExtensionsKey = JSON.stringify(matcher.extensions);\n if (cachedRoutes && cachedAppDir === appDir && cachedPageExtensionsKey === pageExtensionsKey) {\n return cachedRoutes;\n }\n\n const graph = await buildAppRouteGraph(appDir, matcher);\n cachedRoutes = graph.routes;\n cachedAppDir = appDir;\n cachedPageExtensionsKey = pageExtensionsKey;\n return graph.routes;\n}\n\n// Trie cache keyed by route array identity (same array = same trie)\nconst appTrieCache = new WeakMap<AppRoute[], TrieNode<AppRoute>>();\n\nfunction getOrBuildAppTrie(routes: AppRoute[]): TrieNode<AppRoute> {\n let trie = appTrieCache.get(routes);\n if (!trie) {\n trie = buildRouteTrie(routes);\n appTrieCache.set(routes, trie);\n }\n return trie;\n}\n\n/**\n * Match a URL against App Router routes.\n */\nexport function matchAppRoute(\n url: string,\n routes: AppRoute[],\n): { route: AppRoute; params: Record<string, string | string[]> } | null {\n const pathname = url.split(\"?\")[0];\n let normalizedUrl = pathname === \"/\" ? \"/\" : pathname.replace(/\\/$/, \"\");\n normalizedUrl = normalizePathnameForRouteMatch(normalizedUrl);\n\n // Split URL once, look up via trie\n const urlParts = normalizedUrl.split(\"/\").filter(Boolean);\n const trie = getOrBuildAppTrie(routes);\n return trieMatch(trie, urlParts);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,IAAI,eAAkC;AACtC,IAAI,eAA8B;AAClC,IAAI,0BAAyC;AAE7C,SAAgB,0BAAgC;AAC9C,gBAAe;AACf,gBAAe;AACf,2BAA0B;;;;;AAM5B,eAAsB,UACpB,QACA,gBACA,SACqB;AACrB,aAAY,uBAAuB,eAAe;CAClD,MAAM,oBAAoB,KAAK,UAAU,QAAQ,WAAW;AAC5D,KAAI,gBAAgB,iBAAiB,UAAU,4BAA4B,kBACzE,QAAO;CAGT,MAAM,QAAQ,MAAM,mBAAmB,QAAQ,QAAQ;AACvD,gBAAe,MAAM;AACrB,gBAAe;AACf,2BAA0B;AAC1B,QAAO,MAAM;;AAIf,MAAM,+BAAe,IAAI,SAAyC;AAElE,SAAS,kBAAkB,QAAwC;CACjE,IAAI,OAAO,aAAa,IAAI,OAAO;AACnC,KAAI,CAAC,MAAM;AACT,SAAO,eAAe,OAAO;AAC7B,eAAa,IAAI,QAAQ,KAAK;;AAEhC,QAAO;;;;;AAMT,SAAgB,cACd,KACA,QACuE;CACvE,MAAM,WAAW,IAAI,MAAM,IAAI,CAAC;CAChC,IAAI,gBAAgB,aAAa,MAAM,MAAM,SAAS,QAAQ,OAAO,GAAG;AACxE,iBAAgB,+BAA+B,cAAc;CAG7D,MAAM,WAAW,cAAc,MAAM,IAAI,CAAC,OAAO,QAAQ;AAEzD,QAAO,UADM,kBAAkB,OAAO,EACf,SAAS"}
1
+ {"version":3,"file":"app-router.js","names":[],"sources":["../../src/routing/app-router.ts"],"sourcesContent":["/**\n * App Router file-system routing.\n *\n * Scans the app/ directory following Next.js App Router conventions:\n * - app/page.tsx -> /\n * - app/about/page.tsx -> /about\n * - app/blog/[slug]/page.tsx -> /blog/:slug\n * - app/[...catchAll]/page.tsx -> /:catchAll+\n * - app/route.ts -> / (API route)\n * - app/(group)/page.tsx -> / (route groups are transparent)\n * - Layouts: app/layout.tsx wraps all children\n * - Loading: app/loading.tsx -> Suspense fallback\n * - Error: app/error.tsx -> ErrorBoundary\n * - Not Found: app/not-found.tsx\n */\nimport { createValidFileMatcher, type ValidFileMatcher } from \"./file-matcher.js\";\nimport { createRouteTrieCache, matchRouteWithTrie } from \"./route-matching.js\";\nimport {\n buildAppRouteGraph,\n type AppRoute,\n type AppRouteGraphRoute,\n type RouteManifest,\n} from \"./app-route-graph.js\";\nexport type { AppRoute } from \"./app-route-graph.js\";\nexport { computeRootParamNames } from \"./app-route-graph.js\";\n\ntype AppRouteGraph = {\n routes: AppRouteGraphRoute[];\n routeManifest: RouteManifest;\n};\n\n// Cache for app routes\nlet cachedGraph: AppRouteGraph | null = null;\nlet cachedAppDir: string | null = null;\nlet cachedPageExtensionsKey: string | null = null;\n\nexport function invalidateAppRouteCache(): void {\n cachedGraph = null;\n cachedAppDir = null;\n cachedPageExtensionsKey = null;\n}\n\n/**\n * Scan the app/ directory and return the route graph.\n * TODO(#726): Layer 4 should consume this read model directly once the\n * navigation planner owns route graph facts.\n *\n * @internal\n */\nexport async function appRouteGraph(\n appDir: string,\n pageExtensions?: readonly string[],\n matcher?: ValidFileMatcher,\n): Promise<AppRouteGraph> {\n matcher ??= createValidFileMatcher(pageExtensions);\n const pageExtensionsKey = JSON.stringify(matcher.extensions);\n if (cachedGraph && cachedAppDir === appDir && cachedPageExtensionsKey === pageExtensionsKey) {\n return cachedGraph;\n }\n\n const graph = await buildAppRouteGraph(appDir, matcher);\n cachedGraph = graph;\n cachedAppDir = appDir;\n cachedPageExtensionsKey = pageExtensionsKey;\n return graph;\n}\n\n/**\n * Scan the app/ directory and return a list of routes.\n */\nexport async function appRouter(\n appDir: string,\n pageExtensions?: readonly string[],\n matcher?: ValidFileMatcher,\n): Promise<AppRouteGraphRoute[]> {\n const graph = await appRouteGraph(appDir, pageExtensions, matcher);\n return graph.routes;\n}\n\n// Trie cache — keyed by route array identity (same array = same trie)\nconst appTrieCache = createRouteTrieCache<AppRoute>();\n\n/**\n * Match a URL against App Router routes.\n */\nexport function matchAppRoute(\n url: string,\n routes: AppRoute[],\n): { route: AppRoute; params: Record<string, string | string[]> } | null {\n return matchRouteWithTrie(url, routes, appTrieCache);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCA,IAAI,cAAoC;AACxC,IAAI,eAA8B;AAClC,IAAI,0BAAyC;AAE7C,SAAgB,0BAAgC;AAC9C,eAAc;AACd,gBAAe;AACf,2BAA0B;;;;;;;;;AAU5B,eAAsB,cACpB,QACA,gBACA,SACwB;AACxB,aAAY,uBAAuB,eAAe;CAClD,MAAM,oBAAoB,KAAK,UAAU,QAAQ,WAAW;AAC5D,KAAI,eAAe,iBAAiB,UAAU,4BAA4B,kBACxE,QAAO;CAGT,MAAM,QAAQ,MAAM,mBAAmB,QAAQ,QAAQ;AACvD,eAAc;AACd,gBAAe;AACf,2BAA0B;AAC1B,QAAO;;;;;AAMT,eAAsB,UACpB,QACA,gBACA,SAC+B;AAE/B,SADc,MAAM,cAAc,QAAQ,gBAAgB,QAAQ,EACrD;;AAIf,MAAM,eAAe,sBAAgC;;;;AAKrD,SAAgB,cACd,KACA,QACuE;AACvE,QAAO,mBAAmB,KAAK,QAAQ,aAAa"}
@@ -16,10 +16,12 @@ type ValidFileMatcher = {
16
16
  * packages/next/src/server/lib/find-page-file.ts
17
17
  */
18
18
  declare function createValidFileMatcher(pageExtensions?: readonly string[] | null): ValidFileMatcher;
19
+ /** Check if a file exists with any configured page extension. */
20
+ declare function findFileWithExtensions(basePath: string, matcher: ValidFileMatcher): boolean;
19
21
  /**
20
22
  * Use function-form exclude for Node < 22.14 compatibility.
21
23
  */
22
24
  declare function scanWithExtensions(stem: string, cwd: string, extensions: readonly string[], exclude?: (name: string) => boolean): AsyncGenerator<string>;
23
25
  //#endregion
24
- export { ValidFileMatcher, createValidFileMatcher, normalizePageExtensions, scanWithExtensions };
26
+ export { ValidFileMatcher, createValidFileMatcher, findFileWithExtensions, normalizePageExtensions, scanWithExtensions };
25
27
  //# sourceMappingURL=file-matcher.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { existsSync } from "node:fs";
1
2
  import { glob } from "node:fs/promises";
2
3
  //#region src/routing/file-matcher.ts
3
4
  const DEFAULT_PAGE_EXTENSIONS = [
@@ -59,6 +60,10 @@ function createValidFileMatcher(pageExtensions) {
59
60
  }
60
61
  };
61
62
  }
63
+ /** Check if a file exists with any configured page extension. */
64
+ function findFileWithExtensions(basePath, matcher) {
65
+ return matcher.dottedExtensions.some((ext) => existsSync(basePath + ext));
66
+ }
62
67
  /**
63
68
  * Use function-form exclude for Node < 22.14 compatibility.
64
69
  */
@@ -70,6 +75,6 @@ async function* scanWithExtensions(stem, cwd, extensions, exclude) {
70
75
  })) yield file;
71
76
  }
72
77
  //#endregion
73
- export { createValidFileMatcher, normalizePageExtensions, scanWithExtensions };
78
+ export { createValidFileMatcher, findFileWithExtensions, normalizePageExtensions, scanWithExtensions };
74
79
 
75
80
  //# sourceMappingURL=file-matcher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-matcher.js","names":[],"sources":["../../src/routing/file-matcher.ts"],"sourcesContent":["import { glob } from \"node:fs/promises\";\n\nconst DEFAULT_PAGE_EXTENSIONS = [\"tsx\", \"ts\", \"jsx\", \"js\"] as const;\n\nfunction escapeRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nexport function normalizePageExtensions(pageExtensions?: readonly string[] | null): string[] {\n if (!Array.isArray(pageExtensions) || pageExtensions.length === 0) {\n return [...DEFAULT_PAGE_EXTENSIONS];\n }\n\n const filtered = pageExtensions\n .filter((ext): ext is string => typeof ext === \"string\")\n .map((ext) => ext.trim().replace(/^\\.+/, \"\"))\n .filter((ext) => ext.length > 0);\n return filtered.length > 0 ? [...filtered] : [...DEFAULT_PAGE_EXTENSIONS];\n}\n\nfunction buildExtensionGlob(stem: string, extensions: readonly string[]): string {\n if (extensions.length === 1) {\n return `${stem}.${extensions[0]}`;\n }\n return `${stem}.{${extensions.join(\",\")}}`;\n}\n\nexport type ValidFileMatcher = {\n extensions: string[];\n dottedExtensions: string[];\n extensionRegex: RegExp;\n isPageFile(filePath: string): boolean;\n isAppRouterPage(filePath: string): boolean;\n isAppRouterRoute(filePath: string): boolean;\n isAppLayoutFile(filePath: string): boolean;\n isAppDefaultFile(filePath: string): boolean;\n stripExtension(filePath: string): string;\n};\n\n/**\n * Ported in spirit from Next.js createValidFileMatcher:\n * packages/next/src/server/lib/find-page-file.ts\n */\nexport function createValidFileMatcher(\n pageExtensions?: readonly string[] | null,\n): ValidFileMatcher {\n const extensions = normalizePageExtensions(pageExtensions);\n const dottedExtensions = extensions.map((ext) => `.${ext}`);\n const extPattern = `(?:${extensions.map((ext) => escapeRegex(ext)).join(\"|\")})`;\n\n const extensionRegex = new RegExp(`\\\\.${extPattern}$`);\n const createLeafPattern = (fileNames: readonly string[]): RegExp => {\n const names = fileNames.length === 1 ? fileNames[0] : `(${fileNames.join(\"|\")})`;\n return new RegExp(`(^${names}|[\\\\\\\\/]${names})\\\\.${extPattern}$`);\n };\n\n const appRouterPageRegex = createLeafPattern([\"page\", \"route\"]);\n const appRouterRouteRegex = createLeafPattern([\"route\"]);\n const appLayoutRegex = createLeafPattern([\"layout\"]);\n const appDefaultRegex = createLeafPattern([\"default\"]);\n\n return {\n extensions,\n dottedExtensions,\n extensionRegex,\n isPageFile(filePath: string) {\n return extensionRegex.test(filePath);\n },\n isAppRouterPage(filePath: string) {\n return appRouterPageRegex.test(filePath);\n },\n isAppRouterRoute(filePath: string) {\n return appRouterRouteRegex.test(filePath);\n },\n isAppLayoutFile(filePath: string) {\n return appLayoutRegex.test(filePath);\n },\n isAppDefaultFile(filePath: string) {\n return appDefaultRegex.test(filePath);\n },\n stripExtension(filePath: string) {\n return filePath.replace(extensionRegex, \"\");\n },\n };\n}\n\n/**\n * Use function-form exclude for Node < 22.14 compatibility.\n */\nexport async function* scanWithExtensions(\n stem: string,\n cwd: string,\n extensions: readonly string[],\n exclude?: (name: string) => boolean,\n): AsyncGenerator<string> {\n const pattern = buildExtensionGlob(stem, extensions);\n for await (const file of glob(pattern, {\n cwd,\n ...(exclude ? { exclude } : {}),\n })) {\n yield file;\n }\n}\n"],"mappings":";;AAEA,MAAM,0BAA0B;CAAC;CAAO;CAAM;CAAO;CAAK;AAE1D,SAAS,YAAY,OAAuB;AAC1C,QAAO,MAAM,QAAQ,uBAAuB,OAAO;;AAGrD,SAAgB,wBAAwB,gBAAqD;AAC3F,KAAI,CAAC,MAAM,QAAQ,eAAe,IAAI,eAAe,WAAW,EAC9D,QAAO,CAAC,GAAG,wBAAwB;CAGrC,MAAM,WAAW,eACd,QAAQ,QAAuB,OAAO,QAAQ,SAAS,CACvD,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,QAAQ,GAAG,CAAC,CAC5C,QAAQ,QAAQ,IAAI,SAAS,EAAE;AAClC,QAAO,SAAS,SAAS,IAAI,CAAC,GAA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A,SACwB;CACxB,MAAM,UAAU,mBAAmB,MAAM,WAAW;AACpD,YAAW,MAAM,QAAQ,KAAK,SAAS;EACrC;EACA,GAAI,UAAU,EAAE,SAAS,GAAG,EAAE;EAC/B,CAAC,CACA,OAAM"}
1
+ {"version":3,"file":"file-matcher.js","names":[],"sources":["../../src/routing/file-matcher.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { glob } from \"node:fs/promises\";\n\nconst DEFAULT_PAGE_EXTENSIONS = [\"tsx\", \"ts\", \"jsx\", \"js\"] as const;\n\nfunction escapeRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nexport function normalizePageExtensions(pageExtensions?: readonly string[] | null): string[] {\n if (!Array.isArray(pageExtensions) || pageExtensions.length === 0) {\n return [...DEFAULT_PAGE_EXTENSIONS];\n }\n\n const filtered = pageExtensions\n .filter((ext): ext is string => typeof ext === \"string\")\n .map((ext) => ext.trim().replace(/^\\.+/, \"\"))\n .filter((ext) => ext.length > 0);\n return filtered.length > 0 ? [...filtered] : [...DEFAULT_PAGE_EXTENSIONS];\n}\n\nfunction buildExtensionGlob(stem: string, extensions: readonly string[]): string {\n if (extensions.length === 1) {\n return `${stem}.${extensions[0]}`;\n }\n return `${stem}.{${extensions.join(\",\")}}`;\n}\n\nexport type ValidFileMatcher = {\n extensions: string[];\n dottedExtensions: string[];\n extensionRegex: RegExp;\n isPageFile(filePath: string): boolean;\n isAppRouterPage(filePath: string): boolean;\n isAppRouterRoute(filePath: string): boolean;\n isAppLayoutFile(filePath: string): boolean;\n isAppDefaultFile(filePath: string): boolean;\n stripExtension(filePath: string): string;\n};\n\n/**\n * Ported in spirit from Next.js createValidFileMatcher:\n * packages/next/src/server/lib/find-page-file.ts\n */\nexport function createValidFileMatcher(\n pageExtensions?: readonly string[] | null,\n): ValidFileMatcher {\n const extensions = normalizePageExtensions(pageExtensions);\n const dottedExtensions = extensions.map((ext) => `.${ext}`);\n const extPattern = `(?:${extensions.map((ext) => escapeRegex(ext)).join(\"|\")})`;\n\n const extensionRegex = new RegExp(`\\\\.${extPattern}$`);\n const createLeafPattern = (fileNames: readonly string[]): RegExp => {\n const names = fileNames.length === 1 ? fileNames[0] : `(${fileNames.join(\"|\")})`;\n return new RegExp(`(^${names}|[\\\\\\\\/]${names})\\\\.${extPattern}$`);\n };\n\n const appRouterPageRegex = createLeafPattern([\"page\", \"route\"]);\n const appRouterRouteRegex = createLeafPattern([\"route\"]);\n const appLayoutRegex = createLeafPattern([\"layout\"]);\n const appDefaultRegex = createLeafPattern([\"default\"]);\n\n return {\n extensions,\n dottedExtensions,\n extensionRegex,\n isPageFile(filePath: string) {\n return extensionRegex.test(filePath);\n },\n isAppRouterPage(filePath: string) {\n return appRouterPageRegex.test(filePath);\n },\n isAppRouterRoute(filePath: string) {\n return appRouterRouteRegex.test(filePath);\n },\n isAppLayoutFile(filePath: string) {\n return appLayoutRegex.test(filePath);\n },\n isAppDefaultFile(filePath: string) {\n return appDefaultRegex.test(filePath);\n },\n stripExtension(filePath: string) {\n return filePath.replace(extensionRegex, \"\");\n },\n };\n}\n\n/** Check if a file exists with any configured page extension. */\nexport function findFileWithExtensions(basePath: string, matcher: ValidFileMatcher): boolean {\n return matcher.dottedExtensions.some((ext) => existsSync(basePath + ext));\n}\n\n/**\n * Use function-form exclude for Node < 22.14 compatibility.\n */\nexport async function* scanWithExtensions(\n stem: string,\n cwd: string,\n extensions: readonly string[],\n exclude?: (name: string) => boolean,\n): AsyncGenerator<string> {\n const pattern = buildExtensionGlob(stem, extensions);\n for await (const file of glob(pattern, {\n cwd,\n ...(exclude ? { exclude } : {}),\n })) {\n yield file;\n }\n}\n"],"mappings":";;;AAGA,MAAM,0BAA0B;CAAC;CAAO;CAAM;CAAO;CAAK;AAE1D,SAAS,YAAY,OAAuB;AAC1C,QAAO,MAAM,QAAQ,uBAAuB,OAAO;;AAGrD,SAAgB,wBAAwB,gBAAqD;AAC3F,KAAI,CAAC,MAAM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