vinext 1.0.0-beta.1 → 1.0.0-beta.3

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 (234) hide show
  1. package/README.md +10 -10
  2. package/dist/build/client-build-config.js +8 -1
  3. package/dist/build/report.d.ts +8 -1
  4. package/dist/build/report.js +12 -2
  5. package/dist/check.js +19 -2
  6. package/dist/cli.js +3 -2
  7. package/dist/config/config-matchers.d.ts +13 -37
  8. package/dist/config/config-matchers.js +35 -122
  9. package/dist/config/next-config.d.ts +15 -5
  10. package/dist/config/next-config.js +7 -1
  11. package/dist/config/request-context.d.ts +14 -0
  12. package/dist/config/request-context.js +26 -0
  13. package/dist/entries/app-browser-entry.d.ts +4 -10
  14. package/dist/entries/app-browser-entry.js +20 -4
  15. package/dist/entries/app-rsc-entry.js +30 -9
  16. package/dist/entries/app-rsc-manifest.js +36 -0
  17. package/dist/entries/pages-client-entry.js +0 -1
  18. package/dist/entries/pages-server-entry.js +13 -5
  19. package/dist/index.js +194 -101
  20. package/dist/init-cloudflare.d.ts +3 -1
  21. package/dist/init-cloudflare.js +59 -5
  22. package/dist/init.d.ts +6 -4
  23. package/dist/init.js +20 -22
  24. package/dist/plugins/extensionless-dynamic-import.js +23 -18
  25. package/dist/plugins/ignore-dynamic-requests.js +3 -1
  26. package/dist/plugins/import-meta-url.js +17 -6
  27. package/dist/plugins/og-assets.js +1 -1
  28. package/dist/plugins/require-context.js +20 -15
  29. package/dist/plugins/transform-cache.d.ts +19 -0
  30. package/dist/plugins/transform-cache.js +36 -0
  31. package/dist/routing/app-route-graph.d.ts +27 -11
  32. package/dist/routing/app-route-graph.js +158 -22
  33. package/dist/routing/app-router.js +12 -6
  34. package/dist/routing/file-matcher.d.ts +11 -22
  35. package/dist/routing/file-matcher.js +21 -33
  36. package/dist/routing/pages-router.js +23 -29
  37. package/dist/routing/route-matching.d.ts +14 -1
  38. package/dist/routing/route-matching.js +13 -1
  39. package/dist/routing/route-pattern.d.ts +2 -1
  40. package/dist/routing/route-pattern.js +7 -4
  41. package/dist/routing/route-trie.d.ts +5 -1
  42. package/dist/routing/route-trie.js +5 -2
  43. package/dist/server/api-handler.d.ts +2 -0
  44. package/dist/server/api-handler.js +3 -3
  45. package/dist/server/app-browser-entry.js +110 -37
  46. package/dist/server/app-browser-history-controller.d.ts +1 -1
  47. package/dist/server/app-browser-history-controller.js +3 -3
  48. package/dist/server/app-browser-navigation-controller.d.ts +23 -21
  49. package/dist/server/app-browser-navigation-controller.js +2 -2
  50. package/dist/server/app-browser-state.js +1 -1
  51. package/dist/server/app-browser-visible-commit.js +1 -1
  52. package/dist/server/app-fallback-renderer.d.ts +3 -0
  53. package/dist/server/app-fallback-renderer.js +4 -2
  54. package/dist/server/app-middleware.js +2 -1
  55. package/dist/server/app-page-boundary-render.d.ts +12 -1
  56. package/dist/server/app-page-boundary-render.js +84 -2
  57. package/dist/server/app-page-cache-finalizer.d.ts +1 -1
  58. package/dist/server/app-page-cache-finalizer.js +1 -1
  59. package/dist/server/app-page-cache.d.ts +2 -2
  60. package/dist/server/app-page-cache.js +16 -2
  61. package/dist/server/app-page-dispatch.d.ts +19 -2
  62. package/dist/server/app-page-dispatch.js +45 -23
  63. package/dist/server/app-page-element-builder.d.ts +9 -2
  64. package/dist/server/app-page-element-builder.js +144 -33
  65. package/dist/server/app-page-head.d.ts +56 -4
  66. package/dist/server/app-page-head.js +216 -85
  67. package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
  68. package/dist/server/app-page-http-access-fallback-metadata.js +114 -0
  69. package/dist/server/app-page-probe.d.ts +4 -0
  70. package/dist/server/app-page-probe.js +6 -2
  71. package/dist/server/app-page-render.d.ts +2 -2
  72. package/dist/server/app-page-render.js +1 -1
  73. package/dist/server/app-page-request.d.ts +15 -0
  74. package/dist/server/app-page-request.js +134 -14
  75. package/dist/server/app-page-response.js +1 -1
  76. package/dist/server/app-page-route-wiring.d.ts +16 -0
  77. package/dist/server/app-page-route-wiring.js +254 -52
  78. package/dist/server/app-pages-bridge.d.ts +1 -1
  79. package/dist/server/app-pages-bridge.js +2 -1
  80. package/dist/server/app-post-middleware-context.d.ts +1 -1
  81. package/dist/server/app-post-middleware-context.js +1 -1
  82. package/dist/server/app-route-handler-cache.js +4 -0
  83. package/dist/server/app-route-handler-dispatch.js +40 -20
  84. package/dist/server/app-route-handler-execution.d.ts +6 -1
  85. package/dist/server/app-route-handler-execution.js +42 -16
  86. package/dist/server/app-route-handler-policy.d.ts +2 -0
  87. package/dist/server/app-route-handler-policy.js +3 -3
  88. package/dist/server/app-route-handler-response.js +1 -1
  89. package/dist/server/app-route-module-loader.d.ts +9 -1
  90. package/dist/server/app-route-module-loader.js +4 -0
  91. package/dist/server/app-router-entry.js +6 -3
  92. package/dist/server/app-rsc-cache-busting.d.ts +1 -1
  93. package/dist/server/app-rsc-errors.d.ts +1 -1
  94. package/dist/server/app-rsc-errors.js +22 -2
  95. package/dist/server/app-rsc-handler.d.ts +10 -5
  96. package/dist/server/app-rsc-handler.js +73 -33
  97. package/dist/server/app-rsc-request-normalization.d.ts +3 -2
  98. package/dist/server/app-rsc-request-normalization.js +8 -2
  99. package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
  100. package/dist/server/app-rsc-response-finalizer.js +5 -11
  101. package/dist/server/app-rsc-route-matching.d.ts +29 -0
  102. package/dist/server/app-rsc-route-matching.js +93 -11
  103. package/dist/server/app-segment-config.js +13 -3
  104. package/dist/server/app-server-action-execution.d.ts +3 -1
  105. package/dist/server/app-server-action-execution.js +9 -7
  106. package/dist/server/app-ssr-entry.js +6 -6
  107. package/dist/server/app-ssr-stream.d.ts +1 -7
  108. package/dist/server/app-ssr-stream.js +2 -10
  109. package/dist/server/cache-control.d.ts +2 -2
  110. package/dist/server/cache-control.js +2 -1
  111. package/dist/server/config-headers.d.ts +24 -0
  112. package/dist/server/config-headers.js +52 -0
  113. package/dist/server/dev-initial-server-error.d.ts +1 -1
  114. package/dist/server/dev-server.d.ts +3 -1
  115. package/dist/server/dev-server.js +170 -321
  116. package/dist/server/headers.d.ts +2 -2
  117. package/dist/server/headers.js +4 -3
  118. package/dist/server/isr-cache.d.ts +11 -34
  119. package/dist/server/isr-cache.js +33 -43
  120. package/dist/server/isr-decision.d.ts +2 -2
  121. package/dist/server/middleware-matcher-pattern.d.ts +22 -0
  122. package/dist/server/middleware-matcher-pattern.js +219 -0
  123. package/dist/server/middleware-matcher.d.ts +2 -7
  124. package/dist/server/middleware-matcher.js +13 -60
  125. package/dist/server/middleware-path-to-regexp.d.ts +14 -0
  126. package/dist/server/middleware-path-to-regexp.js +228 -0
  127. package/dist/server/middleware-runtime.js +4 -3
  128. package/dist/server/middleware.d.ts +1 -1
  129. package/dist/server/middleware.js +2 -1
  130. package/dist/server/pages-api-route.d.ts +2 -0
  131. package/dist/server/pages-api-route.js +4 -1
  132. package/dist/server/pages-data-route.d.ts +11 -1
  133. package/dist/server/pages-data-route.js +16 -1
  134. package/dist/server/pages-dev-hydration.js +0 -1
  135. package/dist/server/pages-get-initial-props.d.ts +16 -3
  136. package/dist/server/pages-get-initial-props.js +17 -10
  137. package/dist/server/pages-i18n.js +64 -16
  138. package/dist/server/pages-node-compat.d.ts +2 -0
  139. package/dist/server/pages-node-compat.js +7 -3
  140. package/dist/server/pages-page-data.d.ts +64 -10
  141. package/dist/server/pages-page-data.js +349 -80
  142. package/dist/server/pages-page-handler.d.ts +9 -3
  143. package/dist/server/pages-page-handler.js +131 -36
  144. package/dist/server/pages-page-response.d.ts +5 -3
  145. package/dist/server/pages-page-response.js +24 -27
  146. package/dist/server/pages-readiness.d.ts +3 -3
  147. package/dist/server/pages-request-pipeline.d.ts +8 -0
  148. package/dist/server/pages-request-pipeline.js +30 -12
  149. package/dist/server/pages-revalidate.d.ts +1 -1
  150. package/dist/server/pages-revalidate.js +54 -8
  151. package/dist/server/pages-router-entry.d.ts +1 -0
  152. package/dist/server/pages-router-entry.js +16 -4
  153. package/dist/server/prerender-route-params.js +2 -2
  154. package/dist/server/prod-server.d.ts +3 -5
  155. package/dist/server/prod-server.js +72 -35
  156. package/dist/server/request-pipeline.d.ts +15 -29
  157. package/dist/server/request-pipeline.js +24 -59
  158. package/dist/server/revalidation-host.d.ts +11 -0
  159. package/dist/server/revalidation-host.js +19 -0
  160. package/dist/server/rsc-stream-hints.js +122 -18
  161. package/dist/server/worker-revalidation-context.d.ts +13 -0
  162. package/dist/server/worker-revalidation-context.js +29 -0
  163. package/dist/shims/app.d.ts +1 -1
  164. package/dist/shims/cache-handler.d.ts +1 -1
  165. package/dist/shims/cache-handler.js +10 -7
  166. package/dist/shims/cache-request-state.d.ts +27 -1
  167. package/dist/shims/cache-request-state.js +60 -1
  168. package/dist/shims/cache-runtime.d.ts +18 -1
  169. package/dist/shims/cache-runtime.js +26 -8
  170. package/dist/shims/cache.d.ts +5 -5
  171. package/dist/shims/cache.js +27 -11
  172. package/dist/shims/document.d.ts +42 -83
  173. package/dist/shims/document.js +62 -53
  174. package/dist/shims/dynamic.d.ts +5 -25
  175. package/dist/shims/dynamic.js +29 -8
  176. package/dist/shims/error.d.ts +1 -1
  177. package/dist/shims/error.js +2 -2
  178. package/dist/shims/fetch-cache.js +13 -4
  179. package/dist/shims/font-google-base.d.ts +11 -4
  180. package/dist/shims/font-google-base.js +17 -8
  181. package/dist/shims/font-local.d.ts +10 -3
  182. package/dist/shims/font-local.js +41 -10
  183. package/dist/shims/head.d.ts +13 -2
  184. package/dist/shims/head.js +3 -3
  185. package/dist/shims/headers.d.ts +37 -43
  186. package/dist/shims/headers.js +183 -74
  187. package/dist/shims/image.d.ts +27 -37
  188. package/dist/shims/image.js +21 -14
  189. package/dist/shims/internal/cookie-serialize.d.ts +12 -9
  190. package/dist/shims/internal/cookie-serialize.js +10 -7
  191. package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
  192. package/dist/shims/internal/interpolate-as.d.ts +15 -1
  193. package/dist/shims/internal/interpolate-as.js +27 -2
  194. package/dist/shims/internal/utils.d.ts +3 -3
  195. package/dist/shims/legacy-image.d.ts +3 -37
  196. package/dist/shims/legacy-image.js +6 -16
  197. package/dist/shims/link.d.ts +15 -22
  198. package/dist/shims/link.js +34 -13
  199. package/dist/shims/metadata.d.ts +7 -17
  200. package/dist/shims/metadata.js +74 -24
  201. package/dist/shims/navigation-context-state.d.ts +1 -1
  202. package/dist/shims/navigation.d.ts +7 -3
  203. package/dist/shims/navigation.js +25 -14
  204. package/dist/shims/navigation.react-server.js +1 -1
  205. package/dist/shims/next-shims-augmentations.d.ts +1 -0
  206. package/dist/shims/next-shims-public.d.ts +1 -0
  207. package/dist/shims/public-shim-map.json.js +103 -0
  208. package/dist/shims/readonly-url-search-params.d.ts +3 -3
  209. package/dist/shims/readonly-url-search-params.js +3 -3
  210. package/dist/shims/request-context.d.ts +4 -1
  211. package/dist/shims/request-state-types.d.ts +1 -1
  212. package/dist/shims/router.d.ts +55 -21
  213. package/dist/shims/router.js +180 -44
  214. package/dist/shims/script.d.ts +6 -10
  215. package/dist/shims/script.js +7 -4
  216. package/dist/shims/server.d.ts +50 -26
  217. package/dist/shims/server.js +193 -55
  218. package/dist/shims/unified-request-context.d.ts +22 -3
  219. package/dist/shims/unified-request-context.js +84 -1
  220. package/dist/shims/url-safety.d.ts +1 -1
  221. package/dist/shims/url-safety.js +2 -2
  222. package/dist/typegen.d.ts +8 -2
  223. package/dist/typegen.js +76 -15
  224. package/dist/utils/cache-control-metadata.d.ts +2 -1
  225. package/dist/utils/cache-control-metadata.js +5 -1
  226. package/dist/utils/domain-locale.d.ts +2 -2
  227. package/dist/utils/external-url.d.ts +5 -0
  228. package/dist/utils/external-url.js +7 -0
  229. package/dist/utils/html-limited-bots.js +1 -1
  230. package/dist/utils/protocol-headers.d.ts +7 -1
  231. package/dist/utils/protocol-headers.js +7 -1
  232. package/dist/utils/regex-safety.d.ts +8 -0
  233. package/dist/utils/regex-safety.js +737 -0
  234. package/package.json +13 -2
