vinext 0.0.21 → 0.0.22

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 (51) hide show
  1. package/dist/deploy.d.ts.map +1 -1
  2. package/dist/deploy.js +6 -3
  3. package/dist/deploy.js.map +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +179 -10
  6. package/dist/index.js.map +1 -1
  7. package/dist/routing/app-router.d.ts.map +1 -1
  8. package/dist/routing/app-router.js +1 -41
  9. package/dist/routing/app-router.js.map +1 -1
  10. package/dist/routing/pages-router.d.ts.map +1 -1
  11. package/dist/routing/pages-router.js +1 -27
  12. package/dist/routing/pages-router.js.map +1 -1
  13. package/dist/routing/utils.d.ts +25 -0
  14. package/dist/routing/utils.d.ts.map +1 -0
  15. package/dist/routing/utils.js +70 -0
  16. package/dist/routing/utils.js.map +1 -0
  17. package/dist/server/app-dev-server.d.ts.map +1 -1
  18. package/dist/server/app-dev-server.js +70 -3
  19. package/dist/server/app-dev-server.js.map +1 -1
  20. package/dist/server/dev-server.d.ts.map +1 -1
  21. package/dist/server/dev-server.js +77 -4
  22. package/dist/server/dev-server.js.map +1 -1
  23. package/dist/server/prod-server.d.ts.map +1 -1
  24. package/dist/server/prod-server.js +7 -0
  25. package/dist/server/prod-server.js.map +1 -1
  26. package/dist/server/request-log.d.ts +34 -0
  27. package/dist/server/request-log.d.ts.map +1 -0
  28. package/dist/server/request-log.js +65 -0
  29. package/dist/server/request-log.js.map +1 -0
  30. package/dist/shims/cache-runtime.d.ts.map +1 -1
  31. package/dist/shims/cache-runtime.js +5 -1
  32. package/dist/shims/cache-runtime.js.map +1 -1
  33. package/dist/shims/cache.d.ts +6 -0
  34. package/dist/shims/cache.d.ts.map +1 -1
  35. package/dist/shims/cache.js +22 -2
  36. package/dist/shims/cache.js.map +1 -1
  37. package/dist/shims/head.d.ts +11 -0
  38. package/dist/shims/head.d.ts.map +1 -1
  39. package/dist/shims/head.js +21 -0
  40. package/dist/shims/head.js.map +1 -1
  41. package/dist/shims/headers.d.ts +8 -0
  42. package/dist/shims/headers.d.ts.map +1 -1
  43. package/dist/shims/headers.js +41 -0
  44. package/dist/shims/headers.js.map +1 -1
  45. package/dist/shims/script.d.ts.map +1 -1
  46. package/dist/shims/script.js +7 -1
  47. package/dist/shims/script.js.map +1 -1
  48. package/dist/shims/server.d.ts.map +1 -1
  49. package/dist/shims/server.js +2 -1
  50. package/dist/shims/server.js.map +1 -1
  51. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"app-router.d.ts","sourceRoot":"","sources":["../../src/routing/app-router.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,uDAAuD;IACvD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,wEAAwE;IACxE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oDAAoD;IACpD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kDAAkD;IAClD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,2CAA2C;IAC3C,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yDAAyD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CAAC;IACpC,mEAAmE;IACnE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;;OAKG;IACH,aAAa,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IACjC,qCAAqC;IACrC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;;;OAMG;IACH,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAMD,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoCnE;AA+yBD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,QAAQ,EAAE,GACjB;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;CAAE,GAAG,IAAI,CAiBvE"}
@@ -16,6 +16,7 @@
16
16
  import path from "node:path";
17
17
  import fs from "node:fs";
18
18
  import { glob } from "node:fs/promises";
19
+ import { routePrecedence } from "./utils.js";
19
20
  // Cache for app routes
20
21
  let cachedRoutes = null;
21
22
  let cachedAppDir = null;
@@ -768,45 +769,4 @@ function matchPattern(url, pattern) {
768
769
  return null;
769
770
  return params;
770
771
  }
