vinext 0.0.52 → 0.0.54

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 (330) hide show
  1. package/README.md +1 -1
  2. package/dist/build/clean-output.d.ts +14 -0
  3. package/dist/build/clean-output.js +36 -0
  4. package/dist/build/clean-output.js.map +1 -0
  5. package/dist/build/inline-css.d.ts +7 -0
  6. package/dist/build/inline-css.js +50 -0
  7. package/dist/build/inline-css.js.map +1 -0
  8. package/dist/build/prerender.d.ts +6 -2
  9. package/dist/build/prerender.js +51 -12
  10. package/dist/build/prerender.js.map +1 -1
  11. package/dist/build/run-prerender.js +10 -1
  12. package/dist/build/run-prerender.js.map +1 -1
  13. package/dist/build/static-export.d.ts +5 -0
  14. package/dist/build/static-export.js +8 -3
  15. package/dist/build/static-export.js.map +1 -1
  16. package/dist/check.js +4 -0
  17. package/dist/check.js.map +1 -1
  18. package/dist/cli.js +19 -4
  19. package/dist/cli.js.map +1 -1
  20. package/dist/client/instrumentation-client-inject.d.ts +34 -0
  21. package/dist/client/instrumentation-client-inject.js +57 -0
  22. package/dist/client/instrumentation-client-inject.js.map +1 -0
  23. package/dist/client/navigation-runtime.d.ts +16 -2
  24. package/dist/client/navigation-runtime.js +16 -1
  25. package/dist/client/navigation-runtime.js.map +1 -1
  26. package/dist/client/vinext-next-data.d.ts +2 -1
  27. package/dist/client/vinext-next-data.js.map +1 -1
  28. package/dist/client/window-next.d.ts +17 -2
  29. package/dist/client/window-next.js.map +1 -1
  30. package/dist/cloudflare/tpr.js +1 -1
  31. package/dist/cloudflare/tpr.js.map +1 -1
  32. package/dist/config/config-matchers.js +2 -1
  33. package/dist/config/config-matchers.js.map +1 -1
  34. package/dist/config/next-config.d.ts +95 -4
  35. package/dist/config/next-config.js +173 -14
  36. package/dist/config/next-config.js.map +1 -1
  37. package/dist/deploy.js +42 -7
  38. package/dist/deploy.js.map +1 -1
  39. package/dist/entries/app-browser-entry.d.ts +11 -1
  40. package/dist/entries/app-browser-entry.js +16 -6
  41. package/dist/entries/app-browser-entry.js.map +1 -1
  42. package/dist/entries/app-rsc-entry.d.ts +12 -3
  43. package/dist/entries/app-rsc-entry.js +41 -8
  44. package/dist/entries/app-rsc-entry.js.map +1 -1
  45. package/dist/entries/app-rsc-manifest.d.ts +21 -1
  46. package/dist/entries/app-rsc-manifest.js +6 -4
  47. package/dist/entries/app-rsc-manifest.js.map +1 -1
  48. package/dist/entries/pages-client-entry.d.ts +4 -1
  49. package/dist/entries/pages-client-entry.js +40 -3
  50. package/dist/entries/pages-client-entry.js.map +1 -1
  51. package/dist/entries/pages-server-entry.js +292 -34
  52. package/dist/entries/pages-server-entry.js.map +1 -1
  53. package/dist/entries/runtime-entry-module.d.ts +1 -10
  54. package/dist/entries/runtime-entry-module.js +2 -12
  55. package/dist/entries/runtime-entry-module.js.map +1 -1
  56. package/dist/index.js +91 -10
  57. package/dist/index.js.map +1 -1
  58. package/dist/plugins/fonts.js +25 -2
  59. package/dist/plugins/fonts.js.map +1 -1
  60. package/dist/plugins/remove-console.d.ts +16 -0
  61. package/dist/plugins/remove-console.js +176 -0
  62. package/dist/plugins/remove-console.js.map +1 -0
  63. package/dist/routing/app-route-graph.d.ts +24 -1
  64. package/dist/routing/app-route-graph.js +52 -4
  65. package/dist/routing/app-route-graph.js.map +1 -1
  66. package/dist/routing/app-router.d.ts +2 -2
  67. package/dist/routing/app-router.js +2 -2
  68. package/dist/routing/app-router.js.map +1 -1
  69. package/dist/routing/file-matcher.d.ts +21 -1
  70. package/dist/routing/file-matcher.js +39 -1
  71. package/dist/routing/file-matcher.js.map +1 -1
  72. package/dist/routing/pages-router.d.ts +1 -1
  73. package/dist/routing/pages-router.js +10 -3
  74. package/dist/routing/pages-router.js.map +1 -1
  75. package/dist/routing/route-trie.js +13 -18
  76. package/dist/routing/route-trie.js.map +1 -1
  77. package/dist/routing/utils.d.ts +11 -1
  78. package/dist/routing/utils.js +15 -1
  79. package/dist/routing/utils.js.map +1 -1
  80. package/dist/server/api-handler.js +19 -10
  81. package/dist/server/api-handler.js.map +1 -1
  82. package/dist/server/app-browser-action-result.d.ts +16 -1
  83. package/dist/server/app-browser-action-result.js +15 -1
  84. package/dist/server/app-browser-action-result.js.map +1 -1
  85. package/dist/server/app-browser-entry.js +47 -28
  86. package/dist/server/app-browser-entry.js.map +1 -1
  87. package/dist/server/app-browser-navigation-controller.d.ts +2 -0
  88. package/dist/server/app-browser-navigation-controller.js +4 -0
  89. package/dist/server/app-browser-navigation-controller.js.map +1 -1
  90. package/dist/server/app-elements-wire.d.ts +13 -4
  91. package/dist/server/app-elements-wire.js +10 -1
  92. package/dist/server/app-elements-wire.js.map +1 -1
  93. package/dist/server/app-elements.d.ts +2 -2
  94. package/dist/server/app-elements.js +2 -2
  95. package/dist/server/app-elements.js.map +1 -1
  96. package/dist/server/app-fallback-renderer.d.ts +27 -8
  97. package/dist/server/app-fallback-renderer.js +19 -8
  98. package/dist/server/app-fallback-renderer.js.map +1 -1
  99. package/dist/server/app-history-state.js +6 -2
  100. package/dist/server/app-history-state.js.map +1 -1
  101. package/dist/server/app-inline-css-client.d.ts +7 -0
  102. package/dist/server/app-inline-css-client.js +37 -0
  103. package/dist/server/app-inline-css-client.js.map +1 -0
  104. package/dist/server/app-interception-context-header.d.ts +33 -0
  105. package/dist/server/app-interception-context-header.js +44 -0
  106. package/dist/server/app-interception-context-header.js.map +1 -0
  107. package/dist/server/app-mounted-slots-header.d.ts +19 -0
  108. package/dist/server/app-mounted-slots-header.js +40 -1
  109. package/dist/server/app-mounted-slots-header.js.map +1 -1
  110. package/dist/server/app-optimistic-routing.js +26 -18
  111. package/dist/server/app-optimistic-routing.js.map +1 -1
  112. package/dist/server/app-page-boundary-render.d.ts +1 -0
  113. package/dist/server/app-page-boundary-render.js +2 -0
  114. package/dist/server/app-page-boundary-render.js.map +1 -1
  115. package/dist/server/app-page-boundary.d.ts +22 -1
  116. package/dist/server/app-page-boundary.js +30 -3
  117. package/dist/server/app-page-boundary.js.map +1 -1
  118. package/dist/server/app-page-cache.d.ts +9 -3
  119. package/dist/server/app-page-cache.js +14 -8
  120. package/dist/server/app-page-cache.js.map +1 -1
  121. package/dist/server/app-page-dispatch.d.ts +13 -1
  122. package/dist/server/app-page-dispatch.js +136 -82
  123. package/dist/server/app-page-dispatch.js.map +1 -1
  124. package/dist/server/app-page-element-builder.d.ts +2 -1
  125. package/dist/server/app-page-element-builder.js +17 -30
  126. package/dist/server/app-page-element-builder.js.map +1 -1
  127. package/dist/server/app-page-execution.d.ts +1 -0
  128. package/dist/server/app-page-execution.js +2 -0
  129. package/dist/server/app-page-execution.js.map +1 -1
  130. package/dist/server/app-page-head.d.ts +1 -0
  131. package/dist/server/app-page-head.js +8 -0
  132. package/dist/server/app-page-head.js.map +1 -1
  133. package/dist/server/app-page-render-identity.d.ts +22 -0
  134. package/dist/server/app-page-render-identity.js +42 -0
  135. package/dist/server/app-page-render-identity.js.map +1 -0
  136. package/dist/server/app-page-render-observation.js +1 -1
  137. package/dist/server/app-page-render.d.ts +9 -1
  138. package/dist/server/app-page-render.js +8 -2
  139. package/dist/server/app-page-render.js.map +1 -1
  140. package/dist/server/app-page-request.d.ts +6 -3
  141. package/dist/server/app-page-request.js +5 -2
  142. package/dist/server/app-page-request.js.map +1 -1
  143. package/dist/server/app-page-response.d.ts +11 -1
  144. package/dist/server/app-page-response.js +16 -4
  145. package/dist/server/app-page-response.js.map +1 -1
  146. package/dist/server/app-page-route-wiring.d.ts +16 -0
  147. package/dist/server/app-page-route-wiring.js +25 -10
  148. package/dist/server/app-page-route-wiring.js.map +1 -1
  149. package/dist/server/app-page-stream.d.ts +12 -0
  150. package/dist/server/app-page-stream.js +3 -0
  151. package/dist/server/app-page-stream.js.map +1 -1
  152. package/dist/server/app-route-handler-dispatch.d.ts +1 -0
  153. package/dist/server/app-route-handler-dispatch.js +3 -0
  154. package/dist/server/app-route-handler-dispatch.js.map +1 -1
  155. package/dist/server/app-route-handler-execution.d.ts +1 -0
  156. package/dist/server/app-route-handler-execution.js +1 -0
  157. package/dist/server/app-route-handler-execution.js.map +1 -1
  158. package/dist/server/app-route-handler-response.js +38 -6
  159. package/dist/server/app-route-handler-response.js.map +1 -1
  160. package/dist/server/app-rsc-handler.d.ts +16 -3
  161. package/dist/server/app-rsc-handler.js +60 -11
  162. package/dist/server/app-rsc-handler.js.map +1 -1
  163. package/dist/server/app-rsc-request-normalization.d.ts +2 -1
  164. package/dist/server/app-rsc-request-normalization.js +6 -4
  165. package/dist/server/app-rsc-request-normalization.js.map +1 -1
  166. package/dist/server/app-segment-config.d.ts +4 -1
  167. package/dist/server/app-segment-config.js +6 -1
  168. package/dist/server/app-segment-config.js.map +1 -1
  169. package/dist/server/app-server-action-execution.d.ts +22 -3
  170. package/dist/server/app-server-action-execution.js +46 -7
  171. package/dist/server/app-server-action-execution.js.map +1 -1
  172. package/dist/server/app-ssr-entry.d.ts +6 -0
  173. package/dist/server/app-ssr-entry.js +57 -6
  174. package/dist/server/app-ssr-entry.js.map +1 -1
  175. package/dist/server/app-ssr-error-meta.js +3 -3
  176. package/dist/server/app-ssr-error-meta.js.map +1 -1
  177. package/dist/server/app-ssr-stream.d.ts +25 -1
  178. package/dist/server/app-ssr-stream.js +237 -19
  179. package/dist/server/app-ssr-stream.js.map +1 -1
  180. package/dist/server/app-static-generation.d.ts +1 -0
  181. package/dist/server/app-static-generation.js +2 -1
  182. package/dist/server/app-static-generation.js.map +1 -1
  183. package/dist/server/client-trace-metadata.d.ts +31 -0
  184. package/dist/server/client-trace-metadata.js +83 -0
  185. package/dist/server/client-trace-metadata.js.map +1 -0
  186. package/dist/server/cookie-utils.d.ts +13 -0
  187. package/dist/server/cookie-utils.js +20 -0
  188. package/dist/server/cookie-utils.js.map +1 -0
  189. package/dist/server/default-not-found-module.d.ts +20 -0
  190. package/dist/server/default-not-found-module.js +20 -0
  191. package/dist/server/default-not-found-module.js.map +1 -0
  192. package/dist/server/dev-server.d.ts +8 -1
  193. package/dist/server/dev-server.js +56 -11
  194. package/dist/server/dev-server.js.map +1 -1
  195. package/dist/server/headers.d.ts +5 -1
  196. package/dist/server/headers.js +5 -1
  197. package/dist/server/headers.js.map +1 -1
  198. package/dist/server/html.d.ts +2 -1
  199. package/dist/server/html.js +6 -1
  200. package/dist/server/html.js.map +1 -1
  201. package/dist/server/image-optimization.d.ts +13 -4
  202. package/dist/server/image-optimization.js +15 -4
  203. package/dist/server/image-optimization.js.map +1 -1
  204. package/dist/server/isr-cache.d.ts +7 -5
  205. package/dist/server/isr-cache.js +17 -6
  206. package/dist/server/isr-cache.js.map +1 -1
  207. package/dist/server/middleware-runtime.js +1 -2
  208. package/dist/server/middleware-runtime.js.map +1 -1
  209. package/dist/server/middleware.js +1 -1
  210. package/dist/server/middleware.js.map +1 -1
  211. package/dist/server/pages-api-route.d.ts +18 -0
  212. package/dist/server/pages-api-route.js +3 -1
  213. package/dist/server/pages-api-route.js.map +1 -1
  214. package/dist/server/pages-body-parser-config.d.ts +60 -0
  215. package/dist/server/pages-body-parser-config.js +79 -0
  216. package/dist/server/pages-body-parser-config.js.map +1 -0
  217. package/dist/server/pages-data-route.js +1 -0
  218. package/dist/server/pages-data-route.js.map +1 -1
  219. package/dist/server/pages-default-404.d.ts +31 -0
  220. package/dist/server/pages-default-404.js +40 -0
  221. package/dist/server/pages-default-404.js.map +1 -0
  222. package/dist/server/pages-document-initial-props.d.ts +7 -0
  223. package/dist/server/pages-document-initial-props.js +14 -0
  224. package/dist/server/pages-document-initial-props.js.map +1 -0
  225. package/dist/server/pages-node-compat.d.ts +10 -0
  226. package/dist/server/pages-node-compat.js +12 -1
  227. package/dist/server/pages-node-compat.js.map +1 -1
  228. package/dist/server/pages-page-data.d.ts +40 -0
  229. package/dist/server/pages-page-data.js +19 -14
  230. package/dist/server/pages-page-data.js.map +1 -1
  231. package/dist/server/pages-page-method.d.ts +48 -0
  232. package/dist/server/pages-page-method.js +19 -0
  233. package/dist/server/pages-page-method.js.map +1 -0
  234. package/dist/server/pages-page-response.d.ts +8 -0
  235. package/dist/server/pages-page-response.js +21 -11
  236. package/dist/server/pages-page-response.js.map +1 -1
  237. package/dist/server/pages-serializable-props.d.ts +25 -0
  238. package/dist/server/pages-serializable-props.js +69 -0
  239. package/dist/server/pages-serializable-props.js.map +1 -0
  240. package/dist/server/prerender-route-params.d.ts +14 -0
  241. package/dist/server/prerender-route-params.js +94 -0
  242. package/dist/server/prerender-route-params.js.map +1 -0
  243. package/dist/server/prod-server.d.ts +3 -23
  244. package/dist/server/prod-server.js +43 -57
  245. package/dist/server/prod-server.js.map +1 -1
  246. package/dist/server/proxy-trust.d.ts +41 -0
  247. package/dist/server/proxy-trust.js +70 -0
  248. package/dist/server/proxy-trust.js.map +1 -0
  249. package/dist/server/request-pipeline.d.ts +3 -3
  250. package/dist/server/request-pipeline.js +5 -4
  251. package/dist/server/request-pipeline.js.map +1 -1
  252. package/dist/server/seed-cache.js +12 -6
  253. package/dist/server/seed-cache.js.map +1 -1
  254. package/dist/server/server-action-not-found.js +3 -2
  255. package/dist/server/server-action-not-found.js.map +1 -1
  256. package/dist/server/static-file-cache.js +2 -1
  257. package/dist/server/static-file-cache.js.map +1 -1
  258. package/dist/server/streaming-metadata.d.ts +5 -0
  259. package/dist/server/streaming-metadata.js +10 -0
  260. package/dist/server/streaming-metadata.js.map +1 -0
  261. package/dist/shims/app-router-scroll-state.d.ts +14 -0
  262. package/dist/shims/app-router-scroll-state.js +51 -0
  263. package/dist/shims/app-router-scroll-state.js.map +1 -0
  264. package/dist/shims/app-router-scroll.d.ts +28 -0
  265. package/dist/shims/app-router-scroll.js +115 -0
  266. package/dist/shims/app-router-scroll.js.map +1 -0
  267. package/dist/shims/before-interactive-context.d.ts +30 -0
  268. package/dist/shims/before-interactive-context.js +10 -0
  269. package/dist/shims/before-interactive-context.js.map +1 -0
  270. package/dist/shims/cache-runtime.d.ts +1 -1
  271. package/dist/shims/cache-runtime.js +14 -1
  272. package/dist/shims/cache-runtime.js.map +1 -1
  273. package/dist/shims/cache.d.ts +6 -0
  274. package/dist/shims/cache.js +7 -0
  275. package/dist/shims/cache.js.map +1 -1
  276. package/dist/shims/default-not-found.d.ts +12 -0
  277. package/dist/shims/default-not-found.js +61 -0
  278. package/dist/shims/default-not-found.js.map +1 -0
  279. package/dist/shims/error.js +3 -0
  280. package/dist/shims/error.js.map +1 -1
  281. package/dist/shims/font-local.d.ts +5 -0
  282. package/dist/shims/font-local.js +6 -2
  283. package/dist/shims/font-local.js.map +1 -1
  284. package/dist/shims/head.js +4 -4
  285. package/dist/shims/head.js.map +1 -1
  286. package/dist/shims/headers.d.ts +13 -2
  287. package/dist/shims/headers.js +73 -22
  288. package/dist/shims/headers.js.map +1 -1
  289. package/dist/shims/image.d.ts +1 -1
  290. package/dist/shims/image.js +4 -4
  291. package/dist/shims/image.js.map +1 -1
  292. package/dist/shims/internal/app-route-detection.d.ts +37 -0
  293. package/dist/shims/internal/app-route-detection.js +69 -0
  294. package/dist/shims/internal/app-route-detection.js.map +1 -0
  295. package/dist/shims/internal/pages-data-target.d.ts +58 -0
  296. package/dist/shims/internal/pages-data-target.js +91 -0
  297. package/dist/shims/internal/pages-data-target.js.map +1 -0
  298. package/dist/shims/internal/pages-data-url.d.ts +42 -0
  299. package/dist/shims/internal/pages-data-url.js +73 -0
  300. package/dist/shims/internal/pages-data-url.js.map +1 -0
  301. package/dist/shims/link.d.ts +18 -2
  302. package/dist/shims/link.js +129 -15
  303. package/dist/shims/link.js.map +1 -1
  304. package/dist/shims/metadata.d.ts +9 -7
  305. package/dist/shims/metadata.js +70 -7
  306. package/dist/shims/metadata.js.map +1 -1
  307. package/dist/shims/navigation.d.ts +1 -2
  308. package/dist/shims/navigation.js +94 -20
  309. package/dist/shims/navigation.js.map +1 -1
  310. package/dist/shims/router.d.ts +5 -0
  311. package/dist/shims/router.js +389 -80
  312. package/dist/shims/router.js.map +1 -1
  313. package/dist/shims/script.d.ts +11 -1
  314. package/dist/shims/script.js +158 -15
  315. package/dist/shims/script.js.map +1 -1
  316. package/dist/shims/server.js +1 -0
  317. package/dist/shims/server.js.map +1 -1
  318. package/dist/shims/url-utils.d.ts +2 -1
  319. package/dist/shims/url-utils.js +15 -4
  320. package/dist/shims/url-utils.js.map +1 -1
  321. package/dist/utils/html-limited-bots.d.ts +5 -0
  322. package/dist/utils/html-limited-bots.js +15 -0
  323. package/dist/utils/html-limited-bots.js.map +1 -0
  324. package/dist/utils/path.d.ts +13 -0
  325. package/dist/utils/path.js +16 -0
  326. package/dist/utils/path.js.map +1 -0
  327. package/dist/utils/query.d.ts +6 -0
  328. package/dist/utils/query.js +10 -1
  329. package/dist/utils/query.js.map +1 -1
  330. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"pages-server-entry.js","names":[],"sources":["../../src/entries/pages-server-entry.ts"],"sourcesContent":["/**\n * Pages Router server entry generator.\n *\n * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).\n * This is the entry point for `vite build --ssr`. It handles SSR, API routes,\n * middleware, ISR, and i18n for the Pages Router.\n *\n * Extracted from index.ts.\n */\nimport { resolveEntryPath, normalizePathSeparators } from \"./runtime-entry-module.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _middlewareRuntimePath = resolveEntryPath(\"../server/middleware-runtime.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesDataRoutePath = resolveEntryPath(\"../server/pages-data-route.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\nconst _serverGlobalsPath = resolveEntryPath(\"../server/server-globals.js\", import.meta.url);\n\n/**\n * Generate the virtual SSR server entry module.\n * This is the entry point for `vite build --ssr`.\n */\nexport async function generateServerEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n middlewarePath: string | null,\n instrumentationPath: string | null,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n // Generate import statements using absolute paths since virtual\n // modules don't have a real file location for relative resolution.\n const pageImports = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as api_${i} from ${JSON.stringify(absPath)};`;\n });\n\n // Build the route table — include filePath for SSR manifest lookup\n const pageRouteEntries = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;\n });\n\n const apiRouteEntries = apiRoutes.map(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app and _document\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n // Embed the resolved _app path (or null) so the runtime can look it up\n // in the SSR manifest and include any CSS/JS chunks `_app` brings in\n // (e.g. global stylesheets imported by `_app.tsx`) alongside the page's\n // own assets. Without this, `_app`-imported CSS is emitted by Vite but\n // never `<link>`ed from the rendered HTML — see LHF-5 cluster.\n const appAssetPathJson =\n appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : \"null\";\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};`\n : `const DocumentComponent = null;`;\n\n // Serialize i18n config for embedding in the server entry\n const i18nConfigJson = nextConfig?.i18n\n ? JSON.stringify({\n locales: nextConfig.i18n.locales,\n defaultLocale: nextConfig.i18n.defaultLocale,\n localeDetection: nextConfig.i18n.localeDetection,\n domains: nextConfig.i18n.domains,\n })\n : \"null\";\n\n // Embed the resolved build ID at build time\n const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);\n\n // Serialize the full resolved config for the production server.\n // This embeds redirects, rewrites, headers, basePath, trailingSlash\n // so prod-server.ts can apply them without loading next.config.js at runtime.\n const vinextConfigJson = JSON.stringify({\n basePath: nextConfig?.basePath ?? \"\",\n assetPrefix: nextConfig?.assetPrefix ?? \"\",\n trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n expireTime: nextConfig?.expireTime,\n i18n: nextConfig?.i18n ?? null,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\n dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,\n contentDispositionType: nextConfig?.images?.contentDispositionType,\n contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,\n },\n });\n\n // Generate instrumentation code if instrumentation.ts exists.\n // For production (Cloudflare Workers), instrumentation.ts is bundled into the\n // Worker and register() is called as a top-level await at module evaluation time —\n // before any request is handled. This mirrors App Router behavior (generateRscEntry)\n // and matches Next.js semantics: register() runs once on startup in the process\n // that handles requests.\n //\n // The onRequestError handler is stored on globalThis so it is visible across\n // all code within the Worker (same global scope).\n const instrumentationImportCode = instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};`\n : \"\";\n\n const instrumentationInitCode = instrumentationPath\n ? `// Run instrumentation register() once at module evaluation time — before any\n// requests are handled. Matches Next.js semantics: register() is called once\n// on startup in the process that handles requests.\nif (typeof _instrumentation.register === \"function\") {\n await _instrumentation.register();\n}\n// Store the onRequestError handler on globalThis so it is visible to all\n// code within the Worker (same global scope).\nif (typeof _instrumentation.onRequestError === \"function\") {\n globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;\n}`\n : \"\";\n\n // Generate middleware code if middleware.ts exists\n const middlewareImportCode = middlewarePath\n ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};`\n : \"\";\n\n // The matcher config is read from the middleware module at request time.\n // The generated entry only wires the user module into the shared runtime\n // helper; matcher, execution, waitUntil, and result shaping live in normal\n // TypeScript modules so dev/prod paths cannot drift.\n const middlewareExportCode = middlewarePath\n ? `\nexport async function runMiddleware(request, ctx, options) {\n return __runGeneratedMiddleware({\n basePath: vinextConfig.basePath,\n ctx,\n i18nConfig,\n isDataRequest: options?.isDataRequest === true,\n isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},\n module: middlewareModule,\n request,\n trailingSlash: vinextConfig.trailingSlash,\n });\n}\n`\n : `\nexport async function runMiddleware() { return { continue: true }; }\n`;\n\n // The server entry is a self-contained module that uses Web-standard APIs\n // (Request/Response, renderToReadableStream) so it runs on Cloudflare Workers.\n return `\nimport ${JSON.stringify(_serverGlobalsPath)};\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { resetSSRHead, getSSRHeadHTML } from \"next/head\";\nimport { flushPreloads } from \"next/dynamic\";\nimport { setSSRContext, wrapWithRouterContext } from \"next/router\";\nimport { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse } from ${JSON.stringify(_pagesDataRoutePath)};\nimport { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};\n${instrumentationImportCode}\n${middlewareImportCode}\n\n${instrumentationInitCode}\n\n// i18n config (embedded at build time)\nconst i18nConfig = ${i18nConfigJson};\n\n// Build ID (embedded at build time). Exported so the production server can\n// match _next/data requests against the embedded buildId without needing\n// to load next.config.js at runtime.\nexport const buildId = ${buildIdJson};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\n// Path to the user's pages/_app file (or null). Used to look up the\n// _app's CSS/JS chunks in the SSR manifest so any global styles imported\n// by _app are included in every page's <link rel=\"stylesheet\"> set.\nconst _appAssetPath = ${appAssetPathJson};\n\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags, expireSeconds) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags, expireSeconds);\n}\nfunction triggerBackgroundRegeneration(key, renderFn, errorContext) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\n}\n\nasync function renderToStringAsync(element) {\n const stream = await renderToReadableStream(element);\n await stream.allReady;\n return new Response(stream).text();\n}\n\nasync function renderIsrPassToStringAsync(element) {\n // The cache-fill render is a second render pass for the same request.\n // Reset render-scoped state so it cannot leak from the streamed response\n // render or affect async work that is still draining from that stream.\n // Keep request identity state (pathname/query/locale/executionContext)\n // intact: this second pass still belongs to the same request.\n return await runWithServerInsertedHTMLState(() =>\n runWithHeadState(() =>\n _runWithCacheState(() =>\n runWithPrivateCache(() => runWithFetchCache(async () => renderToStringAsync(element))),\n ),\n ),\n );\n}\n\n${pageImports.join(\"\\n\")}\n${apiImports.join(\"\\n\")}\n\n${appImportCode}\n${docImportCode}\n\nexport const pageRoutes = [\n${pageRouteEntries.join(\",\\n\")}\n];\nconst _pageRouteTrie = _buildRouteTrie(pageRoutes);\n\nconst apiRoutes = [\n${apiRouteEntries.join(\",\\n\")}\n];\nconst _apiRouteTrie = _buildRouteTrie(apiRoutes);\n\nfunction matchRoute(url, routes) {\n const pathname = url.split(\"?\")[0];\n let normalizedUrl = pathname === \"/\" ? \"/\" : pathname.replace(/\\\\/$/, \"\");\n // NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at\n // the entry point. Decoding again would create a double-decode vector.\n const urlParts = normalizedUrl.split(\"/\").filter(Boolean);\n const trie = routes === pageRoutes ? _pageRouteTrie : _apiRouteTrie;\n return _trieMatch(trie, urlParts);\n}\n\nexport function matchPageRoute(url, request) {\n const routeUrl = i18nConfig && request\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n ).url\n : url;\n return matchRoute(routeUrl, pageRoutes);\n}\n\nfunction parseQuery(url) {\n const qs = url.split(\"?\")[1];\n if (!qs) return {};\n const p = new URLSearchParams(qs);\n const q = {};\n for (const [k, v] of p) {\n if (k in q) {\n q[k] = Array.isArray(q[k]) ? q[k].concat(v) : [q[k], v];\n } else {\n q[k] = v;\n }\n }\n return q;\n}\n\nfunction mergeRouteParamsIntoQuery(query, params) {\n return Object.assign(query, params);\n}\n\nfunction patternToNextFormat(pattern) {\n // Match any non-/ param name. Non-greedy with lookahead prevents\n // the +/* suffix being consumed into the param name when the name\n // itself contains + or * internally (e.g. :c++lang → [c++lang]).\n return pattern\n .replace(/:([^\\\\/]+?)\\\\+(?=\\\\/|$)/g, \"[...$1]\")\n .replace(/:([^\\\\/]+?)\\\\*(?=\\\\/|$)/g, \"[[...$1]]\")\n .replace(/:([^\\\\/]+?)(?=\\\\/|$)/g, \"[$1]\");\n}\n\nfunction collectAssetTags(manifest, moduleIds, scriptNonce) {\n // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)\n const m = (manifest && Object.keys(manifest).length > 0)\n ? manifest\n : (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_SSR_MANIFEST__) || null;\n const tags = [];\n const seen = new Set();\n const nonceAttr = __createNonceAttribute(scriptNonce);\n\n // Load the set of lazy chunk filenames (only reachable via dynamic imports).\n // These should NOT get <link rel=\"modulepreload\"> or <script type=\"module\">\n // tags — they are fetched on demand when the dynamic import() executes (e.g.\n // chunks behind React.lazy() or next/dynamic boundaries).\n var lazyChunks = (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_LAZY_CHUNKS__) || null;\n var lazySet = lazyChunks && lazyChunks.length > 0 ? new Set(lazyChunks) : null;\n\n // Inject the client entry script if embedded by vinext:cloudflare-build\n if (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_CLIENT_ENTRY__) {\n const entry = globalThis.__VINEXT_CLIENT_ENTRY__;\n seen.add(entry);\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + entry + '\" crossorigin></script>');\n }\n if (m) {\n // Always inject shared chunks (framework, vinext runtime, entry) and\n // page-specific chunks. The manifest maps module file paths to their\n // associated JS/CSS assets.\n //\n // For page-specific injection, the module IDs may be absolute paths\n // while the manifest uses relative paths. Try both the original ID\n // and a suffix match to find the correct manifest entry.\n var allFiles = [];\n\n if (moduleIds && moduleIds.length > 0) {\n // Collect assets for the requested page modules\n for (var mi = 0; mi < moduleIds.length; mi++) {\n var id = moduleIds[mi];\n var files = m[id];\n if (!files) {\n // Absolute path didn't match — try matching by suffix.\n // Manifest keys are relative (e.g. \"pages/about.tsx\") while\n // moduleIds may be absolute (e.g. \"/home/.../pages/about.tsx\").\n for (var mk in m) {\n if (id.endsWith(\"/\" + mk) || id === mk) {\n files = m[mk];\n break;\n }\n }\n }\n if (files) {\n for (var fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);\n }\n }\n\n // Also inject shared chunks that every page needs: framework,\n // vinext runtime, and the entry bootstrap. These are identified\n // by scanning all manifest values for chunk filenames containing\n // known prefixes.\n for (var key in m) {\n var vals = m[key];\n if (!vals) continue;\n for (var vi = 0; vi < vals.length; vi++) {\n var file = vals[vi];\n var basename = file.split(\"/\").pop() || \"\";\n if (\n basename.startsWith(\"framework-\") ||\n basename.startsWith(\"vinext-\") ||\n basename.includes(\"vinext-client-entry\") ||\n basename.includes(\"vinext-app-browser-entry\")\n ) {\n allFiles.push(file);\n }\n }\n }\n } else {\n // No specific modules — include all assets from manifest\n for (var akey in m) {\n var avals = m[akey];\n if (avals) {\n for (var ai = 0; ai < avals.length; ai++) allFiles.push(avals[ai]);\n }\n }\n }\n\n for (var ti = 0; ti < allFiles.length; ti++) {\n var tf = allFiles[ti];\n // Normalize: Vite's SSR manifest values include a leading '/'\n // (from base path), but we prepend '/' ourselves when building\n // href/src attributes. Strip any existing leading slash to avoid\n // producing protocol-relative URLs like \"//assets/chunk.js\".\n // This also ensures consistent keys for the seen-set dedup and\n // lazySet.has() checks (which use values without leading slash).\n if (tf.charAt(0) === '/') tf = tf.slice(1);\n if (seen.has(tf)) continue;\n seen.add(tf);\n if (tf.endsWith(\".css\")) {\n tags.push('<link rel=\"stylesheet\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n } else if (tf.endsWith(\".js\")) {\n // Skip lazy chunks — they are behind dynamic import() boundaries\n // (React.lazy, next/dynamic) and should only be fetched on demand.\n if (lazySet && lazySet.has(tf)) continue;\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\"' + nonceAttr + ' src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));\n return _renderPage(request, url, manifest, middlewareHeaders, options);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders, options) {\n const isDataReq = !!(options && options.isDataReq);\n const localeInfo = i18nConfig\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n )\n : { locale: undefined, url, hadPrefix: false, domainLocale: undefined, redirectUrl: undefined };\n const locale = localeInfo.locale;\n const routeUrl = localeInfo.url;\n const currentDefaultLocale = i18nConfig\n ? (localeInfo.domainLocale ? localeInfo.domainLocale.defaultLocale : i18nConfig.defaultLocale)\n : undefined;\n const domainLocales = i18nConfig ? i18nConfig.domains : undefined;\n\n if (localeInfo.redirectUrl) {\n return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });\n }\n\n const match = matchRoute(routeUrl, pageRoutes);\n if (!match) {\n if (isDataReq) {\n return __buildNextDataNotFoundResponse();\n }\n return new Response(\"<!DOCTYPE html><html><body><h1>404 - Page not found</h1></body></html>\",\n { status: 404, headers: { \"Content-Type\": \"text/html\" } });\n }\n\n const { route, params } = match;\n const __uCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(__uCtx, async () => {\n ensureFetchPatch();\n try {\n const routePattern = patternToNextFormat(route.pattern);\n const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n\n const pageModule = route.module;\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n return new Response(\"Page has no default export\", { status: 500 });\n }\n const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);\n // Build font Link header early so it's available for ISR cached responses too.\n // Font preloads are module-level state populated at import time and persist across requests.\n var _fontLinkHeader = \"\";\n var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n if (_allFp.length > 0) {\n _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n }\n } catch (e) { /* font preloads not available */ }\n const pageDataResult = await __resolvePagesPageData({\n isDataReq,\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n },\n buildId,\n createGsspReqRes() {\n return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });\n },\n createPageElement(currentPageProps) {\n var currentElement = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n : React.createElement(PageComponent, currentPageProps);\n return wrapWithRouterContext(currentElement);\n },\n fontLinkHeader: _fontLinkHeader,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isrCacheKey,\n isrGet,\n isrSet,\n expireSeconds: vinextConfig.expireTime,\n pageModule,\n params,\n query,\n renderIsrPassToStringAsync,\n route: {\n isDynamic: route.isDynamic,\n },\n routePattern,\n routeUrl,\n runInFreshUnifiedContext(callback) {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n return callback();\n });\n },\n safeJsonStringify,\n sanitizeDestination: sanitizeDestinationLocal,\n scriptNonce,\n triggerBackgroundRegeneration,\n });\n if (pageDataResult.kind === \"response\") {\n return pageDataResult.response;\n }\n let pageProps = pageDataResult.pageProps;\n var gsspRes = pageDataResult.gsspRes;\n let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n const isFallbackRender = pageDataResult.isFallback === true;\n\n // Republish the SSR context with isFallback flipped on so the page's\n // \\`useRouter().isFallback\\` returns true during render, matching Next.js's\n // \\`render.tsx\\` fallback shell. Without this, the page would still see\n // \\`isFallback: false\\` and run the non-fallback branch.\n if (isFallbackRender && typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n isFallback: true,\n });\n }\n\n // ── _next/data JSON envelope short-circuit ───────────────────────\n // For client-side navigations Next.js fetches /_next/data/<buildId>/<page>.json\n // and expects { pageProps } as JSON instead of the full HTML page. Skip\n // rendering the React tree and emit the JSON envelope directly via the\n // typed helper so the envelope shape stays in one place. Headers and\n // cookies set on the gsspRes by getServerSideProps are forwarded so\n // middleware/auth flows work the same as the HTML page.\n if (isDataReq) {\n const init = {};\n if (gsspRes && gsspRes.headers) {\n init.headers = {};\n for (const [k, v] of Object.entries(gsspRes.headers)) {\n if (v === undefined || v === null) continue;\n init.headers[k] = Array.isArray(v) ? v.join(\", \") : String(v);\n }\n }\n return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);\n }\n\n // Include both the matched page module and the global _app module\n // (if present). _app is wrapped around every page in Pages Router,\n // and any CSS/JS it imports must be linked from the rendered HTML\n // so the browser actually loads it. Without _app in this list, a\n // global stylesheet imported via import \"./globals.scss\" in\n // _app.tsx never reaches the page, producing the LHF-5 symptom\n // where styled elements render with the browser default colour.\n const pageModuleIds = [];\n if (route.filePath) pageModuleIds.push(route.filePath);\n if (_appAssetPath) pageModuleIds.push(_appAssetPath);\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n gsspRes,\n isrCacheKey,\n expireSeconds: vinextConfig.expireTime,\n isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isFallback: isFallbackRender,\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n routePattern,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\n });\n } catch (e) {\n console.error(\"[vinext] SSR error:\", e);\n _reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n });\n}\n\nexport async function handleApiRoute(request, url, ctx) {\n const match = matchRoute(url, apiRoutes);\n return __handlePagesApiRoute({\n ctx,\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,yBAAyB,iBAAiB,mCAAmC,OAAO,KAAK,IAAI;AACnG,MAAM,iBAAiB,iBAAiB,4BAA4B,OAAO,KAAK,IAAI;AACpF,MAAM,iBAAiB,iBAAiB,2BAA2B,OAAO,KAAK,IAAI;AACnF,MAAM,yBAAyB,iBAC7B,oCACA,OAAO,K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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqd5B,qBAAqB"}