@@ -0,0 +1,14 @@
1
+ //#region src/config/request-context.d.ts
2
+ /** Request context needed for evaluating has/missing conditions. */
3
+ type RequestContext = {
4
+ readonly headers: Headers;
5
+ readonly cookies: Record<string, string>;
6
+ readonly query: URLSearchParams;
7
+ readonly host: string;
8
+ };
9
+ declare function parseCookies(cookieHeader: string | null): Record<string, string>;
10
+ declare function normalizeHost(hostHeader: string | null, fallbackHostname: string): string;
11
+ /** Build a lazily parsed request context from a Web Request. */
12
+ declare function requestContextFromRequest(request: Request): RequestContext;
13
+ //#endregion
14
+ export { RequestContext, normalizeHost, parseCookies, requestContextFromRequest };
@@ -0,0 +1,26 @@
1
+ import { parseCookieHeader } from "../utils/parse-cookie.js";
2
+ //#region src/config/request-context.ts
3
+ function parseCookies(cookieHeader) {
4
+ return parseCookieHeader(cookieHeader);
5
+ }
6
+ function normalizeHost(hostHeader, fallbackHostname) {
7
+ return (hostHeader ?? fallbackHostname).split(":", 1)[0].toLowerCase();
8
+ }
9
+ /** Build a lazily parsed request context from a Web Request. */
10
+ function requestContextFromRequest(request) {
11
+ const url = new URL(request.url);
12
+ let cookies;
13
+ let query;
14
+ return {
15
+ headers: request.headers,
16
+ get cookies() {
17
+ return cookies ??= parseCookies(request.headers.get("cookie"));
18
+ },
19
+ get query() {
20
+ return query ??= url.searchParams;
21
+ },
22
+ host: normalizeHost(request.headers.get("host"), url.hostname)
23
+ };
24
+ }
25
+ //#endregion
26
+ export { normalizeHost, parseCookies, requestContextFromRequest };
@@ -15,15 +15,9 @@ declare function generateBrowserEntry(routes?: readonly AppRoute[], routeManifes
15
15
  beforeFiles: NextRewrite[];
16
16
  fallback: NextRewrite[];
17
17
  }): string;