771
- /**
772
- * Route precedence — lower score is higher priority.
773
- * Matches Next.js specificity rules:
774
- * 1. Static routes first (scored by segment count, more = more specific)
775
- * 2. Dynamic segments penalized by position
776
- * 3. Catch-all comes after dynamic
777
- * 4. Optional catch-all last
778
- * 5. Lexicographic tiebreaker for determinism
779
- *
780
- * Key insight: routes with static prefix segments should have higher priority
781
- * than catch-all routes without them. E.g., /_sites/:subdomain/:slug* should
782
- * match before /:slug* because "_sites" must match exactly.
783
- */
784
- function routePrecedence(pattern) {
785
- const parts = pattern.split("/").filter(Boolean);
786
- let score = 0;
787
- let staticPrefixCount = 0;
788
- // Count static prefix segments (before first dynamic/catch-all)
789
- for (const p of parts) {
790
- if (p.startsWith(":") || p.endsWith("+") || p.endsWith("*"))
791
- break;
792
- staticPrefixCount++;
793
- }
794
- // Static prefix segments dramatically reduce score (increase priority).
795
- // Each static prefix segment gives -10000 priority boost.
796
- score -= staticPrefixCount * 10000;
797
- for (let i = 0; i < parts.length; i++) {
798
- const p = parts[i];
799
- if (p.endsWith("+")) {
800
- score += 1000 + i; // catch-all: moderate penalty
801
- }
802
- else if (p.endsWith("*")) {
803
- score += 2000 + i; // optional catch-all: high penalty
804
- }
805
- else if (p.startsWith(":")) {
806
- score += 100 + i; // dynamic: small penalty by position
807
- }
808
- // static segments after first dynamic don't contribute extra
809
- }
810
- return score;
811
- }
812
772
  //# sourceMappingURL=app-router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-router.js","sourceRoot":"","sources":["../../src/routing/app-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAwFxC,uBAAuB;AACvB,IAAI,YAAY,GAAsB,IAAI,CAAC;AAC3C,IAAI,YAAY,GAAkB,IAAI,CAAC;AAEvC,MAAM,UAAU,uBAAuB;IACrC,YAAY,GAAG,IAAI,CAAC;IACpB,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc;IAC5C,IAAI,YAAY,IAAI,YAAY,KAAK,MAAM;QAAE,OAAO,YAAY,CAAC;IAEjE,oEAAoE;I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AAC,OAAO,CAAC,CAAC;IACjD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAE1B,gEAAgE;IAChE,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,MAAM;QACnE,iBAAiB,EAAE,CAAC;IACtB,CAAC;IAED,wEAAwE;IACxE,0DAA0D;IAC1D,KAAK,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACpB,KAAK,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,8BAA8B;QACnD,CAAC;aAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,KAAK,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,mCAAmC;QACxD,CAAC;aAAM,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,qCAAqC;QACzD,CAAC;QACD,6DAA6D;IAC/D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","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 path from \"node:path\";\nimport fs from \"node:fs\";\nimport { glob } from \"node:fs/promises\";\n\nexport interface 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 /** Parameter names for dynamic segments */\n params: string[];\n}\n\nexport interface ParallelSlot {\n /** Slot name (e.g. \"team\" from @team) */\n name: 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\nexport interface 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 template files from root to leaf (parallel to 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 /** Forbidden component path (403) */\n forbiddenPath: string | null;\n /** Unauthorized component path (401) */\n unauthorizedPath: string | null;\n /**\n * URL segment depth for each layout in the layouts array.\n * Used by useSelectedLayoutSegments() to determine which segments are\n * below a given layout. For example, root layout has depth 0, a layout\n * at app/dashboard/ has depth 1 (one URL segment: \"dashboard\").\n * Route groups and parallel slots don't contribute to the depth.\n */\n layoutSegmentDepths: number[];\n /** Whether this is a dynamic route */\n isDynamic: boolean;\n /** Parameter names for dynamic segments */\n params: string[];\n}\n\n// Cache for app routes\nlet cachedRoutes: AppRoute[] | null = null;\nlet cachedAppDir: string | null = null;\n\nexport function invalidateAppRouteCache(): void {\n cachedRoutes = null;\n cachedAppDir = null;\n}\n\n/**\n * Scan the app/ directory and return a list of routes.\n */\nexport async function appRouter(appDir: string): Promise<AppRoute[]> {\n if (cachedRoutes && cachedAppDir === appDir) return cachedRoutes;\n\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 const routes: AppRoute[] = [];\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 glob(\"**/page.{tsx,ts,jsx,js}\", { cwd: appDir, exclude: (name: string) => name.startsWith(\"@\") })) {\n const route = fileToAppRoute(file, appDir, \"page\");\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 glob(\"**/route.{tsx,ts,jsx,js}\", { cwd: appDir, exclude: (name: string) => name.startsWith(\"@\") })) {\n const route = fileToAppRoute(file, appDir, \"route\");\n if (route) routes.push(route);\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, appDir);\n routes.push(...slotSubRoutes);\n\n // Sort: static routes first, then dynamic, then catch-all\n routes.sort((a, b) => {\n const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);\n return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);\n });\n\n cachedRoutes = routes;\n cachedAppDir = appDir;\n return routes;\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: AppRoute[],\n _appDir: string,\n): AppRoute[] {\n const syntheticRoutes: AppRoute[] = [];\n const existingPatterns = new Set(routes.map((r) => r.pattern));\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: relative sub-path (e.g., \"demographics\") -> Map<slotName, pagePath>\n const subPathMap = new Map<string, Map<string, string>>();\n\n for (const slot of parentRoute.parallelSlots) {\n const slotDir = path.join(parentPageDir, `@${slot.name}`);\n if (!fs.existsSync(slotDir)) continue;\n\n const subPages = findSlotSubPages(slotDir);\n for (const { relativePath, pagePath } of subPages) {\n if (!subPathMap.has(relativePath)) {\n subPathMap.set(relativePath, new Map());\n }\n subPathMap.get(relativePath)!.set(slot.name, 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\");\n\n for (const [subPath, slotPages] of subPathMap) {\n // Convert sub-path segments to URL pattern parts\n const subSegments = subPath.split(path.sep);\n const urlParts: string[] = [];\n const subParams: string[] = [];\n let subIsDynamic = false;\n\n for (const seg of subSegments) {\n // Route groups are transparent\n if (seg.startsWith(\"(\") && seg.endsWith(\")\")) continue;\n\n const catchAllMatch = seg.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n subIsDynamic = true;\n subParams.push(catchAllMatch[1]);\n urlParts.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n const optionalCatchAllMatch = seg.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n subIsDynamic = true;\n subParams.push(optionalCatchAllMatch[1]);\n urlParts.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n const dynamicMatch = seg.match(/^\\[([\\w-]+)\\]$/);\n if (dynamicMatch) {\n subIsDynamic = true;\n subParams.push(dynamicMatch[1]);\n urlParts.push(`:${dynamicMatch[1]}`);\n continue;\n }\n\n urlParts.push(seg);\n }\n\n const subUrlPath = urlParts.join(\"/\");\n const pattern =\n parentRoute.pattern === \"/\"\n ? \"/\" + subUrlPath\n : parentRoute.pattern + \"/\" + subUrlPath;\n\n // Skip if this pattern already exists as a regular route\n if (existingPatterns.has(pattern)) continue;\n if (syntheticRoutes.some((r) => r.pattern === pattern)) 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: ParallelSlot[] = parentRoute.parallelSlots.map(\n (slot) => ({\n ...slot,\n pagePath: slotPages.get(slot.name) || null,\n }),\n );\n\n syntheticRoutes.push({\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 forbiddenPath: parentRoute.forbiddenPath,\n unauthorizedPath: parentRoute.unauthorizedPath,\n layoutSegmentDepths: parentRoute.layoutSegmentDepths,\n isDynamic: parentRoute.isDynamic || subIsDynamic,\n params: [...parentRoute.params, ...subParams],\n });\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 */\nfunction findSlotSubPages(\n slotDir: string,\n): Array<{ relativePath: string; pagePath: string }> {\n const results: Array<{ relativePath: string; pagePath: string }> = [];\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\");\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 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): AppRoute | null {\n // Remove the filename (page.tsx or route.ts)\n const dir = path.dirname(file);\n const segments = dir === \".\" ? [] : dir.split(path.sep);\n\n const params: string[] = [];\n let isDynamic = false;\n\n // Convert segments to URL pattern, stripping route groups and parallel slots\n const urlSegments: string[] = [];\n for (const segment of segments) {\n // Route groups: (group) -> skip (transparent in URL)\n if (segment.startsWith(\"(\") && segment.endsWith(\")\")) {\n continue;\n }\n\n // Parallel slots: @slot -> skip (invisible in URL, content passed as layout props)\n if (segment.startsWith(\"@\")) {\n continue;\n }\n\n // Catch-all: [...slug] (param names may contain hyphens, e.g. [...sign-in])\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n isDynamic = true;\n params.push(catchAllMatch[1]);\n urlSegments.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n\n // Optional catch-all: [[...slug]] (param names may contain hyphens, e.g. [[...sign-in]])\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n isDynamic = true;\n params.push(optionalCatchAllMatch[1]);\n urlSegments.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n\n // Dynamic segment: [id] (param names may contain hyphens, e.g. [my-param])\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 try {\n urlSegments.push(decodeURIComponent(segment));\n } catch {\n urlSegments.push(segment);\n }\n }\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n\n // Discover layouts and templates from root to leaf\n const layouts = discoverLayouts(segments, appDir);\n const templates = discoverTemplates(segments, appDir);\n\n // Compute the URL segment depth for each layout.\n // Each layout corresponds to a directory level. We need to count how many\n // of the filesystem segments up to that layout's level contribute URL segments\n // (i.e., are not route groups or parallel slots).\n const layoutSegmentDepths = computeLayoutSegmentDepths(\n segments,\n appDir,\n layouts,\n );\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);\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\");\n const errorPath = findFile(routeDir, \"error\");\n\n // Discover not-found/forbidden/unauthorized: walk from route directory up to root (nearest wins).\n const notFoundPath = discoverBoundaryFile(segments, appDir, \"not-found\");\n const forbiddenPath = discoverBoundaryFile(segments, appDir, \"forbidden\");\n const unauthorizedPath = discoverBoundaryFile(\n segments,\n appDir,\n \"unauthorized\",\n );\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\");\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(\n segments,\n appDir,\n routeDir,\n );\n\n return {\n pattern: pattern === \"/\" ? \"/\" : pattern,\n pagePath: type === \"page\" ? path.join(appDir, file) : null,\n routePath: type === \"route\" ? path.join(appDir, file) : null,\n layouts,\n templates,\n parallelSlots,\n loadingPath,\n errorPath,\n layoutErrorPaths,\n notFoundPath,\n notFoundPaths,\n forbiddenPath,\n unauthorizedPath,\n layoutSegmentDepths,\n isDynamic,\n params,\n };\n}\n\n/**\n * Compute the URL segment depth for each layout in the layouts array.\n * Root layout = 0, then each directory level that contributes a URL segment\n * increments the depth. Route groups and parallel slots don't contribute.\n */\nfunction computeLayoutSegmentDepths(\n segments: string[],\n appDir: string,\n layouts: string[],\n): number[] {\n // Build a map: layout file path → depth in URL segments\n // Walk the segments directory-by-directory, tracking cumulative URL depth\n const depthMap = new Map<string, number>();\n\n // Root layout (at appDir) always has depth 0\n const rootLayout = findFile(appDir, \"layout\");\n if (rootLayout) depthMap.set(rootLayout, 0);\n\n let urlDepth = 0;\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n\n // Count URL-visible segments (skip route groups and parallel slots)\n const isRouteGroup = segment.startsWith(\"(\") && segment.endsWith(\")\");\n const isParallelSlot = segment.startsWith(\"@\");\n if (!isRouteGroup && !isParallelSlot) {\n urlDepth++;\n }\n\n const layout = findFile(currentDir, \"layout\");\n if (layout) {\n depthMap.set(layout, urlDepth);\n }\n }\n\n // Map the ordered layouts array to their depths\n return layouts.map((layoutPath) => depthMap.get(layoutPath) ?? 0);\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): string[] {\n const layouts: string[] = [];\n\n // Check root layout\n const rootLayout = findFile(appDir, \"layout\");\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\");\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(segments: string[], appDir: string): string[] {\n const templates: string[] = [];\n\n // Check root template\n const rootTemplate = findFile(appDir, \"template\");\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\");\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): (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\");\n if (rootLayout) {\n errors.push(findFile(appDir, \"error\"));\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\");\n if (layout) {\n errors.push(findFile(currentDir, \"error\"));\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): 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);\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): (string | null)[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n return findFile(layoutDir, fileName);\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): 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 let currentDir = appDir;\n const dirsToCheck: { dir: string; layoutIdx: number }[] = [];\n let layoutIdx = findFile(appDir, \"layout\") ? 0 : -1;\n dirsToCheck.push({ dir: appDir, layoutIdx: Math.max(layoutIdx, 0) });\n\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n if (findFile(currentDir, \"layout\")) {\n layoutIdx++;\n }\n dirsToCheck.push({ dir: currentDir, layoutIdx: Math.max(layoutIdx, 0) });\n }\n\n for (const { dir, layoutIdx: lvlLayoutIdx } of dirsToCheck) {\n const isOwnDir = dir === routeDir;\n const slotsAtLevel = discoverParallelSlots(dir, appDir);\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 = lvlLayoutIdx;\n slotMap.set(slot.name, slot);\n } else {\n // At an ancestor directory: use default.tsx as the page, not page.tsx\n // (the slot's page.tsx is for the parent route, not this child route)\n const inheritedSlot: ParallelSlot = {\n ...slot,\n pagePath: null, // Don't use ancestor's page.tsx\n layoutIndex: lvlLayoutIdx,\n // defaultPath, loadingPath, errorPath, interceptingRoutes remain\n };\n // Only inherit if we haven't seen this slot at a closer level\n if (!slotMap.has(slot.name)) {\n slotMap.set(slot.name, inheritedSlot);\n }\n }\n }\n }\n\n return Array.from(slotMap.values());\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(dir: string, appDir: string): 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\");\n const defaultPath = findFile(slotDir, \"default\");\n const interceptingRoutes = discoverInterceptingRoutes(slotDir, dir, appDir);\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 name: slotName,\n pagePath,\n defaultPath,\n layoutPath: findFile(slotDir, \"layout\"),\n loadingPath: findFile(slotDir, \"loading\"),\n errorPath: findFile(slotDir, \"error\"),\n interceptingRoutes,\n layoutIndex: -1, // Will be set by discoverInheritedParallelSlots\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): 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);\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): 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\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 );\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 );\n }\n }\n}\n\n/**\n * Match a directory name against interception convention prefixes.\n */\nfunction matchInterceptConvention(\n name: string,\n): { 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): void {\n // Check for page.tsx in current directory\n const page = findFile(currentDir, \"page\");\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 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 collectInterceptingPages(\n path.join(currentDir, entry.name),\n interceptRoot,\n convention,\n interceptSegment,\n routeDir,\n appDir,\n results,\n );\n }\n}\n\n/**\n * Compute the target URL pattern for an intercepting route.\n *\n * - (.) same level: resolve relative to routeDir\n * - (..) one level up: resolve relative to parent of routeDir\n * - (..)(..)\" two levels up: resolve relative to grandparent of routeDir\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 directory for target resolution\n let baseDir: string;\n switch (convention) {\n case \".\":\n baseDir = routeDir;\n break;\n case \"..\":\n baseDir = path.dirname(routeDir);\n break;\n case \"../..\":\n baseDir = path.dirname(path.dirname(routeDir));\n break;\n case \"...\":\n baseDir = appDir;\n break;\n default:\n return null;\n }\n\n // Build the target URL segments from baseDir relative to appDir\n const baseParts = path\n .relative(appDir, baseDir)\n .split(path.sep)\n .filter(Boolean);\n\n // Add the intercept segment and any nested path segments\n const nestedParts = path\n .relative(interceptRoot, currentDir)\n .split(path.sep)\n .filter(Boolean);\n const allSegments = [...baseParts, interceptSegment, ...nestedParts];\n\n // Convert segments to URL pattern\n const urlSegments: string[] = [];\n const params: string[] = [];\n\n for (const segment of allSegments) {\n if (segment === \".\") continue;\n // Route groups and @ slots are transparent\n if (segment.startsWith(\"(\") && segment.endsWith(\")\")) continue;\n if (segment.startsWith(\"@\")) continue;\n\n // Dynamic segments\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n params.push(catchAllMatch[1]);\n urlSegments.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n params.push(optionalCatchAllMatch[1]);\n urlSegments.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n const dynamicMatch = segment.match(/^\\[([\\w-]+)\\]$/);\n if (dynamicMatch) {\n params.push(dynamicMatch[1]);\n urlSegments.push(`:${dynamicMatch[1]}`);\n continue;\n }\n\n // Decode URL-encoded directory names (e.g., %5Fsites -> _sites)\n try {\n urlSegments.push(decodeURIComponent(segment));\n } catch {\n urlSegments.push(segment);\n }\n }\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n return { pattern: pattern === \"/\" ? \"/\" : pattern, params };\n}\n\n/**\n * Find a file by name (without extension) in a directory.\n * Checks .tsx, .ts, .jsx, .js extensions.\n */\nfunction findFile(dir: string, name: string): string | null {\n const extensions = [\".tsx\", \".ts\", \".jsx\", \".js\"];\n for (const ext of extensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\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 try {\n normalizedUrl = decodeURIComponent(normalizedUrl);\n } catch {\n /* malformed percent-encoding — match as-is */\n }\n\n for (const route of routes) {\n const params = matchPattern(normalizedUrl, route.pattern);\n if (params !== null) {\n return { route, params };\n }\n }\n\n return null;\n}\n\nfunction matchPattern(\n url: string,\n pattern: string,\n): Record<string, string | string[]> | null {\n const urlParts = url.split(\"/\").filter(Boolean);\n const patternParts = pattern.split(\"/\").filter(Boolean);\n\n const params: Record<string, string | string[]> = Object.create(null);\n\n for (let i = 0; i < patternParts.length; i++) {\n const pp = patternParts[i];\n\n if (pp.endsWith(\"+\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n if (remaining.length === 0) return null;\n params[paramName] = remaining;\n return params;\n }\n\n if (pp.endsWith(\"*\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n params[paramName] = remaining;\n return params;\n }\n\n if (pp.startsWith(\":\")) {\n const paramName = pp.slice(1);\n if (i >= urlParts.length) return null;\n params[paramName] = urlParts[i];\n continue;\n }\n\n if (i >= urlParts.length || urlParts[i] !== pp) return null;\n }\n\n if (urlParts.length !== patternParts.length) return null;\n\n return params;\n}\n\n/**\n * Route precedence — lower score is higher priority.\n * Matches Next.js specificity rules:\n * 1. Static routes first (scored by segment count, more = more specific)\n * 2. Dynamic segments penalized by position\n * 3. Catch-all comes after dynamic\n * 4. Optional catch-all last\n * 5. Lexicographic tiebreaker for determinism\n *\n * Key insight: routes with static prefix segments should have higher priority\n * than catch-all routes without them. E.g., /_sites/:subdomain/:slug* should\n * match before /:slug* because \"_sites\" must match exactly.\n */\nfunction routePrecedence(pattern: string): number {\n const parts = pattern.split(\"/\").filter(Boolean);\n let score = 0;\n let staticPrefixCount = 0;\n\n // Count static prefix segments (before first dynamic/catch-all)\n for (const p of parts) {\n if (p.startsWith(\":\") || p.endsWith(\"+\") || p.endsWith(\"*\")) break;\n staticPrefixCount++;\n }\n\n // Static prefix segments dramatically reduce score (increase priority).\n // Each static prefix segment gives -10000 priority boost.\n score -= staticPrefixCount * 10000;\n\n for (let i = 0; i < parts.length; i++) {\n const p = parts[i];\n if (p.endsWith(\"+\")) {\n score += 1000 + i; // catch-all: moderate penalty\n } else if (p.endsWith(\"*\")) {\n score += 2000 + i; // optional catch-all: high penalty\n } else if (p.startsWith(\":\")) {\n score += 100 + i; // dynamic: small penalty by position\n }\n // static segments after first dynamic don't contribute extra\n }\n return score;\n}\n"]}
