vinext 0.0.24 → 0.0.25

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 (92) hide show
  1. package/README.md +24 -0
  2. package/dist/check.d.ts.map +1 -1
  3. package/dist/check.js +3 -2
  4. package/dist/check.js.map +1 -1
  5. package/dist/client/entry.js +1 -1
  6. package/dist/client/entry.js.map +1 -1
  7. package/dist/config/config-matchers.d.ts +21 -0
  8. package/dist/config/config-matchers.d.ts.map +1 -1
  9. package/dist/config/config-matchers.js +46 -6
  10. package/dist/config/config-matchers.js.map +1 -1
  11. package/dist/config/next-config.d.ts +8 -2
  12. package/dist/config/next-config.d.ts.map +1 -1
  13. package/dist/config/next-config.js +90 -35
  14. package/dist/config/next-config.js.map +1 -1
  15. package/dist/deploy.d.ts +10 -0
  16. package/dist/deploy.d.ts.map +1 -1
  17. package/dist/deploy.js +70 -35
  18. package/dist/deploy.js.map +1 -1
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +172 -18
  22. package/dist/index.js.map +1 -1
  23. package/dist/plugins/async-hooks-stub.d.ts +16 -0
  24. package/dist/plugins/async-hooks-stub.d.ts.map +1 -0
  25. package/dist/plugins/async-hooks-stub.js +45 -0
  26. package/dist/plugins/async-hooks-stub.js.map +1 -0
  27. package/dist/routing/app-router.d.ts +12 -6
  28. package/dist/routing/app-router.d.ts.map +1 -1
  29. package/dist/routing/app-router.js +19 -40
  30. package/dist/routing/app-router.js.map +1 -1
  31. package/dist/routing/pages-router.d.ts.map +1 -1
  32. package/dist/routing/pages-router.js +3 -9
  33. package/dist/routing/pages-router.js.map +1 -1
  34. package/dist/routing/utils.d.ts +9 -0
  35. package/dist/routing/utils.d.ts.map +1 -1
  36. package/dist/routing/utils.js +10 -0
  37. package/dist/routing/utils.js.map +1 -1
  38. package/dist/server/api-handler.d.ts.map +1 -1
  39. package/dist/server/api-handler.js +6 -0
  40. package/dist/server/api-handler.js.map +1 -1
  41. package/dist/server/app-dev-server.d.ts +2 -2
  42. package/dist/server/app-dev-server.d.ts.map +1 -1
  43. package/dist/server/app-dev-server.js +238 -114
  44. package/dist/server/app-dev-server.js.map +1 -1
  45. package/dist/server/dev-module-runner.d.ts +84 -0
  46. package/dist/server/dev-module-runner.d.ts.map +1 -0
  47. package/dist/server/dev-module-runner.js +105 -0
  48. package/dist/server/dev-module-runner.js.map +1 -0
  49. package/dist/server/dev-server.js.map +1 -1
  50. package/dist/server/instrumentation.d.ts +52 -9
  51. package/dist/server/instrumentation.d.ts.map +1 -1
  52. package/dist/server/instrumentation.js +52 -15
  53. package/dist/server/instrumentation.js.map +1 -1
  54. package/dist/server/middleware.d.ts +7 -3
  55. package/dist/server/middleware.d.ts.map +1 -1
  56. package/dist/server/middleware.js +16 -6
  57. package/dist/server/middleware.js.map +1 -1
  58. package/dist/server/prod-server.d.ts.map +1 -1
  59. package/dist/server/prod-server.js +15 -25
  60. package/dist/server/prod-server.js.map +1 -1
  61. package/dist/shims/cache.d.ts.map +1 -1
  62. package/dist/shims/cache.js +14 -2
  63. package/dist/shims/cache.js.map +1 -1
  64. package/dist/shims/fetch-cache.d.ts.map +1 -1
  65. package/dist/shims/fetch-cache.js +139 -29
  66. package/dist/shims/fetch-cache.js.map +1 -1
  67. package/dist/shims/form.d.ts.map +1 -1
  68. package/dist/shims/form.js +2 -3
  69. package/dist/shims/form.js.map +1 -1
  70. package/dist/shims/layout-segment-context.d.ts +5 -4
  71. package/dist/shims/layout-segment-context.d.ts.map +1 -1
  72. package/dist/shims/layout-segment-context.js +6 -5
  73. package/dist/shims/layout-segment-context.js.map +1 -1
  74. package/dist/shims/link.d.ts.map +1 -1
  75. package/dist/shims/link.js +32 -17
  76. package/dist/shims/link.js.map +1 -1
  77. package/dist/shims/navigation.d.ts +14 -11
  78. package/dist/shims/navigation.d.ts.map +1 -1
  79. package/dist/shims/navigation.js +122 -102
  80. package/dist/shims/navigation.js.map +1 -1
  81. package/dist/shims/router.d.ts.map +1 -1
  82. package/dist/shims/router.js +37 -21
  83. package/dist/shims/router.js.map +1 -1
  84. package/dist/shims/server.d.ts +2 -0
  85. package/dist/shims/server.d.ts.map +1 -1
  86. package/dist/shims/server.js +4 -0
  87. package/dist/shims/server.js.map +1 -1
  88. package/dist/shims/url-utils.d.ts +13 -0
  89. package/dist/shims/url-utils.d.ts.map +1 -0
  90. package/dist/shims/url-utils.js +28 -0
  91. package/dist/shims/url-utils.js.map +1 -0
  92. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ import type { Plugin } from "vite";
