vinext 0.0.55 → 0.1.1

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 (1001) hide show
  1. package/README.md +51 -15
  2. package/dist/build/assets-ignore.d.ts +32 -0
  3. package/dist/build/assets-ignore.js +48 -0
  4. package/dist/build/clean-output.d.ts +1 -2
  5. package/dist/build/clean-output.js +0 -2
  6. package/dist/build/client-build-config.d.ts +42 -3
  7. package/dist/build/client-build-config.js +86 -4
  8. package/dist/build/css-url-assets.d.ts +29 -0
  9. package/dist/build/css-url-assets.js +211 -0
  10. package/dist/build/google-fonts/build-url.d.ts +1 -2
  11. package/dist/build/google-fonts/build-url.js +0 -2
  12. package/dist/build/google-fonts/fallback-metrics-data.js +0 -2
  13. package/dist/build/google-fonts/fallback-metrics.d.ts +1 -2
  14. package/dist/build/google-fonts/fallback-metrics.js +0 -2
  15. package/dist/build/google-fonts/font-data.js +0 -2
  16. package/dist/build/google-fonts/font-metadata.d.ts +1 -2
  17. package/dist/build/google-fonts/font-metadata.js +0 -2
  18. package/dist/build/google-fonts/get-axes.d.ts +1 -2
  19. package/dist/build/google-fonts/get-axes.js +0 -2
  20. package/dist/build/google-fonts/sort-variants.d.ts +1 -2
  21. package/dist/build/google-fonts/sort-variants.js +0 -2
  22. package/dist/build/google-fonts/validate.d.ts +1 -2
  23. package/dist/build/google-fonts/validate.js +0 -2
  24. package/dist/build/inline-css.d.ts +1 -2
  25. package/dist/build/inline-css.js +0 -2
  26. package/dist/build/layout-classification-types.d.ts +1 -2
  27. package/dist/build/layout-classification.d.ts +2 -3
  28. package/dist/build/layout-classification.js +1 -3
  29. package/dist/build/next-client-runtime-manifests.d.ts +14 -0
  30. package/dist/build/next-client-runtime-manifests.js +39 -0
  31. package/dist/build/nitro-route-rules.d.ts +1 -2
  32. package/dist/build/nitro-route-rules.js +0 -2
  33. package/dist/build/precompress.d.ts +1 -2
  34. package/dist/build/precompress.js +0 -2
  35. package/dist/build/prerender.d.ts +2 -3
  36. package/dist/build/prerender.js +14 -2
  37. package/dist/build/report.d.ts +1 -2
  38. package/dist/build/report.js +0 -2
  39. package/dist/build/route-classification-injector.d.ts +1 -2
  40. package/dist/build/route-classification-injector.js +4 -6
  41. package/dist/build/route-classification-manifest.d.ts +5 -6
  42. package/dist/build/route-classification-manifest.js +5 -7
  43. package/dist/build/run-prerender.d.ts +1 -2
  44. package/dist/build/run-prerender.js +15 -7
  45. package/dist/build/server-manifest.d.ts +1 -2
  46. package/dist/build/server-manifest.js +0 -2
  47. package/dist/build/ssr-manifest.d.ts +1 -2
  48. package/dist/build/ssr-manifest.js +2 -4
  49. package/dist/build/standalone.d.ts +1 -2
  50. package/dist/build/standalone.js +0 -2
  51. package/dist/build/static-export.d.ts +2 -3
  52. package/dist/build/static-export.js +0 -2
  53. package/dist/cache/cache-adapters-virtual.d.ts +50 -0
  54. package/dist/cache/cache-adapters-virtual.js +45 -0
  55. package/dist/check.d.ts +33 -2
  56. package/dist/check.js +306 -24
  57. package/dist/cli-args.d.ts +1 -2
  58. package/dist/cli-args.js +0 -2
  59. package/dist/cli.js +9 -13
  60. package/dist/client/instrumentation-client-inject.d.ts +1 -2
  61. package/dist/client/instrumentation-client-inject.js +0 -2
  62. package/dist/client/instrumentation-client-state.d.ts +1 -2
  63. package/dist/client/instrumentation-client-state.js +0 -2
  64. package/dist/client/instrumentation-client.d.ts +1 -2
  65. package/dist/client/instrumentation-client.js +0 -2
  66. package/dist/client/navigation-runtime.d.ts +9 -2
  67. package/dist/client/navigation-runtime.js +1 -3
  68. package/dist/client/pages-router-link-navigation.d.ts +1 -2
  69. package/dist/client/pages-router-link-navigation.js +0 -2
  70. package/dist/client/validate-module-path.d.ts +1 -2
  71. package/dist/client/validate-module-path.js +0 -2
  72. package/dist/client/vinext-next-data.d.ts +3 -3
  73. package/dist/client/vinext-next-data.js +0 -2
  74. package/dist/client/window-next.d.ts +1 -2
  75. package/dist/client/window-next.js +0 -2
  76. package/dist/cloudflare/index.d.ts +1 -1
  77. package/dist/cloudflare/index.js +1 -1
  78. package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +97 -0
  79. package/dist/cloudflare/{kv-cache-handler.d.ts → src/cache/kv-data-adapter.runtime.d.ts} +25 -6
  80. package/dist/cloudflare/{kv-cache-handler.js → src/cache/kv-data-adapter.runtime.js} +36 -28
  81. package/dist/cloudflare/src/utils/cache-control-metadata.js +20 -0
  82. package/dist/cloudflare/tpr.d.ts +2 -3
  83. package/dist/cloudflare/tpr.js +8 -8
  84. package/dist/config/config-matchers.d.ts +20 -2
  85. package/dist/config/config-matchers.js +35 -3
  86. package/dist/config/dotenv.d.ts +1 -2
  87. package/dist/config/dotenv.js +0 -2
  88. package/dist/config/next-config.d.ts +32 -5
  89. package/dist/config/next-config.js +53 -6
  90. package/dist/config/tsconfig-paths.d.ts +1 -2
  91. package/dist/config/tsconfig-paths.js +3 -7
  92. package/dist/deploy.d.ts +48 -3
  93. package/dist/deploy.js +180 -415
  94. package/dist/entries/app-browser-entry.d.ts +1 -2
  95. package/dist/entries/app-browser-entry.js +0 -2
  96. package/dist/entries/app-rsc-entry.d.ts +12 -6
  97. package/dist/entries/app-rsc-entry.js +101 -62
  98. package/dist/entries/app-rsc-manifest.d.ts +1 -2
  99. package/dist/entries/app-rsc-manifest.js +40 -9
  100. package/dist/entries/app-ssr-entry.d.ts +1 -2
  101. package/dist/entries/app-ssr-entry.js +0 -2
  102. package/dist/entries/pages-client-entry.d.ts +3 -3
  103. package/dist/entries/pages-client-entry.js +16 -5
  104. package/dist/entries/pages-entry-helpers.d.ts +2 -11
  105. package/dist/entries/pages-entry-helpers.js +1 -20
  106. package/dist/entries/pages-server-entry.d.ts +2 -3
  107. package/dist/entries/pages-server-entry.js +98 -703
  108. package/dist/entries/runtime-entry-module.d.ts +1 -2
  109. package/dist/entries/runtime-entry-module.js +0 -2
  110. package/dist/index.d.ts +22 -2
  111. package/dist/index.js +376 -316
  112. package/dist/init.d.ts +1 -2
  113. package/dist/init.js +1 -3
  114. package/dist/plugins/ast-utils.d.ts +20 -0
  115. package/dist/plugins/ast-utils.js +78 -0
  116. package/dist/plugins/async-hooks-stub.d.ts +1 -2
  117. package/dist/plugins/async-hooks-stub.js +0 -2
  118. package/dist/plugins/client-reference-dedup.d.ts +1 -2
  119. package/dist/plugins/client-reference-dedup.js +4 -8
  120. package/dist/plugins/css-data-url.d.ts +1 -2
  121. package/dist/plugins/css-data-url.js +0 -2
  122. package/dist/plugins/fonts.d.ts +13 -3
  123. package/dist/plugins/fonts.js +19 -13
  124. package/dist/plugins/import-meta-url.d.ts +2 -2
  125. package/dist/plugins/import-meta-url.js +187 -33
  126. package/dist/plugins/instrumentation-client.d.ts +1 -2
  127. package/dist/plugins/instrumentation-client.js +0 -2
  128. package/dist/plugins/middleware-server-only.d.ts +1 -2
  129. package/dist/plugins/middleware-server-only.js +0 -2
  130. package/dist/plugins/og-assets.d.ts +32 -8
  131. package/dist/plugins/og-assets.js +126 -34
  132. package/dist/plugins/optimize-imports.d.ts +1 -2
  133. package/dist/plugins/optimize-imports.js +9 -17
  134. package/dist/plugins/postcss.d.ts +1 -2
  135. package/dist/plugins/postcss.js +18 -16
  136. package/dist/plugins/remove-console.d.ts +1 -2
  137. package/dist/plugins/remove-console.js +0 -2
  138. package/dist/plugins/require-context.d.ts +6 -0
  139. package/dist/plugins/require-context.js +184 -0
  140. package/dist/plugins/rsc-client-reference-loaders.d.ts +1 -2
  141. package/dist/plugins/rsc-client-reference-loaders.js +0 -2
  142. package/dist/plugins/rsc-client-shim-excludes.d.ts +1 -2
  143. package/dist/plugins/rsc-client-shim-excludes.js +0 -2
  144. package/dist/plugins/sass.d.ts +1 -2
  145. package/dist/plugins/sass.js +0 -2
  146. package/dist/plugins/server-externals-manifest.d.ts +1 -2
  147. package/dist/plugins/server-externals-manifest.js +0 -2
  148. package/dist/plugins/strip-server-exports.d.ts +1 -2
  149. package/dist/plugins/strip-server-exports.js +0 -2
  150. package/dist/routing/app-route-graph.d.ts +14 -10
  151. package/dist/routing/app-route-graph.js +146 -35
  152. package/dist/routing/app-router.d.ts +1 -2
  153. package/dist/routing/app-router.js +0 -2
  154. package/dist/routing/file-matcher.d.ts +6 -2
  155. package/dist/routing/file-matcher.js +15 -7
  156. package/dist/routing/pages-router.d.ts +1 -2
  157. package/dist/routing/pages-router.js +0 -2
  158. package/dist/routing/route-matching.d.ts +1 -2
  159. package/dist/routing/route-matching.js +0 -2
  160. package/dist/routing/route-pattern.d.ts +2 -2
  161. package/dist/routing/route-pattern.js +16 -3
  162. package/dist/routing/route-trie.d.ts +1 -2
  163. package/dist/routing/route-trie.js +0 -2
  164. package/dist/routing/route-validation.d.ts +1 -2
  165. package/dist/routing/route-validation.js +0 -2
  166. package/dist/routing/utils.d.ts +44 -2
  167. package/dist/routing/utils.js +62 -3
  168. package/dist/server/api-handler.d.ts +1 -2
  169. package/dist/server/api-handler.js +4 -2
  170. package/dist/server/app-bfcache-id.d.ts +5 -0
  171. package/dist/server/app-bfcache-id.js +5 -0
  172. package/dist/server/app-browser-action-result.d.ts +1 -2
  173. package/dist/server/app-browser-action-result.js +0 -2
  174. package/dist/server/app-browser-client-reuse-manifest.d.ts +12 -0
  175. package/dist/server/app-browser-client-reuse-manifest.js +101 -0
  176. package/dist/server/app-browser-entry.js +244 -88
  177. package/dist/server/app-browser-error.d.ts +1 -2
  178. package/dist/server/app-browser-error.js +0 -2
  179. package/dist/server/app-browser-hydration.d.ts +1 -2
  180. package/dist/server/app-browser-hydration.js +0 -2
  181. package/dist/server/app-browser-interception-context.d.ts +2 -2
  182. package/dist/server/app-browser-interception-context.js +15 -4
  183. package/dist/server/app-browser-mpa-navigation.d.ts +2 -2
  184. package/dist/server/app-browser-mpa-navigation.js +9 -3
  185. package/dist/server/app-browser-navigation-controller.d.ts +15 -4
  186. package/dist/server/app-browser-navigation-controller.js +80 -4
  187. package/dist/server/app-browser-popstate.d.ts +12 -4
  188. package/dist/server/app-browser-popstate.js +19 -6
  189. package/dist/server/app-browser-rsc-redirect.d.ts +1 -2
  190. package/dist/server/app-browser-rsc-redirect.js +0 -2
  191. package/dist/server/app-browser-state.d.ts +31 -4
  192. package/dist/server/app-browser-state.js +196 -10
  193. package/dist/server/app-browser-stream.d.ts +1 -2
  194. package/dist/server/app-browser-stream.js +0 -2
  195. package/dist/server/app-browser-visible-commit.d.ts +2 -3
  196. package/dist/server/app-browser-visible-commit.js +30 -21
  197. package/dist/server/app-client-reference-preloader.d.ts +1 -2
  198. package/dist/server/app-client-reference-preloader.js +0 -2
  199. package/dist/server/app-elements-wire.d.ts +14 -8
  200. package/dist/server/app-elements-wire.js +45 -24
  201. package/dist/server/app-elements.d.ts +2 -3
  202. package/dist/server/app-elements.js +2 -4
  203. package/dist/server/app-fallback-renderer.d.ts +5 -5
  204. package/dist/server/app-fallback-renderer.js +4 -3
  205. package/dist/server/app-history-state.d.ts +62 -2
  206. package/dist/server/app-history-state.js +176 -10
  207. package/dist/server/app-hook-warning-suppression.d.ts +1 -2
  208. package/dist/server/app-hook-warning-suppression.js +0 -2
  209. package/dist/server/app-inline-css-client.d.ts +1 -2
  210. package/dist/server/app-inline-css-client.js +0 -2
  211. package/dist/server/app-interception-context-header.d.ts +1 -2
  212. package/dist/server/app-interception-context-header.js +0 -2
  213. package/dist/server/app-layout-param-observation.d.ts +15 -2
  214. package/dist/server/app-layout-param-observation.js +46 -8
  215. package/dist/server/app-middleware.d.ts +1 -2
  216. package/dist/server/app-middleware.js +0 -2
  217. package/dist/server/app-mounted-slots-header.d.ts +1 -2
  218. package/dist/server/app-mounted-slots-header.js +0 -2
  219. package/dist/server/app-optimistic-routing.d.ts +1 -2
  220. package/dist/server/app-optimistic-routing.js +0 -2
  221. package/dist/server/app-page-boundary-render.d.ts +4 -3
  222. package/dist/server/app-page-boundary-render.js +59 -28
  223. package/dist/server/app-page-boundary.d.ts +11 -2
  224. package/dist/server/app-page-boundary.js +13 -4
  225. package/dist/server/app-page-cache.d.ts +3 -3
  226. package/dist/server/app-page-cache.js +36 -11
  227. package/dist/server/app-page-dispatch.d.ts +25 -5
  228. package/dist/server/app-page-dispatch.js +122 -25
  229. package/dist/server/app-page-element-builder.d.ts +4 -2
  230. package/dist/server/app-page-element-builder.js +31 -21
  231. package/dist/server/app-page-execution.d.ts +8 -3
  232. package/dist/server/app-page-execution.js +55 -24
  233. package/dist/server/app-page-head.d.ts +1 -2
  234. package/dist/server/app-page-head.js +6 -6
  235. package/dist/server/app-page-method.d.ts +1 -2
  236. package/dist/server/app-page-method.js +0 -2
  237. package/dist/server/app-page-params.d.ts +1 -2
  238. package/dist/server/app-page-params.js +0 -2
  239. package/dist/server/app-page-probe.d.ts +79 -2
  240. package/dist/server/app-page-probe.js +89 -9
  241. package/dist/server/app-page-render-identity.d.ts +1 -2
  242. package/dist/server/app-page-render-identity.js +0 -2
  243. package/dist/server/app-page-render-observation.d.ts +1 -2
  244. package/dist/server/app-page-render-observation.js +0 -2
  245. package/dist/server/app-page-render.d.ts +15 -3
  246. package/dist/server/app-page-render.js +171 -12
  247. package/dist/server/app-page-request.d.ts +12 -9
  248. package/dist/server/app-page-request.js +12 -11
  249. package/dist/server/app-page-response.d.ts +4 -4
  250. package/dist/server/app-page-response.js +6 -4
  251. package/dist/server/app-page-route-wiring.d.ts +14 -3
  252. package/dist/server/app-page-route-wiring.js +65 -12
  253. package/dist/server/app-page-search-params-observation.d.ts +10 -0
  254. package/dist/server/app-page-search-params-observation.js +20 -0
  255. package/dist/server/app-page-segment-state.d.ts +1 -2
  256. package/dist/server/app-page-segment-state.js +1 -8
  257. package/dist/server/app-page-stream.d.ts +54 -9
  258. package/dist/server/app-page-stream.js +61 -10
  259. package/dist/server/app-pages-bridge.d.ts +41 -0
  260. package/dist/server/app-pages-bridge.js +54 -0
  261. package/dist/server/app-post-middleware-context.d.ts +1 -2
  262. package/dist/server/app-post-middleware-context.js +0 -2
  263. package/dist/server/app-ppr-fallback-shell.d.ts +21 -0
  264. package/dist/server/app-ppr-fallback-shell.js +82 -0
  265. package/dist/server/app-prerender-endpoints.d.ts +1 -2
  266. package/dist/server/app-prerender-endpoints.js +0 -2
  267. package/dist/server/app-prerender-static-params.d.ts +15 -2
  268. package/dist/server/app-prerender-static-params.js +44 -13
  269. package/dist/server/app-render-dependency.d.ts +3 -2
  270. package/dist/server/app-render-dependency.js +9 -3
  271. package/dist/server/app-request-context.d.ts +1 -2
  272. package/dist/server/app-request-context.js +0 -2
  273. package/dist/server/app-route-handler-cache.d.ts +2 -2
  274. package/dist/server/app-route-handler-cache.js +1 -2
  275. package/dist/server/app-route-handler-dispatch.d.ts +2 -2
  276. package/dist/server/app-route-handler-dispatch.js +2 -2
  277. package/dist/server/app-route-handler-execution.d.ts +2 -2
  278. package/dist/server/app-route-handler-execution.js +3 -4
  279. package/dist/server/app-route-handler-policy.d.ts +1 -2
  280. package/dist/server/app-route-handler-policy.js +0 -2
  281. package/dist/server/app-route-handler-response.d.ts +2 -3
  282. package/dist/server/app-route-handler-response.js +7 -6
  283. package/dist/server/app-route-handler-runtime.d.ts +2 -2
  284. package/dist/server/app-route-handler-runtime.js +3 -4
  285. package/dist/server/app-route-module-loader.d.ts +43 -0
  286. package/dist/server/app-route-module-loader.js +32 -0
  287. package/dist/server/app-router-entry.d.ts +1 -2
  288. package/dist/server/app-router-entry.js +2 -2
  289. package/dist/server/app-rsc-cache-busting.d.ts +10 -2
  290. package/dist/server/app-rsc-cache-busting.js +13 -4
  291. package/dist/server/app-rsc-embedded-chunks.d.ts +1 -2
  292. package/dist/server/app-rsc-embedded-chunks.js +0 -2
  293. package/dist/server/app-rsc-error-handler.d.ts +1 -2
  294. package/dist/server/app-rsc-error-handler.js +0 -2
  295. package/dist/server/app-rsc-errors.d.ts +1 -2
  296. package/dist/server/app-rsc-errors.js +0 -2
  297. package/dist/server/app-rsc-handler.d.ts +17 -2
  298. package/dist/server/app-rsc-handler.js +24 -15
  299. package/dist/server/app-rsc-render-mode.d.ts +1 -2
  300. package/dist/server/app-rsc-render-mode.js +0 -2
  301. package/dist/server/app-rsc-request-normalization.d.ts +4 -5
  302. package/dist/server/app-rsc-request-normalization.js +2 -4
  303. package/dist/server/app-rsc-response-finalizer.d.ts +1 -2
  304. package/dist/server/app-rsc-response-finalizer.js +2 -2
  305. package/dist/server/app-rsc-route-matching.d.ts +20 -2
  306. package/dist/server/app-rsc-route-matching.js +29 -6
  307. package/dist/server/app-segment-config.d.ts +4 -2
  308. package/dist/server/app-segment-config.js +8 -2
  309. package/dist/server/app-server-action-execution.d.ts +18 -3
  310. package/dist/server/app-server-action-execution.js +75 -18
  311. package/dist/server/app-ssr-entry.d.ts +11 -4
  312. package/dist/server/app-ssr-entry.js +47 -15
  313. package/dist/server/app-ssr-error-meta.d.ts +1 -2
  314. package/dist/server/app-ssr-error-meta.js +0 -2
  315. package/dist/server/app-ssr-stream.d.ts +1 -2
  316. package/dist/server/app-ssr-stream.js +31 -3
  317. package/dist/server/app-static-generation.d.ts +1 -2
  318. package/dist/server/app-static-generation.js +0 -2
  319. package/dist/server/app-visited-response-cache.d.ts +23 -0
  320. package/dist/server/app-visited-response-cache.js +19 -0
  321. package/dist/server/artifact-compatibility.d.ts +1 -2
  322. package/dist/server/artifact-compatibility.js +2 -6
  323. package/dist/server/cache-control.d.ts +15 -2
  324. package/dist/server/cache-control.js +21 -3
  325. package/dist/server/cache-headers.d.ts +1 -2
  326. package/dist/server/cache-headers.js +0 -2
  327. package/dist/server/cache-proof.d.ts +1 -2
  328. package/dist/server/cache-proof.js +0 -2
  329. package/dist/server/client-reuse-manifest.d.ts +3 -3
  330. package/dist/server/client-reuse-manifest.js +6 -10
  331. package/dist/server/client-trace-metadata.d.ts +1 -2
  332. package/dist/server/client-trace-metadata.js +0 -2
  333. package/dist/server/cookie-utils.d.ts +1 -2
  334. package/dist/server/cookie-utils.js +0 -2
  335. package/dist/server/csp.d.ts +1 -2
  336. package/dist/server/csp.js +0 -2
  337. package/dist/server/default-global-error-module.d.ts +1 -2
  338. package/dist/server/default-global-error-module.js +0 -2
  339. package/dist/server/default-not-found-module.d.ts +1 -2
  340. package/dist/server/default-not-found-module.js +0 -2
  341. package/dist/server/dev-error-overlay-store.d.ts +20 -4
  342. package/dist/server/dev-error-overlay-store.js +23 -4
  343. package/dist/server/dev-error-overlay.d.ts +39 -3
  344. package/dist/server/dev-error-overlay.js +952 -164
  345. package/dist/server/dev-initial-server-error.d.ts +9 -0
  346. package/dist/server/dev-initial-server-error.js +26 -0
  347. package/dist/server/dev-lockfile.d.ts +1 -2
  348. package/dist/server/dev-lockfile.js +0 -2
  349. package/dist/server/dev-module-runner.d.ts +1 -2
  350. package/dist/server/dev-module-runner.js +0 -2
  351. package/dist/server/dev-origin-check.d.ts +1 -2
  352. package/dist/server/dev-origin-check.js +0 -2
  353. package/dist/server/dev-route-files.d.ts +1 -2
  354. package/dist/server/dev-route-files.js +0 -2
  355. package/dist/server/dev-server.d.ts +3 -4
  356. package/dist/server/dev-server.js +129 -49
  357. package/dist/server/dev-stack-sourcemap-endpoint.d.ts +4 -0
  358. package/dist/server/dev-stack-sourcemap-endpoint.js +4 -0
  359. package/dist/server/dev-stack-sourcemap.d.ts +43 -0
  360. package/dist/server/dev-stack-sourcemap.js +443 -0
  361. package/dist/server/document-initial-head.d.ts +1 -2
  362. package/dist/server/document-initial-head.js +0 -2
  363. package/dist/server/edge-api-runtime.d.ts +1 -2
  364. package/dist/server/edge-api-runtime.js +0 -2
  365. package/dist/server/file-based-metadata.d.ts +1 -2
  366. package/dist/server/file-based-metadata.js +0 -2
  367. package/dist/server/headers.d.ts +3 -2
  368. package/dist/server/headers.js +3 -3
  369. package/dist/server/html.d.ts +1 -2
  370. package/dist/server/html.js +0 -2
  371. package/dist/server/http-error-responses.d.ts +1 -2
  372. package/dist/server/http-error-responses.js +0 -2
  373. package/dist/server/image-optimization.d.ts +1 -2
  374. package/dist/server/image-optimization.js +0 -2
  375. package/dist/server/implicit-tags.d.ts +1 -2
  376. package/dist/server/implicit-tags.js +0 -2
  377. package/dist/server/instrumentation-runtime.d.ts +1 -2
  378. package/dist/server/instrumentation-runtime.js +0 -2
  379. package/dist/server/instrumentation.d.ts +1 -2
  380. package/dist/server/instrumentation.js +0 -2
  381. package/dist/server/isr-cache.d.ts +46 -3
  382. package/dist/server/isr-cache.js +93 -24
  383. package/dist/server/metadata-route-build-data.d.ts +1 -2
  384. package/dist/server/metadata-route-build-data.js +0 -2
  385. package/dist/server/metadata-route-response.d.ts +1 -2
  386. package/dist/server/metadata-route-response.js +0 -2
  387. package/dist/server/metadata-routes.d.ts +1 -2
  388. package/dist/server/metadata-routes.js +0 -2
  389. package/dist/server/middleware-matcher.d.ts +1 -2
  390. package/dist/server/middleware-matcher.js +0 -2
  391. package/dist/server/middleware-request-headers.d.ts +1 -2
  392. package/dist/server/middleware-request-headers.js +0 -2
  393. package/dist/server/middleware-response-headers.d.ts +1 -2
  394. package/dist/server/middleware-response-headers.js +0 -2
  395. package/dist/server/middleware-runtime.d.ts +1 -2
  396. package/dist/server/middleware-runtime.js +14 -5
  397. package/dist/server/middleware.d.ts +2 -3
  398. package/dist/server/middleware.js +0 -2
  399. package/dist/server/navigation-planner.d.ts +16 -2
  400. package/dist/server/navigation-planner.js +6 -6
  401. package/dist/server/navigation-trace.d.ts +1 -2
  402. package/dist/server/navigation-trace.js +0 -2
  403. package/dist/server/next-error-digest.d.ts +1 -2
  404. package/dist/server/next-error-digest.js +0 -2
  405. package/dist/server/normalize-path.d.ts +1 -2
  406. package/dist/server/normalize-path.js +0 -2
  407. package/dist/server/pages-api-route.d.ts +1 -2
  408. package/dist/server/pages-api-route.js +1 -3
  409. package/dist/server/pages-asset-tags.d.ts +66 -0
  410. package/dist/server/pages-asset-tags.js +116 -0
  411. package/dist/server/pages-body-parser-config.d.ts +1 -2
  412. package/dist/server/pages-body-parser-config.js +0 -2
  413. package/dist/server/pages-data-route.d.ts +39 -2
  414. package/dist/server/pages-data-route.js +46 -3
  415. package/dist/server/pages-default-404.d.ts +1 -2
  416. package/dist/server/pages-default-404.js +0 -2
  417. package/dist/server/pages-document-initial-props.d.ts +1 -2
  418. package/dist/server/pages-document-initial-props.js +0 -2
  419. package/dist/server/pages-get-initial-props.d.ts +17 -0
  420. package/dist/server/pages-get-initial-props.js +50 -0
  421. package/dist/server/pages-i18n.d.ts +1 -2
  422. package/dist/server/pages-i18n.js +0 -2
  423. package/dist/server/pages-media-type.d.ts +1 -2
  424. package/dist/server/pages-media-type.js +1 -2
  425. package/dist/server/pages-node-compat.d.ts +11 -2
  426. package/dist/server/pages-node-compat.js +38 -3
  427. package/dist/server/pages-page-data.d.ts +17 -10
  428. package/dist/server/pages-page-data.js +79 -35
  429. package/dist/server/pages-page-handler.d.ts +97 -0
  430. package/dist/server/pages-page-handler.js +348 -0
  431. package/dist/server/pages-page-method.d.ts +1 -2
  432. package/dist/server/pages-page-method.js +0 -2
  433. package/dist/server/pages-page-response.d.ts +11 -3
  434. package/dist/server/pages-page-response.js +16 -5
  435. package/dist/server/pages-readiness.d.ts +36 -0
  436. package/dist/server/pages-readiness.js +21 -0
  437. package/dist/server/pages-request-pipeline.d.ts +99 -0
  438. package/dist/server/pages-request-pipeline.js +209 -0
  439. package/dist/server/pages-revalidate.d.ts +15 -0
  440. package/dist/server/pages-revalidate.js +19 -0
  441. package/dist/server/pages-serializable-props.d.ts +1 -2
  442. package/dist/server/pages-serializable-props.js +0 -2
  443. package/dist/server/pregenerated-concrete-paths.d.ts +32 -0
  444. package/dist/server/pregenerated-concrete-paths.js +78 -0
  445. package/dist/server/prerender-route-params.d.ts +13 -3
  446. package/dist/server/prerender-route-params.js +30 -11
  447. package/dist/server/prerender-work-unit-setup.d.ts +1 -2
  448. package/dist/server/prerender-work-unit-setup.js +0 -2
  449. package/dist/server/prod-server.d.ts +8 -6
  450. package/dist/server/prod-server.js +101 -219
  451. package/dist/server/proxy-trust.d.ts +1 -2
  452. package/dist/server/proxy-trust.js +0 -2
  453. package/dist/server/request-log.d.ts +1 -2
  454. package/dist/server/request-log.js +0 -2
  455. package/dist/server/request-pipeline.d.ts +14 -2
  456. package/dist/server/request-pipeline.js +42 -3
  457. package/dist/server/rsc-stream-hints.d.ts +1 -2
  458. package/dist/server/rsc-stream-hints.js +0 -2
  459. package/dist/server/seed-cache.d.ts +6 -2
  460. package/dist/server/seed-cache.js +10 -8
  461. package/dist/server/server-action-not-found.d.ts +1 -2
  462. package/dist/server/server-action-not-found.js +0 -2
  463. package/dist/server/server-globals.d.ts +1 -2
  464. package/dist/server/server-globals.js +0 -2
  465. package/dist/server/skip-cache-proof.d.ts +1 -2
  466. package/dist/server/skip-cache-proof.js +0 -2
  467. package/dist/server/socket-error-backstop.d.ts +19 -2
  468. package/dist/server/socket-error-backstop.js +77 -6
  469. package/dist/server/static-file-cache.d.ts +1 -2
  470. package/dist/server/static-file-cache.js +0 -2
  471. package/dist/server/static-layout-client-reuse-proof.d.ts +1 -2
  472. package/dist/server/static-layout-client-reuse-proof.js +0 -2
  473. package/dist/server/streaming-metadata.d.ts +1 -2
  474. package/dist/server/streaming-metadata.js +0 -2
  475. package/dist/server/worker-utils.d.ts +1 -2
  476. package/dist/server/worker-utils.js +3 -6
  477. package/dist/shims/amp.d.ts +1 -2
  478. package/dist/shims/amp.js +0 -2
  479. package/dist/shims/app-router-scroll-state.d.ts +1 -2
  480. package/dist/shims/app-router-scroll-state.js +0 -2
  481. package/dist/shims/app-router-scroll.d.ts +3 -5
  482. package/dist/shims/app-router-scroll.js +22 -6
  483. package/dist/shims/app.d.ts +1 -2
  484. package/dist/shims/app.js +0 -2
  485. package/dist/shims/before-interactive-context.d.ts +1 -2
  486. package/dist/shims/before-interactive-context.js +0 -2
  487. package/dist/shims/cache-for-request.d.ts +1 -2
  488. package/dist/shims/cache-for-request.js +0 -2
  489. package/dist/shims/cache-runtime.d.ts +20 -5
  490. package/dist/shims/cache-runtime.js +66 -31
  491. package/dist/shims/cache.d.ts +48 -7
  492. package/dist/shims/cache.js +79 -20
  493. package/dist/shims/cdn-cache.d.ts +125 -0
  494. package/dist/shims/cdn-cache.js +100 -0
  495. package/dist/shims/client-hook-error.d.ts +1 -2
  496. package/dist/shims/client-hook-error.js +0 -2
  497. package/dist/shims/client-locale.d.ts +1 -2
  498. package/dist/shims/client-locale.js +1 -3
  499. package/dist/shims/compat-router.d.ts +1 -2
  500. package/dist/shims/compat-router.js +0 -2
  501. package/dist/shims/config.d.ts +1 -2
  502. package/dist/shims/config.js +0 -2
  503. package/dist/shims/constants.d.ts +1 -2
  504. package/dist/shims/constants.js +0 -2
  505. package/dist/shims/default-global-error.d.ts +3 -4
  506. package/dist/shims/default-global-error.js +0 -2
  507. package/dist/shims/default-not-found.d.ts +1 -2
  508. package/dist/shims/default-not-found.js +0 -2
  509. package/dist/shims/document.d.ts +5 -7
  510. package/dist/shims/document.js +0 -2
  511. package/dist/shims/dynamic.d.ts +1 -2
  512. package/dist/shims/dynamic.js +0 -2
  513. package/dist/shims/error-boundary.d.ts +32 -18
  514. package/dist/shims/error-boundary.js +43 -3
  515. package/dist/shims/error.d.ts +1 -2
  516. package/dist/shims/error.js +0 -2
  517. package/dist/shims/fetch-cache.d.ts +14 -2
  518. package/dist/shims/fetch-cache.js +20 -5
  519. package/dist/shims/font-google-base.d.ts +1 -2
  520. package/dist/shims/font-google-base.js +1 -13
  521. package/dist/shims/font-local.d.ts +1 -2
  522. package/dist/shims/font-local.js +1 -15
  523. package/dist/shims/font-utils.d.ts +7 -2
  524. package/dist/shims/font-utils.js +13 -3
  525. package/dist/shims/form.d.ts +12 -5
  526. package/dist/shims/form.js +98 -21
  527. package/dist/shims/hash-scroll.d.ts +2 -2
  528. package/dist/shims/hash-scroll.js +3 -3
  529. package/dist/shims/head-state.d.ts +1 -2
  530. package/dist/shims/head-state.js +0 -2
  531. package/dist/shims/head.d.ts +1 -2
  532. package/dist/shims/head.js +0 -2
  533. package/dist/shims/headers.d.ts +9 -2
  534. package/dist/shims/headers.js +13 -3
  535. package/dist/shims/i18n-context.d.ts +1 -2
  536. package/dist/shims/i18n-context.js +0 -2
  537. package/dist/shims/i18n-state.d.ts +1 -2
  538. package/dist/shims/i18n-state.js +0 -2
  539. package/dist/shims/image-config.d.ts +1 -2
  540. package/dist/shims/image-config.js +0 -2
  541. package/dist/shims/image.d.ts +1 -2
  542. package/dist/shims/image.js +1 -3
  543. package/dist/shims/internal/als-registry.d.ts +1 -2
  544. package/dist/shims/internal/als-registry.js +0 -2
  545. package/dist/shims/internal/api-utils.d.ts +1 -2
  546. package/dist/shims/internal/app-route-detection.d.ts +1 -2
  547. package/dist/shims/internal/app-route-detection.js +0 -2
  548. package/dist/shims/internal/app-router-context.d.ts +1 -2
  549. package/dist/shims/internal/app-router-context.js +0 -2
  550. package/dist/shims/internal/cookie-serialize.d.ts +1 -2
  551. package/dist/shims/internal/cookie-serialize.js +0 -2
  552. package/dist/shims/internal/link-status-registry.d.ts +43 -0
  553. package/dist/shims/internal/link-status-registry.js +42 -0
  554. package/dist/shims/internal/make-hanging-promise.d.ts +1 -2
  555. package/dist/shims/internal/make-hanging-promise.js +0 -2
  556. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +1 -2
  557. package/dist/shims/internal/pages-data-fetch-dedup.js +0 -2
  558. package/dist/shims/internal/pages-data-target.d.ts +1 -2
  559. package/dist/shims/internal/pages-data-target.js +0 -2
  560. package/dist/shims/internal/pages-data-url.d.ts +1 -2
  561. package/dist/shims/internal/pages-data-url.js +0 -2
  562. package/dist/shims/internal/parse-cookie-header.d.ts +1 -2
  563. package/dist/shims/internal/parse-cookie-header.js +0 -2
  564. package/dist/shims/internal/route-pattern-for-warning.d.ts +27 -0
  565. package/dist/shims/internal/route-pattern-for-warning.js +40 -0
  566. package/dist/shims/internal/router-context.d.ts +2 -4
  567. package/dist/shims/internal/router-context.js +0 -2
  568. package/dist/shims/internal/utils.d.ts +2 -2
  569. package/dist/shims/internal/utils.js +0 -2
  570. package/dist/shims/internal/work-unit-async-storage.d.ts +1 -2
  571. package/dist/shims/internal/work-unit-async-storage.js +0 -2
  572. package/dist/shims/layout-segment-context.d.ts +2 -4
  573. package/dist/shims/layout-segment-context.js +0 -2
  574. package/dist/shims/legacy-image.d.ts +1 -2
  575. package/dist/shims/legacy-image.js +0 -2
  576. package/dist/shims/link-prefetch.d.ts +1 -2
  577. package/dist/shims/link-prefetch.js +0 -2
  578. package/dist/shims/link.d.ts +2 -2
  579. package/dist/shims/link.js +40 -20
  580. package/dist/shims/metadata.d.ts +4 -5
  581. package/dist/shims/metadata.js +1 -3
  582. package/dist/shims/navigation-state.d.ts +1 -2
  583. package/dist/shims/navigation-state.js +0 -2
  584. package/dist/shims/navigation.d.ts +25 -9
  585. package/dist/shims/navigation.js +251 -46
  586. package/dist/shims/navigation.react-server.d.ts +1 -2
  587. package/dist/shims/navigation.react-server.js +0 -2
  588. package/dist/shims/offline.d.ts +1 -2
  589. package/dist/shims/offline.js +0 -2
  590. package/dist/shims/og.d.ts +1 -2
  591. package/dist/shims/og.js +2 -4
  592. package/dist/shims/pages-router-runtime.d.ts +7 -2
  593. package/dist/shims/pages-router-runtime.js +11 -3
  594. package/dist/shims/ppr-fallback-shell.d.ts +29 -0
  595. package/dist/shims/ppr-fallback-shell.js +149 -0
  596. package/dist/shims/readonly-url-search-params.d.ts +1 -2
  597. package/dist/shims/readonly-url-search-params.js +0 -2
  598. package/dist/shims/request-context.d.ts +9 -5
  599. package/dist/shims/request-context.js +0 -2
  600. package/dist/shims/request-state-types.d.ts +1 -1
  601. package/dist/shims/root-params.d.ts +1 -2
  602. package/dist/shims/root-params.js +0 -2
  603. package/dist/shims/router-state.d.ts +2 -2
  604. package/dist/shims/router-state.js +2 -2
  605. package/dist/shims/router.d.ts +6 -4
  606. package/dist/shims/router.js +262 -40
  607. package/dist/shims/script-nonce-context.d.ts +1 -2
  608. package/dist/shims/script-nonce-context.js +0 -2
  609. package/dist/shims/script.d.ts +1 -2
  610. package/dist/shims/script.js +0 -2
  611. package/dist/shims/server.d.ts +1 -2
  612. package/dist/shims/server.js +0 -2
  613. package/dist/shims/slot.d.ts +11 -4
  614. package/dist/shims/slot.js +121 -9
  615. package/dist/shims/thenable-params.d.ts +2 -2
  616. package/dist/shims/thenable-params.js +107 -12
  617. package/dist/shims/unified-request-context.d.ts +1 -2
  618. package/dist/shims/unified-request-context.js +0 -2
  619. package/dist/shims/unrecognized-action-error.d.ts +1 -2
  620. package/dist/shims/unrecognized-action-error.js +0 -2
  621. package/dist/shims/url-safety.d.ts +1 -2
  622. package/dist/shims/url-safety.js +0 -2
  623. package/dist/shims/url-utils.d.ts +1 -2
  624. package/dist/shims/url-utils.js +0 -2
  625. package/dist/shims/use-merged-ref.d.ts +1 -2
  626. package/dist/shims/use-merged-ref.js +0 -2
  627. package/dist/shims/web-vitals.d.ts +1 -2
  628. package/dist/shims/web-vitals.js +0 -2
  629. package/dist/typegen.d.ts +1 -2
  630. package/dist/typegen.js +2 -9
  631. package/dist/utils/asset-prefix.d.ts +1 -2
  632. package/dist/utils/asset-prefix.js +0 -2
  633. package/dist/utils/base-path.d.ts +1 -2
  634. package/dist/utils/base-path.js +0 -2
  635. package/dist/utils/cache-control-metadata.d.ts +1 -4
  636. package/dist/utils/cache-control-metadata.js +1 -3
  637. package/dist/utils/client-build-manifest.d.ts +8 -2
  638. package/dist/utils/client-build-manifest.js +30 -7
  639. package/dist/utils/client-entry-manifest.d.ts +11 -0
  640. package/dist/utils/client-entry-manifest.js +29 -0
  641. package/dist/utils/compare.d.ts +4 -0
  642. package/dist/utils/compare.js +8 -0
  643. package/dist/utils/dev-error-recovery-event.d.ts +4 -0
  644. package/dist/utils/dev-error-recovery-event.js +4 -0
  645. package/dist/utils/domain-locale.d.ts +1 -2
  646. package/dist/utils/domain-locale.js +2 -4
  647. package/dist/utils/encode-cache-tag.d.ts +1 -2
  648. package/dist/utils/encode-cache-tag.js +0 -2
  649. package/dist/utils/error-cause.d.ts +1 -2
  650. package/dist/utils/error-cause.js +0 -2
  651. package/dist/utils/hash.d.ts +1 -2
  652. package/dist/utils/hash.js +0 -2
  653. package/dist/utils/html-limited-bots.d.ts +1 -2
  654. package/dist/utils/html-limited-bots.js +0 -2
  655. package/dist/utils/lazy-chunks.d.ts +1 -2
  656. package/dist/utils/lazy-chunks.js +0 -2
  657. package/dist/utils/manifest-paths.d.ts +8 -3
  658. package/dist/utils/manifest-paths.js +15 -3
  659. package/dist/utils/mdx-scan.d.ts +1 -2
  660. package/dist/utils/mdx-scan.js +0 -2
  661. package/dist/utils/navigation-signal.d.ts +1 -2
  662. package/dist/utils/navigation-signal.js +0 -2
  663. package/dist/utils/number.d.ts +4 -0
  664. package/dist/utils/number.js +6 -0
  665. package/dist/utils/path.d.ts +4 -2
  666. package/dist/utils/path.js +5 -3
  667. package/dist/utils/prerender-output-paths.d.ts +1 -2
  668. package/dist/utils/prerender-output-paths.js +0 -2
  669. package/dist/utils/project.d.ts +1 -2
  670. package/dist/utils/project.js +0 -2
  671. package/dist/utils/promise.d.ts +4 -0
  672. package/dist/utils/promise.js +6 -0
  673. package/dist/utils/public-routes.d.ts +1 -2
  674. package/dist/utils/public-routes.js +0 -2
  675. package/dist/utils/query.d.ts +1 -2
  676. package/dist/utils/query.js +0 -2
  677. package/dist/utils/record.d.ts +1 -2
  678. package/dist/utils/record.js +0 -2
  679. package/dist/utils/regex.d.ts +4 -0
  680. package/dist/utils/regex.js +6 -0
  681. package/dist/utils/safe-json-file.d.ts +1 -2
  682. package/dist/utils/safe-json-file.js +0 -2
  683. package/dist/utils/sorted-array.d.ts +1 -2
  684. package/dist/utils/sorted-array.js +0 -2
  685. package/dist/utils/text-stream.d.ts +1 -2
  686. package/dist/utils/text-stream.js +0 -2
  687. package/dist/utils/vinext-root.d.ts +1 -2
  688. package/dist/utils/vinext-root.js +0 -2
  689. package/dist/utils/vite-version.d.ts +1 -2
  690. package/dist/utils/vite-version.js +0 -2
  691. package/package.json +23 -6
  692. package/dist/build/clean-output.js.map +0 -1
  693. package/dist/build/client-build-config.js.map +0 -1
  694. package/dist/build/google-fonts/build-url.js.map +0 -1
  695. package/dist/build/google-fonts/fallback-metrics-data.js.map +0 -1
  696. package/dist/build/google-fonts/fallback-metrics.js.map +0 -1
  697. package/dist/build/google-fonts/font-data.js.map +0 -1
  698. package/dist/build/google-fonts/font-metadata.js.map +0 -1
  699. package/dist/build/google-fonts/get-axes.js.map +0 -1
  700. package/dist/build/google-fonts/sort-variants.js.map +0 -1
  701. package/dist/build/google-fonts/validate.js.map +0 -1
  702. package/dist/build/inline-css.js.map +0 -1
  703. package/dist/build/layout-classification.js.map +0 -1
  704. package/dist/build/nitro-route-rules.js.map +0 -1
  705. package/dist/build/precompress.js.map +0 -1
  706. package/dist/build/prerender.js.map +0 -1
  707. package/dist/build/report.js.map +0 -1
  708. package/dist/build/route-classification-injector.js.map +0 -1
  709. package/dist/build/route-classification-manifest.js.map +0 -1
  710. package/dist/build/run-prerender.js.map +0 -1
  711. package/dist/build/server-manifest.js.map +0 -1
  712. package/dist/build/ssr-manifest.js.map +0 -1
  713. package/dist/build/standalone.js.map +0 -1
  714. package/dist/build/static-export.js.map +0 -1
  715. package/dist/check.js.map +0 -1
  716. package/dist/cli-args.js.map +0 -1
  717. package/dist/cli.js.map +0 -1
  718. package/dist/client/instrumentation-client-inject.js.map +0 -1
  719. package/dist/client/instrumentation-client-state.js.map +0 -1
  720. package/dist/client/instrumentation-client.js.map +0 -1
  721. package/dist/client/navigation-runtime.js.map +0 -1
  722. package/dist/client/pages-router-link-navigation.js.map +0 -1
  723. package/dist/client/validate-module-path.js.map +0 -1
  724. package/dist/client/vinext-next-data.js.map +0 -1
  725. package/dist/client/window-next.js.map +0 -1
  726. package/dist/cloudflare/kv-cache-handler.js.map +0 -1
  727. package/dist/cloudflare/tpr.js.map +0 -1
  728. package/dist/config/config-matchers.js.map +0 -1
  729. package/dist/config/dotenv.js.map +0 -1
  730. package/dist/config/next-config.js.map +0 -1
  731. package/dist/config/tsconfig-paths.js.map +0 -1
  732. package/dist/deploy.js.map +0 -1
  733. package/dist/entries/app-browser-entry.js.map +0 -1
  734. package/dist/entries/app-rsc-entry.js.map +0 -1
  735. package/dist/entries/app-rsc-manifest.js.map +0 -1
  736. package/dist/entries/app-ssr-entry.js.map +0 -1
  737. package/dist/entries/pages-client-entry.js.map +0 -1
  738. package/dist/entries/pages-entry-helpers.js.map +0 -1
  739. package/dist/entries/pages-server-entry.js.map +0 -1
  740. package/dist/entries/runtime-entry-module.js.map +0 -1
  741. package/dist/index.js.map +0 -1
  742. package/dist/init.js.map +0 -1
  743. package/dist/plugins/async-hooks-stub.js.map +0 -1
  744. package/dist/plugins/client-reference-dedup.js.map +0 -1
  745. package/dist/plugins/css-data-url.js.map +0 -1
  746. package/dist/plugins/fonts.js.map +0 -1
  747. package/dist/plugins/import-meta-url.js.map +0 -1
  748. package/dist/plugins/instrumentation-client.js.map +0 -1
  749. package/dist/plugins/middleware-server-only.js.map +0 -1
  750. package/dist/plugins/og-assets.js.map +0 -1
  751. package/dist/plugins/optimize-imports.js.map +0 -1
  752. package/dist/plugins/postcss.js.map +0 -1
  753. package/dist/plugins/remove-console.js.map +0 -1
  754. package/dist/plugins/rsc-client-reference-loaders.js.map +0 -1
  755. package/dist/plugins/rsc-client-shim-excludes.js.map +0 -1
  756. package/dist/plugins/sass.js.map +0 -1
  757. package/dist/plugins/server-externals-manifest.js.map +0 -1
  758. package/dist/plugins/strip-server-exports.js.map +0 -1
  759. package/dist/routing/app-route-graph.js.map +0 -1
  760. package/dist/routing/app-router.js.map +0 -1
  761. package/dist/routing/file-matcher.js.map +0 -1
  762. package/dist/routing/pages-router.js.map +0 -1
  763. package/dist/routing/route-matching.js.map +0 -1
  764. package/dist/routing/route-pattern.js.map +0 -1
  765. package/dist/routing/route-trie.js.map +0 -1
  766. package/dist/routing/route-validation.js.map +0 -1
  767. package/dist/routing/utils.js.map +0 -1
  768. package/dist/server/api-handler.js.map +0 -1
  769. package/dist/server/app-browser-action-result.js.map +0 -1
  770. package/dist/server/app-browser-entry.js.map +0 -1
  771. package/dist/server/app-browser-error.js.map +0 -1
  772. package/dist/server/app-browser-hydration.js.map +0 -1
  773. package/dist/server/app-browser-interception-context.js.map +0 -1
  774. package/dist/server/app-browser-mpa-navigation.js.map +0 -1
  775. package/dist/server/app-browser-navigation-controller.js.map +0 -1
  776. package/dist/server/app-browser-popstate.js.map +0 -1
  777. package/dist/server/app-browser-rsc-redirect.js.map +0 -1
  778. package/dist/server/app-browser-state.js.map +0 -1
  779. package/dist/server/app-browser-stream.js.map +0 -1
  780. package/dist/server/app-browser-visible-commit.js.map +0 -1
  781. package/dist/server/app-client-reference-preloader.js.map +0 -1
  782. package/dist/server/app-elements-wire.js.map +0 -1
  783. package/dist/server/app-elements.js.map +0 -1
  784. package/dist/server/app-fallback-renderer.js.map +0 -1
  785. package/dist/server/app-history-state.js.map +0 -1
  786. package/dist/server/app-hook-warning-suppression.js.map +0 -1
  787. package/dist/server/app-inline-css-client.js.map +0 -1
  788. package/dist/server/app-interception-context-header.js.map +0 -1
  789. package/dist/server/app-layout-param-observation.js.map +0 -1
  790. package/dist/server/app-middleware.js.map +0 -1
  791. package/dist/server/app-mounted-slots-header.js.map +0 -1
  792. package/dist/server/app-optimistic-routing.js.map +0 -1
  793. package/dist/server/app-page-boundary-render.js.map +0 -1
  794. package/dist/server/app-page-boundary.js.map +0 -1
  795. package/dist/server/app-page-cache.js.map +0 -1
  796. package/dist/server/app-page-dispatch.js.map +0 -1
  797. package/dist/server/app-page-element-builder.js.map +0 -1
  798. package/dist/server/app-page-execution.js.map +0 -1
  799. package/dist/server/app-page-head.js.map +0 -1
  800. package/dist/server/app-page-method.js.map +0 -1
  801. package/dist/server/app-page-params.js.map +0 -1
  802. package/dist/server/app-page-probe.js.map +0 -1
  803. package/dist/server/app-page-render-identity.js.map +0 -1
  804. package/dist/server/app-page-render-observation.js.map +0 -1
  805. package/dist/server/app-page-render.js.map +0 -1
  806. package/dist/server/app-page-request.js.map +0 -1
  807. package/dist/server/app-page-response.js.map +0 -1
  808. package/dist/server/app-page-route-wiring.js.map +0 -1
  809. package/dist/server/app-page-segment-state.js.map +0 -1
  810. package/dist/server/app-page-stream.js.map +0 -1
  811. package/dist/server/app-post-middleware-context.js.map +0 -1
  812. package/dist/server/app-prerender-endpoints.js.map +0 -1
  813. package/dist/server/app-prerender-static-params.js.map +0 -1
  814. package/dist/server/app-render-dependency.js.map +0 -1
  815. package/dist/server/app-request-context.js.map +0 -1
  816. package/dist/server/app-route-handler-cache.js.map +0 -1
  817. package/dist/server/app-route-handler-dispatch.js.map +0 -1
  818. package/dist/server/app-route-handler-execution.js.map +0 -1
  819. package/dist/server/app-route-handler-policy.js.map +0 -1
  820. package/dist/server/app-route-handler-response.js.map +0 -1
  821. package/dist/server/app-route-handler-runtime.js.map +0 -1
  822. package/dist/server/app-router-entry.js.map +0 -1
  823. package/dist/server/app-rsc-cache-busting.js.map +0 -1
  824. package/dist/server/app-rsc-embedded-chunks.js.map +0 -1
  825. package/dist/server/app-rsc-error-handler.js.map +0 -1
  826. package/dist/server/app-rsc-errors.js.map +0 -1
  827. package/dist/server/app-rsc-handler.js.map +0 -1
  828. package/dist/server/app-rsc-render-mode.js.map +0 -1
  829. package/dist/server/app-rsc-request-normalization.js.map +0 -1
  830. package/dist/server/app-rsc-response-finalizer.js.map +0 -1
  831. package/dist/server/app-rsc-route-matching.js.map +0 -1
  832. package/dist/server/app-segment-config.js.map +0 -1
  833. package/dist/server/app-server-action-execution.js.map +0 -1
  834. package/dist/server/app-ssr-entry.js.map +0 -1
  835. package/dist/server/app-ssr-error-meta.js.map +0 -1
  836. package/dist/server/app-ssr-stream.js.map +0 -1
  837. package/dist/server/app-static-generation.js.map +0 -1
  838. package/dist/server/artifact-compatibility.js.map +0 -1
  839. package/dist/server/cache-control.js.map +0 -1
  840. package/dist/server/cache-headers.js.map +0 -1
  841. package/dist/server/cache-proof.js.map +0 -1
  842. package/dist/server/client-reuse-manifest.js.map +0 -1
  843. package/dist/server/client-trace-metadata.js.map +0 -1
  844. package/dist/server/cookie-utils.js.map +0 -1
  845. package/dist/server/csp.js.map +0 -1
  846. package/dist/server/default-global-error-module.js.map +0 -1
  847. package/dist/server/default-not-found-module.js.map +0 -1
  848. package/dist/server/dev-error-overlay-store.js.map +0 -1
  849. package/dist/server/dev-error-overlay.js.map +0 -1
  850. package/dist/server/dev-lockfile.js.map +0 -1
  851. package/dist/server/dev-module-runner.js.map +0 -1
  852. package/dist/server/dev-origin-check.js.map +0 -1
  853. package/dist/server/dev-route-files.js.map +0 -1
  854. package/dist/server/dev-server.js.map +0 -1
  855. package/dist/server/document-initial-head.js.map +0 -1
  856. package/dist/server/edge-api-runtime.js.map +0 -1
  857. package/dist/server/file-based-metadata.js.map +0 -1
  858. package/dist/server/headers.js.map +0 -1
  859. package/dist/server/html.js.map +0 -1
  860. package/dist/server/http-error-responses.js.map +0 -1
  861. package/dist/server/image-optimization.js.map +0 -1
  862. package/dist/server/implicit-tags.js.map +0 -1
  863. package/dist/server/instrumentation-runtime.js.map +0 -1
  864. package/dist/server/instrumentation.js.map +0 -1
  865. package/dist/server/isr-cache.js.map +0 -1
  866. package/dist/server/metadata-route-build-data.js.map +0 -1
  867. package/dist/server/metadata-route-response.js.map +0 -1
  868. package/dist/server/metadata-routes.js.map +0 -1
  869. package/dist/server/middleware-matcher.js.map +0 -1
  870. package/dist/server/middleware-request-headers.js.map +0 -1
  871. package/dist/server/middleware-response-headers.js.map +0 -1
  872. package/dist/server/middleware-runtime.js.map +0 -1
  873. package/dist/server/middleware.js.map +0 -1
  874. package/dist/server/navigation-planner.js.map +0 -1
  875. package/dist/server/navigation-trace.js.map +0 -1
  876. package/dist/server/next-error-digest.js.map +0 -1
  877. package/dist/server/normalize-path.js.map +0 -1
  878. package/dist/server/pages-api-route.js.map +0 -1
  879. package/dist/server/pages-body-parser-config.js.map +0 -1
  880. package/dist/server/pages-data-route.js.map +0 -1
  881. package/dist/server/pages-default-404.js.map +0 -1
  882. package/dist/server/pages-document-initial-props.js.map +0 -1
  883. package/dist/server/pages-i18n.js.map +0 -1
  884. package/dist/server/pages-media-type.js.map +0 -1
  885. package/dist/server/pages-node-compat.js.map +0 -1
  886. package/dist/server/pages-page-data.js.map +0 -1
  887. package/dist/server/pages-page-method.js.map +0 -1
  888. package/dist/server/pages-page-response.js.map +0 -1
  889. package/dist/server/pages-serializable-props.js.map +0 -1
  890. package/dist/server/prerender-route-params.js.map +0 -1
  891. package/dist/server/prerender-work-unit-setup.js.map +0 -1
  892. package/dist/server/prod-server.js.map +0 -1
  893. package/dist/server/proxy-trust.js.map +0 -1
  894. package/dist/server/request-log.js.map +0 -1
  895. package/dist/server/request-pipeline.js.map +0 -1
  896. package/dist/server/rsc-stream-hints.js.map +0 -1
  897. package/dist/server/seed-cache.js.map +0 -1
  898. package/dist/server/server-action-not-found.js.map +0 -1
  899. package/dist/server/server-globals.js.map +0 -1
  900. package/dist/server/skip-cache-proof.js.map +0 -1
  901. package/dist/server/socket-error-backstop.js.map +0 -1
  902. package/dist/server/static-file-cache.js.map +0 -1
  903. package/dist/server/static-layout-client-reuse-proof.js.map +0 -1
  904. package/dist/server/streaming-metadata.js.map +0 -1
  905. package/dist/server/worker-utils.js.map +0 -1
  906. package/dist/shims/amp.js.map +0 -1
  907. package/dist/shims/app-router-scroll-state.js.map +0 -1
  908. package/dist/shims/app-router-scroll.js.map +0 -1
  909. package/dist/shims/app.js.map +0 -1
  910. package/dist/shims/before-interactive-context.js.map +0 -1
  911. package/dist/shims/cache-for-request.js.map +0 -1
  912. package/dist/shims/cache-runtime.js.map +0 -1
  913. package/dist/shims/cache.js.map +0 -1
  914. package/dist/shims/client-hook-error.js.map +0 -1
  915. package/dist/shims/client-locale.js.map +0 -1
  916. package/dist/shims/compat-router.js.map +0 -1
  917. package/dist/shims/config.js.map +0 -1
  918. package/dist/shims/constants.js.map +0 -1
  919. package/dist/shims/default-global-error.js.map +0 -1
  920. package/dist/shims/default-not-found.js.map +0 -1
  921. package/dist/shims/document.js.map +0 -1
  922. package/dist/shims/dynamic.js.map +0 -1
  923. package/dist/shims/error-boundary.js.map +0 -1
  924. package/dist/shims/error.js.map +0 -1
  925. package/dist/shims/fetch-cache.js.map +0 -1
  926. package/dist/shims/font-google-base.js.map +0 -1
  927. package/dist/shims/font-local.js.map +0 -1
  928. package/dist/shims/font-utils.js.map +0 -1
  929. package/dist/shims/form.js.map +0 -1
  930. package/dist/shims/hash-scroll.js.map +0 -1
  931. package/dist/shims/head-state.js.map +0 -1
  932. package/dist/shims/head.js.map +0 -1
  933. package/dist/shims/headers.js.map +0 -1
  934. package/dist/shims/i18n-context.js.map +0 -1
  935. package/dist/shims/i18n-state.js.map +0 -1
  936. package/dist/shims/image-config.js.map +0 -1
  937. package/dist/shims/image.js.map +0 -1
  938. package/dist/shims/internal/als-registry.js.map +0 -1
  939. package/dist/shims/internal/app-route-detection.js.map +0 -1
  940. package/dist/shims/internal/app-router-context.js.map +0 -1
  941. package/dist/shims/internal/cookie-serialize.js.map +0 -1
  942. package/dist/shims/internal/make-hanging-promise.js.map +0 -1
  943. package/dist/shims/internal/pages-data-fetch-dedup.js.map +0 -1
  944. package/dist/shims/internal/pages-data-target.js.map +0 -1
  945. package/dist/shims/internal/pages-data-url.js.map +0 -1
  946. package/dist/shims/internal/parse-cookie-header.js.map +0 -1
  947. package/dist/shims/internal/router-context.js.map +0 -1
  948. package/dist/shims/internal/utils.js.map +0 -1
  949. package/dist/shims/internal/work-unit-async-storage.js.map +0 -1
  950. package/dist/shims/layout-segment-context.js.map +0 -1
  951. package/dist/shims/legacy-image.js.map +0 -1
  952. package/dist/shims/link-prefetch.js.map +0 -1
  953. package/dist/shims/link.js.map +0 -1
  954. package/dist/shims/metadata.js.map +0 -1
  955. package/dist/shims/navigation-state.js.map +0 -1
  956. package/dist/shims/navigation.js.map +0 -1
  957. package/dist/shims/navigation.react-server.js.map +0 -1
  958. package/dist/shims/offline.js.map +0 -1
  959. package/dist/shims/og.js.map +0 -1
  960. package/dist/shims/pages-router-runtime.js.map +0 -1
  961. package/dist/shims/readonly-url-search-params.js.map +0 -1
  962. package/dist/shims/request-context.js.map +0 -1
  963. package/dist/shims/root-params.js.map +0 -1
  964. package/dist/shims/router-state.js.map +0 -1
  965. package/dist/shims/router.js.map +0 -1
  966. package/dist/shims/script-nonce-context.js.map +0 -1
  967. package/dist/shims/script.js.map +0 -1
  968. package/dist/shims/server.js.map +0 -1
  969. package/dist/shims/slot.js.map +0 -1
  970. package/dist/shims/thenable-params.js.map +0 -1
  971. package/dist/shims/unified-request-context.js.map +0 -1
  972. package/dist/shims/unrecognized-action-error.js.map +0 -1
  973. package/dist/shims/url-safety.js.map +0 -1
  974. package/dist/shims/url-utils.js.map +0 -1
  975. package/dist/shims/use-merged-ref.js.map +0 -1
  976. package/dist/shims/web-vitals.js.map +0 -1
  977. package/dist/typegen.js.map +0 -1
  978. package/dist/utils/asset-prefix.js.map +0 -1
  979. package/dist/utils/base-path.js.map +0 -1
  980. package/dist/utils/cache-control-metadata.js.map +0 -1
  981. package/dist/utils/client-build-manifest.js.map +0 -1
  982. package/dist/utils/domain-locale.js.map +0 -1
  983. package/dist/utils/encode-cache-tag.js.map +0 -1
  984. package/dist/utils/error-cause.js.map +0 -1
  985. package/dist/utils/hash.js.map +0 -1
  986. package/dist/utils/html-limited-bots.js.map +0 -1
  987. package/dist/utils/lazy-chunks.js.map +0 -1
  988. package/dist/utils/manifest-paths.js.map +0 -1
  989. package/dist/utils/mdx-scan.js.map +0 -1
  990. package/dist/utils/navigation-signal.js.map +0 -1
  991. package/dist/utils/path.js.map +0 -1
  992. package/dist/utils/prerender-output-paths.js.map +0 -1
  993. package/dist/utils/project.js.map +0 -1
  994. package/dist/utils/public-routes.js.map +0 -1
  995. package/dist/utils/query.js.map +0 -1
  996. package/dist/utils/record.js.map +0 -1
  997. package/dist/utils/safe-json-file.js.map +0 -1
  998. package/dist/utils/sorted-array.js.map +0 -1
  999. package/dist/utils/text-stream.js.map +0 -1
  1000. package/dist/utils/vinext-root.js.map +0 -1
  1001. package/dist/utils/vite-version.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"metadata-routes.js","names":[],"sources":["../../src/server/metadata-routes.ts"],"sourcesContent":["/**\n * File-based metadata route handling.\n *\n * Next.js supports special files in the app/ directory that auto-generate\n * metadata routes:\n * - sitemap.ts/.xml → /sitemap.xml (application/xml)\n * - robots.ts/.txt → /robots.txt (text/plain)\n * - manifest.ts/.json/.webmanifest → /manifest.webmanifest (application/manifest+json)\n * - icon.tsx/.png → /icon (image/*)\n * - opengraph-image.tsx/.png → /opengraph-image (image/*)\n * - twitter-image.tsx/.png → /twitter-image (image/*)\n * - apple-icon.tsx/.png → /apple-icon (image/*)\n * - favicon.ico → /favicon.ico (image/x-icon)\n *\n * Dynamic versions (ts/tsx/js) export a default function that returns the data.\n * Static versions (xml/txt/json/png/etc.) are served as-is.\n */\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { matchRoutePattern } from \"../routing/route-pattern.js\";\n\n// -------------------------------------------------------------------\n// Types matching Next.js MetadataRoute\n// -------------------------------------------------------------------\n\nexport type SitemapEntry = {\n url: string;\n lastModified?: string | Date;\n changeFrequency?: \"always\" | \"hourly\" | \"daily\" | \"weekly\" | \"monthly\" | \"yearly\" | \"never\";\n priority?: number;\n alternates?: {\n languages?: Record<string, string>;\n };\n images?: string[];\n videos?: Array<{\n title: string;\n thumbnail_loc: string;\n description: string;\n content_loc?: string;\n player_loc?: string;\n duration?: number;\n expiration_date?: string | Date;\n rating?: number;\n view_count?: number;\n publication_date?: string | Date;\n family_friendly?: \"yes\" | \"no\";\n restriction?: { relationship: \"allow\" | \"deny\"; content: string };\n platform?: { relationship: \"allow\" | \"deny\"; content: string };\n requires_subscription?: \"yes\" | \"no\";\n uploader?: {\n info?: string;\n content?: string;\n };\n live?: \"yes\" | \"no\";\n tag?: string;\n }>;\n};\n\nexport type RobotsRule = {\n userAgent?: string | string[];\n allow?: string | string[];\n disallow?: string | string[];\n crawlDelay?: number;\n other?: Record<string, string | number | Array<string | number>>;\n};\n\nexport type RobotsConfig = {\n rules: RobotsRule | RobotsRule[];\n sitemap?: string | string[];\n host?: string;\n};\n\nexport type ManifestConfig = {\n name?: string;\n short_name?: string;\n description?: string;\n start_url?: string;\n display?: \"fullscreen\" | \"standalone\" | \"minimal-ui\" | \"browser\";\n background_color?: string;\n theme_color?: string;\n icons?: Array<{\n src: string;\n sizes?: string;\n type?: string;\n purpose?: string;\n }>;\n [key: string]: unknown;\n};\n\n// -------------------------------------------------------------------\n// Known metadata file patterns\n// -------------------------------------------------------------------\n\n/** Map of metadata file base names to their URL path and content type. */\nexport const METADATA_FILE_MAP: Record<\n string,\n {\n /** URL path this file is served at */\n urlPath: string;\n /** Content type for the response */\n contentType: string;\n /** Whether this can be dynamic (.ts/.tsx/.js) */\n canBeDynamic: boolean;\n /** File extensions for static variants */\n staticExtensions: string[];\n /** File extensions for dynamic variants */\n dynamicExtensions: string[];\n /** Whether this can be nested in sub-segments */\n nestable: boolean;\n }\n> = {\n sitemap: {\n urlPath: \"/sitemap.xml\",\n contentType: \"application/xml\",\n canBeDynamic: true,\n staticExtensions: [\".xml\"],\n dynamicExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n nestable: true,\n },\n robots: {\n urlPath: \"/robots.txt\",\n contentType: \"text/plain\",\n canBeDynamic: true,\n staticExtensions: [\".txt\"],\n dynamicExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n nestable: false,\n },\n manifest: {\n urlPath: \"/manifest.webmanifest\",\n contentType: \"application/manifest+json\",\n canBeDynamic: true,\n staticExtensions: [\".json\", \".webmanifest\"],\n dynamicExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n nestable: false,\n },\n favicon: {\n urlPath: \"/favicon.ico\",\n contentType: \"image/x-icon\",\n canBeDynamic: false,\n staticExtensions: [\".ico\"],\n dynamicExtensions: [],\n nestable: false,\n },\n icon: {\n urlPath: \"/icon\",\n contentType: \"image/png\",\n canBeDynamic: true,\n staticExtensions: [\".ico\", \".jpg\", \".jpeg\", \".png\", \".svg\"],\n dynamicExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n nestable: true,\n },\n \"opengraph-image\": {\n urlPath: \"/opengraph-image\",\n contentType: \"image/png\",\n canBeDynamic: true,\n staticExtensions: [\".jpg\", \".jpeg\", \".png\", \".gif\"],\n dynamicExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n nestable: true,\n },\n \"twitter-image\": {\n urlPath: \"/twitter-image\",\n contentType: \"image/png\",\n canBeDynamic: true,\n staticExtensions: [\".jpg\", \".jpeg\", \".png\", \".gif\"],\n dynamicExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n nestable: true,\n },\n \"apple-icon\": {\n urlPath: \"/apple-icon\",\n contentType: \"image/png\",\n canBeDynamic: true,\n staticExtensions: [\".jpg\", \".jpeg\", \".png\"],\n dynamicExtensions: [\".tsx\", \".ts\", \".jsx\", \".js\"],\n nestable: true,\n },\n};\n\n// -------------------------------------------------------------------\n// Serializers\n// -------------------------------------------------------------------\n\n/** Escape the five XML special characters in text content and attribute values. */\nfunction escapeXml(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&apos;\");\n}\n\n/**\n * Convert a sitemap array to XML string.\n */\nexport function sitemapToXml(entries: SitemapEntry[]): string {\n const hasAlternates = entries.some((entry) => Object.keys(entry.alternates ?? {}).length > 0);\n const hasImages = entries.some((entry) => Boolean(entry.images?.length));\n const hasVideos = entries.some((entry) => Boolean(entry.videos?.length));\n let content = \"\";\n\n content += '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n';\n content += '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"';\n if (hasImages) {\n content += ' xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"';\n }\n if (hasVideos) {\n content += ' xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"';\n }\n if (hasAlternates) {\n content += ' xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\\n';\n } else {\n content += \">\\n\";\n }\n\n for (const entry of entries) {\n content += \"<url>\\n\";\n content += `<loc>${escapeXml(entry.url)}</loc>\\n`;\n\n const languages = entry.alternates?.languages;\n if (languages && Object.keys(languages).length) {\n for (const language in languages) {\n content += `<xhtml:link rel=\"alternate\" hreflang=\"${escapeXml(language)}\" href=\"${escapeXml(languages[language])}\" />\\n`;\n }\n }\n\n if (entry.images?.length) {\n for (const image of entry.images) {\n content += `<image:image>\\n<image:loc>${escapeXml(image)}</image:loc>\\n</image:image>\\n`;\n }\n }\n\n if (entry.videos?.length) {\n for (const video of entry.videos) {\n const videoFields = [\n \"<video:video>\",\n `<video:title>${escapeXml(String(video.title))}</video:title>`,\n `<video:thumbnail_loc>${escapeXml(String(video.thumbnail_loc))}</video:thumbnail_loc>`,\n `<video:description>${escapeXml(String(video.description))}</video:description>`,\n video.content_loc &&\n `<video:content_loc>${escapeXml(String(video.content_loc))}</video:content_loc>`,\n video.player_loc &&\n `<video:player_loc>${escapeXml(String(video.player_loc))}</video:player_loc>`,\n video.duration && `<video:duration>${video.duration}</video:duration>`,\n video.view_count && `<video:view_count>${video.view_count}</video:view_count>`,\n video.tag && `<video:tag>${escapeXml(String(video.tag))}</video:tag>`,\n video.rating && `<video:rating>${video.rating}</video:rating>`,\n video.expiration_date &&\n `<video:expiration_date>${escapeXml(String(video.expiration_date))}</video:expiration_date>`,\n video.publication_date &&\n `<video:publication_date>${escapeXml(String(video.publication_date))}</video:publication_date>`,\n video.family_friendly &&\n `<video:family_friendly>${video.family_friendly}</video:family_friendly>`,\n video.requires_subscription &&\n `<video:requires_subscription>${video.requires_subscription}</video:requires_subscription>`,\n video.live && `<video:live>${video.live}</video:live>`,\n video.restriction &&\n `<video:restriction relationship=\"${escapeXml(String(video.restriction.relationship))}\">${escapeXml(String(video.restriction.content))}</video:restriction>`,\n video.platform &&\n `<video:platform relationship=\"${escapeXml(String(video.platform.relationship))}\">${escapeXml(String(video.platform.content))}</video:platform>`,\n video.uploader &&\n `<video:uploader${video.uploader.info ? ` info=\"${escapeXml(String(video.uploader.info))}\"` : \"\"}>${escapeXml(String(video.uploader.content))}</video:uploader>`,\n \"</video:video>\\n\",\n ].filter(Boolean);\n content += videoFields.join(\"\\n\");\n }\n }\n\n if (entry.lastModified) {\n content += `<lastmod>${serializeDate(entry.lastModified)}</lastmod>\\n`;\n }\n if (entry.changeFrequency) {\n content += `<changefreq>${entry.changeFrequency}</changefreq>\\n`;\n }\n if (typeof entry.priority === \"number\") {\n content += `<priority>${entry.priority}</priority>\\n`;\n }\n content += \"</url>\\n\";\n }\n\n content += \"</urlset>\\n\";\n return content;\n}\n\n/**\n * Convert a robots config to text format.\n */\nexport function robotsToText(config: RobotsConfig): string {\n const lines: string[] = [];\n const rules = Array.isArray(config.rules) ? config.rules : [config.rules];\n\n for (const rule of rules) {\n const agents = Array.isArray(rule.userAgent) ? rule.userAgent : [rule.userAgent ?? \"*\"];\n\n for (const agent of agents) {\n lines.push(`User-Agent: ${agent}`);\n }\n\n if (rule.allow) {\n const allows = Array.isArray(rule.allow) ? rule.allow : [rule.allow];\n for (const allow of allows) {\n lines.push(`Allow: ${allow}`);\n }\n }\n\n if (rule.disallow) {\n const disallows = Array.isArray(rule.disallow) ? rule.disallow : [rule.disallow];\n for (const disallow of disallows) {\n lines.push(`Disallow: ${disallow}`);\n }\n }\n\n if (rule.crawlDelay !== undefined) {\n lines.push(`Crawl-delay: ${rule.crawlDelay}`);\n }\n\n if (rule.other) {\n for (const key of Object.keys(rule.other)) {\n const value = rule.other[key];\n if (value == null) continue;\n const values = Array.isArray(value) ? value : [value];\n for (const v of values) {\n lines.push(`${key}: ${v}`);\n }\n }\n }\n\n lines.push(\"\");\n }\n\n if (config.host) {\n lines.push(`Host: ${config.host}`);\n }\n\n if (config.sitemap) {\n const sitemaps = Array.isArray(config.sitemap) ? config.sitemap : [config.sitemap];\n for (const sitemap of sitemaps) {\n lines.push(`Sitemap: ${sitemap}`);\n }\n }\n\n return lines.join(\"\\n\").trim() + \"\\n\";\n}\n\n/**\n * Convert a manifest config to JSON string.\n */\nexport function manifestToJson(config: ManifestConfig): string {\n return JSON.stringify(config, null, 2);\n}\n\nfunction serializeDate(value: string | Date): string {\n return value instanceof Date ? value.toISOString() : value;\n}\n\n// -------------------------------------------------------------------\n// Static metadata URL resolution\n//\n// Ported from Next.js: packages/next/src/lib/metadata/get-metadata-route.ts\n// https://github.com/vercel/next.js/blob/7873aea/packages/next/src/lib/metadata/get-metadata-route.ts\n//\n// Static metadata files (like favicon.ico, icon.png) under dynamic parents\n// get a fixed URL with \"-\" placeholders instead of literal \"[param]\" segments.\n// Route groups and parallel route parents trigger a unique hash suffix to\n// avoid collisions.\n// -------------------------------------------------------------------\n\n/**\n * Regular expression pattern used to match route parameters.\n * Matches both single parameters and parameter groups.\n * Examples:\n * - `[[...slug]]` matches parameter group with key 'slug', repeat: true, optional: true\n * - `[...slug]` matches parameter group with key 'slug', repeat: true, optional: false\n * - `[[foo]]` matches parameter with key 'foo', repeat: false, optional: true\n * - `[bar]` matches parameter with key 'bar', repeat: false, optional: false\n */\nconst PARAMETER_PATTERN = /^([^[]*)\\[((?:\\[[^\\]]*\\])|[^\\]]+)\\](.*)$/;\n\nfunction isGroupSegment(segment: string): boolean {\n return segment.startsWith(\"(\") && segment.endsWith(\")\");\n}\n\nfunction isParallelRouteSegment(segment: string): boolean {\n return segment.startsWith(\"@\") && segment !== \"@children\";\n}\n\nfunction normalizeStaticMetadataRouteSegment(segment: string): string {\n let normalizedSegment = segment;\n let match = normalizedSegment.match(PARAMETER_PATTERN);\n while (match) {\n normalizedSegment = `${match[1]}-${match[3]}`;\n match = normalizedSegment.match(PARAMETER_PATTERN);\n }\n return normalizedSegment;\n}\n\nfunction getStaticMetadataRoute(appDirPath: string): string {\n const segments = appDirPath.split(\"/\").filter(Boolean);\n const normalizedSegments: string[] = [];\n for (const seg of segments) {\n // Strip route groups and all parallel route slots (including @children)\n // from the URL path. The @children slot is the default parallel route\n // and must also be invisible in the URL, matching Next.js behavior.\n if (isGroupSegment(seg) || seg.startsWith(\"@\")) continue;\n normalizedSegments.push(normalizeStaticMetadataRouteSegment(seg));\n }\n return normalizedSegments.length > 0 ? `/${normalizedSegments.join(\"/\")}` : \"\";\n}\n\nfunction hashMetadataRouteParentPath(parentPathname: string): string {\n let hash = 5381;\n for (let i = 0; i < parentPathname.length; i++) {\n hash = ((hash << 5) + hash + parentPathname.charCodeAt(i)) & 0xffffffff;\n }\n return (hash >>> 0).toString(36).slice(0, 6);\n}\n\nfunction getMetadataRouteSuffix(page: string): string {\n const lastSlash = page.lastIndexOf(\"/\");\n const parentPathname = lastSlash > 0 ? page.slice(0, lastSlash) : \"\";\n if (page.endsWith(\"/sitemap\") || page.endsWith(\"/sitemap.xml\")) return \"\";\n const segments = parentPathname.split(\"/\");\n const hasInvisibleParent = segments.some(\n (seg) => isGroupSegment(seg) || isParallelRouteSegment(seg),\n );\n if (!hasInvisibleParent) return \"\";\n return hashMetadataRouteParentPath(parentPathname);\n}\n\nfunction computeMetadataRouteSuffix(\n appDirPath: string,\n leafName: string,\n): { route: string; suffix: string } {\n const route = getStaticMetadataRoute(appDirPath);\n const pagePath =\n appDirPath === \"\" || appDirPath === \"/\" ? `/${leafName}` : `${appDirPath}/${leafName}`;\n const suffix = getMetadataRouteSuffix(pagePath);\n return { route, suffix };\n}\n\nfunction getMetadataRouteFilename(appDirPath: string, lastSegment: string): string {\n const ext = path.posix.extname(lastSegment);\n const name = lastSegment.slice(0, -ext.length || undefined);\n const { suffix } = computeMetadataRouteSuffix(appDirPath, name);\n const routeSuffix = suffix ? `-${suffix}` : \"\";\n return `${name}${routeSuffix}${ext}`;\n}\n\n/**\n * Compute the static URL for a metadata file given its app directory\n * parent path and filename.\n *\n * Example:\n * fillStaticMetadataSegment(\"/\", \"favicon.ico\") -> \"/favicon.ico\"\n * fillStaticMetadataSegment(\"/blog/[slug]\", \"favicon.ico\") -> \"/blog/-/favicon.ico\"\n * fillStaticMetadataSegment(\"/(group)/group\", \"icon.png\") -> \"/group/icon-131tc6.png\"\n */\nexport function fillStaticMetadataSegment(appDirPath: string, lastSegment: string): string {\n const route = getStaticMetadataRoute(appDirPath);\n const filename = getMetadataRouteFilename(appDirPath, lastSegment);\n return route === \"\" ? `/${filename}` : `${route}/${filename}`;\n}\n\n// -------------------------------------------------------------------\n// Metadata route discovery\n// -------------------------------------------------------------------\n\nexport type MetadataFileRoute = {\n /** Type of metadata file */\n type: string;\n /** Whether this is a dynamic (code-generated) route */\n isDynamic: boolean;\n /** Imported dynamic module for code-generated metadata routes. */\n module?: Record<string, unknown>;\n /** Absolute file path */\n filePath: string;\n /** Route prefix where this metadata applies, preserving dynamic segment names. */\n routePrefix: string;\n /** Raw app tree segments where this metadata file is colocated. */\n routeSegments?: string[];\n /** Pattern parts for matching dynamic metadata routes at request time. */\n patternParts?: string[];\n /** URL path this file is served at */\n servedUrl: string;\n /** Content type for the response */\n contentType: string;\n /** Optional metadata used to inject file-based routes into <head>. */\n headData?: MetadataRouteHeadData;\n /** Optional content hash for cache-busting metadata links. */\n contentHash?: string;\n /** Sibling .alt.txt file for static social image metadata routes. */\n altFilePath?: string;\n};\n\nexport type MetadataRouteHeadData =\n | {\n kind: \"favicon\" | \"icon\" | \"apple\";\n href: string;\n type?: string;\n sizes?: string;\n }\n | {\n kind: \"openGraph\" | \"twitter\";\n href: string;\n type?: string;\n width?: number;\n height?: number;\n alt?: string;\n }\n | {\n kind: \"manifest\";\n href: string;\n };\n\nexport function getMetadataRouteKind(\n route: Pick<MetadataFileRoute, \"type\">,\n): MetadataRouteHeadData[\"kind\"] | null {\n if (route.type === \"favicon\") return \"favicon\";\n if (route.type === \"icon\") return \"icon\";\n if (route.type === \"apple-icon\") return \"apple\";\n if (route.type === \"opengraph-image\") return \"openGraph\";\n if (route.type === \"twitter-image\") return \"twitter\";\n if (route.type === \"manifest\") return \"manifest\";\n return null;\n}\n\nexport function getMetadataImageRouteKind(\n route: Pick<MetadataFileRoute, \"type\">,\n): Extract<MetadataRouteHeadData[\"kind\"], \"icon\" | \"apple\" | \"openGraph\" | \"twitter\"> | null {\n const kind = getMetadataRouteKind(route);\n if (kind === \"icon\" || kind === \"apple\" || kind === \"openGraph\" || kind === \"twitter\") {\n return kind;\n }\n return null;\n}\n\nconst metadataImageIdPattern = /^[a-zA-Z0-9-_.]+$/;\n\nexport function isValidMetadataImageId(id: string): boolean {\n return metadataImageIdPattern.test(id);\n}\n\nexport function matchMetadataRoutePattern(\n urlParts: string[],\n patternParts: string[],\n): Record<string, string | string[]> | null {\n return matchRoutePattern(urlParts, patternParts);\n}\n\nfunction metadataRouteSuffix(parentSegments: string[], metaType: string): string {\n if (metaType === \"sitemap\") {\n // Sitemap is exempt per Next.js (robots/manifest are root-only, so\n // invisible parents never apply — but we keep the exemption list\n // matching getMetadataRouteSuffix for defensive consistency).\n return \"\";\n }\n\n const hasInvisibleParent = parentSegments.some(\n (segment) =>\n (segment.startsWith(\"(\") && segment.endsWith(\")\")) ||\n (segment.startsWith(\"@\") && segment !== \"@children\"),\n );\n if (!hasInvisibleParent) return \"\";\n\n return hashMetadataRouteParentPath(`/${parentSegments.join(\"/\")}`);\n}\n\nfunction withMetadataSuffix(urlPath: string, suffix: string): string {\n if (!suffix) return urlPath;\n const parsed = path.posix.parse(urlPath);\n return path.posix.join(parsed.dir || \"/\", `${parsed.name}-${suffix}${parsed.ext}`);\n}\n\nfunction getMetadataServedUrl(\n metaType: string,\n config: { urlPath: string },\n ext: string,\n isDynamic: boolean,\n suffix: string,\n routeBaseName: string,\n): string {\n if (\n isDynamic &&\n (metaType === \"icon\" ||\n metaType === \"apple-icon\" ||\n metaType === \"opengraph-image\" ||\n metaType === \"twitter-image\")\n ) {\n return withMetadataSuffix(`/${routeBaseName}`, suffix);\n }\n\n if (isDynamic) {\n return withMetadataSuffix(config.urlPath, suffix);\n }\n\n if (metaType === \"manifest\") {\n return withMetadataSuffix(`/${routeBaseName}${ext}`, suffix);\n }\n\n if (\n metaType === \"icon\" ||\n metaType === \"apple-icon\" ||\n metaType === \"opengraph-image\" ||\n metaType === \"twitter-image\"\n ) {\n return withMetadataSuffix(`/${routeBaseName}${ext}`, suffix);\n }\n\n return withMetadataSuffix(config.urlPath, suffix);\n}\n\nexport function matchMetadataFileBaseName(metaType: string, baseName: string): string | null {\n if (baseName === metaType) {\n return baseName;\n }\n\n if (\n metaType === \"icon\" ||\n metaType === \"apple-icon\" ||\n metaType === \"opengraph-image\" ||\n metaType === \"twitter-image\"\n ) {\n const suffix = baseName.slice(metaType.length);\n if (/^\\d$/.test(suffix)) {\n return baseName;\n }\n }\n\n return null;\n}\n\n/**\n * Scan an app directory for metadata files.\n */\nexport function scanMetadataFiles(appDir: string): MetadataFileRoute[] {\n const routes: MetadataFileRoute[] = [];\n\n // Scan the app directory recursively\n function scan(dir: string, urlPrefix: string, parentSegments: string[]): void {\n if (!fs.existsSync(dir)) return;\n\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const dirName = entry.name;\n if (dirName.startsWith(\"_\")) continue;\n\n const isRouteGroup = dirName.startsWith(\"(\") && dirName.endsWith(\")\");\n const isParallelRoute = dirName.startsWith(\"@\");\n const nextUrlPrefix =\n isRouteGroup || isParallelRoute ? urlPrefix : `${urlPrefix}/${dirName}`;\n scan(path.join(dir, dirName), nextUrlPrefix, [...parentSegments, dirName]);\n continue;\n }\n\n // Check each metadata file pattern\n const fileName = entry.name;\n const baseName = fileName.replace(/\\.[^.]+$/, \"\");\n const ext = fileName.slice(baseName.length);\n\n for (const [metaType, config] of Object.entries(METADATA_FILE_MAP)) {\n const routeBaseName = matchMetadataFileBaseName(metaType, baseName);\n if (!routeBaseName) continue;\n\n // Check nestability — non-nestable types only at root\n if (!config.nestable && urlPrefix !== \"\") continue;\n\n // Check if this is a static or dynamic variant\n const isStatic = config.staticExtensions.includes(ext);\n const isDynamic = config.dynamicExtensions.includes(ext);\n\n if (!isStatic && !isDynamic) continue;\n const appDirPath = parentSegments.length > 0 ? `/${parentSegments.join(\"/\")}` : \"\";\n const suffix = metadataRouteSuffix(parentSegments, metaType);\n const urlPath = getMetadataServedUrl(\n metaType,\n config,\n ext,\n isDynamic,\n suffix,\n routeBaseName,\n );\n const servedUrl = isStatic\n ? fillStaticMetadataSegment(appDirPath, `${routeBaseName}${ext}`)\n : urlPrefix === \"\"\n ? urlPath\n : `${urlPrefix}${urlPath}`;\n const altFilePath =\n isStatic && (metaType === \"opengraph-image\" || metaType === \"twitter-image\")\n ? resolveStaticMetadataAltFilePath(dir, baseName)\n : undefined;\n\n routes.push({\n type: metaType,\n isDynamic,\n filePath: path.join(dir, fileName),\n routePrefix: urlPrefix,\n routeSegments: parentSegments,\n servedUrl,\n contentType:\n isStatic && metaType === \"manifest\"\n ? config.contentType\n : isStatic\n ? getStaticContentType(ext, config.contentType)\n : config.contentType,\n altFilePath,\n });\n }\n }\n }\n\n scan(appDir, \"\", []);\n\n // Deduplicate: if both dynamic and static variants exist at the same URL,\n // keep only the dynamic one (matches Next.js behavior).\n const byUrl = new Map<string, MetadataFileRoute>();\n for (const route of routes) {\n const existing = byUrl.get(route.servedUrl);\n if (!existing) {\n byUrl.set(route.servedUrl, route);\n } else if (route.isDynamic && !existing.isDynamic) {\n // Dynamic takes priority over static\n byUrl.set(route.servedUrl, route);\n }\n // If both are static or both dynamic, keep the first one found\n }\n return Array.from(byUrl.values());\n}\n\nfunction resolveStaticMetadataAltFilePath(dir: string, baseName: string): string | undefined {\n const altPath = path.join(dir, `${baseName}.alt.txt`);\n return fs.existsSync(altPath) ? altPath : undefined;\n}\n\nfunction getStaticContentType(ext: string, fallback: string): string {\n const map: Record<string, string> = {\n \".xml\": \"application/xml\",\n \".txt\": \"text/plain\",\n \".json\": \"application/json\",\n \".webmanifest\": \"application/manifest+json\",\n \".ico\": \"image/x-icon\",\n \".png\": \"image/png\",\n \".jpg\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AEN,OAAO,KAAK;KACV,MAAM;KACN;KACA,UAAU,KAAK,KAAK,KAAK,SAAS;KAClC,aAAa;KACb,eAAe;KACf;KACA,aACE,YAAY,aAAa,aACrB,OAAO,cACP,WACE,qBAAqB,KAAK,OAAO,YAAY,GAC7C,OAAO;KACf;KACD,CAAC;;;;CAKR,KAAK,QAAQ,IAAI,EAAE,CAAC;CAIpB,MAAM,wBAAQ,IAAI,KAAgC;CAClD,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,WAAW,MAAM,IAAI,MAAM,UAAU;EAC3C,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,WAAW,MAAM;OAC5B,IAAI,MAAM,aAAa,CAAC,SAAS,WAEtC,MAAM,IAAI,MAAM,WAAW,MAAM;;CAIrC,OAAO,MAAM,KAAK,MAAM,QAAQ,CAAC;;AAGnC,SAAS,iCAAiC,KAAa,UAAsC;CAC3F,MAAM,UAAU,KAAK,KAAK,KAAK,GAAG,SAAS,UAAU;CACrD,OAAO,GAAG,WAAW,QAAQ,GAAG,UAAU,KAAA;;AAG5C,SAAS,qBAAqB,KAAa,UAA0B;CAanE,OAAO;EAXL,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,gBAAgB;EAChB,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,QAAQ;EAEA,CAAC,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware-matcher.js","names":[],"sources":["../../src/server/middleware-matcher.ts"],"sourcesContent":["import {\n checkHasConditions,\n requestContextFromRequest,\n safeRegExp,\n type RequestContext,\n} from \"../config/config-matchers.js\";\nimport type { HasCondition, NextI18nConfig } from \"../config/next-config.js\";\nimport { removeTrailingSlash } from \"../utils/base-path.js\";\n\nexport type MiddlewareMatcherObject = {\n source: string;\n locale?: false;\n has?: HasCondition[];\n missing?: HasCondition[];\n};\n\nexport type MatcherConfig = string | Array<string | MiddlewareMatcherObject>;\n\nconst EMPTY_MIDDLEWARE_REQUEST_CONTEXT: RequestContext = {\n headers: new Headers(),\n cookies: {},\n query: new URLSearchParams(),\n host: \"\",\n};\n\nconst _mwPatternCache = new Map<string, RegExp | null>();\n\nexport function matchesMiddleware(\n pathname: string,\n matcher: MatcherConfig | undefined,\n request?: Request,\n i18nConfig?: NextI18nConfig | null,\n): boolean {\n if (!matcher) {\n return true;\n }\n\n if (typeof matcher === \"string\") {\n return matchMatcherPattern(pathname, matcher, i18nConfig);\n }\n if (!Array.isArray(matcher)) {\n return false;\n }\n\n const requestContext = request\n ? requestContextFromRequest(request)\n : EMPTY_MIDDLEWARE_REQUEST_CONTEXT;\n\n for (const m of matcher) {\n if (typeof m === \"string\") {\n if (matchMatcherPattern(pathname, m, i18nConfig)) {\n return true;\n }\n continue;\n }\n\n if (isValidMiddlewareMatcherObject(m)) {\n if (!matchObjectMatcher(pathname, m, i18nConfig)) {\n continue;\n }\n\n if (!checkHasConditions(m.has, m.missing, requestContext)) {\n continue;\n }\n\n return true;\n }\n }\n\n return false;\n}\n\nfunction isValidMiddlewareMatcherObject(value: unknown): value is MiddlewareMatcherObject {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\n if (!(\"source\" in value) || typeof value.source !== \"string\") return false;\n\n for (const key of Object.keys(value)) {\n if (key !== \"source\" && key !== \"locale\" && key !== \"has\" && key !== \"missing\") {\n return false;\n }\n }\n\n if (\"locale\" in value && value.locale !== undefined && value.locale !== false) return false;\n if (\"has\" in value && value.has !== undefined && !Array.isArray(value.has)) return false;\n if (\"missing\" in value && value.missing !== undefined && !Array.isArray(value.missing)) {\n return false;\n }\n\n return true;\n}\n\nfunction matchMatcherPattern(\n pathname: string,\n pattern: string,\n i18nConfig?: NextI18nConfig | null,\n): boolean {\n if (!i18nConfig) return matchPattern(pathname, pattern);\n\n const localeStrippedPathname = stripLocalePrefix(pathname, i18nConfig);\n return matchPattern(localeStrippedPathname ?? pathname, pattern);\n}\n\nfunction matchObjectMatcher(\n pathname: string,\n matcher: MiddlewareMatcherObject,\n i18nConfig?: NextI18nConfig | null,\n): boolean {\n return matcher.locale === false\n ? matchPattern(pathname, matcher.source)\n : matchMatcherPattern(pathname, matcher.source, i18nConfig);\n}\n\nfunction stripLocalePrefix(pathname: string, i18nConfig: NextI18nConfig): string | null {\n if (pathname === \"/\") return null;\n\n const segments = pathname.split(\"/\");\n const firstSegment = segments[1];\n if (!firstSegment || !i18nConfig.locales.includes(firstSegment)) {\n return null;\n }\n\n const stripped = \"/\" + segments.slice(2).join(\"/\");\n return removeTrailingSlash(stripped);\n}\n\nexport function matchPattern(pathname: string, pattern: string): boolean {\n let cached = _mwPatternCache.get(pattern);\n if (cached === undefined) {\n cached = compileMatcherPattern(pattern);\n _mwPatternCache.set(pattern, cached);\n }\n if (cached === null) return pathname === pattern;\n return cached.test(pathname);\n}\n\nfunction extractConstraint(str: string, re: RegExp): string | null {\n if (str[re.lastIndex] !== \"(\") return null;\n const start = re.lastIndex + 1;\n let depth = 1;\n let i = start;\n while (i < str.length && depth > 0) {\n if (str[i] === \"(\") depth++;\n else if (str[i] === \")\") depth--;\n i++;\n }\n if (depth !== 0) return null;\n re.lastIndex = i;\n return str.slice(start, i - 1);\n}\n\nfunction compileMatcherPattern(pattern: string): RegExp | null {\n const hasConstraints = /:[\\w-]+[*+]?\\(/.test(pattern);\n\n if (!hasConstraints && (pattern.includes(\"(\") || pattern.includes(\"\\\\\"))) {\n return safeRegExp(\"^\" + pattern + \"$\");\n }\n\n let regexStr = \"\";\n const tokenRe = /\\/:([\\w-]+)\\*|\\/:([\\w-]+)\\+|:([\\w-]+)|[.]|[^/:.]+|./g;\n let tok: RegExpExecArray | null;\n while ((tok = tokenRe.exec(pattern)) !== null) {\n if (tok[1] !== undefined) {\n const constraint = hasConstraints ? extractConstraint(pattern, tokenRe) : null;\n regexStr += constraint !== null ? `(?:/(${constraint}))?` : \"(?:/.*)?\";\n } else if (tok[2] !== undefined) {\n const constraint = hasConstraints ? extractConstraint(pattern, tokenRe) : null;\n regexStr += constraint !== null ? `(?:/(${constraint}))` : \"(?:/.+)\";\n } else if (tok[3] !== undefined) {\n const constraint = hasConstraints ? extractConstraint(pattern, tokenRe) : null;\n const isOptional = pattern[tokenRe.lastIndex] === \"?\";\n if (isOptional) tokenRe.lastIndex += 1;\n\n const group = constraint !== null ? `(${constraint})` : \"([^/]+)\";\n\n if (isOptional && regexStr.endsWith(\"/\")) {\n regexStr = regexStr.slice(0, -1) + `(?:/${group})?`;\n } else if (isOptional) {\n regexStr += `${group}?`;\n } else {\n regexStr += group;\n }\n } else if (tok[0] === \".\") {\n regexStr += \"\\\\.\";\n } else {\n regexStr += tok[0];\n }\n }\n\n return safeRegExp(\"^\" + regexStr + \"$\");\n}\n"],"mappings":";;;AAkBA,MAAM,mCAAmD;CACvD,SAAS,IAAI,SAAS;CACtB,SAAS,EAAE;CACX,OAAO,IAAI,iBAAiB;CAC5B,MAAM;CACP;AAED,MAAM,kCAAkB,IAAI,KAA4B;AAExD,SAAgB,kBACd,UACA,SACA,SACA,YACS;CACT,IAAI,CAAC,SACH,OAAO;CAGT,IAAI,OAAO,YAAY,UACrB,OAAO,oBAAoB,UAAU,SAAS,WAAW;CAE3D,IAAI,CAAC,MAAM,QAAQ,QAAQ,EACzB,OAAO;CAGT,MAAM,iBAAiB,UACnB,0BAA0B,QAAQ,GAClC;CAEJ,KAAK,MAAM,KAAK,SAAS;EACvB,IAAI,OAAO,MAAM,UAAU;GACzB,IAAI,oBAAoB,UAAU,GAAG,WAAW,EAC9C,OAAO;GAET;;EAGF,IAAI,+BAA+B,EAAE,EAAE;GACrC,IAAI,CAAC,mBAAmB,UAAU,GAAG,WAAW,EAC9C;GAGF,IAAI,CAAC,mBAAmB,EAAE,KAAK,EAAE,SAAS,eAAe,EACvD;GAGF,OAAO;;;CAIX,OAAO;;AAGT,SAAS,+BAA+B,OAAkD;CACxF,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,MAAM,EAAE,OAAO;CAExE,IAAI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AO,KACpB,YAAY;MAEZ,YAAY,IAAI;CAIpB,OAAO,WAAW,MAAM,WAAW,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware-request-headers.js","names":[],"sources":["../../src/server/middleware-request-headers.ts"],"sourcesContent":["import {\n MIDDLEWARE_OVERRIDE_HEADERS,\n MIDDLEWARE_REQUEST_HEADER_PREFIX,\n MIDDLEWARE_SET_COOKIE_HEADER,\n} from \"./headers.js\";\nconst CREDENTIAL_REQUEST_HEADERS = [\"authorization\", \"cookie\"] as const;\n\ntype MiddlewareHeaderValue = string | string[];\ntype MiddlewareHeaderSource = Headers | Record<string, MiddlewareHeaderValue>;\ntype BuildRequestHeadersOptions = {\n preserveCredentialHeaders?: boolean;\n};\n\nfunction getMiddlewareHeaderValue(source: MiddlewareHeaderSource, key: string): string | null {\n if (source instanceof Headers) {\n return source.get(key);\n }\n\n const value = source[key];\n if (value === undefined) return null;\n return Array.isArray(value) ? (value[0] ?? null) : value;\n}\n\nfunction getOverrideHeaderNames(source: MiddlewareHeaderSource): string[] | null {\n const rawValue = getMiddlewareHeaderValue(source, MIDDLEWARE_OVERRIDE_HEADERS);\n if (rawValue === null) return null;\n return rawValue\n .split(\",\")\n .map((key) => key.trim())\n .filter(Boolean);\n}\n\nfunction getForwardedRequestHeaders(source: MiddlewareHeaderSource): Map<string, string> {\n const forwardedHeaders = new Map<string, string>();\n\n if (source instanceof Headers) {\n for (const [key, value] of source.entries()) {\n if (key.startsWith(MIDDLEWARE_REQUEST_HEADER_PREFIX)) {\n forwardedHeaders.set(key.slice(MIDDLEWARE_REQUEST_HEADER_PREFIX.length), value);\n }\n }\n return forwardedHeaders;\n }\n\n for (const [key, value] of Object.entries(source)) {\n if (!key.startsWith(MIDDLEWARE_REQUEST_HEADER_PREFIX)) continue;\n const normalizedValue = Array.isArray(value) ? (value[0] ?? \"\") : value;\n forwardedHeaders.set(key.slice(MIDDLEWARE_REQUEST_HEADER_PREFIX.length), normalizedValue);\n }\n\n return forwardedHeaders;\n}\n\nfunction cloneHeaders(source: Headers): Headers {\n const cloned = new Headers();\n for (const [key, value] of source.entries()) {\n cloned.append(key, value);\n }\n return cloned;\n}\n\nexport function encodeMiddlewareRequestHeaders(\n targetHeaders: Headers,\n requestHeaders: Headers,\n): void {\n const overrideHeaderNames = [...requestHeaders.keys()];\n targetHeaders.set(MIDDLEWARE_OVERRIDE_HEADERS, overrideHeaderNames.join(\",\"));\n\n for (const [key, value] of requestHeaders.entries()) {\n targetHeaders.set(`${MIDDLEWARE_REQUEST_HEADER_PREFIX}${key}`, value);\n }\n}\n\nexport function buildRequestHeadersFromMiddlewareResponse(\n baseHeaders: Headers,\n middlewareHeaders: MiddlewareHeaderSource,\n options: BuildRequestHeadersOptions = {},\n): Headers | null {\n const overrideHeaderNames = getOverrideHeaderNames(middlewareHeaders);\n const forwardedHeaders = getForwardedRequestHeaders(middlewareHeaders);\n\n if (overrideHeaderNames === null && forwardedHeaders.size === 0) {\n return null;\n }\n\n const nextHeaders = overrideHeaderNames === null ? cloneHeaders(baseHeaders) : new Headers();\n\n if (overrideHeaderNames === null) {\n for (const [key, value] of forwardedHeaders) {\n nextHeaders.set(key, value);\n }\n return nextHeaders;\n }\n\n if (options.preserveCredentialHeaders) {\n const overrideHeaderNameSet = new Set(overrideHeaderNames);\n for (const key of CREDENTIAL_REQUEST_HEADERS) {\n if (overrideHeaderNameSet.has(key)) continue;\n\n const value = baseHeaders.get(key);\n if (value !== null) {\n nextHeaders.set(key, value);\n }\n }\n }\n\n for (const key of overrideHeaderNames) {\n const value = forwardedHeaders.get(key);\n if (value !== undefined) {\n nextHeaders.set(key, value);\n }\n }\n\n return nextHeaders;\n}\n\nexport function shouldKeepMiddlewareHeader(key: string): boolean {\n return (\n key === MIDDLEWARE_OVERRIDE_HEADERS ||\n key === MIDDLEWARE_SET_COOKIE_HEADER ||\n key.startsWith(MIDDLEWARE_REQUEST_HEADER_PREFIX)\n );\n}\n"],"mappings":";;AAKA,MAAM,6BAA6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U,eAAe,SAAS,EACjD,cAAc,IAAI,GAAG,mCAAmC,OAAO,MAAM;;AAIzE,SAAgB,0CACd,aACA,mBACA,UAAsC,EAAE,EACxB;CAChB,MAAM,sBAAsB,uBAAuB,kBAAkB;CACrE,MAAM,mBAAmB,2BAA2B,kBAAkB;CAEtE,IAAI,wBAAwB,QAAQ,iBAAiB,SAAS,GAC5D,OAAO;CAGT,MAAM,cAAc,wBAAwB,OAAO,aAAa,YAAY,GAAG,IAAI,SAAS;CAE5F,IAAI,wBAAwB,MAAM;EAChC,KAAK,MAAM,CAAC,KAAK,UAAU,kBACzB,YAAY,IAAI,KAAK,MAAM;EAE7B,OAAO;;CAGT,IAAI,QAAQ,2BAA2B;EACrC,MAAM,wBAAwB,IAAI,IAAI,oBAAoB;EAC1D,KAAK,MAAM,OAAO,4BAA4B;GAC5C,IAAI,sBAAsB,IAAI,IAAI,EAAE;GAEpC,MAAM,QAAQ,YAAY,IAAI,IAAI;GAClC,IAAI,UAAU,MACZ,YAAY,IAAI,KAAK,MAAM;;;CAKjC,KAAK,MAAM,OAAO,qBAAqB;EACrC,MAAM,QAAQ,iBAAiB,IAAI,IAAI;EACvC,IAAI,UAAU,KAAA,GACZ,YAAY,IAAI,KAAK,MAAM;;CAI/B,OAAO;;AAGT,SAAgB,2BAA2B,KAAsB;CAC/D,OACE,QAAA,mCACA,QAAA,6BACA,IAAI,WAAA,wBAA4C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware-response-headers.js","names":[],"sources":["../../src/server/middleware-response-headers.ts"],"sourcesContent":["const ADDITIVE_RESPONSE_HEADER_NAMES = new Set([\"set-cookie\", \"vary\"]);\n\nexport function mergeVaryHeader(target: Headers, value: string): void {\n const existing = target.get(\"Vary\");\n const tokens = (existing ? `${existing}, ${value}` : value)\n .split(\",\")\n .map((token) => token.trim())\n .filter((token) => token.length > 0);\n\n // Per RFC 9110, `Vary: *` means the response varies on all request fields.\n // Combining `*` with field names changes semantics and may be treated\n // inconsistently by caches. Collapse to `*` if any token is `*`.\n if (tokens.some((token) => token === \"*\")) {\n target.set(\"Vary\", \"*\");\n return;\n }\n\n const seen = new Set<string>();\n const merged: string[] = [];\n for (const token of tokens) {\n const normalized = token.toLowerCase();\n if (seen.has(normalized)) continue;\n\n seen.add(normalized);\n merged.push(token);\n }\n\n target.set(\"Vary\", merged.join(\", \"));\n}\n\n/**\n * Merge middleware response headers into a target Headers object.\n *\n * Set-Cookie and Vary are accumulated (append) since multiple sources can\n * contribute values. All other headers use set() so middleware owns singular\n * response headers like Cache-Control.\n */\nexport function mergeMiddlewareResponseHeaders(\n target: Headers,\n middlewareHeaders: Headers | null,\n): void {\n if (!middlewareHeaders) {\n return;\n }\n\n for (const [key, value] of middlewareHeaders) {\n if (key.toLowerCase() === \"vary\") {\n mergeVaryHeader(target, value);\n continue;\n }\n\n if (ADDITIVE_RESPONSE_HEADER_NAMES.has(key.toLowerCase())) {\n target.append(key, value);\n continue;\n }\n\n target.set(key, value);\n }\n}\n"],"mappings":";AAAA,MAAM,iCAAiC,IAAI,IAAI,CAAC,cAAc,OAAO,CAAC;AAEtE,SAAgB,gBAAgB,QAAiB,OAAqB;CACpE,MAAM,WAAW,OAAO,IAAI,OAAO;CACnC,MAAM,UAAU,WAAW,GAAG,SAAS,IAAI,UAAU,OAClD,MAAM,IAAI,CACV,KAAK,UAAU,MAAM,MAAM,CAAC,CAC5B,QAAQ,UAAU,MAAM,SAAS,EAAE;CAKtC,IAAI,OAAO,MAAM,UAAU,UAAU,IAAI,EAAE;EACzC,OAAO,IAAI,QAAQ,IAAI;EACvB;;CAGF,MAAM,uBAAO,IAAI,KAAa;CAC9B,MAAM,SAAmB,EAAE;CAC3B,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,aAAa,MAAM,aAAa;EACtC,IAAI,KAAK,IAAI,WAAW,EAAE;EAE1B,KAAK,IAAI,WAAW;EACpB,OAAO,KAAK,MAAM;;CAGpB,OAAO,IAAI,QAAQ,OAAO,KAAK,KAAK,CAAC;;;;;;;;;AAUvC,SAAgB,+BACd,QACA,mBACM;CACN,IAAI,CAAC,mBACH;CAGF,KAAK,MAAM,CAAC,KAAK,UAAU,mBAAmB;EAC5C,IAAI,IAAI,aAAa,KAAK,QAAQ;GAChC,gBAAgB,QAAQ,MAAM;GAC9B;;EAGF,IAAI,+BAA+B,IAAI,IAAI,aAAa,CAAC,EAAE;GACzD,OAAO,OAAO,KAAK,MAAM;GACzB;;EAGF,OAAO,IAAI,KAAK,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware-runtime.js","names":[],"sources":["../../src/server/middleware-runtime.ts"],"sourcesContent":["import \"./server-globals.js\";\nimport type { NextI18nConfig } from \"../config/next-config.js\";\nimport { normalizePathnameForRouteMatchStrict } from \"../routing/utils.js\";\nimport {\n getRequestExecutionContext,\n runWithExecutionContext,\n type ExecutionContextLike,\n} from \"vinext/shims/request-context\";\nimport { NextFetchEvent, NextRequest } from \"vinext/shims/server\";\nimport { normalizePath } from \"./normalize-path.js\";\nimport {\n MIDDLEWARE_HEADER_PREFIX,\n MIDDLEWARE_NEXT_HEADER,\n MIDDLEWARE_REWRITE_HEADER,\n} from \"./headers.js\";\nimport { MatcherConfig, matchesMiddleware } from \"./middleware-matcher.js\";\nimport { shouldKeepMiddlewareHeader } from \"./middleware-request-headers.js\";\nimport { processMiddlewareHeaders } from \"./request-pipeline.js\";\nimport { badRequestResponse, internalServerErrorResponse } from \"./http-error-responses.js\";\n\nexport type MiddlewareModule = Record<string, unknown>;\n\nexport type MiddlewareResult = {\n continue: boolean;\n redirectUrl?: string;\n redirectStatus?: number;\n rewriteUrl?: string;\n rewriteStatus?: number;\n status?: number;\n responseHeaders?: Headers;\n response?: Response;\n waitUntilPromises?: Promise<unknown>[];\n};\n\ntype MiddlewareHandler = (\n request: NextRequest,\n event: NextFetchEvent,\n) => Response | undefined | void | Promise<Response | undefined | void>;\n\ntype MiddlewareConfigExport = {\n matcher?: MatcherConfig;\n};\n\ntype ExecuteMiddlewareOptions = {\n basePath?: string;\n filePath?: string;\n i18nConfig?: NextI18nConfig | null;\n includeErrorDetails?: boolean;\n /**\n * Whether the incoming request was a Next.js `_next/data` fetch (carried\n * `x-nextjs-data: 1`). The header itself is stripped by `filterInternalHeaders`\n * before the middleware request is constructed, so callers must capture this\n * flag from the raw incoming headers and forward it explicitly.\n */\n isDataRequest?: boolean;\n isProxy: boolean;\n module: MiddlewareModule;\n normalizedPathname?: string;\n request: Request;\n /**\n * The user's `trailingSlash` config. Plumbed into the NextRequest's NextURL\n * so `request.nextUrl.toString()` formats with the configured slash policy,\n * which feeds into `NextResponse.redirect(request.nextUrl)` Location headers.\n * Also used to normalize redirect Location pathnames returned via plain\n * `new URL('/x', req.url)`.\n */\n trailingSlash?: boolean;\n};\n\ntype RunGeneratedMiddlewareOptions = ExecuteMiddlewareOptions & {\n ctx?: ExecutionContextLike;\n};\n\nfunction isMiddlewareHandler(value: unknown): value is MiddlewareHandler {\n return typeof value === \"function\";\n}\n\nfunction isMiddlewareConfigExport(value: unknown): value is MiddlewareConfigExport {\n return !!value && typeof value === \"object\";\n}\n\nfunction middlewareFileLabel(isProxy: boolean): string {\n return isProxy ? \"Proxy\" : \"Middleware\";\n}\n\nfunction middlewareExpectedExport(isProxy: boolean): string {\n return isProxy ? \"proxy\" : \"middleware\";\n}\n\nexport function resolveMiddlewareModuleHandler(\n mod: MiddlewareModule,\n options: { filePath?: string; isProxy: boolean },\n): MiddlewareHandler {\n const handler = options.isProxy ? (mod.proxy ?? mod.default) : (mod.middleware ?? mod.default);\n if (isMiddlewareHandler(handler)) return handler;\n\n const fileLabel = middlewareFileLabel(options.isProxy);\n const expectedExport = middlewareExpectedExport(options.isProxy);\n const fileSuffix = options.filePath ? ` \"${options.filePath}\"` : \"\";\n throw new Error(\n `The ${fileLabel} file${fileSuffix} must export a function named \\`${expectedExport}\\` or a \\`default\\` function.`,\n );\n}\n\nfunction middlewareMatcher(mod: MiddlewareModule): MatcherConfig | undefined {\n const config = mod.config;\n if (!isMiddlewareConfigExport(config)) return undefined;\n return config.matcher;\n}\n\nfunction stripMiddlewareHeadersFromResponse(response: Response): Response {\n const headers = new Headers(response.headers);\n processMiddlewareHeaders(headers);\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n}\n\n/**\n * Make a same-host URL relative to the request origin. Cross-origin URLs are\n * returned unchanged. Mirrors Next.js's `getRelativeURL` behaviour:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/utils/relativize-url.ts\n */\nfunction relativizeLocation(location: string, requestUrl: string): string {\n let parsed: URL;\n try {\n parsed = new URL(location, requestUrl);\n } catch {\n return location;\n }\n const base = new URL(requestUrl);\n if (parsed.origin !== base.origin) return parsed.toString();\n return parsed.pathname + parsed.search + parsed.hash;\n}\n\n/**\n * Translate a middleware redirect Response into the soft-redirect protocol\n * used by Next.js for `_next/data` requests: a 200 OK with the redirect target\n * carried in the `x-nextjs-redirect` header. The client router consumes this\n * header to perform the navigation, avoiding CORS issues that would arise from\n * an actual cross-origin HTTP redirect on a data fetch.\n *\n * Reference: packages/next/src/server/web/adapter.ts\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/server/web/adapter.ts\n */\nfunction dataRedirectResponse(target: string, originalResponse: Response): Response {\n const headers = new Headers(originalResponse.headers);\n processMiddlewareHeaders(headers);\n // Headers.delete is case-insensitive per the Fetch spec, so a single call\n // covers `Location` / `location` / `LOCATION`.\n headers.delete(\"Location\");\n headers.set(\"x-nextjs-redirect\", target);\n return new Response(null, { status: 200, headers });\n}\n\nfunction collectMiddlewareHeaders(response: Response): Headers {\n const responseHeaders = new Headers();\n for (const [key, value] of response.headers) {\n if (!key.startsWith(MIDDLEWARE_HEADER_PREFIX) || shouldKeepMiddlewareHeader(key)) {\n responseHeaders.append(key, value);\n }\n }\n return responseHeaders;\n}\n\nfunction drainFetchEvent(fetchEvent: NextFetchEvent): Promise<unknown>[] {\n const waitUntilPromises = fetchEvent.waitUntilPromises;\n const drained = fetchEvent.drainWaitUntil();\n const executionContext = getRequestExecutionContext();\n if (executionContext) {\n executionContext.waitUntil(drained);\n } else {\n void drained;\n }\n return waitUntilPromises;\n}\n\nfunction resolveMiddlewarePathname(request: Request): string | Response {\n const url = new URL(request.url);\n try {\n return normalizePath(normalizePathnameForRouteMatchStrict(url.pathname));\n } catch {\n return badRequestResponse();\n }\n}\n\nfunction createNextRequest(\n request: Request,\n normalizedPathname: string,\n i18nConfig?: NextI18nConfig | null,\n basePath?: string,\n trailingSlash?: boolean,\n): NextRequest {\n const url = new URL(request.url);\n // Middleware gets an isolated body branch; downstream routing keeps owning\n // the original request body.\n let mwRequest = request.body && !request.bodyUsed ? request.clone() : request;\n if (normalizedPathname !== url.pathname) {\n const mwUrl = new URL(url);\n mwUrl.pathname = normalizedPathname;\n mwRequest = new Request(mwUrl, mwRequest);\n }\n\n const hasNextConfig = basePath || i18nConfig || trailingSlash;\n const nextConfig = hasNextConfig\n ? {\n basePath: basePath ?? \"\",\n i18n: i18nConfig ?? undefined,\n trailingSlash: trailingSlash ?? undefined,\n }\n : undefined;\n\n return mwRequest instanceof NextRequest\n ? mwRequest\n : new NextRequest(mwRequest, nextConfig ? { nextConfig } : undefined);\n}\n\nexport async function executeMiddleware(\n options: ExecuteMiddlewareOptions,\n): Promise<MiddlewareResult> {\n const middlewareFn = resolveMiddlewareModuleHandler(options.module, {\n filePath: options.filePath,\n isProxy: options.isProxy,\n });\n const normalizedPathname =\n options.normalizedPathname ?? resolveMiddlewarePathname(options.request);\n if (normalizedPathname instanceof Response) {\n return { continue: false, response: normalizedPathname };\n }\n\n if (\n !matchesMiddleware(\n normalizedPathname,\n middlewareMatcher(options.module),\n options.request,\n options.i18nConfig,\n )\n ) {\n return { continue: true };\n }\n\n const nextRequest = createNextRequest(\n options.request,\n normalizedPathname,\n options.i18nConfig,\n options.basePath,\n options.trailingSlash,\n );\n const fetchEvent = new NextFetchEvent({ page: normalizedPathname });\n\n let response: Response | undefined | void;\n try {\n response = await middlewareFn(nextRequest, fetchEvent);\n } catch (e) {\n console.error(\"[vinext] Middleware error:\", e);\n const waitUntilPromises = drainFetchEvent(fetchEvent);\n const message = options.includeErrorDetails\n ? \"Middleware Error: \" + (e instanceof Error ? e.message : String(e))\n : \"Internal Server Error\";\n return {\n continue: false,\n response: internalServerErrorResponse(message),\n waitUntilPromises,\n };\n }\n\n const waitUntilPromises = drainFetchEvent(fetchEvent);\n\n if (!response) {\n return { continue: true, waitUntilPromises };\n }\n\n if (response.headers.get(MIDDLEWARE_NEXT_HEADER) === \"1\") {\n return {\n continue: true,\n responseHeaders: collectMiddlewareHeaders(response),\n status: response.status !== 200 ? response.status : undefined,\n waitUntilPromises,\n };\n }\n\n if (response.status >= 300 && response.status < 400) {\n const location = response.headers.get(\"Location\") ?? response.headers.get(\"location\");\n if (location) {\n // Make same-host Location relative for parity with Next.js, which only\n // emits absolute URLs for cross-origin redirects:\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/web/adapter.ts\n const relativeLocation = relativizeLocation(location, options.request.url);\n\n // For `_next/data` requests, translate the HTTP redirect into the\n // `x-nextjs-redirect` soft-redirect protocol so the client router can\n // perform the navigation without tripping CORS on cross-origin targets.\n // `x-nextjs-data` lives in INTERNAL_HEADERS and is stripped before the\n // middleware request is constructed, so the flag is threaded in from the\n // caller (which sees the raw incoming headers).\n if (options.isDataRequest) {\n return {\n continue: false,\n response: dataRedirectResponse(relativeLocation, response),\n waitUntilPromises,\n };\n }\n\n const responseHeaders = new Headers();\n for (const [key, value] of response.headers) {\n if (!key.startsWith(MIDDLEWARE_HEADER_PREFIX) && key.toLowerCase() !== \"location\") {\n responseHeaders.append(key, value);\n }\n }\n // Rebuild the response with the relativized Location so consumers that\n // forward `result.response` (rather than `result.redirectUrl`) also send\n // the correct header.\n const relativizedResponseHeaders = new Headers(response.headers);\n relativizedResponseHeaders.set(\"Location\", relativeLocation);\n const relativizedResponse = new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: relativizedResponseHeaders,\n });\n return {\n continue: false,\n redirectUrl: relativeLocation,\n redirectStatus: response.status,\n response: stripMiddlewareHeadersFromResponse(relativizedResponse),\n responseHeaders,\n waitUntilPromises,\n };\n }\n }\n\n const rewriteUrl = response.headers.get(MIDDLEWARE_REWRITE_HEADER);\n if (rewriteUrl) {\n let rewritePath: string;\n try {\n const rewriteParsed = new URL(rewriteUrl, options.request.url);\n const requestOrigin = new URL(options.request.url).origin;\n if (rewriteParsed.origin === requestOrigin) {\n // Middleware constructs the rewrite-target URL itself (e.g. by\n // modifying `request.nextUrl` or by passing a fresh path). Whatever\n // search params that URL carries IS the final query — vinext must not\n // silently re-merge the original request's query, or middleware that\n // deletes keys (e.g. `searchParams.delete('foo')`) would see them\n // resurrected on the rewrite target. Mirrors Next.js' middleware\n // adapter: the `x-middleware-rewrite` URL is parsed directly with no\n // original-side merging.\n // See test/e2e/middleware-rewrites/test/index.test.ts\n // (\"should clear query parameters\")\n // https://github.com/vercel/next.js/blob/canary/test/e2e/middleware-rewrites/test/index.test.ts\n rewritePath = rewriteParsed.pathname + rewriteParsed.search;\n } else {\n // External rewrites are proxied as-is; don't smuggle local query params\n // into the upstream URL.\n rewritePath = rewriteParsed.href;\n }\n } catch {\n rewritePath = rewriteUrl;\n }\n return {\n continue: true,\n rewriteUrl: rewritePath,\n rewriteStatus: response.status !== 200 ? response.status : undefined,\n responseHeaders: collectMiddlewareHeaders(response),\n status: response.status !== 200 ? response.status : undefined,\n waitUntilPromises,\n };\n }\n\n return {\n continue: false,\n response: stripMiddlewareHeadersFromResponse(response),\n waitUntilPromises,\n };\n}\n\nexport async function runGeneratedMiddleware(\n options: RunGeneratedMiddlewareOptions,\n): Promise<MiddlewareResult> {\n const run = () => executeMiddleware(options);\n return options.ctx ? runWithExecutionContext(options.ctx, run) : run();\n}\n"],"mappings":";;;;;;;;;;;AAyEA,SAAS,oBAAoB,OAA4C;CACvE,OAAO,OAAO,UAAU;;AAG1B,SAAS,yBAAyB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MAAM,CAAC,KAAK,UAAU,SAAS,SAClC,IAAI,CAAC,IAAI,WAAA,gBAAoC,IAAI,IAAI,aAAa,KAAK,YACrE,gBAAgB,OAAO,KAAK,MAAM;GAMtC,MAAM,6BAA6B,IAAI,QAAQ,SAAS,QAAQ;GAChE,2BAA2B,IAAI,YAAY,iBAAiB;GAC5D,MAAM,sBAAsB,IAAI,SAAS,SAAS,MAAM;IACtD,QAAQ,SAAS;IACjB,YAAY,SAAS;IACrB,SAAS;IACV,CAAC;GACF,OAAO;IACL,UAAU;IACV,aAAa;IACb,gBAAgB,SAAS;IACzB,UAAU,mCAAmC,oBAAoB;IACjE;IACA;IACD;;;CAIL,MAAM,aAAa,SAAS,QAAQ,IAAI,0BAA0B;CAClE,IAAI,YAAY;EACd,IAAI;EACJ,IAAI;GACF,MAAM,gBAAgB,IAAI,IAAI,YAAY,QAAQ,QAAQ,IAAI;GAC9D,MAAM,gBAAgB,IAAI,IAAI,QAAQ,QAAQ,IAAI,CAAC;GACnD,IAAI,cAAc,WAAW,eAY3B,cAAc,cAAc,WAAW,cAAc;QAIrD,cAAc,cAAc;UAExB;GACN,cAAc;;EAEhB,OAAO;GACL,UAAU;GACV,YAAY;GACZ,eAAe,SAAS,WAAW,MAAM,SAAS,SAAS,KAAA;GAC3D,iBAAiB,yBAAyB,SAAS;GACnD,QAAQ,SAAS,WAAW,MAAM,SAAS,SAAS,KAAA;GACpD;GACD;;CAGH,OAAO;EACL,UAAU;EACV,UAAU,mCAAmC,SAAS;EACtD;EACD;;AAGH,eAAsB,uBACpB,SAC2B;CAC3B,MAAM,YAAY,kBAAkB,QAAQ;CAC5C,OAAO,QAAQ,MAAM,wBAAwB,QAAQ,KAAK,IAAI,GAAG,KAAK"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.js","names":[],"sources":["../../src/server/middleware.ts"],"sourcesContent":["/**\n * proxy.ts / middleware.ts runner\n *\n * Loads and executes the user's proxy.ts (Next.js 16) or middleware.ts file\n * before routing. Runs in Node (not Edge Runtime), per the vinext design.\n *\n * In Next.js 16, proxy.ts replaces middleware.ts:\n * - proxy.ts: default export OR named `proxy` function, runs on Node.js runtime\n * - middleware.ts: deprecated but still supported for Edge runtime use cases\n *\n * The proxy/middleware receives a NextRequest and can:\n * - Return NextResponse.next() to continue to the route\n * - Return NextResponse.redirect() to redirect\n * - Return NextResponse.rewrite() to rewrite the URL\n * - Set/modify headers and cookies\n * - Return a Response directly (e.g., for auth guards)\n *\n * Supports the `config.matcher` export for path filtering.\n */\n\nimport type { ModuleRunner } from \"vite/module-runner\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { NextI18nConfig } from \"../config/next-config.js\";\nimport { ValidFileMatcher } from \"../routing/file-matcher.js\";\nimport {\n resolveMiddlewareModuleHandler,\n runGeneratedMiddleware,\n type MiddlewareModule,\n type MiddlewareResult,\n} from \"./middleware-runtime.js\";\n\nexport { matchPattern, matchesMiddleware } from \"./middleware-matcher.js\";\n\n/**\n * Determine whether a middleware/proxy file path refers to a proxy file.\n * proxy.ts files accept `proxy` or `default` exports.\n * middleware.ts files accept `middleware` or `default` exports.\n *\n * Matches Next.js behavior where each file type only accepts its own\n * named export or a default export:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/build/templates/middleware.ts\n */\nexport function isProxyFile(filePath: string): boolean {\n const base = path.basename(filePath).replace(/\\.\\w+$/, \"\");\n return base === \"proxy\";\n}\n\n/**\n * Resolve the middleware/proxy handler function from a module's exports.\n * Matches Next.js behavior: for proxy files, check `proxy` then `default`;\n * for middleware files, check `middleware` then `default`.\n *\n * Throws if the file exists but doesn't export a valid function, matching\n * Next.js's ProxyMissingExportError behavior.\n *\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/build/templates/middleware.ts\n * @see https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/proxy-missing-export/proxy-missing-export.test.ts\n */\nexport function resolveMiddlewareHandler(mod: MiddlewareModule, filePath: string) {\n return resolveMiddlewareModuleHandler(mod, {\n filePath,\n isProxy: isProxyFile(filePath),\n });\n}\n\nconst MIDDLEWARE_LOCATIONS = [\"\", \"src/\"];\n\n/**\n * Find the proxy or middleware file in the project root.\n * Checks for proxy.ts (Next.js 16) first, then falls back to middleware.ts.\n * If middleware.ts is found, logs a deprecation warning.\n *\n * Note on log noise: this function is called from Vite's `config` hook, which\n * fires once per build environment (RSC, SSR, client, …). That means a project\n * still using `middleware.ts` will see this warning emitted 2–3 times per\n * build. The warning is benign — it does not abort the build. Next.js itself\n * emits the same message via `Log.warnOnce`; matching that parity would\n * require either a per-root deduplication map or hoisting the warning out of\n * this function (e.g. into the plugin's `configResolved` hook). Tracked as a\n * follow-up; see the deploy-suite investigation in run 25870737355.\n *\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/build/index.ts\n * (search for \"MIDDLEWARE_FILENAME\" + \"file convention is deprecated\")\n */\nexport function findMiddlewareFile(root: string, fileMatcher: ValidFileMatcher): string | null {\n // Check proxy.ts first (Next.js 16 replacement for middleware.ts)\n for (const dir of MIDDLEWARE_LOCATIONS) {\n for (const ext of fileMatcher.dottedExtensions) {\n const fullPath = path.join(root, dir, `proxy${ext}`);\n if (fs.existsSync(fullPath)) {\n return fullPath;\n }\n }\n }\n\n // Fall back to middleware.ts (deprecated in Next.js 16).\n // This is a warning, not an error: middleware.ts is still fully supported\n // by both Next.js 16 and vinext. Do not change to `throw` or `process.exit`.\n //\n // Warning text matches Next.js canonical wording from\n // packages/next/src/build/index.ts (search for \"file convention is\n // deprecated\") so Next.js's own deprecation-warnings and app-middleware\n // e2e suites pass when run against vinext.\n for (const dir of MIDDLEWARE_LOCATIONS) {\n for (const ext of fileMatcher.dottedExtensions) {\n const fullPath = path.join(root, dir, `middleware${ext}`);\n if (fs.existsSync(fullPath)) {\n console.warn(\n `The \"middleware\" file convention is deprecated. Please use \"proxy\" instead.\\n\\n` +\n ` To migrate automatically, run:\\n` +\n ` npx @next/codemod@canary middleware-to-proxy .\\n\\n` +\n ` Learn more: https://nextjs.org/docs/messages/middleware-to-proxy`,\n );\n return fullPath;\n }\n }\n }\n return null;\n}\n\nfunction isMiddlewareModule(value: unknown): value is MiddlewareModule {\n return !!value && typeof value === \"object\";\n}\n\n/**\n * Load and execute middleware for a given request.\n *\n * @param runner - A ModuleRunner used to load the middleware module.\n * Must be a long-lived instance created once (e.g. in configureServer) via\n * createDirectRunner() — NOT recreated per request. Using server.ssrLoadModule\n * directly crashes with `outsideEmitter` when @cloudflare/vite-plugin is\n * present because SSRCompatModuleRunner reads environment.hot.api synchronously.\n * @param middlewarePath - Absolute path to the middleware file\n * @param request - The incoming Request object\n * @returns Middleware result describing what action to take\n */\nexport async function runMiddleware(\n runner: ModuleRunner,\n middlewarePath: string,\n request: Request,\n i18nConfig?: NextI18nConfig | null,\n basePath?: string,\n trailingSlash?: boolean,\n isDataRequest?: boolean,\n): Promise<MiddlewareResult> {\n // Load the middleware module via the direct-call ModuleRunner.\n // This bypasses the hot channel entirely and is safe with all Vite plugin\n // combinations, including @cloudflare/vite-plugin.\n const mod = await runner.import(middlewarePath);\n if (!isMiddlewareModule(mod)) {\n throw new Error(`Middleware module \"${middlewarePath}\" did not evaluate to an object.`);\n }\n\n return runGeneratedMiddleware({\n basePath,\n filePath: middlewarePath,\n i18nConfig,\n includeErrorDetails: process.env.NODE_ENV !== \"production\",\n isDataRequest,\n isProxy: isProxyFile(middlewarePath),\n module: mod,\n request,\n trailingSlash,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AA2CA,SAAgB,YAAY,UAA2B;CAErD,OADa,KAAK,SAAS,SAAS,CAAC,QAAQ,UAAU,GAC5C,KAAK;;;;;;;;;;;;;AAclB,SAAgB,yBAAyB,KAAuB,UAAkB;CAChF,OAAO,+BAA+B,KAAK;EACzC;EACA,SAAS,YAAY,SAAS;EAC/B,CAAC;;AAGJ,MAAM,uBAAuB,CAAC,IAAI,OAAO;;;;;;;;;;;;;;;;;;AAmBzC,SAAgB,mBAAmB,MAAc,aAA8C;CAE7F,KAAK,MAAM,OAAO,sBAChB,KAAK,MAAM,OAAO,YAAY,kBAAkB;EAC9C,MAAM,WAAW,KAAK,KAAK,MAAM,KAAK,QAAQ,MAAM;EACpD,IAAI,GAAG,WAAW,SAAS,EACzB,OAAO;;CAab,KAAK,MAAM,OAAO,sBAChB,KAAK,MAAM,OAAO,YAAY,kBAAkB;EAC9C,MAAM,WAAW,KAAK,KAAK,MAAM,KAAK,aAAa,MAAM;EACzD,IAAI,GAAG,WAAW,SAAS,EAAE;GAC3B,QAAQ,KACN,8OAID;GACD,OAAO;;;CAIb,OAAO;;AAGT,SAAS,mBAAmB,OAA2C;CACrE,OAAO,CAAC,CAAC,SAAS,OAAO,UAAU;;;;;;;;;;;;;;AAerC,eAAsB,cACpB,QACA,gBACA,SACA,YACA,UACA,eACA,eAC2B;CAI3B,MAAM,MAAM,MAAM,OAAO,OAAO,eAAe;CAC/C,IAAI,CAAC,mBAAmB,IAAI,EAC1B,MAAM,IAAI,MAAM,sBAAsB,eAAe,kCAAkC;CAGzF,OAAO,uBAAuB;EAC5B;EACA,UAAU;EACV;EACA,qBAAqB,QAAQ,IAAI,aAAa;EAC9C;EACA,SAAS,YAAY,eAAe;EACpC,QAAQ;EACR;EACA;EACD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-planner.js","names":["_exhaustive"],"sources":["../../src/server/navigation-planner.ts"],"sourcesContent":["import { matchRoutePattern, matchRoutePatternPrefix } from \"../routing/route-pattern.js\";\nimport { splitPathnameForRouteMatch } from \"../routing/utils.js\";\nimport type {\n RouteManifest,\n RouteManifestInterception,\n RouteManifestRoute,\n} from \"../routing/app-route-graph.js\";\nimport { compareAppElementsSlotIds, type AppElementsSlotBinding } from \"./app-elements.js\";\nimport type {\n CacheEntryReuseDecision,\n CacheEntryReuseProof,\n CacheProofRejectionCode,\n} from \"./cache-proof.js\";\nimport {\n NavigationTraceReasonCodes,\n createNavigationLifecycleTraceFields,\n createNavigationTrace,\n type NavigationTrace,\n type NavigationTraceFields,\n type NavigationTraceReasonCode,\n} from \"./navigation-trace.js\";\n\nexport type OperationLane =\n | \"hmr\"\n | \"navigation\"\n | \"prefetch\"\n | \"refresh\"\n | \"server-action\"\n | \"traverse\";\n\nexport type OperationToken = {\n operationId: number;\n lane: OperationLane;\n baseVisibleCommitVersion: number;\n graphVersion: string | null;\n deploymentVersion: string | null;\n targetSnapshotFingerprint: string;\n cacheVariantFingerprint?: string;\n};\n\nexport type RouteSnapshotV0 = {\n interception: InterceptionSnapshotV0 | null;\n interceptionContext: string | null;\n routeId: string;\n // Ordered ancestor-first, with the root layout at index 0. Same-layout\n // persistence uses prefix comparison, so callers must preserve this order.\n layoutIds: readonly string[];\n mountedParallelSlots: readonly MountedParallelSlotSnapshotV0[];\n rootBoundaryId: string | null;\n displayUrl: string;\n matchedUrl: string;\n slotBindings: readonly ParallelSlotBindingSnapshotV0[];\n};\n\nexport type InterceptionSnapshotV0 = {\n sourceMatchedUrl: string;\n sourceRouteId: string;\n slotId: string;\n targetMatchedUrl: string;\n targetRouteId: string;\n};\n\nexport type MountedParallelSlotSnapshotV0 = {\n slotId: string;\n ownerLayoutId: string | null;\n};\n\n// Planner snapshots consume the same canonical slot-binding facts decoded from\n// AppElements metadata. Keep the alias explicit so route-state and transport\n// readers cannot drift into structurally identical but semantically separate\n// shapes.\nexport type ParallelSlotBindingSnapshotV0 = AppElementsSlotBinding;\n\nexport type NavigationPlannerStateV0 = {\n // V0 keeps a single state shape so intent events and result events can move\n // through one planner surface. flightResponseArrived uses event.token; later\n // #726 slices can split this by event kind once more result paths are routed\n // through the planner.\n nextOperationToken: OperationToken;\n // Callers that have lifecycle authority should pass the complete trace\n // context. When absent, the planner emits the stable root-boundary facts it\n // can derive from the event and visible snapshot.\n traceFields?: NavigationTraceFields;\n visibleCommitVersion: number;\n visibleSnapshot: RouteSnapshotV0;\n};\n\nexport type RefreshScope = \"visible\";\nexport type TraverseDirection = \"back\" | \"forward\" | \"unknown\";\n\nexport type NavigationEvent =\n | { kind: \"navigate\"; href: string; mode: \"push\" | \"replace\" }\n | { kind: \"refresh\"; scope: RefreshScope }\n | { kind: \"traverse\"; direction: TraverseDirection; historyState: unknown }\n | { kind: \"prefetch\"; href: string }\n | { kind: \"flightResponseArrived\"; token: OperationToken; result: FlightResultV0 };\n\nexport type RequestedWork =\n | { kind: \"flight\"; href: string; mode: \"push\" | \"replace\" | \"refresh\" }\n | { direction: TraverseDirection; historyState: unknown; kind: \"traverseFlight\" }\n | { kind: \"prefetch\"; href: string };\n\nexport type CommitProposal = {\n cacheEntryReuseDecision?: AcceptedCacheEntryReuseDecision;\n preserveAbsentSlots: boolean;\n preserveElementIds: readonly string[];\n preservePreviousSlotIds: readonly string[];\n reason: \"currentRootBoundary\" | \"interceptedCurrentRootBoundary\" | \"unprovenTopologyFallback\";\n targetSnapshot: RouteSnapshotV0;\n};\n\nexport type NoCommitReason = \"prefetchOnly\";\nexport type HardNavigationReason =\n | \"cacheProofRejected\"\n | \"interceptionProofRejected\"\n | \"rootBoundaryChanged\";\nexport type RootBoundaryTransition =\n | \"currentRootBoundary\"\n | \"rootBoundaryChanged\"\n | \"rootBoundaryUnknown\";\n\nexport type NavigationDecisionV0 =\n | {\n kind: \"requestWork\";\n token: OperationToken;\n work: RequestedWork;\n trace: NavigationTrace;\n }\n | {\n kind: \"proposeCommit\";\n token: OperationToken;\n proposal: CommitProposal;\n trace: NavigationTrace;\n }\n | {\n kind: \"noCommit\";\n token: OperationToken;\n reason: NoCommitReason;\n trace: NavigationTrace;\n }\n | {\n kind: \"hardNavigate\";\n token: OperationToken;\n url: string;\n reason: HardNavigationReason;\n trace: NavigationTrace;\n };\n\nexport type FlightResultV0 = {\n cacheEntryReuseProof?: CacheEntryReuseProof;\n href: string;\n targetSnapshot: RouteSnapshotV0;\n};\n\nexport type NavigationPlannerInput = {\n // Graph-owned route topology is the semantic authority for root/layout/slot\n // decisions whenever the caller can supply it. Null keeps the legacy\n // snapshot-only path for low-level tests and unknown route shapes.\n routeManifest: RouteManifest | null;\n state: NavigationPlannerStateV0;\n event: NavigationEvent;\n};\n\ntype RouteTopologySnapshot = {\n layoutIds: readonly string[];\n rootBoundaryId: string | null;\n rootLayoutTreePath: string | null;\n slotBindings: readonly ParallelSlotBindingSnapshotV0[];\n};\n\ntype RouteTopologyResolution =\n | {\n kind: \"known\";\n topology: RouteTopologySnapshot;\n }\n | {\n kind: \"unknown\";\n };\n\ntype RouteTopologySlotBindingSource = \"snapshot\" | \"manifestTarget\";\ntype AcceptedCacheEntryReuseDecision = Extract<CacheEntryReuseDecision, { canReuse: true }>;\ntype RejectedCacheEntryReuseDecision = Extract<CacheEntryReuseDecision, { canReuse: false }>;\ntype CacheEntryProofEvaluation =\n | Readonly<{\n decision: AcceptedCacheEntryReuseDecision | null;\n kind: \"accepted\";\n }>\n | Readonly<{\n decision: RejectedCacheEntryReuseDecision | null;\n kind: \"rejected\";\n }>;\n\nconst ROUTE_INTERCEPTION_CONTEXT_SEPARATOR = \"\\0\";\nconst CACHE_ENTRY_PROOF_MISSING_CODE =\n \"CP_CACHE_ENTRY_PROOF_MISSING\" satisfies CacheProofRejectionCode;\n\nfunction createRequestWorkDecision(options: {\n eventKind: NavigationEvent[\"kind\"];\n state: NavigationPlannerStateV0;\n work: RequestedWork;\n}): NavigationDecisionV0 {\n const traverseFields =\n options.work.kind === \"traverseFlight\" ? { traverseDirection: options.work.direction } : {};\n return {\n kind: \"requestWork\",\n token: options.state.nextOperationToken,\n work: options.work,\n trace: createNavigationTrace(NavigationTraceReasonCodes.requestWork, {\n eventKind: options.eventKind,\n targetHref: getRequestedWorkTargetHref(options.work),\n ...traverseFields,\n }),\n };\n}\n\nfunction getRequestedWorkTargetHref(work: RequestedWork): string | null {\n switch (work.kind) {\n case \"flight\":\n case \"prefetch\":\n return work.href;\n case \"traverseFlight\":\n return null;\n default: {\n const _exhaustive: never = work;\n throw new Error(\"[vinext] Unknown requested navigation work: \" + String(_exhaustive));\n }\n }\n}\n\nfunction createSnapshotRouteTopology(snapshot: RouteSnapshotV0): RouteTopologySnapshot {\n return {\n layoutIds: snapshot.layoutIds,\n rootBoundaryId: snapshot.rootBoundaryId,\n rootLayoutTreePath: snapshot.rootBoundaryId,\n slotBindings: snapshot.slotBindings,\n };\n}\n\nfunction stripInterceptionContextFromRouteId(routeId: string): string {\n const separatorIndex = routeId.indexOf(ROUTE_INTERCEPTION_CONTEXT_SEPARATOR);\n return separatorIndex === -1 ? routeId : routeId.slice(0, separatorIndex);\n}\n\nfunction getMatchedUrlPathname(matchedUrl: string): string {\n try {\n return new URL(matchedUrl, \"https://vinext.local\").pathname;\n } catch {\n const [withoutHash = \"\"] = matchedUrl.split(\"#\");\n const [pathname = \"\"] = withoutHash.split(\"?\");\n return pathname === \"\" ? \"/\" : pathname;\n }\n}\n\nfunction splitMatchedUrlIntoRouteParts(matchedUrl: string): string[] {\n return splitPathnameForRouteMatch(getMatchedUrlPathname(matchedUrl));\n}\n\nfunction findRouteManifestRouteByMatchedUrl(\n routeManifest: RouteManifest,\n matchedUrl: string,\n): RouteManifestRoute | null {\n const urlParts = splitMatchedUrlIntoRouteParts(matchedUrl);\n\n // RouteManifest preserves buildAppRouteGraph's compareRoutes() order, so the\n // first pattern match follows the same static/dynamic/catch-all precedence as\n // request-time route matching instead of raw filesystem scan order.\n for (const route of routeManifest.segmentGraph.routes.values()) {\n if (matchRoutePattern(urlParts, route.patternParts) !== null) {\n return route;\n }\n }\n\n return null;\n}\n\nfunction routeManifestRouteMatchesUrl(route: RouteManifestRoute, matchedUrl: string): boolean {\n return matchRoutePattern(splitMatchedUrlIntoRouteParts(matchedUrl), route.patternParts) !== null;\n}\n\nfunction findRouteManifestRouteByIdOrMatchedUrl(options: {\n matchedUrl: string;\n routeId: string;\n routeManifest: RouteManifest;\n}): RouteManifestRoute | null {\n const routeId = stripInterceptionContextFromRouteId(options.routeId);\n const route = options.routeManifest.segmentGraph.routes.get(routeId);\n if (route && routeManifestRouteMatchesUrl(route, options.matchedUrl)) {\n return route;\n }\n\n return findRouteManifestRouteByMatchedUrl(options.routeManifest, options.matchedUrl);\n}\n\nfunction findRouteManifestRouteForSnapshot(\n routeManifest: RouteManifest,\n snapshot: RouteSnapshotV0,\n): RouteManifestRoute | null {\n if (snapshot.interception !== null) {\n return findRouteManifestRouteByIdOrMatchedUrl({\n matchedUrl: snapshot.interception.sourceMatchedUrl,\n routeId: snapshot.interception.sourceRouteId,\n routeManifest,\n });\n }\n\n return findRouteManifestRouteByIdOrMatchedUrl({\n matchedUrl: snapshot.matchedUrl,\n routeId: snapshot.routeId,\n routeManifest,\n });\n}\n\nfunction resolveRouteManifestSlotBindings(\n routeManifest: RouteManifest,\n route: RouteManifestRoute,\n): readonly ParallelSlotBindingSnapshotV0[] {\n const bindings: ParallelSlotBindingSnapshotV0[] = [];\n for (const slotId of route.slotIds) {\n const binding = routeManifest.segmentGraph.slotBindings.get(`${route.id}::${slotId}`);\n if (!binding) continue;\n bindings.push({\n ownerLayoutId: binding.ownerLayoutId,\n slotId: binding.slotId,\n state: binding.state,\n });\n }\n\n return bindings.sort((left, right) => compareAppElementsSlotIds(left.slotId, right.slotId));\n}\n\nfunction resolveRouteManifestRootLayoutTreePath(\n routeManifest: RouteManifest,\n route: RouteManifestRoute,\n): string | null {\n if (route.rootBoundaryId === null) return null;\n return routeManifest.segmentGraph.rootBoundaries.get(route.rootBoundaryId)?.treePath ?? null;\n}\n\nfunction resolveRouteTopologySnapshot(options: {\n routeManifest: RouteManifest | null;\n slotBindingSource: RouteTopologySlotBindingSource;\n snapshot: RouteSnapshotV0;\n}): RouteTopologyResolution {\n const route =\n options.routeManifest === null\n ? null\n : findRouteManifestRouteForSnapshot(options.routeManifest, options.snapshot);\n if (route === null || options.routeManifest === null) {\n return { kind: \"unknown\" };\n }\n\n // Intercepted targets carry the source route's tree topology, not the direct\n // target route's, so direct-target manifest slot bindings do not apply.\n const shouldUseManifestSlotBindings =\n options.slotBindingSource === \"manifestTarget\" && options.snapshot.interception === null;\n\n return {\n kind: \"known\",\n topology: {\n layoutIds: route.layoutIds,\n rootBoundaryId: route.rootBoundaryId,\n rootLayoutTreePath: resolveRouteManifestRootLayoutTreePath(options.routeManifest, route),\n slotBindings: shouldUseManifestSlotBindings\n ? resolveRouteManifestSlotBindings(options.routeManifest, route)\n : options.snapshot.slotBindings,\n },\n };\n}\n\nfunction findRouteManifestInterceptionForProof(\n routeManifest: RouteManifest,\n proof: InterceptionSnapshotV0,\n): RouteManifestInterception | null {\n const sourceParts = splitMatchedUrlIntoRouteParts(proof.sourceMatchedUrl);\n const targetParts = splitMatchedUrlIntoRouteParts(proof.targetMatchedUrl);\n const targetRoute = findRouteManifestRouteByIdOrMatchedUrl({\n matchedUrl: proof.targetMatchedUrl,\n routeId: proof.targetRouteId,\n routeManifest,\n });\n const candidateInterceptions =\n routeManifest.segmentGraph.interceptionsBySlotId.get(proof.slotId) ?? [];\n\n for (const interception of candidateInterceptions) {\n if (!matchRoutePatternPrefix(sourceParts, interception.sourcePatternParts)) {\n continue;\n }\n if (matchRoutePattern(targetParts, interception.targetPatternParts) === null) continue;\n if (interception.targetRouteId !== null && targetRoute?.id !== interception.targetRouteId) {\n continue;\n }\n return interception;\n }\n\n return null;\n}\n\nfunction createRootBoundaryTraceFields(options: {\n currentRootLayoutTreePath: string | null;\n event: Extract<NavigationEvent, { kind: \"flightResponseArrived\" }>;\n nextRootLayoutTreePath: string | null;\n state: NavigationPlannerStateV0;\n}): NavigationTraceFields {\n // Browser commit approval supplies lifecycle trace context before calling\n // the planner. This fallback exists for pure planner callers and tests; it\n // intentionally cannot invent lifecycle-only fields such as active nav id.\n if (options.state.traceFields) {\n return {\n ...options.state.traceFields,\n currentRootLayoutTreePath: options.currentRootLayoutTreePath,\n nextRootLayoutTreePath: options.nextRootLayoutTreePath,\n };\n }\n\n return createNavigationLifecycleTraceFields({\n currentRootLayoutTreePath: options.currentRootLayoutTreePath,\n currentVisibleCommitVersion: options.state.visibleCommitVersion,\n nextRootLayoutTreePath: options.nextRootLayoutTreePath,\n startedVisibleCommitVersion: options.event.token.baseVisibleCommitVersion,\n });\n}\n\nfunction classifyRootBoundaryTransition(\n currentRootBoundaryId: string | null,\n nextRootBoundaryId: string | null,\n): RootBoundaryTransition {\n if (currentRootBoundaryId === null || nextRootBoundaryId === null) {\n return \"rootBoundaryUnknown\";\n }\n\n return currentRootBoundaryId === nextRootBoundaryId\n ? \"currentRootBoundary\"\n : \"rootBoundaryChanged\";\n}\n\nfunction resolveSameLayoutAncestorPersistence(\n currentSnapshot: RouteSnapshotV0,\n targetSnapshot: RouteSnapshotV0,\n): readonly string[] {\n return resolveSameLayoutAncestorPersistenceForTopologies(\n createSnapshotRouteTopology(currentSnapshot),\n createSnapshotRouteTopology(targetSnapshot),\n );\n}\n\nfunction resolveSameLayoutAncestorPersistenceForTopologies(\n currentTopology: RouteTopologySnapshot,\n targetTopology: RouteTopologySnapshot,\n): readonly string[] {\n if (\n classifyRootBoundaryTransition(\n currentTopology.rootBoundaryId,\n targetTopology.rootBoundaryId,\n ) !== \"currentRootBoundary\"\n ) {\n return [];\n }\n\n const commonLayoutIds: string[] = [];\n const maxLength = Math.min(currentTopology.layoutIds.length, targetTopology.layoutIds.length);\n for (let index = 0; index < maxLength; index++) {\n const layoutId = currentTopology.layoutIds[index];\n if (layoutId !== targetTopology.layoutIds[index]) break;\n commonLayoutIds.push(layoutId);\n }\n return commonLayoutIds;\n}\n\nfunction resolveMountedParallelSlotPersistence(\n currentSnapshot: RouteSnapshotV0,\n targetSnapshot: RouteSnapshotV0,\n): readonly string[] {\n const preservedLayoutIds = resolveSameLayoutAncestorPersistence(currentSnapshot, targetSnapshot);\n return resolveMountedParallelSlotPersistenceForLayouts(currentSnapshot, preservedLayoutIds);\n}\n\nfunction resolveMountedParallelSlotPersistenceForLayouts(\n currentSnapshot: RouteSnapshotV0,\n preservedLayoutIds: readonly string[],\n): readonly string[] {\n if (preservedLayoutIds.length === 0) return [];\n const preservedLayoutIdSet = new Set(preservedLayoutIds);\n\n const preservedSlotIds: string[] = [];\n const seenSlotIds = new Set<string>();\n for (const slot of currentSnapshot.mountedParallelSlots) {\n if (slot.ownerLayoutId === null) continue;\n if (!preservedLayoutIdSet.has(slot.ownerLayoutId)) continue;\n if (seenSlotIds.has(slot.slotId)) continue;\n\n preservedSlotIds.push(slot.slotId);\n seenSlotIds.add(slot.slotId);\n }\n return preservedSlotIds;\n}\n\nfunction resolveCurrentRootBoundaryElementPersistence(\n currentSnapshot: RouteSnapshotV0,\n targetSnapshot: RouteSnapshotV0,\n): readonly string[] {\n const preservedLayoutIds = resolveSameLayoutAncestorPersistence(currentSnapshot, targetSnapshot);\n // Non-commit consumers still receive the legacy mounted-slot element list.\n // Commit promotion uses preservePreviousSlotIds instead so default/unmatched\n // slot reuse requires route-state proof.\n return [\n ...preservedLayoutIds,\n ...resolveMountedParallelSlotPersistenceForLayouts(currentSnapshot, preservedLayoutIds),\n ];\n}\n\nfunction resolveCurrentRootBoundaryCommitElementPersistence(options: {\n currentTopology: RouteTopologySnapshot;\n lane: OperationLane;\n targetTopology: RouteTopologySnapshot;\n}): readonly string[] {\n // Commit element persistence only keeps layout IDs. Default/unmatched slot\n // reuse is handled separately by preservePreviousSlotIds, using slot-binding\n // metadata as proof; payloads without __slotBindings get no semantic reuse.\n // resolveCurrentRootBoundaryCommitSlotPersistence recomputes this same\n // ancestor set; planner correctness relies on both calls agreeing so any\n // preserved slot's owner layout is also present in preserveElementIds.\n return resolveSameLayoutAncestorPersistenceForTopologies(\n options.currentTopology,\n options.targetTopology,\n );\n}\n\nfunction resolveCurrentRootBoundaryCommitSlotPersistence(options: {\n currentTopology: RouteTopologySnapshot;\n lane: OperationLane;\n targetTopology: RouteTopologySnapshot;\n}): readonly string[] {\n if (options.lane === \"traverse\") return [];\n\n const preservedLayoutIds = resolveSameLayoutAncestorPersistenceForTopologies(\n options.currentTopology,\n options.targetTopology,\n );\n if (preservedLayoutIds.length === 0) return [];\n\n return resolveDefaultOrUnmatchedSlotPersistenceForLayouts({\n currentSlotBindings: options.currentTopology.slotBindings,\n preservedLayoutIds,\n targetSlotBindings: options.targetTopology.slotBindings,\n });\n}\n\n/**\n * Default/unmatched slot preservation law:\n *\n * A target default/unmatched slot may reuse previous content only when:\n * - the slot's owner layout is part of the preserved layout ancestor set;\n * - the current visible snapshot proves the same slot had renderable content;\n * - the navigation is not a traversal.\n *\n * Wire absence and UNMATCHED_SLOT markers are not semantic proof.\n */\nfunction resolveDefaultOrUnmatchedSlotPersistenceForLayouts(options: {\n currentSlotBindings: readonly ParallelSlotBindingSnapshotV0[];\n preservedLayoutIds: readonly string[];\n targetSlotBindings: readonly ParallelSlotBindingSnapshotV0[];\n}): readonly string[] {\n const preservedLayoutIdSet = new Set(options.preservedLayoutIds);\n const slotIdsWithContent = new Set<string>();\n for (const binding of options.currentSlotBindings) {\n if (binding.state === \"unmatched\") continue;\n slotIdsWithContent.add(binding.slotId);\n }\n\n const preservedSlotIds: string[] = [];\n const seenSlotIds = new Set<string>();\n for (const binding of options.targetSlotBindings) {\n if (binding.ownerLayoutId === null) continue;\n if (!preservedLayoutIdSet.has(binding.ownerLayoutId)) continue;\n if (binding.state === \"active\") continue;\n if (!slotIdsWithContent.has(binding.slotId)) continue;\n if (seenSlotIds.has(binding.slotId)) continue;\n\n preservedSlotIds.push(binding.slotId);\n seenSlotIds.add(binding.slotId);\n }\n return preservedSlotIds.sort(compareAppElementsSlotIds);\n}\n\ntype VisibleInterceptionSourceIdentity = {\n matchedUrl: string;\n routeId: string;\n};\n\ntype InterceptedPreservationValidation =\n | {\n kind: \"approved\";\n preserveElementIds: readonly string[];\n preservePreviousSlotIds: readonly string[];\n }\n | {\n kind: \"rejected\";\n reasonCode: NavigationTraceReasonCode;\n };\n\nfunction getVisibleInterceptionSourceIdentity(\n snapshot: RouteSnapshotV0,\n): VisibleInterceptionSourceIdentity {\n if (snapshot.interception) {\n return {\n matchedUrl: snapshot.interception.sourceMatchedUrl,\n routeId: snapshot.interception.sourceRouteId,\n };\n }\n return {\n matchedUrl: snapshot.matchedUrl,\n routeId: snapshot.routeId,\n };\n}\n\nfunction createInterceptionProofRejectedDecision(options: {\n event: Extract<NavigationEvent, { kind: \"flightResponseArrived\" }>;\n reasonCode: NavigationTraceReasonCode;\n traceFields: NavigationTraceFields;\n}): NavigationDecisionV0 {\n return {\n kind: \"hardNavigate\",\n reason: \"interceptionProofRejected\",\n token: options.event.token,\n trace: createNavigationTrace(options.reasonCode, options.traceFields),\n url: options.event.result.href,\n };\n}\n\nfunction evaluateCacheEntryReuseProof(\n proof: CacheEntryReuseProof | undefined,\n): CacheEntryProofEvaluation {\n if (proof === undefined) {\n return {\n kind: \"accepted\",\n decision: null,\n };\n }\n\n if (proof.decision === null) {\n return {\n kind: \"rejected\",\n decision: null,\n };\n }\n\n if (proof.decision.canReuse) {\n return {\n kind: \"accepted\",\n decision: proof.decision,\n };\n }\n\n return {\n kind: \"rejected\",\n decision: proof.decision,\n };\n}\n\nfunction createCacheProofRejectedTraceFields(\n traceFields: NavigationTraceFields,\n decision: RejectedCacheEntryReuseDecision | null,\n): NavigationTraceFields {\n if (decision === null) {\n return {\n ...traceFields,\n cacheProofCode: CACHE_ENTRY_PROOF_MISSING_CODE,\n };\n }\n\n return {\n ...traceFields,\n cacheProofCode: decision.code,\n cacheProofMode: decision.mode,\n cacheProofScope: decision.scope,\n };\n}\n\nfunction createCacheProofRejectedDecision(options: {\n event: Extract<NavigationEvent, { kind: \"flightResponseArrived\" }>;\n rejection: Extract<CacheEntryProofEvaluation, { kind: \"rejected\" }>;\n traceFields: NavigationTraceFields;\n}): NavigationDecisionV0 {\n return {\n kind: \"hardNavigate\",\n reason: \"cacheProofRejected\",\n token: options.event.token,\n trace: createNavigationTrace(\n NavigationTraceReasonCodes.cacheProofRejected,\n createCacheProofRejectedTraceFields(options.traceFields, options.rejection.decision),\n ),\n url: options.event.result.href,\n };\n}\n\nfunction createAcceptedCacheProofTraceFields(\n traceFields: NavigationTraceFields,\n decision: AcceptedCacheEntryReuseDecision | null,\n): NavigationTraceFields {\n if (decision === null) return traceFields;\n return {\n ...traceFields,\n cacheProofCode: decision.code,\n cacheProofReuseClass: decision.reuseClass,\n };\n}\n\nfunction createCacheEntryProposalFields(\n decision: AcceptedCacheEntryReuseDecision | null,\n): Pick<CommitProposal, \"cacheEntryReuseDecision\"> {\n if (decision === null) return {};\n return {\n cacheEntryReuseDecision: decision,\n };\n}\n\nfunction validateInterceptedPreservation(options: {\n currentSnapshot: RouteSnapshotV0;\n currentTopology: RouteTopologySnapshot;\n routeManifest: RouteManifest | null;\n targetSnapshot: RouteSnapshotV0;\n targetTopology: RouteTopologySnapshot;\n}): InterceptedPreservationValidation {\n const proof = options.targetSnapshot.interception;\n if (!proof) {\n return {\n kind: \"rejected\",\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedMissingProof,\n };\n }\n\n if (proof.targetMatchedUrl !== options.targetSnapshot.matchedUrl) {\n return {\n kind: \"rejected\",\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedTargetMismatch,\n };\n }\n\n const sourceIdentity = getVisibleInterceptionSourceIdentity(options.currentSnapshot);\n if (\n proof.sourceMatchedUrl !== sourceIdentity.matchedUrl ||\n proof.sourceRouteId !== sourceIdentity.routeId\n ) {\n return {\n kind: \"rejected\",\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedUnknownSource,\n };\n }\n\n const declaredInterception =\n options.routeManifest === null\n ? null\n : findRouteManifestInterceptionForProof(options.routeManifest, proof);\n if (options.routeManifest !== null && declaredInterception === null) {\n return {\n kind: \"rejected\",\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedUndeclaredTopology,\n };\n }\n\n const preservedLayoutIds = resolveSameLayoutAncestorPersistenceForTopologies(\n options.currentTopology,\n options.targetTopology,\n );\n if (preservedLayoutIds.length === 0) {\n return {\n kind: \"rejected\",\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedIncompatibleRoot,\n };\n }\n\n const preservedLayoutIdSet = new Set(preservedLayoutIds);\n const targetSlotBinding = options.targetTopology.slotBindings.find(\n (binding) => binding.slotId === proof.slotId,\n );\n if (\n !targetSlotBinding ||\n targetSlotBinding.state !== \"active\" ||\n targetSlotBinding.ownerLayoutId === null ||\n !preservedLayoutIdSet.has(targetSlotBinding.ownerLayoutId)\n ) {\n return {\n kind: \"rejected\",\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedMissingSlotProof,\n };\n }\n if (\n declaredInterception !== null &&\n targetSlotBinding.ownerLayoutId !== declaredInterception.ownerLayoutId\n ) {\n return {\n kind: \"rejected\",\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedUndeclaredTopology,\n };\n }\n\n const preservePreviousSlotIds = resolveDefaultOrUnmatchedSlotPersistenceForLayouts({\n currentSlotBindings: options.currentTopology.slotBindings,\n preservedLayoutIds,\n targetSlotBindings: options.targetTopology.slotBindings,\n }).filter((slotId) => slotId !== proof.slotId);\n\n return {\n kind: \"approved\",\n preserveElementIds: preservedLayoutIds,\n preservePreviousSlotIds,\n };\n}\n\nfunction planFlightResponseArrived(options: {\n event: Extract<NavigationEvent, { kind: \"flightResponseArrived\" }>;\n routeManifest: RouteManifest | null;\n state: NavigationPlannerStateV0;\n}): NavigationDecisionV0 {\n const targetSnapshot = options.event.result.targetSnapshot;\n const currentTopology = resolveRouteTopologySnapshot({\n routeManifest: options.routeManifest,\n slotBindingSource: \"snapshot\",\n snapshot: options.state.visibleSnapshot,\n });\n const targetTopology = resolveRouteTopologySnapshot({\n routeManifest: options.routeManifest,\n slotBindingSource: \"manifestTarget\",\n snapshot: targetSnapshot,\n });\n const traceFields = createRootBoundaryTraceFields({\n currentRootLayoutTreePath:\n currentTopology.kind === \"known\" ? currentTopology.topology.rootLayoutTreePath : null,\n event: options.event,\n nextRootLayoutTreePath:\n targetTopology.kind === \"known\" ? targetTopology.topology.rootLayoutTreePath : null,\n state: options.state,\n });\n\n if (options.event.token.lane === \"prefetch\") {\n return {\n kind: \"noCommit\",\n reason: \"prefetchOnly\",\n token: options.event.token,\n trace: createNavigationTrace(NavigationTraceReasonCodes.prefetchOnly, traceFields),\n };\n }\n\n const cacheEntryProofEvaluation = evaluateCacheEntryReuseProof(\n options.event.result.cacheEntryReuseProof,\n );\n if (cacheEntryProofEvaluation.kind === \"rejected\") {\n return createCacheProofRejectedDecision({\n event: options.event,\n rejection: cacheEntryProofEvaluation,\n traceFields,\n });\n }\n const acceptedCacheEntryDecision = cacheEntryProofEvaluation.decision;\n const commitTraceFields = createAcceptedCacheProofTraceFields(\n traceFields,\n acceptedCacheEntryDecision,\n );\n const cacheEntryProposalFields = createCacheEntryProposalFields(acceptedCacheEntryDecision);\n\n // interceptionContext is transport evidence, not authority. Normal payloads\n // can carry it when a request was sent from an intercepted visible world, so\n // only explicit __interception proof enters the preservation branch.\n const hasInterceptedPayload = targetSnapshot.interception !== null;\n if (hasInterceptedPayload) {\n if (currentTopology.kind === \"unknown\" || targetTopology.kind === \"unknown\") {\n return createInterceptionProofRejectedDecision({\n event: options.event,\n reasonCode: NavigationTraceReasonCodes.interceptedRejectedUndeclaredTopology,\n traceFields: commitTraceFields,\n });\n }\n\n const validation = validateInterceptedPreservation({\n currentSnapshot: options.state.visibleSnapshot,\n currentTopology: currentTopology.topology,\n routeManifest: options.routeManifest,\n targetSnapshot,\n targetTopology: targetTopology.topology,\n });\n if (validation.kind === \"rejected\") {\n return createInterceptionProofRejectedDecision({\n event: options.event,\n reasonCode: validation.reasonCode,\n traceFields: commitTraceFields,\n });\n }\n\n return {\n kind: \"proposeCommit\",\n proposal: {\n ...cacheEntryProposalFields,\n preserveAbsentSlots: false,\n preserveElementIds: validation.preserveElementIds,\n preservePreviousSlotIds: validation.preservePreviousSlotIds,\n reason: \"interceptedCurrentRootBoundary\",\n targetSnapshot,\n },\n token: options.event.token,\n trace: createNavigationTrace(\n NavigationTraceReasonCodes.interceptedCommitCurrent,\n commitTraceFields,\n ),\n };\n }\n\n const transition =\n currentTopology.kind === \"unknown\" || targetTopology.kind === \"unknown\"\n ? \"rootBoundaryUnknown\"\n : classifyRootBoundaryTransition(\n currentTopology.topology.rootBoundaryId,\n targetTopology.topology.rootBoundaryId,\n );\n\n if (transition === \"rootBoundaryChanged\") {\n return {\n kind: \"hardNavigate\",\n reason: \"rootBoundaryChanged\",\n token: options.event.token,\n trace: createNavigationTrace(\n NavigationTraceReasonCodes.rootBoundaryChanged,\n commitTraceFields,\n ),\n url: options.event.result.href,\n };\n }\n\n if (transition === \"rootBoundaryUnknown\") {\n // Unknown topology is not semantic proof. The event may still commit its\n // fully supplied payload, but it must not preserve absent slots, layouts,\n // or previous slot content from snapshot-derived route shape.\n return {\n kind: \"proposeCommit\",\n proposal: {\n ...cacheEntryProposalFields,\n preserveAbsentSlots: false,\n preserveElementIds: [],\n preservePreviousSlotIds: [],\n reason: \"unprovenTopologyFallback\",\n targetSnapshot,\n },\n token: options.event.token,\n trace: createNavigationTrace(\n NavigationTraceReasonCodes.rootBoundaryUnknown,\n commitTraceFields,\n ),\n };\n }\n\n if (currentTopology.kind !== \"known\" || targetTopology.kind !== \"known\") {\n throw new Error(\"[vinext] Current-root navigation planning requires manifest topology\");\n }\n\n return {\n kind: \"proposeCommit\",\n proposal: {\n ...cacheEntryProposalFields,\n preserveAbsentSlots: false,\n preserveElementIds: resolveCurrentRootBoundaryCommitElementPersistence({\n currentTopology: currentTopology.topology,\n lane: options.event.token.lane,\n targetTopology: targetTopology.topology,\n }),\n preservePreviousSlotIds: resolveCurrentRootBoundaryCommitSlotPersistence({\n currentTopology: currentTopology.topology,\n lane: options.event.token.lane,\n targetTopology: targetTopology.topology,\n }),\n reason: \"currentRootBoundary\",\n targetSnapshot,\n },\n token: options.event.token,\n trace: createNavigationTrace(NavigationTraceReasonCodes.commitCurrent, commitTraceFields),\n };\n}\n\nfunction planNavigation(input: NavigationPlannerInput): NavigationDecisionV0 {\n switch (input.event.kind) {\n case \"navigate\":\n return createRequestWorkDecision({\n eventKind: input.event.kind,\n state: input.state,\n work: {\n href: input.event.href,\n kind: \"flight\",\n mode: input.event.mode,\n },\n });\n case \"refresh\":\n return createRequestWorkDecision({\n eventKind: input.event.kind,\n state: input.state,\n work: {\n href: input.state.visibleSnapshot.displayUrl,\n kind: \"flight\",\n mode: \"refresh\",\n },\n });\n case \"traverse\":\n return createRequestWorkDecision({\n eventKind: input.event.kind,\n state: input.state,\n work: {\n direction: input.event.direction,\n historyState: input.event.historyState,\n kind: \"traverseFlight\",\n },\n });\n case \"prefetch\":\n return createRequestWorkDecision({\n eventKind: input.event.kind,\n state: input.state,\n work: {\n href: input.event.href,\n kind: \"prefetch\",\n },\n });\n case \"flightResponseArrived\":\n return planFlightResponseArrived({\n event: input.event,\n routeManifest: input.routeManifest,\n state: input.state,\n });\n default: {\n const _exhaustive: never = input.event;\n throw new Error(\"[vinext] Unknown navigation event: \" + String(_exhaustive));\n }\n }\n}\n\nexport const navigationPlanner = {\n classifyRootBoundaryTransition,\n plan: planNavigation,\n resolveCurrentRootBoundaryElementPersistence,\n resolveMountedParallelSlotPersistence,\n resolveSameLayoutAncestorPersistence,\n};\n"],"mappings":";;;;;;AAgMA,MAAM,uCAAuC;AAC7C,MAAM,iCACJ;AAEF,SAAS,0BAA0B,SAIV;CACvB,MAAM,iBACJ,QAAQ,KAAK,SAAS,mBAAmB,EAAE,mBAAmB,QAAQ,KAAK,WAAW,GAAG,EAAE;CAC7F,OAAO;EACL,MAAM;EACN,OAAO,QAAQ,MAAM;EACrB,MAAM,QAAQ;EACd,OAAO,sBAAsB,2BAA2B,aAAa;GACnE,WAAW,QAAQ;GACnB,YAAY,2BAA2B,QAAQ,KAAK;GACpD,GAAG;GACJ,CAAC;EACH;;AAGH,SAAS,2BAA2B,MAAoC;CACtE,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK,YACH,OAAO,KAAK;EACd,KAAK,kBACH,OAAO;EACT,SAEE,MAAM,IAAI,MAAM,iDAAiD,OAAOA,KAAY,CAAC;;;AAK3F,SAAS,4BAA4B,UAAkD;CACrF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;GACD;EACD,OAAO,QAAQ,MAAM;EACrB,OAAO,sBAAsB,2BAA2B,eAAe,kBAAkB;EAC1F;;AAGH,SAAS,eAAe,OAAqD;CAC3E,QAAQ,MAAM,MAAM,MAApB;EACE,KAAK,YACH,OAAO,0BAA0B;GAC/B,WAAW,MAAM,MAAM;GACvB,OAAO,MAAM;GACb,MAAM;IACJ,MAAM,MAAM,MAAM;IAClB,MAAM;IACN,MAAM,MAAM,MAAM;IACnB;GACF,CAAC;EACJ,KAAK,WACH,OAAO,0BAA0B;GAC/B,WAAW,MAAM,MAAM;GACvB,OAAO,MAAM;GACb,MAAM;IACJ,MAAM,MAAM,MAAM,gBAAgB;IAClC,MAAM;IACN,MAAM;IACP;GACF,CAAC;EACJ,KAAK,YACH,OAAO,0BAA0B;GAC/B,WAAW,MAAM,MAAM;GACvB,OAAO,MAAM;GACb,MAAM;IACJ,WAAW,MAAM,MAAM;IACvB,cAAc,MAAM,MAAM;IAC1B,MAAM;IACP;GACF,CAAC;EACJ,KAAK,YACH,OAAO,0BAA0B;GAC/B,WAAW,MAAM,MAAM;GACvB,OAAO,MAAM;GACb,MAAM;IACJ,MAAM,MAAM,MAAM;IAClB,MAAM;IACP;GACF,CAAC;EACJ,KAAK,yBACH,OAAO,0BAA0B;GAC/B,OAAO,MAAM;GACb,eAAe,MAAM;GACrB,OAAO,MAAM;GACd,CAAC;EACJ,SAAS;GACP,MAAM,cAAqB,MAAM;GACjC,MAAM,IAAI,MAAM,wCAAwC,OAAO,YAAY,CAAC;;;;AAKlF,MAAa,oBAAoB;CAC/B;CACA,MAAM;CACN;CACA;CACA;CACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-trace.js","names":[],"sources":["../../src/server/navigation-trace.ts"],"sourcesContent":["export const NAVIGATION_TRACE_SCHEMA_VERSION = 0;\n\nexport type NavigationTraceSchemaVersion = 0;\n\nexport const NavigationTraceReasonCodes = {\n cacheProofRejected: \"NC_CACHE_REJECT\",\n commitCurrent: \"NC_COMMIT\",\n interceptedCommitCurrent: \"NC_INTERCEPT_COMMIT\",\n interceptedRejectedIncompatibleRoot: \"NC_INTERCEPT_REJECT_ROOT\",\n interceptedRejectedMissingProof: \"NC_INTERCEPT_REJECT_MISSING_PROOF\",\n interceptedRejectedMissingSlotProof: \"NC_INTERCEPT_REJECT_SLOT\",\n interceptedRejectedTargetMismatch: \"NC_INTERCEPT_REJECT_TARGET\",\n interceptedRejectedUndeclaredTopology: \"NC_INTERCEPT_REJECT_GRAPH\",\n interceptedRejectedUnknownSource: \"NC_INTERCEPT_REJECT_SOURCE\",\n prefetchOnly: \"NC_PREFETCH_ONLY\",\n requestWork: \"NC_REQUEST\",\n rootBoundaryChanged: \"NC_ROOT\",\n rootBoundaryUnknown: \"NC_ROOT_UNKNOWN\",\n staleOperation: \"NC_STALE\",\n} satisfies Readonly<{\n cacheProofRejected: \"NC_CACHE_REJECT\";\n commitCurrent: \"NC_COMMIT\";\n interceptedCommitCurrent: \"NC_INTERCEPT_COMMIT\";\n interceptedRejectedIncompatibleRoot: \"NC_INTERCEPT_REJECT_ROOT\";\n interceptedRejectedMissingProof: \"NC_INTERCEPT_REJECT_MISSING_PROOF\";\n interceptedRejectedMissingSlotProof: \"NC_INTERCEPT_REJECT_SLOT\";\n interceptedRejectedTargetMismatch: \"NC_INTERCEPT_REJECT_TARGET\";\n interceptedRejectedUndeclaredTopology: \"NC_INTERCEPT_REJECT_GRAPH\";\n interceptedRejectedUnknownSource: \"NC_INTERCEPT_REJECT_SOURCE\";\n prefetchOnly: \"NC_PREFETCH_ONLY\";\n requestWork: \"NC_REQUEST\";\n rootBoundaryChanged: \"NC_ROOT\";\n rootBoundaryUnknown: \"NC_ROOT_UNKNOWN\";\n staleOperation: \"NC_STALE\";\n}>;\n\nexport const NavigationTraceTransactionCodes = {\n hardNavigate: \"NT_HARD_NAVIGATE\",\n noCommit: \"NT_NO_COMMIT\",\n visibleCommit: \"NT_VISIBLE_COMMIT\",\n} satisfies Readonly<{\n hardNavigate: \"NT_HARD_NAVIGATE\";\n noCommit: \"NT_NO_COMMIT\";\n visibleCommit: \"NT_VISIBLE_COMMIT\";\n}>;\n\nexport type NavigationTraceReasonCode =\n (typeof NavigationTraceReasonCodes)[keyof typeof NavigationTraceReasonCodes];\n\nexport type NavigationTraceTransactionCode =\n (typeof NavigationTraceTransactionCodes)[keyof typeof NavigationTraceTransactionCodes];\n\nexport type NavigationTraceCode = NavigationTraceReasonCode | NavigationTraceTransactionCode;\n\nexport type NavigationTraceFieldName =\n | \"activeNavigationId\"\n | \"cacheProofCode\"\n | \"cacheProofMode\"\n | \"cacheProofReuseClass\"\n | \"cacheProofScope\"\n | \"currentRootLayoutTreePath\"\n | \"currentVisibleCommitVersion\"\n | \"nextRootLayoutTreePath\"\n | \"eventKind\"\n | \"operationLane\"\n | \"pendingOperationId\"\n | \"startedVisibleCommitVersion\"\n | \"startedNavigationId\"\n | \"targetHref\"\n | \"traverseDirection\";\n\nexport type NavigationTraceFieldValue = string | number | boolean | null;\n\nexport type NavigationTraceFields = Readonly<\n Partial<Record<NavigationTraceFieldName, NavigationTraceFieldValue>>\n>;\n\nexport type NavigationTraceEntry = Readonly<{\n code: NavigationTraceCode;\n fields: NavigationTraceFields;\n}>;\n\nexport type NavigationTrace = Readonly<{\n schemaVersion: NavigationTraceSchemaVersion;\n entries: readonly NavigationTraceEntry[];\n}>;\n\nexport function createNavigationLifecycleTraceFields(options: {\n activeNavigationId?: number;\n currentRootLayoutTreePath: string | null;\n currentVisibleCommitVersion: number;\n nextRootLayoutTreePath: string | null;\n startedNavigationId?: number;\n startedVisibleCommitVersion: number;\n}): NavigationTraceFields {\n return {\n ...(options.activeNavigationId !== undefined\n ? { activeNavigationId: options.activeNavigationId }\n : {}),\n currentRootLayoutTreePath: options.currentRootLayoutTreePath,\n currentVisibleCommitVersion: options.currentVisibleCommitVersion,\n nextRootLayoutTreePath: options.nextRootLayoutTreePath,\n ...(options.startedNavigationId !== undefined\n ? { startedNavigationId: options.startedNavigationId }\n : {}),\n startedVisibleCommitVersion: options.startedVisibleCommitVersion,\n };\n}\n\nfunction createNavigationTraceEntry(\n code: NavigationTraceCode,\n fields: NavigationTraceFields = {},\n): NavigationTraceEntry {\n return {\n code,\n fields: { ...fields },\n };\n}\n\nexport function createNavigationTrace(\n code: NavigationTraceCode,\n fields: NavigationTraceFields = {},\n): NavigationTrace {\n return {\n schemaVersion: NAVIGATION_TRACE_SCHEMA_VERSION,\n entries: [createNavigationTraceEntry(code, fields)],\n };\n}\n\nexport function prependNavigationTraceEntry(\n trace: NavigationTrace,\n code: NavigationTraceCode,\n fields: NavigationTraceFields = {},\n): NavigationTrace {\n return {\n schemaVersion: trace.schemaVersion,\n entries: [createNavigationTraceEntry(code, fields), ...trace.entries],\n };\n}\n"],"mappings":";AAAA,MAAa,kCAAkC;AAI/C,MAAa,6BAA6B;CACxC,oBAAoB;CACpB,eAAe;CACf,0BAA0B;CAC1B,qCAAqC;CACrC,iCAAiC;CACjC,qCAAqC;CACrC,mCAAmC;CACnC,uCAAuC;CACvC,kCAAkC;CAClC,cAAc;CACd,aAAa;CACb,qBAAqB;CACrB,qBAAqB;CACrB,gBAAgB;CACjB;AAiBD,MAAa,kCAAkC;CAC7C,cAAc;CACd,UAAU;CACV,eAAe;CAChB;AA+CD,SAAgB,qCAAqC,SAO3B;CACxB,OAAO;EACL,GAAI,QAAQ,uBAAuB,KAAA,IAC/B,EAAE,oBAAoB,QAAQ,oBAAoB,GAClD,EAAE;EACN,2BAA2B,QAAQ;EACnC,6BAA6B,QAAQ;EACrC,wBAAwB,QAAQ;EAChC,GAAI,QAAQ,wBAAwB,KAAA,IAChC,EAAE,qBAAqB,QAAQ,qBAAqB,GACpD,EAAE;EACN,6BAA6B,QAAQ;EACtC;;AAGH,SAAS,2BACP,MACA,SAAgC,EAAE,EACZ;CACtB,OAAO;EACL;EACA,QAAQ,EAAE,GAAG,QAAQ;EACtB;;AAGH,SAAgB,sBACd,MACA,SAAgC,EAAE,EACjB;CACjB,OAAO;EACL,eAAA;EACA,SAAS,CAAC,2BAA2B,MAAM,OAAO,CAAC;EACpD;;AAGH,SAAgB,4BACd,OACA,MACA,SAAgC,EAAE,EACjB;CACjB,OAAO;EACL,eAAe,MAAM;EACrB,SAAS,CAAC,2BAA2B,MAAM,OAAO,EAAE,GAAG,MAAM,QAAQ;EACtE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"next-error-digest.js","names":[],"sources":["../../src/server/next-error-digest.ts"],"sourcesContent":["/**\n * Helpers for parsing Next.js error `digest` strings shared across the App\n * Router execution paths (server actions, page renders, route handlers).\n *\n * Next.js encodes special control flow as thrown errors carrying a `digest`\n * field with one of these formats:\n * - `NEXT_REDIRECT;<type>;<encodedUrl>;<status>` — `redirect()` / `permanentRedirect()`\n * - `NEXT_NOT_FOUND` — `notFound()`\n * - `NEXT_HTTP_ERROR_FALLBACK;<status>` — `forbidden()` / `unauthorized()` / etc.\n *\n * Each call site needs slightly different post-processing (URL resolution\n * against the request, 303-vs-307 status overrides for actions, etc.), so\n * these helpers only handle the parsing — callers shape the result.\n */\n\ntype NextRedirectDigest = {\n status: number;\n type: string | null;\n url: string;\n};\n\ntype NextHttpErrorDigest = {\n status: number;\n};\n\n/**\n * Pulls a stringified `digest` off an unknown thrown value, or returns null\n * when the value is not a digest-bearing error.\n */\nexport function getNextErrorDigest(error: unknown): string | null {\n if (!error || typeof error !== \"object\" || !(\"digest\" in error)) {\n return null;\n }\n\n return String(error.digest);\n}\n\n/**\n * Parses a `NEXT_REDIRECT;<type>;<encodedUrl>;<status>` digest. Returns null\n * when the digest is not a redirect digest or the encoded URL segment is\n * missing. The `url` is decoded with `decodeURIComponent`; the `status`\n * defaults to 307 when omitted; an omitted `type` is left as null so the\n * caller can apply the correct context-sensitive default.\n */\nexport function parseNextRedirectDigest(digest: string): NextRedirectDigest | null {\n if (!digest.startsWith(\"NEXT_REDIRECT;\")) {\n return null;\n }\n\n const parts = digest.split(\";\");\n const encodedUrl = parts[2];\n if (!encodedUrl) {\n return null;\n }\n\n const type = parts[1];\n\n return {\n status: parts[3] ? parseInt(parts[3], 10) : 307,\n type: type || null,\n url: decodeURIComponent(encodedUrl),\n };\n}\n\n/**\n * Parses a `NEXT_NOT_FOUND` or `NEXT_HTTP_ERROR_FALLBACK;<status>` digest.\n * Returns `{ status: 404 }` for `NEXT_NOT_FOUND` and the parsed status code\n * for the fallback form. Returns null otherwise.\n */\nexport function parseNextHttpErrorDigest(digest: string): NextHttpErrorDigest | null {\n if (digest === \"NEXT_NOT_FOUND\") {\n return { status: 404 };\n }\n if (digest.startsWith(\"NEXT_HTTP_ERROR_FALLBACK;\")) {\n return { status: parseInt(digest.split(\";\")[1], 10) };\n }\n return null;\n}\n"],"mappings":";;;;;AA6BA,SAAgB,mBAAmB,OAA+B;CAChE,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,YAAY,QACvD,OAAO;CAGT,OAAO,OAAO,MAAM,OAAO;;;;;;;;;AAU7B,SAAgB,wBAAwB,QAA2C;CACjF,IAAI,CAAC,OAAO,WAAW,iBAAiB,EACtC,OAAO;CAGT,MAAM,QAAQ,OAAO,MAAM,IAAI;CAC/B,MAAM,aAAa,MAAM;CACzB,IAAI,CAAC,YACH,OAAO;CAGT,MAAM,OAAO,MAAM;CAEnB,OAAO;EACL,QAAQ,MAAM,KAAK,SAAS,MAAM,IAAI,GAAG,GAAG;EAC5C,MAAM,QAAQ;EACd,KAAK,mBAAmB,WAAW;EACpC;;;;;;;AAQH,SAAgB,yBAAyB,QAA4C;CACnF,IAAI,WAAW,kBACb,OAAO,EAAE,QAAQ,KAAK;CAExB,IAAI,OAAO,WAAW,4BAA4B,EAChD,OAAO,EAAE,QAAQ,SAAS,OAAO,MAAM,IAAI,CAAC,IAAI,GAAG,EAAE;CAEvD,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-path.js","names":[],"sources":["../../src/server/normalize-path.ts"],"sourcesContent":["/**\n * Re-encode path delimiter characters that were decoded by decodeURIComponent.\n * After decoding a URL segment, characters like / # ? \\ need to be re-encoded\n * so they don't change the path structure.\n *\n * Ported from Next.js: packages/next/src/shared/lib/router/utils/escape-path-delimiters.ts\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/utils/escape-path-delimiters.ts\n */\nexport function escapePathDelimiters(segment: string, escapeEncoded?: boolean): string {\n return segment.replace(\n new RegExp(`([/#?]${escapeEncoded ? \"|%(2f|23|3f|5c)\" : \"\"})`, \"gi\"),\n (char: string) => encodeURIComponent(char),\n );\n}\n\n/**\n * Decode a URL pathname segment-by-segment, preserving encoded path delimiters.\n * Non-ASCII characters (e.g. %C3%A9 -> e) are decoded, but structural characters\n * like %2F (/) %23 (#) %3F (?) %5C (\\) are re-encoded after decoding.\n *\n * This prevents encoded slashes from changing the path structure (e.g.\n * /admin%2Fpanel stays as a single segment, not /admin/panel).\n *\n * Ported from Next.js: packages/next/src/server/lib/router-utils/decode-path-params.ts\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/router-utils/decode-path-params.ts\n */\nexport function decodePathParams(pathname: string): string {\n return pathname\n .split(\"/\")\n .map((seg) => {\n try {\n return escapePathDelimiters(decodeURIComponent(seg), true);\n } catch {\n return seg;\n }\n })\n .join(\"/\");\n}\n\nexport function isInterceptionMatchedUrlPath(value: string): boolean {\n return (\n value.startsWith(\"/\") &&\n !value.startsWith(\"//\") &&\n !value.includes(\"?\") &&\n !value.includes(\"#\") &&\n !value.includes(\"\\0\")\n );\n}\n\n/**\n * Path normalization utility for request handling.\n *\n * Normalizes URL pathnames to a canonical form BEFORE any matching occurs\n * (middleware, routing, redirects, rewrites). This ensures middleware and\n * the router always see the same path, preventing path-confusion issues like\n * double-slash mismatches.\n *\n * Normalization rules:\n * 1. Collapse consecutive slashes: //foo///bar → /foo/bar\n * 2. Resolve single-dot segments: /foo/./bar → /foo/bar\n * 3. Resolve double-dot segments: /foo/../bar → /bar\n * 4. Ensure leading slash: foo/bar → /foo/bar\n * 5. Preserve root: / → /\n *\n * This function does NOT:\n * - Strip or add trailing slashes (handled separately by trailingSlash config)\n * - Decode percent-encoded characters (callers should decode before calling this)\n * - Lowercase the path (route matching is case-sensitive)\n */\nexport function normalizePath(pathname: string): string {\n // Fast path: already canonical (single leading /, no //, no /./, no /../)\n if (\n pathname === \"/\" ||\n (pathname.length > 1 &&\n pathname[0] === \"/\" &&\n !pathname.includes(\"//\") &&\n !pathname.includes(\"/./\") &&\n !pathname.includes(\"/../\") &&\n !pathname.endsWith(\"/.\") &&\n !pathname.endsWith(\"/..\"))\n ) {\n return pathname;\n }\n\n const segments = pathname.split(\"/\");\n const resolved: string[] = [];\n\n for (const segment of segments) {\n if (segment === \"\" || segment === \".\") {\n // Skip empty segments (from // or leading /) and single-dot segments\n continue;\n }\n if (segment === \"..\") {\n // Go up one level, but never above root\n resolved.pop();\n } else {\n resolved.push(segment);\n }\n }\n\n return \"/\" + resolved.join(\"/\");\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,qBAAqB,SAAiB,eAAiC;CACrF,OAAO,QAAQ,QACb,IAAI,OAAO,SAAS,gBAAgB,oBAAoB,GAAG,IAAI,KAAK,GACnE,SAAiB,mBAAmB,KAAK,CAC3C;;;;;;;;;;;;;AAcH,SAAgB,iBAAiB,UAA0B;CACzD,OAAO,SACJ,MAAM,IAAI,CACV,KAAK,QAAQ;EACZ,IAAI;GACF,OAAO,qBAAqB,mBAAmB,IAAI,EAAE,KAAK;UACpD;GACN,OAAO;;GAET,CACD,KAAK,IAAI;;AAGd,SAAgB,6BAA6B,OAAwB;CACnE,OACE,MAAM,WAAW,IAAI,IACrB,CAAC,MAAM,WAAW,KAAK,IACvB,CAAC,MAAM,SAAS,IAAI,IACpB,CAAC,MAAM,SAAS,IAAI,IACpB,CAAC,MAAM,SAAS,KAAK;;;;;;;;;;;;;;;;;;;;;;AAwBzB,SAAgB,cAAc,UAA0B;CAEtD,IACE,aAAa,OACZ,SAAS,SAAS,KACjB,SAAS,OAAO,OAChB,CAAC,SAAS,SAAS,KAAK,IACxB,CAAC,SAAS,SAAS,MAAM,IACzB,CAAC,SAAS,SAAS,OAAO,IAC1B,CAAC,SAAS,SAAS,KAAK,IACxB,CAAC,SAAS,SAAS,MAAM,EAE3B,OAAO;CAGT,MAAM,WAAW,SAAS,MAAM,IAAI;CACpC,MAAM,WAAqB,EAAE;CAE7B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,YAAY,MAAM,YAAY,KAEhC;EAEF,IAAI,YAAY,MAEd,SAAS,KAAK;OAEd,SAAS,KAAK,QAAQ;;CAI1B,OAAO,MAAM,SAAS,KAAK,IAAI"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-api-route.js","names":["PagesApiBodyParseError"],"sources":["../../src/server/pages-api-route.ts"],"sourcesContent":["import \"./server-globals.js\";\nimport type { Route } from \"../routing/pages-router.js\";\nimport { mergeRouteParamsIntoQuery, parseQueryString } from \"../utils/query.js\";\nimport {\n createPagesReqRes,\n parsePagesApiBody,\n type PagesRequestQuery,\n type PagesReqResRequest,\n type PagesReqResResponse,\n PagesApiBodyParseError,\n} from \"./pages-node-compat.js\";\nimport { resolveBodyParserConfig } from \"./pages-body-parser-config.js\";\nimport { internalServerErrorResponse } from \"./http-error-responses.js\";\nimport { isEdgeApiRuntime } from \"./edge-api-runtime.js\";\nimport { runWithExecutionContext, type ExecutionContextLike } from \"vinext/shims/request-context\";\nimport { NextRequest } from \"vinext/shims/server\";\n\ntype PagesApiRouteConfig = {\n runtime?: string;\n /**\n * `export const config = { api: { bodyParser: false | { sizeLimit: '4mb' } } }`\n * — controls whether vinext parses the request body for the route handler.\n *\n * `bodyParser: false` is critical for webhook handlers (Stripe, GitHub,\n * Slack, etc.) that need to read the raw bytes to verify an HMAC\n * signature. With it set, `req.body` is left undefined and the raw stream\n * is exposed on `req.body` as a Web `ReadableStream<Uint8Array>` so user\n * code can consume it.\n *\n * @see https://nextjs.org/docs/pages/building-your-application/routing/api-routes#custom-config\n */\n api?: {\n bodyParser?: boolean | { sizeLimit?: string | number };\n responseLimit?: boolean | string | number;\n };\n};\n\ntype PagesNodeApiRouteHandler = (\n req: PagesReqResRequest,\n res: PagesReqResResponse,\n) => void | Promise<void>;\n\ntype PagesEdgeApiRouteHandler = (request: Request) => Response | Promise<Response>;\n\ntype PagesApiRouteModule = {\n /**\n * `export const config = { runtime: 'edge' }` — historical Pages Router form.\n */\n config?: PagesApiRouteConfig;\n /**\n * `export const runtime = 'edge'` — bare export form. Next.js resolves the\n * effective runtime as `config.runtime ?? config.config?.runtime`, so a\n * top-level `runtime` export takes precedence over the nested config form.\n *\n * @see https://github.com/vercel/next.js/blob/canary/packages/next/src/build/analysis/get-page-static-info.ts\n */\n runtime?: string;\n default?: PagesNodeApiRouteHandler | PagesEdgeApiRouteHandler;\n};\n\nfunction resolveModuleRuntime(module: PagesApiRouteModule): string | undefined {\n return module.runtime ?? module.config?.runtime;\n}\n\nexport type PagesApiRouteMatch = {\n params: PagesRequestQuery;\n route: Pick<Route, \"pattern\"> & {\n module: PagesApiRouteModule;\n };\n};\n\ntype HandlePagesApiRouteOptions = {\n /**\n * Per-request Cloudflare Workers `ExecutionContext`. When provided, the\n * API route runs inside `runWithExecutionContext(ctx, ...)` so any\n * `after()` (or other shim) call inside the handler can reach\n * `ctx.waitUntil()` via the ALS and keep the isolate alive past the\n * response. Omit on Node.js dev where no Workers lifecycle exists.\n */\n ctx?: ExecutionContextLike;\n match: PagesApiRouteMatch | null;\n reportRequestError?: (error: Error, routePattern: string) => void | Promise<void>;\n request: Request;\n url: string;\n};\n\nfunction buildPagesApiQuery(url: string, params: PagesRequestQuery): PagesRequestQuery {\n return mergeRouteParamsIntoQuery(parseQueryString(url), params);\n}\n\nfunction isEdgeApiRouteModule(\n module: PagesApiRouteModule,\n): module is PagesApiRouteModule & { default: PagesEdgeApiRouteHandler } {\n return typeof module.default === \"function\" && isEdgeApiRuntime(resolveModuleRuntime(module));\n}\n\nfunction isNodeApiRouteModule(\n module: PagesApiRouteModule,\n): module is PagesApiRouteModule & { default: PagesNodeApiRouteHandler } {\n return typeof module.default === \"function\" && !isEdgeApiRuntime(resolveModuleRuntime(module));\n}\n\nexport async function handlePagesApiRoute(options: HandlePagesApiRouteOptions): Promise<Response> {\n if (options.ctx) {\n return runWithExecutionContext(options.ctx, () => _handlePagesApiRoute(options));\n }\n return _handlePagesApiRoute(options);\n}\n\nasync function _handlePagesApiRoute(options: HandlePagesApiRouteOptions): Promise<Response> {\n if (!options.match) {\n return new Response(\"404 - API route not found\", { status: 404 });\n }\n\n const { route, params } = options.match;\n\n try {\n if (isEdgeApiRouteModule(route.module)) {\n // Next.js wraps the incoming Request in a NextRequest before invoking\n // edge API handlers, so handlers can use `req.nextUrl.searchParams`,\n // `req.cookies`, etc. (Cf. NextRequestHint in next/src/server/web/adapter.ts.)\n const nextRequest = new NextRequest(options.request);\n const response = await route.module.default(nextRequest);\n if (response instanceof Response) {\n return response;\n }\n\n throw new Error(\"Edge API route did not return a Response\");\n }\n\n // This is redundant at runtime after the edge branch for function exports, but it\n // keeps the Node handler ABI narrowed without a production type assertion.\n if (!isNodeApiRouteModule(route.module)) {\n return new Response(\"API route does not export a default function\", { status: 500 });\n }\n\n const query = buildPagesApiQuery(options.url, params);\n\n // Honour `export const config = { api: { bodyParser: ... } }` on the\n // route module. When the handler opts out (`bodyParser: false`) we must\n // not consume the stream — leave `req.body` as the raw Web\n // `ReadableStream<Uint8Array>` so user code (e.g. a Stripe/GitHub\n // webhook) can read the raw bytes for HMAC verification.\n const bodyParserConfig = resolveBodyParserConfig(route.module.config);\n\n const body = bodyParserConfig.enabled\n ? await parsePagesApiBody(options.request, bodyParserConfig.sizeLimit)\n : (options.request.body ?? undefined);\n\n const { req, res, responsePromise } = createPagesReqRes({\n body,\n query,\n request: options.request,\n url: options.url,\n });\n\n await route.module.default(req, res);\n res.end();\n return await responsePromise;\n } catch (error) {\n if (error instanceof PagesApiBodyParseError) {\n return new Response(error.message, {\n status: error.statusCode,\n statusText: error.message,\n });\n }\n\n void options.reportRequestError?.(\n error instanceof Error ? error : new Error(String(error)),\n route.pattern,\n );\n return internalServerErrorResponse();\n }\n}\n"],"mappings":";;;;;;;;;;AA4DA,SAAS,qBAAqB,QAAiD;CAC7E,OAAO,OAAO,WAAW,OAAO,QAAQ;;AAyB1C,SAAS,mBAAmB,KAAa,QAA8C;CACrF,OAAO,0BAA0B,iBAAiB,IAAI,EAAE,OAAO;;AAGjE,SAAS,qBACP,QACuE;CACvE,OAAO,OAAO,OAAO,YAAY,cAAc,iBAAiB,qBAAqB,OAAO,CAAC;;AAG/F,SAAS,qBACP,QACuE;CACvE,OAAO,OAAO,OAAO,YAAY,cAAc,CAAC,iBAAiB,qBAAqB,OAAO,CAAC;;AAGhG,eAAsB,oBAAoB,SAAwD;CAChG,IAAI,QAAQ,KACV,OAAO,wBAAwB,QAAQ,WAAW,qBAAqB,QAAQ,CAAC;CAElF,OAAO,qBAAqB,QAAQ;;AAGtC,eAAe,qBAAqB,SAAwD;CAC1F,IAAI,CAAC,QAAQ,OACX,OAAO,IAAI,SAAS,6BAA6B,EAAE,QAAQ,KAAK,CAAC;CAGnE,MAAM,EAAE,OAAO,WAAW,QAAQ;CAElC,IAAI;EACF,IAAI,qBAAqB,MAAM,OAAO,EAAE;GAItC,MAAM,cAAc,IAAI,YAAY,QAAQ,QAAQ;GACpD,MAAM,WAAW,MAAM,MAAM,OAAO,QAAQ,YAAY;GACxD,IAAI,oBAAoB,UACtB,OAAO;GAGT,MAAM,IAAI,MAAM,2CAA2C;;EAK7D,IAAI,CAAC,qBAAqB,MAAM,OAAO,EACrC,OAAO,IAAI,SAAS,gDAAgD,EAAE,QAAQ,KAAK,CAAC;EAGtF,MAAM,QAAQ,mBAAmB,QAAQ,KAAK,OAAO;EAOrD,MAAM,mBAAmB,wBAAwB,MAAM,OAAO,OAAO;EAMrE,MAAM,EAAE,KAAK,KAAK,oBAAoB,kBAAkB;GACtD,MALW,iBAAiB,UAC1B,MAAM,kBAAkB,QAAQ,SAAS,iBAAiB,UAAU,GACnE,QAAQ,QAAQ,QAAQ,KAAA;GAI3B;GACA,SAAS,QAAQ;GACjB,KAAK,QAAQ;GACd,CAAC;EAEF,MAAM,MAAM,OAAO,QAAQ,KAAK,IAAI;EACpC,IAAI,KAAK;EACT,OAAO,MAAM;UACN,OAAO;EACd,IAAI,iBAAiBA,qBACnB,OAAO,IAAI,SAAS,MAAM,SAAS;GACjC,QAAQ,MAAM;GACd,YAAY,MAAM;GACnB,CAAC;EAGJ,QAAa,qBACX,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC,EACzD,MAAM,QACP;EACD,OAAO,6BAA6B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-body-parser-config.js","names":[],"sources":["../../src/server/pages-body-parser-config.ts"],"sourcesContent":["/**\n * Resolve the Pages Router `api.bodyParser` config from a route module export.\n *\n * Next.js API routes can opt out of automatic body parsing or raise the\n * default 1 MB size limit:\n *\n * export const config = { api: { bodyParser: false } };\n * export const config = { api: { bodyParser: { sizeLimit: '4mb' } } };\n *\n * `bodyParser: false` is critical for webhook handlers (Stripe, GitHub,\n * Slack, etc.) that must read the raw request bytes to verify an HMAC\n * signature. Silently parsing the body would consume the stream and break\n * signature verification — usually failing closed, sometimes failing open.\n *\n * @see https://nextjs.org/docs/pages/building-your-application/routing/api-routes#custom-config\n * @see Next.js: packages/next/src/server/api-utils/node/api-resolver.ts\n *\n * The format of `sizeLimit` mirrors what Next.js accepts via the `bytes`\n * package: a number of bytes, or a string with a unit suffix\n * (`\"500b\"`, `\"100kb\"`, `\"4mb\"`, `\"1gb\"`).\n */\n\n/**\n * Default Pages Router API body size limit, matching Next.js.\n */\nexport const DEFAULT_PAGES_API_BODY_SIZE_LIMIT = 1 * 1024 * 1024;\n\n/**\n * Resolved bodyParser configuration. When `enabled` is `false`, the body\n * MUST be passed through to the handler as a raw stream (or left unparsed\n * with `req.body === undefined`), so user code can read it itself.\n */\ntype ResolvedBodyParserConfig = { enabled: false } | { enabled: true; sizeLimit: number };\n\nconst SIZE_UNITS: Record<string, number> = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n tb: 1024 * 1024 * 1024 * 1024,\n};\n\n/**\n * Parse a Next.js-style `sizeLimit` string (e.g. `\"4mb\"`, `\"100kb\"`, `\"1gb\"`)\n * or numeric byte value into a number of bytes. Returns `undefined` for\n * inputs that can't be parsed — callers should fall back to the default.\n *\n * Matches the format accepted by Next.js (the `bytes` package); we\n * implement it inline to avoid pulling a dependency for a tiny parser.\n */\nexport function parseSizeLimit(value: string | number | undefined): number | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === \"number\") {\n return Number.isFinite(value) && value >= 0 ? value : undefined;\n }\n if (typeof value !== \"string\") return undefined;\n\n const trimmed = value.trim().toLowerCase();\n if (!trimmed) return undefined;\n\n // Match `<number><unit?>` where number can be int/decimal and unit is one\n // of b/kb/mb/gb/tb. The unit is optional — a bare number is bytes.\n const match = /^(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb|tb)?$/.exec(trimmed);\n if (!match) return undefined;\n\n const amount = Number.parseFloat(match[1]);\n if (!Number.isFinite(amount) || amount < 0) return undefined;\n\n const unit = match[2] ?? \"b\";\n const multiplier = SIZE_UNITS[unit];\n if (multiplier === undefined) return undefined;\n\n return Math.floor(amount * multiplier);\n}\n\n/**\n * Read the resolved `bodyParser` config from a route module's `config`\n * export. Defaults to enabled with the 1 MB Next.js default.\n */\nexport function resolveBodyParserConfig(\n moduleConfig: { api?: { bodyParser?: boolean | { sizeLimit?: string | number } } } | undefined,\n defaultSizeLimit: number = DEFAULT_PAGES_API_BODY_SIZE_LIMIT,\n): ResolvedBodyParserConfig {\n const bodyParser = moduleConfig?.api?.bodyParser;\n\n // Explicit opt-out: leave the body untouched so handlers can read raw bytes.\n if (bodyParser === false) {\n return { enabled: false };\n }\n\n // `true` or `undefined` → default behaviour.\n if (bodyParser === undefined || bodyParser === true) {\n return { enabled: true, sizeLimit: defaultSizeLimit };\n }\n\n // Object form: honour `sizeLimit` if present and parseable, else default.\n if (typeof bodyParser === \"object\" && bodyParser !== null) {\n const parsed = parseSizeLimit(bodyParser.sizeLimit);\n return { enabled: true, sizeLimit: parsed ?? defaultSizeLimit };\n }\n\n // Anything else (truthy non-object/non-true) — be conservative and use\n // the default, matching Next.js's `!== false` check.\n return { enabled: true, sizeLimit: defaultSizeLimit };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,oCAAoC,IAAI,OAAO;AAS5D,MAAM,aAAqC;CACzC,GAAG;CACH,IAAI;CACJ,IAAI,OAAO;CACX,IAAI,OAAO,OAAO;CAClB,IAAI,OAAO,OAAO,OAAO;CAC1B;;;;;;;;;AAUD,SAAgB,eAAe,OAAwD;CACrF,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,KAAA;CAClD,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS,IAAI,QAAQ,KAAA;CAExD,IAAI,OAAO,UAAU,UAAU,OAAO,KAAA;CAEtC,MAAM,UAAU,MAAM,MAAM,CAAC,aAAa;CAC1C,IAAI,CAAC,SAAS,OAAO,KAAA;CAIrB,MAAM,QAAQ,uCAAuC,KAAK,QAAQ;CAClE,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,SAAS,OAAO,WAAW,MAAM,GAAG;CAC1C,IAAI,CAAC,OAAO,SAAS,OAAO,IAAI,SAAS,GAAG,OAAO,KAAA;CAGnD,MAAM,aAAa,WADN,MAAM,MAAM;CAEzB,IAAI,eAAe,KAAA,GAAW,OAAO,KAAA;CAErC,OAAO,KAAK,MAAM,SAAS,WAAW;;;;;;AAOxC,SAAgB,wBACd,cACA,mBAA2B,mCACD;CAC1B,MAAM,aAAa,cAAc,KAAK;CAGtC,IAAI,eAAe,OACjB,OAAO,EAAE,SAAS,OAAO;CAI3B,IAAI,eAAe,KAAA,KAAa,eAAe,MAC7C,OAAO;EAAE,SAAS;EAAM,WAAW;EAAkB;CAIvD,IAAI,OAAO,eAAe,YAAY,eAAe,MAEnD,OAAO;EAAE,SAAS;EAAM,WADT,eAAe,WAAW,UACA,IAAI;EAAkB;CAKjE,OAAO;EAAE,SAAS;EAAM,WAAW;EAAkB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-data-route.js","names":[],"sources":["../../src/server/pages-data-route.ts"],"sourcesContent":["/**\n * Helpers for the Pages Router `/_next/data/{buildId}/{...page}.json` endpoint.\n *\n * Next.js uses this endpoint for client-side navigations in the Pages Router:\n * `next/link` and `router.push()` fetch `pageProps` from this URL instead of\n * doing a full HTML navigation. The server must:\n * 1. Match the URL pattern and extract the page pathname (with the buildId\n * and `.json` extension removed, locale prefix preserved).\n * 2. Normalize the URL BEFORE middleware runs so middleware sees the page\n * path (e.g. `/about`) rather than the raw `/_next/data/.../about.json`.\n * 3. Invoke the same `getServerSideProps` / `getStaticProps` machinery as\n * the HTML page and serialize the resulting props as a JSON envelope:\n * `{ pageProps: ... }` with `Content-Type: application/json`.\n *\n * Ported from Next.js:\n * - `packages/next/src/server/normalizers/request/next-data.ts` — prefix/suffix matcher.\n * - `packages/next/src/server/base-server.ts` (`handleNextDataRequest`) — pipeline normalization.\n * - `packages/next/src/server/render.tsx` — JSON envelope emission (`isNextDataRequest`).\n */\n\nconst NEXT_DATA_PREFIX = \"/_next/data/\";\nconst NEXT_DATA_SUFFIX = \".json\";\n\ntype NextDataMatch = {\n /**\n * The normalized page pathname (with leading slash, no trailing slash,\n * `.json` stripped, buildId stripped). For locale-prefixed requests like\n * `/_next/data/<buildId>/en/about.json` this is `/en/about` — locale\n * handling is done downstream by the existing `resolvePagesI18nRequest`\n * pipeline so this helper does not need to know about i18n config.\n */\n pagePathname: string;\n};\n\n/**\n * Returns true if the pathname looks like a `_next/data` request, regardless\n * of buildId. Used by the request pipeline to short-circuit before middleware\n * even when the buildId is wrong (so we can still return a 404 JSON response).\n */\nexport function isNextDataPathname(pathname: string): boolean {\n return pathname.startsWith(NEXT_DATA_PREFIX) && pathname.endsWith(NEXT_DATA_SUFFIX);\n}\n\n/**\n * Parse `/_next/data/<buildId>/<...page>.json` and return the normalized page\n * pathname. Returns `null` if the pathname does not match the pattern or if\n * the buildId segment does not match the server's buildId.\n *\n * The returned `pagePathname` is the page route path Next.js would render for\n * the equivalent HTML navigation — including any locale prefix, which is then\n * stripped by `resolvePagesI18nRequest` downstream.\n *\n * `/_next/data/<buildId>/about.json` → `/about`\n * `/_next/data/<buildId>/en/about.json` → `/en/about`\n * `/_next/data/<buildId>/index.json` → `/`\n * `/_next/data/<buildId>/en.json` → `/en`\n * `/_next/data/<wrong-id>/about.json` → null\n * `/_next/data/<buildId>/about` → null (missing .json suffix)\n */\nexport function parseNextDataPathname(pathname: string, buildId: string): NextDataMatch | null {\n if (!buildId) return null;\n if (!isNextDataPathname(pathname)) return null;\n\n const expectedPrefix = `${NEXT_DATA_PREFIX}${buildId}/`;\n // `/_next/data/<buildId>.json` (no trailing slash) is not a valid data req.\n if (!pathname.startsWith(expectedPrefix)) return null;\n\n const rest = pathname.slice(expectedPrefix.length, -NEXT_DATA_SUFFIX.length);\n\n // Empty rest (`/_next/data/<buildId>/.json`) is not a valid page path.\n if (rest.length === 0) return null;\n\n // Next.js denormalizes `index` to `/` to mirror file-system page paths\n // (`pages/index.tsx` → `/`). See `denormalizePagePath` in Next.js.\n if (rest === \"index\") return { pagePathname: \"/\" };\n if (rest.endsWith(\"/index\")) return { pagePathname: `/${rest.slice(0, -\"/index\".length)}` };\n\n // The encoder (`getAssetPathFromRoute` in Next.js / `buildPagesDataPath` in\n // vinext) prefixes any path beginning with `index` with an extra `index/`\n // segment so an explicit `pages/index/foo.tsx` page (route `/index/foo`)\n // round-trips through the data URL without colliding with `/foo`. Strip\n // that prefix here.\n if (rest.startsWith(\"index/\")) return { pagePathname: `/${rest.slice(\"index/\".length)}` };\n\n return { pagePathname: `/${rest}` };\n}\n\n/**\n * Build the JSON envelope returned by `/_next/data/<buildId>/<page>.json`.\n * Mirrors Next.js' `RenderResult(JSON.stringify(props))` path in\n * `packages/next/src/server/render.tsx` (search for `isNextDataRequest`).\n *\n * The envelope is the outer `props` object the React tree would receive:\n * { pageProps: {...}, /* optional locale data, redirect markers, etc. *\\/ }\n */\nexport function buildNextDataJsonResponse(\n pageProps: Record<string, unknown>,\n safeJsonStringify: (value: unknown) => string,\n init?: ResponseInit,\n): Response {\n const body = safeJsonStringify({ pageProps });\n return new Response(body, {\n status: init?.status ?? 200,\n statusText: init?.statusText,\n headers: {\n \"Content-Type\": \"application/json\",\n ...(init?.headers as Record<string, string> | undefined),\n },\n });\n}\n\n/**\n * Build the 404 response Next.js returns for an unknown `_next/data` page.\n * Next.js renders this as a normal 404 page, but the body shape that clients\n * see for a missing page-data endpoint is the literal string `\"{ }\"` for the\n * body and a 404 status with `application/json` so client-side hard-navigation\n * fallback fires (see `__N_SSP` handling in `router.ts`).\n *\n * We match Next.js' behavior: 404 status + JSON content type. The body is an\n * empty JSON object so clients that blindly call `res.json()` do not throw\n * before checking the status code.\n */\nexport function buildNextDataNotFoundResponse(): Response {\n return new Response(\"{}\", {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;;;;;;AAkBzB,SAAgB,mBAAmB,UAA2B;CAC5D,OAAO,SAAS,WAAW,iBAAiB,IAAI,SAAS,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;AAmBrF,SAAgB,sBAAsB,UAAkB,SAAuC;CAC7F,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,CAAC,mBAAmB,SAAS,EAAE,OAAO;CAE1C,MAAM,iBAAiB,GAAG,mBAAmB,QAAQ;CAErD,IAAI,CAAC,SAAS,WAAW,eAAe,EAAE,OAAO;CAEjD,MAAM,OAAO,SAAS,MAAM,eAAe,QAAQ,GAAyB;CAG5E,IAAI,KAAK,WAAW,GAAG,OAAO;CAI9B,IAAI,SAAS,SAAS,OAAO,EAAE,cAAc,KAAK;CAClD,IAAI,KAAK,SAAS,SAAS,EAAE,OAAO,EAAE,cAAc,IAAI,KAAK,MAAM,GAAG,GAAiB,IAAI;CAO3F,IAAI,KAAK,WAAW,SAAS,EAAE,OAAO,EAAE,cAAc,IAAI,KAAK,MAAM,EAAgB,IAAI;CAEzF,OAAO,EAAE,cAAc,IAAI,QAAQ;;;;;;;;;;AAWrC,SAAgB,0BACd,WACA,mBACA,MACU;CACV,MAAM,OAAO,kBAAkB,EAAE,WAAW,CAAC;CAC7C,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ,MAAM,UAAU;EACxB,YAAY,MAAM;EAClB,SAAS;GACP,gBAAgB;GAChB,GAAI,MAAM;GACX;EACF,CAAC;;;;;;;;;;;;;AAcJ,SAAgB,gCAA0C;CACxD,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ;EACR,SAAS,EAAE,gBAAgB,oBAAoB;EAChD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-default-404.js","names":[],"sources":["../../src/server/pages-default-404.ts"],"sourcesContent":["/**\n * Default 404 HTML body for the Pages Router.\n *\n * Used when a Pages Router request does not match any route (and the app has\n * not supplied a custom `pages/404.tsx`). Mirrors the markup Next.js's\n * `pages/_error.tsx` produces for a 404 response: a centered status / message\n * pair plus minified theme CSS and dark-mode media query. The message string\n * `\"This page could not be found.\"` (note the trailing period) is the\n * canonical body asserted by Next.js's deploy suite\n * (`test/e2e/getserversideprops/test/index.test.ts`,\n * `test/e2e/basepath/error-pages.test.ts`).\n *\n * Kept as a hand-rendered HTML literal rather than a React-rendered template\n * because the Pages Router server entry is invoked from both Workers and the\n * dev server before any React-renderer wiring is available for this path —\n * matching the lightweight build-time strategy Next.js uses for its packaged\n * `_error` static fallback. See:\n * .nextjs-ref/packages/next/src/pages/_error.tsx\n */\n\nconst STATUS = 404;\nconst MESSAGE = \"This page could not be found.\";\n\nconst CSS = `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`;\n\nconst HTML = `<!DOCTYPE html><html><head><meta charset=\"utf-8\"/><meta name=\"viewport\" content=\"width=device-width\"/><title>${STATUS}: ${MESSAGE}</title><meta name=\"next-head-count\" content=\"2\"/><style data-next-hide-fouc=\"true\">body{display:none}</style><noscript data-next-hide-fouc=\"true\"><style>body{display:block}</style></noscript></head><body><div id=\"__next\"><div style=\"font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center\"><div style=\"line-height:48px\"><style>${CSS}</style><h1 class=\"next-error-h1\" style=\"display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top\">${STATUS}</h1><div style=\"display:inline-block\"><h2 style=\"font-size:14px;font-weight:400;line-height:28px\">${MESSAGE}</h2></div></div></div></div></body></html>`;\n\n/**\n * Build the Next.js-compatible default 404 HTML response for the Pages Router.\n * Content-type is `text/html; charset=utf-8`, matching Next.js's\n * `pages-handler` 404 response.\n */\nexport function buildDefaultPagesNotFoundResponse(): Response {\n return new Response(HTML, {\n status: STATUS,\n headers: { \"Content-Type\": \"text/html; charset=utf-8\" },\n });\n}\n\n/** Exported for tests / callers that need the raw HTML body. */\nexport const DEFAULT_PAGES_NOT_FOUND_HTML = HTML;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,SAAS;AACf,MAAM,UAAU;AAIhB,MAAM,OAAO,gHAAgH,OAAO,IAAI,QAAQ,u3BAAgqB,OAAO,qGAAqG,QAAQ;;;;;;AAOp6B,SAAgB,oCAA8C;CAC5D,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ;EACR,SAAS,EAAE,gBAAgB,4BAA4B;EACxD,CAAC;;;AAIJ,MAAa,+BAA+B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-document-initial-props.js","names":["BaseDocument"],"sources":["../../src/server/pages-document-initial-props.ts"],"sourcesContent":["/**\n * Pages Router `_document.tsx` `getInitialProps` helper.\n *\n * Next.js's `pages/_document.tsx` may override\n * `static async getInitialProps(ctx)` to inject extra props onto the\n * Document element (the classic pattern is\n * `await Document.getInitialProps(ctx)` + spread, see Next.js's\n * `test/e2e/async-modules/pages/_document.jsx`). The SSR pipeline invokes\n * that hook and then renders the Document with the resolved props:\n *\n * <Document {...htmlProps} {...docProps} />\n *\n * Reference:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/server/render.tsx\n * (search for `loadDocumentInitialProps` and `documentElement`).\n *\n * vinext only forwards `docProps`. The full `DocumentContext`\n * (`renderPage`, `defaultGetInitialProps`, `pathname`, `query`, `req`, `res`,\n * `err`, `asPath`) is not yet plumbed through. The common upstream pattern\n *\n * static async getInitialProps(ctx) {\n * const initialProps = await Document.getInitialProps(ctx)\n * return { ...initialProps, docValue }\n * }\n *\n * works because the base `Document.getInitialProps` shim in\n * `shims/document.tsx` returns `{ html: \"\" }` and ignores `ctx`. User\n * overrides that *only* read `ctx` will see `undefined` fields — that is a\n * separate gap tracked alongside the shim TODO.\n *\n * Returns `null` when the user did not override the base shim (the static\n * `getInitialProps` reference still points at the shim's stub) so callers\n * skip the spread and render the bare Document element on the fast path.\n *\n * Errors from a user `getInitialProps` propagate to the caller. Next.js's\n * `loadGetInitialProps` does not catch — a throw becomes a 500 — and vinext\n * matches that contract so user bugs surface as the loud failures Next.js\n * apps already debug against.\n */\nimport React, { type ComponentType, type ReactNode } from \"react\";\nimport { withScriptNonce } from \"vinext/shims/script-nonce-context\";\n// Static import so the identity comparison below is established once at\n// module evaluation. A previous version used `await import(...)` per request\n// and was flagged by reviewers as unnecessary work — and worse, it left a\n// per-request `await` on the fast path where the user had no override.\nimport BaseDocument from \"vinext/shims/document\";\nimport { readStreamAsText } from \"../utils/text-stream.js\";\n\nconst BASE_GET_INITIAL_PROPS = (\n BaseDocument as unknown as {\n getInitialProps?: unknown;\n }\n).getInitialProps;\n\nexport async function loadUserDocumentInitialProps(\n DocumentComponent: ComponentType,\n): Promise<Record<string, unknown> | null> {\n const getInitialProps = (\n DocumentComponent as unknown as {\n getInitialProps?: (\n ctx: unknown,\n ) => Promise<Record<string, unknown>> | Record<string, unknown>;\n }\n ).getInitialProps;\n if (typeof getInitialProps !== \"function\") return null;\n\n // Identity check: if the user did not override `static getInitialProps`,\n // the inherited reference is the shim's stub. Skip the call so the\n // fast path keeps the same number of awaits as before this helper landed.\n if (getInitialProps === BASE_GET_INITIAL_PROPS) return null;\n\n // Pass ctx as `{}`. Most upstream overrides only use ctx to delegate\n // back to `Document.getInitialProps`, which the shim ignores. Errors\n // propagate — matching Next.js's `loadGetInitialProps`, which has no\n // catch and surfaces user bugs as 500s.\n const result = await getInitialProps({});\n return result && typeof result === \"object\" ? (result as Record<string, unknown>) : null;\n}\n\n/** Options accepted by a `ctx.renderPage()` call (Pages Router contract). */\nexport type RenderPageEnhancers = {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n enhanceApp?: (App: ComponentType<{ children?: ReactNode }>) => any;\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n enhanceComponent?: (Comp: ComponentType<unknown>) => any;\n};\n\ntype DocumentInitialProps = {\n html: string;\n head?: ReactNode[];\n styles?: ReactNode;\n};\n\ntype DocumentRenderPageInput = {\n /** The user `_document` component (may define `getInitialProps`). */\n DocumentComponent: ComponentType | null;\n /**\n * Build the page React tree with optional App/Component enhancers applied.\n * Callers MUST NOT apply `withScriptNonce` themselves — this helper owns the\n * nonce responsibility so the prod and dev paths stay symmetric.\n */\n enhancePageElement?: ((opts: RenderPageEnhancers) => ReactNode) | undefined;\n /** Render a React tree to a UTF-8 byte stream (prod/dev specific). */\n renderToReadableStream: (element: React.ReactElement) => Promise<ReadableStream<Uint8Array>>;\n /** Render the document `styles` element to an HTML string. */\n renderStylesToString: (element: React.ReactElement) => Promise<string>;\n /** Per-request CSP nonce applied to the enhanced page tree, if any. */\n scriptNonce?: string | undefined;\n /** Extra `DocumentContext` fields (pathname/query/asPath). */\n context?: Record<string, unknown> | undefined;\n};\n\n/**\n * Run a user `_document.getInitialProps()` with a `ctx.renderPage()` that\n * applies optional `enhanceApp` / `enhanceComponent` wrappers around the page\n * React tree, mirroring Next.js's Pages Router contract.\n *\n * Used by CSS-in-JS libraries (styled-components, emotion) to wrap the\n * App/Component tree so styles can be collected during SSR. Shared between the\n * prod (`pages-page-response.ts`) and dev (`dev-server.ts`) SSR pipelines so\n * the `getInitialProps` + `renderPage` contract lives in one place.\n *\n * @see .nextjs-ref/packages/next/src/server/render.tsx (search `renderPage`)\n *\n * Result of attempting the renderPage contract:\n * - `skipped` — `getInitialProps` was NOT invoked (no override, or no\n * `enhancePageElement` wired up). Callers should run the\n * normal `loadUserDocumentInitialProps` fast path, which may\n * invoke `getInitialProps` itself.\n * - `rendered` — `renderPage` produced the body. `bodyHtml` is the rendered\n * page string, `stylesHTML` the rendered `styles`, `docProps`\n * the remaining props to spread onto `<Document>`, and `head`\n * the head nodes returned by `getInitialProps` (forward them to\n * `setDocumentInitialHead()` — do NOT call\n * `callDocumentGetInitialProps()` as well).\n * - `consumed` — `getInitialProps` WAS invoked but no body was produced\n * (it never called `renderPage`, returned no `{ html }`, or\n * threw). Callers must NOT re-invoke `getInitialProps` (that\n * would call it a second time) — render the streaming body,\n * spread `docProps` (possibly empty) onto `<Document>`, and\n * forward `head` to `setDocumentInitialHead()`.\n */\ntype RunDocumentRenderPageResult =\n | { status: \"skipped\" }\n | {\n status: \"rendered\";\n bodyHtml: string;\n stylesHTML: string;\n docProps: Record<string, unknown>;\n head: ReactNode[];\n }\n | { status: \"consumed\"; docProps: Record<string, unknown>; head: ReactNode[] };\n\n/**\n * Run a user `_document.getInitialProps()` with a `ctx.renderPage()` that\n * applies optional `enhanceApp` / `enhanceComponent` wrappers around the page\n * React tree, mirroring Next.js's Pages Router contract.\n *\n * Used by CSS-in-JS libraries (styled-components, emotion) to wrap the\n * App/Component tree so styles can be collected during SSR. Shared between the\n * prod (`pages-page-response.ts`) and dev (`dev-server.ts`) SSR pipelines so\n * the `getInitialProps` + `renderPage` contract lives in one place.\n *\n * `getInitialProps` is invoked at most once here. When this returns `consumed`\n * or `rendered`, callers MUST treat that as the single invocation and must not\n * call `loadUserDocumentInitialProps` (which would invoke it again — and, for a\n * throwing override, surface the error as a 500 rather than the clean fallback\n * this contract guarantees).\n *\n * @see .nextjs-ref/packages/next/src/server/render.tsx (search `renderPage`)\n */\nexport async function runDocumentRenderPage(\n input: DocumentRenderPageInput,\n): Promise<RunDocumentRenderPageResult> {\n const DocCtor = input.DocumentComponent as\n | (ComponentType & {\n getInitialProps?: (ctx: unknown) => Promise<DocumentInitialProps>;\n displayName?: string;\n })\n | null;\n if (!DocCtor || typeof DocCtor.getInitialProps !== \"function\") return { status: \"skipped\" };\n // Identity check (mirrors `loadUserDocumentInitialProps`): if the user did\n // not override `static getInitialProps`, the inherited reference is the\n // shim's stub. Skip the renderPage work so the fast path stays cheap and the\n // caller falls through to the bare Document render.\n if (DocCtor.getInitialProps === BASE_GET_INITIAL_PROPS) return { status: \"skipped\" };\n if (!input.enhancePageElement) return { status: \"skipped\" };\n const enhancePageElement = input.enhancePageElement;\n\n let renderPageCalled = false;\n const renderPage = async (\n opts: RenderPageEnhancers = {},\n ): Promise<{ html: string; head: ReactNode[] }> => {\n renderPageCalled = true;\n const enhancedElement = enhancePageElement(opts);\n // Nonce responsibility lives here so prod and dev produce identical\n // output — callers' `enhancePageElement` must not apply it themselves.\n const wrapped = withScriptNonce(enhancedElement as React.ReactElement, input.scriptNonce);\n const stream = await input.renderToReadableStream(wrapped);\n const html = await readStreamAsText(stream);\n return { html, head: [] };\n };\n\n let docInitialProps: DocumentInitialProps;\n try {\n docInitialProps = await DocCtor.getInitialProps({\n // Minimal `DocumentContext` shim — vinext does not yet thread the full\n // context (req/res/AppTree/locale). Subclasses that just forward to\n // `ctx.renderPage` (the styled-components / emotion pattern) work\n // without those fields.\n renderPage,\n defaultGetInitialProps: async (ctx: { renderPage?: typeof renderPage }) => {\n // Mirrors Next.js's `ctx.defaultGetInitialProps`: wrap App in an\n // identity enhancer so renderPage is still invoked even when a user\n // doesn't pass any enhancers themselves.\n const inner = ctx.renderPage ?? renderPage;\n const result = await inner({\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n enhanceApp: (App) => (props: any) => React.createElement(App, props),\n });\n return { html: result.html, head: result.head ?? [], styles: undefined };\n },\n ...input.context,\n });\n } catch (err) {\n // Falls back cleanly: render the streaming body and a bare Document.\n // `getInitialProps` was already invoked, so the caller must not re-call it.\n console.error(\"[vinext] _document.getInitialProps() threw:\", err);\n return { status: \"consumed\", docProps: {}, head: [] };\n }\n\n // Strip the contract fields the pipeline consumes itself so the rest can be\n // spread onto `<Document>` like Next.js does. `html` is the body; `head`/\n // `styles` are merged into the SSR head. `head` is surfaced back to the\n // caller so it can be folded into the dedupe pipeline via\n // `setDocumentInitialHead()` — `getInitialProps` is only ever invoked once\n // (here), so the standalone `callDocumentGetInitialProps()` path must not\n // run again for the same render.\n const { html: _html, head: rawHead, styles: _styles, ...docProps } = docInitialProps ?? {};\n const head: ReactNode[] = Array.isArray(rawHead) ? (rawHead as ReactNode[]) : [];\n\n // If the user implemented getInitialProps but never invoked renderPage\n // (uncommon — but possible if they only return head/styles), fall back to\n // the streaming render so the body content is produced normally.\n if (!renderPageCalled) return { status: \"consumed\", docProps, head };\n\n if (!docInitialProps || typeof docInitialProps.html !== \"string\") {\n console.error(\n `[vinext] \"${DocCtor.displayName ?? DocCtor.name ?? \"Document\"}.getInitialProps()\" did not return an object with a string \"html\" prop`,\n );\n return { status: \"consumed\", docProps, head };\n }\n\n // Render `styles` returned by `getInitialProps()` (e.g. collected\n // styled-components / emotion <style> tags) to a string ready for the SSR\n // head. Matches Next.js's render.tsx where `styles` flows into the head.\n // Failures are swallowed so a buggy styles element doesn't crash the render.\n let stylesHTML = \"\";\n if (docInitialProps.styles != null) {\n try {\n stylesHTML = await input.renderStylesToString(\n React.createElement(React.Fragment, null, docInitialProps.styles),\n );\n } catch (err) {\n console.error(\"[vinext] Failed to render _document.getInitialProps() styles:\", err);\n }\n }\n\n return { status: \"rendered\", bodyHtml: docInitialProps.html, stylesHTML, docProps, head };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,yBACJA,SAGA;AAEF,eAAsB,6BACpB,mBACyC;CACzC,MAAM,kBACJ,kBAKA;CACF,IAAI,OAAO,oBAAoB,YAAY,OAAO;CAKlD,IAAI,oBAAoB,wBAAwB,OAAO;CAMvD,MAAM,SAAS,MAAM,gBAAgB,EAAE,CAAC;CACxC,OAAO,UAAU,OAAO,WAAW,WAAY,SAAqC;;;;;;;;;;;;;;;;;;;;AA+FtF,eAAsB,sBACpB,OACsC;CACtC,MAAM,UAAU,MAAM;CAMtB,IAAI,CAAC,WAAW,OAAO,QAAQ,oBAAoB,YAAY,OAAO,EAAE,QAAQ,WAAW;CAK3F,IAAI,QAAQ,oBAAoB,wBAAwB,OAAO,EAAE,QAAQ,WAAW;CACpF,IAAI,CAAC,MAAM,oBAAoB,OAAO,EAAE,QAAQ,WAAW;CAC3D,MAAM,qBAAqB,MAAM;CAEjC,IAAI,mBAAmB;CACvB,MAAM,aAAa,OACjB,OAA4B,EAAE,KACmB;EACjD,mBAAmB;EAInB,MAAM,UAAU,gBAHQ,mBAAmB,KAGI,EAAwB,MAAM,YAAY;EAGzF,OAAO;GAAE,MAAA,MADU,iBAAiB,MADf,MAAM,uBAAuB,QAAQ,CACf;GAC5B,MAAM,EAAE;GAAE;;CAG3B,IAAI;CACJ,IAAI;EACF,kBAAkB,MAAM,QAAQ,gBAAgB;GAK9C;GACA,wBAAwB,OAAO,QAA4C;IAKzE,MAAM,SAAS,OADD,IAAI,cAAc,YACL,EAEzB,aAAa,SAAS,UAAe,MAAM,cAAc,KAAK,MAAM,EACrE,CAAC;IACF,OAAO;KAAE,MAAM,OAAO;KAAM,MAAM,OAAO,QAAQ,EAAE;KAAE,QAAQ,KAAA;KAAW;;GAE1E,GAAG,MAAM;GACV,CAAC;UACK,KAAK;EAGZ,QAAQ,MAAM,+CAA+C,IAAI;EACjE,OAAO;GAAE,QAAQ;GAAY,UAAU,EAAE;GAAE,MAAM,EAAE;GAAE;;CAUvD,MAAM,EAAE,MAAM,OAAO,MAAM,SAAS,QAAQ,SAAS,GAAG,aAAa,mBAAmB,EAAE;CAC1F,MAAM,OAAoB,MAAM,QAAQ,QAAQ,GAAI,UAA0B,EAAE;CAKhF,IAAI,CAAC,kBAAkB,OAAO;EAAE,QAAQ;EAAY;EAAU;EAAM;CAEpE,IAAI,CAAC,mBAAmB,OAAO,gBAAgB,SAAS,UAAU;EAChE,QAAQ,MACN,aAAa,QAAQ,eAAe,QAAQ,QAAQ,WAAW,wEAChE;EACD,OAAO;GAAE,QAAQ;GAAY;GAAU;GAAM;;CAO/C,IAAI,aAAa;CACjB,IAAI,gBAAgB,UAAU,MAC5B,IAAI;EACF,aAAa,MAAM,MAAM,qBACvB,MAAM,cAAc,MAAM,UAAU,MAAM,gBAAgB,OAAO,CAClE;UACM,KAAK;EACZ,QAAQ,MAAM,iEAAiE,IAAI;;CAIvF,OAAO;EAAE,QAAQ;EAAY,UAAU,gBAAgB;EAAM;EAAY;EAAU;EAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-i18n.js","names":[],"sources":["../../src/server/pages-i18n.ts"],"sourcesContent":["import type { NextI18nConfig } from \"../config/next-config.js\";\nimport {\n detectDomainLocale,\n normalizeDomainHostname,\n type DomainLocale,\n} from \"../utils/domain-locale.js\";\n\ntype HeaderValue = string | string[] | undefined;\ntype HeaderBag = Headers | Record<string, HeaderValue> | undefined;\n\ntype LocaleRedirectOptions = {\n headers?: HeaderBag;\n nextConfig: {\n basePath?: string;\n i18n?: NextI18nConfig | null;\n trailingSlash?: boolean;\n };\n pathLocale?: string;\n urlParsed: {\n hostname?: string | null;\n pathname: string;\n search?: string;\n };\n};\n\ntype PagesI18nRequestInfo = {\n locale: string;\n url: string;\n hadPrefix: boolean;\n domainLocale?: DomainLocale;\n redirectUrl?: string;\n};\n\nfunction readHeader(headers: HeaderBag, name: string): string | undefined {\n if (!headers) return undefined;\n if (headers instanceof Headers) {\n return headers.get(name) ?? undefined;\n }\n\n // For Record headers, callers must pass lowercase names. Node's\n // IncomingMessage.headers are already lowercased by the HTTP parser.\n const direct = headers[name];\n if (Array.isArray(direct)) return direct.join(\", \");\n return direct;\n}\n\nconst normalizeHostname = normalizeDomainHostname;\nexport { detectDomainLocale };\n\n/**\n * Prepend the default locale prefix to a pathname when i18n is configured and\n * the path does not already carry a locale prefix. Mirrors Next.js's\n * server-side path normalisation in `resolve-routes.ts` (lines ~250-263):\n *\n * if (!initialLocaleResult.detectedLocale && !pathname.startsWith('/_next/')) {\n * parsedUrl.pathname = `/${defaultLocale}${pathname === '/' ? '' : pathname}`\n * }\n *\n * Run this **before** matching against `next.config.js` redirects/rewrites\n * (which are emitted by `applyLocaleToRoutes` in locale-prefixed forms) so\n * that requests arriving without a locale prefix still match those rules.\n *\n * Skips internal paths that Next.js leaves alone:\n * - `/_next/*` (build assets, prerender manifests, image optimisation)\n * - `/__vinext/*` (vinext-internal endpoints)\n *\n * Returns the input unchanged when i18n is not configured or when the path\n * already starts with one of the configured locales. The host-based default\n * locale (i18n.domains[].defaultLocale) is preferred over the global default\n * when supplied, matching Next.js's `domainLocale.defaultLocale` branch.\n *\n * Item 4 of issue #1336: without this normalisation, requests like\n * `/to-sv` (default locale = en) against a rule `source: '/:locale/to-sv'`\n * with `locale: false` do not match because there is no segment for\n * `:locale`. After normalisation the request looks like `/en/to-sv` and\n * the rule matches with `:locale=en`.\n *\n * Ported from Next.js: packages/next/src/server/lib/router-utils/resolve-routes.ts\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/router-utils/resolve-routes.ts\n */\nexport function normalizeDefaultLocalePathname(\n pathname: string,\n i18n: NextI18nConfig | null | undefined,\n options: { hostname?: string | null } = {},\n): string {\n if (!i18n) return pathname;\n // Don't touch internal paths.\n if (pathname.startsWith(\"/_next/\") || pathname.startsWith(\"/__vinext/\")) return pathname;\n // If the path already starts with a known locale, leave it alone.\n const parts = pathname.split(\"/\", 3);\n // parts[0] is the empty string before the leading \"/\", parts[1] is the first segment.\n if (parts[1] && i18n.locales.includes(parts[1])) return pathname;\n\n // Pick the default locale: prefer the domain-mapped one when host matches.\n const domainLocale = detectDomainLocale(i18n.domains, options.hostname ?? undefined);\n const defaultLocale = domainLocale?.defaultLocale ?? i18n.defaultLocale;\n\n if (pathname === \"/\") return `/${defaultLocale}`;\n return `/${defaultLocale}${pathname}`;\n}\n\n/**\n * Extract locale prefix from a URL path.\n * e.g. /fr/about -> { locale: \"fr\", url: \"/about\", hadPrefix: true }\n * /about -> { locale: defaultLocale, url: \"/about\", hadPrefix: false }\n */\nexport function extractLocaleFromUrl(\n url: string,\n i18nConfig: NextI18nConfig,\n defaultLocale = i18nConfig.defaultLocale,\n): { locale: string; url: string; hadPrefix: boolean } {\n const pathname = url.split(\"?\")[0];\n const parts = pathname.split(\"/\").filter(Boolean);\n const query = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n\n if (parts.length > 0 && i18nConfig.locales.includes(parts[0])) {\n const locale = parts[0];\n const rest = \"/\" + parts.slice(1).join(\"/\");\n return { locale, url: (rest || \"/\") + query, hadPrefix: true };\n }\n\n return { locale: defaultLocale, url, hadPrefix: false };\n}\n\n/**\n * Strip a leading i18n locale segment from a URL so the result can be used for\n * API route matching. Mirrors Next.js's base-server behaviour for Pages\n * Router API routes: `normalizeLocalePath(pathname, i18n.locales).pathname`\n * runs before the `/api/*` check so `/fr/api/ok` resolves to the\n * `pages/api/ok` handler instead of 404'ing.\n *\n * Returns the original URL untouched when:\n * - `i18nConfig` is null/undefined (no i18n configured)\n * - the URL does not start with a configured locale\n *\n * The query string is preserved verbatim — only the path segment is stripped.\n *\n * Reference: packages/next/src/shared/lib/i18n/normalize-locale-path.ts.\n */\nexport function stripI18nLocaleForApiRoute(\n url: string,\n i18nConfig: NextI18nConfig | null | undefined,\n): string {\n if (!i18nConfig) return url;\n const { url: stripped, hadPrefix } = extractLocaleFromUrl(url, i18nConfig);\n return hadPrefix ? stripped : url;\n}\n\n/**\n * Detect the preferred locale from the Accept-Language header.\n * Returns the best matching locale or null.\n */\nexport function detectLocaleFromAcceptLanguage(\n acceptLang: string | null | undefined,\n i18nConfig: NextI18nConfig,\n): string | null {\n if (!acceptLang) return null;\n\n const langs = acceptLang\n .split(\",\")\n .map((part) => {\n const [lang, qPart] = part.trim().split(\";\");\n const q = qPart ? parseFloat(qPart.replace(\"q=\", \"\")) : 1;\n return { lang: lang.trim().toLowerCase(), q };\n })\n .sort((a, b) => b.q - a.q);\n\n for (const { lang } of langs) {\n const exactMatch = i18nConfig.locales.find((locale) => locale.toLowerCase() === lang);\n if (exactMatch) return exactMatch;\n\n const prefix = lang.split(\"-\")[0];\n const prefixMatch = i18nConfig.locales.find((locale) => {\n const lowered = locale.toLowerCase();\n return lowered === prefix || lowered.startsWith(prefix + \"-\");\n });\n if (prefixMatch) return prefixMatch;\n }\n\n return null;\n}\n\n/**\n * Parse the NEXT_LOCALE cookie.\n * Returns the cookie value if it matches a configured locale, otherwise null.\n */\nexport function parseCookieLocaleFromHeader(\n cookieHeader: string | null | undefined,\n i18nConfig: NextI18nConfig,\n): string | null {\n if (!cookieHeader) return null;\n\n const match = cookieHeader.match(/(?:^|;\\s*)NEXT_LOCALE=([^;]*)/);\n if (!match) return null;\n\n let value: string;\n try {\n value = decodeURIComponent(match[1].trim());\n } catch {\n return null;\n }\n\n if (i18nConfig.locales.includes(value)) return value;\n return null;\n}\n\nfunction formatLocalizedRootPath(\n locale: string,\n defaultLocale: string,\n basePath = \"\",\n trailingSlash = false,\n search = \"\",\n): string | undefined {\n if (locale.toLowerCase() === defaultLocale.toLowerCase()) return undefined;\n const rootPath = `${basePath}/${locale}${trailingSlash ? \"/\" : \"\"}`;\n return `${rootPath.replace(/\\/{2,}/g, \"/\")}${search}`;\n}\n\nexport function getLocaleRedirect({\n headers,\n nextConfig,\n pathLocale,\n urlParsed,\n}: LocaleRedirectOptions): string | undefined {\n const i18n = nextConfig.i18n;\n // Next.js treats localeDetection as the global auto-redirect switch, so\n // disabling it also disables root domain-locale redirects, including\n // cross-domain redirects driven by the current host or Accept-Language.\n if (!i18n || i18n.localeDetection === false || urlParsed.pathname !== \"/\") return undefined;\n\n const domainLocale = detectDomainLocale(i18n.domains, urlParsed.hostname ?? undefined);\n const defaultLocale = domainLocale?.defaultLocale || i18n.defaultLocale;\n const preferredLocale =\n detectLocaleFromAcceptLanguage(readHeader(headers, \"accept-language\"), i18n) ?? undefined;\n const detectedLocale =\n pathLocale ||\n domainLocale?.defaultLocale ||\n (parseCookieLocaleFromHeader(readHeader(headers, \"cookie\"), i18n) ?? undefined) ||\n preferredLocale ||\n i18n.defaultLocale;\n const search = urlParsed.search ?? \"\";\n\n const preferredDomain = detectDomainLocale(i18n.domains, undefined, preferredLocale);\n if (domainLocale && preferredDomain) {\n const sameDomain =\n normalizeHostname(domainLocale.domain) === normalizeHostname(preferredDomain.domain);\n const sameLocale =\n preferredLocale !== undefined &&\n preferredDomain.defaultLocale.toLowerCase() === preferredLocale.toLowerCase();\n\n if (!sameDomain || !sameLocale) {\n // sameDomain && !sameLocale yields a locale-prefixed redirect on the same\n // host (for example /nl-BE). This matches Next.js and doesn't loop because\n // the next request is prefixed and therefore skips getLocaleRedirect().\n const scheme = `http${preferredDomain.http ? \"\" : \"s\"}`;\n const localePath = sameLocale || preferredLocale === undefined ? \"\" : `/${preferredLocale}`;\n const basePath = nextConfig.basePath ?? \"\";\n const rootPath = `${basePath}${localePath}${nextConfig.trailingSlash ? \"/\" : \"\"}` || \"/\";\n const normalizedPath = rootPath.startsWith(\"/\") ? rootPath : `/${rootPath}`;\n return `${scheme}://${preferredDomain.domain}${normalizedPath}${search}`;\n }\n }\n\n return formatLocalizedRootPath(\n detectedLocale,\n defaultLocale,\n nextConfig.basePath,\n nextConfig.trailingSlash,\n search,\n );\n}\n\nexport function resolvePagesI18nRequest(\n url: string,\n i18nConfig: NextI18nConfig,\n headers?: HeaderBag,\n hostname?: string | null,\n basePath = \"\",\n trailingSlash = false,\n): PagesI18nRequestInfo {\n const domainLocale = detectDomainLocale(i18nConfig.domains, hostname ?? undefined);\n const defaultLocale = domainLocale?.defaultLocale || i18nConfig.defaultLocale;\n const localeInfo = extractLocaleFromUrl(url, i18nConfig, defaultLocale);\n\n let redirectUrl: string | undefined;\n if (!localeInfo.hadPrefix) {\n redirectUrl = getLocaleRedirect({\n headers,\n nextConfig: {\n basePath,\n i18n: i18nConfig,\n trailingSlash,\n },\n urlParsed: {\n hostname,\n pathname: localeInfo.url.split(\"?\")[0] || \"/\",\n search: localeInfo.url.includes(\"?\")\n ? localeInfo.url.slice(localeInfo.url.indexOf(\"?\"))\n : \"\",\n },\n });\n }\n\n return {\n ...localeInfo,\n domainLocale,\n redirectUrl,\n };\n}\n"],"mappings":";;AAiCA,SAAS,WAAW,SAAoB,MAAkC;CACxE,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,IAAI,mBAAmB,SACrB,OAAO,QAAQ,IAAI,KAAK,IAAI,KAAA;CAK9B,MAAM,SAAS,QAAQ;CACvB,IAAI,MAAM,QAAQ,OAAO,EAAE,OAAO,OAAO,KAAK,KAAK;CACnD,OAAO;;AAGT,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkC1B,SAAgB,+BACd,UACA,MACA,UAAwC,EAAE,EAClC;CACR,IAAI,CAAC,MAAM,OAAO;CAElB,IAAI,S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L,GAAG;EACH;EACA;EACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-media-type.js","names":[],"sources":["../../src/server/pages-media-type.ts"],"sourcesContent":["/**\n * Shared media-type helpers and body-parse error for Pages API routes.\n *\n * Used by both api-handler.ts (Pages Router dev/prod with Node.js req/res) and\n * pages-node-compat.ts (Pages Router fetch-based facade for Cloudflare Workers).\n */\n\nexport class PagesBodyParseError extends Error {\n constructor(\n message: string,\n readonly statusCode: number,\n ) {\n super(message);\n this.name = \"PagesBodyParseError\";\n }\n}\n\nexport function getMediaType(contentType: string | null | undefined): string {\n const [type] = (contentType ?? \"text/plain\").split(\";\");\n return type?.trim().toLowerCase() || \"text/plain\";\n}\n\nexport function isJsonMediaType(mediaType: string): boolean {\n return mediaType === \"application/json\" || mediaType === \"application/ld+json\";\n}\n"],"mappings":";;;;;;;AAOA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YACE,SACA,YACA;EACA,MAAM,QAAQ;EAFL,KAAA,aAAA;EAGT,KAAK,OAAO;;;AAIhB,SAAgB,aAAa,aAAgD;CAC3E,MAAM,CAAC,SAAS,eAAe,cAAc,MAAM,IAAI;CACvD,OAAO,MAAM,MAAM,CAAC,aAAa,IAAI;;AAGvC,SAAgB,gBAAgB,WAA4B;CAC1D,OAAO,cAAc,sBAAsB,cAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pages-node-compat.js","names":["decodeQueryString"],"sources":["../../src/server/pages-node-compat.ts"],"sourcesContent":["import { decode as decodeQueryString } from \"node:querystring\";\nimport { parseCookies } from \"../config/config-matchers.js\";\nimport { readStreamAsTextWithLimit } from \"../utils/text-stream.js\";\nimport { DEFAULT_PAGES_API_BODY_SIZE_LIMIT } from \"./pages-body-parser-config.js\";\nimport { PagesBodyParseError, getMediaType, isJsonMediaType } from \"./pages-media-type.js\";\n\nconst MAX_PAGES_API_BODY_SIZE = DEFAULT_PAGES_API_BODY_SIZE_LIMIT;\n\n/**\n * @deprecated Use PagesBodyParseError from pages-media-type.ts instead.\n * Kept for backwards compatibility.\n */\nexport { PagesBodyParseError as PagesApiBodyParseError };\n\nexport type PagesRequestQuery = Record<string, string | string[]>;\n\nexport type PagesReqResRequest = {\n method: string;\n url: string;\n headers: Record<string, string>;\n query: PagesRequestQuery;\n body: unknown;\n cookies: Record<string, string>;\n};\n\nexport type PagesReqResHeaders = {\n [key: string]: string | number | boolean | string[];\n};\n\nexport type PagesReqResResponse = {\n statusCode: number;\n readonly headersSent: boolean;\n writeHead: (code: number, headers?: PagesReqResHeaders) => PagesReqResResponse;\n setHeader: (name: string, value: string | number | boolean | string[]) => PagesReqResResponse;\n getHeader: (name: string) => string | number | boolean | string[] | undefined;\n end: (data?: BodyInit | null) => void;\n status: (code: number) => PagesReqResResponse;\n json: (data: unknown) => void;\n send: (data: unknown) => void;\n redirect: (statusOrUrl: number | string, url?: string) => void;\n getHeaders: () => PagesReqResHeaders;\n};\n\ntype CreatePagesReqResOptions = {\n body: unknown;\n query: PagesRequestQuery;\n request: Request;\n url: string;\n};\n\ntype CreatePagesReqResResult = {\n req: PagesReqResRequest;\n res: PagesReqResResponse;\n responsePromise: Promise<Response>;\n};\n\nasync function readPagesRequestBodyWithLimit(request: Request, maxBytes: number): Promise<string> {\n if (!request.body) {\n return \"\";\n }\n\n return readStreamAsTextWithLimit(request.body, maxBytes, () => {\n throw new PagesBodyParseError(\"Request body too large\", 413);\n });\n}\n\n/**\n * Read and parse a Pages Router API request body for the Workers/prod path.\n *\n * `maxBytes` defaults to the 1 MB Next.js default but may be overridden by\n * `export const config = { api: { bodyParser: { sizeLimit: '4mb' } } }` on\n * the route module. Handlers that opt out entirely (`bodyParser: false`)\n * MUST skip this function so the body stream stays intact for user code.\n *\n * @see https://nextjs.org/docs/pages/building-your-application/routing/api-routes#custom-config\n */\nexport async function parsePagesApiBody(\n request: Request,\n maxBytes = MAX_PAGES_API_BODY_SIZE,\n): Promise<unknown> {\n const contentLength = Number.parseInt(request.headers.get(\"content-length\") || \"0\", 10);\n if (contentLength > maxBytes) {\n throw new PagesBodyParseError(\"Request body too large\", 413);\n }\n\n let rawBody = \"\";\n try {\n rawBody = await readPagesRequestBodyWithLimit(request, maxBytes);\n } catch (err) {\n if (err instanceof PagesBodyParseError) {\n throw err;\n }\n throw new PagesBodyParseError(\"Request body too large\", 413);\n }\n\n const mediaType = getMediaType(request.headers.get(\"content-type\"));\n if (!rawBody) {\n return isJsonMediaType(mediaType)\n ? {}\n : mediaType === \"application/x-www-form-urlencoded\"\n ? decodeQueryString(rawBody)\n : undefined;\n }\n\n if (isJsonMediaType(mediaType)) {\n try {\n return JSON.parse(rawBody);\n } catch {\n throw new PagesBodyParseError(\"Invalid JSON\", 400);\n }\n }\n\n if (mediaType === \"application/x-www-form-urlencoded\") {\n return decodeQueryString(rawBody);\n }\n\n return rawBody;\n}\n\nexport function createPagesReqRes(options: CreatePagesReqResOptions): CreatePagesReqResResult {\n const headersObj: Record<string, string> = {};\n for (const [key, value] of options.request.headers) {\n headersObj[key.toLowerCase()] = value;\n }\n\n const req: PagesReqResRequest = {\n method: options.request.method,\n url: options.url,\n headers: headersObj,\n query: options.query,\n body: options.body,\n cookies: parseCookies(options.request.headers.get(\"cookie\")),\n };\n\n let resStatusCode = 200;\n const resHeaders: Record<string, string | number | boolean> = {};\n const setCookieHeaders: string[] = [];\n let resBody: BodyInit | null = null;\n let ended = false;\n let resolveResponse!: (value: Response) => void;\n const responsePromise = new Promise<Response>((resolve) => {\n resolveResponse = resolve;\n });\n\n const res: PagesReqResResponse = {\n get statusCode() {\n return resStatusCode;\n },\n set statusCode(code) {\n resStatusCode = code;\n },\n get headersSent() {\n return ended;\n },\n writeHead(code, headers) {\n resStatusCode = code;\n if (headers) {\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === \"set-cookie\") {\n if (Array.isArray(value)) {\n setCookieHeaders.push(...value.map(String));\n } else {\n setCookieHeaders.push(String(value));\n }\n } else {\n resHeaders[key.toLowerCase()] = Array.isArray(value) ? value.join(\", \") : value;\n }\n }\n }\n return res;\n },\n setHeader(name, value) {\n if (name.toLowerCase() === \"set-cookie\") {\n // Node.js res.setHeader() replaces the existing value entirely.\n setCookieHeaders.length = 0;\n if (Array.isArray(value)) {\n setCookieHeaders.push(...value.map(String));\n } else {\n setCookieHeaders.push(String(value));\n }\n } else {\n resHeaders[name.toLowerCase()] = Array.isArray(value) ? value.join(\", \") : value;\n }\n return res;\n },\n getHeader(name) {\n if (name.toLowerCase() === \"set-cookie\") {\n return setCookieHeaders.length > 0 ? setCookieHeaders : undefined;\n }\n return resHeaders[name.toLowerCase()];\n },\n end(data) {\n if (ended) {\n return;\n }\n ended = true;\n if (data !== undefined && data !== null) {\n resBody = data;\n }\n const headers = new Headers();\n for (const [key, value] of Object.entries(resHeaders)) {\n headers.set(key, String(value));\n }\n for (const cookie of setCookieHeaders) {\n headers.append(\"set-cookie\", cookie);\n }\n resolveResponse(new Response(resBody, { status: resStatusCode, headers }));\n },\n status(code) {\n resStatusCode = code;\n return res;\n },\n json(data) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n },\n send(data) {\n if (Buffer.isBuffer(data)) {\n if (!resHeaders[\"content-type\"]) {\n resHeaders[\"content-type\"] = \"application/octet-stream\";\n }\n resHeaders[\"content-length\"] = String(data.length);\n res.end(new Uint8Array(data));\n return;\n }\n\n if (typeof data === \"object\" && data !== null) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n return;\n }\n\n if (!resHeaders[\"content-type\"]) {\n resHeaders[\"content-type\"] = \"text/plain\";\n }\n res.end(String(data));\n },\n redirect(statusOrUrl, url) {\n if (typeof statusOrUrl === \"string\") {\n res.writeHead(307, { Location: statusOrUrl });\n } else {\n res.writeHead(statusOrUrl, { Location: url ?? \"\" });\n }\n res.end();\n },\n getHeaders() {\n const headers: PagesReqResHeaders = { ...resHeaders };\n if (setCookieHeaders.length > 0) {\n headers[\"set-cookie\"] = setCookieHeaders;\n }\n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