1
+ {"version":3,"file":"app-router.js","sourceRoot":"","sources":["../../src/routing/app-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAwF7C,uBAAuB;AACvB,IAAI,YAAY,GAAsB,IAAI,CAAC;AAC3C,IAAI,YAAY,GAAkB,IAAI,CAAC;AAEvC,MAAM,UAAU,uBAAuB;IACrC,YAAY,GAAG,IAAI,CAAC;IACpB,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc;IAC5C,IAAI,YAAY,IAA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/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 path from \"node:path\";\nimport fs from \"node:fs\";\nimport { glob } from \"node:fs/promises\";\nimport { routePrecedence } from \"./utils.js\";\n\nexport interface 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 /** Parameter names for dynamic segments */\n params: string[];\n}\n\nexport interface ParallelSlot {\n /** Slot name (e.g. \"team\" from @team) */\n name: 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\nexport interface 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 template files from root to leaf (parallel to 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 /** Forbidden component path (403) */\n forbiddenPath: string | null;\n /** Unauthorized component path (401) */\n unauthorizedPath: string | null;\n /**\n * URL segment depth for each layout in the layouts array.\n * Used by useSelectedLayoutSegments() to determine which segments are\n * below a given layout. For example, root layout has depth 0, a layout\n * at app/dashboard/ has depth 1 (one URL segment: \"dashboard\").\n * Route groups and parallel slots don't contribute to the depth.\n */\n layoutSegmentDepths: number[];\n /** Whether this is a dynamic route */\n isDynamic: boolean;\n /** Parameter names for dynamic segments */\n params: string[];\n}\n\n// Cache for app routes\nlet cachedRoutes: AppRoute[] | null = null;\nlet cachedAppDir: string | null = null;\n\nexport function invalidateAppRouteCache(): void {\n cachedRoutes = null;\n cachedAppDir = null;\n}\n\n/**\n * Scan the app/ directory and return a list of routes.\n */\nexport async function appRouter(appDir: string): Promise<AppRoute[]> {\n if (cachedRoutes && cachedAppDir === appDir) return cachedRoutes;\n\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 const routes: AppRoute[] = [];\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 glob(\"**/page.{tsx,ts,jsx,js}\", { cwd: appDir, exclude: (name: string) => name.startsWith(\"@\") })) {\n const route = fileToAppRoute(file, appDir, \"page\");\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 glob(\"**/route.{tsx,ts,jsx,js}\", { cwd: appDir, exclude: (name: string) => name.startsWith(\"@\") })) {\n const route = fileToAppRoute(file, appDir, \"route\");\n if (route) routes.push(route);\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, appDir);\n routes.push(...slotSubRoutes);\n\n // Sort: static routes first, then dynamic, then catch-all\n routes.sort((a, b) => {\n const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);\n return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);\n });\n\n cachedRoutes = routes;\n cachedAppDir = appDir;\n return routes;\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: AppRoute[],\n _appDir: string,\n): AppRoute[] {\n const syntheticRoutes: AppRoute[] = [];\n const existingPatterns = new Set(routes.map((r) => r.pattern));\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: relative sub-path (e.g., \"demographics\") -> Map<slotName, pagePath>\n const subPathMap = new Map<string, Map<string, string>>();\n\n for (const slot of parentRoute.parallelSlots) {\n const slotDir = path.join(parentPageDir, `@${slot.name}`);\n if (!fs.existsSync(slotDir)) continue;\n\n const subPages = findSlotSubPages(slotDir);\n for (const { relativePath, pagePath } of subPages) {\n if (!subPathMap.has(relativePath)) {\n subPathMap.set(relativePath, new Map());\n }\n subPathMap.get(relativePath)!.set(slot.name, 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\");\n\n for (const [subPath, slotPages] of subPathMap) {\n // Convert sub-path segments to URL pattern parts\n const subSegments = subPath.split(path.sep);\n const urlParts: string[] = [];\n const subParams: string[] = [];\n let subIsDynamic = false;\n\n for (const seg of subSegments) {\n // Route groups are transparent\n if (seg.startsWith(\"(\") && seg.endsWith(\")\")) continue;\n\n const catchAllMatch = seg.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n subIsDynamic = true;\n subParams.push(catchAllMatch[1]);\n urlParts.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n const optionalCatchAllMatch = seg.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n subIsDynamic = true;\n subParams.push(optionalCatchAllMatch[1]);\n urlParts.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n const dynamicMatch = seg.match(/^\\[([\\w-]+)\\]$/);\n if (dynamicMatch) {\n subIsDynamic = true;\n subParams.push(dynamicMatch[1]);\n urlParts.push(`:${dynamicMatch[1]}`);\n continue;\n }\n\n urlParts.push(seg);\n }\n\n const subUrlPath = urlParts.join(\"/\");\n const pattern =\n parentRoute.pattern === \"/\"\n ? \"/\" + subUrlPath\n : parentRoute.pattern + \"/\" + subUrlPath;\n\n // Skip if this pattern already exists as a regular route\n if (existingPatterns.has(pattern)) continue;\n if (syntheticRoutes.some((r) => r.pattern === pattern)) 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: ParallelSlot[] = parentRoute.parallelSlots.map(\n (slot) => ({\n ...slot,\n pagePath: slotPages.get(slot.name) || null,\n }),\n );\n\n syntheticRoutes.push({\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 forbiddenPath: parentRoute.forbiddenPath,\n unauthorizedPath: parentRoute.unauthorizedPath,\n layoutSegmentDepths: parentRoute.layoutSegmentDepths,\n isDynamic: parentRoute.isDynamic || subIsDynamic,\n params: [...parentRoute.params, ...subParams],\n });\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 */\nfunction findSlotSubPages(\n slotDir: string,\n): Array<{ relativePath: string; pagePath: string }> {\n const results: Array<{ relativePath: string; pagePath: string }> = [];\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\");\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 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): AppRoute | null {\n // Remove the filename (page.tsx or route.ts)\n const dir = path.dirname(file);\n const segments = dir === \".\" ? [] : dir.split(path.sep);\n\n const params: string[] = [];\n let isDynamic = false;\n\n // Convert segments to URL pattern, stripping route groups and parallel slots\n const urlSegments: string[] = [];\n for (const segment of segments) {\n // Route groups: (group) -> skip (transparent in URL)\n if (segment.startsWith(\"(\") && segment.endsWith(\")\")) {\n continue;\n }\n\n // Parallel slots: @slot -> skip (invisible in URL, content passed as layout props)\n if (segment.startsWith(\"@\")) {\n continue;\n }\n\n // Catch-all: [...slug] (param names may contain hyphens, e.g. [...sign-in])\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n isDynamic = true;\n params.push(catchAllMatch[1]);\n urlSegments.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n\n // Optional catch-all: [[...slug]] (param names may contain hyphens, e.g. [[...sign-in]])\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n isDynamic = true;\n params.push(optionalCatchAllMatch[1]);\n urlSegments.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n\n // Dynamic segment: [id] (param names may contain hyphens, e.g. [my-param])\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 try {\n urlSegments.push(decodeURIComponent(segment));\n } catch {\n urlSegments.push(segment);\n }\n }\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n\n // Discover layouts and templates from root to leaf\n const layouts = discoverLayouts(segments, appDir);\n const templates = discoverTemplates(segments, appDir);\n\n // Compute the URL segment depth for each layout.\n // Each layout corresponds to a directory level. We need to count how many\n // of the filesystem segments up to that layout's level contribute URL segments\n // (i.e., are not route groups or parallel slots).\n const layoutSegmentDepths = computeLayoutSegmentDepths(\n segments,\n appDir,\n layouts,\n );\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);\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\");\n const errorPath = findFile(routeDir, \"error\");\n\n // Discover not-found/forbidden/unauthorized: walk from route directory up to root (nearest wins).\n const notFoundPath = discoverBoundaryFile(segments, appDir, \"not-found\");\n const forbiddenPath = discoverBoundaryFile(segments, appDir, \"forbidden\");\n const unauthorizedPath = discoverBoundaryFile(\n segments,\n appDir,\n \"unauthorized\",\n );\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\");\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(\n segments,\n appDir,\n routeDir,\n );\n\n return {\n pattern: pattern === \"/\" ? \"/\" : pattern,\n pagePath: type === \"page\" ? path.join(appDir, file) : null,\n routePath: type === \"route\" ? path.join(appDir, file) : null,\n layouts,\n templates,\n parallelSlots,\n loadingPath,\n errorPath,\n layoutErrorPaths,\n notFoundPath,\n notFoundPaths,\n forbiddenPath,\n unauthorizedPath,\n layoutSegmentDepths,\n isDynamic,\n params,\n };\n}\n\n/**\n * Compute the URL segment depth for each layout in the layouts array.\n * Root layout = 0, then each directory level that contributes a URL segment\n * increments the depth. Route groups and parallel slots don't contribute.\n */\nfunction computeLayoutSegmentDepths(\n segments: string[],\n appDir: string,\n layouts: string[],\n): number[] {\n // Build a map: layout file path → depth in URL segments\n // Walk the segments directory-by-directory, tracking cumulative URL depth\n const depthMap = new Map<string, number>();\n\n // Root layout (at appDir) always has depth 0\n const rootLayout = findFile(appDir, \"layout\");\n if (rootLayout) depthMap.set(rootLayout, 0);\n\n let urlDepth = 0;\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n\n // Count URL-visible segments (skip route groups and parallel slots)\n const isRouteGroup = segment.startsWith(\"(\") && segment.endsWith(\")\");\n const isParallelSlot = segment.startsWith(\"@\");\n if (!isRouteGroup && !isParallelSlot) {\n urlDepth++;\n }\n\n const layout = findFile(currentDir, \"layout\");\n if (layout) {\n depthMap.set(layout, urlDepth);\n }\n }\n\n // Map the ordered layouts array to their depths\n return layouts.map((layoutPath) => depthMap.get(layoutPath) ?? 0);\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): string[] {\n const layouts: string[] = [];\n\n // Check root layout\n const rootLayout = findFile(appDir, \"layout\");\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\");\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(segments: string[], appDir: string): string[] {\n const templates: string[] = [];\n\n // Check root template\n const rootTemplate = findFile(appDir, \"template\");\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\");\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): (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\");\n if (rootLayout) {\n errors.push(findFile(appDir, \"error\"));\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\");\n if (layout) {\n errors.push(findFile(currentDir, \"error\"));\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): 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);\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): (string | null)[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n return findFile(layoutDir, fileName);\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): 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 let currentDir = appDir;\n const dirsToCheck: { dir: string; layoutIdx: number }[] = [];\n let layoutIdx = findFile(appDir, \"layout\") ? 0 : -1;\n dirsToCheck.push({ dir: appDir, layoutIdx: Math.max(layoutIdx, 0) });\n\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n if (findFile(currentDir, \"layout\")) {\n layoutIdx++;\n }\n dirsToCheck.push({ dir: currentDir, layoutIdx: Math.max(layoutIdx, 0) });\n }\n\n for (const { dir, layoutIdx: lvlLayoutIdx } of dirsToCheck) {\n const isOwnDir = dir === routeDir;\n const slotsAtLevel = discoverParallelSlots(dir, appDir);\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 = lvlLayoutIdx;\n slotMap.set(slot.name, slot);\n } else {\n // At an ancestor directory: use default.tsx as the page, not page.tsx\n // (the slot's page.tsx is for the parent route, not this child route)\n const inheritedSlot: ParallelSlot = {\n ...slot,\n pagePath: null, // Don't use ancestor's page.tsx\n layoutIndex: lvlLayoutIdx,\n // defaultPath, loadingPath, errorPath, interceptingRoutes remain\n };\n // Only inherit if we haven't seen this slot at a closer level\n if (!slotMap.has(slot.name)) {\n slotMap.set(slot.name, inheritedSlot);\n }\n }\n }\n }\n\n return Array.from(slotMap.values());\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(dir: string, appDir: string): 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\");\n const defaultPath = findFile(slotDir, \"default\");\n const interceptingRoutes = discoverInterceptingRoutes(slotDir, dir, appDir);\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 name: slotName,\n pagePath,\n defaultPath,\n layoutPath: findFile(slotDir, \"layout\"),\n loadingPath: findFile(slotDir, \"loading\"),\n errorPath: findFile(slotDir, \"error\"),\n interceptingRoutes,\n layoutIndex: -1, // Will be set by discoverInheritedParallelSlots\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): 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);\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): 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\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 );\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 );\n }\n }\n}\n\n/**\n * Match a directory name against interception convention prefixes.\n */\nfunction matchInterceptConvention(\n name: string,\n): { 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): void {\n // Check for page.tsx in current directory\n const page = findFile(currentDir, \"page\");\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 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 collectInterceptingPages(\n path.join(currentDir, entry.name),\n interceptRoot,\n convention,\n interceptSegment,\n routeDir,\n appDir,\n results,\n );\n }\n}\n\n/**\n * Compute the target URL pattern for an intercepting route.\n *\n * - (.) same level: resolve relative to routeDir\n * - (..) one level up: resolve relative to parent of routeDir\n * - (..)(..)\" two levels up: resolve relative to grandparent of routeDir\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 directory for target resolution\n let baseDir: string;\n switch (convention) {\n case \".\":\n baseDir = routeDir;\n break;\n case \"..\":\n baseDir = path.dirname(routeDir);\n break;\n case \"../..\":\n baseDir = path.dirname(path.dirname(routeDir));\n break;\n case \"...\":\n baseDir = appDir;\n break;\n default:\n return null;\n }\n\n // Build the target URL segments from baseDir relative to appDir\n const baseParts = path\n .relative(appDir, baseDir)\n .split(path.sep)\n .filter(Boolean);\n\n // Add the intercept segment and any nested path segments\n const nestedParts = path\n .relative(interceptRoot, currentDir)\n .split(path.sep)\n .filter(Boolean);\n const allSegments = [...baseParts, interceptSegment, ...nestedParts];\n\n // Convert segments to URL pattern\n const urlSegments: string[] = [];\n const params: string[] = [];\n\n for (const segment of allSegments) {\n if (segment === \".\") continue;\n // Route groups and @ slots are transparent\n if (segment.startsWith(\"(\") && segment.endsWith(\")\")) continue;\n if (segment.startsWith(\"@\")) continue;\n\n // Dynamic segments\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n params.push(catchAllMatch[1]);\n urlSegments.push(`:${catchAllMatch[1]}+`);\n continue;\n }\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n params.push(optionalCatchAllMatch[1]);\n urlSegments.push(`:${optionalCatchAllMatch[1]}*`);\n continue;\n }\n const dynamicMatch = segment.match(/^\\[([\\w-]+)\\]$/);\n if (dynamicMatch) {\n params.push(dynamicMatch[1]);\n urlSegments.push(`:${dynamicMatch[1]}`);\n continue;\n }\n\n // Decode URL-encoded directory names (e.g., %5Fsites -> _sites)\n try {\n urlSegments.push(decodeURIComponent(segment));\n } catch {\n urlSegments.push(segment);\n }\n }\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n return { pattern: pattern === \"/\" ? \"/\" : pattern, params };\n}\n\n/**\n * Find a file by name (without extension) in a directory.\n * Checks .tsx, .ts, .jsx, .js extensions.\n */\nfunction findFile(dir: string, name: string): string | null {\n const extensions = [\".tsx\", \".ts\", \".jsx\", \".js\"];\n for (const ext of extensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\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 try {\n normalizedUrl = decodeURIComponent(normalizedUrl);\n } catch {\n /* malformed percent-encoding — match as-is */\n }\n\n for (const route of routes) {\n const params = matchPattern(normalizedUrl, route.pattern);\n if (params !== null) {\n return { route, params };\n }\n }\n\n return null;\n}\n\nfunction matchPattern(\n url: string,\n pattern: string,\n): Record<string, string | string[]> | null {\n const urlParts = url.split(\"/\").filter(Boolean);\n const patternParts = pattern.split(\"/\").filter(Boolean);\n\n const params: Record<string, string | string[]> = Object.create(null);\n\n for (let i = 0; i < patternParts.length; i++) {\n const pp = patternParts[i];\n\n if (pp.endsWith(\"+\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n if (remaining.length === 0) return null;\n params[paramName] = remaining;\n return params;\n }\n\n if (pp.endsWith(\"*\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n params[paramName] = remaining;\n return params;\n }\n\n if (pp.startsWith(\":\")) {\n const paramName = pp.slice(1);\n if (i >= urlParts.length) return null;\n params[paramName] = urlParts[i];\n continue;\n }\n\n if (i >= urlParts.length || urlParts[i] !== pp) return null;\n }\n\n if (urlParts.length !== patternParts.length) return null;\n\n return params;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pages-router.d.ts","sourceRoot":"","sources":["../../src/routing/pages-router.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,KAAK;IACpB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAKD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAG3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAUpE;AAwGD;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,KAAK,EAAE,GACd;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;CAAE,GAAG,IAAI,CAepE;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAUlE;AAgFD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK3D"}
1
+ {"version":3,"file":"pages-router.d.ts","sourceRoot":"","sources":["../../src/routing/pages-router.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,KAAK;IACpB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAKD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAG3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAUpE;AA8ED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,KAAK,EAAE,GACd;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;CAAE,GAAG,IAAI,CAepE;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAUlE;AAgFD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK3D"}
@@ -1,5 +1,6 @@
1
1
  import { glob } from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { routePrecedence } from "./utils.js";
3
4
  // Route cache — invalidated when pages directory changes
4
5
  const routeCache = new Map();
5
6
  /**
@@ -96,33 +97,6 @@ function fileToRoute(file, pagesDir) {
96
97
  params,
97
98
  };
98
99
  }
99
- /**
100
- * Route precedence — lower score is higher priority.
101
- * Matches Next.js specificity rules:
102
- * 1. Static routes first (scored by segment count, more = more specific)
103
- * 2. Dynamic segments penalized by position
104
- * 3. Catch-all comes after dynamic
105
- * 4. Optional catch-all last
106
- * 5. Lexicographic tiebreaker for determinism
107
- */
108
- function routePrecedence(pattern) {
109
- const parts = pattern.split("/").filter(Boolean);
110
- let score = 0;
111
- for (let i = 0; i < parts.length; i++) {
112
- const p = parts[i];
113
- if (p.endsWith("+")) {
114
- score += 10000 + i; // catch-all: high penalty
115
- }
116
- else if (p.endsWith("*")) {
117
- score += 20000 + i; // optional catch-all: highest penalty
118
- }
119
- else if (p.startsWith(":")) {
120
- score += 100 + i; // dynamic: moderate penalty by position
121
- }
122
- // static segments contribute nothing (better specificity)
123
- }
124
- return score;
125
- }
126
100
  /**
127
101
  * Match a URL path against a route pattern.
128
102
  * Returns the matched params or null if no match.
@@ -1 +1 @@
1
- {"version":3,"file":"pages-router.js","sourceRoot":"","sources":["../../src/routing/pages-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAa7B,yDAAyD;AACzD,MAAM,UAAU,GAAG,IAAI,GAAG,EAA0D,CAAC;AAErF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,UAAU,CAAC,MAAM,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;IACvC,UAAU,CAAC,MAAM,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAgB;IAChD,MAAM,QAAQ,GAAG,SAAS,QAAQ,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IAElC,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;IAC7B,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,QAAgB;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,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,OAAO;SACX,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,CAAG,2CAA2C;SAClF,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAK,gCAAgC;SACvE,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAU,sBAAsB;AACnE,CAAC","sourcesContent":["import { glob } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport interface Route {\n /** URL pattern, e.g. \"/\" or \"/about\" or \"/posts/:id\" */\n pattern: string;\n /** Absolute file path to the page component */\n filePath: string;\n /** Whether this is a dynamic route */\n isDynamic: boolean;\n /** Parameter names for dynamic segments */\n params: string[];\n}\n\n// Route cache — invalidated when pages directory changes\nconst routeCache = new Map<string, { routes: Route[]; promise: Promise<Route[]> }>();\n\n/**\n * Invalidate cached routes for a given pages directory.\n * Called by the file watcher when pages are added/removed.\n */\nexport function invalidateRouteCache(pagesDir: string): void {\n routeCache.delete(`pages:${pagesDir}`);\n routeCache.delete(`api:${pagesDir}`);\n}\n\n/**\n * Scan the pages/ directory and return a list of routes.\n * Results are cached — call invalidateRouteCache() when files change.\n *\n * Follows Next.js Pages Router conventions:\n * - pages/index.tsx -> /\n * - pages/about.tsx -> /about\n * - pages/posts/[id].tsx -> /posts/:id\n * - pages/[...slug].tsx -> /:slug+\n * - Ignores _app.tsx, _document.tsx, _error.tsx, files starting with _\n * - Ignores pages/api/ (handled separately later)\n */\nexport async function pagesRouter(pagesDir: string): Promise<Route[]> {\n const cacheKey = `pages:${pagesDir}`;\n const cached = routeCache.get(cacheKey);\n if (cached) return cached.promise;\n\n const promise = scanPageRoutes(pagesDir);\n routeCache.set(cacheKey, { routes: [], promise });\n const routes = await promise;\n routeCache.set(cacheKey, { routes, promise });\n return routes;\n}\n\nasync function scanPageRoutes(pagesDir: string): Promise<Route[]> {\n const routes: Route[] = [];\n\n // Use function form of exclude for Node < 22.14 compatibility (string arrays require >= 22.14)\n for await (const file of glob(\"**/*.{tsx,ts,jsx,js}\", { cwd: pagesDir, exclude: (name: string) => name === \"api\" || name.startsWith(\"_\") })) {\n const route = fileToRoute(file, pagesDir);\n if (route) routes.push(route);\n }\n\n // Sort: static routes first, then dynamic, then catch-all\n routes.sort((a, b) => {\n const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);\n return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);\n });\n\n return routes;\n}\n\n/**\n * Convert a file path relative to pages/ into a Route.\n */\nfunction fileToRoute(file: string, pagesDir: string): Route | null {\n // Remove extension\n const withoutExt = file.replace(/\\.(tsx?|jsx?)$/, \"\");\n\n // Convert to URL segments\n const segments = withoutExt.split(path.sep);\n\n // Handle index files: pages/index.tsx -> /\n const lastSegment = segments[segments.length - 1];\n if (lastSegment === \"index\") {\n segments.pop();\n }\n\n const params: string[] = [];\n let isDynamic = false;\n\n // Convert Next.js dynamic segments to URL patterns\n const urlSegments = segments.map((segment) => {\n // Catch-all: [...slug] -> :slug+ (param names may contain hyphens)\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n isDynamic = true;\n params.push(catchAllMatch[1]);\n return `:${catchAllMatch[1]}+`;\n }\n\n // Optional catch-all: [[...slug]] -> :slug* (param names may contain hyphens)\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n isDynamic = true;\n params.push(optionalCatchAllMatch[1]);\n return `:${optionalCatchAllMatch[1]}*`;\n }\n\n // Dynamic segment: [id] -> :id (param names may contain hyphens)\n const dynamicMatch = segment.match(/^\\[([\\w-]+)\\]$/);\n if (dynamicMatch) {\n isDynamic = true;\n params.push(dynamicMatch[1]);\n return `:${dynamicMatch[1]}`;\n }\n\n return segment;\n });\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n\n return {\n pattern: pattern === \"/\" ? \"/\" : pattern,\n filePath: path.join(pagesDir, file),\n isDynamic,\n params,\n };\n}\n\n/**\n * Route precedence — lower score is higher priority.\n * Matches Next.js specificity rules:\n * 1. Static routes first (scored by segment count, more = more specific)\n * 2. Dynamic segments penalized by position\n * 3. Catch-all comes after dynamic\n * 4. Optional catch-all last\n * 5. Lexicographic tiebreaker for determinism\n */\nfunction routePrecedence(pattern: string): number {\n const parts = pattern.split(\"/\").filter(Boolean);\n let score = 0;\n for (let i = 0; i < parts.length; i++) {\n const p = parts[i];\n if (p.endsWith(\"+\")) {\n score += 10000 + i; // catch-all: high penalty\n } else if (p.endsWith(\"*\")) {\n score += 20000 + i; // optional catch-all: highest penalty\n } else if (p.startsWith(\":\")) {\n score += 100 + i; // dynamic: moderate penalty by position\n }\n // static segments contribute nothing (better specificity)\n }\n return score;\n}\n\n/**\n * Match a URL path against a route pattern.\n * Returns the matched params or null if no match.\n */\nexport function matchRoute(\n url: string,\n routes: Route[],\n): { route: Route; params: Record<string, string | string[]> } | null {\n // Normalize: strip query string and trailing slash\n const pathname = url.split(\"?\")[0];\n let normalizedUrl =\n pathname === \"/\" ? \"/\" : pathname.replace(/\\/$/, \"\");\n try { normalizedUrl = decodeURIComponent(normalizedUrl); } catch { /* malformed percent-encoding — match as-is */ }\n\n for (const route of routes) {\n const params = matchPattern(normalizedUrl, route.pattern);\n if (params !== null) {\n return { route, params };\n }\n }\n\n return null;\n}\n\n/**\n * Scan the pages/api/ directory and return API routes.\n * Results are cached — call invalidateRouteCache() when files change.\n *\n * Follows Next.js conventions:\n * - pages/api/hello.ts -> /api/hello\n * - pages/api/users/[id].ts -> /api/users/:id\n */\nexport async function apiRouter(pagesDir: string): Promise<Route[]> {\n const cacheKey = `api:${pagesDir}`;\n const cached = routeCache.get(cacheKey);\n if (cached) return cached.promise;\n\n const promise = scanApiRoutes(pagesDir);\n routeCache.set(cacheKey, { routes: [], promise });\n const routes = await promise;\n routeCache.set(cacheKey, { routes, promise });\n return routes;\n}\n\nasync function scanApiRoutes(pagesDir: string): Promise<Route[]> {\n const apiDir = path.join(pagesDir, \"api\");\n let files: string[];\n try {\n files = [];\n for await (const file of glob(\"**/*.{ts,tsx,js,jsx}\", { cwd: apiDir })) {\n files.push(file);\n }\n } catch {\n files = [];\n }\n\n const routes: Route[] = [];\n\n for (const file of files) {\n // Reuse fileToRoute but pretend the file is under a virtual \"api/\" prefix\n const route = fileToRoute(path.join(\"api\", file), pagesDir);\n if (route) {\n routes.push(route);\n }\n }\n\n // Sort same as page routes\n routes.sort((a, b) => {\n const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);\n return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);\n });\n\n return routes;\n}\n\nfunction matchPattern(\n url: string,\n pattern: string,\n): Record<string, string | string[]> | null {\n const urlParts = url.split(\"/\").filter(Boolean);\n const patternParts = pattern.split(\"/\").filter(Boolean);\n\n const params: Record<string, string | string[]> = Object.create(null);\n\n for (let i = 0; i < patternParts.length; i++) {\n const pp = patternParts[i];\n\n // Catch-all: :slug+\n if (pp.endsWith(\"+\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n if (remaining.length === 0) return null;\n params[paramName] = remaining;\n return params;\n }\n\n // Optional catch-all: :slug*\n if (pp.endsWith(\"*\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n params[paramName] = remaining;\n return params;\n }\n\n // Dynamic segment: :id\n if (pp.startsWith(\":\")) {\n const paramName = pp.slice(1);\n if (i >= urlParts.length) return null;\n params[paramName] = urlParts[i];\n continue;\n }\n\n // Static segment\n if (i >= urlParts.length || urlParts[i] !== pp) return null;\n }\n\n // All pattern parts matched - check url doesn't have extra segments\n if (urlParts.length !== patternParts.length) return null;\n\n return params;\n}\n\n/**\n * Convert internal route pattern (e.g., \"/posts/:id\", \"/docs/:slug+\")\n * to Next.js bracket format (e.g., \"/posts/[id]\", \"/docs/[...slug]\").\n * Used for __NEXT_DATA__.page which apps expect in Next.js format.\n */\nexport function patternToNextFormat(pattern: string): string {\n return pattern\n .replace(/:([\\w-]+)\\*/g, \"[[...$1]]\") // optional catch-all :slug* -> [[...slug]]\n .replace(/:([\\w-]+)\\+/g, \"[...$1]\") // catch-all :slug+ -> [...slug]\n .replace(/:([\\w-]+)/g, \"[$1]\"); // dynamic :id -> [id]\n}\n"]}
1
+ {"version":3,"file":"pages-router.js","sourceRoot":"","sources":["../../src/routing/pages-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAa7C,yDAAyD;AACzD,MAAM,UAAU,GAAG,IAAI,GAAG,EAA0D,CAAC;AAErF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,UAAU,CAAC,MAAM,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;IACvC,UAAU,CAAC,MAAM,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAgB;IAChD,MAAM,QAAQ,GAAG,SAAS,QAAQ,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IAElC,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IACzC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;IAC7B,UAAU,CAAC,GAAG,CAAC,QAAQ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,CAAC,CAAC;YACpC,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;YAC9B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,uBAAuB;QACvB,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAC;YACtC,MAAM,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChC,SAAS;QACX,CAAC;QAED,iBAAiB;QACjB,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;IAC9D,CAAC;IAED,oEAAoE;IACpE,IAAI,QAAQ,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,OAAO;SACX,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,CAAG,2CAA2C;SAClF,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAK,gCAAgC;SACvE,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAU,sBAAsB;AACnE,CAAC","sourcesContent":["import { glob } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { routePrecedence } from \"./utils.js\";\n\nexport interface Route {\n /** URL pattern, e.g. \"/\" or \"/about\" or \"/posts/:id\" */\n pattern: string;\n /** Absolute file path to the page component */\n filePath: string;\n /** Whether this is a dynamic route */\n isDynamic: boolean;\n /** Parameter names for dynamic segments */\n params: string[];\n}\n\n// Route cache — invalidated when pages directory changes\nconst routeCache = new Map<string, { routes: Route[]; promise: Promise<Route[]> }>();\n\n/**\n * Invalidate cached routes for a given pages directory.\n * Called by the file watcher when pages are added/removed.\n */\nexport function invalidateRouteCache(pagesDir: string): void {\n routeCache.delete(`pages:${pagesDir}`);\n routeCache.delete(`api:${pagesDir}`);\n}\n\n/**\n * Scan the pages/ directory and return a list of routes.\n * Results are cached — call invalidateRouteCache() when files change.\n *\n * Follows Next.js Pages Router conventions:\n * - pages/index.tsx -> /\n * - pages/about.tsx -> /about\n * - pages/posts/[id].tsx -> /posts/:id\n * - pages/[...slug].tsx -> /:slug+\n * - Ignores _app.tsx, _document.tsx, _error.tsx, files starting with _\n * - Ignores pages/api/ (handled separately later)\n */\nexport async function pagesRouter(pagesDir: string): Promise<Route[]> {\n const cacheKey = `pages:${pagesDir}`;\n const cached = routeCache.get(cacheKey);\n if (cached) return cached.promise;\n\n const promise = scanPageRoutes(pagesDir);\n routeCache.set(cacheKey, { routes: [], promise });\n const routes = await promise;\n routeCache.set(cacheKey, { routes, promise });\n return routes;\n}\n\nasync function scanPageRoutes(pagesDir: string): Promise<Route[]> {\n const routes: Route[] = [];\n\n // Use function form of exclude for Node < 22.14 compatibility (string arrays require >= 22.14)\n for await (const file of glob(\"**/*.{tsx,ts,jsx,js}\", { cwd: pagesDir, exclude: (name: string) => name === \"api\" || name.startsWith(\"_\") })) {\n const route = fileToRoute(file, pagesDir);\n if (route) routes.push(route);\n }\n\n // Sort: static routes first, then dynamic, then catch-all\n routes.sort((a, b) => {\n const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);\n return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);\n });\n\n return routes;\n}\n\n/**\n * Convert a file path relative to pages/ into a Route.\n */\nfunction fileToRoute(file: string, pagesDir: string): Route | null {\n // Remove extension\n const withoutExt = file.replace(/\\.(tsx?|jsx?)$/, \"\");\n\n // Convert to URL segments\n const segments = withoutExt.split(path.sep);\n\n // Handle index files: pages/index.tsx -> /\n const lastSegment = segments[segments.length - 1];\n if (lastSegment === \"index\") {\n segments.pop();\n }\n\n const params: string[] = [];\n let isDynamic = false;\n\n // Convert Next.js dynamic segments to URL patterns\n const urlSegments = segments.map((segment) => {\n // Catch-all: [...slug] -> :slug+ (param names may contain hyphens)\n const catchAllMatch = segment.match(/^\\[\\.\\.\\.([\\w-]+)\\]$/);\n if (catchAllMatch) {\n isDynamic = true;\n params.push(catchAllMatch[1]);\n return `:${catchAllMatch[1]}+`;\n }\n\n // Optional catch-all: [[...slug]] -> :slug* (param names may contain hyphens)\n const optionalCatchAllMatch = segment.match(/^\\[\\[\\.\\.\\.([\\w-]+)\\]\\]$/);\n if (optionalCatchAllMatch) {\n isDynamic = true;\n params.push(optionalCatchAllMatch[1]);\n return `:${optionalCatchAllMatch[1]}*`;\n }\n\n // Dynamic segment: [id] -> :id (param names may contain hyphens)\n const dynamicMatch = segment.match(/^\\[([\\w-]+)\\]$/);\n if (dynamicMatch) {\n isDynamic = true;\n params.push(dynamicMatch[1]);\n return `:${dynamicMatch[1]}`;\n }\n\n return segment;\n });\n\n const pattern = \"/\" + urlSegments.join(\"/\");\n\n return {\n pattern: pattern === \"/\" ? \"/\" : pattern,\n filePath: path.join(pagesDir, file),\n isDynamic,\n params,\n };\n}\n\n/**\n * Match a URL path against a route pattern.\n * Returns the matched params or null if no match.\n */\nexport function matchRoute(\n url: string,\n routes: Route[],\n): { route: Route; params: Record<string, string | string[]> } | null {\n // Normalize: strip query string and trailing slash\n const pathname = url.split(\"?\")[0];\n let normalizedUrl =\n pathname === \"/\" ? \"/\" : pathname.replace(/\\/$/, \"\");\n try { normalizedUrl = decodeURIComponent(normalizedUrl); } catch { /* malformed percent-encoding — match as-is */ }\n\n for (const route of routes) {\n const params = matchPattern(normalizedUrl, route.pattern);\n if (params !== null) {\n return { route, params };\n }\n }\n\n return null;\n}\n\n/**\n * Scan the pages/api/ directory and return API routes.\n * Results are cached — call invalidateRouteCache() when files change.\n *\n * Follows Next.js conventions:\n * - pages/api/hello.ts -> /api/hello\n * - pages/api/users/[id].ts -> /api/users/:id\n */\nexport async function apiRouter(pagesDir: string): Promise<Route[]> {\n const cacheKey = `api:${pagesDir}`;\n const cached = routeCache.get(cacheKey);\n if (cached) return cached.promise;\n\n const promise = scanApiRoutes(pagesDir);\n routeCache.set(cacheKey, { routes: [], promise });\n const routes = await promise;\n routeCache.set(cacheKey, { routes, promise });\n return routes;\n}\n\nasync function scanApiRoutes(pagesDir: string): Promise<Route[]> {\n const apiDir = path.join(pagesDir, \"api\");\n let files: string[];\n try {\n files = [];\n for await (const file of glob(\"**/*.{ts,tsx,js,jsx}\", { cwd: apiDir })) {\n files.push(file);\n }\n } catch {\n files = [];\n }\n\n const routes: Route[] = [];\n\n for (const file of files) {\n // Reuse fileToRoute but pretend the file is under a virtual \"api/\" prefix\n const route = fileToRoute(path.join(\"api\", file), pagesDir);\n if (route) {\n routes.push(route);\n }\n }\n\n // Sort same as page routes\n routes.sort((a, b) => {\n const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);\n return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);\n });\n\n return routes;\n}\n\nfunction matchPattern(\n url: string,\n pattern: string,\n): Record<string, string | string[]> | null {\n const urlParts = url.split(\"/\").filter(Boolean);\n const patternParts = pattern.split(\"/\").filter(Boolean);\n\n const params: Record<string, string | string[]> = Object.create(null);\n\n for (let i = 0; i < patternParts.length; i++) {\n const pp = patternParts[i];\n\n // Catch-all: :slug+\n if (pp.endsWith(\"+\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n if (remaining.length === 0) return null;\n params[paramName] = remaining;\n return params;\n }\n\n // Optional catch-all: :slug*\n if (pp.endsWith(\"*\")) {\n const paramName = pp.slice(1, -1);\n const remaining = urlParts.slice(i);\n params[paramName] = remaining;\n return params;\n }\n\n // Dynamic segment: :id\n if (pp.startsWith(\":\")) {\n const paramName = pp.slice(1);\n if (i >= urlParts.length) return null;\n params[paramName] = urlParts[i];\n continue;\n }\n\n // Static segment\n if (i >= urlParts.length || urlParts[i] !== pp) return null;\n }\n\n // All pattern parts matched - check url doesn't have extra segments\n if (urlParts.length !== patternParts.length) return null;\n\n return params;\n}\n\n/**\n * Convert internal route pattern (e.g., \"/posts/:id\", \"/docs/:slug+\")\n * to Next.js bracket format (e.g., \"/posts/[id]\", \"/docs/[...slug]\").\n * Used for __NEXT_DATA__.page which apps expect in Next.js format.\n */\nexport function patternToNextFormat(pattern: string): string {\n return pattern\n .replace(/:([\\w-]+)\\*/g, \"[[...$1]]\") // optional catch-all :slug* -> [[...slug]]\n .replace(/:([\\w-]+)\\+/g, \"[...$1]\") // catch-all :slug+ -> [...slug]\n .replace(/:([\\w-]+)/g, \"[$1]\"); // dynamic :id -> [id]\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Route precedence — lower score is higher priority.
3
+ * Matches Next.js specificity rules:
4
+ * 1. Static routes first (scored by segment count, more = more specific)
5
+ * 2. Dynamic segments penalized by position
6
+ * 3. Catch-all comes after dynamic
7
+ * 4. Optional catch-all last
8
+ * 5. Lexicographic tiebreaker for determinism
9
+ *
10
+ * Key insight: routes with a static prefix before a dynamic/catch-all segment
11
+ * should have higher priority than bare dynamic/catch-all routes at the same
12
+ * depth. E.g., /_sites/:subdomain should match before /:subdomain, and
13
+ * /_sites/:subdomain/:slug* should match before /:slug*.
14
+ *
15
+ * The static-prefix reduction uses a small value (-50 per segment) so that:
16
+ * - It beats the per-dynamic-segment penalty (100), placing prefix routes
17
+ * above their no-prefix equivalents.
18
+ * - It never goes negative, so purely-static routes (score 0) always win.
19
+ * - It is small enough that infix-static bonuses (-500) and catch-all
20
+ * penalties (1000+) are not swamped, preserving their relative ordering.
21
+ * E.g. /:locale/blog/:path+ (with infix "blog") correctly beats /:locale/:path+
22
+ * even when both share the same "locale-test" static prefix.
23
+ */
24
+ export declare function routePrecedence(pattern: string): number;
25
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/routing/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA+CvD"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Route precedence — lower score is higher priority.
3
+ * Matches Next.js specificity rules:
4
+ * 1. Static routes first (scored by segment count, more = more specific)
5
+ * 2. Dynamic segments penalized by position
6
+ * 3. Catch-all comes after dynamic
7
+ * 4. Optional catch-all last
8
+ * 5. Lexicographic tiebreaker for determinism
9
+ *
10
+ * Key insight: routes with a static prefix before a dynamic/catch-all segment
11
+ * should have higher priority than bare dynamic/catch-all routes at the same
12
+ * depth. E.g., /_sites/:subdomain should match before /:subdomain, and
13
+ * /_sites/:subdomain/:slug* should match before /:slug*.
14
+ *
15
+ * The static-prefix reduction uses a small value (-50 per segment) so that:
16
+ * - It beats the per-dynamic-segment penalty (100), placing prefix routes
17
+ * above their no-prefix equivalents.
18
+ * - It never goes negative, so purely-static routes (score 0) always win.
19
+ * - It is small enough that infix-static bonuses (-500) and catch-all
20
+ * penalties (1000+) are not swamped, preserving their relative ordering.
21
+ * E.g. /:locale/blog/:path+ (with infix "blog") correctly beats /:locale/:path+
22
+ * even when both share the same "locale-test" static prefix.
23
+ */
24
+ export function routePrecedence(pattern) {
25
+ const parts = pattern.split("/").filter(Boolean);
26
+ let score = 0;
27
+ let staticPrefixCount = 0;
28
+ for (const p of parts) {
29
+ if (p.startsWith(":") || p.endsWith("+") || p.endsWith("*"))
30
+ break;
31
+ staticPrefixCount++;
32
+ }
33
+ for (let i = 0; i < parts.length; i++) {
34
+ const p = parts[i];
35
+ if (p.endsWith("+")) {
36
+ score += 1000 + i; // catch-all: moderate penalty
37
+ }
38
+ else if (p.endsWith("*")) {
39
+ score += 2000 + i; // optional catch-all: high penalty
40
+ }
41
+ else if (p.startsWith(":")) {
42
+ score += 100 + i; // dynamic: small penalty by position
43
+ }
44
+ else if (i >= staticPrefixCount) {
45
+ // Static segment interleaved after a dynamic segment (infix static).
46
+ // Boost priority — more specific than a bare catch-all.
47
+ // The -500 compounds for each infix static segment, so routes with more
48
+ // static infixes score lower (higher priority) than those with fewer.
49
+ // E.g. /:a/x/y/:b+ (-1000) beats /:a/x/:b+ (-500) beats /:a/:b+ (0).
50
+ // This is intentional: more static constraints = more specific route.
51
+ score -= 500;
52
+ }
53
+ // Static prefix segments (i < staticPrefixCount) are handled below.
54
+ }
55
+ // Apply a small reduction per static-prefix segment for routes that also
56
+ // contain dynamic segments. This ensures /_sites/:subdomain sorts above
57
+ // /:subdomain, and /_sites/:slug* sorts above /:slug*, while keeping the
58
+ // final score positive (so purely-static routes at score=0 always win).
59
+ //
60
+ // 50 is deliberately smaller than the dynamic-segment penalty (100) so
61
+ // one static prefix segment is enough to beat one bare dynamic segment,
62
+ // and smaller than the infix-static bonus (500) so that infix ordering is
63
+ // not disturbed between two routes that share the same prefix.
64
+ const isDynamic = parts.some((p) => p.startsWith(":") || p.endsWith("+") || p.endsWith("*"));
65
+ if (isDynamic && staticPrefixCount > 0) {
66
+ score -= staticPrefixCount * 50;
67
+ }
68
+ return score;
69
+ }
70
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/routing/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,IAAI,iBAAiB,GAAG,CAAC,CAAC;IAC1B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAA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,GAAG,EAAE,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * Route precedence — lower score is higher priority.\n * Matches Next.js specificity rules:\n * 1. Static routes first (scored by segment count, more = more specific)\n * 2. Dynamic segments penalized by position\n * 3. Catch-all comes after dynamic\n * 4. Optional catch-all last\n * 5. Lexicographic tiebreaker for determinism\n *\n * Key insight: routes with a static prefix before a dynamic/catch-all segment\n * should have higher priority than bare dynamic/catch-all routes at the same\n * depth. E.g., /_sites/:subdomain should match before /:subdomain, and\n * /_sites/:subdomain/:slug* should match before /:slug*.\n *\n * The static-prefix reduction uses a small value (-50 per segment) so that:\n * - It beats the per-dynamic-segment penalty (100), placing prefix routes\n * above their no-prefix equivalents.\n * - It never goes negative, so purely-static routes (score 0) always win.\n * - It is small enough that infix-static bonuses (-500) and catch-all\n * penalties (1000+) are not swamped, preserving their relative ordering.\n * E.g. /:locale/blog/:path+ (with infix \"blog\") correctly beats /:locale/:path+\n * even when both share the same \"locale-test\" static prefix.\n */\nexport function routePrecedence(pattern: string): number {\n const parts = pattern.split(\"/\").filter(Boolean);\n let score = 0;\n\n let staticPrefixCount = 0;\n for (const p of parts) {\n if (p.startsWith(\":\") || p.endsWith(\"+\") || p.endsWith(\"*\")) break;\n staticPrefixCount++;\n }\n\n for (let i = 0; i < parts.length; i++) {\n const p = parts[i];\n if (p.endsWith(\"+\")) {\n score += 1000 + i; // catch-all: moderate penalty\n } else if (p.endsWith(\"*\")) {\n score += 2000 + i; // optional catch-all: high penalty\n } else if (p.startsWith(\":\")) {\n score += 100 + i; // dynamic: small penalty by position\n } else if (i >= staticPrefixCount) {\n // Static segment interleaved after a dynamic segment (infix static).\n // Boost priority — more specific than a bare catch-all.\n // The -500 compounds for each infix static segment, so routes with more\n // static infixes score lower (higher priority) than those with fewer.\n // E.g. /:a/x/y/:b+ (-1000) beats /:a/x/:b+ (-500) beats /:a/:b+ (0).\n // This is intentional: more static constraints = more specific route.\n score -= 500;\n }\n // Static prefix segments (i < staticPrefixCount) are handled below.\n }\n\n // Apply a small reduction per static-prefix segment for routes that also\n // contain dynamic segments. This ensures /_sites/:subdomain sorts above\n // /:subdomain, and /_sites/:slug* sorts above /:slug*, while keeping the\n // final score positive (so purely-static routes at score=0 always win).\n //\n // 50 is deliberately smaller than the dynamic-segment penalty (100) so\n // one static prefix segment is enough to beat one bare dynamic segment,\n // and smaller than the infix-static bonus (500) so that infix ordering is\n // not disturbed between two routes that share the same prefix.\n const isDynamic = parts.some(\n (p) => p.startsWith(\":\") || p.endsWith(\"+\") || p.endsWith(\"*\"),\n );\n if (isDynamic && staticPrefixCount > 0) {\n score -= staticPrefixCount * 50;\n }\n\n return score;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"app-dev-server.d.ts","sourceRoot":"","sources":["../../src/server/app-dev-server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAKtF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE;QACT,WAAW,EAAE,WAAW,EAAE,CAAC;QAC3B,UAAU,EAAE,WAAW,EAAE,CAAC;QAC1B,QAAQ,EAAE,WAAW,EAAE,CAAC;KACzB,CAAC;IACF,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,4GAA4G;IAC5G,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,uGAAuG;IACvG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,EAAE,E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