2
+ export declare const ASYNC_HOOKS_STUB_ID = "\0vinext:async-hooks-stub";
3
+ /**
4
+ * Stubs node:async_hooks in client (browser) builds.
5
+ *
6
+ * Several shims (headers, cache, navigation-state, etc.) import
7
+ * AsyncLocalStorage from node:async_hooks. These shims are aliased
8
+ * globally via resolve.alias so they resolve in every environment.
9
+ * In client builds, Vite externalizes node:async_hooks to an empty
10
+ * __vite-browser-external stub with no named exports, causing Rollup
11
+ * errors. This plugin intercepts node:async_hooks in the client
12
+ * environment and provides a no-op AsyncLocalStorage — semantically
13
+ * correct since shims already guard with `_als.getStore() ?? fallback`.
14
+ */
15
+ export declare const asyncHooksStubPlugin: Plugin;
16
+ //# sourceMappingURL=async-hooks-stub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-hooks-stub.d.ts","sourceRoot":"","sources":["../../src/plugins/async-hooks-stub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAE/D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAgClC,CAAC"}
@@ -0,0 +1,45 @@
1
+ export const ASYNC_HOOKS_STUB_ID = "\0vinext:async-hooks-stub";
2
+ /**
3
+ * Stubs node:async_hooks in client (browser) builds.
4
+ *
5
+ * Several shims (headers, cache, navigation-state, etc.) import
6
+ * AsyncLocalStorage from node:async_hooks. These shims are aliased
7
+ * globally via resolve.alias so they resolve in every environment.
8
+ * In client builds, Vite externalizes node:async_hooks to an empty
9
+ * __vite-browser-external stub with no named exports, causing Rollup
10
+ * errors. This plugin intercepts node:async_hooks in the client
11
+ * environment and provides a no-op AsyncLocalStorage — semantically
12
+ * correct since shims already guard with `_als.getStore() ?? fallback`.
13
+ */
14
+ export const asyncHooksStubPlugin = {
15
+ name: "vinext:async-hooks-stub",
16
+ enforce: "pre",
17
+ resolveId: {
18
+ filter: { id: /^(node:)?async_hooks$/ },
19
+ handler(_id) {
20
+ if (this.environment?.name === "client") {
21
+ return ASYNC_HOOKS_STUB_ID;
22
+ }
23
+ },
24
+ },
25
+ load: {
26
+ filter: { id: new RegExp(`^${ASYNC_HOOKS_STUB_ID}$`) },
27
+ handler(id) {
28
+ if (id === ASYNC_HOOKS_STUB_ID) {
29
+ // Intentionally minimal: only AsyncLocalStorage is exported.
30
+ // If other node:async_hooks exports (e.g. AsyncResource,
31
+ // executionAsyncId) are needed in client shims, extend here.
32
+ return [
33
+ "export class AsyncLocalStorage {",
34
+ " run(_store, fn, ...args) { return fn(...args); }",
35
+ " getStore() { return undefined; }",
36
+ " enterWith() {}",
37
+ " exit(fn, ...args) { return fn(...args); }",
38
+ " disable() {}",
39
+ "}",
40
+ ].join("\n");
41
+ }
42
+ },
43
+ },
44
+ };
45
+ //# sourceMappingURL=async-hooks-stub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-hooks-stub.js","sourceRoot":"","sources":["../../src/plugins/async-hooks-stub.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAW;IAC1C,IAAI,EAAE,yBAAyB;IAC/B,OAAO,EAAE,KAAK;IAEd,SAAS,EAAE;QACT,MAAM,EAAE,EAAE,EAAE,EAAE,uBAAuB,EAAE;QACvC,OAAO,CAAC,GAAG;YACT,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxC,OAAO,mBAAmB,CAAC;YAC7B,CAAC;QACH,CAAC;KACF;IAED,IAAI,EAAE;QACJ,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,MAAM,CAAC,IAAI,mBAAmB,GAAG,CAAC,EAAE;QACtD,OAAO,CAAC,EAAE;YACR,IAAI,EAAE,KAAK,mBAAmB,EAAE,CAAC;gBAC/B,6DAA6D;gBAC7D,yDAAyD;gBACzD,6DAA6D;gBAC7D,OAAO;oBACL,kCAAkC;oBAClC,oDAAoD;oBACpD,oCAAoC;oBACpC,kBAAkB;oBAClB,6CAA6C;oBAC7C,gBAAgB;oBAChB,GAAG;iBACJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACf,CAAC;QACH,CAAC;KACF;CACF,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\n\nexport const ASYNC_HOOKS_STUB_ID = \"\\0vinext:async-hooks-stub\";\n\n/**\n * Stubs node:async_hooks in client (browser) builds.\n *\n * Several shims (headers, cache, navigation-state, etc.) import\n * AsyncLocalStorage from node:async_hooks. These shims are aliased\n * globally via resolve.alias so they resolve in every environment.\n * In client builds, Vite externalizes node:async_hooks to an empty\n * __vite-browser-external stub with no named exports, causing Rollup\n * errors. This plugin intercepts node:async_hooks in the client\n * environment and provides a no-op AsyncLocalStorage — semantically\n * correct since shims already guard with `_als.getStore() ?? fallback`.\n */\nexport const asyncHooksStubPlugin: Plugin = {\n name: \"vinext:async-hooks-stub\",\n enforce: \"pre\",\n\n resolveId: {\n filter: { id: /^(node:)?async_hooks$/ },\n handler(_id) {\n if (this.environment?.name === \"client\") {\n return ASYNC_HOOKS_STUB_ID;\n }\n },\n },\n\n load: {\n filter: { id: new RegExp(`^${ASYNC_HOOKS_STUB_ID}$`) },\n handler(id) {\n if (id === ASYNC_HOOKS_STUB_ID) {\n // Intentionally minimal: only AsyncLocalStorage is exported.\n // If other node:async_hooks exports (e.g. AsyncResource,\n // executionAsyncId) are needed in client shims, extend here.\n return [\n \"export class AsyncLocalStorage {\",\n \" run(_store, fn, ...args) { return fn(...args); }\",\n \" getStore() { return undefined; }\",\n \" enterWith() {}\",\n \" exit(fn, ...args) { return fn(...args); }\",\n \" disable() {}\",\n \"}\",\n ].join(\"\\n\");\n }\n },\n },\n};\n"]}
@@ -70,13 +70,19 @@ export interface AppRoute {
70
70
  /** Unauthorized component path (401) */
71
71
  unauthorizedPath: string | null;
72
72
  /**
73
- * URL segment depth for each layout in the layouts array.
74
- * Used by useSelectedLayoutSegments() to determine which segments are
75
- * below a given layout. For example, root layout has depth 0, a layout
76
- * at app/dashboard/ has depth 1 (one URL segment: "dashboard").
77
- * Route groups and parallel slots don't contribute to the depth.
73
+ * Filesystem segments from app/ root to the route's directory.
74
+ * Includes route groups and dynamic segments (as template strings like "[id]").
75
+ * Used at render time to compute the child segments for useSelectedLayoutSegments().
78
76
  */
79
- layoutSegmentDepths: number[];
77
+ routeSegments: string[];
78
+ /**
79
+ * Tree position (directory depth from app/ root) for each layout.
80
+ * Used to slice routeSegments and determine which segments are below each layout.
81
+ * For example, root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.
82
+ * Unlike the old layoutSegmentDepths, this counts ALL directory levels including
83
+ * route groups and parallel slots.
84
+ */
85
+ layoutTreePositions: number[];
80
86
  /** Whether this is a dynamic route */
81
87
  isDynamic: boolean;
82
88
  /** Parameter names for dynamic segments */
@@ -1 +1 @@
1
- {"version":3,"file":"app-router.d.ts","sourceRoot":"","sources":["../../src/routing/app-router.ts"],"names":[],"mappings":"AAkBA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;IACtB,uDAAuD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AC;IACnB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAOD,wBAAgB,uBAAuB,IAAI,IAAI,CAI9C;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoDrB;AAu0BD;;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"}
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import path from "node:path";
17
17
  import fs from "node:fs";
18
- import { routePrecedence } from "./utils.js";
18
+ import { compareRoutes } from "./utils.js";
19
19
  import { createValidFileMatcher, scanWithExtensions, } from "./file-matcher.js";
20
20
  // Cache for app routes
21
21
  let cachedRoutes = null;
@@ -60,10 +60,7 @@ export async function appRouter(appDir, pageExtensions, matcher) {
60
60
  const slotSubRoutes = discoverSlotSubRoutes(routes, appDir, matcher);
61
61
  routes.push(...slotSubRoutes);
62
62
  // Sort: static routes first, then dynamic, then catch-all
63
- routes.sort((a, b) => {
64
- const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);
65
- return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);
66
- });
63
+ routes.sort(compareRoutes);
67
64
  cachedRoutes = routes;
