vinext 0.0.47 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/README.md +1 -1
  2. package/dist/build/layout-classification.js +3 -1
  3. package/dist/build/layout-classification.js.map +1 -1
  4. package/dist/build/prerender.js +10 -10
  5. package/dist/build/prerender.js.map +1 -1
  6. package/dist/build/report.d.ts +8 -4
  7. package/dist/build/report.js +17 -7
  8. package/dist/build/report.js.map +1 -1
  9. package/dist/build/run-prerender.d.ts +5 -0
  10. package/dist/build/run-prerender.js +4 -1
  11. package/dist/build/run-prerender.js.map +1 -1
  12. package/dist/build/server-manifest.js +2 -7
  13. package/dist/build/server-manifest.js.map +1 -1
  14. package/dist/build/standalone.js +3 -5
  15. package/dist/build/standalone.js.map +1 -1
  16. package/dist/check.js +45 -29
  17. package/dist/check.js.map +1 -1
  18. package/dist/cli-args.d.ts +3 -1
  19. package/dist/cli-args.js +18 -1
  20. package/dist/cli-args.js.map +1 -1
  21. package/dist/cli.js +9 -1
  22. package/dist/cli.js.map +1 -1
  23. package/dist/config/config-matchers.js +46 -37
  24. package/dist/config/config-matchers.js.map +1 -1
  25. package/dist/deploy.d.ts +18 -2
  26. package/dist/deploy.js +47 -4
  27. package/dist/deploy.js.map +1 -1
  28. package/dist/entries/app-rsc-entry.js +11 -9
  29. package/dist/entries/app-rsc-entry.js.map +1 -1
  30. package/dist/entries/app-rsc-manifest.js +4 -1
  31. package/dist/entries/app-rsc-manifest.js.map +1 -1
  32. package/dist/entries/pages-client-entry.js +3 -2
  33. package/dist/entries/pages-client-entry.js.map +1 -1
  34. package/dist/entries/pages-server-entry.js +21 -62
  35. package/dist/entries/pages-server-entry.js.map +1 -1
  36. package/dist/entries/runtime-entry-module.d.ts +12 -3
  37. package/dist/entries/runtime-entry-module.js +15 -4
  38. package/dist/entries/runtime-entry-module.js.map +1 -1
  39. package/dist/index.js +12 -7
  40. package/dist/index.js.map +1 -1
  41. package/dist/init.d.ts +1 -1
  42. package/dist/init.js +2 -2
  43. package/dist/init.js.map +1 -1
  44. package/dist/plugins/og-assets.js +15 -16
  45. package/dist/plugins/og-assets.js.map +1 -1
  46. package/dist/plugins/rsc-client-shim-excludes.d.ts +2 -1
  47. package/dist/plugins/rsc-client-shim-excludes.js +10 -1
  48. package/dist/plugins/rsc-client-shim-excludes.js.map +1 -1
  49. package/dist/routing/app-route-graph.d.ts +90 -4
  50. package/dist/routing/app-route-graph.js +210 -7
  51. package/dist/routing/app-route-graph.js.map +1 -1
  52. package/dist/routing/app-router.d.ts +15 -3
  53. package/dist/routing/app-router.js +20 -23
  54. package/dist/routing/app-router.js.map +1 -1
  55. package/dist/routing/file-matcher.d.ts +3 -1
  56. package/dist/routing/file-matcher.js +6 -1
  57. package/dist/routing/file-matcher.js.map +1 -1
  58. package/dist/routing/pages-router.js +10 -19
  59. package/dist/routing/pages-router.js.map +1 -1
  60. package/dist/routing/route-matching.d.ts +28 -0
  61. package/dist/routing/route-matching.js +44 -0
  62. package/dist/routing/route-matching.js.map +1 -0
  63. package/dist/routing/route-pattern.js +4 -1
  64. package/dist/routing/route-pattern.js.map +1 -1
  65. package/dist/routing/route-trie.d.ts +8 -0
  66. package/dist/routing/route-trie.js +12 -1
  67. package/dist/routing/route-trie.js.map +1 -1
  68. package/dist/routing/route-validation.js +3 -4
  69. package/dist/routing/route-validation.js.map +1 -1
  70. package/dist/routing/utils.d.ts +8 -1
  71. package/dist/routing/utils.js +25 -2
  72. package/dist/routing/utils.js.map +1 -1
  73. package/dist/server/api-handler.js +2 -8
  74. package/dist/server/api-handler.js.map +1 -1
  75. package/dist/server/app-browser-entry.js +66 -49
  76. package/dist/server/app-browser-entry.js.map +1 -1
  77. package/dist/server/app-browser-navigation-controller.d.ts +7 -5
  78. package/dist/server/app-browser-navigation-controller.js +43 -35
  79. package/dist/server/app-browser-navigation-controller.js.map +1 -1
  80. package/dist/server/app-browser-state.d.ts +33 -15
  81. package/dist/server/app-browser-state.js +52 -59
  82. package/dist/server/app-browser-state.js.map +1 -1
  83. package/dist/server/app-browser-visible-commit.d.ts +68 -0
  84. package/dist/server/app-browser-visible-commit.js +182 -0
  85. package/dist/server/app-browser-visible-commit.js.map +1 -0
  86. package/dist/server/app-client-reference-preloader.d.ts +15 -0
  87. package/dist/server/app-client-reference-preloader.js +46 -0
  88. package/dist/server/app-client-reference-preloader.js.map +1 -0
  89. package/dist/server/app-elements-wire.d.ts +130 -0
  90. package/dist/server/app-elements-wire.js +205 -0
  91. package/dist/server/app-elements-wire.js.map +1 -0
  92. package/dist/server/app-elements.d.ts +2 -84
  93. package/dist/server/app-elements.js +3 -102
  94. package/dist/server/app-elements.js.map +1 -1
  95. package/dist/server/app-fallback-renderer.d.ts +1 -1
  96. package/dist/server/app-middleware.d.ts +2 -1
  97. package/dist/server/app-middleware.js +34 -11
  98. package/dist/server/app-middleware.js.map +1 -1
  99. package/dist/server/app-page-boundary-render.d.ts +1 -1
  100. package/dist/server/app-page-boundary-render.js +8 -5
  101. package/dist/server/app-page-boundary-render.js.map +1 -1
  102. package/dist/server/app-page-boundary.js +2 -1
  103. package/dist/server/app-page-boundary.js.map +1 -1
  104. package/dist/server/app-page-cache.d.ts +1 -0
  105. package/dist/server/app-page-cache.js +8 -13
  106. package/dist/server/app-page-cache.js.map +1 -1
  107. package/dist/server/app-page-dispatch.d.ts +2 -1
  108. package/dist/server/app-page-dispatch.js +18 -10
  109. package/dist/server/app-page-dispatch.js.map +1 -1
  110. package/dist/server/app-page-element-builder.d.ts +1 -1
  111. package/dist/server/app-page-element-builder.js +8 -5
  112. package/dist/server/app-page-element-builder.js.map +1 -1
  113. package/dist/server/app-page-execution.d.ts +23 -5
  114. package/dist/server/app-page-execution.js +39 -24
  115. package/dist/server/app-page-execution.js.map +1 -1
  116. package/dist/server/app-page-head.js +2 -1
  117. package/dist/server/app-page-head.js.map +1 -1
  118. package/dist/server/app-page-method.js +2 -5
  119. package/dist/server/app-page-method.js.map +1 -1
  120. package/dist/server/app-page-probe.d.ts +1 -1
  121. package/dist/server/app-page-probe.js +5 -1
  122. package/dist/server/app-page-probe.js.map +1 -1
  123. package/dist/server/app-page-render.d.ts +1 -1
  124. package/dist/server/app-page-render.js +38 -3
  125. package/dist/server/app-page-render.js.map +1 -1
  126. package/dist/server/app-page-request.d.ts +0 -1
  127. package/dist/server/app-page-request.js +7 -10
  128. package/dist/server/app-page-request.js.map +1 -1
  129. package/dist/server/app-page-response.js +3 -2
  130. package/dist/server/app-page-response.js.map +1 -1
  131. package/dist/server/app-page-route-wiring.d.ts +5 -2
  132. package/dist/server/app-page-route-wiring.js +15 -12
  133. package/dist/server/app-page-route-wiring.js.map +1 -1
  134. package/dist/server/app-page-stream.d.ts +7 -0
  135. package/dist/server/app-page-stream.js +9 -2
  136. package/dist/server/app-page-stream.js.map +1 -1
  137. package/dist/server/app-prerender-endpoints.js +3 -2
  138. package/dist/server/app-prerender-endpoints.js.map +1 -1
  139. package/dist/server/app-route-handler-cache.js +2 -1
  140. package/dist/server/app-route-handler-cache.js.map +1 -1
  141. package/dist/server/app-route-handler-dispatch.js +6 -5
  142. package/dist/server/app-route-handler-dispatch.js.map +1 -1
  143. package/dist/server/app-route-handler-policy.js +13 -13
  144. package/dist/server/app-route-handler-policy.js.map +1 -1
  145. package/dist/server/app-route-handler-response.js +2 -1
  146. package/dist/server/app-route-handler-response.js.map +1 -1
  147. package/dist/server/app-route-handler-runtime.d.ts +9 -1
  148. package/dist/server/app-route-handler-runtime.js +11 -1
  149. package/dist/server/app-route-handler-runtime.js.map +1 -1
  150. package/dist/server/app-router-entry.js +9 -4
  151. package/dist/server/app-router-entry.js.map +1 -1
  152. package/dist/server/app-rsc-cache-busting.d.ts +34 -0
  153. package/dist/server/app-rsc-cache-busting.js +137 -0
  154. package/dist/server/app-rsc-cache-busting.js.map +1 -0
  155. package/dist/server/app-rsc-handler.js +22 -11
  156. package/dist/server/app-rsc-handler.js.map +1 -1
  157. package/dist/server/app-rsc-request-normalization.d.ts +4 -2
  158. package/dist/server/app-rsc-request-normalization.js +10 -6
  159. package/dist/server/app-rsc-request-normalization.js.map +1 -1
  160. package/dist/server/app-rsc-response-finalizer.js +1 -1
  161. package/dist/server/app-rsc-route-matching.js +8 -4
  162. package/dist/server/app-rsc-route-matching.js.map +1 -1
  163. package/dist/server/app-segment-config.js +4 -0
  164. package/dist/server/app-segment-config.js.map +1 -1
  165. package/dist/server/app-server-action-execution.js +43 -51
  166. package/dist/server/app-server-action-execution.js.map +1 -1
  167. package/dist/server/app-ssr-entry.js +21 -20
  168. package/dist/server/app-ssr-entry.js.map +1 -1
  169. package/dist/server/artifact-compatibility.d.ts +44 -0
  170. package/dist/server/artifact-compatibility.js +82 -0
  171. package/dist/server/artifact-compatibility.js.map +1 -0
  172. package/dist/server/cache-proof.d.ts +200 -0
  173. package/dist/server/cache-proof.js +342 -0
  174. package/dist/server/cache-proof.js.map +1 -0
  175. package/dist/server/dev-origin-check.js +8 -4
  176. package/dist/server/dev-origin-check.js.map +1 -1
  177. package/dist/server/dev-server.js +6 -16
  178. package/dist/server/dev-server.js.map +1 -1
  179. package/dist/server/http-error-responses.d.ts +67 -0
  180. package/dist/server/http-error-responses.js +77 -0
  181. package/dist/server/http-error-responses.js.map +1 -0
  182. package/dist/server/image-optimization.js +2 -1
  183. package/dist/server/image-optimization.js.map +1 -1
  184. package/dist/server/metadata-route-response.js +6 -5
  185. package/dist/server/metadata-route-response.js.map +1 -1
  186. package/dist/server/metadata-routes.d.ts +1 -0
  187. package/dist/server/metadata-routes.js +6 -0
  188. package/dist/server/metadata-routes.js.map +1 -1
  189. package/dist/server/middleware-matcher.js +2 -2
  190. package/dist/server/middleware-matcher.js.map +1 -1
  191. package/dist/server/middleware-response-headers.js +21 -0
  192. package/dist/server/middleware-response-headers.js.map +1 -1
  193. package/dist/server/middleware-runtime.js +3 -3
  194. package/dist/server/middleware-runtime.js.map +1 -1
  195. package/dist/server/navigation-trace.d.ts +33 -0
  196. package/dist/server/navigation-trace.js +35 -0
  197. package/dist/server/navigation-trace.js.map +1 -0
  198. package/dist/server/next-error-digest.d.ts +44 -0
  199. package/dist/server/next-error-digest.js +40 -0
  200. package/dist/server/next-error-digest.js.map +1 -0
  201. package/dist/server/pages-api-route.js +4 -7
  202. package/dist/server/pages-api-route.js.map +1 -1
  203. package/dist/server/pages-node-compat.js +4 -16
  204. package/dist/server/pages-node-compat.js.map +1 -1
  205. package/dist/server/pages-page-response.d.ts +2 -8
  206. package/dist/server/pages-page-response.js +44 -14
  207. package/dist/server/pages-page-response.js.map +1 -1
  208. package/dist/server/prod-server.d.ts +6 -0
  209. package/dist/server/prod-server.js +28 -21
  210. package/dist/server/prod-server.js.map +1 -1
  211. package/dist/server/request-pipeline.d.ts +42 -1
  212. package/dist/server/request-pipeline.js +97 -17
  213. package/dist/server/request-pipeline.js.map +1 -1
  214. package/dist/shims/cache-runtime.d.ts +2 -2
  215. package/dist/shims/cache-runtime.js +3 -6
  216. package/dist/shims/cache-runtime.js.map +1 -1
  217. package/dist/shims/cache.js +3 -5
  218. package/dist/shims/cache.js.map +1 -1
  219. package/dist/shims/fetch-cache.js +2 -3
  220. package/dist/shims/fetch-cache.js.map +1 -1
  221. package/dist/shims/head-state.js +2 -3
  222. package/dist/shims/head-state.js.map +1 -1
  223. package/dist/shims/headers.js +4 -44
  224. package/dist/shims/headers.js.map +1 -1
  225. package/dist/shims/i18n-state.js +2 -3
  226. package/dist/shims/i18n-state.js.map +1 -1
  227. package/dist/shims/internal/als-registry.d.ts +15 -0
  228. package/dist/shims/internal/als-registry.js +55 -0
  229. package/dist/shims/internal/als-registry.js.map +1 -0
  230. package/dist/shims/internal/cookie-serialize.d.ts +46 -0
  231. package/dist/shims/internal/cookie-serialize.js +51 -0
  232. package/dist/shims/internal/cookie-serialize.js.map +1 -0
  233. package/dist/shims/link.js +31 -26
  234. package/dist/shims/link.js.map +1 -1
  235. package/dist/shims/metadata.d.ts +26 -1
  236. package/dist/shims/metadata.js +94 -4
  237. package/dist/shims/metadata.js.map +1 -1
  238. package/dist/shims/navigation-state.js +2 -3
  239. package/dist/shims/navigation-state.js.map +1 -1
  240. package/dist/shims/navigation.d.ts +2 -7
  241. package/dist/shims/navigation.js +44 -36
  242. package/dist/shims/navigation.js.map +1 -1
  243. package/dist/shims/request-context.js +2 -4
  244. package/dist/shims/request-context.js.map +1 -1
  245. package/dist/shims/router-state.js +2 -3
  246. package/dist/shims/router-state.js.map +1 -1
  247. package/dist/shims/router.js +2 -2
  248. package/dist/shims/router.js.map +1 -1
  249. package/dist/shims/server.js +5 -30
  250. package/dist/shims/server.js.map +1 -1
  251. package/dist/shims/slot.d.ts +1 -1
  252. package/dist/shims/slot.js +5 -4
  253. package/dist/shims/slot.js.map +1 -1
  254. package/dist/shims/thenable-params.d.ts +5 -2
  255. package/dist/shims/thenable-params.js +26 -6
  256. package/dist/shims/thenable-params.js.map +1 -1
  257. package/dist/shims/unified-request-context.js +2 -14
  258. package/dist/shims/unified-request-context.js.map +1 -1
  259. package/dist/utils/base-path.d.ts +7 -1
  260. package/dist/utils/base-path.js +12 -1
  261. package/dist/utils/base-path.js.map +1 -1
  262. package/dist/utils/query.d.ts +8 -1
  263. package/dist/utils/query.js +12 -1
  264. package/dist/utils/query.js.map +1 -1
  265. package/dist/utils/safe-json-file.d.ts +18 -0
  266. package/dist/utils/safe-json-file.js +25 -0
  267. package/dist/utils/safe-json-file.js.map +1 -0
  268. package/dist/utils/text-stream.d.ts +29 -0
  269. package/dist/utils/text-stream.js +66 -0
  270. package/dist/utils/text-stream.js.map +1 -0
  271. package/package.json +5 -5
@@ -1,4 +1,5 @@
1
- import { APP_INTERCEPTION_CONTEXT_KEY, APP_ROOT_LAYOUT_KEY, APP_ROUTE_KEY, APP_UNMATCHED_SLOT_WIRE_VALUE, createAppPayloadPageId, createAppPayloadRouteId } from "./app-elements.js";
1
+ import { AppElementsWire } from "./app-elements-wire.js";
2
+ import "./app-elements.js";
2
3
  import { ErrorBoundary, ForbiddenBoundary, NotFoundBoundary, UnauthorizedBoundary } from "../shims/error-boundary.js";
3
4
  import { LayoutSegmentProvider } from "../shims/layout-segment-context.js";
4
5
  import { MetadataHead, ViewportHead } from "../shims/metadata.js";
