vinext 0.0.50 → 0.0.52

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 (462) hide show
  1. package/dist/build/google-fonts/fallback-metrics-data.js +14031 -0
  2. package/dist/build/google-fonts/fallback-metrics-data.js.map +1 -0
  3. package/dist/build/google-fonts/fallback-metrics.d.ts +13 -0
  4. package/dist/build/google-fonts/fallback-metrics.js +46 -0
  5. package/dist/build/google-fonts/fallback-metrics.js.map +1 -0
  6. package/dist/build/precompress.d.ts +13 -2
  7. package/dist/build/precompress.js +23 -13
  8. package/dist/build/precompress.js.map +1 -1
  9. package/dist/build/prerender.d.ts +4 -15
  10. package/dist/build/prerender.js +83 -53
  11. package/dist/build/prerender.js.map +1 -1
  12. package/dist/build/report.d.ts +5 -4
  13. package/dist/build/report.js +196 -348
  14. package/dist/build/report.js.map +1 -1
  15. package/dist/check.js +5 -0
  16. package/dist/check.js.map +1 -1
  17. package/dist/cli-args.d.ts +1 -0
  18. package/dist/cli-args.js +5 -0
  19. package/dist/cli-args.js.map +1 -1
  20. package/dist/cli.js +99 -3
  21. package/dist/cli.js.map +1 -1
  22. package/dist/client/navigation-runtime.d.ts +47 -0
  23. package/dist/client/navigation-runtime.js +156 -0
  24. package/dist/client/navigation-runtime.js.map +1 -0
  25. package/dist/client/pages-router-link-navigation.d.ts +26 -0
  26. package/dist/client/pages-router-link-navigation.js +14 -0
  27. package/dist/client/pages-router-link-navigation.js.map +1 -0
  28. package/dist/client/vinext-next-data.d.ts +12 -2
  29. package/dist/client/vinext-next-data.js +50 -1
  30. package/dist/client/vinext-next-data.js.map +1 -0
  31. package/dist/client/window-next.d.ts +3 -1
  32. package/dist/client/window-next.js.map +1 -1
  33. package/dist/cloudflare/kv-cache-handler.js +2 -1
  34. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  35. package/dist/config/config-matchers.d.ts +63 -16
  36. package/dist/config/config-matchers.js +143 -8
  37. package/dist/config/config-matchers.js.map +1 -1
  38. package/dist/config/dotenv.d.ts +11 -1
  39. package/dist/config/dotenv.js.map +1 -1
  40. package/dist/config/next-config.d.ts +107 -5
  41. package/dist/config/next-config.js +233 -7
  42. package/dist/config/next-config.js.map +1 -1
  43. package/dist/config/tsconfig-paths.d.ts +13 -0
  44. package/dist/config/tsconfig-paths.js +117 -0
  45. package/dist/config/tsconfig-paths.js.map +1 -0
  46. package/dist/deploy.js +104 -41
  47. package/dist/deploy.js.map +1 -1
  48. package/dist/entries/app-browser-entry.d.ts +2 -2
  49. package/dist/entries/app-browser-entry.js +34 -3
  50. package/dist/entries/app-browser-entry.js.map +1 -1
  51. package/dist/entries/app-rsc-entry.d.ts +19 -1
  52. package/dist/entries/app-rsc-entry.js +89 -23
  53. package/dist/entries/app-rsc-entry.js.map +1 -1
  54. package/dist/entries/app-rsc-manifest.d.ts +10 -0
  55. package/dist/entries/app-rsc-manifest.js +57 -7
  56. package/dist/entries/app-rsc-manifest.js.map +1 -1
  57. package/dist/entries/app-ssr-entry.d.ts +3 -3
  58. package/dist/entries/app-ssr-entry.js +4 -4
  59. package/dist/entries/app-ssr-entry.js.map +1 -1
  60. package/dist/entries/pages-client-entry.js +21 -7
  61. package/dist/entries/pages-client-entry.js.map +1 -1
  62. package/dist/entries/pages-server-entry.js +77 -9
  63. package/dist/entries/pages-server-entry.js.map +1 -1
  64. package/dist/entries/runtime-entry-module.d.ts +2 -1
  65. package/dist/entries/runtime-entry-module.js +9 -3
  66. package/dist/entries/runtime-entry-module.js.map +1 -1
  67. package/dist/index.js +260 -75
  68. package/dist/index.js.map +1 -1
  69. package/dist/plugins/client-reference-dedup.d.ts +15 -2
  70. package/dist/plugins/client-reference-dedup.js +138 -16
  71. package/dist/plugins/client-reference-dedup.js.map +1 -1
  72. package/dist/plugins/css-data-url.d.ts +7 -0
  73. package/dist/plugins/css-data-url.js +81 -0
  74. package/dist/plugins/css-data-url.js.map +1 -0
  75. package/dist/plugins/fonts.d.ts +2 -2
  76. package/dist/plugins/fonts.js +20 -9
  77. package/dist/plugins/fonts.js.map +1 -1
  78. package/dist/plugins/middleware-server-only.d.ts +54 -0
  79. package/dist/plugins/middleware-server-only.js +91 -0
  80. package/dist/plugins/middleware-server-only.js.map +1 -0
  81. package/dist/plugins/optimize-imports.js +4 -4
  82. package/dist/plugins/optimize-imports.js.map +1 -1
  83. package/dist/plugins/sass.d.ts +34 -0
  84. package/dist/plugins/sass.js +22 -0
  85. package/dist/plugins/sass.js.map +1 -0
  86. package/dist/plugins/strip-server-exports.js +5 -8
  87. package/dist/plugins/strip-server-exports.js.map +1 -1
  88. package/dist/routing/app-route-graph.d.ts +50 -2
  89. package/dist/routing/app-route-graph.js +140 -16
  90. package/dist/routing/app-route-graph.js.map +1 -1
  91. package/dist/routing/app-router.d.ts +2 -2
  92. package/dist/routing/app-router.js +2 -2
  93. package/dist/routing/app-router.js.map +1 -1
  94. package/dist/routing/route-pattern.d.ts +56 -1
  95. package/dist/routing/route-pattern.js +60 -1
  96. package/dist/routing/route-pattern.js.map +1 -1
  97. package/dist/routing/utils.d.ts +2 -1
  98. package/dist/routing/utils.js +4 -1
  99. package/dist/routing/utils.js.map +1 -1
  100. package/dist/server/api-handler.js +139 -37
  101. package/dist/server/api-handler.js.map +1 -1
  102. package/dist/server/app-browser-action-result.d.ts +27 -2
  103. package/dist/server/app-browser-action-result.js +63 -2
  104. package/dist/server/app-browser-action-result.js.map +1 -1
  105. package/dist/server/app-browser-entry.js +493 -195
  106. package/dist/server/app-browser-entry.js.map +1 -1
  107. package/dist/server/app-browser-hydration.d.ts +13 -1
  108. package/dist/server/app-browser-hydration.js +9 -1
  109. package/dist/server/app-browser-hydration.js.map +1 -1
  110. package/dist/server/app-browser-interception-context.d.ts +24 -0
  111. package/dist/server/app-browser-interception-context.js +32 -0
  112. package/dist/server/app-browser-interception-context.js.map +1 -0
  113. package/dist/server/app-browser-navigation-controller.d.ts +17 -2
  114. package/dist/server/app-browser-navigation-controller.js +33 -10
  115. package/dist/server/app-browser-navigation-controller.js.map +1 -1
  116. package/dist/server/app-browser-popstate.d.ts +16 -0
  117. package/dist/server/app-browser-popstate.js +17 -0
  118. package/dist/server/app-browser-popstate.js.map +1 -0
  119. package/dist/server/app-browser-rsc-redirect.d.ts +29 -0
  120. package/dist/server/app-browser-rsc-redirect.js +37 -0
  121. package/dist/server/app-browser-rsc-redirect.js.map +1 -0
  122. package/dist/server/app-browser-state.d.ts +28 -7
  123. package/dist/server/app-browser-state.js +63 -27
  124. package/dist/server/app-browser-state.js.map +1 -1
  125. package/dist/server/app-browser-stream.d.ts +9 -17
  126. package/dist/server/app-browser-stream.js +18 -13
  127. package/dist/server/app-browser-stream.js.map +1 -1
  128. package/dist/server/app-browser-visible-commit.d.ts +7 -1
  129. package/dist/server/app-browser-visible-commit.js +39 -5
  130. package/dist/server/app-browser-visible-commit.js.map +1 -1
  131. package/dist/server/app-elements-wire.d.ts +43 -6
  132. package/dist/server/app-elements-wire.js +189 -7
  133. package/dist/server/app-elements-wire.js.map +1 -1
  134. package/dist/server/app-elements.d.ts +3 -2
  135. package/dist/server/app-elements.js +3 -2
  136. package/dist/server/app-elements.js.map +1 -1
  137. package/dist/server/app-fallback-renderer.d.ts +10 -1
  138. package/dist/server/app-fallback-renderer.js +41 -3
  139. package/dist/server/app-fallback-renderer.js.map +1 -1
  140. package/dist/server/app-history-state.d.ts +26 -0
  141. package/dist/server/app-history-state.js +53 -0
  142. package/dist/server/app-history-state.js.map +1 -0
  143. package/dist/server/app-middleware.d.ts +13 -0
  144. package/dist/server/app-middleware.js +3 -1
  145. package/dist/server/app-middleware.js.map +1 -1
  146. package/dist/server/app-optimistic-routing.d.ts +54 -0
  147. package/dist/server/app-optimistic-routing.js +200 -0
  148. package/dist/server/app-optimistic-routing.js.map +1 -0
  149. package/dist/server/app-page-boundary-render.d.ts +10 -1
  150. package/dist/server/app-page-boundary-render.js +13 -6
  151. package/dist/server/app-page-boundary-render.js.map +1 -1
  152. package/dist/server/app-page-boundary.js +3 -2
  153. package/dist/server/app-page-boundary.js.map +1 -1
  154. package/dist/server/app-page-cache.d.ts +26 -1
  155. package/dist/server/app-page-cache.js +86 -14
  156. package/dist/server/app-page-cache.js.map +1 -1
  157. package/dist/server/app-page-dispatch.d.ts +7 -0
  158. package/dist/server/app-page-dispatch.js +96 -12
  159. package/dist/server/app-page-dispatch.js.map +1 -1
  160. package/dist/server/app-page-element-builder.d.ts +7 -0
  161. package/dist/server/app-page-element-builder.js +34 -5
  162. package/dist/server/app-page-element-builder.js.map +1 -1
  163. package/dist/server/app-page-execution.d.ts +28 -1
  164. package/dist/server/app-page-execution.js +91 -7
  165. package/dist/server/app-page-execution.js.map +1 -1
  166. package/dist/server/app-page-head.d.ts +7 -0
  167. package/dist/server/app-page-head.js +23 -3
  168. package/dist/server/app-page-head.js.map +1 -1
  169. package/dist/server/app-page-probe.d.ts +23 -1
  170. package/dist/server/app-page-probe.js +29 -1
  171. package/dist/server/app-page-probe.js.map +1 -1
  172. package/dist/server/app-page-render-observation.d.ts +35 -0
  173. package/dist/server/app-page-render-observation.js +68 -0
  174. package/dist/server/app-page-render-observation.js.map +1 -0
  175. package/dist/server/app-page-render.d.ts +7 -1
  176. package/dist/server/app-page-render.js +81 -4
  177. package/dist/server/app-page-render.js.map +1 -1
  178. package/dist/server/app-page-request.d.ts +1 -0
  179. package/dist/server/app-page-request.js.map +1 -1
  180. package/dist/server/app-page-response.js +7 -5
  181. package/dist/server/app-page-response.js.map +1 -1
  182. package/dist/server/app-page-route-wiring.d.ts +3 -1
  183. package/dist/server/app-page-route-wiring.js +59 -24
  184. package/dist/server/app-page-route-wiring.js.map +1 -1
  185. package/dist/server/app-page-stream.d.ts +5 -0
  186. package/dist/server/app-page-stream.js +2 -0
  187. package/dist/server/app-page-stream.js.map +1 -1
  188. package/dist/server/app-prerender-static-params.d.ts +2 -1
  189. package/dist/server/app-prerender-static-params.js +44 -8
  190. package/dist/server/app-prerender-static-params.js.map +1 -1
  191. package/dist/server/app-route-handler-cache.d.ts +2 -2
  192. package/dist/server/app-route-handler-cache.js +3 -2
  193. package/dist/server/app-route-handler-cache.js.map +1 -1
  194. package/dist/server/app-route-handler-dispatch.d.ts +6 -1
  195. package/dist/server/app-route-handler-dispatch.js +1 -1
  196. package/dist/server/app-route-handler-dispatch.js.map +1 -1
  197. package/dist/server/app-route-handler-execution.d.ts +17 -2
  198. package/dist/server/app-route-handler-execution.js.map +1 -1
  199. package/dist/server/app-route-handler-response.js +5 -4
  200. package/dist/server/app-route-handler-response.js.map +1 -1
  201. package/dist/server/app-router-entry.js +7 -15
  202. package/dist/server/app-router-entry.js.map +1 -1
  203. package/dist/server/app-rsc-cache-busting.d.ts +19 -1
  204. package/dist/server/app-rsc-cache-busting.js +36 -1
  205. package/dist/server/app-rsc-cache-busting.js.map +1 -1
  206. package/dist/server/app-rsc-embedded-chunks.d.ts +9 -0
  207. package/dist/server/app-rsc-embedded-chunks.js +34 -0
  208. package/dist/server/app-rsc-embedded-chunks.js.map +1 -0
  209. package/dist/server/app-rsc-errors.d.ts +4 -1
  210. package/dist/server/app-rsc-errors.js +1 -1
  211. package/dist/server/app-rsc-errors.js.map +1 -1
  212. package/dist/server/app-rsc-handler.d.ts +21 -5
  213. package/dist/server/app-rsc-handler.js +38 -15
  214. package/dist/server/app-rsc-handler.js.map +1 -1
  215. package/dist/server/app-rsc-render-mode.d.ts +4 -3
  216. package/dist/server/app-rsc-render-mode.js +7 -1
  217. package/dist/server/app-rsc-render-mode.js.map +1 -1
  218. package/dist/server/app-rsc-request-normalization.d.ts +4 -1
  219. package/dist/server/app-rsc-request-normalization.js +4 -1
  220. package/dist/server/app-rsc-request-normalization.js.map +1 -1
  221. package/dist/server/app-rsc-response-finalizer.d.ts +8 -1
  222. package/dist/server/app-rsc-response-finalizer.js +10 -3
  223. package/dist/server/app-rsc-response-finalizer.js.map +1 -1
  224. package/dist/server/app-rsc-route-matching.d.ts +23 -0
  225. package/dist/server/app-rsc-route-matching.js +47 -25
  226. package/dist/server/app-rsc-route-matching.js.map +1 -1
  227. package/dist/server/app-server-action-execution.d.ts +35 -3
  228. package/dist/server/app-server-action-execution.js +87 -33
  229. package/dist/server/app-server-action-execution.js.map +1 -1
  230. package/dist/server/app-ssr-entry.d.ts +3 -0
  231. package/dist/server/app-ssr-entry.js +83 -58
  232. package/dist/server/app-ssr-entry.js.map +1 -1
  233. package/dist/server/app-ssr-error-meta.d.ts +14 -0
  234. package/dist/server/app-ssr-error-meta.js +50 -0
  235. package/dist/server/app-ssr-error-meta.js.map +1 -0
  236. package/dist/server/app-ssr-stream.d.ts +7 -2
  237. package/dist/server/app-ssr-stream.js +26 -15
  238. package/dist/server/app-ssr-stream.js.map +1 -1
  239. package/dist/server/artifact-compatibility.d.ts +13 -3
  240. package/dist/server/artifact-compatibility.js +12 -8
  241. package/dist/server/artifact-compatibility.js.map +1 -1
  242. package/dist/server/cache-headers.d.ts +7 -0
  243. package/dist/server/cache-headers.js +19 -0
  244. package/dist/server/cache-headers.js.map +1 -0
  245. package/dist/server/cache-proof.d.ts +170 -5
  246. package/dist/server/cache-proof.js +472 -18
  247. package/dist/server/cache-proof.js.map +1 -1
  248. package/dist/server/client-reuse-manifest.d.ts +99 -0
  249. package/dist/server/client-reuse-manifest.js +212 -0
  250. package/dist/server/client-reuse-manifest.js.map +1 -0
  251. package/dist/server/default-global-error-module.d.ts +20 -0
  252. package/dist/server/default-global-error-module.js +20 -0
  253. package/dist/server/default-global-error-module.js.map +1 -0
  254. package/dist/server/dev-lockfile.d.ts +110 -0
  255. package/dist/server/dev-lockfile.js +180 -0
  256. package/dist/server/dev-lockfile.js.map +1 -0
  257. package/dist/server/dev-server.d.ts +9 -1
  258. package/dist/server/dev-server.js +76 -19
  259. package/dist/server/dev-server.js.map +1 -1
  260. package/dist/server/edge-api-runtime.d.ts +5 -0
  261. package/dist/server/edge-api-runtime.js +8 -0
  262. package/dist/server/edge-api-runtime.js.map +1 -0
  263. package/dist/server/file-based-metadata.d.ts +13 -0
  264. package/dist/server/file-based-metadata.js +49 -2
  265. package/dist/server/file-based-metadata.js.map +1 -1
  266. package/dist/server/headers.d.ts +20 -1
  267. package/dist/server/headers.js +22 -2
  268. package/dist/server/headers.js.map +1 -1
  269. package/dist/server/html.js +1 -1
  270. package/dist/server/html.js.map +1 -1
  271. package/dist/server/http-error-responses.d.ts +26 -1
  272. package/dist/server/http-error-responses.js +32 -2
  273. package/dist/server/http-error-responses.js.map +1 -1
  274. package/dist/server/isr-cache.d.ts +8 -3
  275. package/dist/server/isr-cache.js +24 -6
  276. package/dist/server/isr-cache.js.map +1 -1
  277. package/dist/server/metadata-route-response.js +22 -5
  278. package/dist/server/metadata-route-response.js.map +1 -1
  279. package/dist/server/metadata-routes.js +27 -8
  280. package/dist/server/metadata-routes.js.map +1 -1
  281. package/dist/server/middleware-runtime.d.ts +15 -0
  282. package/dist/server/middleware-runtime.js +60 -7
  283. package/dist/server/middleware-runtime.js.map +1 -1
  284. package/dist/server/middleware.d.ts +13 -1
  285. package/dist/server/middleware.js +16 -2
  286. package/dist/server/middleware.js.map +1 -1
  287. package/dist/server/navigation-planner.d.ts +26 -6
  288. package/dist/server/navigation-planner.js +358 -24
  289. package/dist/server/navigation-planner.js.map +1 -1
  290. package/dist/server/navigation-trace.d.ts +9 -1
  291. package/dist/server/navigation-trace.js +8 -0
  292. package/dist/server/navigation-trace.js.map +1 -1
  293. package/dist/server/normalize-path.d.ts +2 -1
  294. package/dist/server/normalize-path.js +4 -1
  295. package/dist/server/normalize-path.js.map +1 -1
  296. package/dist/server/pages-api-route.d.ts +27 -1
  297. package/dist/server/pages-api-route.js +25 -3
  298. package/dist/server/pages-api-route.js.map +1 -1
  299. package/dist/server/pages-data-route.d.ts +77 -0
  300. package/dist/server/pages-data-route.js +97 -0
  301. package/dist/server/pages-data-route.js.map +1 -0
  302. package/dist/server/pages-i18n.d.ts +51 -1
  303. package/dist/server/pages-i18n.js +61 -1
  304. package/dist/server/pages-i18n.js.map +1 -1
  305. package/dist/server/pages-page-data.d.ts +32 -4
  306. package/dist/server/pages-page-data.js +52 -19
  307. package/dist/server/pages-page-data.js.map +1 -1
  308. package/dist/server/pages-page-response.d.ts +11 -1
  309. package/dist/server/pages-page-response.js +6 -4
  310. package/dist/server/pages-page-response.js.map +1 -1
  311. package/dist/server/prod-server.d.ts +26 -1
  312. package/dist/server/prod-server.js +150 -44
  313. package/dist/server/prod-server.js.map +1 -1
  314. package/dist/server/request-pipeline.d.ts +11 -2
  315. package/dist/server/request-pipeline.js +28 -11
  316. package/dist/server/request-pipeline.js.map +1 -1
  317. package/dist/server/seed-cache.d.ts +12 -31
  318. package/dist/server/seed-cache.js +22 -35
  319. package/dist/server/seed-cache.js.map +1 -1
  320. package/dist/server/server-action-not-found.d.ts +16 -3
  321. package/dist/server/server-action-not-found.js +27 -4
  322. package/dist/server/server-action-not-found.js.map +1 -1
  323. package/dist/server/server-globals.d.ts +5 -0
  324. package/dist/server/server-globals.js +37 -0
  325. package/dist/server/server-globals.js.map +1 -0
  326. package/dist/server/skip-cache-proof.d.ts +41 -0
  327. package/dist/server/skip-cache-proof.js +101 -0
  328. package/dist/server/skip-cache-proof.js.map +1 -0
  329. package/dist/server/static-file-cache.d.ts +1 -1
  330. package/dist/server/static-file-cache.js +7 -6
  331. package/dist/server/static-file-cache.js.map +1 -1
  332. package/dist/shims/cache-runtime.d.ts +19 -2
  333. package/dist/shims/cache-runtime.js +67 -11
  334. package/dist/shims/cache-runtime.js.map +1 -1
  335. package/dist/shims/cache.d.ts +5 -18
  336. package/dist/shims/cache.js +2 -0
  337. package/dist/shims/cache.js.map +1 -1
  338. package/dist/shims/client-locale.d.ts +15 -0
  339. package/dist/shims/client-locale.js +13 -0
  340. package/dist/shims/client-locale.js.map +1 -0
  341. package/dist/shims/default-global-error.d.ts +32 -0
  342. package/dist/shims/default-global-error.js +181 -0
  343. package/dist/shims/default-global-error.js.map +1 -0
  344. package/dist/shims/document.d.ts +59 -3
  345. package/dist/shims/document.js +36 -5
  346. package/dist/shims/document.js.map +1 -1
  347. package/dist/shims/error-boundary.d.ts +2 -2
  348. package/dist/shims/error-boundary.js +6 -8
  349. package/dist/shims/error-boundary.js.map +1 -1
  350. package/dist/shims/error.d.ts +18 -1
  351. package/dist/shims/error.js +56 -1
  352. package/dist/shims/error.js.map +1 -1
  353. package/dist/shims/fetch-cache.d.ts +4 -1
  354. package/dist/shims/fetch-cache.js +40 -5
  355. package/dist/shims/fetch-cache.js.map +1 -1
  356. package/dist/shims/font-google-base.d.ts +22 -8
  357. package/dist/shims/font-google-base.js +41 -71
  358. package/dist/shims/font-google-base.js.map +1 -1
  359. package/dist/shims/font-local.d.ts +3 -20
  360. package/dist/shims/font-local.js +23 -75
  361. package/dist/shims/font-local.js.map +1 -1
  362. package/dist/shims/font-utils.d.ts +51 -0
  363. package/dist/shims/font-utils.js +97 -0
  364. package/dist/shims/font-utils.js.map +1 -0
  365. package/dist/shims/form.js +13 -6
  366. package/dist/shims/form.js.map +1 -1
  367. package/dist/shims/hash-scroll.d.ts +7 -0
  368. package/dist/shims/hash-scroll.js +30 -0
  369. package/dist/shims/hash-scroll.js.map +1 -0
  370. package/dist/shims/headers.d.ts +8 -11
  371. package/dist/shims/headers.js +22 -2
  372. package/dist/shims/headers.js.map +1 -1
  373. package/dist/shims/image.d.ts +1 -0
  374. package/dist/shims/image.js +144 -78
  375. package/dist/shims/image.js.map +1 -1
  376. package/dist/shims/internal/app-router-context.d.ts +6 -6
  377. package/dist/shims/internal/app-router-context.js +17 -6
  378. package/dist/shims/internal/app-router-context.js.map +1 -1
  379. package/dist/shims/link-prefetch.d.ts +9 -1
  380. package/dist/shims/link-prefetch.js +11 -6
  381. package/dist/shims/link-prefetch.js.map +1 -1
  382. package/dist/shims/link.d.ts +33 -5
  383. package/dist/shims/link.js +205 -50
  384. package/dist/shims/link.js.map +1 -1
  385. package/dist/shims/metadata.d.ts +16 -30
  386. package/dist/shims/metadata.js +91 -32
  387. package/dist/shims/metadata.js.map +1 -1
  388. package/dist/shims/navigation.d.ts +164 -17
  389. package/dist/shims/navigation.js +355 -84
  390. package/dist/shims/navigation.js.map +1 -1
  391. package/dist/shims/navigation.react-server.d.ts +3 -2
  392. package/dist/shims/navigation.react-server.js +5 -2
  393. package/dist/shims/navigation.react-server.js.map +1 -1
  394. package/dist/shims/og.d.ts +18 -2
  395. package/dist/shims/og.js +49 -1
  396. package/dist/shims/og.js.map +1 -0
  397. package/dist/shims/pages-router-runtime.d.ts +7 -0
  398. package/dist/shims/pages-router-runtime.js +16 -0
  399. package/dist/shims/pages-router-runtime.js.map +1 -0
  400. package/dist/shims/request-state-types.d.ts +1 -1
  401. package/dist/shims/root-params.d.ts +3 -1
  402. package/dist/shims/root-params.js +11 -3
  403. package/dist/shims/root-params.js.map +1 -1
  404. package/dist/shims/router-state.d.ts +1 -0
  405. package/dist/shims/router-state.js.map +1 -1
  406. package/dist/shims/router.d.ts +40 -7
  407. package/dist/shims/router.js +355 -250
  408. package/dist/shims/router.js.map +1 -1
  409. package/dist/shims/script.js +110 -32
  410. package/dist/shims/script.js.map +1 -1
  411. package/dist/shims/server.d.ts +21 -4
  412. package/dist/shims/server.js +31 -10
  413. package/dist/shims/server.js.map +1 -1
  414. package/dist/shims/slot.d.ts +1 -0
  415. package/dist/shims/slot.js +45 -1
  416. package/dist/shims/slot.js.map +1 -1
  417. package/dist/shims/unified-request-context.d.ts +1 -1
  418. package/dist/shims/unified-request-context.js +2 -0
  419. package/dist/shims/unified-request-context.js.map +1 -1
  420. package/dist/shims/unrecognized-action-error.d.ts +35 -0
  421. package/dist/shims/unrecognized-action-error.js +41 -0
  422. package/dist/shims/unrecognized-action-error.js.map +1 -0
  423. package/dist/shims/url-safety.d.ts +23 -1
  424. package/dist/shims/url-safety.js +29 -2
  425. package/dist/shims/url-safety.js.map +1 -1
  426. package/dist/shims/url-utils.d.ts +21 -1
  427. package/dist/shims/url-utils.js +67 -3
  428. package/dist/shims/url-utils.js.map +1 -1
  429. package/dist/typegen.d.ts +10 -0
  430. package/dist/typegen.js +242 -0
  431. package/dist/typegen.js.map +1 -0
  432. package/dist/utils/asset-prefix.d.ts +97 -0
  433. package/dist/utils/asset-prefix.js +124 -0
  434. package/dist/utils/asset-prefix.js.map +1 -0
  435. package/dist/utils/base-path.d.ts +7 -1
  436. package/dist/utils/base-path.js +10 -1
  437. package/dist/utils/base-path.js.map +1 -1
  438. package/dist/utils/cache-control-metadata.d.ts +2 -1
  439. package/dist/utils/cache-control-metadata.js +1 -3
  440. package/dist/utils/cache-control-metadata.js.map +1 -1
  441. package/dist/utils/domain-locale.d.ts +2 -1
  442. package/dist/utils/domain-locale.js +9 -1
  443. package/dist/utils/domain-locale.js.map +1 -1
  444. package/dist/utils/lazy-chunks.d.ts +1 -1
  445. package/dist/utils/lazy-chunks.js +1 -1
  446. package/dist/utils/lazy-chunks.js.map +1 -1
  447. package/dist/utils/navigation-signal.d.ts +1 -2
  448. package/dist/utils/navigation-signal.js +1 -1
  449. package/dist/utils/navigation-signal.js.map +1 -1
  450. package/dist/utils/prerender-output-paths.d.ts +15 -0
  451. package/dist/utils/prerender-output-paths.js +24 -0
  452. package/dist/utils/prerender-output-paths.js.map +1 -0
  453. package/dist/utils/query.d.ts +17 -1
  454. package/dist/utils/query.js +36 -1
  455. package/dist/utils/query.js.map +1 -1
  456. package/dist/utils/record.d.ts +5 -0
  457. package/dist/utils/record.js +8 -0
  458. package/dist/utils/record.js.map +1 -0
  459. package/dist/utils/sorted-array.d.ts +9 -0
  460. package/dist/utils/sorted-array.js +22 -0
  461. package/dist/utils/sorted-array.js.map +1 -0
  462. package/package.json +13 -5