18
- /**
19
- * Filter for routes that should appear in the `__VINEXT_LINK_PREFETCH_ROUTES__`
20
- * manifest. Exported so the Pages Router client entry can reuse it when
21
- * emitting the same manifest for hybrid builds — see issue #1526 and
22
- * `pages-client-entry.ts`.
23
- */
24
- declare function isLinkPrefetchRoute(route: AppRoute): boolean;
25
- declare function toDocumentOnlyAppRoute(route: AppRoute): VinextLinkPrefetchRoute;
26
18
  /** Project an `AppRoute` down to the public `VinextLinkPrefetchRoute` shape. */
27
- declare function toLinkPrefetchRoute(route: AppRoute): VinextLinkPrefetchRoute;
19
+ declare function toLinkPrefetchRoute(route: AppRoute, hasSiblingInterceptLoading?: boolean): VinextLinkPrefetchRoute;
20
+ /** Project App routes together so sibling-intercept loading is applied to its target route. */
21
+ declare function toLinkPrefetchRoutes(routes: readonly AppRoute[]): VinextLinkPrefetchRoute[];
28
22
  //#endregion
29
- export { generateBrowserEntry, isLinkPrefetchRoute, toDocumentOnlyAppRoute, toLinkPrefetchRoute };
23
+ export { generateBrowserEntry, toLinkPrefetchRoute, toLinkPrefetchRoutes };
@@ -1,4 +1,5 @@
1
1
  import { resolveClientRuntimeModule, resolveRuntimeEntryModule } from "./runtime-entry-module.js";