68
65
  cachedAppDir = appDir;
69
66
  cachedPageExtensionsKey = pageExtensionsKey;
@@ -170,7 +167,8 @@ function discoverSlotSubRoutes(routes, _appDir, matcher) {
170
167
  notFoundPaths: parentRoute.notFoundPaths,
171
168
  forbiddenPath: parentRoute.forbiddenPath,
172
169
  unauthorizedPath: parentRoute.unauthorizedPath,
173
- layoutSegmentDepths: parentRoute.layoutSegmentDepths,
170
+ routeSegments: [...parentRoute.routeSegments, ...subSegments],
171
+ layoutTreePositions: parentRoute.layoutTreePositions,
174
172
  isDynamic: parentRoute.isDynamic || subIsDynamic,
175
173
  params: [...parentRoute.params, ...subParams],
176
174
  });
@@ -267,11 +265,8 @@ function fileToAppRoute(file, appDir, type, matcher) {
267
265
  // Discover layouts and templates from root to leaf
268
266
  const layouts = discoverLayouts(segments, appDir, matcher);
269
267
  const templates = discoverTemplates(segments, appDir, matcher);
270
- // Compute the URL segment depth for each layout.
271
- // Each layout corresponds to a directory level. We need to count how many
272
- // of the filesystem segments up to that layout's level contribute URL segments
273
- // (i.e., are not route groups or parallel slots).
274
- const layoutSegmentDepths = computeLayoutSegmentDepths(segments, appDir, layouts, matcher);
268
+ // Compute the tree position (directory depth) for each layout.
269
+ const layoutTreePositions = computeLayoutTreePositions(appDir, layouts);
275
270
  // Discover per-layout error boundaries (aligned with layouts array).
276
271
  // In Next.js, each segment independently wraps its children with an ErrorBoundary.
277
272
  // This array enables interleaving error boundaries with layouts in the rendering.
@@ -306,41 +301,25 @@ function fileToAppRoute(file, appDir, type, matcher) {
306
301
  notFoundPaths,
307
302
  forbiddenPath,
308
303
  unauthorizedPath,
309
- layoutSegmentDepths,
304
+ routeSegments: segments,
305
+ layoutTreePositions,
310
306
  isDynamic,
311
307
  params,
312
308
  };
313
309
  }
314
310
  /**
315
- * Compute the URL segment depth for each layout in the layouts array.
316
- * Root layout = 0, then each directory level that contributes a URL segment
317
- * increments the depth. Route groups and parallel slots don't contribute.
311
+ * Compute the tree position (directory depth from app root) for each layout.
312
+ * Root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.
313
+ * Counts ALL directory levels including route groups and parallel slots.
318
314
  */