@@ -1,12 +1,19 @@
1
- import { VINEXT_CACHE_HEADER, VINEXT_MOUNTED_SLOTS_HEADER } from "./headers.js";
1
+ import { VINEXT_MOUNTED_SLOTS_HEADER } from "./headers.js";
2
+ import { setCacheStateHeaders } from "./cache-headers.js";
2
3
  import { encodeCacheTag } from "../utils/encode-cache-tag.js";
3
4
  import { buildAppPageCacheValue } from "./isr-cache.js";
4
- import { VINEXT_RSC_VARY_HEADER } from "./app-rsc-cache-busting.js";
5
- import { readStreamAsText } from "../utils/text-stream.js";
5
+ import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader } from "./app-rsc-cache-busting.js";
6
6
  import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
7
7
  import { buildCachedRevalidateCacheControl } from "./cache-control.js";
8
+ import { readStreamAsText } from "../utils/text-stream.js";
9
+ import { createEmptyAppPageRenderObservationState } from "./app-page-render-observation.js";
8
10
  //#region src/server/app-page-cache.ts
9
11
  const NO_STORE_CACHE_CONTROL = "no-store, must-revalidate";
12
+ function recordAppPageCacheOutcome(recordCacheOutcome, input) {
13
+ try {
14
+ recordCacheOutcome?.(input);
15
+ } catch {}
16
+ }
10
17
  function buildAppPageCacheTags(pathname, extraTags) {
11
18
  const tags = [
12
19
  pathname,
@@ -33,9 +40,9 @@ function buildAppPageCachedHeaders(options) {
33
40
  const headers = new Headers({
34
41
  "Cache-Control": options.cacheControl,
35
42
  "Content-Type": options.contentType,
36
- Vary: VINEXT_RSC_VARY_HEADER,
37
- [VINEXT_CACHE_HEADER]: options.cacheState
43
+ Vary: VINEXT_RSC_VARY_HEADER
38
44
  });
45
+ setCacheStateHeaders(headers, options.cacheState);
39
46
  if (options.mountedSlotsHeader) headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);
40
47
  mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);
41
48
  return headers;
@@ -65,10 +72,11 @@ function buildAppPageCachedResponse(cachedValue, options) {
65
72
  const rscHeaders = buildAppPageCachedHeaders({
66
73
  cacheControl,
67
74
  cacheState: options.cacheState,
68
- contentType: "text/x-component; charset=utf-8",
75
+ contentType: VINEXT_RSC_CONTENT_TYPE,
69
76
  middlewareHeaders: options.middlewareHeaders,
70
77
  mountedSlotsHeader: options.mountedSlotsHeader
71
78
  });
79
+ applyRscCompatibilityIdHeader(rscHeaders);
72
80
  return new Response(cachedValue.rscData, {
73
81
  status,
74
82
  headers: rscHeaders
@@ -88,9 +96,20 @@ function buildAppPageCachedResponse(cachedValue, options) {
88
96
  }
89
97
  async function readAppPageCacheResponse(options) {
90
98
  const isrKey = options.isRscRequest ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode) : options.isrHtmlKey(options.cleanPathname);
99
+ const artifact = options.isRscRequest ? "rsc" : "html";
91
100
  try {
92
101
  const cached = await options.isrGet(isrKey);
93
102
  const cachedValue = getCachedAppPageValue(cached);
103
+ if (cached && !cachedValue) {
104
+ recordAppPageCacheOutcome(options.recordCacheOutcome, {
105
+ artifact,
106
+ cacheKey: isrKey,
107
+ outcome: "miss",
108
+ reason: "non-app-page-entry"
109
+ });
110
+ options.isrDebug?.("MISS (non app-page cache entry)", options.cleanPathname);
111
+ return null;
112
+ }
94
113
  if (cachedValue && !cached?.isStale) {
95
114
  const hitResponse = buildAppPageCachedResponse(cachedValue, {
96
115
  cacheState: "HIT",
@@ -103,10 +122,22 @@ async function readAppPageCacheResponse(options) {
103
122
  revalidateSeconds: options.revalidateSeconds
104
123
  });
105
124
  if (hitResponse) {
125
+ recordAppPageCacheOutcome(options.recordCacheOutcome, {
126
+ artifact,
127
+ cacheKey: isrKey,
128
+ outcome: "hit",
129
+ reason: "served"
130
+ });
106
131
  options.isrDebug?.(options.isRscRequest ? "HIT (RSC)" : "HIT (HTML)", options.cleanPathname);
107
132
  options.clearRequestContext();
108
133
  return hitResponse;
109
134
  }
135
+ recordAppPageCacheOutcome(options.recordCacheOutcome, {
136
+ artifact,
137
+ cacheKey: isrKey,
138
+ outcome: "miss",
139
+ reason: "empty-entry"
140
+ });
110
141
  options.isrDebug?.("MISS (empty cached entry)", options.cleanPathname);
111
142
  }
112
143
  if (cached?.isStale && cachedValue) {
@@ -115,8 +146,8 @@ async function readAppPageCacheResponse(options) {
115
146
  const revalidatedPage = await options.renderFreshPageForCache();
116
147
  const revalidateSeconds = revalidatedPage.cacheControl?.revalidate ?? options.revalidateSeconds;
117
148
  const expireSeconds = revalidatedPage.cacheControl?.expire ?? options.expireSeconds;
118
- const writes = [options.isrSet(options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode), buildAppPageCacheValue("", revalidatedPage.rscData, 200), revalidateSeconds, revalidatedPage.tags, expireSeconds)];
119
- if (!options.isRscRequest) writes.push(options.isrSet(options.isrHtmlKey(options.cleanPathname), buildAppPageCacheValue(revalidatedPage.html, void 0, 200), revalidateSeconds, revalidatedPage.tags, expireSeconds));
149
+ const writes = [options.isrSet(options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode), buildAppPageCacheValue("", revalidatedPage.rscData, 200, revalidatedPage.rscRenderObservation), revalidateSeconds, revalidatedPage.tags, expireSeconds)];
150
+ if (!options.isRscRequest) writes.push(options.isrSet(options.isrHtmlKey(options.cleanPathname), buildAppPageCacheValue(revalidatedPage.html, void 0, 200, revalidatedPage.htmlRenderObservation), revalidateSeconds, revalidatedPage.tags, expireSeconds));
120
151
  await Promise.all(writes);
121
152
  options.isrDebug?.("regen complete", options.cleanPathname);
122
153
  });
@@ -131,14 +162,40 @@ async function readAppPageCacheResponse(options) {
131
162
  revalidateSeconds: options.revalidateSeconds
132
163
  });
133
164
  if (staleResponse) {
165
+ recordAppPageCacheOutcome(options.recordCacheOutcome, {
166
+ artifact,
167
+ cacheKey: isrKey,
168
+ outcome: "stale",
169
+ reason: "served"
170
+ });
134
171
  options.isrDebug?.(options.isRscRequest ? "STALE (RSC)" : "STALE (HTML)", options.cleanPathname);
135
172
  options.clearRequestContext();
136
173
  return staleResponse;
137
174
  }
175
+ recordAppPageCacheOutcome(options.recordCacheOutcome, {
176
+ artifact,
177
+ cacheKey: isrKey,
178
+ outcome: "miss",
179
+ reason: "stale-empty-entry"
180
+ });
138
181
  options.isrDebug?.("STALE MISS (empty stale entry)", options.cleanPathname);
139
182
  }
140
- if (!cached) options.isrDebug?.("MISS (no cache entry)", options.cleanPathname);
183
+ if (!cached) {
184
+ recordAppPageCacheOutcome(options.recordCacheOutcome, {
185
+ artifact,
186
+ cacheKey: isrKey,
187
+ outcome: "miss",
188
+ reason: "no-entry"
189
+ });
190
+ options.isrDebug?.("MISS (no cache entry)", options.cleanPathname);
191
+ }
141
192
  } catch (isrReadError) {
193
+ recordAppPageCacheOutcome(options.recordCacheOutcome, {
194
+ artifact,
195
+ cacheKey: isrKey,
196
+ outcome: "miss",
197
+ reason: "read-error"
198
+ });
142
199
  console.error("[vinext] ISR cache read error:", isrReadError);
143
200
  }
144
201
  return null;
@@ -151,7 +208,7 @@ function finalizeAppPageHtmlCacheResponse(response, options) {
151
208
  const clientHeaders = new Headers(response.headers);
152
209
  if (options.preserveClientResponseHeaders !== true) {
153
210
  clientHeaders.set("Cache-Control", NO_STORE_CACHE_CONTROL);
154
- clientHeaders.set(VINEXT_CACHE_HEADER, "MISS");
211
+ setCacheStateHeaders(clientHeaders, "MISS");
155
212
  }
156
213
  const cachePromise = (async () => {
157
214
  try {
@@ -170,8 +227,17 @@ function finalizeAppPageHtmlCacheResponse(response, options) {
170
227
  return;
171
228
  }
172
229
  const pageTags = options.getPageTags();
173
- const writes = [options.isrSet(htmlKey, buildAppPageCacheValue(cachedHtml, void 0, 200), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds)];
174
- if (options.capturedRscDataPromise) writes.push(options.capturedRscDataPromise.then((rscData) => options.isrSet(rscKey, buildAppPageCacheValue("", rscData, 200), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds)));
230
+ const observationState = options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();
231
+ const htmlRenderObservation = options.createHtmlRenderObservation?.({
232
+ cacheTags: pageTags,
233
+ state: observationState
234
+ });
235
+ const rscRenderObservation = options.createRscRenderObservation?.({
236
+ cacheTags: pageTags,
237
+ state: observationState
238
+ });
239
+ const writes = [options.isrSet(htmlKey, buildAppPageCacheValue(cachedHtml, void 0, 200, htmlRenderObservation), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds)];
240
+ if (options.capturedRscDataPromise) writes.push(options.capturedRscDataPromise.then((rscData) => options.isrSet(rscKey, buildAppPageCacheValue("", rscData, 200, rscRenderObservation), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds)));
175
241
  await Promise.all(writes);
176
242
  options.isrDebug?.("HTML cache written", htmlKey);
177
243
  } catch (cacheError) {
@@ -190,7 +256,7 @@ function finalizeAppPageRscCacheResponse(response, options) {
190
256
  if (options.preserveClientResponseHeaders === true) return response;
191
257
  const clientHeaders = new Headers(response.headers);
192
258
  clientHeaders.set("Cache-Control", NO_STORE_CACHE_CONTROL);
193
- clientHeaders.set(VINEXT_CACHE_HEADER, "MISS");
259
+ setCacheStateHeaders(clientHeaders, "MISS");
194
260
  return new Response(response.body, {
195
261
  status: response.status,
196
262
  statusText: response.statusText,
@@ -217,7 +283,13 @@ function scheduleAppPageRscCacheWrite(options) {
217
283
  options.isrDebug?.("RSC cache write skipped (no cache policy)", rscKey);
218
284
  return;
219
285
  }
220
- await options.isrSet(rscKey, buildAppPageCacheValue("", rscData, 200), cachePolicy.revalidateSeconds, options.getPageTags(), cachePolicy.expireSeconds);
286
+ const pageTags = options.getPageTags();
287
+ const observationState = options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();
288
+ const rscRenderObservation = options.createRscRenderObservation?.({
289
+ cacheTags: pageTags,
290
+ state: observationState
291
+ });
292
+ await options.isrSet(rscKey, buildAppPageCacheValue("", rscData, 200, rscRenderObservation), cachePolicy.revalidateSeconds, pageTags, cachePolicy.expireSeconds);
221
293
  options.isrDebug?.("RSC cache written", rscKey);
222
294
  } catch (cacheError) {
223
295
  console.error("[vinext] ISR RSC cache write error:", cacheError);
@@ -1 +1 @@
1
- {"version":3,"file":"app-page-cache.js","names":[],"sources":["../../src/server/app-page-cache.ts"],"sourcesContent":["import type { CachedAppPageValue, CacheControlMetadata } from \"vinext/shims/cache\";\nimport { VINEXT_RSC_VARY_HEADER } from \"./app-rsc-cache-busting.js\";\nimport { buildCachedRevalidateCacheControl } from \"./cache-control.js\";\nimport { VINEXT_CACHE_HEADER, VINEXT_MOUNTED_SLOTS_HEADER } from \"./headers.js\";\nimport { buildAppPageCacheValue, type ISRCacheEntry } from \"./isr-cache.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\nimport { readStreamAsText } from \"../utils/text-stream.js\";\nimport { encodeCacheTag } from \"../utils/encode-cache-tag.js\";\nimport type { AppRscRenderMode } from \"./app-rsc-render-mode.js\";\n\ntype AppPageDebugLogger = (event: string, detail: string) => void;\ntype AppPageCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype AppPageCacheSetter = (\n key: string,\n data: CachedAppPageValue,\n revalidateSeconds: number,\n tags: string[],\n expireSeconds?: number,\n) => Promise<void>;\ntype AppPageBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;\ntype AppPageRequestCacheLife = {\n revalidate?: number;\n expire?: number;\n};\n\ntype AppPageCacheRenderResult = {\n cacheControl?: CacheControlMetadata;\n html: string;\n rscData: ArrayBuffer;\n tags: string[];\n};\n\ntype BuildAppPageCachedResponseOptions = {\n cacheControl?: CacheControlMetadata;\n cacheState: \"HIT\" | \"STALE\";\n expireSeconds?: number;\n isRscRequest: boolean;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n revalidateSeconds: number;\n};\n\ntype ReadAppPageCacheResponseOptions = {\n cleanPathname: string;\n clearRequestContext: () => void;\n isRscRequest: boolean;\n isrDebug?: AppPageDebugLogger;\n isrGet: AppPageCacheGetter;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n expireSeconds?: number;\n revalidateSeconds: number;\n renderFreshPageForCache: () => Promise<AppPageCacheRenderResult>;\n scheduleBackgroundRegeneration: AppPageBackgroundRegenerator;\n};\n\ntype FinalizeAppPageHtmlCacheResponseOptions = {\n capturedDynamicUsageBeforeContextCleanup?: () => boolean;\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\n isrDebug?: AppPageDebugLogger;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\ntype ScheduleAppPageRscCacheWriteOptions = {\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n dynamicUsedDuringBuild: boolean;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\n isrDebug?: AppPageDebugLogger;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\nconst NO_STORE_CACHE_CONTROL = \"no-store, must-revalidate\";\n\nexport function buildAppPageCacheTags(pathname: string, extraTags: readonly string[]): string[] {\n const tags = [pathname, `_N_T_${pathname}`, \"_N_T_/layout\"];\n const segments = pathname.split(\"/\");\n let built = \"\";\n for (let index = 1; index < segments.length; index++) {\n const segment = segments[index];\n if (segment) {\n built += `/${segment}`;\n tags.push(`_N_T_${built}/layout`);\n }\n }\n\n tags.push(`_N_T_${built}/page`);\n for (const tag of extraTags) {\n if (!tags.includes(tag)) {\n tags.push(tag);\n }\n }\n // Canonicalise to ASCII-safe form so path-derived tags from non-ASCII\n // pathnames match what `revalidatePath`/`revalidateTag` produce after\n // their own encoding pass.\n return tags.map(encodeCacheTag);\n}\n\nfunction buildAppPageCacheControl(\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"],\n revalidateSeconds: number,\n expireSeconds?: number,\n): string {\n return buildCachedRevalidateCacheControl(cacheState, revalidateSeconds, expireSeconds);\n}\n\nfunction buildAppPageCachedHeaders(options: {\n cacheControl: string;\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"];\n contentType: string;\n middlewareHeaders?: Headers | null;\n mountedSlotsHeader?: string | null;\n}): Headers {\n const headers = new Headers({\n \"Cache-Control\": options.cacheControl,\n \"Content-Type\": options.contentType,\n Vary: VINEXT_RSC_VARY_HEADER,\n [VINEXT_CACHE_HEADER]: options.cacheState,\n });\n\n if (options.mountedSlotsHeader) {\n headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n return headers;\n}\n\nfunction getCachedAppPageValue(entry: ISRCacheEntry | null): CachedAppPageValue | null {\n return entry?.value.value && entry.value.value.kind === \"APP_PAGE\" ? entry.value.value : null;\n}\n\nfunction resolveAppPageCacheWritePolicy(options: {\n expireSeconds?: number;\n requestCacheLife?: AppPageRequestCacheLife | null;\n revalidateSeconds: number | null;\n}): { expireSeconds?: number; revalidateSeconds: number } | null {\n let revalidateSeconds = options.revalidateSeconds;\n let expireSeconds = options.expireSeconds;\n const requestCacheLife = options.requestCacheLife;\n\n if (requestCacheLife?.revalidate !== undefined) {\n revalidateSeconds =\n revalidateSeconds === null\n ? requestCacheLife.revalidate\n : Math.min(revalidateSeconds, requestCacheLife.revalidate);\n }\n if (requestCacheLife?.expire !== undefined) {\n expireSeconds = requestCacheLife.expire;\n }\n\n if (revalidateSeconds === null || revalidateSeconds <= 0 || !Number.isFinite(revalidateSeconds)) {\n return null;\n }\n\n return { expireSeconds, revalidateSeconds };\n}\n\nexport function buildAppPageCachedResponse(\n cachedValue: CachedAppPageValue,\n options: BuildAppPageCachedResponseOptions,\n): Response | null {\n // Preserve the legacy fallback semantics from the generated entry: invalid\n // falsy statuses still fall back to 200 rather than being forwarded through.\n const status = options.middlewareStatus ?? (cachedValue.status || 200);\n const revalidateSeconds = options.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds =\n options.cacheControl === undefined\n ? undefined\n : (options.cacheControl.expire ?? options.expireSeconds);\n const cacheControl = buildAppPageCacheControl(\n options.cacheState,\n revalidateSeconds,\n expireSeconds,\n );\n if (options.isRscRequest) {\n if (!cachedValue.rscData) {\n return null;\n }\n\n const rscHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: \"text/x-component; charset=utf-8\",\n middlewareHeaders: options.middlewareHeaders,\n mountedSlotsHeader: options.mountedSlotsHeader,\n });\n\n return new Response(cachedValue.rscData, {\n status,\n headers: rscHeaders,\n });\n }\n\n if (typeof cachedValue.html !== \"string\" || cachedValue.html.length === 0) {\n return null;\n }\n\n const htmlHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: \"text/html; charset=utf-8\",\n middlewareHeaders: options.middlewareHeaders,\n });\n\n return new Response(cachedValue.html, {\n status,\n headers: htmlHeaders,\n });\n}\n\nexport async function readAppPageCacheResponse(\n options: ReadAppPageCacheResponseOptions,\n): Promise<Response | null> {\n const isrKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n\n try {\n const cached = await options.isrGet(isrKey);\n const cachedValue = getCachedAppPageValue(cached);\n\n if (cachedValue && !cached?.isStale) {\n const hitResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"HIT\",\n cacheControl: cached?.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (hitResponse) {\n options.isrDebug?.(\n options.isRscRequest ? \"HIT (RSC)\" : \"HIT (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return hitResponse;\n }\n\n options.isrDebug?.(\"MISS (empty cached entry)\", options.cleanPathname);\n }\n\n if (cached?.isStale && cachedValue) {\n const regenerationKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n\n // Preserve the legacy behavior from the inline generator: stale entries\n // still trigger background regeneration even if this request cannot use\n // the stale payload and will fall through to a fresh render.\n options.scheduleBackgroundRegeneration(regenerationKey, async () => {\n const revalidatedPage = await options.renderFreshPageForCache();\n const revalidateSeconds =\n revalidatedPage.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds = revalidatedPage.cacheControl?.expire ?? options.expireSeconds;\n const writes = [\n options.isrSet(\n options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n ),\n buildAppPageCacheValue(\"\", revalidatedPage.rscData, 200),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n ];\n\n if (!options.isRscRequest) {\n // HTML cache is slot-state-independent (canonical), so only refresh it\n // during HTML-triggered regens. RSC-triggered regens only update the\n // requesting client's RSC slot variant; a stale HTML cache entry will\n // be regenerated independently by the next full-page HTML request.\n writes.push(\n options.isrSet(\n options.isrHtmlKey(options.cleanPathname),\n buildAppPageCacheValue(revalidatedPage.html, undefined, 200),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"regen complete\", options.cleanPathname);\n });\n\n const staleResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"STALE\",\n cacheControl: cached.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (staleResponse) {\n options.isrDebug?.(\n options.isRscRequest ? \"STALE (RSC)\" : \"STALE (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return staleResponse;\n }\n\n options.isrDebug?.(\"STALE MISS (empty stale entry)\", options.cleanPathname);\n }\n\n if (!cached) {\n options.isrDebug?.(\"MISS (no cache entry)\", options.cleanPathname);\n }\n } catch (isrReadError) {\n console.error(\"[vinext] ISR cache read error:\", isrReadError);\n }\n\n return null;\n}\n\nexport function finalizeAppPageHtmlCacheResponse(\n response: Response,\n options: FinalizeAppPageHtmlCacheResponseOptions,\n): Response {\n if (!response.body) {\n return response;\n }\n\n const [streamForClient, streamForCache] = response.body.tee();\n const htmlKey = options.isrHtmlKey(options.cleanPathname);\n const rscKey = options.isrRscKey(options.cleanPathname, null);\n const clientHeaders = new Headers(response.headers);\n if (options.preserveClientResponseHeaders !== true) {\n // HTML Server Components can access request APIs while the stream is being\n // consumed. Until that late dynamic check finishes, downstream shared caches\n // must not cache a response whose ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n clientHeaders.set(VINEXT_CACHE_HEADER, \"MISS\");\n }\n\n const cachePromise = (async () => {\n try {\n const cachedHtml = await readStreamAsText(streamForCache);\n\n if (\n options.capturedDynamicUsageBeforeContextCleanup?.() === true ||\n options.consumeDynamicUsage()\n ) {\n options.isrDebug?.(\"HTML cache write skipped (dynamic usage during render)\", htmlKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"HTML cache write skipped (no cache policy)\", htmlKey);\n return;\n }\n\n const pageTags = options.getPageTags();\n const writes = [\n options.isrSet(\n htmlKey,\n buildAppPageCacheValue(cachedHtml, undefined, 200),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ];\n\n if (options.capturedRscDataPromise) {\n writes.push(\n options.capturedRscDataPromise.then((rscData) =>\n options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"HTML cache written\", htmlKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n\n return new Response(streamForClient, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function finalizeAppPageRscCacheResponse(\n response: Response,\n options: ScheduleAppPageRscCacheWriteOptions,\n): Response {\n const didSchedule = scheduleAppPageRscCacheWrite(options);\n if (!didSchedule) {\n return response;\n }\n\n if (options.preserveClientResponseHeaders === true) {\n return response;\n }\n\n const clientHeaders = new Headers(response.headers);\n // RSC payloads are also streamed lazily. Until the captured stream proves no\n // late request API was used, the client-facing MISS response must not enter a\n // shared cache when the ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n clientHeaders.set(VINEXT_CACHE_HEADER, \"MISS\");\n\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function scheduleAppPageRscCacheWrite(\n options: ScheduleAppPageRscCacheWriteOptions,\n): boolean {\n const capturedRscDataPromise = options.capturedRscDataPromise;\n if (!capturedRscDataPromise || options.dynamicUsedDuringBuild) {\n return false;\n }\n\n const rscKey = options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n );\n const cachePromise = (async () => {\n try {\n const rscData = await capturedRscDataPromise;\n\n // Two-phase dynamic detection:\n // 1. dynamicUsedDuringBuild catches searchParams-driven opt-in before the\n // RSC response is sent.\n // 2. consumeDynamicUsage() here catches APIs that fire while the RSC\n // stream is consumed (headers(), cookies(), noStore()).\n if (options.consumeDynamicUsage()) {\n options.isrDebug?.(\"RSC cache write skipped (dynamic usage during render)\", rscKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"RSC cache write skipped (no cache policy)\", rscKey);\n return;\n }\n\n await options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200),\n cachePolicy.revalidateSeconds,\n options.getPageTags(),\n cachePolicy.expireSeconds,\n );\n options.isrDebug?.(\"RSC cache written\", rscKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR RSC cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n return true;\n}\n"],"mappings":";;;;;;;;AA6GA,MAAM,yBAAyB;AAE/B,SAAgB,sBAAsB,UAAkB,WAAwC;CAC9F,MAAM,OAAO;EAAC;EAAU,QAAQ;EAAY;EAAe;CAC3D,MAAM,WAAW,SAAS,MAAM,IAAI;CACpC,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS;EACpD,MAAM,UAAU,SAAS;EACzB,IAAI,SAAS;GACX,SAAS,IAAI;GACb,KAAK,KAAK,QAAQ,MAAM,SAAS;;;CAIrC,KAAK,KAAK,QAAQ,MAAM,OAAO;CAC/B,KAAK,MAAM,OAAO,WAChB,IAAI,CAAC,KAAK,SAAS,IAAI,EACrB,KAAK,KAAK,IAAI;CAMlB,OAAO,KAAK,IAAI,eAAe;;AAGjC,SAAS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9C,OAAO,IAAI,SAAS,SAAS,MAAM;EACjC,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,SAAS;EACV,CAAC;;AAGJ,SAAgB,6BACd,SACS;CACT,MAAM,yBAAyB,QAAQ;CACvC,IAAI,CAAC,0BAA0B,QAAQ,wBACrC,OAAO;CAGT,MAAM,SAAS,QAAQ,UACrB,QAAQ,eACR,QAAQ,oBACR,QAAQ,WACT;CACD,MAAM,gBAAgB,YAAY;EAChC,IAAI;GACF,MAAM,UAAU,MAAM;GAOtB,IAAI,QAAQ,qBAAqB,EAAE;IACjC,QAAQ,WAAW,yDAAyD,OAAO;IACnF;;GAGF,MAAM,cAAc,+BAA+B;IACjD,eAAe,QAAQ;IACvB,kBAAkB,QAAQ,uBAAuB;IACjD,mBAAmB,QAAQ;IAC5B,CAAC;GACF,IAAI,CAAC,aAAa;IAChB,QAAQ,WAAW,6CAA6C,OAAO;IACvE;;GAGF,MAAM,QAAQ,OACZ,QACA,uBAAuB,IAAI,SAAS,IAAI,EACxC,YAAY,mBACZ,QAAQ,aAAa,EACrB,YAAY,cACb;GACD,QAAQ,WAAW,qBAAqB,OAAO;WACxC,YAAY;GACnB,QAAQ,MAAM,uCAAuC,WAAW;;KAEhE;CAEJ,QAAQ,YAAY,aAAa;CACjC,OAAO"}
1
+ {"version":3,"file":"app-page-cache.js","names":[],"sources":["../../src/server/app-page-cache.ts"],"sourcesContent":["import type { CachedAppPageValue, CacheControlMetadata } from \"vinext/shims/cache\";\nimport {\n VINEXT_RSC_CONTENT_TYPE,\n VINEXT_RSC_VARY_HEADER,\n applyRscCompatibilityIdHeader,\n} from \"./app-rsc-cache-busting.js\";\nimport { buildCachedRevalidateCacheControl } from \"./cache-control.js\";\nimport { VINEXT_MOUNTED_SLOTS_HEADER } from \"./headers.js\";\nimport { setCacheStateHeaders } from \"./cache-headers.js\";\nimport { buildAppPageCacheValue, type ISRCacheEntry } from \"./isr-cache.js\";\nimport { mergeMiddlewareResponseHeaders } from \"./middleware-response-headers.js\";\nimport { readStreamAsText } from \"../utils/text-stream.js\";\nimport { encodeCacheTag } from \"../utils/encode-cache-tag.js\";\nimport type { AppRscRenderMode } from \"./app-rsc-render-mode.js\";\nimport {\n createEmptyAppPageRenderObservationState,\n type AppPageRenderObservationState,\n} from \"./app-page-render-observation.js\";\nimport type { RenderObservation } from \"./cache-proof.js\";\n\ntype AppPageDebugLogger = (event: string, detail: string) => void;\ntype AppPageCacheGetter = (key: string) => Promise<ISRCacheEntry | null>;\ntype AppPageCacheSetter = (\n key: string,\n data: CachedAppPageValue,\n revalidateSeconds: number,\n tags: string[],\n expireSeconds?: number,\n) => Promise<void>;\ntype AppPageBackgroundRegenerator = (key: string, renderFn: () => Promise<void>) => void;\ntype AppPageRequestCacheLife = {\n revalidate?: number;\n expire?: number;\n};\nexport type AppPageCacheOutcomeMetric = Readonly<{\n artifact: \"html\" | \"rsc\";\n /**\n * Internal cache lookup key for debugging and tests. Runtime telemetry sinks should hash or\n * redact this value before export to avoid high-cardinality or user-derived labels.\n */\n cacheKey: string;\n outcome: \"hit\" | \"miss\" | \"stale\";\n reason:\n | \"empty-entry\"\n | \"no-entry\"\n | \"non-app-page-entry\"\n | \"read-error\"\n | \"served\"\n | \"stale-empty-entry\";\n}>;\ntype AppPageCacheOutcomeRecorder = (metric: AppPageCacheOutcomeMetric) => void;\n\ntype BuildAppPageCacheRenderObservation = (input: {\n cacheTags: readonly string[];\n state: AppPageRenderObservationState;\n}) => RenderObservation;\n\ntype AppPageCacheRenderResult = {\n cacheControl?: CacheControlMetadata;\n html: string;\n htmlRenderObservation?: RenderObservation;\n rscData: ArrayBuffer;\n rscRenderObservation?: RenderObservation;\n tags: string[];\n};\n\ntype BuildAppPageCachedResponseOptions = {\n cacheControl?: CacheControlMetadata;\n cacheState: \"HIT\" | \"STALE\";\n expireSeconds?: number;\n isRscRequest: boolean;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n revalidateSeconds: number;\n};\n\ntype ReadAppPageCacheResponseOptions = {\n cleanPathname: string;\n clearRequestContext: () => void;\n isRscRequest: boolean;\n isrDebug?: AppPageDebugLogger;\n isrGet: AppPageCacheGetter;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n middlewareHeaders?: Headers | null;\n middlewareStatus?: number | null;\n mountedSlotsHeader?: string | null;\n recordCacheOutcome?: AppPageCacheOutcomeRecorder;\n renderMode?: AppRscRenderMode;\n expireSeconds?: number;\n revalidateSeconds: number;\n renderFreshPageForCache: () => Promise<AppPageCacheRenderResult>;\n scheduleBackgroundRegeneration: AppPageBackgroundRegenerator;\n};\n\ntype FinalizeAppPageHtmlCacheResponseOptions = {\n capturedDynamicUsageBeforeContextCleanup?: () => boolean;\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n consumeRenderObservationState?: () => AppPageRenderObservationState;\n createHtmlRenderObservation?: BuildAppPageCacheRenderObservation;\n createRscRenderObservation?: BuildAppPageCacheRenderObservation;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\n isrDebug?: AppPageDebugLogger;\n isrHtmlKey: (pathname: string) => string;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\ntype ScheduleAppPageRscCacheWriteOptions = {\n capturedRscDataPromise: Promise<ArrayBuffer> | null;\n cleanPathname: string;\n consumeDynamicUsage: () => boolean;\n consumeRenderObservationState?: () => AppPageRenderObservationState;\n createRscRenderObservation?: BuildAppPageCacheRenderObservation;\n dynamicUsedDuringBuild: boolean;\n getPageTags: () => string[];\n getRequestCacheLife?: () => AppPageRequestCacheLife | null;\n isrDebug?: AppPageDebugLogger;\n isrRscKey: (\n pathname: string,\n mountedSlotsHeader?: string | null,\n renderMode?: AppRscRenderMode,\n ) => string;\n isrSet: AppPageCacheSetter;\n mountedSlotsHeader?: string | null;\n renderMode?: AppRscRenderMode;\n preserveClientResponseHeaders?: boolean;\n expireSeconds?: number;\n revalidateSeconds: number | null;\n waitUntil?: (promise: Promise<void>) => void;\n};\n\nconst NO_STORE_CACHE_CONTROL = \"no-store, must-revalidate\";\n\nfunction recordAppPageCacheOutcome(\n recordCacheOutcome: AppPageCacheOutcomeRecorder | undefined,\n input: AppPageCacheOutcomeMetric,\n): void {\n try {\n recordCacheOutcome?.(input);\n } catch {\n // Metrics are observational only; telemetry failures must not alter cache serving behavior.\n }\n}\n\nexport function buildAppPageCacheTags(pathname: string, extraTags: readonly string[]): string[] {\n const tags = [pathname, `_N_T_${pathname}`, \"_N_T_/layout\"];\n const segments = pathname.split(\"/\");\n let built = \"\";\n for (let index = 1; index < segments.length; index++) {\n const segment = segments[index];\n if (segment) {\n built += `/${segment}`;\n tags.push(`_N_T_${built}/layout`);\n }\n }\n\n tags.push(`_N_T_${built}/page`);\n for (const tag of extraTags) {\n if (!tags.includes(tag)) {\n tags.push(tag);\n }\n }\n // Canonicalise to ASCII-safe form so path-derived tags from non-ASCII\n // pathnames match what `revalidatePath`/`revalidateTag` produce after\n // their own encoding pass.\n return tags.map(encodeCacheTag);\n}\n\nfunction buildAppPageCacheControl(\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"],\n revalidateSeconds: number,\n expireSeconds?: number,\n): string {\n return buildCachedRevalidateCacheControl(cacheState, revalidateSeconds, expireSeconds);\n}\n\nfunction buildAppPageCachedHeaders(options: {\n cacheControl: string;\n cacheState: BuildAppPageCachedResponseOptions[\"cacheState\"];\n contentType: string;\n middlewareHeaders?: Headers | null;\n mountedSlotsHeader?: string | null;\n}): Headers {\n const headers = new Headers({\n \"Cache-Control\": options.cacheControl,\n \"Content-Type\": options.contentType,\n Vary: VINEXT_RSC_VARY_HEADER,\n });\n setCacheStateHeaders(headers, options.cacheState);\n\n if (options.mountedSlotsHeader) {\n headers.set(VINEXT_MOUNTED_SLOTS_HEADER, options.mountedSlotsHeader);\n }\n\n mergeMiddlewareResponseHeaders(headers, options.middlewareHeaders ?? null);\n return headers;\n}\n\nfunction getCachedAppPageValue(entry: ISRCacheEntry | null): CachedAppPageValue | null {\n return entry?.value.value && entry.value.value.kind === \"APP_PAGE\" ? entry.value.value : null;\n}\n\nfunction resolveAppPageCacheWritePolicy(options: {\n expireSeconds?: number;\n requestCacheLife?: AppPageRequestCacheLife | null;\n revalidateSeconds: number | null;\n}): { expireSeconds?: number; revalidateSeconds: number } | null {\n let revalidateSeconds = options.revalidateSeconds;\n let expireSeconds = options.expireSeconds;\n const requestCacheLife = options.requestCacheLife;\n\n if (requestCacheLife?.revalidate !== undefined) {\n revalidateSeconds =\n revalidateSeconds === null\n ? requestCacheLife.revalidate\n : Math.min(revalidateSeconds, requestCacheLife.revalidate);\n }\n if (requestCacheLife?.expire !== undefined) {\n expireSeconds = requestCacheLife.expire;\n }\n\n if (revalidateSeconds === null || revalidateSeconds <= 0 || !Number.isFinite(revalidateSeconds)) {\n return null;\n }\n\n return { expireSeconds, revalidateSeconds };\n}\n\nexport function buildAppPageCachedResponse(\n cachedValue: CachedAppPageValue,\n options: BuildAppPageCachedResponseOptions,\n): Response | null {\n // Preserve the legacy fallback semantics from the generated entry: invalid\n // falsy statuses still fall back to 200 rather than being forwarded through.\n const status = options.middlewareStatus ?? (cachedValue.status || 200);\n const revalidateSeconds = options.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds =\n options.cacheControl === undefined\n ? undefined\n : (options.cacheControl.expire ?? options.expireSeconds);\n const cacheControl = buildAppPageCacheControl(\n options.cacheState,\n revalidateSeconds,\n expireSeconds,\n );\n if (options.isRscRequest) {\n if (!cachedValue.rscData) {\n return null;\n }\n\n const rscHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: VINEXT_RSC_CONTENT_TYPE,\n middlewareHeaders: options.middlewareHeaders,\n mountedSlotsHeader: options.mountedSlotsHeader,\n });\n applyRscCompatibilityIdHeader(rscHeaders);\n\n return new Response(cachedValue.rscData, {\n status,\n headers: rscHeaders,\n });\n }\n\n if (typeof cachedValue.html !== \"string\" || cachedValue.html.length === 0) {\n return null;\n }\n\n const htmlHeaders = buildAppPageCachedHeaders({\n cacheControl,\n cacheState: options.cacheState,\n contentType: \"text/html; charset=utf-8\",\n middlewareHeaders: options.middlewareHeaders,\n });\n\n return new Response(cachedValue.html, {\n status,\n headers: htmlHeaders,\n });\n}\n\nexport async function readAppPageCacheResponse(\n options: ReadAppPageCacheResponseOptions,\n): Promise<Response | null> {\n const isrKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n const artifact = options.isRscRequest ? \"rsc\" : \"html\";\n\n try {\n const cached = await options.isrGet(isrKey);\n const cachedValue = getCachedAppPageValue(cached);\n\n if (cached && !cachedValue) {\n recordAppPageCacheOutcome(options.recordCacheOutcome, {\n artifact,\n cacheKey: isrKey,\n outcome: \"miss\",\n reason: \"non-app-page-entry\",\n });\n options.isrDebug?.(\"MISS (non app-page cache entry)\", options.cleanPathname);\n return null;\n }\n\n if (cachedValue && !cached?.isStale) {\n const hitResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"HIT\",\n cacheControl: cached?.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (hitResponse) {\n recordAppPageCacheOutcome(options.recordCacheOutcome, {\n artifact,\n cacheKey: isrKey,\n outcome: \"hit\",\n reason: \"served\",\n });\n options.isrDebug?.(\n options.isRscRequest ? \"HIT (RSC)\" : \"HIT (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return hitResponse;\n }\n\n recordAppPageCacheOutcome(options.recordCacheOutcome, {\n artifact,\n cacheKey: isrKey,\n outcome: \"miss\",\n reason: \"empty-entry\",\n });\n options.isrDebug?.(\"MISS (empty cached entry)\", options.cleanPathname);\n }\n\n if (cached?.isStale && cachedValue) {\n const regenerationKey = options.isRscRequest\n ? options.isrRscKey(options.cleanPathname, options.mountedSlotsHeader, options.renderMode)\n : options.isrHtmlKey(options.cleanPathname);\n\n // Preserve the legacy behavior from the inline generator: stale entries\n // still trigger background regeneration even if this request cannot use\n // the stale payload and will fall through to a fresh render.\n options.scheduleBackgroundRegeneration(regenerationKey, async () => {\n const revalidatedPage = await options.renderFreshPageForCache();\n const revalidateSeconds =\n revalidatedPage.cacheControl?.revalidate ?? options.revalidateSeconds;\n const expireSeconds = revalidatedPage.cacheControl?.expire ?? options.expireSeconds;\n const writes = [\n options.isrSet(\n options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n ),\n buildAppPageCacheValue(\n \"\",\n revalidatedPage.rscData,\n 200,\n revalidatedPage.rscRenderObservation,\n ),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n ];\n\n if (!options.isRscRequest) {\n // HTML cache is slot-state-independent (canonical), so only refresh it\n // during HTML-triggered regens. RSC-triggered regens only update the\n // requesting client's RSC slot variant; a stale HTML cache entry will\n // be regenerated independently by the next full-page HTML request.\n writes.push(\n options.isrSet(\n options.isrHtmlKey(options.cleanPathname),\n buildAppPageCacheValue(\n revalidatedPage.html,\n undefined,\n 200,\n revalidatedPage.htmlRenderObservation,\n ),\n revalidateSeconds,\n revalidatedPage.tags,\n expireSeconds,\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"regen complete\", options.cleanPathname);\n });\n\n const staleResponse = buildAppPageCachedResponse(cachedValue, {\n cacheState: \"STALE\",\n cacheControl: cached.value.cacheControl,\n expireSeconds: options.expireSeconds,\n isRscRequest: options.isRscRequest,\n middlewareHeaders: options.middlewareHeaders,\n middlewareStatus: options.middlewareStatus,\n mountedSlotsHeader: options.mountedSlotsHeader,\n revalidateSeconds: options.revalidateSeconds,\n });\n\n if (staleResponse) {\n recordAppPageCacheOutcome(options.recordCacheOutcome, {\n artifact,\n cacheKey: isrKey,\n outcome: \"stale\",\n reason: \"served\",\n });\n options.isrDebug?.(\n options.isRscRequest ? \"STALE (RSC)\" : \"STALE (HTML)\",\n options.cleanPathname,\n );\n options.clearRequestContext();\n return staleResponse;\n }\n\n recordAppPageCacheOutcome(options.recordCacheOutcome, {\n artifact,\n cacheKey: isrKey,\n outcome: \"miss\",\n reason: \"stale-empty-entry\",\n });\n options.isrDebug?.(\"STALE MISS (empty stale entry)\", options.cleanPathname);\n }\n\n if (!cached) {\n recordAppPageCacheOutcome(options.recordCacheOutcome, {\n artifact,\n cacheKey: isrKey,\n outcome: \"miss\",\n reason: \"no-entry\",\n });\n options.isrDebug?.(\"MISS (no cache entry)\", options.cleanPathname);\n }\n } catch (isrReadError) {\n recordAppPageCacheOutcome(options.recordCacheOutcome, {\n artifact,\n cacheKey: isrKey,\n outcome: \"miss\",\n reason: \"read-error\",\n });\n console.error(\"[vinext] ISR cache read error:\", isrReadError);\n }\n\n return null;\n}\n\nexport function finalizeAppPageHtmlCacheResponse(\n response: Response,\n options: FinalizeAppPageHtmlCacheResponseOptions,\n): Response {\n if (!response.body) {\n return response;\n }\n\n const [streamForClient, streamForCache] = response.body.tee();\n const htmlKey = options.isrHtmlKey(options.cleanPathname);\n const rscKey = options.isrRscKey(options.cleanPathname, null);\n const clientHeaders = new Headers(response.headers);\n if (options.preserveClientResponseHeaders !== true) {\n // HTML Server Components can access request APIs while the stream is being\n // consumed. Until that late dynamic check finishes, downstream shared caches\n // must not cache a response whose ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n setCacheStateHeaders(clientHeaders, \"MISS\");\n }\n\n const cachePromise = (async () => {\n try {\n const cachedHtml = await readStreamAsText(streamForCache);\n\n if (\n options.capturedDynamicUsageBeforeContextCleanup?.() === true ||\n options.consumeDynamicUsage()\n ) {\n options.isrDebug?.(\"HTML cache write skipped (dynamic usage during render)\", htmlKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"HTML cache write skipped (no cache policy)\", htmlKey);\n return;\n }\n\n const pageTags = options.getPageTags();\n // This continuation is scheduled while the request ALS scope is active.\n // It intentionally consumes observation state only after the HTML stream\n // drains, so late Server Component request API usage is included.\n // Consume once: HTML and captured RSC artifacts come from the same render\n // pass, so both cache artifacts share the same observation snapshot.\n const observationState =\n options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();\n const htmlRenderObservation = options.createHtmlRenderObservation?.({\n cacheTags: pageTags,\n state: observationState,\n });\n const rscRenderObservation = options.createRscRenderObservation?.({\n cacheTags: pageTags,\n state: observationState,\n });\n const writes = [\n options.isrSet(\n htmlKey,\n buildAppPageCacheValue(cachedHtml, undefined, 200, htmlRenderObservation),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ];\n\n if (options.capturedRscDataPromise) {\n writes.push(\n options.capturedRscDataPromise.then((rscData) =>\n options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200, rscRenderObservation),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n ),\n ),\n );\n }\n\n await Promise.all(writes);\n options.isrDebug?.(\"HTML cache written\", htmlKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n\n return new Response(streamForClient, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function finalizeAppPageRscCacheResponse(\n response: Response,\n options: ScheduleAppPageRscCacheWriteOptions,\n): Response {\n const didSchedule = scheduleAppPageRscCacheWrite(options);\n if (!didSchedule) {\n return response;\n }\n\n if (options.preserveClientResponseHeaders === true) {\n return response;\n }\n\n const clientHeaders = new Headers(response.headers);\n // RSC payloads are also streamed lazily. Until the captured stream proves no\n // late request API was used, the client-facing MISS response must not enter a\n // shared cache when the ISR policy was known before streaming.\n clientHeaders.set(\"Cache-Control\", NO_STORE_CACHE_CONTROL);\n setCacheStateHeaders(clientHeaders, \"MISS\");\n\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: clientHeaders,\n });\n}\n\nexport function scheduleAppPageRscCacheWrite(\n options: ScheduleAppPageRscCacheWriteOptions,\n): boolean {\n const capturedRscDataPromise = options.capturedRscDataPromise;\n if (!capturedRscDataPromise || options.dynamicUsedDuringBuild) {\n return false;\n }\n\n const rscKey = options.isrRscKey(\n options.cleanPathname,\n options.mountedSlotsHeader,\n options.renderMode,\n );\n const cachePromise = (async () => {\n try {\n const rscData = await capturedRscDataPromise;\n\n // Two-phase dynamic detection:\n // 1. dynamicUsedDuringBuild catches searchParams-driven opt-in before the\n // RSC response is sent.\n // 2. consumeDynamicUsage() here catches APIs that fire while the RSC\n // stream is consumed (headers(), cookies(), noStore()).\n if (options.consumeDynamicUsage()) {\n options.isrDebug?.(\"RSC cache write skipped (dynamic usage during render)\", rscKey);\n return;\n }\n\n const cachePolicy = resolveAppPageCacheWritePolicy({\n expireSeconds: options.expireSeconds,\n requestCacheLife: options.getRequestCacheLife?.(),\n revalidateSeconds: options.revalidateSeconds,\n });\n if (!cachePolicy) {\n options.isrDebug?.(\"RSC cache write skipped (no cache policy)\", rscKey);\n return;\n }\n\n const pageTags = options.getPageTags();\n // This continuation is scheduled while the request ALS scope is active.\n // It intentionally consumes observation state only after the captured RSC\n // stream resolves, so late Server Component request API usage is included.\n const observationState =\n options.consumeRenderObservationState?.() ?? createEmptyAppPageRenderObservationState();\n const rscRenderObservation = options.createRscRenderObservation?.({\n cacheTags: pageTags,\n state: observationState,\n });\n await options.isrSet(\n rscKey,\n buildAppPageCacheValue(\"\", rscData, 200, rscRenderObservation),\n cachePolicy.revalidateSeconds,\n pageTags,\n cachePolicy.expireSeconds,\n );\n options.isrDebug?.(\"RSC cache written\", rscKey);\n } catch (cacheError) {\n console.error(\"[vinext] ISR RSC cache write error:\", cacheError);\n }\n })();\n\n options.waitUntil?.(cachePromise);\n return true;\n}\n"],"mappings":";;;;;;;;;;AAqJA,MAAM,yBAAyB;AAE/B,SAAS,0BACP,oBACA,OACM;CACN,IAAI;EACF,qBAAqB,MAAM;SACrB;;AAKV,SAAgB,sBAAsB,UAAkB,WAAwC;CAC9F,MAAM,OAAO;EAAC;EAAU,QAAQ;EAAY;EAAe;CAC3D,MAAM,WAAW,SAAS,MAAM,IAAI;CACpC,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS;EACpD,MAAM,UAAU,SAAS;EACzB,IAAI,SAAS;GACX,SAAS,IAAI;GACb,KAAK,KAAK,QAAQ,MAAM,SAAS;;;CAIrC,KAAK,KAAK,QAAQ,MAAM,OAAO;CAC/B,KAAK,MAAM,OAAO,WAChB,IAAI,CAAC,KAAK,SAAS,IAAI,EACrB,KAAK,KAAK,IAAI;CAMlB,OAAO,KAAK,IAAI,eAAe;;AAGjC,SAAS,yBACP,YACA,mBACA,eACQ;CACR,OAAO,kCAAkC,YAAY,mBAAmB,cAAc;;AAGxF,SAAS,0BAA0B,SAMvB;CACV,MAAM,UAAU,IAAI,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,gBAAgB,QAAQ;EACxB,MAAM;EACP,CAAC;CACF,qBAAqB,SAAS,QAAQ,WAAW;CAEjD,IAAI,QAAQ,oBACV,QAAQ,IAAI,6BAA6B,QAAQ,mBAAmB;CAGtE,+BAA+B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AAa;GAItC,MAAM,mBACJ,QAAQ,iCAAiC,IAAI,0CAA0C;GACzF,MAAM,uBAAuB,QAAQ,6BAA6B;IAChE,WAAW;IACX,OAAO;IACR,CAAC;GACF,MAAM,QAAQ,OACZ,QACA,uBAAuB,IAAI,SAAS,KAAK,qBAAqB,EAC9D,YAAY,mBACZ,UACA,YAAY,cACb;GACD,QAAQ,WAAW,qBAAqB,OAAO;WACxC,YAAY;GACnB,QAAQ,MAAM,uCAAuC,WAAW;;KAEhE;CAEJ,QAAQ,YAAY,aAAa;CACjC,OAAO"}
@@ -3,6 +3,7 @@ import { CachedAppPageValue } from "../shims/cache.js";
3
3
  import { AppOutgoingElements } from "./app-elements-wire.js";
4
4
  import { AppPageFontPreload, LayoutClassificationOptions } from "./app-page-execution.js";
5
5
  import { AppPageMiddlewareContext } from "./app-page-response.js";
6
+ import { RootParams } from "../shims/root-params.js";
6
7
  import { AppPageSsrHandler } from "./app-page-stream.js";
7
8
  import { AppRscRenderMode } from "./app-rsc-render-mode.js";
8
9
  import { ISRCacheEntry } from "./isr-cache.js";
@@ -29,6 +30,7 @@ type AppPageDispatchIntercept<TPage = unknown> = {
29
30
  interceptLayouts?: readonly AppPageModule[] | null;
30
31
  matchedParams: AppPageParams;
31
32
  page: TPage;
33
+ slotId?: string | null;
32
34
  slotKey: string;
33
35
  sourceRouteIndex: number;
34
36
  };
@@ -37,7 +39,9 @@ type AppPageDispatchInterceptOptions<TPage = unknown> = {
37
39
  interceptLayouts?: readonly AppPageModule[] | null;
38
40
  interceptPage: TPage;
39
41
  interceptParams: AppPageParams;
42
+ interceptSlotId?: string | null;
40
43
  interceptSlotKey: string;
44
+ interceptSourceMatchedUrl?: string | null;
41
45
  };
42
46
  type AppPageModule = {
43
47
  default?: unknown;
@@ -70,6 +74,8 @@ type DispatchAppPageOptions<TRoute extends AppPageDispatchRoute> = {
70
74
  fetchCache?: FetchCacheMode | null;
71
75
  findIntercept: (pathname: string) => AppPageDispatchIntercept | null;
72
76
  formState?: ReactFormState | null;
77
+ actionError?: unknown;
78
+ actionFailed?: boolean;
73
79
  generateStaticParams?: ValidateAppPageDynamicParamsOptions["generateStaticParams"];
74
80
  getFontLinks: () => string[];
75
81
  getFontPreloads: () => AppPageFontPreload[];
@@ -93,6 +99,7 @@ type DispatchAppPageOptions<TRoute extends AppPageDispatchRoute> = {
93
99
  middlewareContext: AppPageMiddlewareContext;
94
100
  mountedSlotsHeader?: string | null;
95
101
  params: AppPageParams;
102
+ rootParams?: RootParams;
96
103
  probeLayoutAt: (layoutIndex: number) => unknown;
97
104
  probePage: () => unknown;
98
105
  expireSeconds?: number;
@@ -1,24 +1,26 @@
1
1
  import { createRequestContext, runWithRequestContext } from "../shims/unified-request-context.js";
2
2
  import { getRequestExecutionContext } from "../shims/request-context.js";
3
- import { consumeDynamicUsage, consumeInvalidDynamicUsageError, getAndClearPendingCookies, getDraftModeCookieHeader, isDraftModeRequest, markDynamicUsage, setHeadersContext } from "../shims/headers.js";
3
+ import { consumeDynamicUsage, consumeInvalidDynamicUsageError, consumeRenderRequestApiUsage, getAndClearPendingCookies, getDraftModeCookieHeader, isDraftModeRequest, markDynamicUsage, peekRenderRequestApiUsage, setHeadersContext } from "../shims/headers.js";
4
4
  import { _consumeRequestScopedCacheLife, _peekRequestScopedCacheLife } from "../shims/cache.js";
5
5
  import { shouldSuppressLoadingBoundaries } from "./app-rsc-render-mode.js";
6
- import { ensureFetchPatch, getCollectedFetchTags, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags } from "../shims/fetch-cache.js";
6
+ import { consumeDynamicFetchObservations, ensureFetchPatch, getCollectedFetchTags, peekDynamicFetchObservations, runWithFetchDedupe, setCurrentFetchCacheMode, setCurrentFetchSoftTags } from "../shims/fetch-cache.js";
7
7
  import { AppElementsWire } from "./app-elements-wire.js";
8
8
  import "./app-elements.js";
9
- import { VINEXT_RSC_VARY_HEADER } from "./app-rsc-cache-busting.js";
9
+ import { VINEXT_RSC_CONTENT_TYPE, VINEXT_RSC_VARY_HEADER, applyRscCompatibilityIdHeader } from "./app-rsc-cache-busting.js";
10
10
  import { createAppPageTreePath } from "./app-page-route-wiring.js";
11
- import { readStreamAsText } from "../utils/text-stream.js";
12
11
  import { mergeMiddlewareResponseHeaders } from "./middleware-response-headers.js";
12
+ import { buildAppPageSpecialErrorResponse, resolveAppPageSpecialError, teeAppPageRscStreamForCapture } from "./app-page-execution.js";
13
13
  import { resolveAppPageParentHttpAccessBoundaryModule } from "./app-page-boundary.js";
14
+ import { readStreamAsText } from "../utils/text-stream.js";
15
+ import { createAppPageHtmlOutputScope, createAppPageRenderObservation, createAppPageRscOutputScope } from "./app-page-render-observation.js";
14
16
  import { readAppPageCacheResponse } from "./app-page-cache.js";
15
- import { buildAppPageSpecialErrorResponse, resolveAppPageSpecialError, teeAppPageRscStreamForCapture } from "./app-page-execution.js";
16
17
  import { resolveAppPageMethodResponse } from "./app-page-method.js";
17
18
  import { buildAppPageElement, resolveAppPageIntercept, validateAppPageDynamicParams } from "./app-page-request.js";
18
19
  import "./app-page-response.js";
19
20
  import { renderAppPageLifecycle } from "./app-page-render.js";
20
21
  import { createStaticGenerationHeadersContext } from "./app-static-generation.js";
21
22
  import { buildPageCacheTags } from "./implicit-tags.js";
23
+ import React from "react";
22
24
  //#region src/server/app-page-dispatch.ts
23
25
  function shouldReadAppPageCache(options) {
24
26
  return options.isProduction && !options.isProgressiveActionRender && !options.isDraftMode && !options.isForceDynamic && (options.isRscRequest || !options.scriptNonce) && (options.revalidateSeconds === null || options.revalidateSeconds > 0);
@@ -57,7 +59,9 @@ function toInterceptOptions(interceptionContext, intercept) {
57
59
  interceptLayouts: intercept.interceptLayouts,
58
60
  interceptPage: intercept.page,
59
61
  interceptParams: intercept.matchedParams,
60
- interceptSlotKey: intercept.slotKey
62
+ interceptSlotId: intercept.slotId ?? null,
63
+ interceptSlotKey: intercept.slotKey,
64
+ interceptSourceMatchedUrl: interceptionContext
61
65
  };
62
66
  }
63
67
  async function dispatchAppPage(options) {
@@ -143,17 +147,57 @@ async function dispatchAppPageInner(options) {
143
147
  links: options.getFontLinks(),
144
148
  styles: options.getFontStyles(),
145
149
  preloads: options.getFontPreloads()
146
- }, revalidatedRscCapture.sideStream ? {
147
- sideStream: revalidatedRscCapture.sideStream,
148
- capturedRscDataRef: revalidatedCapturedRscRef
149
- } : void 0));
150
+ }, {
151
+ basePath: options.basePath,
152
+ rootParams: options.rootParams,
153
+ ...revalidatedRscCapture.sideStream ? {
154
+ sideStream: revalidatedRscCapture.sideStream,
155
+ capturedRscDataRef: revalidatedCapturedRscRef
156
+ } : {}
157
+ }));
150
158
  const rscData = await getCapturedRscDataPromise(revalidatedCapturedRscRef.value);
151
159
  const cacheLife = _consumeRequestScopedCacheLife();
152
160
  options.clearRequestContext();
161
+ const tags = buildAppPageTags(options.cleanPathname, getCollectedFetchTags(), route.routeSegments);
162
+ const observationState = {
163
+ dynamicFetches: consumeDynamicFetchObservations(),
164
+ requestApis: consumeRenderRequestApiUsage()
165
+ };
153
166
  return {
154
167
  html,
168
+ htmlRenderObservation: createAppPageRenderObservation({
169
+ boundaryOutcome: { kind: "success" },
170
+ cacheability: "public",
171
+ cacheTags: tags,
172
+ cleanPathname: options.cleanPathname,
173
+ completeness: "complete",
174
+ output: createAppPageHtmlOutputScope({
175
+ element: revalidatedElement,
176
+ renderEpoch: null,
177
+ rootBoundaryId: null,
178
+ routePattern: route.pattern
179
+ }),
180
+ params: options.params,
181
+ state: observationState
182
+ }),
155
183
  rscData,
156
- tags: buildAppPageTags(options.cleanPathname, getCollectedFetchTags(), route.routeSegments),
184
+ rscRenderObservation: createAppPageRenderObservation({
185
+ boundaryOutcome: { kind: "success" },
186
+ cacheability: "public",
187
+ cacheTags: tags,
188
+ cleanPathname: options.cleanPathname,
189
+ completeness: "complete",
190
+ output: createAppPageRscOutputScope({
191
+ element: revalidatedElement,
192
+ mountedSlotsHeader: options.mountedSlotsHeader,
193
+ renderEpoch: null,
194
+ rootBoundaryId: null,
195
+ routePattern: route.pattern
196
+ }),
197
+ params: options.params,
198
+ state: observationState
199
+ }),
200
+ tags,
157
201
  cacheControl: typeof cacheLife?.revalidate === "number" ? {
158
202
  revalidate: cacheLife.revalidate,
159
203
  expire: cacheLife.expire
@@ -199,10 +243,11 @@ async function dispatchAppPageInner(options) {
199
243
  const interceptOnError = options.createRscOnErrorHandler(options.cleanPathname, sourceRoute.pattern);
200
244
  const interceptStream = options.renderToReadableStream(interceptElement, { onError: interceptOnError });
201
245
  const interceptHeaders = new Headers({
202
- "Content-Type": "text/x-component; charset=utf-8",
246
+ "Content-Type": VINEXT_RSC_CONTENT_TYPE,
203
247
  Vary: VINEXT_RSC_VARY_HEADER
204
248
  });
205
249
  mergeMiddlewareResponseHeaders(interceptHeaders, options.middlewareContext.headers);
250
+ applyRscCompatibilityIdHeader(interceptHeaders);
206
251
  return new Response(interceptStream, {
207
252
  status: options.middlewareContext.status ?? 200,
208
253
  headers: interceptHeaders
@@ -217,6 +262,7 @@ async function dispatchAppPageInner(options) {
217
262
  if (interceptResult.response) return interceptResult.response;
218
263
  const pageBuildResult = await buildAppPageElement({
219
264
  buildPageElement() {
265
+ if (options.actionFailed) throw options.actionError;
220
266
  return options.buildPageElement(route, options.params, interceptResult.interceptOpts, options.searchParams);
221
267
  },
222
268
  renderErrorBoundaryPage(buildError) {
@@ -229,10 +275,17 @@ async function dispatchAppPageInner(options) {
229
275
  });
230
276
  if (pageBuildResult.response) return pageBuildResult.response;
231
277
  return renderAppPageLifecycle({
278
+ basePath: options.basePath,
232
279
  cleanPathname: options.cleanPathname,
233
280
  clearRequestContext: options.clearRequestContext,
234
281
  consumeDynamicUsage,
235
282
  consumeInvalidDynamicUsageError,
283
+ consumeRenderObservationState() {
284
+ return {
285
+ dynamicFetches: consumeDynamicFetchObservations(),
286
+ requestApis: consumeRenderRequestApiUsage()
287
+ };
288
+ },
236
289
  createRscOnErrorHandler(pathname, routePath) {
237
290
  return options.createRscOnErrorHandler(pathname, routePath);
238
291
  },
@@ -271,6 +324,13 @@ async function dispatchAppPageInner(options) {
271
324
  loadSsrHandler: options.loadSsrHandler,
272
325
  middlewareContext: options.middlewareContext,
273
326
  params: options.params,
327
+ rootParams: options.rootParams,
328
+ peekRenderObservationState() {
329
+ return {
330
+ dynamicFetches: peekDynamicFetchObservations(),
331
+ requestApis: peekRenderRequestApiUsage()
332
+ };
333
+ },
274
334
  probeLayoutAt(layoutIndex) {
275
335
  return options.probeLayoutAt(layoutIndex);
276
336
  },
@@ -322,9 +382,32 @@ async function dispatchAppPageInner(options) {
322
382
  }
323
383
  });
324
384
  }
385
+ /**
386
+ * Builds an RSC flight payload that encodes a redirect as a React error chunk.
387
+ * We render a tiny element that immediately throws an `Error` whose `digest`
388
+ * is the canonical `NEXT_REDIRECT;...` string. `renderToReadableStream`'s
389
+ * `onError` returns that digest, react-server-dom-webpack serializes the
390
+ * error into the stream, and the client's `RedirectErrorBoundary` decodes it
391
+ * via `getURLFromRedirectError` / `getRedirectTypeFromError`.
392
+ *
393
+ * The thrown error's digest matches Next.js's well-known router error format,
394
+ * so neither vinext's RSC error handler nor Next.js's reporter logs it as a
395
+ * "real" server error. Mirrors `app-render.tsx generateDynamicFlightRenderResult`
396
+ * where a redirect thrown during RSC rendering propagates through
397
+ * `renderToFlightStream`'s `onError` callback into the flight payload.
398
+ */
399
+ function buildRscRedirectFlightStream(options, digest) {
400
+ const throwingElement = React.createElement(function NextRedirectFlightThrower() {
401
+ const err = /* @__PURE__ */ new Error("NEXT_REDIRECT");
402
+ err.digest = digest;
403
+ throw err;
404
+ });
405
+ return options.renderToReadableStream(throwingElement, { onError: () => digest });
406
+ }
325
407
  async function renderLayoutSpecialError(options, specialError, layoutIndex) {
326
408
  return buildAppPageSpecialErrorResponse({
327
409
  basePath: options.basePath,
410
+ buildRscRedirectFlightStream: (rscOptions) => buildRscRedirectFlightStream(options, rscOptions.digest),
328
411
  clearRequestContext: options.clearRequestContext,
329
412
  getAndClearPendingCookies,
330
413
  isRscRequest: options.isRscRequest,
@@ -353,6 +436,7 @@ async function renderLayoutSpecialError(options, specialError, layoutIndex) {
353
436
  async function renderPageSpecialError(options, specialError) {
354
437
  return buildAppPageSpecialErrorResponse({
355
438
  basePath: options.basePath,
439
+ buildRscRedirectFlightStream: (rscOptions) => buildRscRedirectFlightStream(options, rscOptions.digest),
356
440
  clearRequestContext: options.clearRequestContext,
357
441
  getAndClearPendingCookies,
358
442
  isRscRequest: options.isRscRequest,