vinext 1.0.0-beta.3 → 1.0.0-beta.5

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 (436) hide show
  1. package/README.md +44 -3
  2. package/dist/build/client-build-config.d.ts +0 -1
  3. package/dist/build/css-url-assets.d.ts +0 -1
  4. package/dist/build/google-fonts/build-url.d.ts +5 -2
  5. package/dist/build/google-fonts/font-metadata.d.ts +7 -3
  6. package/dist/build/google-fonts/get-axes.d.ts +0 -1
  7. package/dist/build/layout-classification.d.ts +7 -4
  8. package/dist/build/next-client-runtime-manifests.d.ts +0 -1
  9. package/dist/build/next-client-runtime-manifests.js +2 -19
  10. package/dist/build/nitro-route-rules.d.ts +0 -1
  11. package/dist/build/pages-client-assets-module.d.ts +0 -1
  12. package/dist/build/precompress.d.ts +7 -2
  13. package/dist/build/precompress.js +42 -8
  14. package/dist/build/prerender-paths.d.ts +2 -2
  15. package/dist/build/prerender-server-entry.d.ts +1 -1
  16. package/dist/build/prerender-server-pool.d.ts +4 -2
  17. package/dist/build/prerender.d.ts +36 -32
  18. package/dist/build/prerender.js +18 -3
  19. package/dist/build/public-dir-conflict.d.ts +14 -0
  20. package/dist/build/public-dir-conflict.js +25 -0
  21. package/dist/build/report.d.ts +2 -2
  22. package/dist/build/route-classification-injector.d.ts +0 -1
  23. package/dist/build/route-classification-manifest.d.ts +5 -3
  24. package/dist/build/run-prerender.d.ts +3 -2
  25. package/dist/build/static-export.d.ts +23 -12
  26. package/dist/cache/cache-adapters-virtual.d.ts +5 -2
  27. package/dist/check.js +4 -4
  28. package/dist/cli-args.d.ts +2 -1
  29. package/dist/cli-args.js +10 -0
  30. package/dist/cli-dev-config.d.ts +0 -1
  31. package/dist/cli.d.ts +1 -1
  32. package/dist/cli.js +14 -8
  33. package/dist/client/client-rewrite-matcher.d.ts +12 -0
  34. package/dist/client/client-rewrite-matcher.js +20 -0
  35. package/dist/client/client-rewrites.d.ts +31 -0
  36. package/dist/client/client-rewrites.js +41 -0
  37. package/dist/client/dev-error-overlay.d.ts +0 -1
  38. package/dist/client/empty-module.d.ts +1 -1
  39. package/dist/client/index.d.ts +2 -0
  40. package/dist/client/index.js +2 -0
  41. package/dist/client/instrumentation-client-state.d.ts +0 -1
  42. package/dist/client/navigation-runtime.d.ts +12 -1
  43. package/dist/client/navigation-runtime.js +6 -2
  44. package/dist/client/pages-router-link-navigation.d.ts +3 -21
  45. package/dist/client/react-instance-bootstrap.d.ts +1 -0
  46. package/dist/client/react-instance-bootstrap.js +7 -0
  47. package/dist/client/react-instance.d.ts +13 -0
  48. package/dist/client/react-instance.js +20 -0
  49. package/dist/client/vinext-next-data.d.ts +11 -6
  50. package/dist/client/window-next.d.ts +5 -2
  51. package/dist/config/config-matchers.d.ts +3 -5
  52. package/dist/config/config-matchers.js +7 -6
  53. package/dist/config/dotenv.d.ts +4 -9
  54. package/dist/config/dotenv.js +30 -22
  55. package/dist/config/next-config.d.ts +113 -52
  56. package/dist/config/next-config.js +6 -0
  57. package/dist/config/prerender.d.ts +0 -1
  58. package/dist/entries/app-browser-entry.d.ts +0 -1
  59. package/dist/entries/app-browser-entry.js +7 -3
  60. package/dist/entries/app-rsc-entry.d.ts +30 -16
  61. package/dist/entries/app-rsc-entry.js +40 -12
  62. package/dist/entries/app-rsc-manifest.d.ts +0 -1
  63. package/dist/entries/app-rsc-manifest.js +1 -0
  64. package/dist/entries/pages-client-entry.d.ts +0 -1
  65. package/dist/entries/pages-client-entry.js +7 -2
  66. package/dist/entries/pages-server-entry.d.ts +1 -2
  67. package/dist/entries/pages-server-entry.js +25 -6
  68. package/dist/image/image-adapters-virtual.d.ts +4 -2
  69. package/dist/index.d.ts +0 -1
  70. package/dist/index.js +257 -75
  71. package/dist/init-cloudflare.d.ts +0 -1
  72. package/dist/init-platform.d.ts +0 -1
  73. package/dist/init.d.ts +40 -20
  74. package/dist/plugins/ast-scope.d.ts +0 -1
  75. package/dist/plugins/async-hooks-stub.d.ts +0 -1
  76. package/dist/plugins/client-reference-dedup.d.ts +0 -1
  77. package/dist/plugins/client-reference-dedup.js +7 -5
  78. package/dist/plugins/css-data-url.d.ts +0 -1
  79. package/dist/plugins/css-module-imports.d.ts +0 -1
  80. package/dist/plugins/dynamic-preload-metadata.d.ts +0 -1
  81. package/dist/plugins/extensionless-dynamic-import.d.ts +0 -1
  82. package/dist/plugins/extensionless-dynamic-import.js +352 -13
  83. package/dist/plugins/fonts.d.ts +0 -1
  84. package/dist/plugins/ignore-dynamic-requests.d.ts +0 -1
  85. package/dist/plugins/ignore-dynamic-requests.js +28 -4
  86. package/dist/plugins/import-meta-url.d.ts +0 -1
  87. package/dist/plugins/instrumentation-client.d.ts +0 -1
  88. package/dist/plugins/middleware-server-only.d.ts +0 -1
  89. package/dist/plugins/og-asset-ownership.d.ts +0 -1
  90. package/dist/plugins/og-assets.d.ts +0 -1
  91. package/dist/plugins/optimize-imports.d.ts +0 -1
  92. package/dist/plugins/remove-console.d.ts +0 -1
  93. package/dist/plugins/require-context.d.ts +0 -1
  94. package/dist/plugins/require-context.js +143 -26
  95. package/dist/plugins/rsc-client-reference-loaders.d.ts +0 -1
  96. package/dist/plugins/rsc-reference-validation-normalizer.d.ts +0 -1
  97. package/dist/plugins/sass.d.ts +30 -2
  98. package/dist/plugins/sass.js +67 -5
  99. package/dist/plugins/server-externals-manifest.d.ts +0 -1
  100. package/dist/plugins/strip-server-exports.d.ts +0 -1
  101. package/dist/plugins/styled-jsx.d.ts +0 -1
  102. package/dist/plugins/wasm-module-import.d.ts +0 -1
  103. package/dist/routing/app-route-graph.d.ts +115 -56
  104. package/dist/routing/app-route-graph.js +2 -1
  105. package/dist/routing/app-router.d.ts +0 -1
  106. package/dist/routing/pages-router.d.ts +9 -5
  107. package/dist/routing/route-matching.d.ts +0 -1
  108. package/dist/routing/utils.d.ts +1 -23
  109. package/dist/routing/utils.js +1 -30
  110. package/dist/server/accept-encoding.d.ts +0 -1
  111. package/dist/server/api-handler.d.ts +0 -1
  112. package/dist/server/api-handler.js +4 -3
  113. package/dist/server/app-bfcache-identity.d.ts +9 -10
  114. package/dist/server/app-bfcache-identity.js +27 -102
  115. package/dist/server/app-browser-action-result.d.ts +0 -1
  116. package/dist/server/app-browser-client-reuse-manifest.d.ts +0 -1
  117. package/dist/server/app-browser-entry.d.ts +1 -1
  118. package/dist/server/app-browser-entry.js +106 -66
  119. package/dist/server/app-browser-history-controller.d.ts +8 -5
  120. package/dist/server/app-browser-hydration.d.ts +0 -1
  121. package/dist/server/app-browser-interception-context.d.ts +0 -1
  122. package/dist/server/app-browser-mpa-navigation.d.ts +0 -1
  123. package/dist/server/app-browser-navigation-controller.d.ts +3 -6
  124. package/dist/server/app-browser-navigation-controller.js +29 -4
  125. package/dist/server/app-browser-popstate.d.ts +0 -1
  126. package/dist/server/app-browser-prefetch-response.d.ts +25 -0
  127. package/dist/server/app-browser-prefetch-response.js +54 -0
  128. package/dist/server/app-browser-server-action-client.d.ts +1 -1
  129. package/dist/server/app-browser-server-action-client.js +3 -2
  130. package/dist/server/app-browser-server-action-navigation.d.ts +0 -1
  131. package/dist/server/app-browser-state.d.ts +11 -5
  132. package/dist/server/app-browser-state.js +10 -6
  133. package/dist/server/app-browser-stream.d.ts +0 -1
  134. package/dist/server/app-browser-visible-commit.d.ts +1 -1
  135. package/dist/server/app-browser-visible-commit.js +6 -2
  136. package/dist/server/app-elements-wire.d.ts +16 -13
  137. package/dist/server/app-elements-wire.js +37 -10
  138. package/dist/server/app-elements.d.ts +2 -3
  139. package/dist/server/app-elements.js +2 -2
  140. package/dist/server/app-fallback-renderer.d.ts +8 -4
  141. package/dist/server/app-fallback-renderer.js +2 -1
  142. package/dist/server/app-history-state.d.ts +2 -2
  143. package/dist/server/app-history-state.js +1 -1
  144. package/dist/server/app-hook-warning-suppression.d.ts +0 -1
  145. package/dist/server/app-layout-param-observation.d.ts +0 -1
  146. package/dist/server/app-layout-param-observation.js +1 -1
  147. package/dist/server/app-middleware.d.ts +5 -1
  148. package/dist/server/app-middleware.js +96 -31
  149. package/dist/server/app-optimistic-routing.d.ts +1 -0
  150. package/dist/server/app-page-boundary-render.d.ts +8 -4
  151. package/dist/server/app-page-cache-finalizer.d.ts +2 -3
  152. package/dist/server/app-page-cache-finalizer.js +47 -17
  153. package/dist/server/app-page-cache-render.d.ts +2 -2
  154. package/dist/server/app-page-cache-render.js +2 -1
  155. package/dist/server/app-page-cache.d.ts +1 -3
  156. package/dist/server/app-page-cache.js +22 -11
  157. package/dist/server/app-page-dispatch.d.ts +12 -6
  158. package/dist/server/app-page-dispatch.js +14 -6
  159. package/dist/server/app-page-element-builder.d.ts +63 -20
  160. package/dist/server/app-page-element-builder.js +114 -43
  161. package/dist/server/app-page-execution.d.ts +12 -5
  162. package/dist/server/app-page-execution.js +1 -1
  163. package/dist/server/app-page-head.d.ts +2 -2
  164. package/dist/server/app-page-http-access-fallback-metadata.d.ts +2 -2
  165. package/dist/server/app-page-params.d.ts +0 -1
  166. package/dist/server/app-page-ppr-runtime.d.ts +0 -1
  167. package/dist/server/app-page-probe.d.ts +4 -3
  168. package/dist/server/app-page-probe.js +1 -1
  169. package/dist/server/app-page-render-identity.d.ts +1 -0
  170. package/dist/server/app-page-render-observation.d.ts +0 -1
  171. package/dist/server/app-page-render.d.ts +7 -5
  172. package/dist/server/app-page-render.js +59 -24
  173. package/dist/server/app-page-request.d.ts +3 -2
  174. package/dist/server/app-page-request.js +6 -46
  175. package/dist/server/app-page-response.d.ts +15 -3
  176. package/dist/server/app-page-response.js +21 -3
  177. package/dist/server/app-page-route-wiring.d.ts +30 -7
  178. package/dist/server/app-page-route-wiring.js +163 -63
  179. package/dist/server/app-page-search-params-observation.d.ts +0 -1
  180. package/dist/server/app-page-segment-plan.d.ts +56 -0
  181. package/dist/server/app-page-segment-plan.js +177 -0
  182. package/dist/server/app-page-segment-state.d.ts +18 -2
  183. package/dist/server/app-page-segment-state.js +23 -4
  184. package/dist/server/app-page-stream.d.ts +19 -10
  185. package/dist/server/app-pages-bridge.d.ts +2 -2
  186. package/dist/server/app-pages-bridge.js +14 -2
  187. package/dist/server/app-post-middleware-context.d.ts +0 -1
  188. package/dist/server/app-ppr-fallback-shell-render.d.ts +0 -1
  189. package/dist/server/app-prerender-endpoints.d.ts +0 -1
  190. package/dist/server/app-prerender-static-params.d.ts +0 -1
  191. package/dist/server/app-render-dependency.d.ts +11 -4
  192. package/dist/server/app-render-dependency.js +59 -9
  193. package/dist/server/app-request-context.d.ts +1 -0
  194. package/dist/server/app-route-handler-cache.d.ts +2 -2
  195. package/dist/server/app-route-handler-cache.js +5 -1
  196. package/dist/server/app-route-handler-dispatch.d.ts +0 -1
  197. package/dist/server/app-route-handler-execution.d.ts +2 -2
  198. package/dist/server/app-route-handler-execution.js +5 -1
  199. package/dist/server/app-route-handler-policy.d.ts +0 -1
  200. package/dist/server/app-route-handler-response.d.ts +0 -1
  201. package/dist/server/app-route-handler-runtime.d.ts +0 -1
  202. package/dist/server/app-route-handler-runtime.js +1 -2
  203. package/dist/server/app-route-module-loader.d.ts +32 -6
  204. package/dist/server/app-route-module-loader.js +73 -3
  205. package/dist/server/app-router-entry.d.ts +0 -1
  206. package/dist/server/app-router-entry.js +2 -2
  207. package/dist/server/app-rsc-cache-busting.d.ts +7 -1
  208. package/dist/server/app-rsc-cache-busting.js +6 -0
  209. package/dist/server/app-rsc-handler.d.ts +9 -2
  210. package/dist/server/app-rsc-handler.js +173 -41
  211. package/dist/server/app-rsc-redirect-flight.d.ts +0 -1
  212. package/dist/server/app-rsc-render-mode.d.ts +3 -2
  213. package/dist/server/app-rsc-render-mode.js +4 -1
  214. package/dist/server/app-rsc-request-normalization.d.ts +19 -10
  215. package/dist/server/app-rsc-request-normalization.js +65 -4
  216. package/dist/server/app-rsc-response-finalizer.d.ts +5 -2
  217. package/dist/server/app-rsc-response-finalizer.js +31 -18
  218. package/dist/server/app-rsc-route-matching.d.ts +6 -1
  219. package/dist/server/app-rsc-route-matching.js +47 -2
  220. package/dist/server/app-segment-config.d.ts +0 -1
  221. package/dist/server/app-server-action-execution.d.ts +42 -9
  222. package/dist/server/app-server-action-execution.js +189 -111
  223. package/dist/server/app-ssr-entry.d.ts +5 -3
  224. package/dist/server/app-ssr-entry.js +4 -5
  225. package/dist/server/app-ssr-router-instance.d.ts +0 -1
  226. package/dist/server/app-ssr-stream.d.ts +7 -1
  227. package/dist/server/app-ssr-stream.js +2 -1
  228. package/dist/server/app-static-generation.d.ts +0 -1
  229. package/dist/server/app-visited-response-cache.d.ts +7 -2
  230. package/dist/server/app-visited-response-cache.js +49 -1
  231. package/dist/server/before-interactive-head.d.ts +0 -1
  232. package/dist/server/before-interactive-head.js +2 -0
  233. package/dist/server/bfcache-identity.d.ts +45 -0
  234. package/dist/server/bfcache-identity.js +52 -0
  235. package/dist/server/cache-control.d.ts +3 -3
  236. package/dist/server/cache-control.js +3 -2
  237. package/dist/server/cache-proof.d.ts +0 -1
  238. package/dist/server/client-reuse-manifest.d.ts +0 -1
  239. package/dist/server/config-headers.d.ts +2 -2
  240. package/dist/server/csp.d.ts +0 -1
  241. package/dist/server/default-global-error-module.d.ts +0 -1
  242. package/dist/server/default-global-not-found-module.d.ts +0 -1
  243. package/dist/server/default-not-found-module.d.ts +0 -1
  244. package/dist/server/dev-lockfile.d.ts +21 -9
  245. package/dist/server/dev-module-runner.d.ts +0 -1
  246. package/dist/server/dev-route-files.d.ts +0 -1
  247. package/dist/server/dev-server.d.ts +4 -8
  248. package/dist/server/dev-server.js +86 -131
  249. package/dist/server/dev-stack-sourcemap.d.ts +0 -1
  250. package/dist/server/document-initial-head.d.ts +12 -2
  251. package/dist/server/document-initial-head.js +17 -2
  252. package/dist/server/edge-api-runtime.d.ts +10 -1
  253. package/dist/server/edge-api-runtime.js +29 -1
  254. package/dist/server/file-based-metadata.d.ts +0 -1
  255. package/dist/server/headers.d.ts +17 -2
  256. package/dist/server/headers.js +17 -1
  257. package/dist/server/http-conditional.d.ts +22 -0
  258. package/dist/server/http-conditional.js +117 -0
  259. package/dist/server/http-date.d.ts +5 -0
  260. package/dist/server/http-date.js +73 -0
  261. package/dist/server/http-error-responses.d.ts +2 -1
  262. package/dist/server/http-error-responses.js +14 -2
  263. package/dist/server/http-range.d.ts +25 -0
  264. package/dist/server/http-range.js +67 -0
  265. package/dist/server/image-optimization.d.ts +14 -6
  266. package/dist/server/image-optimization.js +0 -1
  267. package/dist/server/instrumentation.d.ts +7 -4
  268. package/dist/server/isr-cache.d.ts +28 -6
  269. package/dist/server/isr-cache.js +19 -13
  270. package/dist/server/isr-decision.d.ts +6 -4
  271. package/dist/server/metadata-route-build-data.d.ts +0 -1
  272. package/dist/server/metadata-route-response.d.ts +0 -1
  273. package/dist/server/metadata-route-response.js +7 -6
  274. package/dist/server/metadata-routes.d.ts +34 -16
  275. package/dist/server/middleware-matcher-pattern.d.ts +0 -1
  276. package/dist/server/middleware-matcher.d.ts +8 -3
  277. package/dist/server/middleware-matcher.js +23 -18
  278. package/dist/server/middleware-runtime.d.ts +6 -1
  279. package/dist/server/middleware-runtime.js +91 -28
  280. package/dist/server/middleware.d.ts +0 -1
  281. package/dist/server/navigation-planner.d.ts +1 -1
  282. package/dist/server/next-error-digest.d.ts +0 -1
  283. package/dist/server/pages-api-route.d.ts +2 -1
  284. package/dist/server/pages-api-route.js +32 -7
  285. package/dist/server/pages-asset-tags.d.ts +3 -1
  286. package/dist/server/pages-asset-tags.js +6 -4
  287. package/dist/server/pages-data-route.d.ts +14 -6
  288. package/dist/server/pages-data-route.js +19 -10
  289. package/dist/server/pages-dev-hydration.js +3 -0
  290. package/dist/server/pages-dev-stylesheets.d.ts +10 -0
  291. package/dist/server/pages-dev-stylesheets.js +150 -0
  292. package/dist/server/pages-document-asset-props.d.ts +26 -0
  293. package/dist/server/pages-document-asset-props.js +69 -0
  294. package/dist/server/pages-document-initial-props.d.ts +10 -6
  295. package/dist/server/pages-get-initial-props.d.ts +2 -2
  296. package/dist/server/pages-i18n.d.ts +1 -7
  297. package/dist/server/pages-node-compat.d.ts +11 -2
  298. package/dist/server/pages-node-compat.js +52 -5
  299. package/dist/server/pages-page-data.d.ts +21 -9
  300. package/dist/server/pages-page-data.js +109 -30
  301. package/dist/server/pages-page-handler.d.ts +70 -32
  302. package/dist/server/pages-page-handler.js +25 -6
  303. package/dist/server/pages-page-response.d.ts +9 -13
  304. package/dist/server/pages-page-response.js +25 -26
  305. package/dist/server/pages-readiness.d.ts +0 -1
  306. package/dist/server/pages-request-pipeline.d.ts +20 -6
  307. package/dist/server/pages-request-pipeline.js +40 -20
  308. package/dist/server/pages-revalidate.d.ts +0 -1
  309. package/dist/server/pages-revalidate.js +1 -1
  310. package/dist/server/pages-router-entry.js +14 -10
  311. package/dist/server/prerender-manifest.d.ts +7 -0
  312. package/dist/server/prod-server.d.ts +13 -7
  313. package/dist/server/prod-server.js +276 -83
  314. package/dist/server/proxy-trust.d.ts +0 -1
  315. package/dist/server/request-log.d.ts +7 -11
  316. package/dist/server/request-pipeline.d.ts +13 -4
  317. package/dist/server/request-pipeline.js +28 -20
  318. package/dist/server/revalidation-host.d.ts +0 -1
  319. package/dist/server/revalidation-host.js +1 -1
  320. package/dist/server/rsc-completion-metadata.d.ts +15 -0
  321. package/dist/server/rsc-completion-metadata.js +183 -0
  322. package/dist/server/seed-cache.d.ts +2 -1
  323. package/dist/server/seed-cache.js +8 -5
  324. package/dist/server/skip-cache-proof.d.ts +0 -1
  325. package/dist/server/static-file-cache.d.ts +23 -9
  326. package/dist/server/static-file-cache.js +47 -23
  327. package/dist/server/static-layout-client-reuse-proof.d.ts +0 -1
  328. package/dist/server/worker-revalidation-context.d.ts +0 -1
  329. package/dist/server/worker-revalidation-context.js +1 -0
  330. package/dist/server/worker-utils.d.ts +3 -1
  331. package/dist/server/worker-utils.js +11 -2
  332. package/dist/shims/app-router-scroll-state.d.ts +2 -1
  333. package/dist/shims/app-router-scroll-state.js +7 -2
  334. package/dist/shims/app-router-scroll.d.ts +2 -8
  335. package/dist/shims/app.d.ts +1 -5
  336. package/dist/shims/before-interactive-context.d.ts +5 -3
  337. package/dist/shims/cache-handler.d.ts +6 -1
  338. package/dist/shims/cache-handler.js +4 -2
  339. package/dist/shims/cache-request-state.d.ts +12 -1
  340. package/dist/shims/cache-request-state.js +22 -1
  341. package/dist/shims/cache-runtime.d.ts +9 -5
  342. package/dist/shims/cache-runtime.js +16 -6
  343. package/dist/shims/cache.d.ts +2 -3
  344. package/dist/shims/cache.js +2 -2
  345. package/dist/shims/cdn-cache.d.ts +0 -1
  346. package/dist/shims/client-locale.d.ts +1 -6
  347. package/dist/shims/client-only.d.ts +1 -1
  348. package/dist/shims/compat-router.d.ts +0 -1
  349. package/dist/shims/constants.d.ts +1 -1
  350. package/dist/shims/default-global-error.d.ts +1 -4
  351. package/dist/shims/default-not-found.d.ts +0 -1
  352. package/dist/shims/document.d.ts +0 -1
  353. package/dist/shims/document.js +17 -3
  354. package/dist/shims/dynamic-preload-chunks.d.ts +0 -1
  355. package/dist/shims/dynamic.d.ts +0 -1
  356. package/dist/shims/error-boundary-navigation.d.ts +0 -1
  357. package/dist/shims/error-boundary.d.ts +7 -32
  358. package/dist/shims/error.d.ts +1 -6
  359. package/dist/shims/fetch-cache.js +112 -63
  360. package/dist/shims/font-google-base.d.ts +0 -1
  361. package/dist/shims/font-local.d.ts +0 -1
  362. package/dist/shims/form.d.ts +5 -3
  363. package/dist/shims/hash-scroll.d.ts +1 -1
  364. package/dist/shims/hash-scroll.js +2 -1
  365. package/dist/shims/head-state.d.ts +0 -1
  366. package/dist/shims/head.d.ts +1 -4
  367. package/dist/shims/headers.d.ts +2 -2
  368. package/dist/shims/headers.js +1 -1
  369. package/dist/shims/i18n-context.d.ts +0 -1
  370. package/dist/shims/i18n-state.d.ts +0 -1
  371. package/dist/shims/image.d.ts +0 -1
  372. package/dist/shims/image.js +1 -2
  373. package/dist/shims/internal/als-registry.d.ts +31 -2
  374. package/dist/shims/internal/als-registry.js +50 -2
  375. package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +17 -2
  376. package/dist/shims/internal/app-prefetch-fetch-queue.js +69 -7
  377. package/dist/shims/internal/app-route-detection.d.ts +0 -1
  378. package/dist/shims/internal/app-route-prefetch-policy.d.ts +31 -0
  379. package/dist/shims/internal/app-route-prefetch-policy.js +57 -0
  380. package/dist/shims/internal/app-router-context.d.ts +0 -1
  381. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +1 -5
  382. package/dist/shims/internal/hybrid-client-route-owner.d.ts +0 -1
  383. package/dist/shims/internal/hybrid-client-route-owner.js +6 -8
  384. package/dist/shims/internal/interpolate-as.d.ts +3 -2
  385. package/dist/shims/internal/pages-data-target.d.ts +21 -10
  386. package/dist/shims/internal/pages-data-target.js +1 -1
  387. package/dist/shims/internal/pages-data-url.d.ts +3 -1
  388. package/dist/shims/internal/router-context.d.ts +0 -1
  389. package/dist/shims/internal/work-unit-async-storage.d.ts +4 -3
  390. package/dist/shims/internal/work-unit-async-storage.js +2 -0
  391. package/dist/shims/layout-segment-context.d.ts +2 -6
  392. package/dist/shims/legacy-image.d.ts +0 -1
  393. package/dist/shims/link.d.ts +29 -21
  394. package/dist/shims/link.js +52 -97
  395. package/dist/shims/metadata.d.ts +11 -25
  396. package/dist/shims/metadata.js +24 -32
  397. package/dist/shims/navigation-context-state.d.ts +0 -1
  398. package/dist/shims/navigation-state.d.ts +1 -0
  399. package/dist/shims/navigation.d.ts +54 -6
  400. package/dist/shims/navigation.js +325 -73
  401. package/dist/shims/navigation.react-server.d.ts +1 -0
  402. package/dist/shims/og.d.ts +0 -1
  403. package/dist/shims/request-context.d.ts +8 -3
  404. package/dist/shims/request-state-types.d.ts +1 -0
  405. package/dist/shims/router.d.ts +44 -23
  406. package/dist/shims/router.js +8 -7
  407. package/dist/shims/script-nonce-context.d.ts +0 -1
  408. package/dist/shims/script.d.ts +25 -13
  409. package/dist/shims/server-only.d.ts +1 -1
  410. package/dist/shims/server.d.ts +1 -3
  411. package/dist/shims/server.js +5 -6
  412. package/dist/shims/slot.d.ts +23 -11
  413. package/dist/shims/slot.js +103 -19
  414. package/dist/shims/streamed-icons.d.ts +7 -0
  415. package/dist/shims/streamed-icons.js +33 -0
  416. package/dist/shims/unified-request-context.d.ts +44 -4
  417. package/dist/shims/unified-request-context.js +56 -2
  418. package/dist/shims/use-merged-ref.d.ts +0 -1
  419. package/dist/shims/web-vitals.d.ts +0 -1
  420. package/dist/typegen.d.ts +1 -2
  421. package/dist/typegen.js +1 -1
  422. package/dist/utils/cache-control-metadata.d.ts +13 -1
  423. package/dist/utils/cache-control-metadata.js +17 -1
  424. package/dist/utils/client-build-manifest.d.ts +0 -1
  425. package/dist/utils/domain-locale.d.ts +1 -5
  426. package/dist/utils/html-limited-bots.js +1 -1
  427. package/dist/utils/middleware-request-headers.d.ts +17 -5
  428. package/dist/utils/middleware-request-headers.js +32 -23
  429. package/dist/utils/precompressed-variant.d.ts +9 -0
  430. package/dist/utils/precompressed-variant.js +15 -0
  431. package/dist/utils/project.d.ts +12 -7
  432. package/dist/utils/public-file-path.d.ts +5 -0
  433. package/dist/utils/public-file-path.js +12 -0
  434. package/dist/utils/public-routes.d.ts +1 -1
  435. package/dist/utils/public-routes.js +6 -5
  436. package/package.json +7 -3