@@ -26,7 +27,7 @@ function createAppPageLayoutEntries(route) {
26
27
  return {
27
28
  errorModule: route.errors?.[index] ?? null,
28
29
  forbiddenModule: route.forbiddens?.[index] ?? null,
29
- id: `layout:${treePath}`,
30
+ id: AppElementsWire.encodeLayoutId(treePath),
30
31
  layoutModule,
31
32
  notFoundModule: route.notFounds?.[index] ?? null,
32
33
  unauthorizedModule: route.unauthorizeds?.[index] ?? null,
@@ -40,7 +41,7 @@ function createAppPageTemplateEntries(route) {
40
41
  const treePosition = route.templateTreePositions?.[index] ?? 0;
41
42
  const treePath = createAppPageTreePath(route.routeSegments, treePosition);
42
43
  return {
43
- id: `template:${treePath}`,
44
+ id: AppElementsWire.encodeTemplateId(treePath),
44
45
  templateModule,
45
46
  treePath,
46
47
  treePosition
@@ -92,7 +93,7 @@ function createAppPageParallelSlotEntries(layoutIndex, layoutEntries, route, get
92
93
  const slotParams = getEffectiveSlotParams(slotKey, slotName);
93
94
  parallelSlots[slotName] = /* @__PURE__ */ jsx(LayoutSegmentProvider, {
94
95
  segmentMap: { children: slot.routeSegments ? resolveAppPageChildSegments(slot.routeSegments, 0, slotParams) : [] },
95
- children: /* @__PURE__ */ jsx(Slot, { id: `slot:${slotName}:${treePath}` })
96
+ children: /* @__PURE__ */ jsx(Slot, { id: AppElementsWire.encodeSlotId(slotName, treePath) })
96
97
  });
97
98
  }
98
99
  return Object.keys(parallelSlots).length > 0 ? parallelSlots : void 0;
@@ -105,10 +106,9 @@ function createAppPageRouteHead(metadata, viewport) {
105
106
  ] });
106
107
  }
107
108
  function buildAppPageElements(options) {
108
- const elements = {};
109
109
  const interceptionContext = options.interceptionContext ?? null;
110
- const routeId = createAppPayloadRouteId(options.routePath, interceptionContext);
111
- const pageId = createAppPayloadPageId(options.routePath, interceptionContext);
110
+ const routeId = AppElementsWire.encodeRouteId(options.routePath, interceptionContext);
111
+ const pageId = AppElementsWire.encodePageId(options.routePath, interceptionContext);
112
112
  const layoutEntries = createAppPageLayoutEntries(options.route);
113
113
  const templateEntries = createAppPageTemplateEntries(options.route);
114
114
  const layoutEntriesByTreePosition = /* @__PURE__ */ new Map();
@@ -124,6 +124,11 @@ function buildAppPageElements(options) {
124
124
  const templateDependenciesBeforeById = /* @__PURE__ */ new Map();
125
125
  const pageDependencies = [];
126
126
  const rootLayoutTreePath = layoutEntries[0]?.treePath ?? null;
127
+ const elements = { ...AppElementsWire.createMetadataEntries({
128
+ interceptionContext,
129
+ rootLayoutTreePath,
130
+ routeId
131
+ }) };
127
132
  const slotNameCounts = /* @__PURE__ */ new Map();
128
133
  for (const slot of Object.values(options.route.slots ?? {})) {
129
134
  const slotName = slot.name;
@@ -155,9 +160,6 @@ function buildAppPageElements(options) {
155
160
  templateDependenciesBeforeById.set(templateEntry.id, [...pageDependencies]);
156
161
  pageDependencies.push(templateDependency);
157
162
  }
158
- elements[APP_ROUTE_KEY] = routeId;
159
- elements[APP_INTERCEPTION_CONTEXT_KEY] = interceptionContext;
160
- elements[APP_ROOT_LAYOUT_KEY] = rootLayoutTreePath;
161
163
  elements[pageId] = renderAfterAppDependencies(options.element, pageDependencies);
162
164
  for (const templateEntry of templateEntries) {
163
165
  const templateComponent = getDefaultExport(templateEntry.templateModule);
@@ -197,7 +199,8 @@ function buildAppPageElements(options) {
197
199
  for (const [slotKey, slot] of Object.entries(options.route.slots ?? {})) {
198
200
  const slotName = slot.name;
199
201
  const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;
200
- const slotId = `slot:${slotName}:${layoutEntries[targetIndex]?.treePath ?? "/"}`;
202
+ const treePath = layoutEntries[targetIndex]?.treePath ?? "/";
203
+ const slotId = AppElementsWire.encodeSlotId(slotName, treePath);
201
204
  const slotOverride = resolveSlotOverride(slotKey, slotName);
202
205
  const slotParams = getEffectiveSlotParams(slotKey, slotName);
203
206
  const overrideOrPageComponent = getDefaultExport(slotOverride?.pageModule) ?? getDefaultExport(slot.page);
@@ -205,7 +208,7 @@ function buildAppPageElements(options) {
205
208
  if (!overrideOrPageComponent && defaultComponent && options.isRscRequest && options.mountedSlotIds?.has(slotId)) continue;
206
209
  const slotComponent = overrideOrPageComponent ?? defaultComponent;
207
210
  if (!slotComponent) {
208
- elements[slotId] = APP_UNMATCHED_SLOT_WIRE_VALUE;
211
+ elements[slotId] = AppElementsWire.unmatchedSlotValue;
209
212
  continue;
210
213
  }
211
214
  const slotThenableParams = options.makeThenableParams(slotParams);
@@ -1 +1 @@
1
- {"version":3,"file":"app-page-route-wiring.js","names":["Children"],"sources":["../../src/server/app-page-route-wiring.tsx"],"sourcesContent":["import { Suspense, type ComponentType, type ReactNode } from \"react\";\nimport {\n APP_INTERCEPTION_CONTEXT_KEY,\n APP_ROOT_LAYOUT_KEY,\n APP_ROUTE_KEY,\n APP_UNMATCHED_SLOT_WIRE_VALUE,\n createAppPayloadPageId,\n createAppPayloadRouteId,\n type AppElements,\n} from \"./app-elements.js\";\nimport {\n ErrorBoundary,\n ForbiddenBoundary,\n NotFoundBoundary,\n UnauthorizedBoundary,\n} from \"vinext/shims/error-boundary\";\nimport { LayoutSegmentProvider } from \"vinext/shims/layout-segment-context\";\nimport { MetadataHead, ViewportHead, type Metadata, type Viewport } from \"vinext/shims/metadata\";\nimport { Children, ParallelSlot, Slot } from \"vinext/shims/slot\";\nimport type { AppPageParams } from \"./app-page-boundary.js\";\nimport {\n createAppRenderDependency,\n renderAfterAppDependencies,\n renderWithAppDependencyBarrier,\n type AppRenderDependency,\n} from \"./app-render-dependency.js\";\nimport { resolveAppPageSegmentParams } from \"./app-page-params.js\";\n\ntype AppPageComponentProps = {\n children?: ReactNode;\n error?: unknown;\n params?: unknown;\n reset?: () => void;\n} & Record<string, unknown>;\n\ntype AppPageComponent = ComponentType<AppPageComponentProps>;\ntype AppPageErrorComponent = ComponentType<{ error: unknown; reset: () => void }>;\n\nexport type AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\n\nexport type AppPageErrorModule = Record<string, unknown> & {\n default?: AppPageErrorComponent | null | undefined;\n};\n\ntype AppPageRouteWiringSlot<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n /** Slot prop name passed to the owning layout (e.g. \"modal\" from @modal). */\n name: string;\n default?: TModule | null;\n error?: TErrorModule | null;\n layout?: TModule | null;\n layoutIndex: number;\n loading?: TModule | null;\n page?: TModule | null;\n routeSegments?: readonly string[] | null;\n /**\n * Full URL pattern parts for the slot's mirrored sub-page. Set when the\n * slot's params may differ from the route's (e.g. inherited slot whose\n * dynamic markers have different names than the route's). The runtime\n * matches the request URL against these parts to extract slot params.\n */\n slotPatternParts?: readonly string[] | null;\n /** Param names captured by `slotPatternParts`, in order. */\n slotParamNames?: readonly string[] | null;\n};\n\nexport type AppPageRouteWiringRoute<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n error?: TErrorModule | null;\n errors?: readonly (TErrorModule | null | undefined)[] | null;\n layoutTreePositions?: readonly number[] | null;\n layouts: readonly (TModule | null | undefined)[];\n loading?: TModule | null;\n notFound?: TModule | null;\n notFounds?: readonly (TModule | null | undefined)[] | null;\n forbidden?: TModule | null;\n forbiddens?: readonly (TModule | null | undefined)[] | null;\n unauthorized?: TModule | null;\n unauthorizeds?: readonly (TModule | null | undefined)[] | null;\n routeSegments?: readonly string[];\n /**\n * Keyed by stable slot id (name + owner path), not necessarily the slot prop name.\n */\n slots?: Readonly<Record<string, AppPageRouteWiringSlot<TModule, TErrorModule>>> | null;\n templateTreePositions?: readonly number[] | null;\n templates?: readonly (TModule | null | undefined)[] | null;\n};\n\nexport type AppPageSlotOverride<TModule extends AppPageModule = AppPageModule> = {\n layoutModules?: readonly (TModule | null | undefined)[] | null;\n /**\n * The page module to render for this slot. Optional — when omitted, the\n * slot's existing `page` is used (e.g. when the override only changes the\n * slot's `params` for an inherited mirror with distinct param names).\n */\n pageModule?: TModule | null;\n params?: AppPageParams;\n props?: Readonly<Record<string, unknown>>;\n};\n\ntype AppPageLayoutEntry<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n errorModule?: TErrorModule | null | undefined;\n forbiddenModule?: TModule | null | undefined;\n id: string;\n layoutModule?: TModule | null | undefined;\n notFoundModule?: TModule | null | undefined;\n unauthorizedModule?: TModule | null | undefined;\n treePath: string;\n treePosition: number;\n};\n\ntype BuildAppPageRouteElementOptions<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n element: ReactNode;\n globalErrorModule?: TErrorModule | null;\n makeThenableParams: (params: AppPageParams) => unknown;\n matchedParams: AppPageParams;\n resolvedMetadata: Metadata | null;\n resolvedViewport: Viewport;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n route: AppPageRouteWiringRoute<TModule, TErrorModule>;\n slotOverrides?: Readonly<Record<string, AppPageSlotOverride<TModule>>> | null;\n};\n\ntype BuildAppPageElementsOptions<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = BuildAppPageRouteElementOptions<TModule, TErrorModule> & {\n interceptionContext?: string | null;\n isRscRequest?: boolean;\n mountedSlotIds?: ReadonlySet<string> | null;\n routePath: string;\n};\n\ntype AppPageTemplateEntry<TModule extends AppPageModule = AppPageModule> = {\n id: string;\n templateModule?: TModule | null | undefined;\n treePath: string;\n treePosition: number;\n};\n\nfunction getDefaultExport<TModule extends AppPageModule>(\n module: TModule | null | undefined,\n): AppPageComponent | null {\n return module?.default ?? null;\n}\n\nfunction getErrorBoundaryExport<TModule extends AppPageErrorModule>(\n module: TModule | null | undefined,\n): AppPageErrorComponent | null {\n return module?.default ?? null;\n}\n\nexport function createAppPageTreePath(\n routeSegments: readonly string[] | null | undefined,\n treePosition: number,\n): string {\n const treePathSegments = routeSegments?.slice(0, treePosition) ?? [];\n if (treePathSegments.length === 0) {\n return \"/\";\n }\n return `/${treePathSegments.join(\"/\")}`;\n}\n\nexport function createAppPageLayoutEntries<\n TModule extends AppPageModule,\n TErrorModule extends AppPageErrorModule,\n>(\n route: Pick<\n AppPageRouteWiringRoute<TModule, TErrorModule>,\n \"errors\" | \"layoutTreePositions\" | \"layouts\" | \"notFounds\" | \"routeSegments\"\n > & {\n forbiddens?: readonly (TModule | null | undefined)[] | null;\n unauthorizeds?: readonly (TModule | null | undefined)[] | null;\n },\n): AppPageLayoutEntry<TModule, TErrorModule>[] {\n return route.layouts.map((layoutModule, index) => {\n const treePosition = route.layoutTreePositions?.[index] ?? 0;\n const treePath = createAppPageTreePath(route.routeSegments, treePosition);\n return {\n errorModule: route.errors?.[index] ?? null,\n forbiddenModule: route.forbiddens?.[index] ?? null,\n id: `layout:${treePath}`,\n layoutModule,\n notFoundModule: route.notFounds?.[index] ?? null,\n unauthorizedModule: route.unauthorizeds?.[index] ?? null,\n treePath,\n treePosition,\n };\n });\n}\n\nfunction createAppPageTemplateEntries<TModule extends AppPageModule>(\n route: Pick<\n AppPageRouteWiringRoute<TModule>,\n \"routeSegments\" | \"templateTreePositions\" | \"templates\"\n >,\n): AppPageTemplateEntry<TModule>[] {\n return (route.templates ?? []).map((templateModule, index) => {\n const treePosition = route.templateTreePositions?.[index] ?? 0;\n const treePath = createAppPageTreePath(route.routeSegments, treePosition);\n return {\n id: `template:${treePath}`,\n templateModule,\n treePath,\n treePosition,\n };\n });\n}\n\nexport function resolveAppPageChildSegments(\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n): string[] {\n const rawSegments = routeSegments.slice(treePosition);\n const resolvedSegments: string[] = [];\n\n for (const segment of rawSegments) {\n if (\n segment.startsWith(\"[[...\") &&\n segment.endsWith(\"]]\") &&\n segment.length > \"[[...x]]\".length - 1\n ) {\n const paramName = segment.slice(5, -2);\n const paramValue = params[paramName];\n if (Array.isArray(paramValue) && paramValue.length === 0) {\n continue;\n }\n if (paramValue === undefined) {\n continue;\n }\n resolvedSegments.push(Array.isArray(paramValue) ? paramValue.join(\"/\") : paramValue);\n continue;\n }\n\n if (segment.startsWith(\"[...\") && segment.endsWith(\"]\")) {\n const paramName = segment.slice(4, -1);\n const paramValue = params[paramName];\n if (Array.isArray(paramValue)) {\n resolvedSegments.push(paramValue.join(\"/\"));\n continue;\n }\n resolvedSegments.push(paramValue ?? segment);\n continue;\n }\n\n if (segment.startsWith(\"[\") && segment.endsWith(\"]\") && !segment.includes(\".\")) {\n const paramName = segment.slice(1, -1);\n const paramValue = params[paramName];\n resolvedSegments.push(\n Array.isArray(paramValue) ? paramValue.join(\"/\") : (paramValue ?? segment),\n );\n continue;\n }\n\n resolvedSegments.push(segment);\n }\n\n return resolvedSegments;\n}\n\nfunction resolveAppPageVisibleSegments(\n routeSegments: readonly string[],\n params: AppPageParams,\n): string[] {\n const resolvedSegments = resolveAppPageChildSegments(routeSegments, 0, params);\n return resolvedSegments.filter((segment) => !(segment.startsWith(\"(\") && segment.endsWith(\")\")));\n}\n\nfunction resolveAppPageTemplateKey(\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n): string {\n const visibleSegments = resolveAppPageVisibleSegments(routeSegments.slice(treePosition), params);\n return visibleSegments[0] ?? \"\";\n}\n\nfunction createAppPageParallelSlotEntries<\n TModule extends AppPageModule,\n TErrorModule extends AppPageErrorModule,\n>(\n layoutIndex: number,\n layoutEntries: readonly AppPageLayoutEntry<TModule, TErrorModule>[],\n route: AppPageRouteWiringRoute<TModule, TErrorModule>,\n getEffectiveSlotParams: (slotKey: string, slotName: string) => AppPageParams,\n): Readonly<Record<string, ReactNode>> | undefined {\n const parallelSlots: Record<string, ReactNode> = {};\n\n for (const [slotKey, slot] of Object.entries(route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n if (targetIndex !== layoutIndex) {\n continue;\n }\n\n const layoutEntry = layoutEntries[targetIndex];\n const treePath = layoutEntry?.treePath ?? \"/\";\n const slotParams = getEffectiveSlotParams(slotKey, slotName);\n const slotSegments = slot.routeSegments\n ? resolveAppPageChildSegments(slot.routeSegments, 0, slotParams)\n : [];\n parallelSlots[slotName] = (\n <LayoutSegmentProvider segmentMap={{ children: slotSegments }}>\n <Slot id={`slot:${slotName}:${treePath}`} />\n </LayoutSegmentProvider>\n );\n }\n\n return Object.keys(parallelSlots).length > 0 ? parallelSlots : undefined;\n}\n\nfunction createAppPageRouteHead(metadata: Metadata | null, viewport: Viewport): ReactNode {\n return (\n <>\n <meta charSet=\"utf-8\" />\n {metadata ? <MetadataHead metadata={metadata} /> : null}\n <ViewportHead viewport={viewport} />\n </>\n );\n}\n\nexport function buildAppPageElements<\n TModule extends AppPageModule,\n TErrorModule extends AppPageErrorModule,\n>(options: BuildAppPageElementsOptions<TModule, TErrorModule>): AppElements {\n const elements: Record<string, ReactNode | string | null> = {};\n const interceptionContext = options.interceptionContext ?? null;\n const routeId = createAppPayloadRouteId(options.routePath, interceptionContext);\n const pageId = createAppPayloadPageId(options.routePath, interceptionContext);\n const layoutEntries = createAppPageLayoutEntries(options.route);\n const templateEntries = createAppPageTemplateEntries(options.route);\n const layoutEntriesByTreePosition = new Map<number, AppPageLayoutEntry<TModule, TErrorModule>>();\n const templateEntriesByTreePosition = new Map<number, AppPageTemplateEntry<TModule>>();\n for (const layoutEntry of layoutEntries) {\n layoutEntriesByTreePosition.set(layoutEntry.treePosition, layoutEntry);\n }\n for (const templateEntry of templateEntries) {\n templateEntriesByTreePosition.set(templateEntry.treePosition, templateEntry);\n }\n const layoutIndicesByTreePosition = new Map<number, number>();\n for (let index = 0; index < layoutEntries.length; index++) {\n layoutIndicesByTreePosition.set(layoutEntries[index].treePosition, index);\n }\n const layoutDependenciesByIndex = new Map<number, AppRenderDependency>();\n const layoutDependenciesBefore: AppRenderDependency[][] = [];\n const slotDependenciesByLayoutIndex: AppRenderDependency[][] = [];\n const templateDependenciesById = new Map<string, AppRenderDependency>();\n const templateDependenciesBeforeById = new Map<string, AppRenderDependency[]>();\n const pageDependencies: AppRenderDependency[] = [];\n const rootLayoutTreePath = layoutEntries[0]?.treePath ?? null;\n const slotNameCounts = new Map<string, number>();\n for (const slot of Object.values(options.route.slots ?? {})) {\n const slotName = slot.name;\n slotNameCounts.set(slotName, (slotNameCounts.get(slotName) ?? 0) + 1);\n }\n const orderedTreePositions = Array.from(\n new Set<number>([\n ...layoutEntries.map((entry) => entry.treePosition),\n ...templateEntries.map((entry) => entry.treePosition),\n ]),\n ).sort((left, right) => left - right);\n const resolveSlotOverride = (slotKey: string, slotName: string) => {\n const overrideByKey = options.slotOverrides?.[slotKey];\n if (overrideByKey) {\n return overrideByKey;\n }\n\n // Legacy callers may still provide overrides by slot prop name.\n // Only allow that fallback when it is unambiguous.\n if (slotKey === slotName || (slotNameCounts.get(slotName) ?? 0) === 1) {\n return options.slotOverrides?.[slotName];\n }\n\n return undefined;\n };\n const getEffectiveSlotParams = (slotKey: string, slotName: string): AppPageParams =>\n resolveSlotOverride(slotKey, slotName)?.params ?? options.matchedParams;\n\n for (const treePosition of orderedTreePositions) {\n const layoutIndex = layoutIndicesByTreePosition.get(treePosition);\n if (layoutIndex !== undefined) {\n const layoutEntry = layoutEntries[layoutIndex];\n layoutDependenciesBefore[layoutIndex] = [...pageDependencies];\n if (getDefaultExport(layoutEntry.layoutModule)) {\n const layoutDependency = createAppRenderDependency();\n layoutDependenciesByIndex.set(layoutIndex, layoutDependency);\n pageDependencies.push(layoutDependency);\n }\n slotDependenciesByLayoutIndex[layoutIndex] = [...pageDependencies];\n }\n\n const templateEntry = templateEntriesByTreePosition.get(treePosition);\n if (!templateEntry || !getDefaultExport(templateEntry.templateModule)) {\n continue;\n }\n\n const templateDependency = createAppRenderDependency();\n templateDependenciesById.set(templateEntry.id, templateDependency);\n templateDependenciesBeforeById.set(templateEntry.id, [...pageDependencies]);\n pageDependencies.push(templateDependency);\n }\n\n elements[APP_ROUTE_KEY] = routeId;\n elements[APP_INTERCEPTION_CONTEXT_KEY] = interceptionContext;\n elements[APP_ROOT_LAYOUT_KEY] = rootLayoutTreePath;\n elements[pageId] = renderAfterAppDependencies(options.element, pageDependencies);\n\n for (const templateEntry of templateEntries) {\n const templateComponent = getDefaultExport(templateEntry.templateModule);\n if (!templateComponent) {\n continue;\n }\n const TemplateComponent = templateComponent;\n const templateDependency = templateDependenciesById.get(templateEntry.id);\n const templateElement = templateDependency ? (\n renderWithAppDependencyBarrier(\n <TemplateComponent params={options.matchedParams}>\n <Children />\n </TemplateComponent>,\n templateDependency,\n )\n ) : (\n <TemplateComponent params={options.matchedParams}>\n <Children />\n </TemplateComponent>\n );\n elements[templateEntry.id] = renderAfterAppDependencies(\n templateElement,\n templateDependenciesBeforeById.get(templateEntry.id) ?? [],\n );\n }\n\n for (let index = 0; index < layoutEntries.length; index++) {\n const layoutEntry = layoutEntries[index];\n const layoutComponent = getDefaultExport(layoutEntry.layoutModule);\n if (!layoutComponent) {\n continue;\n }\n\n const layoutProps: Record<string, unknown> = {\n params: options.makeThenableParams(\n resolveAppPageSegmentParams(\n options.route.routeSegments,\n layoutEntry.treePosition,\n options.matchedParams,\n ),\n ),\n };\n\n for (const slot of Object.values(options.route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n if (targetIndex !== index) {\n continue;\n }\n layoutProps[slotName] = <ParallelSlot name={slotName} />;\n }\n\n const LayoutComponent = layoutComponent;\n const layoutDependency = layoutDependenciesByIndex.get(index);\n const layoutElement = layoutDependency ? (\n renderWithAppDependencyBarrier(\n <LayoutComponent {...layoutProps}>\n <Children />\n </LayoutComponent>,\n layoutDependency,\n )\n ) : (\n <LayoutComponent {...layoutProps}>\n <Children />\n </LayoutComponent>\n );\n elements[layoutEntry.id] = renderAfterAppDependencies(\n layoutElement,\n layoutDependenciesBefore[index] ?? [],\n );\n }\n\n for (const [slotKey, slot] of Object.entries(options.route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n const treePath = layoutEntries[targetIndex]?.treePath ?? \"/\";\n const slotId = `slot:${slotName}:${treePath}`;\n const slotOverride = resolveSlotOverride(slotKey, slotName);\n const slotParams = getEffectiveSlotParams(slotKey, slotName);\n const overrideOrPageComponent =\n getDefaultExport(slotOverride?.pageModule) ?? getDefaultExport(slot.page);\n const defaultComponent = getDefaultExport(slot.default);\n\n // On soft nav (RSC): omit key when only default.tsx exists and the slot is\n // already mounted on the client. Absent key means the browser retains prior\n // slot content rather than replacing it. When the slot is not yet mounted\n // (first entry into this layout), include the key so default.tsx renders.\n if (\n !overrideOrPageComponent &&\n defaultComponent &&\n options.isRscRequest &&\n options.mountedSlotIds?.has(slotId)\n ) {\n continue;\n }\n\n const slotComponent = overrideOrPageComponent ?? defaultComponent;\n\n if (!slotComponent) {\n elements[slotId] = APP_UNMATCHED_SLOT_WIRE_VALUE;\n continue;\n }\n\n const slotThenableParams = options.makeThenableParams(slotParams);\n const slotProps: Record<string, unknown> = {\n params: slotThenableParams,\n };\n if (slotOverride?.props) {\n Object.assign(slotProps, slotOverride.props);\n }\n\n const SlotComponent = slotComponent;\n let slotElement: ReactNode = <SlotComponent {...slotProps} />;\n const interceptLayouts = slotOverride?.layoutModules ?? [];\n\n for (let layoutIndex = interceptLayouts.length - 1; layoutIndex >= 0; layoutIndex--) {\n const interceptLayoutComponent = getDefaultExport(interceptLayouts[layoutIndex]);\n if (!interceptLayoutComponent) {\n continue;\n }\n const InterceptLayoutComponent = interceptLayoutComponent;\n slotElement = (\n <InterceptLayoutComponent params={slotThenableParams}>\n {slotElement}\n </InterceptLayoutComponent>\n );\n }\n\n const slotLayoutComponent = getDefaultExport(slot.layout);\n if (slotLayoutComponent) {\n const SlotLayoutComponent = slotLayoutComponent;\n slotElement = (\n <SlotLayoutComponent params={slotThenableParams}>{slotElement}</SlotLayoutComponent>\n );\n }\n\n const slotLoadingComponent = getDefaultExport(slot.loading);\n if (slotLoadingComponent) {\n const SlotLoadingComponent = slotLoadingComponent;\n slotElement = <Suspense fallback={<SlotLoadingComponent />}>{slotElement}</Suspense>;\n }\n\n const slotErrorComponent = getErrorBoundaryExport(slot.error);\n if (slotErrorComponent) {\n slotElement = <ErrorBoundary fallback={slotErrorComponent}>{slotElement}</ErrorBoundary>;\n }\n\n elements[slotId] = renderAfterAppDependencies(\n slotElement,\n targetIndex >= 0 ? (slotDependenciesByLayoutIndex[targetIndex] ?? []) : [],\n );\n }\n\n let routeChildren: ReactNode = (\n <LayoutSegmentProvider segmentMap={{ children: [] }}>\n <Slot id={pageId} />\n </LayoutSegmentProvider>\n );\n\n const routeLoadingComponent = getDefaultExport(options.route.loading);\n if (routeLoadingComponent) {\n const RouteLoadingComponent = routeLoadingComponent;\n routeChildren = <Suspense fallback={<RouteLoadingComponent />}>{routeChildren}</Suspense>;\n }\n\n const lastLayoutErrorModule =\n options.route.errors && options.route.errors.length > 0\n ? options.route.errors[options.route.errors.length - 1]\n : null;\n // Next.js nesting (outer to inner): Error > Unauthorized > Forbidden > NotFound > children.\n // Building bottom-up means NotFoundBoundary must wrap first, then Forbidden, Unauthorized, Error.\n const notFoundComponent =\n getDefaultExport(options.route.notFound) ?? getDefaultExport(options.rootNotFoundModule);\n if (notFoundComponent) {\n const NotFoundComponent = notFoundComponent;\n routeChildren = (\n <NotFoundBoundary fallback={<NotFoundComponent />}>{routeChildren}</NotFoundBoundary>\n );\n }\n\n const forbiddenComponent =\n getDefaultExport(options.route.forbidden) ?? getDefaultExport(options.rootForbiddenModule);\n if (forbiddenComponent) {\n const ForbiddenComponent = forbiddenComponent;\n routeChildren = (\n <ForbiddenBoundary fallback={<ForbiddenComponent />}>{routeChildren}</ForbiddenBoundary>\n );\n }\n\n const unauthorizedComponent =\n getDefaultExport(options.route.unauthorized) ??\n getDefaultExport(options.rootUnauthorizedModule);\n if (unauthorizedComponent) {\n const UnauthorizedComponent = unauthorizedComponent;\n routeChildren = (\n <UnauthorizedBoundary fallback={<UnauthorizedComponent />}>\n {routeChildren}\n </UnauthorizedBoundary>\n );\n }\n\n const pageErrorComponent = getErrorBoundaryExport(options.route.error);\n if (pageErrorComponent && options.route.error !== lastLayoutErrorModule) {\n routeChildren = <ErrorBoundary fallback={pageErrorComponent}>{routeChildren}</ErrorBoundary>;\n }\n\n for (let index = orderedTreePositions.length - 1; index >= 0; index--) {\n const treePosition = orderedTreePositions[index];\n let segmentChildren: ReactNode = routeChildren;\n const layoutEntry = layoutEntriesByTreePosition.get(treePosition);\n const templateEntry = templateEntriesByTreePosition.get(treePosition);\n\n // Next.js nesting per segment (outer to inner): Layout > Template > Error > Unauthorized > Forbidden > NotFound > children.\n // Building bottom-up means NotFoundBoundary must wrap the leaf subtree first,\n // then ErrorBoundary, then Template, with the Layout slot outermost.\n if (layoutEntry) {\n const layoutNotFoundComponent = getDefaultExport(layoutEntry.notFoundModule);\n if (layoutNotFoundComponent) {\n const LayoutNotFoundComponent = layoutNotFoundComponent;\n segmentChildren = (\n <NotFoundBoundary fallback={<LayoutNotFoundComponent />}>\n {segmentChildren}\n </NotFoundBoundary>\n );\n }\n\n const layoutForbiddenComponent = getDefaultExport(layoutEntry.forbiddenModule);\n if (layoutForbiddenComponent) {\n const LayoutForbiddenComponent = layoutForbiddenComponent;\n segmentChildren = (\n <ForbiddenBoundary fallback={<LayoutForbiddenComponent />}>\n {segmentChildren}\n </ForbiddenBoundary>\n );\n }\n\n const layoutUnauthorizedComponent = getDefaultExport(layoutEntry.unauthorizedModule);\n if (layoutUnauthorizedComponent) {\n const LayoutUnauthorizedComponent = layoutUnauthorizedComponent;\n segmentChildren = (\n <UnauthorizedBoundary fallback={<LayoutUnauthorizedComponent />}>\n {segmentChildren}\n </UnauthorizedBoundary>\n );\n }\n\n const layoutErrorComponent = getErrorBoundaryExport(layoutEntry.errorModule);\n if (layoutErrorComponent) {\n segmentChildren = (\n <ErrorBoundary fallback={layoutErrorComponent}>{segmentChildren}</ErrorBoundary>\n );\n }\n }\n\n if (templateEntry && getDefaultExport(templateEntry.templateModule)) {\n segmentChildren = (\n <Slot\n id={templateEntry.id}\n key={resolveAppPageTemplateKey(\n options.route.routeSegments ?? [],\n templateEntry.treePosition,\n options.matchedParams,\n )}\n >\n {segmentChildren}\n </Slot>\n );\n }\n\n if (!layoutEntry) {\n routeChildren = segmentChildren;\n continue;\n }\n const layoutHasElement = getDefaultExport(layoutEntry.layoutModule) !== null;\n const layoutIndex = layoutIndicesByTreePosition.get(treePosition) ?? -1;\n const segmentMap: { children: string[] } & Record<string, string[]> = {\n children: resolveAppPageChildSegments(\n options.route.routeSegments ?? [],\n layoutEntry.treePosition,\n options.matchedParams,\n ),\n };\n for (const [slotKey, slot] of Object.entries(options.route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n if (targetIndex !== layoutIndex) {\n continue;\n }\n const slotParams = getEffectiveSlotParams(slotKey, slotName);\n segmentMap[slotName] = slot.routeSegments\n ? resolveAppPageChildSegments(slot.routeSegments, 0, slotParams)\n : [];\n }\n\n routeChildren = (\n <LayoutSegmentProvider segmentMap={segmentMap}>\n {layoutHasElement ? (\n <Slot\n id={layoutEntry.id}\n parallelSlots={createAppPageParallelSlotEntries(\n layoutIndex,\n layoutEntries,\n options.route,\n getEffectiveSlotParams,\n )}\n >\n {segmentChildren}\n </Slot>\n ) : (\n segmentChildren\n )}\n </LayoutSegmentProvider>\n );\n }\n\n const globalErrorComponent = getErrorBoundaryExport(options.globalErrorModule);\n if (globalErrorComponent) {\n routeChildren = <ErrorBoundary fallback={globalErrorComponent}>{routeChildren}</ErrorBoundary>;\n }\n\n elements[routeId] = (\n <>\n {createAppP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I;AAIX,MAAI,CAAC,aAAa;AAChB,mBAAgB;AAChB;;EAEF,MAAM,mBAAmB,iBAAiB,YAAY,aAAa,KAAK;EACxE,MAAM,cAAc,4BAA4B,IAAI,aAAa,IAAI;EACrE,MAAM,aAAgE,EACpE,UAAU,4BACR,QAAQ,MAAM,iBAAiB,EAAE,EACjC,YAAY,cACZ,QAAQ,cACT,EACF;AACD,OAAK,MAAM,CAAC,SAAS,SAAS,OAAO,QAAQ,QAAQ,MAAM,SAAS,EAAE,CAAC,EAAE;GACvE,MAAM,WAAW,KAAK;AAEtB,QADoB,KAAK,eAAe,IAAI,KAAK,cAAc,cAAc,SAAS,OAClE,YAClB;GAEF,MAAM,aAAa,uBAAuB,SAAS,SAAS;AAC5D,cAAW,YAAY,KAAK,gBACxB,4BAA4B,KAAK,eAAe,GAAG,WAAW,GAC9D,EAAE;;AAGR,kBACE,oBAAC,uBAAD;GAAmC;aAChC,mBACC,oBAAC,MAAD;IACE,IAAI,YAAY;IAChB,eAAe,iCACb,aACA,eACA,QAAQ,OACR,uBACD;cAEA;IACI,CAAA,GAEP;GAEoB,CAAA;;CAI5B,MAAM,uBAAuB,uBAAuB,QAAQ,kBAAkB;AAC9E,KAAI,qBACF,iBAAgB,oBAAC,eAAD;EAAe,UAAU;YAAuB;EAA8B,CAAA;AAGhG,UAAS,WACP,qBAAA,YAAA,EAAA,UAAA,CACG,uBAAuB,QAAQ,kBAAkB,QAAQ,iBAAiB,EAC1E,cACA,EAAA,CAAA;AAGL,QAAO"}
1
+ {"version":3,"file":"app-page-route-wiring.js","names":["Children"],"sources":["../../src/server/app-page-route-wiring.tsx"],"sourcesContent":["import { Suspense, type ComponentType, type ReactNode } from \"react\";\nimport { AppElementsWire, type AppElements } from \"./app-elements.js\";\nimport {\n ErrorBoundary,\n ForbiddenBoundary,\n NotFoundBoundary,\n UnauthorizedBoundary,\n} from \"vinext/shims/error-boundary\";\nimport type { AppRouteSemanticIds } from \"../routing/app-route-graph.js\";\nimport { LayoutSegmentProvider } from \"vinext/shims/layout-segment-context\";\nimport { MetadataHead, ViewportHead, type Metadata, type Viewport } from \"vinext/shims/metadata\";\nimport { Children, ParallelSlot, Slot } from \"vinext/shims/slot\";\nimport type { AppPageParams } from \"./app-page-boundary.js\";\nimport {\n createAppRenderDependency,\n renderAfterAppDependencies,\n renderWithAppDependencyBarrier,\n type AppRenderDependency,\n} from \"./app-render-dependency.js\";\nimport { resolveAppPageSegmentParams } from \"./app-page-params.js\";\n\ntype AppPageComponentProps = {\n children?: ReactNode;\n error?: unknown;\n params?: unknown;\n reset?: () => void;\n} & Record<string, unknown>;\n\ntype AppPageComponent = ComponentType<AppPageComponentProps>;\ntype AppPageErrorComponent = ComponentType<{ error: unknown; reset: () => void }>;\n\nexport type AppPageModule = Record<string, unknown> & {\n default?: AppPageComponent | null | undefined;\n};\n\nexport type AppPageErrorModule = Record<string, unknown> & {\n default?: AppPageErrorComponent | null | undefined;\n};\n\ntype AppPageRouteWiringSlot<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n /** Graph-owned semantic slot identity. */\n id?: string | null;\n /** Slot prop name passed to the owning layout (e.g. \"modal\" from @modal). */\n name: string;\n default?: TModule | null;\n error?: TErrorModule | null;\n layout?: TModule | null;\n layoutIndex: number;\n loading?: TModule | null;\n page?: TModule | null;\n routeSegments?: readonly string[] | null;\n /**\n * Full URL pattern parts for the slot's mirrored sub-page. Set when the\n * slot's params may differ from the route's (e.g. inherited slot whose\n * dynamic markers have different names than the route's). The runtime\n * matches the request URL against these parts to extract slot params.\n */\n slotPatternParts?: readonly string[] | null;\n /** Param names captured by `slotPatternParts`, in order. */\n slotParamNames?: readonly string[] | null;\n};\n\nexport type AppPageRouteWiringRoute<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n ids?: AppRouteSemanticIds | null;\n error?: TErrorModule | null;\n errors?: readonly (TErrorModule | null | undefined)[] | null;\n layoutTreePositions?: readonly number[] | null;\n layouts: readonly (TModule | null | undefined)[];\n loading?: TModule | null;\n notFound?: TModule | null;\n notFounds?: readonly (TModule | null | undefined)[] | null;\n forbidden?: TModule | null;\n forbiddens?: readonly (TModule | null | undefined)[] | null;\n unauthorized?: TModule | null;\n unauthorizeds?: readonly (TModule | null | undefined)[] | null;\n routeSegments?: readonly string[];\n /**\n * Keyed by stable slot id (name + owner path), not necessarily the slot prop name.\n */\n slots?: Readonly<Record<string, AppPageRouteWiringSlot<TModule, TErrorModule>>> | null;\n templateTreePositions?: readonly number[] | null;\n templates?: readonly (TModule | null | undefined)[] | null;\n};\n\nexport type AppPageSlotOverride<TModule extends AppPageModule = AppPageModule> = {\n layoutModules?: readonly (TModule | null | undefined)[] | null;\n /**\n * The page module to render for this slot. Optional — when omitted, the\n * slot's existing `page` is used (e.g. when the override only changes the\n * slot's `params` for an inherited mirror with distinct param names).\n */\n pageModule?: TModule | null;\n params?: AppPageParams;\n props?: Readonly<Record<string, unknown>>;\n};\n\ntype AppPageLayoutEntry<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n errorModule?: TErrorModule | null | undefined;\n forbiddenModule?: TModule | null | undefined;\n id: string;\n layoutModule?: TModule | null | undefined;\n notFoundModule?: TModule | null | undefined;\n unauthorizedModule?: TModule | null | undefined;\n treePath: string;\n treePosition: number;\n};\n\ntype BuildAppPageRouteElementOptions<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = {\n element: ReactNode;\n globalErrorModule?: TErrorModule | null;\n makeThenableParams: (params: AppPageParams) => unknown;\n matchedParams: AppPageParams;\n resolvedMetadata: Metadata | null;\n resolvedViewport: Viewport;\n rootForbiddenModule?: TModule | null;\n rootNotFoundModule?: TModule | null;\n rootUnauthorizedModule?: TModule | null;\n route: AppPageRouteWiringRoute<TModule, TErrorModule>;\n slotOverrides?: Readonly<Record<string, AppPageSlotOverride<TModule>>> | null;\n};\n\ntype BuildAppPageElementsOptions<\n TModule extends AppPageModule = AppPageModule,\n TErrorModule extends AppPageErrorModule = AppPageErrorModule,\n> = BuildAppPageRouteElementOptions<TModule, TErrorModule> & {\n interceptionContext?: string | null;\n isRscRequest?: boolean;\n mountedSlotIds?: ReadonlySet<string> | null;\n routePath: string;\n};\n\ntype AppPageTemplateEntry<TModule extends AppPageModule = AppPageModule> = {\n id: string;\n templateModule?: TModule | null | undefined;\n treePath: string;\n treePosition: number;\n};\n\nfunction getDefaultExport<TModule extends AppPageModule>(\n module: TModule | null | undefined,\n): AppPageComponent | null {\n return module?.default ?? null;\n}\n\nfunction getErrorBoundaryExport<TModule extends AppPageErrorModule>(\n module: TModule | null | undefined,\n): AppPageErrorComponent | null {\n return module?.default ?? null;\n}\n\nexport function createAppPageTreePath(\n routeSegments: readonly string[] | null | undefined,\n treePosition: number,\n): string {\n const treePathSegments = routeSegments?.slice(0, treePosition) ?? [];\n if (treePathSegments.length === 0) {\n return \"/\";\n }\n return `/${treePathSegments.join(\"/\")}`;\n}\n\nexport function createAppPageLayoutEntries<\n TModule extends AppPageModule,\n TErrorModule extends AppPageErrorModule,\n>(\n route: Pick<\n AppPageRouteWiringRoute<TModule, TErrorModule>,\n \"errors\" | \"layoutTreePositions\" | \"layouts\" | \"notFounds\" | \"routeSegments\"\n > & {\n forbiddens?: readonly (TModule | null | undefined)[] | null;\n unauthorizeds?: readonly (TModule | null | undefined)[] | null;\n },\n): AppPageLayoutEntry<TModule, TErrorModule>[] {\n return route.layouts.map((layoutModule, index) => {\n const treePosition = route.layoutTreePositions?.[index] ?? 0;\n const treePath = createAppPageTreePath(route.routeSegments, treePosition);\n return {\n errorModule: route.errors?.[index] ?? null,\n forbiddenModule: route.forbiddens?.[index] ?? null,\n id: AppElementsWire.encodeLayoutId(treePath),\n layoutModule,\n notFoundModule: route.notFounds?.[index] ?? null,\n unauthorizedModule: route.unauthorizeds?.[index] ?? null,\n treePath,\n treePosition,\n };\n });\n}\n\nfunction createAppPageTemplateEntries<TModule extends AppPageModule>(\n route: Pick<\n AppPageRouteWiringRoute<TModule>,\n \"routeSegments\" | \"templateTreePositions\" | \"templates\"\n >,\n): AppPageTemplateEntry<TModule>[] {\n return (route.templates ?? []).map((templateModule, index) => {\n const treePosition = route.templateTreePositions?.[index] ?? 0;\n const treePath = createAppPageTreePath(route.routeSegments, treePosition);\n return {\n id: AppElementsWire.encodeTemplateId(treePath),\n templateModule,\n treePath,\n treePosition,\n };\n });\n}\n\nexport function resolveAppPageChildSegments(\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n): string[] {\n const rawSegments = routeSegments.slice(treePosition);\n const resolvedSegments: string[] = [];\n\n for (const segment of rawSegments) {\n if (\n segment.startsWith(\"[[...\") &&\n segment.endsWith(\"]]\") &&\n segment.length > \"[[...x]]\".length - 1\n ) {\n const paramName = segment.slice(5, -2);\n const paramValue = params[paramName];\n if (Array.isArray(paramValue) && paramValue.length === 0) {\n continue;\n }\n if (paramValue === undefined) {\n continue;\n }\n resolvedSegments.push(Array.isArray(paramValue) ? paramValue.join(\"/\") : paramValue);\n continue;\n }\n\n if (segment.startsWith(\"[...\") && segment.endsWith(\"]\")) {\n const paramName = segment.slice(4, -1);\n const paramValue = params[paramName];\n if (Array.isArray(paramValue)) {\n resolvedSegments.push(paramValue.join(\"/\"));\n continue;\n }\n resolvedSegments.push(paramValue ?? segment);\n continue;\n }\n\n if (segment.startsWith(\"[\") && segment.endsWith(\"]\") && !segment.includes(\".\")) {\n const paramName = segment.slice(1, -1);\n const paramValue = params[paramName];\n resolvedSegments.push(\n Array.isArray(paramValue) ? paramValue.join(\"/\") : (paramValue ?? segment),\n );\n continue;\n }\n\n resolvedSegments.push(segment);\n }\n\n return resolvedSegments;\n}\n\nfunction resolveAppPageVisibleSegments(\n routeSegments: readonly string[],\n params: AppPageParams,\n): string[] {\n const resolvedSegments = resolveAppPageChildSegments(routeSegments, 0, params);\n return resolvedSegments.filter((segment) => !(segment.startsWith(\"(\") && segment.endsWith(\")\")));\n}\n\nfunction resolveAppPageTemplateKey(\n routeSegments: readonly string[],\n treePosition: number,\n params: AppPageParams,\n): string {\n const visibleSegments = resolveAppPageVisibleSegments(routeSegments.slice(treePosition), params);\n return visibleSegments[0] ?? \"\";\n}\n\nfunction createAppPageParallelSlotEntries<\n TModule extends AppPageModule,\n TErrorModule extends AppPageErrorModule,\n>(\n layoutIndex: number,\n layoutEntries: readonly AppPageLayoutEntry<TModule, TErrorModule>[],\n route: AppPageRouteWiringRoute<TModule, TErrorModule>,\n getEffectiveSlotParams: (slotKey: string, slotName: string) => AppPageParams,\n): Readonly<Record<string, ReactNode>> | undefined {\n const parallelSlots: Record<string, ReactNode> = {};\n\n for (const [slotKey, slot] of Object.entries(route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n if (targetIndex !== layoutIndex) {\n continue;\n }\n\n const layoutEntry = layoutEntries[targetIndex];\n const treePath = layoutEntry?.treePath ?? \"/\";\n const slotParams = getEffectiveSlotParams(slotKey, slotName);\n const slotSegments = slot.routeSegments\n ? resolveAppPageChildSegments(slot.routeSegments, 0, slotParams)\n : [];\n parallelSlots[slotName] = (\n <LayoutSegmentProvider segmentMap={{ children: slotSegments }}>\n <Slot id={AppElementsWire.encodeSlotId(slotName, treePath)} />\n </LayoutSegmentProvider>\n );\n }\n\n return Object.keys(parallelSlots).length > 0 ? parallelSlots : undefined;\n}\n\nfunction createAppPageRouteHead(metadata: Metadata | null, viewport: Viewport): ReactNode {\n return (\n <>\n <meta charSet=\"utf-8\" />\n {metadata ? <MetadataHead metadata={metadata} /> : null}\n <ViewportHead viewport={viewport} />\n </>\n );\n}\n\nexport function buildAppPageElements<\n TModule extends AppPageModule,\n TErrorModule extends AppPageErrorModule,\n>(options: BuildAppPageElementsOptions<TModule, TErrorModule>): AppElements {\n const interceptionContext = options.interceptionContext ?? null;\n const routeId = AppElementsWire.encodeRouteId(options.routePath, interceptionContext);\n const pageId = AppElementsWire.encodePageId(options.routePath, interceptionContext);\n const layoutEntries = createAppPageLayoutEntries(options.route);\n const templateEntries = createAppPageTemplateEntries(options.route);\n const layoutEntriesByTreePosition = new Map<number, AppPageLayoutEntry<TModule, TErrorModule>>();\n const templateEntriesByTreePosition = new Map<number, AppPageTemplateEntry<TModule>>();\n for (const layoutEntry of layoutEntries) {\n layoutEntriesByTreePosition.set(layoutEntry.treePosition, layoutEntry);\n }\n for (const templateEntry of templateEntries) {\n templateEntriesByTreePosition.set(templateEntry.treePosition, templateEntry);\n }\n const layoutIndicesByTreePosition = new Map<number, number>();\n for (let index = 0; index < layoutEntries.length; index++) {\n layoutIndicesByTreePosition.set(layoutEntries[index].treePosition, index);\n }\n const layoutDependenciesByIndex = new Map<number, AppRenderDependency>();\n const layoutDependenciesBefore: AppRenderDependency[][] = [];\n const slotDependenciesByLayoutIndex: AppRenderDependency[][] = [];\n const templateDependenciesById = new Map<string, AppRenderDependency>();\n const templateDependenciesBeforeById = new Map<string, AppRenderDependency[]>();\n const pageDependencies: AppRenderDependency[] = [];\n const rootLayoutTreePath = layoutEntries[0]?.treePath ?? null;\n const elements: Record<string, ReactNode | string | null> = {\n ...AppElementsWire.createMetadataEntries({\n interceptionContext,\n rootLayoutTreePath,\n routeId,\n }),\n };\n const slotNameCounts = new Map<string, number>();\n for (const slot of Object.values(options.route.slots ?? {})) {\n const slotName = slot.name;\n slotNameCounts.set(slotName, (slotNameCounts.get(slotName) ?? 0) + 1);\n }\n const orderedTreePositions = Array.from(\n new Set<number>([\n ...layoutEntries.map((entry) => entry.treePosition),\n ...templateEntries.map((entry) => entry.treePosition),\n ]),\n ).sort((left, right) => left - right);\n const resolveSlotOverride = (slotKey: string, slotName: string) => {\n const overrideByKey = options.slotOverrides?.[slotKey];\n if (overrideByKey) {\n return overrideByKey;\n }\n\n // Legacy callers may still provide overrides by slot prop name.\n // Only allow that fallback when it is unambiguous.\n if (slotKey === slotName || (slotNameCounts.get(slotName) ?? 0) === 1) {\n return options.slotOverrides?.[slotName];\n }\n\n return undefined;\n };\n const getEffectiveSlotParams = (slotKey: string, slotName: string): AppPageParams =>\n resolveSlotOverride(slotKey, slotName)?.params ?? options.matchedParams;\n\n for (const treePosition of orderedTreePositions) {\n const layoutIndex = layoutIndicesByTreePosition.get(treePosition);\n if (layoutIndex !== undefined) {\n const layoutEntry = layoutEntries[layoutIndex];\n layoutDependenciesBefore[layoutIndex] = [...pageDependencies];\n if (getDefaultExport(layoutEntry.layoutModule)) {\n const layoutDependency = createAppRenderDependency();\n layoutDependenciesByIndex.set(layoutIndex, layoutDependency);\n pageDependencies.push(layoutDependency);\n }\n slotDependenciesByLayoutIndex[layoutIndex] = [...pageDependencies];\n }\n\n const templateEntry = templateEntriesByTreePosition.get(treePosition);\n if (!templateEntry || !getDefaultExport(templateEntry.templateModule)) {\n continue;\n }\n\n const templateDependency = createAppRenderDependency();\n templateDependenciesById.set(templateEntry.id, templateDependency);\n templateDependenciesBeforeById.set(templateEntry.id, [...pageDependencies]);\n pageDependencies.push(templateDependency);\n }\n\n elements[pageId] = renderAfterAppDependencies(options.element, pageDependencies);\n\n for (const templateEntry of templateEntries) {\n const templateComponent = getDefaultExport(templateEntry.templateModule);\n if (!templateComponent) {\n continue;\n }\n const TemplateComponent = templateComponent;\n const templateDependency = templateDependenciesById.get(templateEntry.id);\n const templateElement = templateDependency ? (\n renderWithAppDependencyBarrier(\n <TemplateComponent params={options.matchedParams}>\n <Children />\n </TemplateComponent>,\n templateDependency,\n )\n ) : (\n <TemplateComponent params={options.matchedParams}>\n <Children />\n </TemplateComponent>\n );\n elements[templateEntry.id] = renderAfterAppDependencies(\n templateElement,\n templateDependenciesBeforeById.get(templateEntry.id) ?? [],\n );\n }\n\n for (let index = 0; index < layoutEntries.length; index++) {\n const layoutEntry = layoutEntries[index];\n const layoutComponent = getDefaultExport(layoutEntry.layoutModule);\n if (!layoutComponent) {\n continue;\n }\n\n const layoutProps: Record<string, unknown> = {\n params: options.makeThenableParams(\n resolveAppPageSegmentParams(\n options.route.routeSegments,\n layoutEntry.treePosition,\n options.matchedParams,\n ),\n ),\n };\n\n for (const slot of Object.values(options.route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n if (targetIndex !== index) {\n continue;\n }\n layoutProps[slotName] = <ParallelSlot name={slotName} />;\n }\n\n const LayoutComponent = layoutComponent;\n const layoutDependency = layoutDependenciesByIndex.get(index);\n const layoutElement = layoutDependency ? (\n renderWithAppDependencyBarrier(\n <LayoutComponent {...layoutProps}>\n <Children />\n </LayoutComponent>,\n layoutDependency,\n )\n ) : (\n <LayoutComponent {...layoutProps}>\n <Children />\n </LayoutComponent>\n );\n elements[layoutEntry.id] = renderAfterAppDependencies(\n layoutElement,\n layoutDependenciesBefore[index] ?? [],\n );\n }\n\n for (const [slotKey, slot] of Object.entries(options.route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n const treePath = layoutEntries[targetIndex]?.treePath ?? \"/\";\n const slotId = AppElementsWire.encodeSlotId(slotName, treePath);\n const slotOverride = resolveSlotOverride(slotKey, slotName);\n const slotParams = getEffectiveSlotParams(slotKey, slotName);\n const overrideOrPageComponent =\n getDefaultExport(slotOverride?.pageModule) ?? getDefaultExport(slot.page);\n const defaultComponent = getDefaultExport(slot.default);\n\n // On soft nav (RSC): omit key when only default.tsx exists and the slot is\n // already mounted on the client. Absent key means the browser retains prior\n // slot content rather than replacing it. When the slot is not yet mounted\n // (first entry into this layout), include the key so default.tsx renders.\n if (\n !overrideOrPageComponent &&\n defaultComponent &&\n options.isRscRequest &&\n options.mountedSlotIds?.has(slotId)\n ) {\n continue;\n }\n\n const slotComponent = overrideOrPageComponent ?? defaultComponent;\n\n if (!slotComponent) {\n elements[slotId] = AppElementsWire.unmatchedSlotValue;\n continue;\n }\n\n const slotThenableParams = options.makeThenableParams(slotParams);\n const slotProps: Record<string, unknown> = {\n params: slotThenableParams,\n };\n if (slotOverride?.props) {\n Object.assign(slotProps, slotOverride.props);\n }\n\n const SlotComponent = slotComponent;\n let slotElement: ReactNode = <SlotComponent {...slotProps} />;\n const interceptLayouts = slotOverride?.layoutModules ?? [];\n\n for (let layoutIndex = interceptLayouts.length - 1; layoutIndex >= 0; layoutIndex--) {\n const interceptLayoutComponent = getDefaultExport(interceptLayouts[layoutIndex]);\n if (!interceptLayoutComponent) {\n continue;\n }\n const InterceptLayoutComponent = interceptLayoutComponent;\n slotElement = (\n <InterceptLayoutComponent params={slotThenableParams}>\n {slotElement}\n </InterceptLayoutComponent>\n );\n }\n\n const slotLayoutComponent = getDefaultExport(slot.layout);\n if (slotLayoutComponent) {\n const SlotLayoutComponent = slotLayoutComponent;\n slotElement = (\n <SlotLayoutComponent params={slotThenableParams}>{slotElement}</SlotLayoutComponent>\n );\n }\n\n const slotLoadingComponent = getDefaultExport(slot.loading);\n if (slotLoadingComponent) {\n const SlotLoadingComponent = slotLoadingComponent;\n slotElement = <Suspense fallback={<SlotLoadingComponent />}>{slotElement}</Suspense>;\n }\n\n const slotErrorComponent = getErrorBoundaryExport(slot.error);\n if (slotErrorComponent) {\n slotElement = <ErrorBoundary fallback={slotErrorComponent}>{slotElement}</ErrorBoundary>;\n }\n\n elements[slotId] = renderAfterAppDependencies(\n slotElement,\n targetIndex >= 0 ? (slotDependenciesByLayoutIndex[targetIndex] ?? []) : [],\n );\n }\n\n let routeChildren: ReactNode = (\n <LayoutSegmentProvider segmentMap={{ children: [] }}>\n <Slot id={pageId} />\n </LayoutSegmentProvider>\n );\n\n const routeLoadingComponent = getDefaultExport(options.route.loading);\n if (routeLoadingComponent) {\n const RouteLoadingComponent = routeLoadingComponent;\n routeChildren = <Suspense fallback={<RouteLoadingComponent />}>{routeChildren}</Suspense>;\n }\n\n const lastLayoutErrorModule =\n options.route.errors && options.route.errors.length > 0\n ? options.route.errors[options.route.errors.length - 1]\n : null;\n // Next.js nesting (outer to inner): Error > Unauthorized > Forbidden > NotFound > children.\n // Building bottom-up means NotFoundBoundary must wrap first, then Forbidden, Unauthorized, Error.\n const notFoundComponent =\n getDefaultExport(options.route.notFound) ?? getDefaultExport(options.rootNotFoundModule);\n if (notFoundComponent) {\n const NotFoundComponent = notFoundComponent;\n routeChildren = (\n <NotFoundBoundary fallback={<NotFoundComponent />}>{routeChildren}</NotFoundBoundary>\n );\n }\n\n const forbiddenComponent =\n getDefaultExport(options.route.forbidden) ?? getDefaultExport(options.rootForbiddenModule);\n if (forbiddenComponent) {\n const ForbiddenComponent = forbiddenComponent;\n routeChildren = (\n <ForbiddenBoundary fallback={<ForbiddenComponent />}>{routeChildren}</ForbiddenBoundary>\n );\n }\n\n const unauthorizedComponent =\n getDefaultExport(options.route.unauthorized) ??\n getDefaultExport(options.rootUnauthorizedModule);\n if (unauthorizedComponent) {\n const UnauthorizedComponent = unauthorizedComponent;\n routeChildren = (\n <UnauthorizedBoundary fallback={<UnauthorizedComponent />}>\n {routeChildren}\n </UnauthorizedBoundary>\n );\n }\n\n const pageErrorComponent = getErrorBoundaryExport(options.route.error);\n if (pageErrorComponent && options.route.error !== lastLayoutErrorModule) {\n routeChildren = <ErrorBoundary fallback={pageErrorComponent}>{routeChildren}</ErrorBoundary>;\n }\n\n for (let index = orderedTreePositions.length - 1; index >= 0; index--) {\n const treePosition = orderedTreePositions[index];\n let segmentChildren: ReactNode = routeChildren;\n const layoutEntry = layoutEntriesByTreePosition.get(treePosition);\n const templateEntry = templateEntriesByTreePosition.get(treePosition);\n\n // Next.js nesting per segment (outer to inner): Layout > Template > Error > Unauthorized > Forbidden > NotFound > children.\n // Building bottom-up means NotFoundBoundary must wrap the leaf subtree first,\n // then ErrorBoundary, then Template, with the Layout slot outermost.\n if (layoutEntry) {\n const layoutNotFoundComponent = getDefaultExport(layoutEntry.notFoundModule);\n if (layoutNotFoundComponent) {\n const LayoutNotFoundComponent = layoutNotFoundComponent;\n segmentChildren = (\n <NotFoundBoundary fallback={<LayoutNotFoundComponent />}>\n {segmentChildren}\n </NotFoundBoundary>\n );\n }\n\n const layoutForbiddenComponent = getDefaultExport(layoutEntry.forbiddenModule);\n if (layoutForbiddenComponent) {\n const LayoutForbiddenComponent = layoutForbiddenComponent;\n segmentChildren = (\n <ForbiddenBoundary fallback={<LayoutForbiddenComponent />}>\n {segmentChildren}\n </ForbiddenBoundary>\n );\n }\n\n const layoutUnauthorizedComponent = getDefaultExport(layoutEntry.unauthorizedModule);\n if (layoutUnauthorizedComponent) {\n const LayoutUnauthorizedComponent = layoutUnauthorizedComponent;\n segmentChildren = (\n <UnauthorizedBoundary fallback={<LayoutUnauthorizedComponent />}>\n {segmentChildren}\n </UnauthorizedBoundary>\n );\n }\n\n const layoutErrorComponent = getErrorBoundaryExport(layoutEntry.errorModule);\n if (layoutErrorComponent) {\n segmentChildren = (\n <ErrorBoundary fallback={layoutErrorComponent}>{segmentChildren}</ErrorBoundary>\n );\n }\n }\n\n if (templateEntry && getDefaultExport(templateEntry.templateModule)) {\n segmentChildren = (\n <Slot\n id={templateEntry.id}\n key={resolveAppPageTemplateKey(\n options.route.routeSegments ?? [],\n templateEntry.treePosition,\n options.matchedParams,\n )}\n >\n {segmentChildren}\n </Slot>\n );\n }\n\n if (!layoutEntry) {\n routeChildren = segmentChildren;\n continue;\n }\n const layoutHasElement = getDefaultExport(layoutEntry.layoutModule) !== null;\n const layoutIndex = layoutIndicesByTreePosition.get(treePosition) ?? -1;\n const segmentMap: { children: string[] } & Record<string, string[]> = {\n children: resolveAppPageChildSegments(\n options.route.routeSegments ?? [],\n layoutEntry.treePosition,\n options.matchedParams,\n ),\n };\n for (const [slotKey, slot] of Object.entries(options.route.slots ?? {})) {\n const slotName = slot.name;\n const targetIndex = slot.layoutIndex >= 0 ? slot.layoutIndex : layoutEntries.length - 1;\n if (targetIndex !== layoutIndex) {\n continue;\n }\n const slotParams = getEffectiveSlotParams(slotKey, slotName);\n segmentMap[slotName] = slot.routeSegments\n ? resolveAppPageChildSegments(slot.routeSegments, 0, slotParams)\n : [];\n }\n\n routeChildren = (\n <LayoutSegmentProvider segmentMap={segmentMap}>\n {layoutHasElement ? (\n <Slot\n id={layoutEntry.id}\n parallelSlots={createAppPageParallelSlotEntries(\n layoutIndex,\n layoutEntries,\n options.route,\n getEffectiveSlotParams,\n )}\n >\n {segmentChildren}\n </Slot>\n ) : (\n segmentChildren\n )}\n </LayoutSegmentProvider>\n );\n }\n\n const globalErrorComponent = getErrorBoundaryExport(options.globalErrorModule);\n if (globalErrorComponent) {\n routeChildren = <ErrorBoundary fallback={globalErrorComponent}>{routeChildren}</ErrorBoundary>;\n }\n\n elements[routeId] = (\n <>\n {createAppPageRouteHead(options.resolvedMetadata, options.resolvedViewport)}\n {routeChildren}\n </>\n );\n\n return elements;\n}\n"],"mappings":";;;;;;;;;;;AAsJA,SAAS,iBACP,QACyB;AACzB,QAAO,QAAQ,WAAW;;AAG5B,SAAS,uBACP,QAC8B;AAC9B,QAAO,QAAQ,WAAW;;AAG5B,SAAgB,sBACd,eACA,cACQ;CACR,MAAM,mBAAmB,eAAe,MAAM,GAAG,aAAa,IAAI,EAAE;AACpE,KAAI,iBAAiB,WAAW,EAC9B,QAAO;AAET,QAAO,IAAI,iBAAiB,KAAK,IAAI;;AAGvC,SAAgB,2BAId,OAO6C;AAC7C,QAAO,MAAM,QAAQ,KAAK,cAAc,UAAU;EAChD,MAAM,eAAe,MAAM,sBAAsB,UAAU;EAC3D,MAAM,WAAW,sBAAsB,MAAM,eAAe,aAAa;AACzE,SAAO;GACL,aAAa,MAAM,SAAS,UAAU;GACtC,iBAAiB,MAAM,aAAa,UAAU;GAC9C,IAAI,gBAAgB,eAAe,SAAS;GAC5C;GACA,gBAAgB,MAAM,YAAY,UAAU;GAC5C,oBAAoB,MAAM,gBAAgB,UAAU;GACpD;GACA;GACD;GACD;;AAGJ,SAAS,6BACP,OAIiC;A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GAEP;GAEoB,CAAA;;CAI5B,MAAM,uBAAuB,uBAAuB,QAAQ,kBAAkB;AAC9E,KAAI,qBACF,iBAAgB,oBAAC,eAAD;EAAe,UAAU;YAAuB;EAA8B,CAAA;AAGhG,UAAS,WACP,qBAAA,YAAA,EAAA,UAAA,CACG,uBAAuB,QAAQ,kBAAkB,QAAQ,iBAAiB,EAC1E,cACA,EAAA,CAAA;AAGL,QAAO"}
@@ -52,6 +52,13 @@ type RenderAppPageHtmlStreamWithRecoveryOptions<TSpecialError> = {
52
52
  };
53
53
  type AppPageRscErrorTracker = {
54
54
  getCapturedError: () => unknown;
55
+ /**
56
+ * Returns a NEXT_REDIRECT or NEXT_HTTP_ERROR_FALLBACK error captured during
57
+ * the RSC render. Read after the SSR shell promise resolves to swap a
58
+ * 307/404 in place of the streamed body when redirect()/notFound() throws
59
+ * synchronously inside a route-level Suspense boundary (loading.tsx).
60
+ */
61
+ getCapturedSpecialError: () => unknown;
55
62
  onRenderError: (error: unknown, requestInfo: unknown, errorContext: unknown) => unknown;
56
63
  };
57
64
  type ShouldRerenderAppPageWithGlobalErrorOptions = {
@@ -1,3 +1,4 @@
1
+ import { VINEXT_RSC_VARY_HEADER } from "./app-rsc-cache-busting.js";
1
2
  import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
2
3
  //#region src/server/app-page-stream.ts
3
4
  function createAppPageFontData(options) {
@@ -56,7 +57,7 @@ async function renderAppPageHtmlResponse(options) {
56
57
  });
57
58
  const headers = new Headers({
58
59
  "Content-Type": "text/html; charset=utf-8",
59
- Vary: "RSC, Accept"
60
+ Vary: VINEXT_RSC_VARY_HEADER
60
61
  });
61
62
  if (options.fontLinkHeader) headers.set("Link", options.fontLinkHeader);
62
63
  mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);
@@ -89,12 +90,18 @@ async function renderAppPageHtmlStreamWithRecovery(options) {
89
90
  }
90
91
  function createAppPageRscErrorTracker(baseOnError) {
91
92
  let capturedError = null;
93
+ let capturedSpecialError = null;
92
94
  return {
93
95
  getCapturedError() {
94
96
  return capturedError;
95
97
  },
98
+ getCapturedSpecialError() {
99
+ return capturedSpecialError;
100
+ },
96
101
  onRenderError(error, requestInfo, errorContext) {
97
- if (!(error && typeof error === "object" && "digest" in error)) capturedError = error;
102
+ if (error && typeof error === "object" && "digest" in error) {
103
+ if (capturedSpecialError === null) capturedSpecialError = error;
104
+ } else capturedError = error;
98
105
  return baseOnError(error, requestInfo, errorContext);
99
106
  }
100
107
  };
@@ -1 +1 @@
1
- {"version":3,"file":"app-page-stream.js","names":[],"sources":["../../src/server/app-page-stream.ts"],"sourcesContent":["import type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\n\nexport type AppPageFontData = {\n links: string[];\n preloads: readonly AppPageFontPreload[];\n styles: string[];\n};\n\ntype CreateAppPageFontDataOptions = {\n getLinks: () => string[];\n getPreloads: () => AppPageFontPreload[];\n getStyles: () => string[];\n};\n\nexport type AppPageSsrHandler = {\n handleSsr: (\n rscStream: ReadableStream<Uint8Array>,\n navigationContext: unknown,\n fontData: AppPageFontData,\n options?: {\n scriptNonce?: string;\n sideStream?: ReadableStream<Uint8Array>;\n capturedRscDataRef?: { value: Promise<ArrayBuffer> | null };\n },\n ) => Promise<ReadableStream<Uint8Array>>;\n};\n\ntype RenderAppPageHtmlStreamOptions = {\n fontData: AppPageFontData;\n navigationContext: unknown;\n rscStream: ReadableStream<Uint8Array>;\n scriptNonce?: string;\n ssrHandler: AppPageSsrHandler;\n /** Pre-split side stream for fused embed+capture (#981). When set,\n * handleSsr skips its internal tee and accumulates raw RSC bytes. */\n sideStream?: ReadableStream<Uint8Array>;\n /** Out-parameter filled with accumulated raw RSC bytes after stream consumption. */\n capturedRscDataRef?: { value: Promise<ArrayBuffer> | null };\n};\n\ntype RenderAppPageHtmlResponseOptions = {\n clearRequestContext: () => void;\n fontLinkHeader?: string;\n middlewareHeaders?: Headers | null;\n status: number;\n} & RenderAppPageHtmlStreamOptions;\n\ntype AppPageHtmlStreamRecoveryResult = {\n htmlStream: ReadableStream<Uint8Array> | null;\n response: Response | null;\n};\n\ntype RenderAppPageHtmlStreamWithRecoveryOptions<TSpecialError> = {\n onShellRendered?: () => void;\n renderErrorBoundaryResponse: (error: unknown) => Promise<Response | null>;\n renderHtmlStream: () => Promise<ReadableStream<Uint8Array>>;\n renderSpecialErrorResponse: (specialError: TSpecialError) => Promise<Response>;\n resolveSpecialError: (error: unknown) => TSpecialError | null;\n};\n\ntype AppPageRscErrorTracker = {\n getCapturedError: () => unknown;\n onRenderError: (error: unknown, requestInfo: unknown, errorContext: unknown) => unknown;\n};\n\ntype ShouldRerenderAppPageWithGlobalErrorOptions = {\n capturedError: unknown;\n hasLocalBoundary: boolean;\n};\n\nexport function createAppPageFontData(options: CreateAppPageFontDataOptions): AppPageFontData {\n return {\n links: options.getLinks(),\n preloads: options.getPreloads(),\n styles: options.getStyles(),\n };\n}\n\nexport async function renderAppPageHtmlStream(\n options: RenderAppPageHtmlStreamOptions,\n): Promise<ReadableStream<Uint8Array>> {\n const ssrOptions = {\n scriptNonce: options.scriptNonce,\n sideStream: options.sideStream,\n capturedRscDataRef: options.capturedRscDataRef,\n };\n\n return options.ssrHandler.handleSsr(\n options.rscStream,\n options.navigationContext,\n options.fontData,\n ssrOptions,\n );\n}\n\n/**\n * Wraps a stream so that `onFlush` is called when the last byte has been read\n * by the downstream consumer (i.e. when the HTTP layer finishes draining the\n * response body). This is the correct place to clear per-request context,\n * because the RSC/SSR pipeline is lazy — components execute while the stream\n * is being consumed, not when the stream handle is first obtained.\n */\nexport function deferUntilStreamConsumed(\n stream: ReadableStream<Uint8Array>,\n onFlush: () => void,\n): ReadableStream<Uint8Array> {\n let called = false;\n const once = () => {\n if (!called) {\n called = true;\n onFlush();\n }\n };\n\n const cleanup = new TransformStream<Uint8Array, Uint8Array>({\n flush() {\n once();\n },\n });\n\n const piped = stream.pipeThrough(cleanup);\n\n // Wrap with a ReadableStream so we can intercept cancel() — the TransformStream\n // Transformer interface does not expose a cancel hook in the Web Streams spec.\n const reader = piped.getReader();\n return new ReadableStream<Uint8Array>({\n pull(controller) {\n return reader.read().then(\n ({ done, value }) => {\n if (done) {\n controller.close();\n } else {\n controller.enqueue(value);\n }\n },\n (error) => {\n once();\n controller.error(error);\n },\n );\n },\n cancel(reason) {\n // Stream cancelled before fully consumed (e.g. client disconnected).\n // Still clear per-request context to avoid leaks.\n once();\n return reader.cancel(reason);\n },\n });\n}\n\nexport async function renderAppPageHtmlResponse(\n options: RenderAppPageHtmlResponseOptions,\n): Promise<Response> {\n const htmlStream = await renderAppPageHtmlStream(options);\n\n // Defer clearRequestContext() until the stream is fully consumed by the HTTP\n // layer. Calling it synchronously here would race the lazy RSC/SSR pipeline:\n // components execute while the stream is being pulled, not when the handle\n // is first returned. See: https://github.com/cloudflare/vinext/issues/660\n const safeStream = deferUntilStreamConsumed(htmlStream, () => {\n options.clearRequestContext();\n });\n\n const headers = new Headers({\n \"Content-Type\": \"text/html; charset=utf-8\",\n Vary: \"RSC, Accept\",\n });\n\n if (options.fontLinkHeader) {\n headers.set(\"Link\", options.fontLinkHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n\n return new Response(safeStream, {\n status: options.status,\n headers,\n });\n}\n\nexport async function renderAppPageHtmlStreamWithRecovery<TSpecialError>(\n options: RenderAppPageHtmlStreamWithRecoveryOptions<TSpecialError>,\n): Promise<AppPageHtmlStreamRecoveryResult> {\n try {\n const htmlStream = await options.renderHtmlStream();\n options.onShellRendered?.();\n return {\n htmlStream,\n response: null,\n };\n } catch (error) {\n const specialError = options.resolveSpecialError(error);\n if (specialError) {\n return {\n htmlStream: null,\n response: await options.renderSpecialErrorResponse(specialError),\n };\n }\n\n const boundaryResponse = await options.renderErrorBoundaryResponse(error);\n if (boundaryResponse) {\n return {\n htmlStream: null,\n response: boundaryResponse,\n };\n }\n\n throw error;\n }\n}\n\nexport function createAppPageRscErrorTracker(\n baseOnError: (error: unknown, requestInfo: unknown, errorContext: unknown) => unknown,\n): AppPageRscErrorTracker {\n let capturedError: unknown = null;\n\n return {\n getCapturedError() {\n return capturedError;\n },\n onRenderError(error, requestInfo, errorContext) {\n if (!(error && typeof error === \"object\" && \"digest\" in error)) {\n capturedError = error;\n }\n return baseOnError(error, requestInfo, errorContext);\n },\n };\n}\n\nexport function shouldRerenderAppPageWithGlobalError(\n options: ShouldRerenderAppPageWithGlobalErrorOptions,\n): boolean {\n return Boolean(options.capturedError) && !options.hasLocalBoundary;\n}\n"],"mappings":";;AAuEA,SAAgB,sBAAsB,SAAwD;AAC5F,QAAO;EACL,OAAO,QAAQ,UAAU;EACzB,UAAU,QAAQ,aAAa;EAC/B,QAAQ,QAAQ,WAAW;EAC5B;;AAGH,eAAsB,wBACpB,SACqC;CACrC,MAAM,aAAa;EACjB,aAAa,QAAQ;EACrB,YAAY,QAAQ;EACpB,oBAAoB,QAAQ;EAC7B;AAED,QAAO,QAAQ,WAAW,UACxB,QAAQ,WACR,QAAQ,mBACR,QAAQ,UACR,WACD;;;;;;;;;AAUH,SAAgB,yBACd,QACA,SAC4B;CAC5B,IAAI,SAAS;CACb,MAAM,aAAa;AACjB,MAAI,CAAC,QAAQ;AACX,YAAS;AACT,YAAS;;;CAIb,MAAM,UAAU,IAAI,gBAAwC,EAC1D,QAAQ;AACN,QAAM;IAET,CAAC;CAMF,MAAM,SAJQ,OAAO,YAAY,QAAQ,CAIpB,WAAW;AAChC,QAAO,IAAI,eAA2B;EACpC,KAAK,YAAY;AACf,UAAO,OAAO,MAAM,CAAC,MAClB,EAAE,MAAM,YAAY;AACnB,QAAI,KACF,YAAW,OAAO;QAElB,YAAW,QAAQ,MAAM;OAG5B,UAAU;AACT,UAAM;AACN,eAAW,MAAM,MAAM;KAE1B;;EAEH,OAAO,QAAQ;AAGb,SAAM;AACN,UAAO,OAAO,OAAO,OAAO;;EAE/B,CAAC;;AAGJ,eAAsB,0BACpB,SACmB;CAOnB,MAAM,aAAa,yBANA,MAAM,wBAAwB,QAAQ,QAMK;AAC5D,UAAQ,qBAAqB;GAC7B;CAEF,MAAM,UAAU,IAAI,QAAQ;EAC1B,gBAAgB;EAChB,MAAM;EACP,CAAC;AAEF,KAAI,QAAQ,eACV,SAAQ,IAAI,QAAQ,QAAQ,eAAe;AAG7C,gCAA+B,SAAS,QAAQ,qBAAqB,KAAK;AAE1E,QAAO,IAAI,SAAS,YAAY;EAC9B,QAAQ,QAAQ;EAChB;EACD,CAAC;;AAGJ,eAAsB,oCACpB,SAC0C;AAC1C,KAAI;EACF,MAAM,aAAa,MAAM,QAAQ,kBAAkB;AACnD,UAAQ,mBAAmB;AAC3B,SAAO;GACL;GACA,UAAU;GACX;UACM,OAAO;EACd,MAAM,eAAe,QAAQ,oBAAoB,MAAM;AACvD,MAAI,aACF,QAAO;GACL,YAAY;GACZ,UAAU,MAAM,QAAQ,2BAA2B,aAAa;GACjE;EAGH,MAAM,mBAAmB,MAAM,QAAQ,4BAA4B,MAAM;AACzE,MAAI,iBACF,QAAO;GACL,YAAY;GACZ,UAAU;GACX;AAGH,QAAM;;;AAIV,SAAgB,6BACd,aACwB;CACxB,IAAI,gBAAyB;AAE7B,QAAO;EACL,mBAAmB;AACjB,UAAO;;EAET,cAAc,OAAO,aAAa,cAAc;AAC9C,OAAI,EAAE,SAAS,OAAO,UAAU,YAAY,YAAY,OACtD,iBAAgB;AAElB,UAAO,YAAY,OAAO,aAAa,aAAa;;EAEvD;;AAGH,SAAgB,qCACd,SACS;AACT,QAAO,QAAQ,QAAQ,cAAc,IAAI,CAAC,QAAQ"}
1
+ {"version":3,"file":"app-page-stream.js","names":[],"sources":["../../src/server/app-page-stream.ts"],"sourcesContent":["import type { AppPageFontPreload } from \"./app-page-execution.js\";\nimport { VINEXT_RSC_VARY_HEADER } from \"./app-rsc-cache-busting.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\n\nexport type AppPageFontData = {\n links: string[];\n preloads: readonly AppPageFontPreload[];\n styles: string[];\n};\n\ntype CreateAppPageFontDataOptions = {\n getLinks: () => string[];\n getPreloads: () => AppPageFontPreload[];\n getStyles: () => string[];\n};\n\nexport type AppPageSsrHandler = {\n handleSsr: (\n rscStream: ReadableStream<Uint8Array>,\n navigationContext: unknown,\n fontData: AppPageFontData,\n options?: {\n scriptNonce?: string;\n sideStream?: ReadableStream<Uint8Array>;\n capturedRscDataRef?: { value: Promise<ArrayBuffer> | null };\n },\n ) => Promise<ReadableStream<Uint8Array>>;\n};\n\ntype RenderAppPageHtmlStreamOptions = {\n fontData: AppPageFontData;\n navigationContext: unknown;\n rscStream: ReadableStream<Uint8Array>;\n scriptNonce?: string;\n ssrHandler: AppPageSsrHandler;\n /** Pre-split side stream for fused embed+capture (#981). When set,\n * handleSsr skips its internal tee and accumulates raw RSC bytes. */\n sideStream?: ReadableStream<Uint8Array>;\n /** Out-parameter filled with accumulated raw RSC bytes after stream consumption. */\n capturedRscDataRef?: { value: Promise<ArrayBuffer> | null };\n};\n\ntype RenderAppPageHtmlResponseOptions = {\n clearRequestContext: () => void;\n fontLinkHeader?: string;\n middlewareHeaders?: Headers | null;\n status: number;\n} & RenderAppPageHtmlStreamOptions;\n\ntype AppPageHtmlStreamRecoveryResult = {\n htmlStream: ReadableStream<Uint8Array> | null;\n response: Response | null;\n};\n\ntype RenderAppPageHtmlStreamWithRecoveryOptions<TSpecialError> = {\n onShellRendered?: () => void;\n renderErrorBoundaryResponse: (error: unknown) => Promise<Response | null>;\n renderHtmlStream: () => Promise<ReadableStream<Uint8Array>>;\n renderSpecialErrorResponse: (specialError: TSpecialError) => Promise<Response>;\n resolveSpecialError: (error: unknown) => TSpecialError | null;\n};\n\ntype AppPageRscErrorTracker = {\n getCapturedError: () => unknown;\n /**\n * Returns a NEXT_REDIRECT or NEXT_HTTP_ERROR_FALLBACK error captured during\n * the RSC render. Read after the SSR shell promise resolves to swap a\n * 307/404 in place of the streamed body when redirect()/notFound() throws\n * synchronously inside a route-level Suspense boundary (loading.tsx).\n */\n getCapturedSpecialError: () => unknown;\n onRenderError: (error: unknown, requestInfo: unknown, errorContext: unknown) => unknown;\n};\n\ntype ShouldRerenderAppPageWithGlobalErrorOptions = {\n capturedError: unknown;\n hasLocalBoundary: boolean;\n};\n\nexport function createAppPageFontData(options: CreateAppPageFontDataOptions): AppPageFontData {\n return {\n links: options.getLinks(),\n preloads: options.getPreloads(),\n styles: options.getStyles(),\n };\n}\n\nexport async function renderAppPageHtmlStream(\n options: RenderAppPageHtmlStreamOptions,\n): Promise<ReadableStream<Uint8Array>> {\n const ssrOptions = {\n scriptNonce: options.scriptNonce,\n sideStream: options.sideStream,\n capturedRscDataRef: options.capturedRscDataRef,\n };\n\n return options.ssrHandler.handleSsr(\n options.rscStream,\n options.navigationContext,\n options.fontData,\n ssrOptions,\n );\n}\n\n/**\n * Wraps a stream so that `onFlush` is called when the last byte has been read\n * by the downstream consumer (i.e. when the HTTP layer finishes draining the\n * response body). This is the correct place to clear per-request context,\n * because the RSC/SSR pipeline is lazy — components execute while the stream\n * is being consumed, not when the stream handle is first obtained.\n */\nexport function deferUntilStreamConsumed(\n stream: ReadableStream<Uint8Array>,\n onFlush: () => void,\n): ReadableStream<Uint8Array> {\n let called = false;\n const once = () => {\n if (!called) {\n called = true;\n onFlush();\n }\n };\n\n const cleanup = new TransformStream<Uint8Array, Uint8Array>({\n flush() {\n once();\n },\n });\n\n const piped = stream.pipeThrough(cleanup);\n\n // Wrap with a ReadableStream so we can intercept cancel() — the TransformStream\n // Transformer interface does not expose a cancel hook in the Web Streams spec.\n const reader = piped.getReader();\n return new ReadableStream<Uint8Array>({\n pull(controller) {\n return reader.read().then(\n ({ done, value }) => {\n if (done) {\n controller.close();\n } else {\n controller.enqueue(value);\n }\n },\n (error) => {\n once();\n controller.error(error);\n },\n );\n },\n cancel(reason) {\n // Stream cancelled before fully consumed (e.g. client disconnected).\n // Still clear per-request context to avoid leaks.\n once();\n return reader.cancel(reason);\n },\n });\n}\n\nexport async function renderAppPageHtmlResponse(\n options: RenderAppPageHtmlResponseOptions,\n): Promise<Response> {\n const htmlStream = await renderAppPageHtmlStream(options);\n\n // Defer clearRequestContext() until the stream is fully consumed by the HTTP\n // layer. Calling it synchronously here would race the lazy RSC/SSR pipeline:\n // components execute while the stream is being pulled, not when the handle\n // is first returned. See: https://github.com/cloudflare/vinext/issues/660\n const safeStream = deferUntilStreamConsumed(htmlStream, () => {\n options.clearRequestContext();\n });\n\n const headers = new Headers({\n \"Content-Type\": \"text/html; charset=utf-8\",\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n\n if (options.fontLinkHeader) {\n headers.set(\"Link\", options.fontLinkHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n\n return new Response(safeStream, {\n status: options.status,\n headers,\n });\n}\n\nexport async function renderAppPageHtmlStreamWithRecovery<TSpecialError>(\n options: RenderAppPageHtmlStreamWithRecoveryOptions<TSpecialError>,\n): Promise<AppPageHtmlStreamRecoveryResult> {\n try {\n const htmlStream = await options.renderHtmlStream();\n options.onShellRendered?.();\n return {\n htmlStream,\n response: null,\n };\n } catch (error) {\n const specialError = options.resolveSpecialError(error);\n if (specialError) {\n return {\n htmlStream: null,\n response: await options.renderSpecialErrorResponse(specialError),\n };\n }\n\n const boundaryResponse = await options.renderErrorBoundaryResponse(error);\n if (boundaryResponse) {\n return {\n htmlStream: null,\n response: boundaryResponse,\n };\n }\n\n throw error;\n }\n}\n\nexport function createAppPageRscErrorTracker(\n baseOnError: (error: unknown, requestInfo: unknown, errorContext: unknown) => unknown,\n): AppPageRscErrorTracker {\n let capturedError: unknown = null;\n let capturedSpecialError: unknown = null;\n\n return {\n getCapturedError() {\n return capturedError;\n },\n getCapturedSpecialError() {\n return capturedSpecialError;\n },\n onRenderError(error, requestInfo, errorContext) {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n // Errors with a digest are signal throws (NEXT_REDIRECT,\n // NEXT_NOT_FOUND, NEXT_HTTP_ERROR_FALLBACK). They're not real\n // failures — keep the first one so the lifecycle can swap a\n // 307/404 in place of a streamed \"Switched to client rendering\"\n // body for routes with a route-level Suspense boundary.\n if (capturedSpecialError === null) {\n capturedSpecialError = error;\n }\n } else {\n capturedError = error;\n }\n return baseOnError(error, requestInfo, errorContext);\n },\n };\n}\n\nexport function shouldRerenderAppPageWithGlobalError(\n options: ShouldRerenderAppPageWithGlobalErrorOptions,\n): boolean {\n return Boolean(options.capturedError) && !options.hasLocalBoundary;\n}\n"],"mappings":";;;AA+EA,SAAgB,sBAAsB,SAAwD;AAC5F,QAAO;EACL,OAAO,QAAQ,UAAU;EACzB,UAAU,QAAQ,aAAa;EAC/B,QAAQ,QAAQ,WAAW;EAC5B;;AAGH,eAAsB,wBACpB,SACqC;CACrC,MAAM,aAAa;EACjB,aAAa,QAAQ;EACrB,YAAY,QAAQ;EACpB,oBAAoB,QAAQ;EAC7B;AAED,QAAO,QAAQ,WAAW,UACxB,QAAQ,WACR,QAAQ,mBACR,QAAQ,UACR,WACD;;;;;;;;;AAUH,SAAgB,yBACd,QACA,SAC4B;CAC5B,IAAI,SAAS;CACb,MAAM,aAAa;AACjB,MAAI,CAAC,QAAQ;AACX,YAAS;AACT,YAAS;;;CAIb,MAAM,UAAU,IAAI,gBAAwC,EAC1D,QAAQ;AACN,QAAM;IAET,CAAC;CAMF,MAAM,SAJQ,OAAO,YAAY,QAAQ,CAIpB,WAAW;AAChC,QAAO,IAAI,eAA2B;EACpC,KAAK,YAAY;AACf,UAAO,OAAO,MAAM,CAAC,MAClB,EAAE,MAAM,YAAY;AACnB,QAAI,KACF,YAAW,OAAO;QAElB,YAAW,QAAQ,MAAM;OAG5B,UAAU;AACT,UAAM;AACN,eAAW,MAAM,MAAM;KAE1B;;EAEH,OAAO,QAAQ;AAGb,SAAM;AACN,UAAO,OAAO,OAAO,OAAO;;EAE/B,CAAC;;AAGJ,eAAsB,0BACpB,SACmB;CAOnB,MAAM,aAAa,yBANA,MAAM,wBAAwB,QAAQ,QAMK;AAC5D,UAAQ,qBAAqB;GAC7B;CAEF,MAAM,UAAU,IAAI,QAAQ;EAC1B,gBAAgB;EAChB,MAAM;EACP,CAAC;AAEF,KAAI,QAAQ,eACV,SAAQ,IAAI,QAAQ,QAAQ,eAAe;AAG7C,gCAA+B,SAAS,QAAQ,qBAAqB,KAAK;AAE1E,QAAO,IAAI,SAAS,YAAY;EAC9B,QAAQ,QAAQ;EAChB;EACD,CAAC;;AAGJ,eAAsB,oCACpB,SAC0C;AAC1C,KAAI;EACF,MAAM,aAAa,MAAM,QAAQ,kBAAkB;AACnD,UAAQ,mBAAmB;AAC3B,SAAO;GACL;GACA,UAAU;GACX;UACM,OAAO;EACd,MAAM,eAAe,QAAQ,oBAAoB,MAAM;AACvD,MAAI,aACF,QAAO;GACL,YAAY;GACZ,UAAU,MAAM,QAAQ,2BAA2B,aAAa;GACjE;EAGH,MAAM,mBAAmB,MAAM,QAAQ,4BAA4B,MAAM;AACzE,MAAI,iBACF,QAAO;GACL,YAAY;GACZ,UAAU;GACX;AAGH,QAAM;;;AAIV,SAAgB,6BACd,aACwB;CACxB,IAAI,gBAAyB;CAC7B,IAAI,uBAAgC;AAEpC,QAAO;EACL,mBAAmB;AACjB,UAAO;;EAET,0BAA0B;AACxB,UAAO;;EAET,cAAc,OAAO,aAAa,cAAc;AAC9C,OAAI,SAAS,OAAO,UAAU,YAAY,YAAY;QAMhD,yBAAyB,KAC3B,wBAAuB;SAGzB,iBAAgB;AAElB,UAAO,YAAY,OAAO,aAAa,aAAa;;EAEvD;;AAGH,SAAgB,qCACd,SACS;AACT,QAAO,QAAQ,QAAQ,cAAc,IAAI,CAAC,QAAQ"}
@@ -1,3 +1,4 @@
1
+ import { notFoundResponse } from "./http-error-responses.js";
1
2
  import { callAppPrerenderStaticParams } from "./app-prerender-static-params.js";
2
3
  //#region src/server/app-prerender-endpoints.ts
3
4
  const STATIC_PARAMS_ENDPOINT = "/__vinext/prerender/static-params";
@@ -12,7 +13,7 @@ async function handleAppPrerenderEndpoint(request, options) {
12
13
  return null;
13
14
  }
14
15
  async function handleStaticParamsEndpoint(request, options) {
15
- if (!isEnabled(options)) return new Response("Not Found", { status: 404 });
16
+ if (!isEnabled(options)) return notFoundResponse();
16
17
  const url = new URL(request.url);
17
18
  const pattern = url.searchParams.get("pattern");
18
19
  if (!pattern) return new Response("missing pattern", { status: 400 });
@@ -30,7 +31,7 @@ async function handleStaticParamsEndpoint(request, options) {
30
31
  }
31
32
  }
32
33
  async function handlePagesStaticPathsEndpoint(request, options) {
33
- if (!isEnabled(options)) return new Response("Not Found", { status: 404 });
34
+ if (!isEnabled(options)) return notFoundResponse();
34
35
  const url = new URL(request.url);
35
36
  const pattern = url.searchParams.get("pattern");
36
37
  if (!pattern) return new Response("missing pattern", { status: 400 });
@@ -1 +1 @@
1
- {"version":3,"file":"app-prerender-endpoints.js","names":[],"sources":["../../src/server/app-prerender-endpoints.ts"],"sourcesContent":["import { callAppPrerenderStaticParams } from \"./app-prerender-static-params.js\";\nimport type { RootParams } from \"vinext/shims/root-params\";\n\ntype GenerateStaticParams = (args: { params: RootParams }) => unknown;\n\ntype AppPrerenderStaticParamsMap = Record<string, GenerateStaticParams | null | undefined>;\ntype RootParamNamesMap = Record<string, readonly string[] | undefined>;\n\ntype AppPrerenderPageRoute = {\n pattern: string;\n module?: {\n getStaticPaths?: (opts: { locales: string[]; defaultLocale: string }) => unknown;\n };\n};\n\ntype HandleAppPrerenderEndpointOptions = {\n isPrerenderEnabled?: () => boolean;\n loadPagesRoutes?: () => Promise<unknown>;\n pathname: string;\n rootParamNamesByPattern?: RootParamNamesMap;\n staticParamsMap: AppPrerenderStaticParamsMap;\n};\n\nconst STATIC_PARAMS_ENDPOINT = \"/__vinext/prerender/static-params\";\nconst PAGES_STATIC_PATHS_ENDPOINT = \"/__vinext/prerender/pages-static-paths\";\nconst JSON_HEADERS = { \"content-type\": \"application/json\" };\n\nexport async function handleAppPrerenderEndpoint(\n request: Request,\n options: HandleAppPrerenderEndpointOptions,\n): Promise<Response | null> {\n if (options.pathname === STATIC_PARAMS_ENDPOINT) {\n return handleStaticParamsEndpoint(request, options);\n }\n\n if (options.pathname === PAGES_STATIC_PATHS_ENDPOINT) {\n if (!options.loadPagesRoutes) return null;\n return handlePagesStaticPathsEndpoint(request, options);\n }\n\n return null;\n}\n\nasync function handleStaticParamsEndpoint(\n request: Request,\n options: HandleAppPrerenderEndpointOptions,\n): Promise<Response> {\n if (!isEnabled(options)) {\n return new Response(\"Not Found\", { status: 404 });\n }\n\n const url = new URL(request.url);\n const pattern = url.searchParams.get(\"pattern\");\n if (!pattern) return new Response(\"missing pattern\", { status: 400 });\n\n const generateStaticParams = options.staticParamsMap[pattern];\n if (typeof generateStaticParams !== \"function\") {\n return jsonNullResponse();\n }\n\n try {\n const params = parseParentParams(url.searchParams.get(\"parentParams\"));\n const result = await callAppPrerenderStaticParams({\n fn: generateStaticParams,\n params,\n pattern,\n rootParamNamesByPattern: options.rootParamNamesByPattern ?? {},\n });\n return jsonResponse(result);\n } catch (error) {\n return jsonResponse({ error: String(error) }, 500);\n }\n}\n\nasync function handlePagesStaticPathsEndpoint(\n request: Request,\n options: HandleAppPrerenderEndpointOptions,\n): Promise<Response> {\n if (!isEnabled(options)) {\n return new Response(\"Not Found\", { status: 404 });\n }\n\n const url = new URL(request.url);\n const pattern = url.searchParams.get(\"pattern\");\n if (!pattern) return new Response(\"missing pattern\", { status: 400 });\n\n try {\n const pageRoutes = await options.loadPagesRoutes?.();\n const route = findPageRoute(pageRoutes, pattern);\n const getStaticPaths = route?.module?.getStaticPaths;\n if (typeof getStaticPaths !== \"function\") {\n return jsonNullResponse();\n }\n\n const locales = parseLocales(url.searchParams.get(\"locales\"));\n const defaultLocale = url.searchParams.get(\"defaultLocale\") ?? \"\";\n const result = await getStaticPaths({ locales, defaultLocale });\n return jsonResponse(result);\n } catch (error) {\n return jsonResponse({ error: String(error) }, 500);\n }\n}\n\nfunction isEnabled(options: HandleAppPrerenderEndpointOptions): boolean {\n return options.isPrerenderEnabled?.() ?? false;\n}\n\nfunction jsonResponse(body: unknown, status = 200): Response {\n return new Response(JSON.stringify(body), {\n headers: JSON_HEADERS,\n status,\n });\n}\n\nfunction jsonNullResponse(): Response {\n return new Response(\"null\", {\n headers: JSON_HEADERS,\n status: 200,\n });\n}\n\nfunction parseParentParams(raw: string | null): RootParams {\n if (!raw) return {};\n\n const value = JSON.parse(raw);\n if (!isPlainObject(value)) return {};\n\n const params: RootParams = {};\n for (const [key, paramValue] of Object.entries(value)) {\n if (typeof paramValue === \"string\" || paramValue === undefined || isStringArray(paramValue)) {\n params[key] = paramValue;\n }\n }\n return params;\n}\n\nfunction parseLocales(raw: string | null): string[] {\n if (!raw) return [];\n\n const value = JSON.parse(raw);\n if (!Array.isArray(value)) return [];\n\n return value.filter((locale) => typeof locale === \"string\");\n}\n\nfunction findPageRoute(value: unknown, pattern: string): AppPrerenderPageRoute | undefined {\n if (!Array.isArray(value)) return undefined;\n\n for (const route of value) {\n if (isPageRoute(route) && route.pattern === pattern) {\n return route;\n }\n }\n\n return undefined;\n}\n\nfunction isPageRoute(value: unknown): value is AppPrerenderPageRoute {\n if (!isPlainObject(value) || typeof value.pattern !== \"string\") return false;\n if (value.module === undefined) return true;\n if (!isPlainObject(value.module)) return false;\n\n return (\n value.module.getStaticPaths === undefined || typeof value.module.getStaticPaths === \"function\"\n );\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n"],"mappings":";;AAuBA,MAAM,yBAAyB;AAC/B,MAAM,8BAA8B;AACpC,MAAM,eAAe,EAAE,gBAAgB,oBAAoB;AAE3D,eAAsB,2BACpB,SACA,SAC0B;AAC1B,KAAI,QAAQ,aAAa,uBACvB,QAAO,2BAA2B,SAAS,QA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O;AACvC,KAAI,CAAC,cAAc,MAAM,OAAO,CAAE,QAAO;AAEzC,QACE,MAAM,OAAO,mBAAmB,KAAA,KAAa,OAAO,MAAM,OAAO,mBAAmB;;AAIxF,SAAS,cAAc,OAAkD;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAS,cAAc,OAAmC;AACxD,QAAO,MAAM,QAAQ,MAAM,IAAI,MAAM,OAAO,SAAS,OAAO,SAAS,SAAS"}
1
+ {"version":3,"file":"app-prerender-endpoints.js","names":[],"sources":["../../src/server/app-prerender-endpoints.ts"],"sourcesContent":["import { callAppPrerenderStaticParams } from \"./app-prerender-static-params.js\";\nimport { notFoundResponse } from \"./http-error-responses.js\";\nimport type { RootParams } from \"vinext/shims/root-params\";\n\ntype GenerateStaticParams = (args: { params: RootParams }) => unknown;\n\ntype AppPrerenderStaticParamsMap = Record<string, GenerateStaticParams | null | undefined>;\ntype RootParamNamesMap = Record<string, readonly string[] | undefined>;\n\ntype AppPrerenderPageRoute = {\n pattern: string;\n module?: {\n getStaticPaths?: (opts: { locales: string[]; defaultLocale: string }) => unknown;\n };\n};\n\ntype HandleAppPrerenderEndpointOptions = {\n isPrerenderEnabled?: () => boolean;\n loadPagesRoutes?: () => Promise<unknown>;\n pathname: string;\n rootParamNamesByPattern?: RootParamNamesMap;\n staticParamsMap: AppPrerenderStaticParamsMap;\n};\n\nconst STATIC_PARAMS_ENDPOINT = \"/__vinext/prerender/static-params\";\nconst PAGES_STATIC_PATHS_ENDPOINT = \"/__vinext/prerender/pages-static-paths\";\nconst JSON_HEADERS = { \"content-type\": \"application/json\" };\n\nexport async function handleAppPrerenderEndpoint(\n request: Request,\n options: HandleAppPrerenderEndpointOptions,\n): Promise<Response | null> {\n if (options.pathname === STATIC_PARAMS_ENDPOINT) {\n return handleStaticParamsEndpoint(request, options);\n }\n\n if (options.pathname === PAGES_STATIC_PATHS_ENDPOINT) {\n if (!options.loadPagesRoutes) return null;\n return handlePagesStaticPathsEndpoint(request, options);\n }\n\n return null;\n}\n\nasync function handleStaticParamsEndpoint(\n request: Request,\n options: HandleAppPrerenderEndpointOptions,\n): Promise<Response> {\n if (!isEnabled(options)) {\n return notFoundResponse();\n }\n\n const url = new URL(request.url);\n const pattern = url.searchParams.get(\"pattern\");\n if (!pattern) return new Response(\"missing pattern\", { status: 400 });\n\n const generateStaticParams = options.staticParamsMap[pattern];\n if (typeof generateStaticParams !== \"function\") {\n return jsonNullResponse();\n }\n\n try {\n const params = parseParentParams(url.searchParams.get(\"parentParams\"));\n const result = await callAppPrerenderStaticParams({\n fn: generateStaticParams,\n params,\n pattern,\n rootParamNamesByPattern: options.rootParamNamesByPattern ?? {},\n });\n return jsonResponse(result);\n } catch (error) {\n return jsonResponse({ error: String(error) }, 500);\n }\n}\n\nasync function handlePagesStaticPathsEndpoint(\n request: Request,\n options: HandleAppPrerenderEndpointOptions,\n): Promise<Response> {\n if (!isEnabled(options)) {\n return notFoundResponse();\n }\n\n const url = new URL(request.url);\n const pattern = url.searchParams.get(\"pattern\");\n if (!pattern) return new Response(\"missing pattern\", { status: 400 });\n\n try {\n const pageRoutes = await options.loadPagesRoutes?.();\n const route = findPageRoute(pageRoutes, pattern);\n const getStaticPaths = route?.module?.getStaticPaths;\n if (typeof getStaticPaths !== \"function\") {\n return jsonNullResponse();\n }\n\n const locales = parseLocales(url.searchParams.get(\"locales\"));\n const defaultLocale = url.searchParams.get(\"defaultLocale\") ?? \"\";\n const result = await getStaticPaths({ locales, defaultLocale });\n return jsonResponse(result);\n } catch (error) {\n return jsonResponse({ error: String(error) }, 500);\n }\n}\n\nfunction isEnabled(options: HandleAppPrerenderEndpointOptions): boolean {\n return options.isPrerenderEnabled?.() ?? false;\n}\n\nfunction jsonResponse(body: unknown, status = 200): Response {\n return new Response(JSON.stringify(body), {\n headers: JSON_HEADERS,\n status,\n });\n}\n\nfunction jsonNullResponse(): Response {\n return new Response(\"null\", {\n headers: JSON_HEADERS,\n status: 200,\n });\n}\n\nfunction parseParentParams(raw: string | null): RootParams {\n if (!raw) return {};\n\n const value = JSON.parse(raw);\n if (!isPlainObject(value)) return {};\n\n const params: RootParams = {};\n for (const [key, paramValue] of Object.entries(value)) {\n if (typeof paramValue === \"string\" || paramValue === undefined || isStringArray(paramValue)) {\n params[key] = paramValue;\n }\n }\n return params;\n}\n\nfunction parseLocales(raw: string | null): string[] {\n if (!raw) return [];\n\n const value = JSON.parse(raw);\n if (!Array.isArray(value)) return [];\n\n return value.filter((locale) => typeof locale === \"string\");\n}\n\nfunction findPageRoute(value: unknown, pattern: string): AppPrerenderPageRoute | undefined {\n if (!Array.isArray(value)) return undefined;\n\n for (const route of value) {\n if (isPageRoute(route) && route.pattern === pattern) {\n return route;\n }\n }\n\n return undefined;\n}\n\nfunction isPageRoute(value: unknown): value is AppPrerenderPageRoute {\n if (!isPlainObject(value) || typeof value.pattern !== \"string\") return false;\n if (value.module === undefined) return true;\n if (!isPlainObject(value.module)) return false;\n\n return (\n value.module.getStaticPaths === undefined || typeof value.module.getStaticPaths === \"function\"\n );\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n"],"mappings":";;;AAwBA,MAAM,yBAAyB;AAC/B,MAAM,8BAA8B;AACpC,MAAM,eAAe,EAAE,gBAAgB,oBAAoB;AAE3D,eAAsB,2BACpB,SACA,SAC0B;AAC1B,KAAI,QAAQ,aAAa,uBACvB,QAAO,2BAA2B,SAAS,QAAQ;AAGrD,KAAI,QAAQ,aAAa,6BAA6B;AACpD,MAAI,CAAC,QAAQ,gBAAiB,QAAO;AACrC,SAAO,+BAA+B,SAAS,QAAQ;;AAGzD,QAAO;;AAGT,eAAe,2BACb,SACA,SACmB;AACnB,KAAI,CAAC,UAAU,QAAQ,CACrB,QAAO,kBAAkB;CAG3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AAM,OAAO,SAAS,OAAO,SAAS,SAAS"}
@@ -1,3 +1,4 @@
1
+ import { makeThenableParams } from "../shims/thenable-params.js";
1
2
  import { markKnownDynamicAppRoute } from "./app-route-handler-runtime.js";
2
3
  import { applyRouteHandlerMiddlewareContext, assertSupportedAppRouteHandlerResponse, buildAppRouteCacheValue, buildRouteHandlerCachedResponse } from "./app-route-handler-response.js";
3
4
  import { runAppRouteHandler } from "./app-route-handler-execution.js";
@@ -38,7 +39,7 @@ async function readAppRouteHandlerCacheResponse(options) {
38
39
  handlerFn: options.handlerFn,
39
40
  i18n: options.i18n,
40
41
  markDynamicUsage: options.markDynamicUsage,
41
- params: options.params,
42
+ params: makeThenableParams(options.params),
42
43
  request: new Request(options.requestUrl, { method: "GET" }),
43
44
  routePattern: options.routePattern,
44
45
  setHeadersAccessPhase: options.setHeadersAccessPhase
@@ -1 +1 @@
1
- {"version":3,"file":"app-route-handler-cache.js","names":[],"sources":["../../src/server/app-route-handler-cache.ts"],"sourcesContent":["import type { NextI18nConfig } from \"../config/next-config.js\";\nimport type { HeadersAccessPhase } from \"vinext/shims/headers\";\nimport type { ISRCacheEntry } from \"./isr-cache.js\";\nimport type { RouteHandlerMiddlewareContext } from \"./app-route-handler-response.js\";\nimport {\n applyRouteHandlerMiddlewareContext,\n assertSupportedAppRouteHandlerResponse,\n buildAppRouteCacheValue,\n buildRouteHandlerCachedResponse,\n} from \"./app-route-handler-response.js\";\nimport { markKnownDynamicAppRoute } from \"./app-route-handler-runtime.js\";\nimport {\n runAppRouteHandler,\n type AppRouteDebugLogger,\n type AppRouteDynamicUsageFn,\n type AppRouteHandlerFunction,\n type AppRouteParams,\n type MarkAppRouteDynamicUsageFn,\n type RouteHandlerCacheSetter,\n} from \"./app-route-handler-execution.js\";\n\ntype RouteHandlerCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype RouteHandlerBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;\ntype RouteHandlerRevalidationContextRunner = (renderFn: () => Promise<void>) => Promise<void>;\n\ntype ReadAppRouteHandlerCacheOptions = {\n basePath?: string;\n buildPageCacheTags: (pathname: string, extraTags: string[]) => string[];\n cleanPathname: string;\n clearRequestContext: () => void;\n consumeDynamicUsage: AppRouteDynamicUsageFn;\n dynamicConfig?: string;\n getCollectedFetchTags: () => string[];\n handlerFn: AppRouteHandlerFunction;\n i18n?: NextI18nConfig | null;\n isAutoHead: boolean;\n isrDebug?: AppRouteDebugLogger;\n isrGet: RouteHandlerCacheGetter;\n isrRouteKey: (pathname: string) => string;\n isrSet: RouteHandlerCacheSetter;\n markDynamicUsage: MarkAppRouteDynamicUsageFn;\n middlewareContext: RouteHandlerMiddlewareContext;\n params: AppRouteParams;\n requestUrl: string;\n revalidateSearchParams: URLSearchParams;\n expireSeconds?: number;\n revalidateSeconds: number;\n routePattern: string;\n runInRevalidationContext: RouteHandlerRevalidationContextRunner;\n scheduleBackgroundRegeneration: RouteHandlerBackgroundRegenerator;\n setHeadersAccessPhase: (phase: HeadersAccessPhase) => HeadersAccessPhase;\n setNavigationContext: (\n context: {\n pathname: string;\n searchParams: URLSearchParams;\n params: AppRouteParams;\n } | null,\n ) => void;\n};\n\nfunction getCachedAppRouteValue(entry: ISRCacheEntry | null) {\n return entry?.value.value && entry.value.value.kind === \"APP_ROUTE\" ? entry.value.value : null;\n}\n\nexport async function readAppRouteHandlerCacheResponse(\n options: ReadAppRouteHandlerCacheOptions,\n): Promise<Response | null> {\n const routeKey = options.isrRouteKey(options.cleanPathname);\n\n try {\n const cached = await options.isrGet(routeKey);\n const cachedValue = getCachedAppRouteValue(cached);\n\n if (cachedValue && !cached?.isStale) {\n options.isrDebug?.(\"HIT (route)\", options.cleanPathname);\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n buildRouteHandlerCachedResponse(cachedValue, {\n cacheState: \"HIT\",\n cacheControl: cached?.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isHead: options.isAutoHead,\n revalidateSeconds: options.revalidateSeconds,\n }),\n options.middlewareContext,\n );\n }\n\n if (cached?.isStale && cachedValue) {\n const staleValue = cachedValue;\n const revalidateSearchParams = new URLSearchParams(options.revalidateSearchParams);\n\n options.scheduleBackgroundRegeneration(routeKey, async () => {\n await options.runInRevalidationContext(async () => {\n options.setNavigationContext({\n pathname: options.cleanPathname,\n searchParams: revalidateSearchParams,\n params: options.params,\n });\n\n const { dynamicUsedInHandler, response } = await runAppRouteHandler({\n basePath: options.basePath,\n consumeDynamicUsage: options.consumeDynamicUsage,\n dynamicConfig: options.dynamicConfig,\n handlerFn: options.handlerFn,\n i18n: options.i18n,\n markDynamicUsage: options.markDynamicUsage,\n params: options.params,\n request: new Request(options.requestUrl, { method: \"GET\" }),\n routePattern: options.routePattern,\n setHeadersAccessPhase: options.setHeadersAccessPhase,\n });\n\n options.setNavigationContext(null);\n assertSupportedAppRouteHandlerResponse(response);\n\n if (dynamicUsedInHandler) {\n markKnownDynamicAppRoute(options.routePattern);\n options.isrDebug?.(\"route regen skipped (dynamic usage)\", options.cleanPathname);\n return;\n }\n\n const routeTags = options.buildPageCacheTags(\n options.cleanPathname,\n options.getCollectedFetchTags(),\n );\n const routeCacheValue = await buildAppRouteCacheValue(response);\n await options.isrSet(\n routeKey,\n routeCacheValue,\n options.revalidateSeconds,\n routeTags,\n options.expireSeconds,\n );\n options.isrDebug?.(\"route regen complete\", routeKey);\n });\n });\n\n options.isrDebug?.(\"STALE (route)\", options.cleanPathname);\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n buildRouteHandlerCachedResponse(staleValue, {\n cacheState: \"STALE\",\n cacheControl: cached.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isHead: options.isAutoHead,\n revalidateSeconds: options.revalidateSeconds,\n }),\n options.middlewareContext,\n );\n }\n } catch (routeCacheError) {\n console.error(\"[vinext] ISR route cache read error:\", routeCacheError);\n }\n\n return null;\n}\n"],"mappings":";;;;AA4DA,SAAS,uBAAuB,OAA6B;AAC3D,QAAO,OAA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,QAAQ,eACR,QAAQ,uBAAuB,CAChC;KACD,MAAM,kBAAkB,MAAM,wBAAwB,SAAS;AAC/D,WAAM,QAAQ,OACZ,UACA,iBACA,QAAQ,mBACR,WACA,QAAQ,cACT;AACD,aAAQ,WAAW,wBAAwB,SAAS;MACpD;KACF;AAEF,WAAQ,WAAW,iBAAiB,QAAQ,cAAc;AAC1D,WAAQ,qBAAqB;AAC7B,UAAO,mCACL,gCAAgC,YAAY;IAC1C,YAAY;IACZ,cAAc,OAAO,MAAM;IAC3B,eAAe,QAAQ;IACvB,QAAQ,QAAQ;IAChB,mBAAmB,QAAQ;IAC5B,CAAC,EACF,QAAQ,kBACT;;UAEI,iBAAiB;AACxB,UAAQ,MAAM,wCAAwC,gBAAgB;;AAGxE,QAAO"}
1
+ {"version":3,"file":"app-route-handler-cache.js","names":[],"sources":["../../src/server/app-route-handler-cache.ts"],"sourcesContent":["import type { NextI18nConfig } from \"../config/next-config.js\";\nimport type { HeadersAccessPhase } from \"vinext/shims/headers\";\nimport type { ISRCacheEntry } from \"./isr-cache.js\";\nimport type { RouteHandlerMiddlewareContext } from \"./app-route-handler-response.js\";\nimport {\n applyRouteHandlerMiddlewareContext,\n assertSupportedAppRouteHandlerResponse,\n buildAppRouteCacheValue,\n buildRouteHandlerCachedResponse,\n} from \"./app-route-handler-response.js\";\nimport { markKnownDynamicAppRoute } from \"./app-route-handler-runtime.js\";\nimport { makeThenableParams } from \"vinext/shims/thenable-params\";\nimport {\n runAppRouteHandler,\n type AppRouteDebugLogger,\n type AppRouteDynamicUsageFn,\n type AppRouteHandlerFunction,\n type AppRouteParams,\n type MarkAppRouteDynamicUsageFn,\n type RouteHandlerCacheSetter,\n} from \"./app-route-handler-execution.js\";\n\ntype RouteHandlerCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype RouteHandlerBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;\ntype RouteHandlerRevalidationContextRunner = (renderFn: () => Promise<void>) => Promise<void>;\n\ntype ReadAppRouteHandlerCacheOptions = {\n basePath?: string;\n buildPageCacheTags: (pathname: string, extraTags: string[]) => string[];\n cleanPathname: string;\n clearRequestContext: () => void;\n consumeDynamicUsage: AppRouteDynamicUsageFn;\n dynamicConfig?: string;\n getCollectedFetchTags: () => string[];\n handlerFn: AppRouteHandlerFunction;\n i18n?: NextI18nConfig | null;\n isAutoHead: boolean;\n isrDebug?: AppRouteDebugLogger;\n isrGet: RouteHandlerCacheGetter;\n isrRouteKey: (pathname: string) => string;\n isrSet: RouteHandlerCacheSetter;\n markDynamicUsage: MarkAppRouteDynamicUsageFn;\n middlewareContext: RouteHandlerMiddlewareContext;\n params: AppRouteParams;\n requestUrl: string;\n revalidateSearchParams: URLSearchParams;\n expireSeconds?: number;\n revalidateSeconds: number;\n routePattern: string;\n runInRevalidationContext: RouteHandlerRevalidationContextRunner;\n scheduleBackgroundRegeneration: RouteHandlerBackgroundRegenerator;\n setHeadersAccessPhase: (phase: HeadersAccessPhase) => HeadersAccessPhase;\n setNavigationContext: (\n context: {\n pathname: string;\n searchParams: URLSearchParams;\n params: AppRouteParams;\n } | null,\n ) => void;\n};\n\nfunction getCachedAppRouteValue(entry: ISRCacheEntry | null) {\n return entry?.value.value && entry.value.value.kind === \"APP_ROUTE\" ? entry.value.value : null;\n}\n\nexport async function readAppRouteHandlerCacheResponse(\n options: ReadAppRouteHandlerCacheOptions,\n): Promise<Response | null> {\n const routeKey = options.isrRouteKey(options.cleanPathname);\n\n try {\n const cached = await options.isrGet(routeKey);\n const cachedValue = getCachedAppRouteValue(cached);\n\n if (cachedValue && !cached?.isStale) {\n options.isrDebug?.(\"HIT (route)\", options.cleanPathname);\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n buildRouteHandlerCachedResponse(cachedValue, {\n cacheState: \"HIT\",\n cacheControl: cached?.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isHead: options.isAutoHead,\n revalidateSeconds: options.revalidateSeconds,\n }),\n options.middlewareContext,\n );\n }\n\n if (cached?.isStale && cachedValue) {\n const staleValue = cachedValue;\n const revalidateSearchParams = new URLSearchParams(options.revalidateSearchParams);\n\n options.scheduleBackgroundRegeneration(routeKey, async () => {\n await options.runInRevalidationContext(async () => {\n options.setNavigationContext({\n pathname: options.cleanPathname,\n searchParams: revalidateSearchParams,\n params: options.params,\n });\n\n const { dynamicUsedInHandler, response } = await runAppRouteHandler({\n basePath: options.basePath,\n consumeDynamicUsage: options.consumeDynamicUsage,\n dynamicConfig: options.dynamicConfig,\n handlerFn: options.handlerFn,\n i18n: options.i18n,\n markDynamicUsage: options.markDynamicUsage,\n params: makeThenableParams(options.params),\n request: new Request(options.requestUrl, { method: \"GET\" }),\n routePattern: options.routePattern,\n setHeadersAccessPhase: options.setHeadersAccessPhase,\n });\n\n options.setNavigationContext(null);\n assertSupportedAppRouteHandlerResponse(response);\n\n if (dynamicUsedInHandler) {\n markKnownDynamicAppRoute(options.routePattern);\n options.isrDebug?.(\"route regen skipped (dynamic usage)\", options.cleanPathname);\n return;\n }\n\n const routeTags = options.buildPageCacheTags(\n options.cleanPathname,\n options.getCollectedFetchTags(),\n );\n const routeCacheValue = await buildAppRouteCacheValue(response);\n await options.isrSet(\n routeKey,\n routeCacheValue,\n options.revalidateSeconds,\n routeTags,\n options.expireSeconds,\n );\n options.isrDebug?.(\"route regen complete\", routeKey);\n });\n });\n\n options.isrDebug?.(\"STALE (route)\", options.cleanPathname);\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n buildRouteHandlerCachedResponse(staleValue, {\n cacheState: \"STALE\",\n cacheControl: cached.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isHead: options.isAutoHead,\n revalidateSeconds: options.revalidateSeconds,\n }),\n options.middlewareContext,\n );\n }\n } catch (routeCacheError) {\n console.error(\"[vinext] ISR route cache read error:\", routeCacheError);\n }\n\n return null;\n}\n"],"mappings":";;;;;AA6DA,SAAS,uBAAuB,OAA6B;AAC3D,QAAO,OAAO,MAAM,SAAS,MA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QAAQ,eACR,QAAQ,uBAAuB,CAChC;KACD,MAAM,kBAAkB,MAAM,wBAAwB,SAAS;AAC/D,WAAM,QAAQ,OACZ,UACA,iBACA,QAAQ,mBACR,WACA,QAAQ,cACT;AACD,aAAQ,WAAW,wBAAwB,SAAS;MACpD;KACF;AAEF,WAAQ,WAAW,iBAAiB,QAAQ,cAAc;AAC1D,WAAQ,qBAAqB;AAC7B,UAAO,mCACL,gCAAgC,YAAY;IAC1C,YAAY;IACZ,cAAc,OAAO,MAAM;IAC3B,eAAe,QAAQ;IACvB,QAAQ,QAAQ;IAChB,mBAAmB,QAAQ;IAC5B,CAAC,EACF,QAAQ,kBACT;;UAEI,iBAAiB;AACxB,UAAQ,MAAM,wCAAwC,gBAAgB;;AAGxE,QAAO"}
@@ -4,7 +4,8 @@ import { reportRequestError } from "./instrumentation.js";
4
4
  import { consumeDynamicUsage, getAndClearPendingCookies, getDraftModeCookieHeader, markDynamicUsage, setHeadersAccessPhase } from "../shims/headers.js";
5
5
  import { ensureFetchPatch, getCollectedFetchTags, setCurrentFetchSoftTags } from "../shims/fetch-cache.js";
6
6
  import { setNavigationContext } from "../shims/navigation.js";
7
- import { isKnownDynamicAppRoute } from "./app-route-handler-runtime.js";
7
+ import { makeThenableParams } from "../shims/thenable-params.js";
8
+ import { isKnownDynamicAppRoute, isValidHTTPMethod } from "./app-route-handler-runtime.js";
8
9
  import { getAppRouteHandlerRevalidateSeconds, hasAppRouteHandlerDefaultExport, resolveAppRouteHandlerMethod, shouldReadAppRouteHandlerCache } from "./app-route-handler-policy.js";
9
10
  import { createStaticGenerationHeadersContext } from "./app-static-generation.js";
10
11
  import { buildPageCacheTags } from "./implicit-tags.js";
@@ -15,10 +16,6 @@ import { readAppRouteHandlerCacheResponse } from "./app-route-handler-cache.js";
15
16
  function isAppRouteHandlerFunction(value) {
16
17
  return typeof value === "function";
17
18
  }
18
- function makeThenableParams(params) {
19
- const plain = { ...params };
20
- return Object.assign(Promise.resolve(plain), plain);
21
- }
22
19
  function buildRouteHandlerPageCacheTags(pathname, extraTags, routeSegments) {
23
20
  return buildPageCacheTags(pathname, extraTags, routeSegments, "route");
24
21
  }
@@ -45,6 +42,10 @@ async function dispatchAppRouteHandler(options) {
45
42
  const isDevelopment = options.isDevelopment ?? process.env.NODE_ENV === "development";
46
43
  const isProduction = options.isProduction ?? process.env.NODE_ENV === "production";
47
44
  if (hasAppRouteHandlerDefaultExport(handler) && isDevelopment) console.error("[vinext] Detected default export in route handler " + route.pattern + ". Export a named export for each HTTP method instead.");
45
+ if (!isValidHTTPMethod(method)) {
46
+ options.clearRequestContext();
47
+ return applyRouteHandlerMiddlewareContext(new Response(null, { status: 400 }), options.middlewareContext);
48
+ }
48
49
  const { allowHeaderForOptions, handlerFn, isAutoHead, shouldAutoRespondToOptions } = resolveAppRouteHandlerMethod(handler, method);
49
50
  if (shouldAutoRespondToOptions) {
50
51
  options.clearRequestContext();
@@ -1 +1 @@
1
- {"version":3,"file":"app-route-handler-dispatch.js","names":[],"sources":["../../src/server/app-route-handler-dispatch.ts"],"sourcesContent":["import type { NextI18nConfig } from \"../config/next-config.js\";\nimport {\n getCollectedFetchTags,\n ensureFetchPatch,\n setCurrentFetchSoftTags,\n} from \"vinext/shims/fetch-cache\";\nimport {\n consumeDynamicUsage,\n getAndClearPendingCookies,\n getDraftModeCookieHeader,\n markDynamicUsage,\n setHeadersAccessPhase,\n} from \"vinext/shims/headers\";\nimport { setNavigationContext } from \"vinext/shims/navigation\";\nimport { getRequestExecutionContext } from \"vinext/shims/request-context\";\nimport { createRequestContext, runWithRequestContext } from \"vinext/shims/unified-request-context\";\nimport type { ISRCacheEntry } from \"./isr-cache.js\";\nimport {\n getAppRouteHandlerRevalidateSeconds,\n hasAppRouteHandlerDefaultExport,\n resolveAppRouteHandlerMethod,\n shouldReadAppRouteHandlerCache,\n type AppRouteHandlerModule,\n} from \"./app-route-handler-policy.js\";\nimport { readAppRouteHandlerCacheResponse } from \"./app-route-handler-cache.js\";\nimport {\n executeAppRouteHandler,\n type AppRouteDebugLogger,\n type AppRouteHandlerFunction,\n type AppRouteParams,\n type RouteHandlerCacheSetter,\n} from \"./app-route-handler-execution.js\";\nimport { isKnownDynamicAppRoute } from \"./app-route-handler-runtime.js\";\nimport {\n applyRouteHandlerMiddlewareContext,\n type RouteHandlerMiddlewareContext,\n} from \"./app-route-handler-response.js\";\nimport { createStaticGenerationHeadersContext } from \"./app-static-generation.js\";\nimport { buildPageCacheTags } from \"./implicit-tags.js\";\nimport { reportRequestError } from \"./instrumentation.js\";\n\ntype AppRouteHandlerDispatchRoute = {\n pattern: string;\n routeHandler: AppRouteHandlerModule;\n routeSegments: string[];\n};\n\ntype RouteHandlerCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype RouteHandlerBackgroundRegenerationErrorContext = {\n routerKind: \"App Router\";\n routePath: string;\n routeType: \"route\";\n};\ntype RouteHandlerBackgroundRegenerator = (\n key: string,\n renderFn: () => Promise<void>,\n errorContext?: RouteHandlerBackgroundRegenerationErrorContext,\n) => void;\n\ntype DispatchAppRouteHandlerOptions = {\n basePath?: string;\n cleanPathname: string;\n clearRequestContext: () => void;\n expireSeconds?: number;\n i18n?: NextI18nConfig | null;\n isDevelopment?: boolean;\n isProduction?: boolean;\n isrDebug?: AppRouteDebugLogger;\n isrGet: RouteHandlerCacheGetter;\n isrRouteKey: (pathname: string) => string;\n isrSet: RouteHandlerCacheSetter;\n middlewareContext: RouteHandlerMiddlewareContext;\n middlewareRequestHeaders?: Headers | null;\n params: AppRouteParams;\n request: Request;\n route: AppRouteHandlerDispatchRoute;\n scheduleBackgroundRegeneration: RouteHandlerBackgroundRegenerator;\n searchParams: URLSearchParams;\n};\n\nfunction isAppRouteHandlerFunction(value: unknown): value is AppRouteHandlerFunction {\n return typeof value === \"function\";\n}\n\nfunction makeThenableParams<T extends AppRouteParams>(params: T): Promise<T> & T {\n const plain = { ...params };\n return Object.assign(Promise.resolve(plain), plain);\n}\n\nfunction buildRouteHandlerPageCacheTags(\n pathname: string,\n extraTags: string[],\n routeSegments: string[],\n): string[] {\n return buildPageCacheTags(pathname, extraTags, routeSegments, \"route\");\n}\n\nasync function runInRouteHandlerRevalidationContext(\n options: {\n cleanPathname: string;\n dynamicConfig?: string;\n routePattern: string;\n routeSegments: string[];\n },\n renderFn: () => Promise<void>,\n): Promise<void> {\n const headersContext = createStaticGenerationHeadersContext({\n dynamicConfig: options.dynamicConfig,\n routeKind: \"route\",\n routePattern: options.routePattern,\n });\n const requestContext = createRequestContext({\n headersContext,\n executionContext: getRequestExecutionContext(),\n unstableCacheRevalidation: \"foreground\",\n });\n\n await runWithRequestContext(requestContext, async () => {\n ensureFetchPatch();\n setCurrentFetchSoftTags(\n buildRouteHandlerPageCacheTags(options.cleanPathname, [], options.routeSegments),\n );\n await renderFn();\n });\n}\n\nexport async function dispatchAppRouteHandler(\n options: DispatchAppRouteHandlerOptions,\n): Promise<Response> {\n const { route } = options;\n const handler = route.routeHandler;\n const method = options.request.method.toUpperCase();\n const revalidateSeconds = getAppRouteHandlerRevalidateSeconds(handler);\n const isDevelopment = options.isDevelopment ?? process.env.NODE_ENV === \"development\";\n const isProduction = options.isProduction ?? process.env.NODE_ENV === \"production\";\n\n if (hasAppRouteHandlerDefaultExport(handler) && isDevelopment) {\n console.error(\n \"[vinext] Detected default export in route handler \" +\n route.pattern +\n \". Export a named export for each HTTP method instead.\",\n );\n }\n\n const { allowHeaderForOptions, handlerFn, isAutoHead, shouldAutoRespondToOptions } =\n resolveAppRouteHandlerMethod(handler, method);\n\n if (shouldAutoRespondToOptions) {\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n new Response(null, {\n status: 204,\n headers: { Allow: allowHeaderForOptions },\n }),\n options.middlewareContext,\n );\n }\n\n const resolvedHandlerFn = isAppRouteHandlerFunction(handlerFn) ? handlerFn : undefined;\n\n if (\n revalidateSeconds !== null &&\n shouldReadAppRouteHandlerCache({\n dynamicConfig: handler.dynamic,\n handlerFn: resolvedHandlerFn,\n isAutoHead,\n isKnownDynamic: isKnownDynamicAppRoute(route.pattern),\n isProduction,\n method,\n revalidateSeconds,\n }) &&\n resolvedHandlerFn\n ) {\n const cachedRouteResponse = await readAppRouteHandlerCacheResponse({\n basePath: options.basePath,\n buildPageCacheTags(pathname, extraTags) {\n return buildRouteHandlerPageCacheTags(pathname, extraTags, route.routeSegments);\n },\n cleanPathname: options.cleanPathname,\n clearRequestContext: options.clearRequestContext,\n consumeDynamicUsage,\n dynamicConfig: handler.dynamic,\n getCollectedFetchTags,\n handlerFn: resolvedHandlerFn,\n i18n: options.i18n,\n isAutoHead,\n isrDebug: options.isrDebug,\n isrGet: options.isrGet,\n isrRouteKey: options.isrRouteKey,\n isrSet: options.isrSet,\n markDynamicUsage,\n middlewareContext: options.middlewareContext,\n params: options.params,\n requestUrl: options.request.url,\n revalidateSearchParams: options.searchParams,\n expireSeconds: options.expireSeconds,\n revalidateSeconds,\n routePattern: route.pattern,\n runInRevalidationContext(renderFn) {\n return runInRouteHandlerRevalidationContext(\n {\n cleanPathname: options.cleanPathname,\n dynamicConfig: handler.dynamic,\n routePattern: route.pattern,\n routeSegments: route.routeSegments,\n },\n renderFn,\n );\n },\n scheduleBackgroundRegeneration(key, renderFn) {\n options.scheduleBackgroundRegeneration(key, renderFn, {\n routerKind: \"App Router\",\n routePath: route.pattern,\n routeType: \"route\",\n });\n },\n setHeadersAccessPhase,\n setNavigationContext,\n });\n if (cachedRouteResponse) {\n return cachedRouteResponse;\n }\n }\n\n if (resolvedHandlerFn) {\n return executeAppRouteHandler({\n basePath: options.basePath,\n buildPageCacheTags(pathname, extraTags) {\n return buildRouteHandlerPageCacheTags(pathname, extraTags, route.routeSegments);\n },\n cleanPathname: options.cleanPathname,\n clearRequestContext: options.clearRequestContext,\n consumeDynamicUsage,\n executionContext: getRequestExecutionContext(),\n getAndClearPendingCookies,\n getCollectedFetchTags,\n getDraftModeCookieHeader,\n handler,\n handlerFn: resolvedHandlerFn,\n i18n: options.i18n,\n isAutoHead,\n isProduction,\n isrDebug: options.isrDebug,\n isrRouteKey: options.isrRouteKey,\n isrSet: options.isrSet,\n markDynamicUsage,\n method,\n middlewareContext: options.middlewareContext,\n middlewareRequestHeaders: options.middlewareRequestHeaders,\n params: makeThenableParams(options.params),\n reportRequestError,\n request: options.request,\n expireSeconds: options.expireSeconds,\n revalidateSeconds,\n routePattern: route.pattern,\n setHeadersAccessPhase,\n });\n }\n\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n new Response(null, {\n status: 405,\n }),\n options.middlewareContext,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAgFA,SAAS,0BAA0B,OAAkD;AACnF,QAAO,OAAO,UAAU;;AAG1B,SAAS,mBAA6C,QAA2B;CAC/E,MAAM,QAAQ,EAAE,GAAG,QAAQ;AAC3B,QAAO,OAAO,OAAO,QAAQ,QAAQ,MAAM,EAAE,MAAM;;AAGrD,SAAS,+BACP,UACA,WACA,eACU;AACV,QAAO,mBAAmB,UAAU,WAAW,eAAe,QAAQ;;AAGxE,eAAe,qCACb,SAMA,UACe;AAYf,OAAM,sBANiB,qBAAqB;EAC1C,gBANqB,qCAAqC;GAC1D,eAAe,QAAQ;GACvB,WAAW;GACX,cAAc,QAAQ;GACvB,CAAC;EAGA,kBAAkB,4BAA4B;EAC9C,2BAA2B;EAC5B,CAAC,EAE0C,YAAY;AACtD,oBAAkB;AAClB,0BACE,+BAA+B,QAAQ,eAAe,EAAE,EAAE,QAAQ,cAAc,CACjF;AACD,QAAM,UAAU;GAChB;;AAGJ,eAAsB,wBACpB,SACmB;CACnB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,MAAM;CACtB,MAAM,SAAS,QAAQ,QAAQ,OAAO,aAAa;CACnD,MAAM,oBAAoB,oCAAoC,QAAQ;CACtE,MAAM,gBAAgB,QAAQ,iBAAiB,QAAQ,IAAI,aAAa;CACxE,MAAM,eAAe,QAAQ,gBAAgB,QAAQ,IAAI,aAAa;AAEtE,KAAI,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X,KAAI,kBACF,QAAO,uBAAuB;EAC5B,UAAU,QAAQ;EAClB,mBAAmB,UAAU,WAAW;AACtC,UAAO,+BAA+B,UAAU,WAAW,MAAM,cAAc;;EAEjF,eAAe,QAAQ;EACvB,qBAAqB,QAAQ;EAC7B;EACA,kBAAkB,4BAA4B;EAC9C;EACA;EACA;EACA;EACA,WAAW;EACX,MAAM,QAAQ;EACd;EACA;EACA,UAAU,QAAQ;EAClB,aAAa,QAAQ;EACrB,QAAQ,QAAQ;EAChB;EACA;EACA,mBAAmB,QAAQ;EAC3B,0BAA0B,QAAQ;EAClC,QAAQ,mBAAmB,QAAQ,OAAO;EAC1C;EACA,SAAS,QAAQ;EACjB,eAAe,QAAQ;EACvB;EACA,cAAc,MAAM;EACpB;EACD,CAAC;AAGJ,SAAQ,qBAAqB;AAC7B,QAAO,mCACL,IAAI,SAAS,MAAM,EACjB,QAAQ,KACT,CAAC,EACF,QAAQ,kBACT"}
1
+ {"version":3,"file":"app-route-handler-dispatch.js","names":[],"sources":["../../src/server/app-route-handler-dispatch.ts"],"sourcesContent":["import type { NextI18nConfig } from \"../config/next-config.js\";\nimport {\n getCollectedFetchTags,\n ensureFetchPatch,\n setCurrentFetchSoftTags,\n} from \"vinext/shims/fetch-cache\";\nimport {\n consumeDynamicUsage,\n getAndClearPendingCookies,\n getDraftModeCookieHeader,\n markDynamicUsage,\n setHeadersAccessPhase,\n} from \"vinext/shims/headers\";\nimport { setNavigationContext } from \"vinext/shims/navigation\";\nimport { getRequestExecutionContext } from \"vinext/shims/request-context\";\nimport { createRequestContext, runWithRequestContext } from \"vinext/shims/unified-request-context\";\nimport type { ISRCacheEntry } from \"./isr-cache.js\";\nimport {\n getAppRouteHandlerRevalidateSeconds,\n hasAppRouteHandlerDefaultExport,\n resolveAppRouteHandlerMethod,\n shouldReadAppRouteHandlerCache,\n type AppRouteHandlerModule,\n} from \"./app-route-handler-policy.js\";\nimport { readAppRouteHandlerCacheResponse } from \"./app-route-handler-cache.js\";\nimport {\n executeAppRouteHandler,\n type AppRouteDebugLogger,\n type AppRouteHandlerFunction,\n type AppRouteParams,\n type RouteHandlerCacheSetter,\n} from \"./app-route-handler-execution.js\";\nimport { isKnownDynamicAppRoute, isValidHTTPMethod } from \"./app-route-handler-runtime.js\";\nimport {\n applyRouteHandlerMiddlewareContext,\n type RouteHandlerMiddlewareContext,\n} from \"./app-route-handler-response.js\";\nimport { createStaticGenerationHeadersContext } from \"./app-static-generation.js\";\nimport { buildPageCacheTags } from \"./implicit-tags.js\";\nimport { makeThenableParams } from \"vinext/shims/thenable-params\";\nimport { reportRequestError } from \"./instrumentation.js\";\n\ntype AppRouteHandlerDispatchRoute = {\n pattern: string;\n routeHandler: AppRouteHandlerModule;\n routeSegments: string[];\n};\n\ntype RouteHandlerCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype RouteHandlerBackgroundRegenerationErrorContext = {\n routerKind: \"App Router\";\n routePath: string;\n routeType: \"route\";\n};\ntype RouteHandlerBackgroundRegenerator = (\n key: string,\n renderFn: () => Promise<void>,\n errorContext?: RouteHandlerBackgroundRegenerationErrorContext,\n) => void;\n\ntype DispatchAppRouteHandlerOptions = {\n basePath?: string;\n cleanPathname: string;\n clearRequestContext: () => void;\n expireSeconds?: number;\n i18n?: NextI18nConfig | null;\n isDevelopment?: boolean;\n isProduction?: boolean;\n isrDebug?: AppRouteDebugLogger;\n isrGet: RouteHandlerCacheGetter;\n isrRouteKey: (pathname: string) => string;\n isrSet: RouteHandlerCacheSetter;\n middlewareContext: RouteHandlerMiddlewareContext;\n middlewareRequestHeaders?: Headers | null;\n params: AppRouteParams;\n request: Request;\n route: AppRouteHandlerDispatchRoute;\n scheduleBackgroundRegeneration: RouteHandlerBackgroundRegenerator;\n searchParams: URLSearchParams;\n};\n\nfunction isAppRouteHandlerFunction(value: unknown): value is AppRouteHandlerFunction {\n return typeof value === \"function\";\n}\n\nfunction buildRouteHandlerPageCacheTags(\n pathname: string,\n extraTags: string[],\n routeSegments: string[],\n): string[] {\n return buildPageCacheTags(pathname, extraTags, routeSegments, \"route\");\n}\n\nasync function runInRouteHandlerRevalidationContext(\n options: {\n cleanPathname: string;\n dynamicConfig?: string;\n routePattern: string;\n routeSegments: string[];\n },\n renderFn: () => Promise<void>,\n): Promise<void> {\n const headersContext = createStaticGenerationHeadersContext({\n dynamicConfig: options.dynamicConfig,\n routeKind: \"route\",\n routePattern: options.routePattern,\n });\n const requestContext = createRequestContext({\n headersContext,\n executionContext: getRequestExecutionContext(),\n unstableCacheRevalidation: \"foreground\",\n });\n\n await runWithRequestContext(requestContext, async () => {\n ensureFetchPatch();\n setCurrentFetchSoftTags(\n buildRouteHandlerPageCacheTags(options.cleanPathname, [], options.routeSegments),\n );\n await renderFn();\n });\n}\n\nexport async function dispatchAppRouteHandler(\n options: DispatchAppRouteHandlerOptions,\n): Promise<Response> {\n const { route } = options;\n const handler = route.routeHandler;\n const method = options.request.method.toUpperCase();\n const revalidateSeconds = getAppRouteHandlerRevalidateSeconds(handler);\n const isDevelopment = options.isDevelopment ?? process.env.NODE_ENV === \"development\";\n const isProduction = options.isProduction ?? process.env.NODE_ENV === \"production\";\n\n if (hasAppRouteHandlerDefaultExport(handler) && isDevelopment) {\n console.error(\n \"[vinext] Detected default export in route handler \" +\n route.pattern +\n \". Export a named export for each HTTP method instead.\",\n );\n }\n\n // Reject non-standard HTTP methods before any auto-OPTIONS/405 logic.\n // Next.js returns 400 for invalid methods; vinext mirrors that behavior.\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/route-modules/app-route/module.ts#L390-L392\n if (!isValidHTTPMethod(method)) {\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n new Response(null, { status: 400 }),\n options.middlewareContext,\n );\n }\n\n const { allowHeaderForOptions, handlerFn, isAutoHead, shouldAutoRespondToOptions } =\n resolveAppRouteHandlerMethod(handler, method);\n\n if (shouldAutoRespondToOptions) {\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n new Response(null, {\n status: 204,\n headers: { Allow: allowHeaderForOptions },\n }),\n options.middlewareContext,\n );\n }\n\n const resolvedHandlerFn = isAppRouteHandlerFunction(handlerFn) ? handlerFn : undefined;\n\n if (\n revalidateSeconds !== null &&\n shouldReadAppRouteHandlerCache({\n dynamicConfig: handler.dynamic,\n handlerFn: resolvedHandlerFn,\n isAutoHead,\n isKnownDynamic: isKnownDynamicAppRoute(route.pattern),\n isProduction,\n method,\n revalidateSeconds,\n }) &&\n resolvedHandlerFn\n ) {\n const cachedRouteResponse = await readAppRouteHandlerCacheResponse({\n basePath: options.basePath,\n buildPageCacheTags(pathname, extraTags) {\n return buildRouteHandlerPageCacheTags(pathname, extraTags, route.routeSegments);\n },\n cleanPathname: options.cleanPathname,\n clearRequestContext: options.clearRequestContext,\n consumeDynamicUsage,\n dynamicConfig: handler.dynamic,\n getCollectedFetchTags,\n handlerFn: resolvedHandlerFn,\n i18n: options.i18n,\n isAutoHead,\n isrDebug: options.isrDebug,\n isrGet: options.isrGet,\n isrRouteKey: options.isrRouteKey,\n isrSet: options.isrSet,\n markDynamicUsage,\n middlewareContext: options.middlewareContext,\n params: options.params,\n requestUrl: options.request.url,\n revalidateSearchParams: options.searchParams,\n expireSeconds: options.expireSeconds,\n revalidateSeconds,\n routePattern: route.pattern,\n runInRevalidationContext(renderFn) {\n return runInRouteHandlerRevalidationContext(\n {\n cleanPathname: options.cleanPathname,\n dynamicConfig: handler.dynamic,\n routePattern: route.pattern,\n routeSegments: route.routeSegments,\n },\n renderFn,\n );\n },\n scheduleBackgroundRegeneration(key, renderFn) {\n options.scheduleBackgroundRegeneration(key, renderFn, {\n routerKind: \"App Router\",\n routePath: route.pattern,\n routeType: \"route\",\n });\n },\n setHeadersAccessPhase,\n setNavigationContext,\n });\n if (cachedRouteResponse) {\n return cachedRouteResponse;\n }\n }\n\n if (resolvedHandlerFn) {\n return executeAppRouteHandler({\n basePath: options.basePath,\n buildPageCacheTags(pathname, extraTags) {\n return buildRouteHandlerPageCacheTags(pathname, extraTags, route.routeSegments);\n },\n cleanPathname: options.cleanPathname,\n clearRequestContext: options.clearRequestContext,\n consumeDynamicUsage,\n executionContext: getRequestExecutionContext(),\n getAndClearPendingCookies,\n getCollectedFetchTags,\n getDraftModeCookieHeader,\n handler,\n handlerFn: resolvedHandlerFn,\n i18n: options.i18n,\n isAutoHead,\n isProduction,\n isrDebug: options.isrDebug,\n isrRouteKey: options.isrRouteKey,\n isrSet: options.isrSet,\n markDynamicUsage,\n method,\n middlewareContext: options.middlewareContext,\n middlewareRequestHeaders: options.middlewareRequestHeaders,\n params: makeThenableParams(options.params),\n reportRequestError,\n request: options.request,\n expireSeconds: options.expireSeconds,\n revalidateSeconds,\n routePattern: route.pattern,\n setHeadersAccessPhase,\n });\n }\n\n options.clearRequestContext();\n return applyRouteHandlerMiddlewareContext(\n new Response(null, {\n status: 405,\n }),\n options.middlewareContext,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiFA,SAAS,0BAA0B,OAAkD;AACnF,QAAO,OAAO,UAAU;;AAG1B,SAAS,+BACP,UACA,WACA,eACU;AACV,QAAO,mBAAmB,UAAU,WAAW,eAAe,QAAQ;;AAGxE,eAAe,qCACb,SAMA,UACe;AAYf,OAAM,sBANiB,qBAAqB;EAC1C,gBANqB,qCAAqC;GAC1D,eAAe,QAAQ;GACvB,WAAW;GACX,cAAc,QAAQ;GACvB,CAAC;EAGA,kBAAkB,4BAA4B;EAC9C,2BAA2B;EAC5B,CAAC,EAE0C,YAAY;AACtD,oBAAkB;AAClB,0BACE,+BAA+B,QAAQ,eAAe,EAAE,EAAE,QAAQ,cAAc,CACjF;AACD,QAAM,UAAU;GAChB;;AAGJ,eAAsB,wBACpB,SACmB;CACnB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,MAAM;CACtB,MAAM,SAAS,QAAQ,QAAQ,OAAO,aAAa;CACnD,MAAM,oBAAoB,oCAAoC,QAAQ;CACtE,MAAM,gBAAgB,QAAQ,iBAAiB,QAAQ,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