1
+ {"version":3,"file":"pages-server-entry.js","names":[],"sources":["../../src/entries/pages-server-entry.ts"],"sourcesContent":["/**\n * Pages Router server entry generator.\n *\n * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).\n * This is the entry point for `vite build --ssr`. It handles SSR, API routes,\n * middleware, ISR, and i18n for the Pages Router.\n *\n * Extracted from index.ts.\n */\nimport { resolveEntryPath } from \"./runtime-entry-module.js\";\nimport { normalizePathSeparators } from \"../utils/path.js\";\nimport { pagesRouter, apiRouter, type Route } from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { isProxyFile } from \"../server/middleware.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nconst _requestContextShimPath = resolveEntryPath(\"../shims/request-context.js\", import.meta.url);\nconst _middlewareRuntimePath = resolveEntryPath(\"../server/middleware-runtime.js\", import.meta.url);\nconst _routeTriePath = resolveEntryPath(\"../routing/route-trie.js\", import.meta.url);\nconst _pagesI18nPath = resolveEntryPath(\"../server/pages-i18n.js\", import.meta.url);\nconst _pagesPageResponsePath = resolveEntryPath(\n \"../server/pages-page-response.js\",\n import.meta.url,\n);\nconst _pagesPageDataPath = resolveEntryPath(\"../server/pages-page-data.js\", import.meta.url);\nconst _pagesPageMethodPath = resolveEntryPath(\"../server/pages-page-method.js\", import.meta.url);\nconst _pagesDataRoutePath = resolveEntryPath(\"../server/pages-data-route.js\", import.meta.url);\nconst _pagesDefault404Path = resolveEntryPath(\"../server/pages-default-404.js\", import.meta.url);\nconst _pagesNodeCompatPath = resolveEntryPath(\"../server/pages-node-compat.js\", import.meta.url);\nconst _pagesApiRoutePath = resolveEntryPath(\"../server/pages-api-route.js\", import.meta.url);\nconst _isrCachePath = resolveEntryPath(\"../server/isr-cache.js\", import.meta.url);\nconst _cspPath = resolveEntryPath(\"../server/csp.js\", import.meta.url);\nconst _serverGlobalsPath = resolveEntryPath(\"../server/server-globals.js\", import.meta.url);\n\n/**\n * Generate the virtual SSR server entry module.\n * This is the entry point for `vite build --ssr`.\n */\nexport async function generateServerEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n middlewarePath: string | null,\n instrumentationPath: string | null,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n // Generate import statements using absolute paths since virtual\n // modules don't have a real file location for relative resolution.\n const pageImports = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as page_${i} from ${JSON.stringify(absPath)};`;\n });\n\n const apiImports = apiRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return `import * as api_${i} from ${JSON.stringify(absPath)};`;\n });\n\n // Build the route table — include filePath for SSR manifest lookup\n const pageRouteEntries = pageRoutes.map((r: Route, i: number) => {\n const absPath = normalizePathSeparators(r.filePath);\n return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(absPath)} }`;\n });\n\n const apiRouteEntries = apiRoutes.map(\n (r: Route, i: number) =>\n ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`,\n );\n\n // Check for _app, _document, and _error.\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const docFilePath = findFileWithExts(pagesDir, \"_document\", fileMatcher);\n const errorFilePath = findFileWithExts(pagesDir, \"_error\", fileMatcher);\n // Embed the resolved _app path (or null) so the runtime can look it up\n // in the SSR manifest and include any CSS/JS chunks `_app` brings in\n // (e.g. global stylesheets imported by `_app.tsx`) alongside the page's\n // own assets. Without this, `_app`-imported CSS is emitted by Vite but\n // never `<link>`ed from the rendered HTML — see LHF-5 cluster.\n const appAssetPathJson =\n appFilePath !== null ? JSON.stringify(normalizePathSeparators(appFilePath)) : \"null\";\n const appImportCode =\n appFilePath !== null\n ? `import { default as AppComponent } from ${JSON.stringify(normalizePathSeparators(appFilePath))};`\n : `const AppComponent = null;`;\n\n const docImportCode =\n docFilePath !== null\n ? `import { default as DocumentComponent } from ${JSON.stringify(normalizePathSeparators(docFilePath))};`\n : `const DocumentComponent = null;`;\n\n const errorAssetPathJson =\n errorFilePath !== null ? JSON.stringify(normalizePathSeparators(errorFilePath)) : \"null\";\n const errorImportCode =\n errorFilePath !== null\n ? `import * as ErrorPageModule from ${JSON.stringify(normalizePathSeparators(errorFilePath))};`\n : `const ErrorPageModule = null;`;\n\n // Serialize i18n config for embedding in the server entry\n const i18nConfigJson = nextConfig?.i18n\n ? JSON.stringify({\n locales: nextConfig.i18n.locales,\n defaultLocale: nextConfig.i18n.defaultLocale,\n localeDetection: nextConfig.i18n.localeDetection,\n domains: nextConfig.i18n.domains,\n })\n : \"null\";\n\n // Embed the resolved build ID at build time\n const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);\n\n // Serialize the full resolved config for the production server.\n // This embeds redirects, rewrites, headers, basePath, trailingSlash\n // so prod-server.ts can apply them without loading next.config.js at runtime.\n const vinextConfigJson = JSON.stringify({\n basePath: nextConfig?.basePath ?? \"\",\n assetPrefix: nextConfig?.assetPrefix ?? \"\",\n trailingSlash: nextConfig?.trailingSlash ?? false,\n redirects: nextConfig?.redirects ?? [],\n rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: nextConfig?.headers ?? [],\n expireTime: nextConfig?.expireTime,\n i18n: nextConfig?.i18n ?? null,\n // Mirrors Next.js `experimental.disableOptimizedLoading` — when false\n // (the default), page scripts are emitted with `defer` in <head>. See\n // `.nextjs-ref/packages/next/src/pages/_document.tsx` getScripts().\n disableOptimizedLoading: nextConfig?.disableOptimizedLoading === true,\n clientTraceMetadata: nextConfig?.clientTraceMetadata,\n images: {\n deviceSizes: nextConfig?.images?.deviceSizes,\n imageSizes: nextConfig?.images?.imageSizes,\n dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,\n dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,\n contentDispositionType: nextConfig?.images?.contentDispositionType,\n contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,\n },\n });\n\n // Generate instrumentation code if instrumentation.ts exists.\n // For production (Cloudflare Workers), instrumentation.ts is bundled into the\n // Worker and register() is called as a top-level await at module evaluation time —\n // before any request is handled. This mirrors App Router behavior (generateRscEntry)\n // and matches Next.js semantics: register() runs once on startup in the process\n // that handles requests.\n //\n // The onRequestError handler is stored on globalThis so it is visible across\n // all code within the Worker (same global scope).\n const instrumentationImportCode = instrumentationPath\n ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};`\n : \"\";\n\n const instrumentationInitCode = instrumentationPath\n ? `// Run instrumentation register() once at module evaluation time — before any\n// requests are handled. Matches Next.js semantics: register() is called once\n// on startup in the process that handles requests.\nif (typeof _instrumentation.register === \"function\") {\n await _instrumentation.register();\n}\n// Store the onRequestError handler on globalThis so it is visible to all\n// code within the Worker (same global scope).\nif (typeof _instrumentation.onRequestError === \"function\") {\n globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;\n}`\n : \"\";\n\n // Generate middleware code if middleware.ts exists\n const middlewareImportCode = middlewarePath\n ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};`\n : \"\";\n\n // The matcher config is read from the middleware module at request time.\n // The generated entry only wires the user module into the shared runtime\n // helper; matcher, execution, waitUntil, and result shaping live in normal\n // TypeScript modules so dev/prod paths cannot drift.\n const middlewareExportCode = middlewarePath\n ? `\nexport async function runMiddleware(request, ctx, options) {\n // Auto-detect /_next/data/<buildId>/<page>.json requests so user-written\n // worker entries don't need to know about the data endpoint protocol.\n // Mismatched buildId → JSON 404 short-circuit. Matched → middleware sees\n // the normalized page path via the request URL, and the worker sees the\n // normalized URL via result.rewriteUrl (if middleware didn't already\n // rewrite to something else).\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n const __result = await __runGeneratedMiddleware({\n basePath: vinextConfig.basePath,\n ctx,\n i18nConfig,\n isDataRequest: options?.isDataRequest === true || __dataNorm.isDataReq,\n isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},\n module: middlewareModule,\n request: __dataNorm.request,\n trailingSlash: vinextConfig.trailingSlash,\n });\n if (__dataNorm.isDataReq && __result.continue && !__result.rewriteUrl && !__result.redirectUrl) {\n return { ...__result, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return __result;\n}\n`\n : `\nexport async function runMiddleware(request) {\n // Even without user middleware, the data-endpoint URL must be normalized so\n // the worker pipeline sees the page path. Mismatched buildId → JSON 404.\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) {\n return { continue: false, response: __dataNorm.notFoundResponse };\n }\n if (__dataNorm.isDataReq) {\n return { continue: true, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };\n }\n return { continue: true };\n}\n`;\n\n // The server entry is a self-contained module that uses Web-standard APIs\n // (Request/Response, renderToReadableStream) so it runs on Cloudflare Workers.\n return `\nimport ${JSON.stringify(_serverGlobalsPath)};\nimport React from \"react\";\nimport { renderToReadableStream } from \"react-dom/server.edge\";\nimport { resetSSRHead, getSSRHeadHTML } from \"next/head\";\nimport { flushPreloads } from \"next/dynamic\";\nimport { setSSRContext, wrapWithRouterContext } from \"next/router\";\nimport { _runWithCacheState } from \"next/cache\";\nimport { runWithPrivateCache } from \"vinext/cache-runtime\";\nimport { ensureFetchPatch, runWithFetchCache } from \"vinext/fetch-cache\";\nimport { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from \"vinext/unified-request-context\";\nimport \"vinext/router-state\";\nimport { runWithServerInsertedHTMLState } from \"vinext/navigation-state\";\nimport { runWithHeadState } from \"vinext/head-state\";\nimport \"vinext/i18n-state\";\nimport { setI18nContext } from \"vinext/i18n-context\";\nimport { createNonceAttribute as __createNonceAttribute, safeJsonStringify } from \"vinext/html\";\nimport { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from \"next/font/google\";\nimport { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from \"next/font/local\";\nimport { sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(resolveEntryPath(\"../config/config-matchers.js\", import.meta.url))};\nimport { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};\nimport { runGeneratedMiddleware as __runGeneratedMiddleware } from ${JSON.stringify(_middlewareRuntimePath)};\nimport { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};\nimport { reportRequestError as _reportRequestError } from \"vinext/instrumentation\";\nimport { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};\nimport { createPagesReqRes as __createPagesReqRes } from ${JSON.stringify(_pagesNodeCompatPath)};\nimport { handlePagesApiRoute as __handlePagesApiRoute } from ${JSON.stringify(_pagesApiRoutePath)};\nimport {\n isrGet as __sharedIsrGet,\n isrSet as __sharedIsrSet,\n isrCacheKey as __sharedIsrCacheKey,\n triggerBackgroundRegeneration as __sharedTriggerBackgroundRegeneration,\n} from ${JSON.stringify(_isrCachePath)};\nimport { getScriptNonceFromHeaderSources as __getScriptNonceFromHeaderSources } from ${JSON.stringify(_cspPath)};\nimport { resolvePagesPageData as __resolvePagesPageData } from ${JSON.stringify(_pagesPageDataPath)};\nimport { resolvePagesPageMethodResponse as __resolvePagesPageMethodResponse } from ${JSON.stringify(_pagesPageMethodPath)};\nimport { buildNextDataJsonResponse as __buildNextDataJsonResponse, buildNextDataNotFoundResponse as __buildNextDataNotFoundResponse, isNextDataPathname as __isNextDataPathname, parseNextDataPathname as __parseNextDataPathname } from ${JSON.stringify(_pagesDataRoutePath)};\nimport { buildDefaultPagesNotFoundResponse as __buildDefaultPagesNotFoundResponse } from ${JSON.stringify(_pagesDefault404Path)};\nimport { renderPagesPageResponse as __renderPagesPageResponse } from ${JSON.stringify(_pagesPageResponsePath)};\n${instrumentationImportCode}\n${middlewareImportCode}\n\n${instrumentationInitCode}\n\n// i18n config (embedded at build time)\nconst i18nConfig = ${i18nConfigJson};\n\n// Build ID (embedded at build time). Exported so the production server can\n// match _next/data requests against the embedded buildId without needing\n// to load next.config.js at runtime.\nexport const buildId = ${buildIdJson};\nconst __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};\n\n// Full resolved config for production server (embedded at build time)\nexport const vinextConfig = ${vinextConfigJson};\n\n// Path to the user's pages/_app file (or null). Used to look up the\n// _app's CSS/JS chunks in the SSR manifest so any global styles imported\n// by _app are included in every page's <link rel=\"stylesheet\"> set.\nconst _appAssetPath = ${appAssetPathJson};\n\nfunction isrGet(key) {\n return __sharedIsrGet(key);\n}\nfunction isrSet(key, data, revalidateSeconds, tags, expireSeconds) {\n return __sharedIsrSet(key, data, revalidateSeconds, tags, expireSeconds);\n}\nfunction triggerBackgroundRegeneration(key, renderFn, errorContext) {\n return __sharedTriggerBackgroundRegeneration(key, renderFn, errorContext);\n}\nfunction isrCacheKey(router, pathname) {\n return __sharedIsrCacheKey(router, pathname, buildId || undefined);\n}\n\n/**\n * Detect and normalize /_next/data/<buildId>/<page>.json requests in one\n * place so user-written worker entries don't need to know about the data\n * endpoint protocol. Returns the normalized request (with the page path as\n * its URL), an isDataReq flag, and notFoundResponse when the buildId in\n * the URL does not match this server's buildId — callers should return that\n * response immediately so a stale client falls back to a hard navigation.\n */\nfunction __normalizePagesDataRequest(request) {\n const reqUrl = new URL(request.url);\n if (!__isNextDataPathname(reqUrl.pathname)) {\n return { isDataReq: false, request, normalizedPathname: null, search: \"\", notFoundResponse: null };\n }\n const dataMatch = buildId ? __parseNextDataPathname(reqUrl.pathname, buildId) : null;\n if (!dataMatch) {\n return {\n isDataReq: false,\n request,\n normalizedPathname: null,\n search: \"\",\n notFoundResponse: __buildNextDataNotFoundResponse(),\n };\n }\n const normalizedUrl = new URL(reqUrl);\n normalizedUrl.pathname = dataMatch.pagePathname;\n return {\n isDataReq: true,\n request: new Request(normalizedUrl, request),\n normalizedPathname: dataMatch.pagePathname,\n search: reqUrl.search,\n notFoundResponse: null,\n };\n}\n\nasync function renderToStringAsync(element) {\n const stream = await renderToReadableStream(element);\n await stream.allReady;\n return new Response(stream).text();\n}\n\nasync function renderIsrPassToStringAsync(element) {\n // The cache-fill render is a second render pass for the same request.\n // Reset render-scoped state so it cannot leak from the streamed response\n // render or affect async work that is still draining from that stream.\n // Keep request identity state (pathname/query/locale/executionContext)\n // intact: this second pass still belongs to the same request.\n return await runWithServerInsertedHTMLState(() =>\n runWithHeadState(() =>\n _runWithCacheState(() =>\n runWithPrivateCache(() => runWithFetchCache(async () => renderToStringAsync(element))),\n ),\n ),\n );\n}\n\n${pageImports.join(\"\\n\")}\n${apiImports.join(\"\\n\")}\n\n${appImportCode}\n${docImportCode}\n${errorImportCode}\n\nexport const pageRoutes = [\n${pageRouteEntries.join(\",\\n\")}\n];\nconst _pageRouteTrie = _buildRouteTrie(pageRoutes);\nconst _errorPageRoute = ErrorPageModule\n ? {\n pattern: \"/_error\",\n patternParts: [\"_error\"],\n isDynamic: false,\n params: [],\n module: ErrorPageModule,\n filePath: ${errorAssetPathJson},\n }\n : null;\n\nconst apiRoutes = [\n${apiRouteEntries.join(\",\\n\")}\n];\nconst _apiRouteTrie = _buildRouteTrie(apiRoutes);\n\nfunction matchRoute(url, routes) {\n const pathname = url.split(\"?\")[0];\n let normalizedUrl = pathname === \"/\" ? \"/\" : pathname.replace(/\\\\/$/, \"\");\n // NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at\n // the entry point. Decoding again would create a double-decode vector.\n const urlParts = normalizedUrl.split(\"/\").filter(Boolean);\n const trie = routes === pageRoutes ? _pageRouteTrie : _apiRouteTrie;\n return _trieMatch(trie, urlParts);\n}\n\nexport function matchPageRoute(url, request) {\n const routeUrl = i18nConfig && request\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n ).url\n : url;\n return matchRoute(routeUrl, pageRoutes);\n}\n\nfunction parseQuery(url) {\n // Per RFC 3986 only the first \"?\" separates path from query, so additional\n // \"?\" chars belong to the query string (e.g. /linker?href=/about?hello=world\n // has query \"href=/about?hello=world\"). split(\"?\")[1] would drop everything\n // after the second \"?\" and strip embedded query strings from values.\n const queryIndex = url.indexOf(\"?\");\n if (queryIndex === -1) return {};\n const hashIndex = url.indexOf(\"#\", queryIndex + 1);\n const qs = hashIndex === -1 ? url.slice(queryIndex + 1) : url.slice(queryIndex + 1, hashIndex);\n if (!qs) return {};\n const p = new URLSearchParams(qs);\n const q = {};\n for (const [k, v] of p) {\n if (k in q) {\n q[k] = Array.isArray(q[k]) ? q[k].concat(v) : [q[k], v];\n } else {\n q[k] = v;\n }\n }\n return q;\n}\n\nfunction mergeRouteParamsIntoQuery(query, params) {\n return Object.assign(query, params);\n}\n\nfunction patternToNextFormat(pattern) {\n // Match any non-/ param name. Non-greedy with lookahead prevents\n // the +/* suffix being consumed into the param name when the name\n // itself contains + or * internally (e.g. :c++lang → [c++lang]).\n return pattern\n .replace(/:([^\\\\/]+?)\\\\+(?=\\\\/|$)/g, \"[...$1]\")\n .replace(/:([^\\\\/]+?)\\\\*(?=\\\\/|$)/g, \"[[...$1]]\")\n .replace(/:([^\\\\/]+?)(?=\\\\/|$)/g, \"[$1]\");\n}\n\nfunction resolveSsrManifest(manifest) {\n // Fall back to embedded manifest (set by vinext:cloudflare-build for Workers)\n return (manifest && Object.keys(manifest).length > 0)\n ? manifest\n : (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_SSR_MANIFEST__) || null;\n}\n\nfunction getManifestFilesForModule(manifest, moduleId) {\n if (!manifest || !moduleId) return null;\n\n var files = manifest[moduleId];\n if (files) return files;\n\n for (var key in manifest) {\n if (moduleId.endsWith(\"/\" + key) || moduleId === key) {\n return manifest[key];\n }\n }\n return null;\n}\n\nfunction collectAssetTags(manifest, moduleIds, scriptNonce) {\n const m = resolveSsrManifest(manifest);\n const tags = [];\n const seen = new Set();\n const nonceAttr = __createNonceAttribute(scriptNonce);\n // Mirrors Next.js \\`_document\\` behaviour: when \\`experimental.disableOptimizedLoading\\`\n // is false (the default), page scripts are emitted with \\`defer\\` in <head>. See\n // .nextjs-ref/packages/next/src/pages/_document.tsx getScripts() — \\`defer={!disableOptimizedLoading}\\`.\n // vinext always emits \\`type=\"module\"\\` (which already defers implicitly), but\n // upstream tests (e.g. test/e2e/optimized-loading) assert the literal \\`defer\\`\n // attribute, and adding it preserves parity without changing browser behaviour.\n const deferAttr = vinextConfig.disableOptimizedLoading ? \"\" : \" defer\";\n\n // Load the set of lazy chunk filenames (only reachable via dynamic imports).\n // These should NOT get <link rel=\"modulepreload\"> or <script type=\"module\">\n // tags — they are fetched on demand when the dynamic import() executes (e.g.\n // chunks behind React.lazy() or next/dynamic boundaries).\n var lazyChunks = (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_LAZY_CHUNKS__) || null;\n var lazySet = lazyChunks && lazyChunks.length > 0 ? new Set(lazyChunks) : null;\n\n // Inject the client entry script if embedded by vinext:cloudflare-build\n if (typeof globalThis !== \"undefined\" && globalThis.__VINEXT_CLIENT_ENTRY__) {\n const entry = globalThis.__VINEXT_CLIENT_ENTRY__;\n seen.add(entry);\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + entry + '\" />');\n tags.push('<script type=\"module\"' + deferAttr + nonceAttr + ' src=\"/' + entry + '\" crossorigin></script>');\n }\n if (m) {\n // Always inject shared chunks (framework, vinext runtime, entry) and\n // page-specific chunks. The manifest maps module file paths to their\n // associated JS/CSS assets.\n //\n // For page-specific injection, the module IDs may be absolute paths\n // while the manifest uses relative paths. Try both the original ID\n // and a suffix match to find the correct manifest entry.\n var allFiles = [];\n\n if (moduleIds && moduleIds.length > 0) {\n // Collect assets for the requested page modules\n for (var mi = 0; mi < moduleIds.length; mi++) {\n var id = moduleIds[mi];\n var files = getManifestFilesForModule(m, id);\n if (files) {\n for (var fi = 0; fi < files.length; fi++) allFiles.push(files[fi]);\n }\n }\n\n // Also inject shared chunks that every page needs: framework,\n // vinext runtime, and the entry bootstrap. These are identified\n // by scanning all manifest values for chunk filenames containing\n // known prefixes.\n for (var key in m) {\n var vals = m[key];\n if (!vals) continue;\n for (var vi = 0; vi < vals.length; vi++) {\n var file = vals[vi];\n var basename = file.split(\"/\").pop() || \"\";\n if (\n basename.startsWith(\"framework-\") ||\n basename.startsWith(\"vinext-\") ||\n basename.includes(\"vinext-client-entry\") ||\n basename.includes(\"vinext-app-browser-entry\")\n ) {\n allFiles.push(file);\n }\n }\n }\n } else {\n // No specific modules — include all assets from manifest\n for (var akey in m) {\n var avals = m[akey];\n if (avals) {\n for (var ai = 0; ai < avals.length; ai++) allFiles.push(avals[ai]);\n }\n }\n }\n\n for (var ti = 0; ti < allFiles.length; ti++) {\n var tf = allFiles[ti];\n // Normalize: Vite's SSR manifest values include a leading '/'\n // (from base path), but we prepend '/' ourselves when building\n // href/src attributes. Strip any existing leading slash to avoid\n // producing protocol-relative URLs like \"//assets/chunk.js\".\n // This also ensures consistent keys for the seen-set dedup and\n // lazySet.has() checks (which use values without leading slash).\n if (tf.charAt(0) === '/') tf = tf.slice(1);\n if (seen.has(tf)) continue;\n seen.add(tf);\n if (tf.endsWith(\".css\")) {\n tags.push('<link rel=\"stylesheet\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n } else if (tf.endsWith(\".js\")) {\n // Skip lazy chunks — they are behind dynamic import() boundaries\n // (React.lazy, next/dynamic) and should only be fetched on demand.\n if (lazySet && lazySet.has(tf)) continue;\n tags.push('<link rel=\"modulepreload\"' + nonceAttr + ' href=\"/' + tf + '\" />');\n tags.push('<script type=\"module\"' + deferAttr + nonceAttr + ' src=\"/' + tf + '\" crossorigin></script>');\n }\n }\n }\n return tags.join(\"\\\\n \");\n}\n\nfunction resolveClientModuleUrl(manifest, moduleId) {\n const files = getManifestFilesForModule(resolveSsrManifest(manifest), moduleId);\n if (!files) return undefined;\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n if (!file || !file.endsWith(\".js\")) continue;\n if (file.charAt(0) !== \"/\") file = \"/\" + file;\n return file;\n }\n return undefined;\n}\n\nexport async function renderPage(request, url, manifest, ctx, middlewareHeaders, options) {\n if (ctx) return _runWithExecutionContext(ctx, () => _renderPage(request, url, manifest, middlewareHeaders, options));\n return _renderPage(request, url, manifest, middlewareHeaders, options);\n}\n\nasync function _renderPage(request, url, manifest, middlewareHeaders, options) {\n let isDataReq = !!(options && options.isDataReq);\n // Auto-detect /_next/data/... requests by inspecting the incoming request\n // URL. The worker pipeline does not need to know about the data endpoint\n // protocol — when it forwards an unrewritten data URL as the url arg, we\n // normalize it to the page path here.\n if (!isDataReq) {\n const __dataNorm = __normalizePagesDataRequest(request);\n if (__dataNorm.notFoundResponse) return __dataNorm.notFoundResponse;\n if (__dataNorm.isDataReq) {\n isDataReq = true;\n if (url && url.startsWith(\"/_next/data/\")) {\n const __qs = url.includes(\"?\") ? url.slice(url.indexOf(\"?\")) : \"\";\n url = __dataNorm.normalizedPathname + __qs;\n }\n }\n }\n const statusCode = options && typeof options.statusCode === \"number\" ? options.statusCode : undefined;\n const asPath = options && typeof options.asPath === \"string\" ? options.asPath : undefined;\n const renderErrorPageOnMiss = !(options && options.renderErrorPageOnMiss === false);\n // Guard against infinite recursion when the user's custom 500/error page\n // itself throws during render. When this flag is set, the catch block below\n // returns the plain \"Internal Server Error\" text response instead of trying\n // to render an error page again. Fixes #1458.\n const isInternalErrorRender = !!(options && options.__isInternalErrorRender);\n const localeInfo = i18nConfig\n ? resolvePagesI18nRequest(\n url,\n i18nConfig,\n request.headers,\n new URL(request.url).hostname,\n vinextConfig.basePath,\n vinextConfig.trailingSlash,\n )\n : { locale: undefined, url, hadPrefix: false, domainLocale: undefined, redirectUrl: undefined };\n const locale = localeInfo.locale;\n const routeUrl = localeInfo.url;\n const currentDefaultLocale = i18nConfig\n ? (localeInfo.domainLocale ? localeInfo.domainLocale.defaultLocale : i18nConfig.defaultLocale)\n : undefined;\n const domainLocales = i18nConfig ? i18nConfig.domains : undefined;\n\n if (localeInfo.redirectUrl) {\n return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });\n }\n\n // Internal error render path: caller has pinned a specific route (the\n // user's pages/500 or pages/_error) to render in response to an SSR throw.\n // Skip route matching so we don't accidentally double-route, and skip the\n // missing-route 404 fallback. See catch block below. Fixes #1458.\n let match = options && options.__forcedRoute\n ? { route: options.__forcedRoute, params: {} }\n : matchRoute(routeUrl, pageRoutes);\n let renderStatusCodeOverride = statusCode;\n let renderAsPath = asPath;\n if (!match) {\n if (isDataReq) {\n return __buildNextDataNotFoundResponse();\n }\n if (!renderErrorPageOnMiss) {\n return __buildDefaultPagesNotFoundResponse();\n }\n const notFoundMatch = matchRoute(\"/404\", pageRoutes);\n // matchRoute may match a catch-all (e.g. [...slug]); only use the explicit pages/404 route.\n if (notFoundMatch && notFoundMatch.route.pattern === \"/404\") {\n match = notFoundMatch;\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else if (_errorPageRoute) {\n match = { route: _errorPageRoute, params: {} };\n renderStatusCodeOverride = 404;\n renderAsPath = routeUrl;\n } else {\n return __buildDefaultPagesNotFoundResponse();\n }\n }\n\n const { route, params } = match;\n const __uCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(__uCtx, async () => {\n ensureFetchPatch();\n try {\n const routePattern = patternToNextFormat(route.pattern);\n const renderStatusCode = renderStatusCodeOverride ?? (routePattern === \"/404\" ? 404 : undefined);\n const query = mergeRouteParamsIntoQuery(parseQuery(routeUrl), params);\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n\n const pageModule = route.module;\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n return new Response(\"Page has no default export\", { status: 500 });\n }\n\n // Refs #1463: reject non-GET/HEAD methods on static (no\n // getServerSideProps) Pages routes with 405 + Allow: GET, HEAD.\n // Skip for error/status pages (/_error, /404, /500), data requests\n // (those go through the JSON envelope path and have their own shape),\n // and renders that are already an error-page miss-render override.\n // Mirrors Next.js's base-server.ts L2277 carve-outs.\n if (\n !isDataReq &&\n routePattern !== \"/_error\" &&\n routePattern !== \"/404\" &&\n routePattern !== \"/500\" &&\n renderStatusCodeOverride === undefined\n ) {\n const methodResponse = __resolvePagesPageMethodResponse({\n hasGetServerSideProps: typeof pageModule.getServerSideProps === \"function\",\n method: request.method,\n });\n if (methodResponse) {\n return methodResponse;\n }\n }\n\n const pageModuleUrl = resolveClientModuleUrl(manifest, route.filePath);\n const appModuleUrl = resolveClientModuleUrl(manifest, _appAssetPath);\n const scriptNonce = __getScriptNonceFromHeaderSources(request.headers, middlewareHeaders);\n // Build font Link header early so it's available for ISR cached responses too.\n // Font preloads are module-level state populated at import time and persist across requests.\n var _fontLinkHeader = \"\";\n var _allFp = [];\n try {\n var _fpGoogle = typeof _getSSRFontPreloadsGoogle === \"function\" ? _getSSRFontPreloadsGoogle() : [];\n var _fpLocal = typeof _getSSRFontPreloadsLocal === \"function\" ? _getSSRFontPreloadsLocal() : [];\n _allFp = _fpGoogle.concat(_fpLocal);\n if (_allFp.length > 0) {\n _fontLinkHeader = _allFp.map(function(p) { return \"<\" + p.href + \">; rel=preload; as=font; type=\" + p.type + \"; crossorigin\"; }).join(\", \");\n }\n } catch (e) { /* font preloads not available */ }\n const pageDataResult = await __resolvePagesPageData({\n isDataReq,\n applyRequestContexts() {\n if (typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n });\n }\n if (i18nConfig) {\n setI18nContext({\n locale: locale,\n locales: i18nConfig.locales,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n hostname: new URL(request.url).hostname,\n });\n }\n },\n buildId,\n createGsspReqRes() {\n return __createPagesReqRes({ body: undefined, query, request, url: routeUrl });\n },\n createPageElement(currentPageProps) {\n var currentElement = AppComponent\n ? React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps })\n : React.createElement(PageComponent, currentPageProps);\n return wrapWithRouterContext(currentElement);\n },\n fontLinkHeader: _fontLinkHeader,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isrCacheKey,\n isrGet,\n isrSet,\n expireSeconds: vinextConfig.expireTime,\n // The vinext build phase boots the prod server with VINEXT_PRERENDER=1\n // and fetches every statically-generated page through it. That hit is\n // the \"build\" prerender for revalidateReason; runtime hits are not.\n // Mirrors Next.js's \\`renderOpts.isBuildTimePrerendering\\`. See\n // \\`.nextjs-ref/packages/next/src/server/render.tsx\\` and\n // \\`packages/vinext/src/build/prerender.ts\\`.\n isBuildTimePrerendering: typeof process !== \"undefined\" && process.env && process.env.VINEXT_PRERENDER === \"1\",\n pageModule,\n params,\n query,\n renderIsrPassToStringAsync,\n route: {\n isDynamic: route.isDynamic,\n },\n routePattern,\n routeUrl,\n runInFreshUnifiedContext(callback) {\n var revalCtx = _createUnifiedCtx({\n executionContext: _getRequestExecutionContext(),\n });\n return _runWithUnifiedCtx(revalCtx, async () => {\n ensureFetchPatch();\n return callback();\n });\n },\n safeJsonStringify,\n sanitizeDestination: sanitizeDestinationLocal,\n scriptNonce,\n statusCode: renderStatusCode,\n triggerBackgroundRegeneration,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n if (pageDataResult.kind === \"response\") {\n return pageDataResult.response;\n }\n let pageProps = pageDataResult.pageProps;\n if (routePattern === \"/_error\" && typeof renderStatusCode === \"number\") {\n pageProps = { ...pageProps, statusCode: renderStatusCode };\n }\n var gsspRes = pageDataResult.gsspRes;\n let isrRevalidateSeconds = pageDataResult.isrRevalidateSeconds;\n const isFallbackRender = pageDataResult.isFallback === true;\n\n // Republish the SSR context with isFallback flipped on so the page's\n // \\`useRouter().isFallback\\` returns true during render, matching Next.js's\n // \\`render.tsx\\` fallback shell. Without this, the page would still see\n // \\`isFallback: false\\` and run the non-fallback branch.\n if (isFallbackRender && typeof setSSRContext === \"function\") {\n setSSRContext({\n pathname: routePattern,\n query,\n asPath: renderAsPath || routeUrl,\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n isFallback: true,\n });\n }\n\n // ── _next/data JSON envelope short-circuit ───────────────────────\n // For client-side navigations Next.js fetches /_next/data/<buildId>/<page>.json\n // and expects { pageProps } as JSON instead of the full HTML page. Skip\n // rendering the React tree and emit the JSON envelope directly via the\n // typed helper so the envelope shape stays in one place. Headers and\n // cookies set on the gsspRes by getServerSideProps are forwarded so\n // middleware/auth flows work the same as the HTML page.\n if (isDataReq) {\n const init = { headers: {} };\n if (gsspRes && typeof gsspRes.getHeaders === \"function\") {\n const gsspHeaders = gsspRes.getHeaders();\n for (const k of Object.keys(gsspHeaders)) {\n const v = gsspHeaders[k];\n if (v === undefined || v === null) continue;\n init.headers[k] = Array.isArray(v) ? v.join(\", \") : String(v);\n }\n }\n if (gsspRes) {\n // Default Cache-Control for gSSP-driven _next/data responses,\n // matching Next.js's pages-handler.ts (revalidate: 0 →\n // getCacheControlHeader). Skip when gSSP already set one via\n // res.setHeader (case-insensitive). Mirrors the HTML branch in\n // pages-page-response.ts and the dev-server branch. Fixes #1461.\n var hasUserCacheControl = false;\n for (const headerKey of Object.keys(init.headers)) {\n if (headerKey.toLowerCase() === \"cache-control\") {\n hasUserCacheControl = true;\n break;\n }\n }\n if (!hasUserCacheControl) {\n init.headers[\"Cache-Control\"] =\n \"private, no-cache, no-store, max-age=0, must-revalidate\";\n }\n }\n return __buildNextDataJsonResponse(pageProps, safeJsonStringify, init);\n }\n\n // Include both the matched page module and the global _app module\n // (if present). _app is wrapped around every page in Pages Router,\n // and any CSS/JS it imports must be linked from the rendered HTML\n // so the browser actually loads it. Without _app in this list, a\n // global stylesheet imported via import \"./globals.scss\" in\n // _app.tsx never reaches the page, producing the LHF-5 symptom\n // where styled elements render with the browser default colour.\n const pageModuleIds = [];\n if (route.filePath) pageModuleIds.push(route.filePath);\n if (_appAssetPath) pageModuleIds.push(_appAssetPath);\n const assetTags = collectAssetTags(manifest, pageModuleIds, scriptNonce);\n\n return __renderPagesPageResponse({\n assetTags,\n buildId,\n clearSsrContext() {\n if (typeof setSSRContext === \"function\") setSSRContext(null);\n },\n createPageElement(currentPageProps) {\n var currentElement;\n if (AppComponent) {\n currentElement = React.createElement(AppComponent, { Component: PageComponent, pageProps: currentPageProps });\n } else {\n currentElement = React.createElement(PageComponent, currentPageProps);\n }\n return wrapWithRouterContext(currentElement);\n },\n DocumentComponent,\n flushPreloads: typeof flushPreloads === \"function\" ? flushPreloads : undefined,\n fontLinkHeader: _fontLinkHeader,\n fontPreloads: _allFp,\n getFontLinks() {\n try {\n return typeof _getSSRFontLinks === \"function\" ? _getSSRFontLinks() : [];\n } catch (e) {\n return [];\n }\n },\n getFontStyles() {\n try {\n var allFontStyles = [];\n if (typeof _getSSRFontStylesGoogle === \"function\") allFontStyles.push(..._getSSRFontStylesGoogle());\n if (typeof _getSSRFontStylesLocal === \"function\") allFontStyles.push(..._getSSRFontStylesLocal());\n return allFontStyles;\n } catch (e) {\n return [];\n }\n },\n getSSRHeadHTML: typeof getSSRHeadHTML === \"function\" ? getSSRHeadHTML : undefined,\n clientTraceMetadata: vinextConfig.clientTraceMetadata,\n gsspRes,\n isrCacheKey,\n expireSeconds: vinextConfig.expireTime,\n isrRevalidateSeconds,\n isrSet,\n i18n: {\n locale: locale,\n locales: i18nConfig ? i18nConfig.locales : undefined,\n defaultLocale: currentDefaultLocale,\n domainLocales: domainLocales,\n },\n isFallback: isFallbackRender,\n pageProps,\n params,\n renderDocumentToString(element) {\n return renderToStringAsync(element);\n },\n renderToReadableStream(element) {\n return renderToReadableStream(element);\n },\n resetSSRHead: typeof resetSSRHead === \"function\" ? resetSSRHead : undefined,\n routePattern,\n routeUrl,\n safeJsonStringify,\n scriptNonce,\n statusCode: renderStatusCode,\n vinext: {\n pageModuleUrl,\n appModuleUrl,\n hasMiddleware: __hasMiddleware,\n },\n });\n } catch (e) {\n console.error(\"[vinext] SSR error:\", e);\n _reportRequestError(\n e instanceof Error ? e : new Error(String(e)),\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: route.pattern, routeType: \"render\" },\n ).catch(() => { /* ignore reporting errors */ });\n // Data (_next/data) requests can't render HTML, and avoid recursion if\n // we're already in the middle of rendering the error page itself.\n // Mirrors Next.js base-server.ts which renders /500 (or _error) when\n // SSR throws. Fixes #1458.\n if (!isInternalErrorRender && !isDataReq) {\n // Look for an explicit pages/500.tsx first, then fall back to _error.\n // Only match the literal /500 pattern — never a catch-all/dynamic route.\n let errorRoute = null;\n for (var __i = 0; __i < pageRoutes.length; __i++) {\n if (pageRoutes[__i].pattern === \"/500\") {\n errorRoute = pageRoutes[__i];\n break;\n }\n }\n if (!errorRoute && _errorPageRoute) {\n errorRoute = _errorPageRoute;\n }\n if (errorRoute) {\n try {\n return await _renderPage(request, url, manifest, middlewareHeaders, {\n statusCode: 500,\n asPath: url,\n renderErrorPageOnMiss: false,\n __isInternalErrorRender: true,\n __forcedRoute: errorRoute,\n });\n } catch (errorPageErr) {\n console.error(\"[vinext] Error page render failed:\", errorPageErr);\n }\n }\n }\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n });\n}\n\nexport async function handleApiRoute(request, url, ctx) {\n const match = matchRoute(url, apiRoutes);\n return __handlePagesApiRoute({\n ctx,\n match,\n request,\n url,\n reportRequestError(error, routePattern) {\n console.error(\"[vinext] API error:\", error);\n void _reportRequestError(\n error,\n { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },\n { routerKind: \"Pages Router\", routePath: routePattern, routeType: \"route\" },\n );\n },\n });\n}\n\n${middlewareExportCode}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,0BAA0B,iBAAiB,+BAA+B,OAAO,KAAK,IAAI;AAChG,MAAM,yBAAyB,iBAAiB,mCAAmC,OAAO,KAAK,IAAI;AACnG,MAAM,iBAAiB,iBAAiB,4BAA4B,OAAO,KAAK,IAAI;AACpF,MAAM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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsoB5B,qBAAqB"}
@@ -1,13 +1,4 @@
1
1
  //#region src/entries/runtime-entry-module.d.ts
2
- /**
3
- * Convert Windows-style backslash path separators to forward slashes.
4
- *
5
- * Generated entry modules embed absolute filesystem paths inside `import`
6
- * statements. On Windows the OS-native paths use `\` which is invalid in JS
7
- * module specifiers, so every entry generator normalizes paths through this
8
- * helper before stringifying them into the emitted code.
9
- */
10
- declare function normalizePathSeparators(p: string): string;
11
2
  /**
12
3
  * Resolve a sibling module path relative to a caller's `import.meta.url`,
13
4
  * returning a forward-slash path safe for embedding in generated code.
@@ -31,5 +22,5 @@ declare function resolveEntryPath(rel: string, base: string): string;
31
22
  declare function resolveRuntimeEntryModule(name: string): string;
32
23
  declare function resolveClientRuntimeModule(name: string): string;
33
24
  //#endregion
34
- export { normalizePathSeparators, resolveClientRuntimeModule, resolveEntryPath, resolveRuntimeEntryModule };
25
+ export { resolveClientRuntimeModule, resolveEntryPath, resolveRuntimeEntryModule };
35
26
  //# sourceMappingURL=runtime-entry-module.d.ts.map
@@ -1,18 +1,8 @@
1
+ import { normalizePathSeparators } from "../utils/path.js";
1
2
  import fs from "node:fs";
2
3
  import { fileURLToPath } from "node:url";
3
4
  //#region src/entries/runtime-entry-module.ts
4
5
  /**
5
- * Convert Windows-style backslash path separators to forward slashes.
6
- *
7
- * Generated entry modules embed absolute filesystem paths inside `import`
8
- * statements. On Windows the OS-native paths use `\` which is invalid in JS
9
- * module specifiers, so every entry generator normalizes paths through this
10
- * helper before stringifying them into the emitted code.
11
- */
12
- function normalizePathSeparators(p) {
13
- return p.replace(/\\/g, "/");
14
- }
15
- /**
16
6
  * Resolve a sibling module path relative to a caller's `import.meta.url`,
17
7
  * returning a forward-slash path safe for embedding in generated code.
18
8
  *
@@ -53,6 +43,6 @@ function resolveRuntimeModulePath(directory, name) {
53
43
  return resolveEntryPath(`../${directory}/${name}.js`, import.meta.url);
54
44
  }
55
45
  //#endregion
56
- export { normalizePathSeparators, resolveClientRuntimeModule, resolveEntryPath, resolveRuntimeEntryModule };
46
+ export { resolveClientRuntimeModule, resolveEntryPath, resolveRuntimeEntryModule };
57
47
 
58
48
  //# sourceMappingURL=runtime-entry-module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-entry-module.js","names":[],"sources":["../../src/entries/runtime-entry-module.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Convert Windows-style backslash path separators to forward slashes.\n *\n * Generated entry modules embed absolute filesystem paths inside `import`\n * statements. On Windows the OS-native paths use `\\` which is invalid in JS\n * module specifiers, so every entry generator normalizes paths through this\n * helper before stringifying them into the emitted code.\n */\nexport function normalizePathSeparators(p: string): string {\n return p.replace(/\\\\/g, \"/\");\n}\n\n/**\n * Resolve a sibling module path relative to a caller's `import.meta.url`,\n * returning a forward-slash path safe for embedding in generated code.\n *\n * This is the single place that owns the\n * `fileURLToPath(new URL(rel, base))` + path-separator normalization idiom so\n * callers don't duplicate it.\n *\n * @param rel - Relative path to the target module (e.g. `\"../server/foo.js\"`)\n * @param base - The caller's `import.meta.url`\n */\nexport function resolveEntryPath(rel: string, base: string): string {\n return normalizePathSeparators(fileURLToPath(new URL(rel, base)));\n}\n\n/**\n * Resolve a real runtime module for a virtual entry generator.\n *\n * During local development we want to point at source files (for example `.ts`),\n * while packed builds only contain emitted `.js` files in `dist/`. Probe the\n * common source/build extensions and fall back to the `.js` path that exists in\n * published packages.\n */\nexport function resolveRuntimeEntryModule(name: string): string {\n return resolveRuntimeModulePath(\"server\", name);\n}\n\nexport function resolveClientRuntimeModule(name: string): string {\n return resolveRuntimeModulePath(\"client\", name);\n}\n\nfunction resolveRuntimeModulePath(directory: \"client\" | \"server\", name: string): string {\n for (const ext of [\".ts\", \".js\", \".mts\", \".mjs\"]) {\n const filePath = resolveEntryPath(`../${directory}/${name}${ext}`, import.meta.url);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n }\n\n return resolveEntryPath(`../${directory}/${name}.js`, import.meta.url);\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,wBAAwB,GAAmB;CACzD,OAAO,EAAE,QAAQ,OAAO,IAAI;;;;;;;;;;;;;AAc9B,SAAgB,iBAAiB,KAAa,MAAsB;CAClE,OAAO,wBAAwB,cAAc,IAAI,IAAI,KAAK,KAAK,CAAC,CAAC;;;;;;;;;;AAWnE,SAAgB,0BAA0B,MAAsB;CAC9D,OAAO,yBAAyB,UAAU,KAAK;;AAGjD,SAAgB,2BAA2B,MAAsB;CAC/D,OAAO,yBAAyB,UAAU,KAAK;;AAGjD,SAAS,yBAAyB,WAAgC,MAAsB;CACtF,KAAK,MAAM,OAAO;EAAC;EAAO;EAAO;EAAQ;EAAO,EAAE;EAChD,MAAM,WAAW,iBAAiB,MAAM,UAAU,GAAG,OAAO,OAAO,OAAO,KAAK,IAAI;EACnF,IAAI,GAAG,WAAW,SAAS,EACzB,OAAO;;CAIX,OAAO,iBAAiB,MAAM,UAAU,GAAG,KAAK,MAAM,OAAO,KAAK,IAAI"}
1
+ {"version":3,"file":"runtime-entry-module.js","names":[],"sources":["../../src/entries/runtime-entry-module.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { normalizePathSeparators } from \"../utils/path.js\";\n\n/**\n * Resolve a sibling module path relative to a caller's `import.meta.url`,\n * returning a forward-slash path safe for embedding in generated code.\n *\n * This is the single place that owns the\n * `fileURLToPath(new URL(rel, base))` + path-separator normalization idiom so\n * callers don't duplicate it.\n *\n * @param rel - Relative path to the target module (e.g. `\"../server/foo.js\"`)\n * @param base - The caller's `import.meta.url`\n */\nexport function resolveEntryPath(rel: string, base: string): string {\n return normalizePathSeparators(fileURLToPath(new URL(rel, base)));\n}\n\n/**\n * Resolve a real runtime module for a virtual entry generator.\n *\n * During local development we want to point at source files (for example `.ts`),\n * while packed builds only contain emitted `.js` files in `dist/`. Probe the\n * common source/build extensions and fall back to the `.js` path that exists in\n * published packages.\n */\nexport function resolveRuntimeEntryModule(name: string): string {\n return resolveRuntimeModulePath(\"server\", name);\n}\n\nexport function resolveClientRuntimeModule(name: string): string {\n return resolveRuntimeModulePath(\"client\", name);\n}\n\nfunction resolveRuntimeModulePath(directory: \"client\" | \"server\", name: string): string {\n for (const ext of [\".ts\", \".js\", \".mts\", \".mjs\"]) {\n const filePath = resolveEntryPath(`../${directory}/${name}${ext}`, import.meta.url);\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n }\n\n return resolveEntryPath(`../${directory}/${name}.js`, import.meta.url);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,iBAAiB,KAAa,MAAsB;CAClE,OAAO,wBAAwB,cAAc,IAAI,IAAI,KAAK,KAAK,CAAC,CAAC;;;;;;;;;;AAWnE,SAAgB,0BAA0B,MAAsB;CAC9D,OAAO,yBAAyB,UAAU,KAAK;;AAGjD,SAAgB,2BAA2B,MAAsB;CAC/D,OAAO,yBAAyB,UAAU,KAAK;;AAGjD,SAAS,yBAAyB,WAAgC,MAAsB;CACtF,KAAK,MAAM,OAAO;EAAC;EAAO;EAAO;EAAQ;EAAO,EAAE;EAChD,MAAM,WAAW,iBAAiB,MAAM,UAAU,GAAG,OAAO,OAAO,OAAO,KAAK,IAAI;EACnF,IAAI,GAAG,WAAW,SAAS,EACzB,OAAO;;CAIX,OAAO,iBAAiB,MAAM,UAAU,GAAG,KAAK,MAAM,OAAO,KAAK,IAAI"}
package/dist/index.js CHANGED
@@ -1,23 +1,24 @@
1
1
  import { detectPackageManager } from "./utils/project.js";
2
2
  import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
3
- import { createValidFileMatcher } from "./routing/file-matcher.js";
3
+ import { buildViteResolveExtensions, createValidFileMatcher } from "./routing/file-matcher.js";
4
4
  import { hasBasePath } from "./utils/base-path.js";
5
5
  import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
6
- import { INTERNAL_HEADERS, VINEXT_MW_CTX_HEADER, VINEXT_TIMING_HEADER } from "./server/headers.js";
6
+ import { INTERNAL_HEADERS, VINEXT_INTERNAL_HEADERS, VINEXT_MW_CTX_HEADER, VINEXT_TIMING_HEADER } from "./server/headers.js";
7
7
  import { buildRequestHeadersFromMiddlewareResponse } from "./server/middleware-request-headers.js";
8
8
  import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
9
9
  import { isExternalUrl, matchHeaders, matchRedirect, matchRewrite, proxyExternalRequest, requestContextFromRequest, sanitizeDestination } from "./config/config-matchers.js";
10
10
  import { filterInternalHeaders, isOpenRedirectShaped, normalizeTrailingSlash } from "./server/request-pipeline.js";
11
- import { mergeRewriteQuery } from "./utils/query.js";
12
11
  import { findMiddlewareFile, runMiddleware } from "./server/middleware.js";
13
12
  import { generateServerEntry } from "./entries/pages-server-entry.js";
14
13
  import { generateClientEntry } from "./entries/pages-client-entry.js";
15
14
  import { appRouteGraph, appRouter, invalidateAppRouteCache } from "./routing/app-router.js";
16
15
  import { findInstrumentationClientFile, findInstrumentationFile, runInstrumentation } from "./server/instrumentation.js";
16
+ import { mergeRewriteQuery } from "./utils/query.js";
17
17
  import { logRequest, now } from "./server/request-log.js";
18
18
  import { normalizeDefaultLocalePathname, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
19
19
  import { createSSRHandler } from "./server/dev-server.js";
20
20
  import { handleApiRoute } from "./server/api-handler.js";
21
+ import { isImageOptimizationPath } from "./server/image-optimization.js";
21
22
  import { installSocketErrorBackstop } from "./server/socket-error-backstop.js";
22
23
  import { scanMetadataFiles } from "./server/metadata-routes.js";
23
24
  import { shouldInvalidateAppRouteFile } from "./server/dev-route-files.js";
@@ -25,7 +26,7 @@ import { createDirectRunner } from "./server/dev-module-runner.js";
25
26
  import { validateDevRequest } from "./server/dev-origin-check.js";
26
27
  import { generateRscEntry } from "./entries/app-rsc-entry.js";
27
28
  import { generateSsrEntry } from "./entries/app-ssr-entry.js";
28
- import { generateBrowserEntry } from "./entries/app-browser-entry.js";
29
+ import { generateBrowserEntry, isLinkPrefetchRoute, toLinkPrefetchRoute } from "./entries/app-browser-entry.js";
29
30
  import { collectRouteClassificationManifest } from "./build/route-classification-manifest.js";
30
31
  import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
31
32
  import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
@@ -34,12 +35,14 @@ import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsP
34
35
  import { findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
35
36
  import { isNextDataPathname, parseNextDataPathname } from "./server/pages-data-route.js";
36
37
  import { precompressAssets } from "./build/precompress.js";
38
+ import { collectInlineCssManifest, injectInlineCssManifestGlobal } from "./build/inline-css.js";
37
39
  import { manifestFileWithBase, manifestFilesWithBase } from "./utils/manifest-paths.js";
38
40
  import { asyncHooksStubPlugin } from "./plugins/async-hooks-stub.js";
39
41
  import { clientReferenceDedupPlugin } from "./plugins/client-reference-dedup.js";
40
42
  import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
41
43
  import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
42
44
  import { createInstrumentationClientTransformPlugin } from "./plugins/instrumentation-client.js";
45
+ import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
43
46
  import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
44
47
  import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
45
48
  import { createOgInlineFetchAssetsPlugin, ogAssetsPlugin } from "./plugins/og-assets.js";
@@ -53,6 +56,7 @@ import { buildSassPreprocessorOptions } from "./plugins/sass.js";
53
56
  import { createClientCodeSplittingConfig, createClientManualChunks, createClientOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfigForVite, withBuildBundlerOptions } from "./build/client-build-config.js";
54
57
  import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
55
58
  import { stripServerExports } from "./plugins/strip-server-exports.js";
59
+ import { removeConsoleCalls } from "./plugins/remove-console.js";
56
60
  import { hasMdxFiles } from "./utils/mdx-scan.js";
57
61
  import { scanPublicFileRoutes } from "./utils/public-routes.js";
58
62
  import { staticExportApp, staticExportPages } from "./build/static-export.js";
@@ -255,6 +259,9 @@ const RESOLVED_APP_SSR_ENTRY = "\0" + VIRTUAL_APP_SSR_ENTRY;
255
259
  const VIRTUAL_APP_BROWSER_ENTRY = "virtual:vinext-app-browser-entry";
256
260
  const RESOLVED_APP_BROWSER_ENTRY = "\0" + VIRTUAL_APP_BROWSER_ENTRY;
257
261
  const RESOLVED_ROOT_PARAMS = "\0virtual:vinext-root-params";
262
+ /** Virtual module for composed instrumentation-client bootstrap. */
263
+ const VIRTUAL_INSTRUMENTATION_CLIENT = "private-next-instrumentation-client";
264
+ const RESOLVED_INSTRUMENTATION_CLIENT = `\0${VIRTUAL_INSTRUMENTATION_CLIENT}.mjs`;
258
265
  /** Image file extensions handled by the vinext:image-imports plugin.
259
266
  * Shared between the Rolldown hook filter and the transform handler regex. */
260
267
  const IMAGE_EXTS = "png|jpe?g|gif|webp|avif|svg|ico|bmp|tiff?";
@@ -353,10 +360,12 @@ function vinext(options = {}) {
353
360
  let middlewarePath = null;
354
361
  let instrumentationPath = null;
355
362
  let instrumentationClientPath = null;
363
+ let clientInjectModule = null;
356
364
  let hasCloudflarePlugin = false;
357
365
  let warnedInlineNextConfigOverride = false;
358
366
  let hasNitroPlugin = false;
359
367
  let rscCompatibilityId;
368
+ const draftModeSecret = randomUUID();
360
369
  let rscClassificationManifest = null;
361
370
  const shimsDir = path.resolve(__dirname, "shims");
362
371
  const canonicalize = (p) => tryRealpathSync(p) ?? p;
@@ -382,7 +391,8 @@ function vinext(options = {}) {
382
391
  * __NEXT_DATA__ to determine which page to hydrate.
383
392
  */
384
393
  async function generateClientEntry$1() {
385
- return generateClientEntry(pagesDir, nextConfig, fileMatcher);
394
+ const appPrefetchRoutes = hasAppDir ? (await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher)).filter(isLinkPrefetchRoute).map(toLinkPrefetchRoute) : [];
395
+ return generateClientEntry(pagesDir, nextConfig, fileMatcher, { appPrefetchRoutes });
386
396
  }
387
397
  async function writeRouteTypes() {
388
398
  if (!hasAppDir) return;
@@ -536,6 +546,8 @@ function vinext(options = {}) {
536
546
  instrumentationPath = findInstrumentationFile(root, fileMatcher);
537
547
  instrumentationClientPath = findInstrumentationClientFile(root, fileMatcher);
538
548
  middlewarePath = findMiddlewareFile(root, fileMatcher);
549
+ const instrumentationClientInjects = nextConfig.instrumentationClientInject.map((spec) => spec.startsWith("./") || spec.startsWith("../") ? path.resolve(root, spec) : spec);
550
+ clientInjectModule = instrumentationClientInjects.length ? generateInstrumentationClientInjectModule(instrumentationClientInjects, instrumentationClientPath, INSTRUMENTATION_CLIENT_EMPTY_MODULE) : null;
539
551
  if (env?.command === "build") await writeRouteTypes();
540
552
  const defines = getNextPublicEnvDefines();
541
553
  if (!config.define || typeof config.define !== "object" || !("process.env.NODE_ENV" in config.define)) defines["process.env.NODE_ENV"] = JSON.stringify(resolvedNodeEnv);
@@ -544,6 +556,7 @@ function vinext(options = {}) {
544
556
  defines[`process.env.${key}`] = JSON.stringify(value);
545
557
  }
546
558
  defines["process.env.__NEXT_ROUTER_BASEPATH"] = JSON.stringify(nextConfig.basePath);
559
+ defines["process.env.__NEXT_CLIENT_ROUTER_STATIC_STALETIME"] = JSON.stringify(String(nextConfig.staleTimes.static));
547
560
  defines["process.env.__VINEXT_TRAILING_SLASH"] = JSON.stringify(nextConfig.trailingSlash ? "true" : "false");
548
561
  defines["process.env.__VINEXT_IMAGE_REMOTE_PATTERNS"] = JSON.stringify(JSON.stringify(nextConfig.images?.remotePatterns ?? []));
549
562
  defines["process.env.__VINEXT_IMAGE_DOMAINS"] = JSON.stringify(JSON.stringify(nextConfig.images?.domains ?? []));
@@ -573,12 +586,17 @@ function vinext(options = {}) {
573
586
  }
574
587
  defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_SVG"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowSVG ?? false));
575
588
  defines["process.env.__VINEXT_IMAGE_DANGEROUSLY_ALLOW_LOCAL_IP"] = JSON.stringify(String(nextConfig.images?.dangerouslyAllowLocalIP ?? false));
576
- defines["process.env.__VINEXT_DRAFT_SECRET"] = JSON.stringify(crypto.randomUUID());
577
589
  defines["process.env.__VINEXT_BUILD_ID"] = JSON.stringify(nextConfig.buildId);
578
590
  defines["process.env.__VINEXT_RSC_COMPATIBILITY_ID"] = JSON.stringify(rscCompatibilityId);
579
591
  defines["process.env.__VINEXT_DEPLOYMENT_ID"] = JSON.stringify(nextConfig.deploymentId ?? "");
592
+ defines["process.env.NEXT_DEPLOYMENT_ID"] = nextConfig.deploymentId ? JSON.stringify(nextConfig.deploymentId) : "false";
580
593
  defines["process.env.__NEXT_VERSION"] = JSON.stringify(getVinextVersion());
581
594
  defines["process.env.__NEXT_APP_SHELLS"] = JSON.stringify(false);
595
+ for (const [key, value] of Object.entries(nextConfig.compilerDefine)) {
596
+ if (key in defines) throw new Error(`The \`compiler.define\` option is configured to replace the \`${key}\` variable. This variable is either part of a built-in or is already configured.`);
597
+ defines[key] = value;
598
+ }
599
+ for (const key of Object.keys(nextConfig.compilerDefineServer)) if (key in defines) throw new Error(`The \`compiler.defineServer\` option is configured to replace the \`${key}\` variable. This variable is either part of a built-in or is already configured.`);
582
600
  nextShimMap = Object.fromEntries(Object.entries({
583
601
  "next/link": path.join(shimsDir, "link"),
584
602
  "next/head": path.join(shimsDir, "head"),
@@ -634,7 +652,7 @@ function vinext(options = {}) {
634
652
  "vinext/instrumentation": path.resolve(__dirname, "server", "instrumentation"),
635
653
  "vinext/instrumentation-client": path.resolve(__dirname, "client", "instrumentation-client"),
636
654
  "vinext/html": path.resolve(__dirname, "server", "html"),
637
- "private-next-instrumentation-client": instrumentationClientPath ?? path.resolve(__dirname, "client", "empty-module")
655
+ ...clientInjectModule === null ? { "private-next-instrumentation-client": instrumentationClientPath ?? INSTRUMENTATION_CLIENT_EMPTY_MODULE } : {}
638
656
  }).flatMap(([k, v]) => k.startsWith("next/") ? [[k, v], [`${k}.js`, v]] : [[k, v]]));
639
657
  const pluginsFlat = [];
640
658
  function flattenPlugins(arr) {
@@ -696,6 +714,7 @@ function vinext(options = {}) {
696
714
  ...nextConfig.aliases,
697
715
  ...nextShimMap
698
716
  },
717
+ extensions: buildViteResolveExtensions(nextConfig.pageExtensions),
699
718
  dedupe: [
700
719
  "react",
701
720
  "react-dom",
@@ -915,12 +934,16 @@ function vinext(options = {}) {
915
934
  allowedOrigins: nextConfig?.serverActionsAllowedOrigins,
916
935
  allowedDevOrigins: nextConfig?.allowedDevOrigins,
917
936
  bodySizeLimit: nextConfig?.serverActionsBodySizeLimit,
937
+ htmlLimitedBots: nextConfig?.htmlLimitedBots,
938
+ clientTraceMetadata: nextConfig?.clientTraceMetadata,
918
939
  assetPrefix: nextConfig?.assetPrefix,
919
940
  expireTime: nextConfig?.expireTime,
941
+ inlineCss: nextConfig?.inlineCss,
920
942
  i18n: nextConfig?.i18n,
921
943
  hasPagesDir,
922
944
  publicFiles: scanPublicFileRoutes(root),
923
- globalNotFoundPath
945
+ globalNotFoundPath,
946
+ draftModeSecret
924
947
  }, instrumentationPath);
925
948
  }
926
949
  if (id === RESOLVED_ROOT_PARAMS) return generateRootParamsModule((hasAppDir ? await appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : []).flatMap((route) => route.rootParamNames ?? []));
@@ -971,6 +994,18 @@ function vinext(options = {}) {
971
994
  },
972
995
  asyncHooksStubPlugin,
973
996
  createInstrumentationClientTransformPlugin(() => instrumentationClientPath),
997
+ {
998
+ name: "vinext:instrumentation-client-inject",
999
+ enforce: "pre",
1000
+ resolveId(id) {
1001
+ if (id !== VIRTUAL_INSTRUMENTATION_CLIENT) return null;
1002
+ return clientInjectModule !== null ? RESOLVED_INSTRUMENTATION_CLIENT : null;
1003
+ },
1004
+ load(id) {
1005
+ if (id !== RESOLVED_INSTRUMENTATION_CLIENT) return null;
1006
+ return clientInjectModule;
1007
+ }
1008
+ },
974
1009
  ...options.experimental?.clientReferenceDedup ? [clientReferenceDedupPlugin()] : [],
975
1010
  {
976
1011
  name: "vinext:mdx",
@@ -1195,7 +1230,7 @@ function vinext(options = {}) {
1195
1230
  res.end("Forbidden");
1196
1231
  return;
1197
1232
  }
1198
- if (url.split("?")[0] === "/_vinext/image") {
1233
+ if (isImageOptimizationPath(url.split("?")[0])) {
1199
1234
  const rawImgUrl = new URLSearchParams(url.split("?")[1] ?? "").get("url");
1200
1235
  const imgUrl = rawImgUrl?.replaceAll("\\", "/") ?? null;
1201
1236
  if (!imgUrl || !imgUrl.startsWith("/") || imgUrl.startsWith("//") || imgUrl.startsWith("/@") || imgUrl.startsWith("/__vite") || imgUrl.startsWith("/node_modules")) {
@@ -1269,6 +1304,7 @@ function vinext(options = {}) {
1269
1304
  const isDataRequest = rawHeaders.get("x-nextjs-data") === "1";
1270
1305
  const nodeRequestHeaders = filterInternalHeaders(rawHeaders);
1271
1306
  for (const header of INTERNAL_HEADERS) delete req.headers[header];
1307
+ for (const header of VINEXT_INTERNAL_HEADERS) delete req.headers[header];
1272
1308
  const requestOrigin = `http://${req.headers.host || "localhost"}`;
1273
1309
  const preMiddlewareReqUrl = new URL(url, requestOrigin);
1274
1310
  const preMiddlewareReqCtx = requestContextFromRequest(new Request(preMiddlewareReqUrl, { headers: nodeRequestHeaders }));
@@ -1392,7 +1428,7 @@ function vinext(options = {}) {
1392
1428
  await proxyExternalRewriteNode(req, res, resolvedUrl);
1393
1429
  return;
1394
1430
  }
1395
- const handler = createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false);
1431
+ const handler = createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, nextConfig?.clientTraceMetadata);
1396
1432
  const mwStatus = req.__vinextMiddlewareStatus;
1397
1433
  if (match) {
1398
1434
  applyDeferredMwHeaders();
@@ -1448,6 +1484,32 @@ function vinext(options = {}) {
1448
1484
  }
1449
1485
  }
1450
1486
  },
1487
+ {
1488
+ name: "vinext:remove-console",
1489
+ apply: "build",
1490
+ transform: {
1491
+ filter: { id: /\.(tsx?|jsx?|mjs)$/ },
1492
+ handler(code, id) {
1493
+ if (this.environment?.name !== "client") return null;
1494
+ if (!nextConfig.removeConsole) return null;
1495
+ if (id.includes("/node_modules/")) return null;
1496
+ const result = removeConsoleCalls(code, nextConfig.removeConsole);
1497
+ if (!result) return null;
1498
+ return {
1499
+ code: result,
1500
+ map: null
1501
+ };
1502
+ }
1503
+ }
1504
+ },
1505
+ {
1506
+ name: "vinext:compiler-define-server",
1507
+ configEnvironment(name) {
1508
+ if (Object.keys(nextConfig.compilerDefineServer).length === 0) return null;
1509
+ if (name === "client") return null;
1510
+ return { define: { ...nextConfig.compilerDefineServer } };
1511
+ }
1512
+ },
1451
1513
  {
1452
1514
  name: "vinext:image-imports",
1453
1515
  enforce: "pre",
@@ -1795,6 +1857,25 @@ function vinext(options = {}) {
1795
1857
  }
1796
1858
  };
1797
1859
  })(),
1860
+ {
1861
+ name: "vinext:inline-css-manifest",
1862
+ apply: "build",
1863
+ enforce: "post",
1864
+ closeBundle: {
1865
+ sequential: true,
1866
+ order: "post",
1867
+ handler() {
1868
+ if (this.environment?.name !== "client") return;
1869
+ if (!hasAppDir || nextConfig?.inlineCss !== true) return;
1870
+ const envConfig = this.environment?.config;
1871
+ if (!envConfig) return;
1872
+ const buildRoot = envConfig.root ?? process.cwd();
1873
+ const manifest = collectInlineCssManifest(path.resolve(buildRoot, "dist", "client"), nextConfig.assetPrefix);
1874
+ const rscOutDir = path.resolve(buildRoot, options.rscOutDir ?? path.join("dist", "server"));
1875
+ for (const entryFile of ["index.js", "index.mjs"]) if (injectInlineCssManifestGlobal(path.join(rscOutDir, entryFile), manifest)) break;
1876
+ }
1877
+ }
1878
+ },
1798
1879
  {
1799
1880
  name: "vinext:cloudflare-build",
1800
1881
  apply: "build",