@@ -1,9 +1,12 @@
1
1
  import { ValidFileMatcher } from "./file-matcher.js";
2
2
  import { isInvisibleSegment } from "./utils.js";
3
-
4
3
  //#region src/routing/app-route-graph.d.ts
5
4
  type InterceptingRoute = {
6
- /** The interception convention: "." | ".." | "../.." | "..." */convention: string; /** The URL pattern this intercepts (e.g. "/photos/:id") */
5
+ /** Graph-owned identity for this interception edge. */
6
+ id?: string;
7
+ /** The interception convention: "." | ".." | "../.." | "..." */
8
+ convention: string;
9
+ /** The URL pattern this intercepts (e.g. "/photos/:id") */
7
10
  targetPattern: string;
8
11
  /**
9
12
  * URL pattern of the *intercepting route* — the path that owns the slot
@@ -20,17 +23,28 @@ type InterceptingRoute = {
20
23
  * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/lib/generate-interception-routes-rewrites.ts
21
24
  * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/utils/interception-routes.ts
22
25
  */
23
- sourceMatchPattern: string; /** Absolute path to the intercepting page component */
24
- pagePath: string; /** Filesystem segments from app/ root to the intercepting page directory. */
25
- sourcePageSegments?: string[]; /** Absolute layout paths inside the intercepting route tree, outermost to innermost */
26
- layoutPaths: string[]; /** Normalized branch segments accumulated at each intercept layout. */
27
- layoutSegments?: string[][]; /** Loading conventions inside the intercepted branch, outermost to innermost. */
28
- loadingPaths?: string[]; /** Tree positions for loadingPaths in the normalized interception branch. */
29
- loadingTreePositions?: number[]; /** Full normalized interception branch segments through the page. */
30
- branchSegments?: string[]; /** Nearest not-found convention inside the interception branch. */
31
- notFoundPath?: string | null; /** Slot-root-relative branch segments used to scope not-found params. */
32
- notFoundBranchSegments?: string[]; /** Tree position relative to the normalized interception branch. */
33
- notFoundTreePosition?: number | null; /** Parameter names for dynamic segments */
26
+ sourceMatchPattern: string;
27
+ /** Absolute path to the intercepting page component */
28
+ pagePath: string;
29
+ /** Filesystem segments from app/ root to the intercepting page directory. */
30
+ sourcePageSegments?: string[];
31
+ /** Absolute layout paths inside the intercepting route tree, outermost to innermost */
32
+ layoutPaths: string[];
33
+ /** Normalized branch segments accumulated at each intercept layout. */
34
+ layoutSegments?: string[][];
35
+ /** Loading conventions inside the intercepted branch, outermost to innermost. */
36
+ loadingPaths?: string[];
37
+ /** Tree positions for loadingPaths in the normalized interception branch. */
38
+ loadingTreePositions?: number[];
39
+ /** Full normalized interception branch segments through the page. */
40
+ branchSegments?: string[];
41
+ /** Nearest not-found convention inside the interception branch. */
42
+ notFoundPath?: string | null;
43
+ /** Slot-root-relative branch segments used to scope not-found params. */
44
+ notFoundBranchSegments?: string[];
45
+ /** Tree position relative to the normalized interception branch. */
46
+ notFoundTreePosition?: number | null;
47
+ /** Parameter names for dynamic segments */
34
48
  params: string[];
35
49
  /**
36
50
  * Synthetic page-carrier slot id for sibling (slot-less) interception.
@@ -39,24 +53,43 @@ type InterceptingRoute = {
39
53
  slotId?: string;
40
54
  };
41
55
  type ParallelSlot = {
42
- /** Graph-owned semantic slot identity. Required on AppRouteGraphParallelSlot. */id?: string; /** Stable slot identity (name + owning directory), used for route serialization keys. */
43
- key: string; /** Slot name (e.g. "team" from @team) */
44
- name: string; /** Absolute path to the @slot directory that owns this slot. Internal routing metadata. */
45
- ownerDir: string; /** Stable tree path for the directory whose layout owns this slot. */
46
- ownerTreePath: string; /** Directory depth of the slot owner from app/ root. */
47
- ownerTreePosition?: number; /** Whether the slot owner directory declares its own page component. */
48
- hasPage: boolean; /** Absolute path to the slot's page component */
49
- pagePath: string | null; /** Absolute path to the slot's default.tsx fallback */
50
- defaultPath: string | null; /** Absolute path to the slot's layout component (wraps slot content) */
51
- layoutPath: string | null; /** Nested active-branch layouts whose exports contribute route config. */
52
- configLayoutPaths?: string[]; /** Tree positions of configLayoutPaths relative to the slot root. */
53
- configLayoutTreePositions?: number[]; /** Absolute path to the slot's loading component */
54
- loadingPath: string | null; /** Per-segment loading components from the slot root to its active page. */
55
- loadingPaths?: string[]; /** Slot-root-relative tree positions aligned with loadingPaths. */
56
- loadingTreePositions?: number[]; /** Absolute path to the slot's error component */
57
- errorPath: string | null; /** Nearest not-found convention for the slot's active branch. */
58
- notFoundPath?: string | null; /** Tree position of that convention relative to the slot root. */
59
- notFoundTreePosition?: number | null; /** Intercepting routes within this slot */
56
+ /** Graph-owned semantic slot identity. Required on AppRouteGraphParallelSlot. */
57
+ id?: string;
58
+ /** Stable slot identity (name + owning directory), used for route serialization keys. */
59
+ key: string;
60
+ /** Slot name (e.g. "team" from @team) */
61
+ name: string;
62
+ /** Absolute path to the @slot directory that owns this slot. Internal routing metadata. */
63
+ ownerDir: string;
64
+ /** Stable tree path for the directory whose layout owns this slot. */
65
+ ownerTreePath: string;
66
+ /** Directory depth of the slot owner from app/ root. */
67
+ ownerTreePosition?: number;
68
+ /** Whether the slot owner directory declares its own page component. */
69
+ hasPage: boolean;
70
+ /** Absolute path to the slot's page component */
71
+ pagePath: string | null;
72
+ /** Absolute path to the slot's default.tsx fallback */
73
+ defaultPath: string | null;
74
+ /** Absolute path to the slot's layout component (wraps slot content) */
75
+ layoutPath: string | null;
76
+ /** Nested active-branch layouts whose exports contribute route config. */
77
+ configLayoutPaths?: string[];
78
+ /** Tree positions of configLayoutPaths relative to the slot root. */
79
+ configLayoutTreePositions?: number[];
80
+ /** Absolute path to the slot's loading component */
81
+ loadingPath: string | null;
82
+ /** Per-segment loading components from the slot root to its active page. */
83
+ loadingPaths?: string[];
84
+ /** Slot-root-relative tree positions aligned with loadingPaths. */
85
+ loadingTreePositions?: number[];
86
+ /** Absolute path to the slot's error component */
87
+ errorPath: string | null;
88
+ /** Nearest not-found convention for the slot's active branch. */
89
+ notFoundPath?: string | null;
90
+ /** Tree position of that convention relative to the slot root. */
91
+ notFoundTreePosition?: number | null;
92
+ /** Intercepting routes within this slot */
60
93
  interceptingRoutes: InterceptingRoute[];
61
94
  /**
62
95
  * The layout index (0-based, in route.layouts[]) that this slot belongs to.
@@ -87,13 +120,21 @@ type ParallelSlot = {
87
120
  slotParamNames?: string[];
88
121
  };
89
122
  type AppRoute = {
90
- /** Graph-owned semantic identities. Required on AppRouteGraphRoute. */ids?: AppRouteSemanticIds; /** URL pattern, e.g. "/" or "/about" or "/blog/:slug" */
91
- pattern: string; /** Absolute file path to the page component */
92
- pagePath: string | null; /** Absolute file path to the route handler (route.ts) */
93
- routePath: string | null; /** Ordered list of layout files from root to leaf */
94
- layouts: string[]; /** Ordered list of all discovered template files from root to leaf (not necessarily aligned 1:1 with layouts) */
95
- templates: string[]; /** Parallel route slots (from @slot directories at the route's directory level) */
96
- parallelSlots: ParallelSlot[]; /** Stable implicit children-slot identity for parallel-slot sub-route families. */
123
+ /** Graph-owned semantic identities. Required on AppRouteGraphRoute. */
124
+ ids?: AppRouteSemanticIds;
125
+ /** URL pattern, e.g. "/" or "/about" or "/blog/:slug" */
126
+ pattern: string;
127
+ /** Absolute file path to the page component */
128
+ pagePath: string | null;
129
+ /** Absolute file path to the route handler (route.ts) */
130
+ routePath: string | null;
131
+ /** Ordered list of layout files from root to leaf */
132
+ layouts: string[];
133
+ /** Ordered list of all discovered template files from root to leaf (not necessarily aligned 1:1 with layouts) */
134
+ templates: string[];
135
+ /** Parallel route slots (from @slot directories at the route's directory level) */
136
+ parallelSlots: ParallelSlot[];
137
+ /** Stable implicit children-slot identity for parallel-slot sub-route families. */
97
138
  childrenSlot?: {
98
139
  id: string;
99
140
  ownerTreePath: string;
@@ -104,20 +145,28 @@ type AppRoute = {
104
145
  * On soft-nav, the intercepting page replaces the entire page response.
105
146
  * Empty array when there are no sibling-style interception markers.
106
147
  */
107
- siblingIntercepts: InterceptingRoute[]; /** Loading component path (leaf directory only) */
108
- loadingPath: string | null; /** Per-segment loading component paths, aligned with loadingTreePositions. */
109
- loadingPaths?: string[]; /** Tree position (directory depth from app/ root) for each loading boundary. */
110
- loadingTreePositions?: number[]; /** Error component path (leaf directory only) */
148
+ siblingIntercepts: InterceptingRoute[];
149
+ /** Loading component path (leaf directory only) */
150
+ loadingPath: string | null;
151
+ /** Per-segment loading component paths, aligned with loadingTreePositions. */
152
+ loadingPaths?: string[];
153
+ /** Tree position (directory depth from app/ root) for each loading boundary. */
154
+ loadingTreePositions?: number[];
155
+ /** Error component path (leaf directory only) */
111
156
  errorPath: string | null;
112
157
  /**
113
158
  * Per-layout error boundary paths, aligned with the layouts array.
114
159
  * Each entry is the error.tsx at the same directory level as the
115
160
  * corresponding layout (or null if that level has no error.tsx).
116
161
  */
117
- layoutErrorPaths: (string | null)[]; /** Per-segment error boundary paths, aligned with errorTreePositions. */
118
- errorPaths?: string[]; /** Tree position (directory depth from app/ root) for each error boundary. */
119
- errorTreePositions?: number[]; /** Not-found component path (nearest, walking up from page dir) */
120
- notFoundPath: string | null; /** Tree position of the nearest not-found component's owning segment. */
162
+ layoutErrorPaths: (string | null)[];
163
+ /** Per-segment error boundary paths, aligned with errorTreePositions. */
164
+ errorPaths?: string[];
165
+ /** Tree position (directory depth from app/ root) for each error boundary. */
166
+ errorTreePositions?: number[];
167
+ /** Not-found component path (nearest, walking up from page dir) */
168
+ notFoundPath: string | null;
169
+ /** Tree position of the nearest not-found component's owning segment. */
121
170
  notFoundTreePosition?: number | null;
122
171
  /**
123
172
  * Not-found component paths per layout level (aligned with layouts array).
@@ -131,11 +180,16 @@ type AppRoute = {
131
180
  * Each entry is the forbidden.tsx at that layout's directory, or null.
132
181
  * Used to create per-layout ForbiddenBoundary.
133
182
  */
134
- forbiddenPaths: (string | null)[]; /** Forbidden component path (403) at the route's directory level */
135
- forbiddenPath: string | null; /** Tree position of the nearest forbidden component's owning segment. */
136
- forbiddenTreePosition?: number | null; /** Unauthorized component path (401) at the route's directory level */
137
- unauthorizedPath: string | null; /** Tree position of the nearest unauthorized component's owning segment. */
138
- unauthorizedTreePosition?: number | null; /** Unauthorized component paths per layout level (aligned with layouts array). */
183
+ forbiddenPaths: (string | null)[];
184
+ /** Forbidden component path (403) at the route's directory level */
185
+ forbiddenPath: string | null;
186
+ /** Tree position of the nearest forbidden component's owning segment. */
187
+ forbiddenTreePosition?: number | null;
188
+ /** Unauthorized component path (401) at the route's directory level */
189
+ unauthorizedPath: string | null;
190
+ /** Tree position of the nearest unauthorized component's owning segment. */
191
+ unauthorizedTreePosition?: number | null;
192
+ /** Unauthorized component paths per layout level (aligned with layouts array). */
139
193
  unauthorizedPaths: (string | null)[];
140
194
  /**
141
195
  * Filesystem segments from app/ root to the route's directory.
@@ -151,7 +205,8 @@ type AppRoute = {
151
205
  * but their children slot renders the parent's default.tsx. In that case the
152
206
  * active children segments remain at the parent route.
153
207
  */
154
- childrenRouteSegments?: string[]; /** Tree position (directory depth from app/ root) for each template. */
208
+ childrenRouteSegments?: string[];
209
+ /** Tree position (directory depth from app/ root) for each template. */
155
210
  templateTreePositions?: number[];
156
211
  /**
157
212
  * Tree position (directory depth from app/ root) for each layout.
@@ -160,10 +215,14 @@ type AppRoute = {
160
215
  * Unlike the old layoutSegmentDepths, this counts ALL directory levels including
161
216
  * route groups and parallel slots.
162
217
  */
163
- layoutTreePositions: number[]; /** Whether this is a dynamic route */
164
- isDynamic: boolean; /** Parameter names for dynamic segments */
165
- params: string[]; /** Dynamic parameter names captured by the route's root layout. */
166
- rootParamNames?: string[]; /** Pre-split pattern segments (computed once at scan time, reused per request) */
218
+ layoutTreePositions: number[];
219
+ /** Whether this is a dynamic route */
220
+ isDynamic: boolean;
221
+ /** Parameter names for dynamic segments */
222
+ params: string[];
223
+ /** Dynamic parameter names captured by the route's root layout. */
224
+ rootParamNames?: string[];
225
+ /** Pre-split pattern segments (computed once at scan time, reused per request) */
167
226
  patternParts: string[];
168
227
  };
169
228
  type AppRouteSemanticIds = {
@@ -201,7 +201,7 @@ function createStaticSegmentGraph(routes) {
201
201
  }
202
202
  for (const ir of route.siblingIntercepts) {
203
203
  if (!ir.slotId) continue;
204
- const id = createAppRouteGraphInterceptionId(ir.slotId, ir.sourceMatchPattern, ir.targetPattern);
204
+ const id = ir.id ?? createAppRouteGraphInterceptionId(ir.slotId, ir.sourceMatchPattern, ir.targetPattern);
205
205
  interceptions.set(id, {
206
206
  id,
207
207
  sourcePattern: ir.sourceMatchPattern,
@@ -1386,6 +1386,7 @@ function discoverSiblingInterceptingRoutes(routes, appDir, matcher) {
1386
1386
  collectInterceptingPages(childDir, childDir, marker.convention, restOfName, parentDir, appDir, parentDir, null, results, matcher);
1387
1387
  for (const ir of results) {
1388
1388
  ir.slotId = createAppRouteGraphSiblingInterceptSlotId(ir.sourceMatchPattern);
1389
+ ir.id = createAppRouteGraphInterceptionId(ir.slotId, ir.sourceMatchPattern, ir.targetPattern);
1389
1390
  const owner = findOwnerRouteForDir(parentDir, appDir, routes, routesByDir);
1390
1391
  if (owner) owner.siblingIntercepts.push(ir);
1391
1392
  }
@@ -1,6 +1,5 @@
1
1
  import { ValidFileMatcher } from "./file-matcher.js";
2
2
  import { AppRoute, AppRouteGraphRoute, RouteManifest, computeAppRouteStaticSiblings, computeRootParamNames, convertSegmentsToRouteParts } from "./app-route-graph.js";
3
-
4
3
  //#region src/routing/app-router.d.ts
5
4
  type AppRouteGraph = {
6
5
  routes: AppRouteGraphRoute[];
@@ -1,12 +1,16 @@
1
1
  import { ValidFileMatcher } from "./file-matcher.js";
2
2
  import { patternToNextFormat } from "./route-validation.js";
3
-
4
3
  //#region src/routing/pages-router.d.ts
5
4
  type Route = {
6
- /** URL pattern, e.g. "/" or "/about" or "/posts/:id" */pattern: string; /** Pre-split pattern segments (computed once at scan time, reused per request) */
7
- patternParts: string[]; /** Absolute file path to the page component */
8
- filePath: string; /** Whether this is a dynamic route */
9
- isDynamic: boolean; /** Parameter names for dynamic segments */
5
+ /** URL pattern, e.g. "/" or "/about" or "/posts/:id" */
6
+ pattern: string;
7
+ /** Pre-split pattern segments (computed once at scan time, reused per request) */
8
+ patternParts: string[];
9
+ /** Absolute file path to the page component */
10
+ filePath: string;
11
+ /** Whether this is a dynamic route */
12
+ isDynamic: boolean;
13
+ /** Parameter names for dynamic segments */
10
14
  params: string[];
11
15
  };
12
16
  /**
@@ -1,5 +1,4 @@
1
1
  import { TrieNode } from "./route-trie.js";
2
-
3
2
  //#region src/routing/route-matching.d.ts
4
3
  type RouteTrieCache<R extends {
5
4
  patternParts: string[];
@@ -91,27 +91,5 @@ declare function isCatchAllSegment(segment: string): boolean;
91
91
  * this matches zero or more URL segments.
92
92
  */
93
93
  declare function isOptionalCatchAllSegment(segment: string): boolean;
94
- /**
95
- * Count how many pathname segments a tree path's *visible* segments consume,
96
- * given the total number of pathname segments available.
97
- *
98
- * This is the minimal pure slice of the canonical filesystem-segment →
99
- * URL-segment mapping in `app-route-graph.ts` (`convertSegmentsToRouteParts`),
100
- * extracted here so browser-side bfcache identity logic can share it without
101
- * importing the Node-bound route graph module. `convertSegmentsToRouteParts`
102
- * remains the source of truth for how each segment kind maps to a URL part.
103
- *
104
- * Each ordinary visible segment (static or `[x]`) consumes exactly one pathname
105
- * segment. A catch-all (`[...x]`) is terminal and consumes every remaining
106
- * pathname segment. An optional-catch-all (`[[...x]]`) is also terminal but may
107
- * match zero segments, so it consumes only the remaining pathname segments
108
- * (which is zero once preceding segments have already consumed the pathname) —
109
- * never more than are actually present.
110
- *
111
- * @param visibleTreePathSegments URL-visible tree-path segments (callers must
112
- * pre-filter invisible segments via `isInvisibleSegment`).
113
- * @param pathnameSegmentCount Total number of pathname segments available.
114
- */
115
- declare function countConsumedPathnameSegments(visibleTreePathSegments: readonly string[], pathnameSegmentCount: number): number;
116
94
  //#endregion
117
- export { buildParams, compareHybridRoutePatterns, countConsumedPathnameSegments, decodeMatchedParams, decodeRouteSegment, isCatchAllSegment, isInvisibleSegment, isOptionalCatchAllSegment, normalizePathnameForRouteMatch, normalizePathnameForRouteMatchStrict, sortRoutes, splitPathSegments, splitPathnameForRouteMatch };
95
+ export { buildParams, compareHybridRoutePatterns, decodeMatchedParams, decodeRouteSegment, isCatchAllSegment, isInvisibleSegment, isOptionalCatchAllSegment, normalizePathnameForRouteMatch, normalizePathnameForRouteMatchStrict, sortRoutes, splitPathSegments, splitPathnameForRouteMatch };
@@ -209,34 +209,5 @@ function isCatchAllSegment(segment) {
209
209
  function isOptionalCatchAllSegment(segment) {
210
210
  return segment.startsWith("[[...") && segment.endsWith("]]") && segment.length > 7;
211
211
  }
212
- /**
213
- * Count how many pathname segments a tree path's *visible* segments consume,
214
- * given the total number of pathname segments available.
215
- *
216
- * This is the minimal pure slice of the canonical filesystem-segment →
217
- * URL-segment mapping in `app-route-graph.ts` (`convertSegmentsToRouteParts`),
218
- * extracted here so browser-side bfcache identity logic can share it without
219
- * importing the Node-bound route graph module. `convertSegmentsToRouteParts`
220
- * remains the source of truth for how each segment kind maps to a URL part.
221
- *
222
- * Each ordinary visible segment (static or `[x]`) consumes exactly one pathname
223
- * segment. A catch-all (`[...x]`) is terminal and consumes every remaining
224
- * pathname segment. An optional-catch-all (`[[...x]]`) is also terminal but may
225
- * match zero segments, so it consumes only the remaining pathname segments
226
- * (which is zero once preceding segments have already consumed the pathname) —
227
- * never more than are actually present.
228
- *
229
- * @param visibleTreePathSegments URL-visible tree-path segments (callers must
230
- * pre-filter invisible segments via `isInvisibleSegment`).
231
- * @param pathnameSegmentCount Total number of pathname segments available.
232
- */
233
- function countConsumedPathnameSegments(visibleTreePathSegments, pathnameSegmentCount) {
234
- let consumed = 0;
235
- for (const segment of visibleTreePathSegments) {
236
- if (isCatchAllSegment(segment) || isOptionalCatchAllSegment(segment)) return Math.max(consumed, pathnameSegmentCount);
237
- consumed += 1;
238
- }
239
- return consumed;
240
- }
241
212
  //#endregion
242
- export { buildParams, compareHybridRoutePatterns, countConsumedPathnameSegments, decodeMatchedParams, decodeRouteSegment, isCatchAllSegment, isInvisibleSegment, isOptionalCatchAllSegment, normalizePathnameForRouteMatch, normalizePathnameForRouteMatchStrict, sortRoutes, splitPathSegments, splitPathnameForRouteMatch };
213
+ export { buildParams, compareHybridRoutePatterns, decodeMatchedParams, decodeRouteSegment, isCatchAllSegment, isInvisibleSegment, isOptionalCatchAllSegment, normalizePathnameForRouteMatch, normalizePathnameForRouteMatchStrict, sortRoutes, splitPathSegments, splitPathnameForRouteMatch };
@@ -1,5 +1,4 @@
1
1
  import { IncomingMessage } from "node:http";
2
-
3
2
  //#region src/server/accept-encoding.d.ts
4
3
  type ContentEncoding = "zstd" | "br" | "gzip" | "deflate";
5
4
  type NegotiatedEncoding = ContentEncoding | "identity";
@@ -2,7 +2,6 @@ import { NextI18nConfig } from "../config/next-config.js";
2
2
  import { Route } from "../routing/pages-router.js";
3
3
  import { ModuleImporter } from "./instrumentation.js";
4
4
  import { IncomingMessage, ServerResponse } from "node:http";
5
-
6
5
  //#region src/server/api-handler.d.ts
7
6
  /**
8
7
  * Handle an API route request.
@@ -9,7 +9,7 @@ import { PagesBodyParseError, getMediaType, isJsonMediaType } from "./pages-medi
9
9
  import { resolveRequestHost, resolveRequestProtocol } from "./proxy-trust.js";
10
10
  import { performOnDemandRevalidate } from "./pages-revalidate.js";
11
11
  import { attachPagesPreviewApi, attachPagesRequestCookies } from "./pages-node-compat.js";
12
- import { isEdgeApiRuntime } from "./edge-api-runtime.js";
12
+ import { finalizeEdgeApiResponse, isEdgeApiRuntime } from "./edge-api-runtime.js";
13
13
  import { decode } from "node:querystring";
14
14
  import { Buffer } from "node:buffer";
15
15
  //#region src/server/api-handler.ts
@@ -227,8 +227,9 @@ async function handleApiRoute(runner, req, res, url, apiRoutes, nextConfig) {
227
227
  i18n: nextConfig.i18n ?? void 0,
228
228
  trailingSlash: nextConfig.trailingSlash
229
229
  } } : void 0);
230
- const response = await apiModule.default(nextRequest);
231
- if (!(response instanceof Response)) throw new Error("Edge API route did not return a Response");
230
+ const handlerResponse = await apiModule.default(nextRequest);
231
+ if (!(handlerResponse instanceof Response)) throw new Error("Edge API route did not return a Response");
232
+ const response = finalizeEdgeApiResponse(handlerResponse, "node");
232
233
  res.statusCode = response.status;
233
234
  res.statusMessage = response.statusText;
234
235
  const setCookieHeaders = response.headers.getSetCookie();
@@ -1,29 +1,26 @@
1
+ import { BfcacheSegmentIdentity } from "./bfcache-identity.js";
1
2
  import { AppElements, AppElementsWire } from "./app-elements-wire.js";
3
+ import "./app-elements.js";
2
4
  import { BfcacheIdMap } from "./app-history-state.js";
3
-
4
5
  //#region src/server/app-bfcache-identity.d.ts
5
- type BfcacheStateKeyMap = Readonly<Record<string, string>>;
6
+ type BfcacheSegmentIdentityMap = Readonly<Record<string, BfcacheSegmentIdentity>>;
6
7
  type InitialBfcacheMaps = Readonly<{
7
8
  bfcacheIds: BfcacheIdMap;
8
- stateKeys: BfcacheStateKeyMap;
9
+ identities: BfcacheSegmentIdentityMap;
9
10
  }>;
10
11
  type AppElementsMetadata = ReturnType<typeof AppElementsWire.readMetadata>;
11
12
  declare function createInitialBfcacheIdMap(elements: AppElements): BfcacheIdMap;
12
- declare function createBfcacheSegmentStateKeyMap(options: {
13
+ declare function createBfcacheSegmentIdentityMap(options: {
13
14
  elements: AppElements;
14
- pathname: string;
15
- }): BfcacheStateKeyMap;
15
+ }): BfcacheSegmentIdentityMap;
16
16
  declare function createInitialBfcacheMaps(options: {
17
17
  elements: AppElements;
18
18
  metadata: AppElementsMetadata;
19
- pathname: string;
20
19
  }): InitialBfcacheMaps;
21
20
  declare function createNextBfcacheIdMap(options: {
22
21
  current: BfcacheIdMap;
23
22
  currentElements: AppElements;
24
- currentPathname: string;
25
23
  elements: AppElements;
26
- nextPathname: string;
27
24
  restored?: BfcacheIdMap | null;
28
25
  reuseCurrent?: boolean;
29
26
  }): BfcacheIdMap;
@@ -31,6 +28,8 @@ declare function preserveBfcacheIdsForMergedElements(options: {
31
28
  elements: AppElements;
32
29
  next: BfcacheIdMap;
33
30
  previous: BfcacheIdMap;
31
+ preservedElementIds?: readonly string[];
32
+ preservePreviousIds?: readonly string[];
34
33
  }): BfcacheIdMap;
35
34
  //#endregion
36
- export { BfcacheStateKeyMap, InitialBfcacheMaps, createBfcacheSegmentStateKeyMap, createInitialBfcacheIdMap, createInitialBfcacheMaps, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements };
35
+ export { BfcacheSegmentIdentityMap, InitialBfcacheMaps, createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap, createInitialBfcacheMaps, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements };
@@ -1,8 +1,8 @@
1
- import { countConsumedPathnameSegments, isInvisibleSegment, normalizePathnameForRouteMatch, splitPathSegments } from "../routing/utils.js";
2
- import { normalizePath } from "./normalize-path.js";
3
1
  import { AppElementsWire } from "./app-elements-wire.js";
4
2
  import "./app-elements.js";
3
+ import { isNestedBfcacheSlotSegmentIdFor } from "./bfcache-identity.js";
5
4
  import "./app-bfcache-id.js";
5
+ import { isBfcacheSegmentId } from "./app-history-state.js";
6
6
  //#region src/server/app-bfcache-identity.ts
7
7
  let nextBfcacheId = 0;
8
8
  function rememberBfcacheId(value) {
@@ -14,106 +14,35 @@ function mintBfcacheId() {
14
14
  nextBfcacheId += 1;
15
15
  return `_b_${nextBfcacheId}_`;
16
16
  }
17
- function getVisibleTreePathSegments(treePath) {
18
- return splitPathSegments(treePath).filter((segment) => !isInvisibleSegment(segment));
19
- }
20
- function getTreePathIdentityPrefix(pathname, treePath) {
21
- const pathnameSegments = splitPathSegments(pathname);
22
- const consumedPathnameSegments = countConsumedPathnameSegments(getVisibleTreePathSegments(treePath), pathnameSegments.length);
23
- if (consumedPathnameSegments === 0) return "/";
24
- return `/${pathnameSegments.slice(0, consumedPathnameSegments).join("/")}`;
25
- }
26
- function indexAppElementsMetadata(metadata) {
27
- const slotBindingsBySlotId = /* @__PURE__ */ new Map();
28
- for (const binding of metadata.slotBindings) slotBindingsBySlotId.set(binding.slotId, binding);
29
- return {
30
- metadata,
31
- slotBindingsBySlotId
32
- };
33
- }
34
17
  function readAppElementsMetadata(elements) {
35
- let metadata;
36
18
  try {
37
- metadata = AppElementsWire.readMetadata(elements);
19
+ return AppElementsWire.readMetadata(elements);
38
20
  } catch {
39
21
  return null;
40
22
  }
41
- return indexAppElementsMetadata(metadata);
42
- }
43
- function parseBfcacheSegmentKey(id) {
44
- const parsed = AppElementsWire.parseElementKey(id);
45
- return parsed !== null && parsed.kind !== "route" ? parsed : null;
46
- }
47
- function createActiveSlotIdentity(id, parsed) {
48
- const activeSlotBinding = parsed?.slotBindingsBySlotId.get(id);
49
- if (activeSlotBinding?.activeRouteId != null) return `${id}@${activeSlotBinding.activeRouteId}`;
50
- const interception = parsed?.metadata.interception;
51
- if (interception?.slotId !== id) return null;
52
- return `${id}@${interception.targetRouteId}`;
53
23
  }
54
- /**
55
- * Derive BFCache identity from AppElements wire keys. Keep wire-key parsing
56
- * contained here until vinext has a route-manifest authority equivalent to
57
- * Next.js CacheNode or segment-cache state.
58
- */
59
- function createBfcacheSegmentIdentity(id, parsed, options) {
60
- if (parsed.kind === "page") return `${id}@${options.pathname}`;
61
- if (parsed.kind === "slot") {
62
- const activeSlotIdentity = createActiveSlotIdentity(id, options.metadata);
63
- if (activeSlotIdentity !== null) return activeSlotIdentity;
64
- return `${id}@${getTreePathIdentityPrefix(options.pathname, parsed.treePath)}`;
65
- }
66
- if (parsed.kind === "layout" || parsed.kind === "template") return `${id}@${getTreePathIdentityPrefix(options.pathname, parsed.treePath)}`;
67
- return null;
68
- }
69
- function collectBfcacheSegmentIdCandidates(elements, metadata = readAppElementsMetadata(elements)) {
24
+ function collectBfcacheSegmentIds(elements, metadata) {
70
25
  const ids = new Set(Object.keys(elements));
71
- for (const layoutId of metadata?.metadata.layoutIds ?? []) ids.add(layoutId);
72
- return ids;
26
+ const parsedMetadata = metadata === void 0 ? readAppElementsMetadata(elements) : metadata;
27
+ for (const layoutId of parsedMetadata?.layoutIds ?? []) ids.add(layoutId);
28
+ for (const identityId of Object.keys(parsedMetadata?.bfcacheSegmentIdentities ?? {})) ids.add(identityId);
29
+ return Array.from(ids).filter(isBfcacheSegmentId);
73
30
  }
74
31
  function createInitialBfcacheIdMap(elements) {
75
32
  const bfcacheIds = {};
76
- for (const id of collectBfcacheSegmentIdCandidates(elements)) if (parseBfcacheSegmentKey(id) !== null) bfcacheIds[id] = "0";
33
+ for (const id of collectBfcacheSegmentIds(elements)) bfcacheIds[id] = "0";
77
34
  return bfcacheIds;
78
35
  }
79
- function normalizeBfcachePathname(pathname) {
80
- const normalized = normalizePath(normalizePathnameForRouteMatch(pathname));
81
- return normalized.length > 1 ? normalized.replace(/\/$/, "") : normalized;
82
- }
83
- function createBfcacheSegmentStateKeyMap(options) {
84
- const metadata = readAppElementsMetadata(options.elements);
85
- const normalizedPathname = normalizeBfcachePathname(options.pathname);
86
- const stateKeys = {};
87
- for (const id of collectBfcacheSegmentIdCandidates(options.elements, metadata)) {
88
- const parsed = parseBfcacheSegmentKey(id);
89
- if (parsed === null) continue;
90
- const stateKey = createBfcacheSegmentIdentity(id, parsed, {
91
- metadata,
92
- pathname: normalizedPathname
93
- });
94
- if (stateKey !== null) stateKeys[id] = stateKey;
95
- }
96
- return stateKeys;
36
+ function createBfcacheSegmentIdentityMap(options) {
37
+ return readAppElementsMetadata(options.elements)?.bfcacheSegmentIdentities ?? {};
97
38
  }
98
39
  function createInitialBfcacheMaps(options) {
99
- const metadata = indexAppElementsMetadata(options.metadata);
100
- const ids = collectBfcacheSegmentIdCandidates(options.elements, metadata);
101
- const normalizedPathname = normalizeBfcachePathname(options.pathname);
40
+ const metadata = options.metadata;
102
41
  const bfcacheIds = {};
103
- const stateKeys = {};
104
- for (const id of ids) {
105
- const parsed = parseBfcacheSegmentKey(id);
106
- if (parsed === null) continue;
107
- bfcacheIds[id] = "0";
108
- const stateKey = createBfcacheSegmentIdentity(id, parsed, {
109
- metadata,
110
- pathname: normalizedPathname
111
- });
112
- if (stateKey !== null) stateKeys[id] = stateKey;
113
- }
42
+ for (const id of collectBfcacheSegmentIds(options.elements, metadata)) bfcacheIds[id] = "0";
114
43
  return {
115
44
  bfcacheIds,
116
- stateKeys
45
+ identities: metadata.bfcacheSegmentIdentities
117
46
  };
118
47
  }
119
48
  function createNextBfcacheIdMap(options) {
@@ -122,20 +51,12 @@ function createNextBfcacheIdMap(options) {
122
51
  for (const value of Object.values(options.restored ?? {})) rememberBfcacheId(value);
123
52
  const currentMetadata = readAppElementsMetadata(options.currentElements);
124
53
  const nextMetadata = readAppElementsMetadata(options.elements);
125
- const currentPathname = normalizeBfcachePathname(options.currentPathname);
126
- const nextPathname = normalizeBfcachePathname(options.nextPathname);
127
54
  const ids = {};
128
- for (const id of collectBfcacheSegmentIdCandidates(options.elements, nextMetadata)) {
129
- const parsed = parseBfcacheSegmentKey(id);
130
- if (parsed === null) continue;
131
- const currentValue = createBfcacheSegmentIdentity(id, parsed, {
132
- metadata: currentMetadata,
133
- pathname: currentPathname
134
- }) === createBfcacheSegmentIdentity(id, parsed, {
135
- metadata: nextMetadata,
136
- pathname: nextPathname
137
- }) ? current[id] : void 0;
138
- const value = options.restored?.[id] ?? currentValue ?? mintBfcacheId();
55
+ for (const id of collectBfcacheSegmentIds(options.elements, nextMetadata)) {
56
+ const currentIdentity = currentMetadata?.bfcacheSegmentIdentities[id];
57
+ const nextIdentity = nextMetadata?.bfcacheSegmentIdentities[id];
58
+ const currentValue = currentIdentity !== void 0 && currentIdentity === nextIdentity ? current[id] : void 0;
59
+ const value = (nextIdentity === void 0 ? void 0 : options.restored?.[id]) ?? currentValue ?? mintBfcacheId();
139
60
  ids[id] = value;
140
61
  rememberBfcacheId(value);
141
62
  }
@@ -143,9 +64,13 @@ function createNextBfcacheIdMap(options) {
143
64
  }
144
65
  function preserveBfcacheIdsForMergedElements(options) {
145
66
  const ids = {};
146
- for (const id of collectBfcacheSegmentIdCandidates(options.elements)) {
147
- if (parseBfcacheSegmentKey(id) === null) continue;
148
- const value = options.next[id] ?? options.previous[id];
67
+ const preservePreviousIds = new Set(options.preservePreviousIds ?? []);
68
+ const preservedElementIds = new Set(options.preservedElementIds ?? []);
69
+ const preservedParentIds = [...preservedElementIds];
70
+ const identities = createBfcacheSegmentIdentityMap({ elements: options.elements });
71
+ for (const id of collectBfcacheSegmentIds(options.elements)) {
72
+ const isPreservedNestedSegment = preservedParentIds.some((parentId) => isNestedBfcacheSlotSegmentIdFor(id, parentId));
73
+ const value = (preservedElementIds.has(id) || isPreservedNestedSegment) && identities[id] === void 0 ? mintBfcacheId() : preservePreviousIds.has(id) || isPreservedNestedSegment ? options.previous[id] ?? options.next[id] : options.next[id] ?? options.previous[id];
149
74
  if (value === void 0) continue;
150
75
  ids[id] = value;
151
76
  rememberBfcacheId(value);
@@ -153,4 +78,4 @@ function preserveBfcacheIdsForMergedElements(options) {
153
78
  return ids;
154
79
  }
155
80
  //#endregion
156
- export { createBfcacheSegmentStateKeyMap, createInitialBfcacheIdMap, createInitialBfcacheMaps, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements };
81
+ export { createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap, createInitialBfcacheMaps, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements };
@@ -1,6 +1,5 @@
1
1
  import { OperationLane } from "./operation-token.js";
2
2
  import { ServerActionResultFacts } from "./navigation-planner.js";
3
-
4
3
  //#region src/server/app-browser-action-result.d.ts
5
4
  type AppBrowserServerActionResult<TRoot> = {
6
5
  root?: TRoot;