2
+ import { patternsStructurallyEquivalent } from "../routing/app-route-graph.js";
2
3
  //#region src/entries/app-browser-entry.ts
3
4
  /**
4
5
  * Generate the virtual browser entry module.
@@ -14,7 +15,7 @@ function generateBrowserEntry(routes = [], routeManifest = null, pagesPrefetchRo
14
15
  }) {
15
16
  const entryPath = resolveRuntimeEntryModule("app-browser-entry");
16
17
  const navigationRuntimePath = resolveClientRuntimeModule("navigation-runtime");
17
- const prefetchRoutes = routes.map((route) => isLinkPrefetchRoute(route) ? toLinkPrefetchRoute(route) : toDocumentOnlyAppRoute(route));
18
+ const prefetchRoutes = toLinkPrefetchRoutes(routes);
18
19
  return `import { registerNavigationRuntimeBootstrap } from ${JSON.stringify(navigationRuntimePath)};
19
20
 
20
21
  window.__VINEXT_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(prefetchRoutes)};
@@ -50,15 +51,30 @@ function toDocumentOnlyAppRoute(route) {
50
51
  function requiresDynamicNavigationRequest(route) {
51
52
  return route.isDynamic && route.parallelSlots.length > 0;
52
53
  }
54
+ function splitPatternParts(pattern) {
55
+ return pattern.split("/").filter(Boolean);
56
+ }
57
+ function interceptTargetsRoute(interceptTargetPattern, route) {
58
+ return patternsStructurallyEquivalent(splitPatternParts(interceptTargetPattern), route.patternParts);
59
+ }
60
+ function hasLoadingBoundary(route, hasSiblingInterceptLoading) {
61
+ return route.loadingPath !== null || (route.loadingPaths?.length ?? 0) > 0 || route.parallelSlots.some((slot) => slot.loadingPath !== null || (slot.loadingPaths?.length ?? 0) > 0 || slot.interceptingRoutes.some((intercept) => interceptTargetsRoute(intercept.targetPattern, route) && (intercept.loadingPaths?.length ?? 0) > 0)) || hasSiblingInterceptLoading;
62
+ }
53
63
  /** Project an `AppRoute` down to the public `VinextLinkPrefetchRoute` shape. */