319
- function computeLayoutSegmentDepths(segments, appDir, layouts, matcher) {
320
- // Build a map: layout file path → depth in URL segments
321
- // Walk the segments directory-by-directory, tracking cumulative URL depth
322
- const depthMap = new Map();
323
- // Root layout (at appDir) always has depth 0
324
- const rootLayout = findFile(appDir, "layout", matcher);
325
- if (rootLayout)
326
- depthMap.set(rootLayout, 0);
327
- let urlDepth = 0;
328
- let currentDir = appDir;
329
- for (const segment of segments) {
330
- currentDir = path.join(currentDir, segment);
331
- // Count URL-visible segments (skip route groups and parallel slots)
332
- const isRouteGroup = segment.startsWith("(") && segment.endsWith(")");
333
- const isParallelSlot = segment.startsWith("@");
334
- if (!isRouteGroup && !isParallelSlot) {
335
- urlDepth++;
336
- }
337
- const layout = findFile(currentDir, "layout", matcher);
338
- if (layout) {
339
- depthMap.set(layout, urlDepth);
340
- }
341
- }
342
- // Map the ordered layouts array to their depths
343
- return layouts.map((layoutPath) => depthMap.get(layoutPath) ?? 0);
315
+ function computeLayoutTreePositions(appDir, layouts) {
316
+ return layouts.map((layoutPath) => {
317
+ const layoutDir = path.dirname(layoutPath);
318
+ if (layoutDir === appDir)
319
+ return 0;
320
+ const relative = path.relative(appDir, layoutDir);
321
+ return relative.split(path.sep).length;
322
+ });
344
323
  }
345
324
  /**
346
325
  * Discover all layout files from root to the given directory.
@@ -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,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAwF3B,uBAAuB;AACvB,IAAI,YAAY,GAAsB,IAAI,CAAC;AAC3C,IAAI,YAAY,GAAkB,IAAI,CAAC;AACvC,IAAI,uBAAuB,GAAkB,IAAI,CAAC;AAElD,MAAM,UAAU,uBAAuB;IACrC,YAAY,GAAG,IAAI,CAAC;IACpB,YAAY,GAAG,IAAI,CAAC;IACpB,uBAAuB,GAAG,IAAI,CA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C;YAC9B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;YAC9B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,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,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;IAC9D,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzD,OAAO,MAAM,CAAC;AAChB,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 { routePrecedence } from \"./utils.js\";\nimport {\n createValidFileMatcher,\n scanWithExtensions,\n type ValidFileMatcher,\n} from \"./file-matcher.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;\nlet cachedPageExtensionsKey: string | null = null;\n\nexport function invalidateAppRouteCache(): void {\n cachedRoutes = null;\n cachedAppDir = null;\n cachedPageExtensionsKey = null;\n}\n\n/**\n * Scan the app/ directory and return a list of routes.\n */\nexport async function appRouter(\n appDir: string,\n pageExtensions?: readonly string[],\n matcher?: ValidFileMatcher,\n): Promise<AppRoute[]> {\n matcher ??= createValidFileMatcher(pageExtensions);\n const pageExtensionsKey = JSON.stringify(matcher.extensions);\n if (\n cachedRoutes &&\n cachedAppDir === appDir &&\n cachedPageExtensionsKey === pageExtensionsKey\n ) {\n return cachedRoutes;\n }\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 scanWithExtensions(\n \"**/page\",\n appDir,\n matcher.extensions,\n (name: string) => name.startsWith(\"@\"),\n )) {\n const route = fileToAppRoute(file, appDir, \"page\", matcher);\n if (route) routes.push(route);\n }\n\n // Process route handler files (API routes) in a single pass\n for await (const file of scanWithExtensions(\n \"**/route\",\n appDir,\n matcher.extensions,\n (name: string) => name.startsWith(\"@\"),\n )) {\n const route = fileToAppRoute(file, appDir, \"route\", matcher);\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, matcher);\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 cachedPageExtensionsKey = pageExtensionsKey;\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 matcher: ValidFileMatcher,\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, matcher);\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\", matcher);\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 matcher: ValidFileMatcher,\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\", matcher);\n if (page) {\n const relativePath = path.relative(slotDir, subDir);\n results.push({ relativePath, pagePath: page });\n }\n // Continue scanning deeper for nested sub-pages\n scan(subDir);\n }\n }\n\n scan(slotDir);\n return results;\n}\n\n/**\n * Convert a file path relative to app/ into an AppRoute.\n */\nfunction fileToAppRoute(\n file: string,\n appDir: string,\n type: \"page\" | \"route\",\n matcher: ValidFileMatcher,\n): AppRoute | null {\n // Remove the filename (page.tsx or route.ts)\n const dir = path.dirname(file);\n 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, matcher);\n const templates = discoverTemplates(segments, appDir, matcher);\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 matcher,\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, matcher);\n\n // Discover loading, error in the route's directory\n const routeDir = dir === \".\" ? appDir : path.join(appDir, dir);\n const loadingPath = findFile(routeDir, \"loading\", matcher);\n const errorPath = findFile(routeDir, \"error\", matcher);\n\n // Discover not-found/forbidden/unauthorized: walk from route directory up to root (nearest wins).\n const notFoundPath = discoverBoundaryFile(\n segments,\n appDir,\n \"not-found\",\n matcher,\n );\n const forbiddenPath = discoverBoundaryFile(\n segments,\n appDir,\n \"forbidden\",\n matcher,\n );\n const unauthorizedPath = discoverBoundaryFile(\n segments,\n appDir,\n \"unauthorized\",\n matcher,\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(\n layouts,\n \"not-found\",\n matcher,\n );\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 matcher,\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 matcher: ValidFileMatcher,\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\", matcher);\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\", matcher);\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(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): string[] {\n const layouts: string[] = [];\n\n // Check root layout\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) layouts.push(rootLayout);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) layouts.push(layout);\n }\n\n return layouts;\n}\n\n/**\n * Discover all template files from root to the given directory.\n * Each level of the directory tree may have a template.tsx.\n * Templates are like layouts but re-mount on navigation.\n */\nfunction discoverTemplates(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): string[] {\n const templates: string[] = [];\n\n // Check root template\n const rootTemplate = findFile(appDir, \"template\", matcher);\n if (rootTemplate) templates.push(rootTemplate);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const template = findFile(currentDir, \"template\", matcher);\n if (template) templates.push(template);\n }\n\n return templates;\n}\n\n/**\n * Discover error.tsx files aligned with the layouts array.\n * Walks the same directory levels as discoverLayouts and, for each level\n * that contributes a layout entry, checks whether error.tsx also exists.\n * Returns an array of the same length as discoverLayouts() would return,\n * with the error path (or null) at each corresponding layout level.\n *\n * This enables interleaving ErrorBoundary components with layouts in the\n * rendering tree, matching Next.js behavior where each segment independently\n * wraps its children with an error boundary.\n */\nfunction discoverLayoutAlignedErrors(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n const errors: (string | null)[] = [];\n\n // Root level (only if root has a layout — matching discoverLayouts logic)\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) {\n errors.push(findFile(appDir, \"error\", matcher));\n }\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) {\n errors.push(findFile(currentDir, \"error\", matcher));\n }\n }\n\n return errors;\n}\n\n/**\n * Discover the nearest boundary file (not-found, forbidden, unauthorized)\n * by walking from the route's directory up to the app root.\n * Returns the first (closest) file found, or null.\n */\nfunction discoverBoundaryFile(\n segments: string[],\n appDir: string,\n fileName: string,\n matcher: ValidFileMatcher,\n): string | null {\n // Build all directory paths from leaf to root\n const dirs: string[] = [];\n let dir = appDir;\n dirs.push(dir);\n for (const segment of segments) {\n dir = path.join(dir, segment);\n dirs.push(dir);\n }\n\n // Walk from leaf (last) to root (first)\n for (let i = dirs.length - 1; i >= 0; i--) {\n const f = findFile(dirs[i], fileName, matcher);\n if (f) return f;\n }\n return null;\n}\n\n/**\n * Discover boundary files (not-found, forbidden, unauthorized) at each layout directory.\n * Returns an array aligned with the layouts array, where each entry is the boundary\n * file at that layout's directory, or null if none exists there.\n *\n * This is used for per-layout error boundaries. In Next.js, each layout level\n * has its own boundary that wraps the layout's children. When notFound() is thrown\n * from a layout, it propagates up to the parent layout's boundary.\n */\nfunction discoverBoundaryFilePerLayout(\n layouts: string[],\n fileName: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n return findFile(layoutDir, fileName, matcher);\n });\n}\n\n/**\n * Discover parallel slots inherited from ancestor directories.\n *\n * In Next.js, parallel slots belong to the layout that defines them. When a\n * child route is rendered, its parent layout's slots must still be present.\n * If the child doesn't have matching content in a slot, the slot's default.tsx\n * is rendered instead.\n *\n * Walk from appDir through each segment to the route's directory. At each level\n * that has @slot dirs, collect them. Slots at the route's own directory level\n * use page.tsx; slots at ancestor levels use default.tsx only.\n */\nfunction discoverInheritedParallelSlots(\n segments: string[],\n appDir: string,\n routeDir: string,\n matcher: ValidFileMatcher,\n): ParallelSlot[] {\n const slotMap = new Map<string, ParallelSlot>();\n\n // Walk from appDir through each segment, tracking layout indices.\n // layoutIndex tracks which position in the route's layouts[] array corresponds\n // to a given directory. Only directories with a layout.tsx file increment.\n let currentDir = appDir;\n const dirsToCheck: { dir: string; layoutIdx: number }[] = [];\n let layoutIdx = findFile(appDir, \"layout\", matcher) ? 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\", matcher)) {\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, matcher);\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(\n dir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n): ParallelSlot[] {\n if (!fs.existsSync(dir)) return [];\n\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n const slots: ParallelSlot[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n\n const slotName = entry.name.slice(1); // \"@team\" -> \"team\"\n const slotDir = path.join(dir, entry.name);\n\n const pagePath = findFile(slotDir, \"page\", matcher);\n const defaultPath = findFile(slotDir, \"default\", matcher);\n const interceptingRoutes = discoverInterceptingRoutes(\n slotDir,\n dir,\n appDir,\n matcher,\n );\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\", matcher),\n loadingPath: findFile(slotDir, \"loading\", matcher),\n errorPath: findFile(slotDir, \"error\", matcher),\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 matcher: ValidFileMatcher,\n): InterceptingRoute[] {\n if (!fs.existsSync(slotDir)) return [];\n\n const results: InterceptingRoute[] = [];\n\n // Recursively scan for page files inside intercepting directories\n scanForInterceptingPages(slotDir, routeDir, appDir, results, matcher);\n\n return results;\n}\n\n/**\n * Recursively scan a directory tree for page.tsx files that are inside\n * intercepting route directories.\n */\nfunction scanForInterceptingPages(\n currentDir: string,\n routeDir: string,\n appDir: string,\n results: InterceptingRoute[],\n matcher: ValidFileMatcher,\n): void {\n if (!fs.existsSync(currentDir)) return;\n\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n\n // Check if this directory name starts with an interception convention\n const interceptMatch = matchInterceptConvention(entry.name);\n\n if (interceptMatch) {\n // This directory is the start of an intercepting route\n // e.g. \"(.)photos\" means intercept same-level \"photos\" route\n const restOfName = entry.name.slice(interceptMatch.prefix.length);\n const interceptDir = path.join(currentDir, entry.name);\n\n // Find page files within this intercepting directory tree\n collectInterceptingPages(\n interceptDir,\n interceptDir,\n interceptMatch.convention,\n restOfName,\n routeDir,\n appDir,\n results,\n matcher,\n );\n } else {\n // Regular subdirectory — keep scanning for intercepting dirs\n scanForInterceptingPages(\n path.join(currentDir, entry.name),\n routeDir,\n appDir,\n results,\n matcher,\n );\n }\n }\n}\n\n/**\n * Match a directory name against interception convention prefixes.\n */\nfunction matchInterceptConvention(\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 matcher: ValidFileMatcher,\n): void {\n // Check for page.tsx in current directory\n const page = findFile(currentDir, \"page\", matcher);\n if (page) {\n const targetPattern = computeInterceptTarget(\n convention,\n interceptSegment,\n currentDir,\n interceptRoot,\n routeDir,\n appDir,\n );\n if (targetPattern) {\n results.push({\n convention,\n 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 matcher,\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 configured pageExtensions.\n */\nfunction findFile(\n dir: string,\n name: string,\n matcher: ValidFileMatcher,\n): string | null {\n for (const ext of matcher.dottedExtensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\n}\n\n/**\n * 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
+ {"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,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,sBAAsB,EACtB,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AA8F3B,uBAAuB;AACvB,IAAI,YAAY,GAAsB,IAAI,CAAC;AAC3C,IAAI,YAAY,GAAkB,IAAI,CAAC;AACvC,IAAI,uBAAuB,GAAkB,IAAI,CAAC;AAElD,MAAM,UAAU,uBAAuB;IACrC,YAAY,GAAG,IAAI,CAAC;IACpB,YAAY,GAAG,IAAI,CAAC;IACpB,uBAAuB,GAAG,IAAI,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAc,EACd,cAAkC,EAClC,OA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AC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YACxC,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;YAC9B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;YAC9B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,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,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;IAC9D,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzD,OAAO,MAAM,CAAC;AAChB,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 { compareRoutes } from \"./utils.js\";\nimport {\n createValidFileMatcher,\n scanWithExtensions,\n type ValidFileMatcher,\n} from \"./file-matcher.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 * Filesystem segments from app/ root to the route's directory.\n * Includes route groups and dynamic segments (as template strings like \"[id]\").\n * Used at render time to compute the child segments for useSelectedLayoutSegments().\n */\n routeSegments: string[];\n /**\n * Tree position (directory depth from app/ root) for each layout.\n * Used to slice routeSegments and determine which segments are below each layout.\n * For example, root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.\n * Unlike the old layoutSegmentDepths, this counts ALL directory levels including\n * route groups and parallel slots.\n */\n layoutTreePositions: number[];\n /** Whether this is a dynamic route */\n isDynamic: boolean;\n /** Parameter names for dynamic segments */\n params: string[];\n}\n\n// Cache for app routes\nlet cachedRoutes: AppRoute[] | null = null;\nlet cachedAppDir: string | null = null;\nlet cachedPageExtensionsKey: string | null = null;\n\nexport function invalidateAppRouteCache(): void {\n cachedRoutes = null;\n cachedAppDir = null;\n cachedPageExtensionsKey = null;\n}\n\n/**\n * Scan the app/ directory and return a list of routes.\n */\nexport async function appRouter(\n appDir: string,\n pageExtensions?: readonly string[],\n matcher?: ValidFileMatcher,\n): Promise<AppRoute[]> {\n matcher ??= createValidFileMatcher(pageExtensions);\n const pageExtensionsKey = JSON.stringify(matcher.extensions);\n if (\n cachedRoutes &&\n cachedAppDir === appDir &&\n cachedPageExtensionsKey === pageExtensionsKey\n ) {\n return cachedRoutes;\n }\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 scanWithExtensions(\n \"**/page\",\n appDir,\n matcher.extensions,\n (name: string) => name.startsWith(\"@\"),\n )) {\n const route = fileToAppRoute(file, appDir, \"page\", matcher);\n if (route) routes.push(route);\n }\n\n // Process route handler files (API routes) in a single pass\n for await (const file of scanWithExtensions(\n \"**/route\",\n appDir,\n matcher.extensions,\n (name: string) => name.startsWith(\"@\"),\n )) {\n const route = fileToAppRoute(file, appDir, \"route\", matcher);\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, matcher);\n routes.push(...slotSubRoutes);\n\n // Sort: static routes first, then dynamic, then catch-all\n routes.sort(compareRoutes);\n\n cachedRoutes = routes;\n cachedAppDir = appDir;\n cachedPageExtensionsKey = pageExtensionsKey;\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 matcher: ValidFileMatcher,\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, matcher);\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\", matcher);\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 routeSegments: [...parentRoute.routeSegments, ...subSegments],\n layoutTreePositions: parentRoute.layoutTreePositions,\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 matcher: ValidFileMatcher,\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\", matcher);\n if (page) {\n const relativePath = path.relative(slotDir, subDir);\n results.push({ relativePath, pagePath: page });\n }\n // Continue scanning deeper for nested sub-pages\n scan(subDir);\n }\n }\n\n scan(slotDir);\n return results;\n}\n\n/**\n * Convert a file path relative to app/ into an AppRoute.\n */\nfunction fileToAppRoute(\n file: string,\n appDir: string,\n type: \"page\" | \"route\",\n matcher: ValidFileMatcher,\n): AppRoute | null {\n // Remove the filename (page.tsx or route.ts)\n const dir = path.dirname(file);\n 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, matcher);\n const templates = discoverTemplates(segments, appDir, matcher);\n\n // Compute the tree position (directory depth) for each layout.\n const layoutTreePositions = computeLayoutTreePositions(\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, matcher);\n\n // Discover loading, error in the route's directory\n const routeDir = dir === \".\" ? appDir : path.join(appDir, dir);\n const loadingPath = findFile(routeDir, \"loading\", matcher);\n const errorPath = findFile(routeDir, \"error\", matcher);\n\n // Discover not-found/forbidden/unauthorized: walk from route directory up to root (nearest wins).\n const notFoundPath = discoverBoundaryFile(\n segments,\n appDir,\n \"not-found\",\n matcher,\n );\n const forbiddenPath = discoverBoundaryFile(\n segments,\n appDir,\n \"forbidden\",\n matcher,\n );\n const unauthorizedPath = discoverBoundaryFile(\n segments,\n appDir,\n \"unauthorized\",\n matcher,\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(\n layouts,\n \"not-found\",\n matcher,\n );\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 matcher,\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 routeSegments: segments,\n layoutTreePositions,\n isDynamic,\n params,\n };\n}\n\n/**\n * Compute the tree position (directory depth from app root) for each layout.\n * Root layout = 0, a layout at app/blog/ = 1, app/blog/(group)/ = 2.\n * Counts ALL directory levels including route groups and parallel slots.\n */\nfunction computeLayoutTreePositions(\n appDir: string,\n layouts: string[],\n): number[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n if (layoutDir === appDir) return 0;\n const relative = path.relative(appDir, layoutDir);\n return relative.split(path.sep).length;\n });\n}\n\n/**\n * Discover all layout files from root to the given directory.\n * Each level of the directory tree may have a layout.tsx.\n */\nfunction discoverLayouts(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): string[] {\n const layouts: string[] = [];\n\n // Check root layout\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) layouts.push(rootLayout);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) layouts.push(layout);\n }\n\n return layouts;\n}\n\n/**\n * Discover all template files from root to the given directory.\n * Each level of the directory tree may have a template.tsx.\n * Templates are like layouts but re-mount on navigation.\n */\nfunction discoverTemplates(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): string[] {\n const templates: string[] = [];\n\n // Check root template\n const rootTemplate = findFile(appDir, \"template\", matcher);\n if (rootTemplate) templates.push(rootTemplate);\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const template = findFile(currentDir, \"template\", matcher);\n if (template) templates.push(template);\n }\n\n return templates;\n}\n\n/**\n * Discover error.tsx files aligned with the layouts array.\n * Walks the same directory levels as discoverLayouts and, for each level\n * that contributes a layout entry, checks whether error.tsx also exists.\n * Returns an array of the same length as discoverLayouts() would return,\n * with the error path (or null) at each corresponding layout level.\n *\n * This enables interleaving ErrorBoundary components with layouts in the\n * rendering tree, matching Next.js behavior where each segment independently\n * wraps its children with an error boundary.\n */\nfunction discoverLayoutAlignedErrors(\n segments: string[],\n appDir: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n const errors: (string | null)[] = [];\n\n // Root level (only if root has a layout — matching discoverLayouts logic)\n const rootLayout = findFile(appDir, \"layout\", matcher);\n if (rootLayout) {\n errors.push(findFile(appDir, \"error\", matcher));\n }\n\n // Check each directory level\n let currentDir = appDir;\n for (const segment of segments) {\n currentDir = path.join(currentDir, segment);\n const layout = findFile(currentDir, \"layout\", matcher);\n if (layout) {\n errors.push(findFile(currentDir, \"error\", matcher));\n }\n }\n\n return errors;\n}\n\n/**\n * Discover the nearest boundary file (not-found, forbidden, unauthorized)\n * by walking from the route's directory up to the app root.\n * Returns the first (closest) file found, or null.\n */\nfunction discoverBoundaryFile(\n segments: string[],\n appDir: string,\n fileName: string,\n matcher: ValidFileMatcher,\n): string | null {\n // Build all directory paths from leaf to root\n const dirs: string[] = [];\n let dir = appDir;\n dirs.push(dir);\n for (const segment of segments) {\n dir = path.join(dir, segment);\n dirs.push(dir);\n }\n\n // Walk from leaf (last) to root (first)\n for (let i = dirs.length - 1; i >= 0; i--) {\n const f = findFile(dirs[i], fileName, matcher);\n if (f) return f;\n }\n return null;\n}\n\n/**\n * Discover boundary files (not-found, forbidden, unauthorized) at each layout directory.\n * Returns an array aligned with the layouts array, where each entry is the boundary\n * file at that layout's directory, or null if none exists there.\n *\n * This is used for per-layout error boundaries. In Next.js, each layout level\n * has its own boundary that wraps the layout's children. When notFound() is thrown\n * from a layout, it propagates up to the parent layout's boundary.\n */\nfunction discoverBoundaryFilePerLayout(\n layouts: string[],\n fileName: string,\n matcher: ValidFileMatcher,\n): (string | null)[] {\n return layouts.map((layoutPath) => {\n const layoutDir = path.dirname(layoutPath);\n return findFile(layoutDir, fileName, matcher);\n });\n}\n\n/**\n * Discover parallel slots inherited from ancestor directories.\n *\n * In Next.js, parallel slots belong to the layout that defines them. When a\n * child route is rendered, its parent layout's slots must still be present.\n * If the child doesn't have matching content in a slot, the slot's default.tsx\n * is rendered instead.\n *\n * Walk from appDir through each segment to the route's directory. At each level\n * that has @slot dirs, collect them. Slots at the route's own directory level\n * use page.tsx; slots at ancestor levels use default.tsx only.\n */\nfunction discoverInheritedParallelSlots(\n segments: string[],\n appDir: string,\n routeDir: string,\n matcher: ValidFileMatcher,\n): ParallelSlot[] {\n const slotMap = new Map<string, ParallelSlot>();\n\n // Walk from appDir through each segment, tracking layout indices.\n // layoutIndex tracks which position in the route's layouts[] array corresponds\n // to a given directory. Only directories with a layout.tsx file increment.\n let currentDir = appDir;\n const dirsToCheck: { dir: string; layoutIdx: number }[] = [];\n let layoutIdx = findFile(appDir, \"layout\", matcher) ? 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\", matcher)) {\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, matcher);\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(\n dir: string,\n appDir: string,\n matcher: ValidFileMatcher,\n): ParallelSlot[] {\n if (!fs.existsSync(dir)) return [];\n\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n const slots: ParallelSlot[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n\n const slotName = entry.name.slice(1); // \"@team\" -> \"team\"\n const slotDir = path.join(dir, entry.name);\n\n const pagePath = findFile(slotDir, \"page\", matcher);\n const defaultPath = findFile(slotDir, \"default\", matcher);\n const interceptingRoutes = discoverInterceptingRoutes(\n slotDir,\n dir,\n appDir,\n matcher,\n );\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\", matcher),\n loadingPath: findFile(slotDir, \"loading\", matcher),\n errorPath: findFile(slotDir, \"error\", matcher),\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 matcher: ValidFileMatcher,\n): InterceptingRoute[] {\n if (!fs.existsSync(slotDir)) return [];\n\n const results: InterceptingRoute[] = [];\n\n // Recursively scan for page files inside intercepting directories\n scanForInterceptingPages(slotDir, routeDir, appDir, results, matcher);\n\n return results;\n}\n\n/**\n * Recursively scan a directory tree for page.tsx files that are inside\n * intercepting route directories.\n */\nfunction scanForInterceptingPages(\n currentDir: string,\n routeDir: string,\n appDir: string,\n results: InterceptingRoute[],\n matcher: ValidFileMatcher,\n): void {\n if (!fs.existsSync(currentDir)) return;\n\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n\n // Check if this directory name starts with an interception convention\n const interceptMatch = matchInterceptConvention(entry.name);\n\n if (interceptMatch) {\n // This directory is the start of an intercepting route\n // e.g. \"(.)photos\" means intercept same-level \"photos\" route\n const restOfName = entry.name.slice(interceptMatch.prefix.length);\n const interceptDir = path.join(currentDir, entry.name);\n\n // Find page files within this intercepting directory tree\n collectInterceptingPages(\n interceptDir,\n interceptDir,\n interceptMatch.convention,\n restOfName,\n routeDir,\n appDir,\n results,\n matcher,\n );\n } else {\n // Regular subdirectory — keep scanning for intercepting dirs\n scanForInterceptingPages(\n path.join(currentDir, entry.name),\n routeDir,\n appDir,\n results,\n matcher,\n );\n }\n }\n}\n\n/**\n * Match a directory name against interception convention prefixes.\n */\nfunction matchInterceptConvention(\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 matcher: ValidFileMatcher,\n): void {\n // Check for page.tsx in current directory\n const page = findFile(currentDir, \"page\", matcher);\n if (page) {\n const targetPattern = computeInterceptTarget(\n convention,\n interceptSegment,\n currentDir,\n interceptRoot,\n routeDir,\n appDir,\n );\n if (targetPattern) {\n results.push({\n convention,\n 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 matcher,\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 configured pageExtensions.\n */\nfunction findFile(\n dir: string,\n name: string,\n matcher: ValidFileMatcher,\n): string | null {\n for (const ext of matcher.dottedExtensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\n}\n\n/**\n * 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":"AAEA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,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,CAM3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,KAAK,EAAE,CAAC,CAWlB;AA2FD;;;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,CAC7B,QAAQ,EAAE,M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lB;AAoFD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK3D"}
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import { routePrecedence } from "./utils.js";
2
+ import { compareRoutes } from "./utils.js";
3
3
  import { createValidFileMatcher, scanWithExtensions, } from "./file-matcher.js";
4
4
  // Route cache — invalidated when pages directory changes
5
5
  const routeCache = new Map();
@@ -47,10 +47,7 @@ async function scanPageRoutes(pagesDir, matcher) {
47
47
  routes.push(route);
48
48
  }
49
49
  // Sort: static routes first, then dynamic, then catch-all
50
- routes.sort((a, b) => {
51
- const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);
52
- return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);
53
- });
50
+ routes.sort(compareRoutes);
54
51
  return routes;
55
52
  }
56
53
  /**
@@ -164,10 +161,7 @@ async function scanApiRoutes(pagesDir, matcher) {
164
161
  }
165
162
  }
166
163
  // Sort same as page routes
167
- routes.sort((a, b) => {
168
- const diff = routePrecedence(a.pattern) - routePrecedence(b.pattern);
169
- return diff !== 0 ? diff : a.pattern.localeCompare(b.pattern);
170
- });
164
+ routes.sort(compareRoutes);
171
165
  return routes;
172
166
  }
173
167
  function matchPattern(url, pattern) {