54
- function toLinkPrefetchRoute(route) {
64
+ function toLinkPrefetchRoute(route, hasSiblingInterceptLoading = route.siblingIntercepts.some((intercept) => interceptTargetsRoute(intercept.targetPattern, route) && (intercept.loadingPaths?.length ?? 0) > 0)) {
55
65
  return {
56
- canPrefetchLoadingShell: route.loadingPath !== null,
66
+ canPrefetchLoadingShell: hasLoadingBoundary(route, hasSiblingInterceptLoading),
57
67
  patternParts: [...route.patternParts],
58
68
  isDynamic: route.isDynamic,
59
69
  ...requiresDynamicNavigationRequest(route) ? { requiresDynamicNavigationRequest: true } : {}
60
70
  };
61
71
  }
72
+ /** Project App routes together so sibling-intercept loading is applied to its target route. */
73
+ function toLinkPrefetchRoutes(routes) {
74
+ const siblingInterceptLoadingTargets = [];
75
+ for (const route of routes) for (const intercept of route.siblingIntercepts) if ((intercept.loadingPaths?.length ?? 0) > 0) siblingInterceptLoadingTargets.push(splitPatternParts(intercept.targetPattern));
76
+ return routes.map((route) => isLinkPrefetchRoute(route) ? toLinkPrefetchRoute(route, siblingInterceptLoadingTargets.some((targetParts) => patternsStructurallyEquivalent(targetParts, route.patternParts))) : toDocumentOnlyAppRoute(route));
77
+ }
62
78
  function buildRouteManifestExpression(routeManifest) {
63
79
  if (routeManifest === null) return "null";
64
80
  const graph = routeManifest.segmentGraph;
@@ -84,4 +100,4 @@ function buildMapExpression(map) {
84
100
  return `new Map(${JSON.stringify(Array.from(map.entries()))})`;
85
101
  }
86
102
  //#endregion
87
- export { generateBrowserEntry, isLinkPrefetchRoute, toDocumentOnlyAppRoute, toLinkPrefetchRoute };
103
+ export { generateBrowserEntry, toLinkPrefetchRoute, toLinkPrefetchRoutes };
@@ -195,6 +195,7 @@ import {
195
195
  isrGet as __isrGet,
196
196
  isrSet as __isrSet,
197
197
  isrSetPrerenderedAppPage as __isrSetPrerenderedAppPage,
198
+ isOnDemandRevalidateRequest as __isOnDemandRevalidateRequest,
198
199
  triggerBackgroundRegeneration as __triggerBackgroundRegeneration,
199
200
  } from ${JSON.stringify(isrCachePath)};
200
201
  // Import server-only state module to register ALS-backed accessors.
@@ -401,6 +402,10 @@ function matchRoute(url) {
401
402
  return __routeMatcher.matchRoute(url);
402
403
  }
403
404
 
405
+ function matchRequestRoute(url) {
406
+ return __routeMatcher.matchRequestRoute(url);
407
+ }
408
+
404
409
  /**
405
410
  * Check if a pathname matches any intercepting route.
406
411
  * Returns the match info or null.
@@ -432,6 +437,8 @@ async function buildPageElements(route, params, routePath, pageRequest, layoutPa
432
437
  }
433
438
 
434
439
  const __i18nConfig = ${JSON.stringify(i18nConfig)};
440
+ export { __i18nConfig };
441
+ export const authorizeOnDemandRevalidate = __isOnDemandRevalidateRequest;
435
442
  const __configRedirects = ${JSON.stringify(redirects)};
436
443
  const __configRewrites = ${JSON.stringify(rewrites)};
437
444
  const __configHeaders = ${JSON.stringify(headers)};
@@ -523,6 +530,7 @@ export default createAppRscHandler({
523
530
  actionFailed,
524
531
  handlerStart,
525
532
  interceptionContext,
533
+ interceptionPathname,
526
534
  isProgressiveActionRender,
527
535
  isRscRequest,
528
536
  middlewareContext,
@@ -589,6 +597,7 @@ export default createAppRscHandler({
589
597
  observeMetadataSearchParamsAccess: buildOptions?.observeMetadataSearchParamsAccess === true,
590
598
  observePageSearchParamsAccess: buildOptions?.observePageSearchParamsAccess === true,
591
599
  serveStreamingMetadata: buildOptions?.serveStreamingMetadata,
600
+ isProduction: process.env.NODE_ENV === "production",
592
601
  }, layoutParamAccess, displayPathname);
593
602
  },
594
603
  clientReuseManifest,
@@ -608,7 +617,10 @@ export default createAppRscHandler({
608
617
  fetchCache: __segmentConfig.fetchCache ?? null,
609
618
  isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
610
619
  findIntercept(pathname) {
611
- return findIntercept(pathname, interceptionContext);
620
+ return findIntercept(
621
+ pathname === cleanPathname ? interceptionPathname : pathname,
622
+ interceptionContext,
623
+ );
612
624
  },
613
625
  generateStaticParams: __generateStaticParams,
614
626
  getFontLinks: _getSSRFontLinks,
@@ -660,7 +672,7 @@ export default createAppRscHandler({
660
672
  });
661
673
  },
662
674
  async probePage(probeSearchParams = searchParams) {
663
- const __probeIntercept = findIntercept(cleanPathname, interceptionContext);
675
+ const __probeIntercept = findIntercept(interceptionPathname, interceptionContext);
664
676
  // The intercepting-route page module is lazy (page: null + __pageLoader).
665
677
  // Resolve it before probing so buildAppPageProbes inspects the real page
666
678
  // component for dynamic bailout — matching the render path, which also
@@ -682,7 +694,7 @@ export default createAppRscHandler({
682
694
  }));
683
695
  },
684
696
  renderErrorBoundaryPage(renderErr, errorOrigin) {
685
- const __activeIntercept = findIntercept(cleanPathname, interceptionContext);
697
+ const __activeIntercept = findIntercept(interceptionPathname, interceptionContext);
686
698
  return __fallbackRenderer.renderErrorBoundary(route, renderErr, isRscRequest, request, params, scriptNonce, middlewareContext, {
687
699
  isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
688
700
  sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
@@ -691,9 +703,10 @@ export default createAppRscHandler({
691
703
  }, errorOrigin);
692
704
  },
693
705
  renderHttpAccessFallbackPage(statusCode, opts, currentMiddlewareContext) {
694
- const __activeIntercept = findIntercept(cleanPathname, interceptionContext);
706
+ const __activeIntercept = findIntercept(interceptionPathname, interceptionContext);
695
707
  return __fallbackRenderer.renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, currentMiddlewareContext, {
696
708
  isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
709
+ routePathname: cleanPathname,
697
710
  sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
698
711
  ? __activeIntercept.sourcePageSegments
699
712
  : null,
@@ -772,6 +785,7 @@ export default createAppRscHandler({
772
785
  contentType,
773
786
  middlewareContext,
774
787
  request,
788
+ routeMatch,
775
789
  }) {
776
790
  const {
777
791
  handleProgressiveServerActionRequest: __handleProgressiveServerActionRequest,
@@ -792,11 +806,10 @@ export default createAppRscHandler({
792
806
  contentType,
793
807
  actionId,
794
808
  );
795
- const __progressiveActionMatch = __isProgressiveAction ? matchRoute(cleanPathname) : null;
796
809
  const __hasPageRoute = Boolean(
797
- __progressiveActionMatch &&
798
- __progressiveActionMatch.route.__loadPage &&
799
- !__progressiveActionMatch.route.__loadRouteHandler,
810
+ __isProgressiveAction &&
811
+ routeMatch?.route.__loadPage &&
812
+ !routeMatch.route.__loadRouteHandler,
800
813
  );
801
814
  return __handleProgressiveServerActionRequest({
802
815
  actionId,
@@ -829,6 +842,8 @@ export default createAppRscHandler({
829
842
  middlewareContext,
830
843
  mountedSlotsHeader,
831
844
  request,
845
+ routeMatch,
846
+ routePathname,
832
847
  searchParams,
833
848
  }) {
834
849
  const {
@@ -836,7 +851,7 @@ export default createAppRscHandler({
836
851
  readActionBodyWithLimit: __readBodyWithLimit,
837
852
  readActionFormDataWithLimit: __readFormDataWithLimit,
838
853
  } = await __loadAppServerActionExecution();
839
- const __actionMatch = matchRoute(cleanPathname);
854
+ const __actionMatch = routeMatch;
840
855
  if (__actionMatch) await __ensureRouteLoaded(__actionMatch.route);
841
856
  const __actionIsEdgeRuntime = __actionMatch
842
857
  ? __isEdgeRuntime(__resolveRouteRuntime(__actionMatch.route))
@@ -876,6 +891,8 @@ export default createAppRscHandler({
876
891
  __clearRequestContext();
877
892
  },
878
893
  contentType,
894
+ currentRouteMatch: __actionMatch,
895
+ currentRoutePathname: routePathname,
879
896
  createNotFoundElement(actionRouteId) {
880
897
  return {
881
898
  ...__AppElementsWire.createMetadataEntries({
@@ -940,6 +957,9 @@ export default createAppRscHandler({
940
957
  interceptLayouts: intercept.interceptLayouts,
941
958
  interceptLayoutSegments: intercept.interceptLayoutSegments,
942
959
  interceptBranchSegments: intercept.interceptBranchSegments,
960
+ interceptNotFoundBranchSegments: intercept.interceptNotFoundBranchSegments,
961
+ interceptNotFound: intercept.notFound,
962
+ interceptNotFoundTreePosition: intercept.notFoundTreePosition,
943
963
  interceptSlotId: intercept.slotId,
944
964
  interceptSlotKey: intercept.slotKey,
945
965
  interceptSourceMatchedUrl: interceptionContext,
@@ -963,6 +983,7 @@ export default createAppRscHandler({
963
983
  });
964
984
  },` : ""}
965
985
  matchRoute,
986
+ matchRequestRoute,
966
987
  ${middlewarePath ? `runMiddleware({ cleanPathname, context, hadBasePath, isDataRequest, request }) {
967
988
  return __applyAppMiddleware({
968
989
  basePath: __basePath,
@@ -53,6 +53,7 @@ function registerRouteModules(routes, imports) {
53
53
  for (const layout of route.layouts) imports.getLazyLoaderVar(layout);
54
54
  for (const tmpl of route.templates) imports.getLazyLoaderVar(tmpl);
55
55
  if (route.loadingPath) imports.getLazyLoaderVar(route.loadingPath);
56
+ for (const loadingPath of route.loadingPaths ?? []) imports.getLazyLoaderVar(loadingPath);
56
57
  if (route.errorPath) imports.getLazyLoaderVar(route.errorPath);
57
58
  if (route.layoutErrorPaths) {
58
59
  for (const ep of route.layoutErrorPaths) if (ep) imports.getLazyLoaderVar(ep);
@@ -76,15 +77,21 @@ function registerRouteModules(routes, imports) {
76
77
  if (slot.layoutPath) imports.getLazyLoaderVar(slot.layoutPath);
77
78
  for (const layoutPath of slot.configLayoutPaths ?? []) imports.getLazyLoaderVar(layoutPath);
78
79
  if (slot.loadingPath) imports.getLazyLoaderVar(slot.loadingPath);
80
+ for (const loadingPath of slot.loadingPaths ?? []) imports.getLazyLoaderVar(loadingPath);
79
81
  if (slot.errorPath) imports.getLazyLoaderVar(slot.errorPath);
82
+ if (slot.notFoundPath) imports.getLazyLoaderVar(slot.notFoundPath);
80
83
  for (const ir of slot.interceptingRoutes) {
81
84
  imports.getLazyLoaderVar(ir.pagePath);
85
+ if (ir.notFoundPath) imports.getLazyLoaderVar(ir.notFoundPath);
82
86
  for (const layoutPath of ir.layoutPaths) imports.getLazyLoaderVar(layoutPath);
87
+ for (const loadingPath of ir.loadingPaths ?? []) imports.getLazyLoaderVar(loadingPath);
83
88
  }
84
89
  }
85
90
  for (const ir of route.siblingIntercepts ?? []) {
86
91
  imports.getLazyLoaderVar(ir.pagePath);
92
+ if (ir.notFoundPath) imports.getLazyLoaderVar(ir.notFoundPath);
87
93
  for (const layoutPath of ir.layoutPaths) imports.getLazyLoaderVar(layoutPath);
94
+ for (const loadingPath of ir.loadingPaths ?? []) imports.getLazyLoaderVar(loadingPath);
88
95
  }
89
96
  }
90
97
  }
@@ -99,10 +106,12 @@ function buildRouteEntries(routes, imports) {
99
106
  const staticSiblings = route.isDynamic ? computeAppRouteStaticSiblings(routes, route) : [];
100
107
  const layoutLoaders = lazyLoaderArray(route.layouts, imports);
101
108
  const templateLoaders = lazyLoaderArray(route.templates, imports);
109
+ const loadingPaths = route.loadingPaths ?? [];
102
110
  const notFoundPaths = route.notFoundPaths ?? [];
103
111
  const forbiddenPaths = route.forbiddenPaths ?? [];
104
112
  const unauthorizedPaths = route.unauthorizedPaths ?? [];
105
113
  const notFoundLoaders = lazyLoaderArray(notFoundPaths, imports);
114
+ const loadingLoaders = lazyLoaderArray(loadingPaths, imports);
106
115
  const forbiddenLoaders = lazyLoaderArray(forbiddenPaths, imports);
107
116
  const unauthorizedLoaders = lazyLoaderArray(unauthorizedPaths, imports);
108
117
  const siblingInterceptEntries = (route.siblingIntercepts ?? []).map((ir) => ` {
@@ -115,8 +124,15 @@ function buildRouteEntries(routes, imports) {
115
124
  __loadInterceptLayouts: ${lazyLoaderArray(ir.layoutPaths, imports)},
116
125
  interceptLayoutSegments: ${JSON.stringify(ir.layoutSegments ?? [])},
117
126
  interceptBranchSegments: ${JSON.stringify(ir.branchSegments ?? [])},
127
+ interceptLoadings: ${moduleArray(ir.loadingPaths?.length ?? 0)},
128
+ __loadInterceptLoadings: ${lazyLoaderArray(ir.loadingPaths ?? [], imports)},
129
+ interceptLoadingTreePositions: ${JSON.stringify(ir.loadingTreePositions ?? [])},
130
+ interceptNotFoundBranchSegments: ${JSON.stringify(ir.notFoundBranchSegments ?? ir.branchSegments ?? [])},
118
131
  page: null,
119
132
  __pageLoader: ${imports.getLazyLoaderVar(ir.pagePath)},
133
+ notFound: null,
134
+ __loadNotFound: ${ir.notFoundPath ? imports.getLazyLoaderVar(ir.notFoundPath) : "null"},
135
+ notFoundTreePosition: ${ir.notFoundTreePosition ?? "null"},
120
136
  params: ${JSON.stringify(ir.params)},
121
137
  }`);
122
138
  const slotEntries = route.parallelSlots.map((slot) => {
@@ -129,13 +145,21 @@ function buildRouteEntries(routes, imports) {
129
145
  __loadInterceptLayouts: ${lazyLoaderArray(ir.layoutPaths, imports)},
130
146
  interceptLayoutSegments: ${JSON.stringify(ir.layoutSegments ?? [])},
131
147
  interceptBranchSegments: ${JSON.stringify(ir.branchSegments ?? [])},
148
+ interceptLoadings: ${moduleArray(ir.loadingPaths?.length ?? 0)},
149
+ __loadInterceptLoadings: ${lazyLoaderArray(ir.loadingPaths ?? [], imports)},
150
+ interceptLoadingTreePositions: ${JSON.stringify(ir.loadingTreePositions ?? [])},
151
+ interceptNotFoundBranchSegments: ${JSON.stringify(ir.notFoundBranchSegments ?? ir.branchSegments ?? [])},
132
152
  page: null,
133
153
  __pageLoader: ${imports.getLazyLoaderVar(ir.pagePath)},
154
+ notFound: null,
155
+ __loadNotFound: ${ir.notFoundPath ? imports.getLazyLoaderVar(ir.notFoundPath) : "null"},
156
+ notFoundTreePosition: ${ir.notFoundTreePosition ?? "null"},
134
157
  params: ${JSON.stringify(ir.params)},
135
158
  }`);
136
159
  return ` ${JSON.stringify(slot.key)}: {
137
160
  id: ${JSON.stringify(slot.id ?? null)},
138
161
  name: ${JSON.stringify(slot.name)},
162
+ ownerTreePosition: ${slot.ownerTreePosition ?? "null"},
139
163
  page: null,
140
164
  __loadPage: ${slot.pagePath ? imports.getLazyLoaderVar(slot.pagePath) : "null"},
141
165
  default: null,
@@ -147,8 +171,14 @@ function buildRouteEntries(routes, imports) {
147
171
  configLayoutTreePositions: ${JSON.stringify(slot.configLayoutTreePositions ?? [])},
148
172
  loading: null,
149
173
  __loadLoading: ${slot.loadingPath ? imports.getLazyLoaderVar(slot.loadingPath) : "null"},
174
+ loadings: ${moduleArray(slot.loadingPaths?.length ?? 0)},
175
+ __loadLoadings: ${lazyLoaderArray(slot.loadingPaths ?? [], imports)},
176
+ loadingTreePositions: ${JSON.stringify(slot.loadingTreePositions ?? [])},
150
177
  error: null,
151
178
  __loadError: ${slot.errorPath ? imports.getLazyLoaderVar(slot.errorPath) : "null"},
179
+ notFound: null,
180
+ __loadNotFound: ${slot.notFoundPath ? imports.getLazyLoaderVar(slot.notFoundPath) : "null"},
181
+ notFoundTreePosition: ${slot.notFoundTreePosition ?? "null"},
152
182
  layoutIndex: ${slot.layoutIndex},
153
183
  routeSegments: ${JSON.stringify(slot.routeSegments)},
154
184
  slotPatternParts: ${slot.slotPatternParts ? JSON.stringify(slot.slotPatternParts) : "null"},
@@ -186,6 +216,9 @@ ${interceptEntries.join(",\n")}
186
216
  layoutTreePositions: ${JSON.stringify(route.layoutTreePositions)},
187
217
  templates: ${moduleArray(route.templates.length)},
188
218
  __loadTemplates: ${templateLoaders},
219
+ loadings: ${moduleArray(loadingPaths.length)},
220
+ __loadLoadings: ${loadingLoaders},
221
+ loadingTreePositions: ${JSON.stringify(route.loadingTreePositions ?? null)},
189
222
  errors: ${moduleArray(layoutErrorPaths.length)},
190
223
  __loadErrors: ${layoutErrorLoaders},
191
224
  errorPaths: ${moduleArray(errorPaths.length)},
@@ -204,14 +237,17 @@ ${siblingInterceptEntries.join(",\n")}
204
237
  __loadError: ${route.errorPath ? imports.getLazyLoaderVar(route.errorPath) : "null"},
205
238
  notFound: null,
206
239
  __loadNotFound: ${route.notFoundPath ? imports.getLazyLoaderVar(route.notFoundPath) : "null"},
240
+ notFoundTreePosition: ${route.notFoundTreePosition ?? "null"},
207
241
  notFounds: ${moduleArray(notFoundPaths.length)},
208
242
  __loadNotFounds: ${notFoundLoaders},
209
243
  forbidden: null,
210
244
  __loadForbidden: ${route.forbiddenPath ? imports.getLazyLoaderVar(route.forbiddenPath) : "null"},
245
+ forbiddenTreePosition: ${route.forbiddenTreePosition ?? "null"},
211
246
  forbiddens: ${moduleArray(forbiddenPaths.length)},
212
247
  __loadForbiddens: ${forbiddenLoaders},
213
248
  unauthorized: null,
214
249
  __loadUnauthorized: ${route.unauthorizedPath ? imports.getLazyLoaderVar(route.unauthorizedPath) : "null"},
250
+ unauthorizedTreePosition: ${route.unauthorizedTreePosition ?? "null"},
215
251
  unauthorizeds: ${moduleArray(unauthorizedPaths.length)},
216
252
  __loadUnauthorizeds: ${unauthorizedLoaders},
217
253
  }`;
@@ -177,7 +177,6 @@ async function hydrate() {
177
177
  element = React.createElement(AppComponent, {
178
178
  ...props,
179
179
  Component: PageComponent,
180
- pageProps: rawPageProps,
181
180
  router: Router,
182
181
  });
183
182
  } catch {
@@ -24,6 +24,7 @@ const _pagesApiRoutePath = resolveEntryPath("../server/pages-api-route.js", impo
24
24
  const _serverGlobalsPath = resolveEntryPath("../server/server-globals.js", import.meta.url);
25
25
  const _queryUtilsPath = resolveEntryPath("../utils/query.js", import.meta.url);
26
26
  const _pagesPageHandlerPath = resolveEntryPath("../server/pages-page-handler.js", import.meta.url);
27
+ const _isrCachePath = resolveEntryPath("../server/isr-cache.js", import.meta.url);
27
28
  async function getPagesDataKind(filePath) {
28
29
  const source = await readFile(filePath, "utf8");
29
30
  if (hasExportedName(source, "getStaticProps")) return "static";
@@ -71,6 +72,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
71
72
  },
72
73
  headers: nextConfig?.headers ?? [],
73
74
  expireTime: nextConfig?.expireTime,
75
+ allowedRevalidateHeaderKeys: nextConfig?.allowedRevalidateHeaderKeys ?? [],
74
76
  cacheMaxMemorySize: nextConfig?.cacheMaxMemorySize,
75
77
  htmlLimitedBots: nextConfig?.htmlLimitedBots,
76
78
  i18n: nextConfig?.i18n ?? null,
@@ -151,11 +153,17 @@ import { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_p
151
153
  import { normalizePagesDataRequest as __normalizePagesDataRequest, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse } from ${JSON.stringify(_pagesDataRoutePath)};
152
154
  import { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};
153
155
  import { createPagesPageHandler as __createPagesPageHandler } from ${JSON.stringify(_pagesPageHandlerPath)};
156
+ import { isOnDemandRevalidateRequest as __isOnDemandRevalidateRequest } from ${JSON.stringify(_isrCachePath)};
154
157
  ${instrumentationImportCode}
155
158
  ${middlewareImportCode}
156
159
 
157
160
  ${instrumentationInitCode}
158
161
 
162
+ // The outer Node production pipeline runs outside this generated bundle, so
163
+ // it cannot safely validate against its own development fallback secret. Give
164
+ // it a verifier closed over this entry's build-time-baked secret instead.
165
+ export const authorizeOnDemandRevalidate = __isOnDemandRevalidateRequest;
166
+
159
167
  // i18n config (embedded at build time)
160
168
  const i18nConfig = ${i18nConfigJson};
161
169
 
@@ -236,8 +244,8 @@ const _apiRouteTrie = _buildRouteTrie(apiRoutes);
236
244
  function matchRoute(url, routes) {
237
245
  const pathname = url.split("?")[0];
238
246
  let normalizedUrl = pathname === "/" ? "/" : pathname.replace(/\\/$/, "");
239
- // NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at
240
- // the entry point. Decoding again would create a double-decode vector.
247
+ // Static route selection uses raw encoded identity (/%61bout must not
248
+ // select /about). _trieMatch decodes dynamic captures exactly once.
241
249
  const urlParts = normalizedUrl.split("/").filter(Boolean);
242
250
  const trie = routes === pageRoutes ? _pageRouteTrie : _apiRouteTrie;
243
251
  return _trieMatch(trie, urlParts);
@@ -307,6 +315,7 @@ const _renderPage = __createPagesPageHandler({
307
315
  : null,
308
316
  setI18nContext: typeof setI18nContext === "function" ? setI18nContext : null,
309
317
  wrapWithRouterContext: typeof wrapWithRouterContext === "function" ? wrapWithRouterContext : null,
318
+ router: Router,
310
319
  resetSSRHead: typeof resetSSRHead === "function" ? resetSSRHead : undefined,
311
320
  getSSRHeadHTML: typeof getSSRHeadHTML === "function" ? getSSRHeadHTML : undefined,
312
321
  setDocumentInitialHead: typeof setDocumentInitialHead === "function" ? setDocumentInitialHead : undefined,
@@ -343,7 +352,6 @@ const _renderPage = __createPagesPageHandler({
343
352
  ? React.createElement(AppComponent, {
344
353
  ...props,
345
354
  Component: PageComponent,
346
- pageProps: rawPageProps,
347
355
  router: Router,
348
356
  })
349
357
  : React.createElement(PageComponent, pageProps);
@@ -361,7 +369,6 @@ const _renderPage = __createPagesPageHandler({
361
369
  ? React.createElement(FinalApp, {
362
370
  ...props,
363
371
  Component: FinalComp,
364
- pageProps: rawPageProps,
365
372
  router: Router,
366
373
  })
367
374
  : React.createElement(FinalComp, pageProps);
@@ -378,7 +385,7 @@ export async function renderPage(request, url, manifest, ctx, middlewareHeaders,
378
385
 
379
386
 
380
387
 
381
- export async function handleApiRoute(request, url, ctx) {
388
+ export async function handleApiRoute(request, url, ctx, trustedRevalidateOrigin) {
382
389
  __registerConfiguredCacheAdapters();
383
390
  const match = matchRoute(url, apiRoutes);
384
391
  return __handlePagesApiRoute({
@@ -386,6 +393,7 @@ export async function handleApiRoute(request, url, ctx) {
386
393
  match,
387
394
  nextConfig: vinextConfig,
388
395
  request,
396
+ trustedRevalidateOrigin,
389
397
  url,
390
398
  reportRequestError(error, routePattern) {
391
399
  console.error("[vinext] API error:", error);