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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages-body-parser-config.js","names":[],"sources":["../../src/server/pages-body-parser-config.ts"],"sourcesContent":["/**\n * Resolve the Pages Router `api.bodyParser` config from a route module export.\n *\n * Next.js API routes can opt out of automatic body parsing or raise the\n * default 1 MB size limit:\n *\n * export const config = { api: { bodyParser: false } };\n * export const config = { api: { bodyParser: { sizeLimit: '4mb' } } };\n *\n * `bodyParser: false` is critical for webhook handlers (Stripe, GitHub,\n * Slack, etc.) that must read the raw request bytes to verify an HMAC\n * signature. Silently parsing the body would consume the stream and break\n * signature verification — usually failing closed, sometimes failing open.\n *\n * @see https://nextjs.org/docs/pages/building-your-application/routing/api-routes#custom-config\n * @see Next.js: packages/next/src/server/api-utils/node/api-resolver.ts\n *\n * The format of `sizeLimit` mirrors what Next.js accepts via the `bytes`\n * package: a number of bytes, or a string with a unit suffix\n * (`\"500b\"`, `\"100kb\"`, `\"4mb\"`, `\"1gb\"`).\n */\n\n/**\n * Default Pages Router API body size limit, matching Next.js.\n */\nexport const DEFAULT_PAGES_API_BODY_SIZE_LIMIT = 1 * 1024 * 1024;\n\n/**\n * Resolved bodyParser configuration. When `enabled` is `false`, the body\n * MUST be passed through to the handler as a raw stream (or left unparsed\n * with `req.body === undefined`), so user code can read it itself.\n */\ntype ResolvedBodyParserConfig = { enabled: false } | { enabled: true; sizeLimit: number };\n\nconst SIZE_UNITS: Record<string, number> = {\n b: 1,\n kb: 1024,\n mb: 1024 * 1024,\n gb: 1024 * 1024 * 1024,\n tb: 1024 * 1024 * 1024 * 1024,\n};\n\n/**\n * Parse a Next.js-style `sizeLimit` string (e.g. `\"4mb\"`, `\"100kb\"`, `\"1gb\"`)\n * or numeric byte value into a number of bytes. Returns `undefined` for\n * inputs that can't be parsed — callers should fall back to the default.\n *\n * Matches the format accepted by Next.js (the `bytes` package); we\n * implement it inline to avoid pulling a dependency for a tiny parser.\n */\nexport function parseSizeLimit(value: string | number | undefined): number | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === \"number\") {\n return Number.isFinite(value) && value >= 0 ? value : undefined;\n }\n if (typeof value !== \"string\") return undefined;\n\n const trimmed = value.trim().toLowerCase();\n if (!trimmed) return undefined;\n\n // Match `<number><unit?>` where number can be int/decimal and unit is one\n // of b/kb/mb/gb/tb. The unit is optional — a bare number is bytes.\n const match = /^(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb|tb)?$/.exec(trimmed);\n if (!match) return undefined;\n\n const amount = Number.parseFloat(match[1]);\n if (!Number.isFinite(amount) || amount < 0) return undefined;\n\n const unit = match[2] ?? \"b\";\n const multiplier = SIZE_UNITS[unit];\n if (multiplier === undefined) return undefined;\n\n return Math.floor(amount * multiplier);\n}\n\n/**\n * Read the resolved `bodyParser` config from a route module's `config`\n * export. Defaults to enabled with the 1 MB Next.js default.\n */\nexport function resolveBodyParserConfig(\n moduleConfig: { api?: { bodyParser?: boolean | { sizeLimit?: string | number } } } | undefined,\n defaultSizeLimit: number = DEFAULT_PAGES_API_BODY_SIZE_LIMIT,\n): ResolvedBodyParserConfig {\n const bodyParser = moduleConfig?.api?.bodyParser;\n\n // Explicit opt-out: leave the body untouched so handlers can read raw bytes.\n if (bodyParser === false) {\n return { enabled: false };\n }\n\n // `true` or `undefined` → default behaviour.\n if (bodyParser === undefined || bodyParser === true) {\n return { enabled: true, sizeLimit: defaultSizeLimit };\n }\n\n // Object form: honour `sizeLimit` if present and parseable, else default.\n if (typeof bodyParser === \"object\" && bodyParser !== null) {\n const parsed = parseSizeLimit(bodyParser.sizeLimit);\n return { enabled: true, sizeLimit: parsed ?? defaultSizeLimit };\n }\n\n // Anything else (truthy non-object/non-true) — be conservative and use\n // the default, matching Next.js's `!== false` check.\n return { enabled: true, sizeLimit: defaultSizeLimit };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,oCAAoC,IAAI,OAAO;AAS5D,MAAM,aAAqC;CACzC,GAAG;CACH,IAAI;CACJ,IAAI,OAAO;CACX,IAAI,OAAO,OAAO;CAClB,IAAI,OAAO,OAAO,OAAO;CAC1B;;;;;;;;;AAUD,SAAgB,eAAe,OAAwD;CACrF,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,KAAA;CAClD,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS,IAAI,QAAQ,KAAA;CAExD,IAAI,OAAO,UAAU,UAAU,OAAO,KAAA;CAEtC,MAAM,UAAU,MAAM,MAAM,CAAC,aAAa;CAC1C,IAAI,CAAC,SAAS,OAAO,KAAA;CAIrB,MAAM,QAAQ,uCAAuC,KAAK,QAAQ;CAClE,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,SAAS,OAAO,WAAW,MAAM,GAAG;CAC1C,IAAI,CAAC,OAAO,SAAS,OAAO,IAAI,SAAS,GAAG,OAAO,KAAA;CAGnD,MAAM,aAAa,WADN,MAAM,MAAM;CAEzB,IAAI,eAAe,KAAA,GAAW,OAAO,KAAA;CAErC,OAAO,KAAK,MAAM,SAAS,WAAW;;;;;;AAOxC,SAAgB,wBACd,cACA,mBAA2B,mCACD;CAC1B,MAAM,aAAa,cAAc,KAAK;CAGtC,IAAI,eAAe,OACjB,OAAO,EAAE,SAAS,OAAO;CAI3B,IAAI,eAAe,KAAA,KAAa,eAAe,MAC7C,OAAO;EAAE,SAAS;EAAM,WAAW;EAAkB;CAIvD,IAAI,OAAO,eAAe,YAAY,eAAe,MAEnD,OAAO;EAAE,SAAS;EAAM,WADT,eAAe,WAAW,UACA,IAAI;EAAkB;CAKjE,OAAO;EAAE,SAAS;EAAM,WAAW;EAAkB"}
@@ -53,6 +53,7 @@ function parseNextDataPathname(pathname, buildId) {
53
53
  if (rest.length === 0) return null;
54
54
  if (rest === "index") return { pagePathname: "/" };
55
55
  if (rest.endsWith("/index")) return { pagePathname: `/${rest.slice(0, -6)}` };
56
+ if (rest.startsWith("index/")) return { pagePathname: `/${rest.slice(6)}` };
56
57
  return { pagePathname: `/${rest}` };
57
58
  }
58
59
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pages-data-route.js","names":[],"sources":["../../src/server/pages-data-route.ts"],"sourcesContent":["/**\n * Helpers for the Pages Router `/_next/data/{buildId}/{...page}.json` endpoint.\n *\n * Next.js uses this endpoint for client-side navigations in the Pages Router:\n * `next/link` and `router.push()` fetch `pageProps` from this URL instead of\n * doing a full HTML navigation. The server must:\n * 1. Match the URL pattern and extract the page pathname (with the buildId\n * and `.json` extension removed, locale prefix preserved).\n * 2. Normalize the URL BEFORE middleware runs so middleware sees the page\n * path (e.g. `/about`) rather than the raw `/_next/data/.../about.json`.\n * 3. Invoke the same `getServerSideProps` / `getStaticProps` machinery as\n * the HTML page and serialize the resulting props as a JSON envelope:\n * `{ pageProps: ... }` with `Content-Type: application/json`.\n *\n * Ported from Next.js:\n * - `packages/next/src/server/normalizers/request/next-data.ts` — prefix/suffix matcher.\n * - `packages/next/src/server/base-server.ts` (`handleNextDataRequest`) — pipeline normalization.\n * - `packages/next/src/server/render.tsx` — JSON envelope emission (`isNextDataRequest`).\n */\n\nconst NEXT_DATA_PREFIX = \"/_next/data/\";\nconst NEXT_DATA_SUFFIX = \".json\";\n\ntype NextDataMatch = {\n /**\n * The normalized page pathname (with leading slash, no trailing slash,\n * `.json` stripped, buildId stripped). For locale-prefixed requests like\n * `/_next/data/<buildId>/en/about.json` this is `/en/about` — locale\n * handling is done downstream by the existing `resolvePagesI18nRequest`\n * pipeline so this helper does not need to know about i18n config.\n */\n pagePathname: string;\n};\n\n/**\n * Returns true if the pathname looks like a `_next/data` request, regardless\n * of buildId. Used by the request pipeline to short-circuit before middleware\n * even when the buildId is wrong (so we can still return a 404 JSON response).\n */\nexport function isNextDataPathname(pathname: string): boolean {\n return pathname.startsWith(NEXT_DATA_PREFIX) && pathname.endsWith(NEXT_DATA_SUFFIX);\n}\n\n/**\n * Parse `/_next/data/<buildId>/<...page>.json` and return the normalized page\n * pathname. Returns `null` if the pathname does not match the pattern or if\n * the buildId segment does not match the server's buildId.\n *\n * The returned `pagePathname` is the page route path Next.js would render for\n * the equivalent HTML navigation — including any locale prefix, which is then\n * stripped by `resolvePagesI18nRequest` downstream.\n *\n * `/_next/data/<buildId>/about.json` → `/about`\n * `/_next/data/<buildId>/en/about.json` → `/en/about`\n * `/_next/data/<buildId>/index.json` → `/`\n * `/_next/data/<buildId>/en.json` → `/en`\n * `/_next/data/<wrong-id>/about.json` → null\n * `/_next/data/<buildId>/about` → null (missing .json suffix)\n */\nexport function parseNextDataPathname(pathname: string, buildId: string): NextDataMatch | null {\n if (!buildId) return null;\n if (!isNextDataPathname(pathname)) return null;\n\n const expectedPrefix = `${NEXT_DATA_PREFIX}${buildId}/`;\n // `/_next/data/<buildId>.json` (no trailing slash) is not a valid data req.\n if (!pathname.startsWith(expectedPrefix)) return null;\n\n const rest = pathname.slice(expectedPrefix.length, -NEXT_DATA_SUFFIX.length);\n\n // Empty rest (`/_next/data/<buildId>/.json`) is not a valid page path.\n if (rest.length === 0) return null;\n\n // Next.js denormalizes `index` to `/` to mirror file-system page paths\n // (`pages/index.tsx` → `/`). See `denormalizePagePath` in Next.js.\n if (rest === \"index\") return { pagePathname: \"/\" };\n if (rest.endsWith(\"/index\")) return { pagePathname: `/${rest.slice(0, -\"/index\".length)}` };\n\n return { pagePathname: `/${rest}` };\n}\n\n/**\n * Build the JSON envelope returned by `/_next/data/<buildId>/<page>.json`.\n * Mirrors Next.js' `RenderResult(JSON.stringify(props))` path in\n * `packages/next/src/server/render.tsx` (search for `isNextDataRequest`).\n *\n * The envelope is the outer `props` object the React tree would receive:\n * { pageProps: {...}, /* optional locale data, redirect markers, etc. *\\/ }\n */\nexport function buildNextDataJsonResponse(\n pageProps: Record<string, unknown>,\n safeJsonStringify: (value: unknown) => string,\n init?: ResponseInit,\n): Response {\n const body = safeJsonStringify({ pageProps });\n return new Response(body, {\n status: init?.status ?? 200,\n statusText: init?.statusText,\n headers: {\n \"Content-Type\": \"application/json\",\n ...(init?.headers as Record<string, string> | undefined),\n },\n });\n}\n\n/**\n * Build the 404 response Next.js returns for an unknown `_next/data` page.\n * Next.js renders this as a normal 404 page, but the body shape that clients\n * see for a missing page-data endpoint is the literal string `\"{ }\"` for the\n * body and a 404 status with `application/json` so client-side hard-navigation\n * fallback fires (see `__N_SSP` handling in `router.ts`).\n *\n * We match Next.js' behavior: 404 status + JSON content type. The body is an\n * empty JSON object so clients that blindly call `res.json()` do not throw\n * before checking the status code.\n */\nexport function buildNextDataNotFoundResponse(): Response {\n return new Response(\"{}\", {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;;;;;;AAkBzB,SAAgB,mBAAmB,UAA2B;CAC5D,OAAO,SAAS,WAAW,iBAAiB,IAAI,SAAS,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;AAmBrF,SAAgB,sBAAsB,UAAkB,SAAuC;CAC7F,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,CAAC,mBAAmB,SAAS,EAAE,OAAO;CAE1C,MAAM,iBAAiB,GAAG,mBAAmB,QAAQ;CAErD,IAAI,CAAC,SAAS,WAAW,eAAe,EAAE,OAAO;CAEjD,MAAM,OAAO,SAAS,MAAM,eAAe,QAAQ,GAAyB;CAG5E,IAAI,KAAK,WAAW,GAAG,OAAO;CAI9B,IAAI,SAAS,SAAS,OAAO,EAAE,cAAc,KAAK;CAClD,IAAI,KAAK,SAAS,SAAS,EAAE,OAAO,EAAE,cAAc,IAAI,KAAK,MAAM,GAAG,GAAiB,IAAI;CAE3F,OAAO,EAAE,cAAc,IAAI,QAAQ;;;;;;;;;;AAWrC,SAAgB,0BACd,WACA,mBACA,MACU;CACV,MAAM,OAAO,kBAAkB,EAAE,WAAW,CAAC;CAC7C,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ,MAAM,UAAU;EACxB,YAAY,MAAM;EAClB,SAAS;GACP,gBAAgB;GAChB,GAAI,MAAM;GACX;EACF,CAAC;;;;;;;;;;;;;AAcJ,SAAgB,gCAA0C;CACxD,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ;EACR,SAAS,EAAE,gBAAgB,oBAAoB;EAChD,CAAC"}
1
+ {"version":3,"file":"pages-data-route.js","names":[],"sources":["../../src/server/pages-data-route.ts"],"sourcesContent":["/**\n * Helpers for the Pages Router `/_next/data/{buildId}/{...page}.json` endpoint.\n *\n * Next.js uses this endpoint for client-side navigations in the Pages Router:\n * `next/link` and `router.push()` fetch `pageProps` from this URL instead of\n * doing a full HTML navigation. The server must:\n * 1. Match the URL pattern and extract the page pathname (with the buildId\n * and `.json` extension removed, locale prefix preserved).\n * 2. Normalize the URL BEFORE middleware runs so middleware sees the page\n * path (e.g. `/about`) rather than the raw `/_next/data/.../about.json`.\n * 3. Invoke the same `getServerSideProps` / `getStaticProps` machinery as\n * the HTML page and serialize the resulting props as a JSON envelope:\n * `{ pageProps: ... }` with `Content-Type: application/json`.\n *\n * Ported from Next.js:\n * - `packages/next/src/server/normalizers/request/next-data.ts` — prefix/suffix matcher.\n * - `packages/next/src/server/base-server.ts` (`handleNextDataRequest`) — pipeline normalization.\n * - `packages/next/src/server/render.tsx` — JSON envelope emission (`isNextDataRequest`).\n */\n\nconst NEXT_DATA_PREFIX = \"/_next/data/\";\nconst NEXT_DATA_SUFFIX = \".json\";\n\ntype NextDataMatch = {\n /**\n * The normalized page pathname (with leading slash, no trailing slash,\n * `.json` stripped, buildId stripped). For locale-prefixed requests like\n * `/_next/data/<buildId>/en/about.json` this is `/en/about` — locale\n * handling is done downstream by the existing `resolvePagesI18nRequest`\n * pipeline so this helper does not need to know about i18n config.\n */\n pagePathname: string;\n};\n\n/**\n * Returns true if the pathname looks like a `_next/data` request, regardless\n * of buildId. Used by the request pipeline to short-circuit before middleware\n * even when the buildId is wrong (so we can still return a 404 JSON response).\n */\nexport function isNextDataPathname(pathname: string): boolean {\n return pathname.startsWith(NEXT_DATA_PREFIX) && pathname.endsWith(NEXT_DATA_SUFFIX);\n}\n\n/**\n * Parse `/_next/data/<buildId>/<...page>.json` and return the normalized page\n * pathname. Returns `null` if the pathname does not match the pattern or if\n * the buildId segment does not match the server's buildId.\n *\n * The returned `pagePathname` is the page route path Next.js would render for\n * the equivalent HTML navigation — including any locale prefix, which is then\n * stripped by `resolvePagesI18nRequest` downstream.\n *\n * `/_next/data/<buildId>/about.json` → `/about`\n * `/_next/data/<buildId>/en/about.json` → `/en/about`\n * `/_next/data/<buildId>/index.json` → `/`\n * `/_next/data/<buildId>/en.json` → `/en`\n * `/_next/data/<wrong-id>/about.json` → null\n * `/_next/data/<buildId>/about` → null (missing .json suffix)\n */\nexport function parseNextDataPathname(pathname: string, buildId: string): NextDataMatch | null {\n if (!buildId) return null;\n if (!isNextDataPathname(pathname)) return null;\n\n const expectedPrefix = `${NEXT_DATA_PREFIX}${buildId}/`;\n // `/_next/data/<buildId>.json` (no trailing slash) is not a valid data req.\n if (!pathname.startsWith(expectedPrefix)) return null;\n\n const rest = pathname.slice(expectedPrefix.length, -NEXT_DATA_SUFFIX.length);\n\n // Empty rest (`/_next/data/<buildId>/.json`) is not a valid page path.\n if (rest.length === 0) return null;\n\n // Next.js denormalizes `index` to `/` to mirror file-system page paths\n // (`pages/index.tsx` → `/`). See `denormalizePagePath` in Next.js.\n if (rest === \"index\") return { pagePathname: \"/\" };\n if (rest.endsWith(\"/index\")) return { pagePathname: `/${rest.slice(0, -\"/index\".length)}` };\n\n // The encoder (`getAssetPathFromRoute` in Next.js / `buildPagesDataPath` in\n // vinext) prefixes any path beginning with `index` with an extra `index/`\n // segment so an explicit `pages/index/foo.tsx` page (route `/index/foo`)\n // round-trips through the data URL without colliding with `/foo`. Strip\n // that prefix here.\n if (rest.startsWith(\"index/\")) return { pagePathname: `/${rest.slice(\"index/\".length)}` };\n\n return { pagePathname: `/${rest}` };\n}\n\n/**\n * Build the JSON envelope returned by `/_next/data/<buildId>/<page>.json`.\n * Mirrors Next.js' `RenderResult(JSON.stringify(props))` path in\n * `packages/next/src/server/render.tsx` (search for `isNextDataRequest`).\n *\n * The envelope is the outer `props` object the React tree would receive:\n * { pageProps: {...}, /* optional locale data, redirect markers, etc. *\\/ }\n */\nexport function buildNextDataJsonResponse(\n pageProps: Record<string, unknown>,\n safeJsonStringify: (value: unknown) => string,\n init?: ResponseInit,\n): Response {\n const body = safeJsonStringify({ pageProps });\n return new Response(body, {\n status: init?.status ?? 200,\n statusText: init?.statusText,\n headers: {\n \"Content-Type\": \"application/json\",\n ...(init?.headers as Record<string, string> | undefined),\n },\n });\n}\n\n/**\n * Build the 404 response Next.js returns for an unknown `_next/data` page.\n * Next.js renders this as a normal 404 page, but the body shape that clients\n * see for a missing page-data endpoint is the literal string `\"{ }\"` for the\n * body and a 404 status with `application/json` so client-side hard-navigation\n * fallback fires (see `__N_SSP` handling in `router.ts`).\n *\n * We match Next.js' behavior: 404 status + JSON content type. The body is an\n * empty JSON object so clients that blindly call `res.json()` do not throw\n * before checking the status code.\n */\nexport function buildNextDataNotFoundResponse(): Response {\n return new Response(\"{}\", {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;;;;;;AAkBzB,SAAgB,mBAAmB,UAA2B;CAC5D,OAAO,SAAS,WAAW,iBAAiB,IAAI,SAAS,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;AAmBrF,SAAgB,sBAAsB,UAAkB,SAAuC;CAC7F,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI,CAAC,mBAAmB,SAAS,EAAE,OAAO;CAE1C,MAAM,iBAAiB,GAAG,mBAAmB,QAAQ;CAErD,IAAI,CAAC,SAAS,WAAW,eAAe,EAAE,OAAO;CAEjD,MAAM,OAAO,SAAS,MAAM,eAAe,QAAQ,GAAyB;CAG5E,IAAI,KAAK,WAAW,GAAG,OAAO;CAI9B,IAAI,SAAS,SAAS,OAAO,EAAE,cAAc,KAAK;CAClD,IAAI,KAAK,SAAS,SAAS,EAAE,OAAO,EAAE,cAAc,IAAI,KAAK,MAAM,GAAG,GAAiB,IAAI;CAO3F,IAAI,KAAK,WAAW,SAAS,EAAE,OAAO,EAAE,cAAc,IAAI,KAAK,MAAM,EAAgB,IAAI;CAEzF,OAAO,EAAE,cAAc,IAAI,QAAQ;;;;;;;;;;AAWrC,SAAgB,0BACd,WACA,mBACA,MACU;CACV,MAAM,OAAO,kBAAkB,EAAE,WAAW,CAAC;CAC7C,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ,MAAM,UAAU;EACxB,YAAY,MAAM;EAClB,SAAS;GACP,gBAAgB;GAChB,GAAI,MAAM;GACX;EACF,CAAC;;;;;;;;;;;;;AAcJ,SAAgB,gCAA0C;CACxD,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ;EACR,SAAS,EAAE,gBAAgB,oBAAoB;EAChD,CAAC"}
@@ -0,0 +1,31 @@
1
+ //#region src/server/pages-default-404.d.ts
2
+ /**
3
+ * Default 404 HTML body for the Pages Router.
4
+ *
5
+ * Used when a Pages Router request does not match any route (and the app has
6
+ * not supplied a custom `pages/404.tsx`). Mirrors the markup Next.js's
7
+ * `pages/_error.tsx` produces for a 404 response: a centered status / message
8
+ * pair plus minified theme CSS and dark-mode media query. The message string
9
+ * `"This page could not be found."` (note the trailing period) is the
10
+ * canonical body asserted by Next.js's deploy suite
11
+ * (`test/e2e/getserversideprops/test/index.test.ts`,
12
+ * `test/e2e/basepath/error-pages.test.ts`).
13
+ *
14
+ * Kept as a hand-rendered HTML literal rather than a React-rendered template
15
+ * because the Pages Router server entry is invoked from both Workers and the
16
+ * dev server before any React-renderer wiring is available for this path —
17
+ * matching the lightweight build-time strategy Next.js uses for its packaged
18
+ * `_error` static fallback. See:
19
+ * .nextjs-ref/packages/next/src/pages/_error.tsx
20
+ */
21
+ /**
22
+ * Build the Next.js-compatible default 404 HTML response for the Pages Router.
23
+ * Content-type is `text/html; charset=utf-8`, matching Next.js's
24
+ * `pages-handler` 404 response.
25
+ */
26
+ declare function buildDefaultPagesNotFoundResponse(): Response;
27
+ /** Exported for tests / callers that need the raw HTML body. */
28
+ declare const DEFAULT_PAGES_NOT_FOUND_HTML = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"/><meta name=\"viewport\" content=\"width=device-width\"/><title>404: This page could not be found.</title><meta name=\"next-head-count\" content=\"2\"/><style data-next-hide-fouc=\"true\">body{display:none}</style><noscript data-next-hide-fouc=\"true\"><style>body{display:block}</style></noscript></head><body><div id=\"__next\"><div style=\"font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center\"><div style=\"line-height:48px\"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class=\"next-error-h1\" style=\"display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top\">404</h1><div style=\"display:inline-block\"><h2 style=\"font-size:14px;font-weight:400;line-height:28px\">This page could not be found.</h2></div></div></div></div></body></html>";
29
+ //#endregion
30
+ export { DEFAULT_PAGES_NOT_FOUND_HTML, buildDefaultPagesNotFoundResponse };
31
+ //# sourceMappingURL=pages-default-404.d.ts.map
@@ -0,0 +1,40 @@
1
+ //#region src/server/pages-default-404.ts
2
+ /**
3
+ * Default 404 HTML body for the Pages Router.
4
+ *
5
+ * Used when a Pages Router request does not match any route (and the app has
6
+ * not supplied a custom `pages/404.tsx`). Mirrors the markup Next.js's
7
+ * `pages/_error.tsx` produces for a 404 response: a centered status / message
8
+ * pair plus minified theme CSS and dark-mode media query. The message string
9
+ * `"This page could not be found."` (note the trailing period) is the
10
+ * canonical body asserted by Next.js's deploy suite
11
+ * (`test/e2e/getserversideprops/test/index.test.ts`,
12
+ * `test/e2e/basepath/error-pages.test.ts`).
13
+ *
14
+ * Kept as a hand-rendered HTML literal rather than a React-rendered template
15
+ * because the Pages Router server entry is invoked from both Workers and the
16
+ * dev server before any React-renderer wiring is available for this path —
17
+ * matching the lightweight build-time strategy Next.js uses for its packaged
18
+ * `_error` static fallback. See:
19
+ * .nextjs-ref/packages/next/src/pages/_error.tsx
20
+ */
21
+ const STATUS = 404;
22
+ const MESSAGE = "This page could not be found.";
23
+ const HTML = `<!DOCTYPE html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width"/><title>${STATUS}: ${MESSAGE}</title><meta name="next-head-count" content="2"/><style data-next-hide-fouc="true">body{display:none}</style><noscript data-next-hide-fouc="true"><style>body{display:block}</style></noscript></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">${STATUS}</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">${MESSAGE}</h2></div></div></div></div></body></html>`;
24
+ /**
25
+ * Build the Next.js-compatible default 404 HTML response for the Pages Router.
26
+ * Content-type is `text/html; charset=utf-8`, matching Next.js's
27
+ * `pages-handler` 404 response.
28
+ */
29
+ function buildDefaultPagesNotFoundResponse() {
30
+ return new Response(HTML, {
31
+ status: STATUS,
32
+ headers: { "Content-Type": "text/html; charset=utf-8" }
33
+ });
34
+ }
35
+ /** Exported for tests / callers that need the raw HTML body. */
36
+ const DEFAULT_PAGES_NOT_FOUND_HTML = HTML;
37
+ //#endregion
38
+ export { DEFAULT_PAGES_NOT_FOUND_HTML, buildDefaultPagesNotFoundResponse };
39
+
40
+ //# sourceMappingURL=pages-default-404.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages-default-404.js","names":[],"sources":["../../src/server/pages-default-404.ts"],"sourcesContent":["/**\n * Default 404 HTML body for the Pages Router.\n *\n * Used when a Pages Router request does not match any route (and the app has\n * not supplied a custom `pages/404.tsx`). Mirrors the markup Next.js's\n * `pages/_error.tsx` produces for a 404 response: a centered status / message\n * pair plus minified theme CSS and dark-mode media query. The message string\n * `\"This page could not be found.\"` (note the trailing period) is the\n * canonical body asserted by Next.js's deploy suite\n * (`test/e2e/getserversideprops/test/index.test.ts`,\n * `test/e2e/basepath/error-pages.test.ts`).\n *\n * Kept as a hand-rendered HTML literal rather than a React-rendered template\n * because the Pages Router server entry is invoked from both Workers and the\n * dev server before any React-renderer wiring is available for this path —\n * matching the lightweight build-time strategy Next.js uses for its packaged\n * `_error` static fallback. See:\n * .nextjs-ref/packages/next/src/pages/_error.tsx\n */\n\nconst STATUS = 404;\nconst MESSAGE = \"This page could not be found.\";\n\nconst CSS = `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`;\n\nconst HTML = `<!DOCTYPE html><html><head><meta charset=\"utf-8\"/><meta name=\"viewport\" content=\"width=device-width\"/><title>${STATUS}: ${MESSAGE}</title><meta name=\"next-head-count\" content=\"2\"/><style data-next-hide-fouc=\"true\">body{display:none}</style><noscript data-next-hide-fouc=\"true\"><style>body{display:block}</style></noscript></head><body><div id=\"__next\"><div style=\"font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center\"><div style=\"line-height:48px\"><style>${CSS}</style><h1 class=\"next-error-h1\" style=\"display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top\">${STATUS}</h1><div style=\"display:inline-block\"><h2 style=\"font-size:14px;font-weight:400;line-height:28px\">${MESSAGE}</h2></div></div></div></div></body></html>`;\n\n/**\n * Build the Next.js-compatible default 404 HTML response for the Pages Router.\n * Content-type is `text/html; charset=utf-8`, matching Next.js's\n * `pages-handler` 404 response.\n */\nexport function buildDefaultPagesNotFoundResponse(): Response {\n return new Response(HTML, {\n status: STATUS,\n headers: { \"Content-Type\": \"text/html; charset=utf-8\" },\n });\n}\n\n/** Exported for tests / callers that need the raw HTML body. */\nexport const DEFAULT_PAGES_NOT_FOUND_HTML = HTML;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,SAAS;AACf,MAAM,UAAU;AAIhB,MAAM,OAAO,gHAAgH,OAAO,IAAI,QAAQ,u3BAAgqB,OAAO,qGAAqG,QAAQ;;;;;;AAOp6B,SAAgB,oCAA8C;CAC5D,OAAO,IAAI,SAAS,MAAM;EACxB,QAAQ;EACR,SAAS,EAAE,gBAAgB,4BAA4B;EACxD,CAAC;;;AAIJ,MAAa,+BAA+B"}
@@ -0,0 +1,7 @@
1
+ import { ComponentType } from "react";
2
+
3
+ //#region src/server/pages-document-initial-props.d.ts
4
+ declare function loadUserDocumentInitialProps(DocumentComponent: ComponentType): Promise<Record<string, unknown> | null>;
5
+ //#endregion
6
+ export { loadUserDocumentInitialProps };
7
+ //# sourceMappingURL=pages-document-initial-props.d.ts.map
@@ -0,0 +1,14 @@
1
+ import Document from "../shims/document.js";
2
+ //#region src/server/pages-document-initial-props.ts
3
+ const BASE_GET_INITIAL_PROPS = Document.getInitialProps;
4
+ async function loadUserDocumentInitialProps(DocumentComponent) {
5
+ const getInitialProps = DocumentComponent.getInitialProps;
6
+ if (typeof getInitialProps !== "function") return null;
7
+ if (getInitialProps === BASE_GET_INITIAL_PROPS) return null;
8
+ const result = await getInitialProps({});
9
+ return result && typeof result === "object" ? result : null;
10
+ }
11
+ //#endregion
12
+ export { loadUserDocumentInitialProps };
13
+
14
+ //# sourceMappingURL=pages-document-initial-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages-document-initial-props.js","names":["BaseDocument"],"sources":["../../src/server/pages-document-initial-props.ts"],"sourcesContent":["/**\n * Pages Router `_document.tsx` `getInitialProps` helper.\n *\n * Next.js's `pages/_document.tsx` may override\n * `static async getInitialProps(ctx)` to inject extra props onto the\n * Document element (the classic pattern is\n * `await Document.getInitialProps(ctx)` + spread, see Next.js's\n * `test/e2e/async-modules/pages/_document.jsx`). The SSR pipeline invokes\n * that hook and then renders the Document with the resolved props:\n *\n * <Document {...htmlProps} {...docProps} />\n *\n * Reference:\n * https://github.com/vercel/next.js/blob/canary/packages/next/src/server/render.tsx\n * (search for `loadDocumentInitialProps` and `documentElement`).\n *\n * vinext only forwards `docProps`. The full `DocumentContext`\n * (`renderPage`, `defaultGetInitialProps`, `pathname`, `query`, `req`, `res`,\n * `err`, `asPath`) is not yet plumbed through. The common upstream pattern\n *\n * static async getInitialProps(ctx) {\n * const initialProps = await Document.getInitialProps(ctx)\n * return { ...initialProps, docValue }\n * }\n *\n * works because the base `Document.getInitialProps` shim in\n * `shims/document.tsx` returns `{ html: \"\" }` and ignores `ctx`. User\n * overrides that *only* read `ctx` will see `undefined` fields — that is a\n * separate gap tracked alongside the shim TODO.\n *\n * Returns `null` when the user did not override the base shim (the static\n * `getInitialProps` reference still points at the shim's stub) so callers\n * skip the spread and render the bare Document element on the fast path.\n *\n * Errors from a user `getInitialProps` propagate to the caller. Next.js's\n * `loadGetInitialProps` does not catch — a throw becomes a 500 — and vinext\n * matches that contract so user bugs surface as the loud failures Next.js\n * apps already debug against.\n */\nimport type { ComponentType } from \"react\";\n// Static import so the identity comparison below is established once at\n// module evaluation. A previous version used `await import(...)` per request\n// and was flagged by reviewers as unnecessary work — and worse, it left a\n// per-request `await` on the fast path where the user had no override.\nimport BaseDocument from \"vinext/shims/document\";\n\nconst BASE_GET_INITIAL_PROPS = (\n BaseDocument as unknown as {\n getInitialProps?: unknown;\n }\n).getInitialProps;\n\nexport async function loadUserDocumentInitialProps(\n DocumentComponent: ComponentType,\n): Promise<Record<string, unknown> | null> {\n const getInitialProps = (\n DocumentComponent as unknown as {\n getInitialProps?: (\n ctx: unknown,\n ) => Promise<Record<string, unknown>> | Record<string, unknown>;\n }\n ).getInitialProps;\n if (typeof getInitialProps !== \"function\") return null;\n\n // Identity check: if the user did not override `static getInitialProps`,\n // the inherited reference is the shim's stub. Skip the call so the\n // fast path keeps the same number of awaits as before this helper landed.\n if (getInitialProps === BASE_GET_INITIAL_PROPS) return null;\n\n // Pass ctx as `{}`. Most upstream overrides only use ctx to delegate\n // back to `Document.getInitialProps`, which the shim ignores. Errors\n // propagate — matching Next.js's `loadGetInitialProps`, which has no\n // catch and surfaces user bugs as 500s.\n const result = await getInitialProps({});\n return result && typeof result === \"object\" ? (result as Record<string, unknown>) : null;\n}\n"],"mappings":";;AA8CA,MAAM,yBACJA,SAGA;AAEF,eAAsB,6BACpB,mBACyC;CACzC,MAAM,kBACJ,kBAKA;CACF,IAAI,OAAO,oBAAoB,YAAY,OAAO;CAKlD,IAAI,oBAAoB,wBAAwB,OAAO;CAMvD,MAAM,SAAS,MAAM,gBAAgB,EAAE,CAAC;CACxC,OAAO,UAAU,OAAO,WAAW,WAAY,SAAqC"}
@@ -37,6 +37,16 @@ type CreatePagesReqResResult = {
37
37
  res: PagesReqResResponse;
38
38
  responsePromise: Promise<Response>;
39
39
  };
40
+ /**
41
+ * Read and parse a Pages Router API request body for the Workers/prod path.
42
+ *
43
+ * `maxBytes` defaults to the 1 MB Next.js default but may be overridden by
44
+ * `export const config = { api: { bodyParser: { sizeLimit: '4mb' } } }` on
45
+ * the route module. Handlers that opt out entirely (`bodyParser: false`)
46
+ * MUST skip this function so the body stream stays intact for user code.
47
+ *
48
+ * @see https://nextjs.org/docs/pages/building-your-application/routing/api-routes#custom-config
49
+ */
40
50
  declare function parsePagesApiBody(request: Request, maxBytes?: number): Promise<unknown>;
41
51
  declare function createPagesReqRes(options: CreatePagesReqResOptions): CreatePagesReqResResult;
42
52
  //#endregion
@@ -1,15 +1,26 @@
1
1
  import { parseCookies } from "../config/config-matchers.js";
2
2
  import { PagesBodyParseError, getMediaType, isJsonMediaType } from "./pages-media-type.js";
3
+ import { DEFAULT_PAGES_API_BODY_SIZE_LIMIT } from "./pages-body-parser-config.js";
3
4
  import { readStreamAsTextWithLimit } from "../utils/text-stream.js";
4
5
  import { decode } from "node:querystring";
5
6
  //#region src/server/pages-node-compat.ts
6
- const MAX_PAGES_API_BODY_SIZE = 1 * 1024 * 1024;
7
+ const MAX_PAGES_API_BODY_SIZE = DEFAULT_PAGES_API_BODY_SIZE_LIMIT;
7
8
  async function readPagesRequestBodyWithLimit(request, maxBytes) {
8
9
  if (!request.body) return "";
9
10
  return readStreamAsTextWithLimit(request.body, maxBytes, () => {
10
11
  throw new PagesBodyParseError("Request body too large", 413);
11
12
  });
12
13
  }
14
+ /**
15
+ * Read and parse a Pages Router API request body for the Workers/prod path.
16
+ *
17
+ * `maxBytes` defaults to the 1 MB Next.js default but may be overridden by
18
+ * `export const config = { api: { bodyParser: { sizeLimit: '4mb' } } }` on
19
+ * the route module. Handlers that opt out entirely (`bodyParser: false`)
20
+ * MUST skip this function so the body stream stays intact for user code.
21
+ *
22
+ * @see https://nextjs.org/docs/pages/building-your-application/routing/api-routes#custom-config
23
+ */
13
24
  async function parsePagesApiBody(request, maxBytes = MAX_PAGES_API_BODY_SIZE) {
14
25
  if (Number.parseInt(request.headers.get("content-length") || "0", 10) > maxBytes) throw new PagesBodyParseError("Request body too large", 413);
15
26
  let rawBody = "";
@@ -1 +1 @@
1
- {"version":3,"file":"pages-node-compat.js","names":["decodeQueryString"],"sources":["../../src/server/pages-node-compat.ts"],"sourcesContent":["import { decode as decodeQueryString } from \"node:querystring\";\nimport { parseCookies } from \"../config/config-matchers.js\";\nimport { readStreamAsTextWithLimit } from \"../utils/text-stream.js\";\nimport { PagesBodyParseError, getMediaType, isJsonMediaType } from \"./pages-media-type.js\";\n\nconst MAX_PAGES_API_BODY_SIZE = 1 * 1024 * 1024;\n\n/**\n * @deprecated Use PagesBodyParseError from pages-media-type.ts instead.\n * Kept for backwards compatibility.\n */\nexport { PagesBodyParseError as PagesApiBodyParseError };\n\nexport type PagesRequestQuery = Record<string, string | string[]>;\n\nexport type PagesReqResRequest = {\n method: string;\n url: string;\n headers: Record<string, string>;\n query: PagesRequestQuery;\n body: unknown;\n cookies: Record<string, string>;\n};\n\nexport type PagesReqResHeaders = {\n [key: string]: string | number | boolean | string[];\n};\n\nexport type PagesReqResResponse = {\n statusCode: number;\n readonly headersSent: boolean;\n writeHead: (code: number, headers?: PagesReqResHeaders) => PagesReqResResponse;\n setHeader: (name: string, value: string | number | boolean | string[]) => PagesReqResResponse;\n getHeader: (name: string) => string | number | boolean | string[] | undefined;\n end: (data?: BodyInit | null) => void;\n status: (code: number) => PagesReqResResponse;\n json: (data: unknown) => void;\n send: (data: unknown) => void;\n redirect: (statusOrUrl: number | string, url?: string) => void;\n getHeaders: () => PagesReqResHeaders;\n};\n\ntype CreatePagesReqResOptions = {\n body: unknown;\n query: PagesRequestQuery;\n request: Request;\n url: string;\n};\n\ntype CreatePagesReqResResult = {\n req: PagesReqResRequest;\n res: PagesReqResResponse;\n responsePromise: Promise<Response>;\n};\n\nasync function readPagesRequestBodyWithLimit(request: Request, maxBytes: number): Promise<string> {\n if (!request.body) {\n return \"\";\n }\n\n return readStreamAsTextWithLimit(request.body, maxBytes, () => {\n throw new PagesBodyParseError(\"Request body too large\", 413);\n });\n}\n\nexport async function parsePagesApiBody(\n request: Request,\n maxBytes = MAX_PAGES_API_BODY_SIZE,\n): Promise<unknown> {\n const contentLength = Number.parseInt(request.headers.get(\"content-length\") || \"0\", 10);\n if (contentLength > maxBytes) {\n throw new PagesBodyParseError(\"Request body too large\", 413);\n }\n\n let rawBody = \"\";\n try {\n rawBody = await readPagesRequestBodyWithLimit(request, maxBytes);\n } catch (err) {\n if (err instanceof PagesBodyParseError) {\n throw err;\n }\n throw new PagesBodyParseError(\"Request body too large\", 413);\n }\n\n const mediaType = getMediaType(request.headers.get(\"content-type\"));\n if (!rawBody) {\n return isJsonMediaType(mediaType)\n ? {}\n : mediaType === \"application/x-www-form-urlencoded\"\n ? decodeQueryString(rawBody)\n : undefined;\n }\n\n if (isJsonMediaType(mediaType)) {\n try {\n return JSON.parse(rawBody);\n } catch {\n throw new PagesBodyParseError(\"Invalid JSON\", 400);\n }\n }\n\n if (mediaType === \"application/x-www-form-urlencoded\") {\n return decodeQueryString(rawBody);\n }\n\n return rawBody;\n}\n\nexport function createPagesReqRes(options: CreatePagesReqResOptions): CreatePagesReqResResult {\n const headersObj: Record<string, string> = {};\n for (const [key, value] of options.request.headers) {\n headersObj[key.toLowerCase()] = value;\n }\n\n const req: PagesReqResRequest = {\n method: options.request.method,\n url: options.url,\n headers: headersObj,\n query: options.query,\n body: options.body,\n cookies: parseCookies(options.request.headers.get(\"cookie\")),\n };\n\n let resStatusCode = 200;\n const resHeaders: Record<string, string | number | boolean> = {};\n const setCookieHeaders: string[] = [];\n let resBody: BodyInit | null = null;\n let ended = false;\n let resolveResponse!: (value: Response) => void;\n const responsePromise = new Promise<Response>((resolve) => {\n resolveResponse = resolve;\n });\n\n const res: PagesReqResResponse = {\n get statusCode() {\n return resStatusCode;\n },\n set statusCode(code) {\n resStatusCode = code;\n },\n get headersSent() {\n return ended;\n },\n writeHead(code, headers) {\n resStatusCode = code;\n if (headers) {\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === \"set-cookie\") {\n if (Array.isArray(value)) {\n setCookieHeaders.push(...value.map(String));\n } else {\n setCookieHeaders.push(String(value));\n }\n } else {\n resHeaders[key.toLowerCase()] = Array.isArray(value) ? value.join(\", \") : value;\n }\n }\n }\n return res;\n },\n setHeader(name, value) {\n if (name.toLowerCase() === \"set-cookie\") {\n // Node.js res.setHeader() replaces the existing value entirely.\n setCookieHeaders.length = 0;\n if (Array.isArray(value)) {\n setCookieHeaders.push(...value.map(String));\n } else {\n setCookieHeaders.push(String(value));\n }\n } else {\n resHeaders[name.toLowerCase()] = Array.isArray(value) ? value.join(\", \") : value;\n }\n return res;\n },\n getHeader(name) {\n if (name.toLowerCase() === \"set-cookie\") {\n return setCookieHeaders.length > 0 ? setCookieHeaders : undefined;\n }\n return resHeaders[name.toLowerCase()];\n },\n end(data) {\n if (ended) {\n return;\n }\n ended = true;\n if (data !== undefined && data !== null) {\n resBody = data;\n }\n const headers = new Headers();\n for (const [key, value] of Object.entries(resHeaders)) {\n headers.set(key, String(value));\n }\n for (const cookie of setCookieHeaders) {\n headers.append(\"set-cookie\", cookie);\n }\n resolveResponse(new Response(resBody, { status: resStatusCode, headers }));\n },\n status(code) {\n resStatusCode = code;\n return res;\n },\n json(data) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n },\n send(data) {\n if (Buffer.isBuffer(data)) {\n if (!resHeaders[\"content-type\"]) {\n resHeaders[\"content-type\"] = \"application/octet-stream\";\n }\n resHeaders[\"content-length\"] = String(data.length);\n res.end(new Uint8Array(data));\n return;\n }\n\n if (typeof data === \"object\" && data !== null) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n return;\n }\n\n if (!resHeaders[\"content-type\"]) {\n resHeaders[\"content-type\"] = \"text/plain\";\n }\n res.end(String(data));\n },\n redirect(statusOrUrl, url) {\n if (typeof statusOrUrl === \"string\") {\n res.writeHead(307, { Location: statusOrUrl });\n } else {\n res.writeHead(statusOrUrl, { Location: url ?? \"\" });\n }\n res.end();\n },\n getHeaders() {\n const headers: PagesReqResHeaders = { ...resHeaders };\n if (setCookieHeaders.length > 0) {\n headers[\"set-cookie\"] = setCookieHeaders;\n }\n return headers;\n },\n };\n\n return { req, res, responsePromise };\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"pages-node-compat.js","names":["decodeQueryString"],"sources":["../../src/server/pages-node-compat.ts"],"sourcesContent":["import { decode as decodeQueryString } from \"node:querystring\";\nimport { parseCookies } from \"../config/config-matchers.js\";\nimport { readStreamAsTextWithLimit } from \"../utils/text-stream.js\";\nimport { DEFAULT_PAGES_API_BODY_SIZE_LIMIT } from \"./pages-body-parser-config.js\";\nimport { PagesBodyParseError, getMediaType, isJsonMediaType } from \"./pages-media-type.js\";\n\nconst MAX_PAGES_API_BODY_SIZE = DEFAULT_PAGES_API_BODY_SIZE_LIMIT;\n\n/**\n * @deprecated Use PagesBodyParseError from pages-media-type.ts instead.\n * Kept for backwards compatibility.\n */\nexport { PagesBodyParseError as PagesApiBodyParseError };\n\nexport type PagesRequestQuery = Record<string, string | string[]>;\n\nexport type PagesReqResRequest = {\n method: string;\n url: string;\n headers: Record<string, string>;\n query: PagesRequestQuery;\n body: unknown;\n cookies: Record<string, string>;\n};\n\nexport type PagesReqResHeaders = {\n [key: string]: string | number | boolean | string[];\n};\n\nexport type PagesReqResResponse = {\n statusCode: number;\n readonly headersSent: boolean;\n writeHead: (code: number, headers?: PagesReqResHeaders) => PagesReqResResponse;\n setHeader: (name: string, value: string | number | boolean | string[]) => PagesReqResResponse;\n getHeader: (name: string) => string | number | boolean | string[] | undefined;\n end: (data?: BodyInit | null) => void;\n status: (code: number) => PagesReqResResponse;\n json: (data: unknown) => void;\n send: (data: unknown) => void;\n redirect: (statusOrUrl: number | string, url?: string) => void;\n getHeaders: () => PagesReqResHeaders;\n};\n\ntype CreatePagesReqResOptions = {\n body: unknown;\n query: PagesRequestQuery;\n request: Request;\n url: string;\n};\n\ntype CreatePagesReqResResult = {\n req: PagesReqResRequest;\n res: PagesReqResResponse;\n responsePromise: Promise<Response>;\n};\n\nasync function readPagesRequestBodyWithLimit(request: Request, maxBytes: number): Promise<string> {\n if (!request.body) {\n return \"\";\n }\n\n return readStreamAsTextWithLimit(request.body, maxBytes, () => {\n throw new PagesBodyParseError(\"Request body too large\", 413);\n });\n}\n\n/**\n * Read and parse a Pages Router API request body for the Workers/prod path.\n *\n * `maxBytes` defaults to the 1 MB Next.js default but may be overridden by\n * `export const config = { api: { bodyParser: { sizeLimit: '4mb' } } }` on\n * the route module. Handlers that opt out entirely (`bodyParser: false`)\n * MUST skip this function so the body stream stays intact for user code.\n *\n * @see https://nextjs.org/docs/pages/building-your-application/routing/api-routes#custom-config\n */\nexport async function parsePagesApiBody(\n request: Request,\n maxBytes = MAX_PAGES_API_BODY_SIZE,\n): Promise<unknown> {\n const contentLength = Number.parseInt(request.headers.get(\"content-length\") || \"0\", 10);\n if (contentLength > maxBytes) {\n throw new PagesBodyParseError(\"Request body too large\", 413);\n }\n\n let rawBody = \"\";\n try {\n rawBody = await readPagesRequestBodyWithLimit(request, maxBytes);\n } catch (err) {\n if (err instanceof PagesBodyParseError) {\n throw err;\n }\n throw new PagesBodyParseError(\"Request body too large\", 413);\n }\n\n const mediaType = getMediaType(request.headers.get(\"content-type\"));\n if (!rawBody) {\n return isJsonMediaType(mediaType)\n ? {}\n : mediaType === \"application/x-www-form-urlencoded\"\n ? decodeQueryString(rawBody)\n : undefined;\n }\n\n if (isJsonMediaType(mediaType)) {\n try {\n return JSON.parse(rawBody);\n } catch {\n throw new PagesBodyParseError(\"Invalid JSON\", 400);\n }\n }\n\n if (mediaType === \"application/x-www-form-urlencoded\") {\n return decodeQueryString(rawBody);\n }\n\n return rawBody;\n}\n\nexport function createPagesReqRes(options: CreatePagesReqResOptions): CreatePagesReqResResult {\n const headersObj: Record<string, string> = {};\n for (const [key, value] of options.request.headers) {\n headersObj[key.toLowerCase()] = value;\n }\n\n const req: PagesReqResRequest = {\n method: options.request.method,\n url: options.url,\n headers: headersObj,\n query: options.query,\n body: options.body,\n cookies: parseCookies(options.request.headers.get(\"cookie\")),\n };\n\n let resStatusCode = 200;\n const resHeaders: Record<string, string | number | boolean> = {};\n const setCookieHeaders: string[] = [];\n let resBody: BodyInit | null = null;\n let ended = false;\n let resolveResponse!: (value: Response) => void;\n const responsePromise = new Promise<Response>((resolve) => {\n resolveResponse = resolve;\n });\n\n const res: PagesReqResResponse = {\n get statusCode() {\n return resStatusCode;\n },\n set statusCode(code) {\n resStatusCode = code;\n },\n get headersSent() {\n return ended;\n },\n writeHead(code, headers) {\n resStatusCode = code;\n if (headers) {\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === \"set-cookie\") {\n if (Array.isArray(value)) {\n setCookieHeaders.push(...value.map(String));\n } else {\n setCookieHeaders.push(String(value));\n }\n } else {\n resHeaders[key.toLowerCase()] = Array.isArray(value) ? value.join(\", \") : value;\n }\n }\n }\n return res;\n },\n setHeader(name, value) {\n if (name.toLowerCase() === \"set-cookie\") {\n // Node.js res.setHeader() replaces the existing value entirely.\n setCookieHeaders.length = 0;\n if (Array.isArray(value)) {\n setCookieHeaders.push(...value.map(String));\n } else {\n setCookieHeaders.push(String(value));\n }\n } else {\n resHeaders[name.toLowerCase()] = Array.isArray(value) ? value.join(\", \") : value;\n }\n return res;\n },\n getHeader(name) {\n if (name.toLowerCase() === \"set-cookie\") {\n return setCookieHeaders.length > 0 ? setCookieHeaders : undefined;\n }\n return resHeaders[name.toLowerCase()];\n },\n end(data) {\n if (ended) {\n return;\n }\n ended = true;\n if (data !== undefined && data !== null) {\n resBody = data;\n }\n const headers = new Headers();\n for (const [key, value] of Object.entries(resHeaders)) {\n headers.set(key, String(value));\n }\n for (const cookie of setCookieHeaders) {\n headers.append(\"set-cookie\", cookie);\n }\n resolveResponse(new Response(resBody, { status: resStatusCode, headers }));\n },\n status(code) {\n resStatusCode = code;\n return res;\n },\n json(data) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n },\n send(data) {\n if (Buffer.isBuffer(data)) {\n if (!resHeaders[\"content-type\"]) {\n resHeaders[\"content-type\"] = \"application/octet-stream\";\n }\n resHeaders[\"content-length\"] = String(data.length);\n res.end(new Uint8Array(data));\n return;\n }\n\n if (typeof data === \"object\" && data !== null) {\n resHeaders[\"content-type\"] = \"application/json\";\n res.end(JSON.stringify(data));\n return;\n }\n\n if (!resHeaders[\"content-type\"]) {\n resHeaders[\"content-type\"] = \"text/plain\";\n }\n res.end(String(data));\n },\n redirect(statusOrUrl, url) {\n if (typeof statusOrUrl === \"string\") {\n res.writeHead(307, { Location: statusOrUrl });\n } else {\n res.writeHead(statusOrUrl, { Location: url ?? \"\" });\n }\n res.end();\n },\n getHeaders() {\n const headers: PagesReqResHeaders = { ...resHeaders };\n if (setCookieHeaders.length > 0) {\n headers[\"set-cookie\"] = setCookieHeaders;\n }\n return headers;\n },\n };\n\n return { req, res, responsePromise };\n}\n"],"mappings":"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"}
@@ -1,4 +1,5 @@
1
1
  import { Route } from "../routing/pages-router.js";
2
+ import { VinextNextData } from "../client/vinext-next-data.js";
2
3
  import { CachedPagesValue } from "../shims/cache.js";
3
4
  import { ISRCacheEntry } from "./isr-cache.js";
4
5
  import { PagesGsspResponse, PagesI18nRenderContext } from "./pages-page-response.js";
@@ -64,6 +65,18 @@ type PagesPageModule = {
64
65
  locale?: string;
65
66
  locales?: string[];
66
67
  defaultLocale?: string;
68
+ /**
69
+ * Indicates why `getStaticProps` was invoked.
70
+ *
71
+ * - `"build"`: initial build-time prerender (before runtime traffic).
72
+ * - `"on-demand"`: triggered by `res.revalidate()` from an API route.
73
+ * - `"stale"`: stale-while-revalidate background regeneration.
74
+ *
75
+ * Mirrors Next.js `render.tsx`'s `revalidateReason` on the
76
+ * `GetStaticPropsContext` type — see
77
+ * `.nextjs-ref/packages/next/src/types.ts`.
78
+ */
79
+ revalidateReason?: "build" | "on-demand" | "stale";
67
80
  }) => Promise<PagesPagePropsResult> | PagesPagePropsResult;
68
81
  };
69
82
  type RenderPagesIsrHtmlOptions = {
@@ -76,6 +89,7 @@ type RenderPagesIsrHtmlOptions = {
76
89
  renderIsrPassToStringAsync: (element: ReactNode) => Promise<string>;
77
90
  routePattern: string;
78
91
  safeJsonStringify: (value: unknown) => string;
92
+ vinext?: VinextNextData["__vinext"];
79
93
  };
80
94
  type ResolvePagesPageDataOptions = {
81
95
  applyRequestContexts: () => void;
@@ -97,6 +111,30 @@ type ResolvePagesPageDataOptions = {
97
111
  isrGet: (key: string) => Promise<ISRCacheEntry | null>;
98
112
  isrSet: (key: string, data: CachedPagesValue, revalidateSeconds: number, tags?: string[], expireSeconds?: number) => Promise<void>;
99
113
  expireSeconds?: number;
114
+ /**
115
+ * When true, this dispatch corresponds to a build-time prerender (the
116
+ * `vinext` build phase fetches each statically generated page through the
117
+ * production server). Maps to `revalidateReason: "build"` when
118
+ * `getStaticProps` is invoked. Mirrors Next.js's
119
+ * `renderOpts.isBuildTimePrerendering` flag — see
120
+ * `.nextjs-ref/packages/next/src/server/render.tsx`.
121
+ */
122
+ isBuildTimePrerendering?: boolean;
123
+ /**
124
+ * When true, this dispatch was triggered by an on-demand revalidation
125
+ * request (e.g. `res.revalidate()` in a Pages Router API route, or an
126
+ * equivalent webhook). Maps to `revalidateReason: "on-demand"` when
127
+ * `getStaticProps` is invoked. Mirrors Next.js's
128
+ * `renderOpts.isOnDemandRevalidate` flag — see
129
+ * `.nextjs-ref/packages/next/src/server/render.tsx`.
130
+ *
131
+ * Forward-looking plumbing: no caller currently sets this — `res.revalidate()`
132
+ * is not yet implemented in vinext. The `"on-demand"` branch in the
133
+ * `revalidateReason` resolver is intentionally unreachable today; keeping the
134
+ * typed contract here means wiring it up will be a one-line change once the
135
+ * trigger lands.
136
+ */
137
+ isOnDemandRevalidate?: boolean;
100
138
  pageModule: PagesPageModule;
101
139
  params: Record<string, unknown>;
102
140
  query: Record<string, unknown>;
@@ -107,12 +145,14 @@ type ResolvePagesPageDataOptions = {
107
145
  safeJsonStringify: (value: unknown) => string;
108
146
  sanitizeDestination: (destination: string) => string;
109
147
  scriptNonce?: string;
148
+ statusCode?: number;
110
149
  triggerBackgroundRegeneration: (key: string, renderFn: () => Promise<void>, errorContext?: {
111
150
  routerKind: "Pages Router";
112
151
  routePath: string;
113
152
  routeType: "render";
114
153
  }) => void;
115
154
  renderIsrPassToStringAsync: (element: ReactNode) => Promise<string>;
155
+ vinext?: VinextNextData["__vinext"];
116
156
  };
117
157
  type ResolvePagesPageDataRenderResult = {
118
158
  kind: "render";
@@ -1,14 +1,13 @@
1
1
  import { normalizeStaticPathname } from "../routing/route-pattern.js";
2
2
  import { buildCacheStateHeaders } from "./cache-headers.js";
3
3
  import { buildPagesCacheValue } from "./isr-cache.js";
4
+ import { buildDefaultPagesNotFoundResponse } from "./pages-default-404.js";
5
+ import { isSerializableProps } from "./pages-serializable-props.js";
4
6
  import { buildCachedRevalidateCacheControl } from "./cache-control.js";
5
7
  import { buildPagesNextDataScript } from "./pages-page-response.js";
6
8
  //#region src/server/pages-page-data.ts
7
9
  function buildPagesNotFoundResponse() {
8
- return new Response("<!DOCTYPE html><html><body><h1>404 - Page not found</h1></body></html>", {
9
- status: 404,
10
- headers: { "Content-Type": "text/html" }
11
- });
10
+ return buildDefaultPagesNotFoundResponse();
12
11
  }
13
12
  function buildPagesDataNotFoundResponse() {
14
13
  return new Response("{}", {
@@ -44,7 +43,7 @@ function matchesPagesStaticPath(pathEntry, params, routeUrl) {
44
43
  return String(value) === String(actual);
45
44
  });
46
45
  }
47
- function buildPagesCacheResponse(html, cacheState, fontLinkHeader, revalidateSeconds, expireSeconds, cacheControl) {
46
+ function buildPagesCacheResponse(html, cacheState, fontLinkHeader, revalidateSeconds, expireSeconds, cacheControl, status) {
48
47
  const effectiveRevalidateSeconds = cacheControl?.revalidate ?? revalidateSeconds ?? 60;
49
48
  const effectiveExpireSeconds = cacheControl === void 0 ? void 0 : cacheControl.expire ?? expireSeconds;
50
49
  const headers = {
@@ -54,7 +53,7 @@ function buildPagesCacheResponse(html, cacheState, fontLinkHeader, revalidateSec
54
53
  };
55
54
  if (fontLinkHeader) headers.Link = fontLinkHeader;
56
55
  return new Response(html, {
57
- status: 200,
56
+ status: status ?? 200,
58
57
  headers
59
58
  });
60
59
  }
@@ -80,7 +79,8 @@ async function renderPagesIsrHtml(options) {
80
79
  pageProps: options.pageProps,
81
80
  params: options.params,
82
81
  routePattern: options.routePattern,
83
- safeJsonStringify: options.safeJsonStringify
82
+ safeJsonStringify: options.safeJsonStringify,
83
+ vinext: options.vinext
84
84
  });
85
85
  return rewritePagesCachedHtml(options.cachedHtml, freshBody, nextDataScript);
86
86
  }
@@ -125,7 +125,7 @@ async function resolvePagesPageData(options) {
125
125
  kind: "response",
126
126
  response: await responsePromise
127
127
  };
128
- if (result?.props) pageProps = result.props;
128
+ if (result?.props) pageProps = await Promise.resolve(result.props);
129
129
  if (result?.redirect) return {
130
130
  kind: "response",
131
131
  response: new Response(null, {
@@ -137,6 +137,7 @@ async function resolvePagesPageData(options) {
137
137
  kind: "response",
138
138
  response: options.isDataReq ? buildPagesDataNotFoundResponse() : buildPagesNotFoundResponse()
139
139
  };
140
+ if (result?.props !== void 0) isSerializableProps(options.routePattern, "getServerSideProps", pageProps);
140
141
  gsspRes = res;
141
142
  }
142
143
  let isrRevalidateSeconds = null;
@@ -147,7 +148,7 @@ async function resolvePagesPageData(options) {
147
148
  const cachedValue = cached?.value.value;
148
149
  if (cachedValue?.kind === "PAGES" && cached && !cached.isStale && !options.scriptNonce && !options.isDataReq) return {
149
150
  kind: "response",
150
- response: buildPagesCacheResponse(cachedValue.html, "HIT", options.fontLinkHeader, void 0, options.expireSeconds, cached.value.cacheControl)
151
+ response: buildPagesCacheResponse(cachedValue.html, "HIT", options.fontLinkHeader, void 0, options.expireSeconds, cached.value.cacheControl, cachedValue.status)
151
152
  };
152
153
  if (cachedValue?.kind === "PAGES" && cached && cached.isStale && !options.scriptNonce && !options.isDataReq) {
153
154
  options.triggerBackgroundRegeneration(cacheKey, async function() {
@@ -156,7 +157,8 @@ async function resolvePagesPageData(options) {
156
157
  params: userFacingParams,
157
158
  locale: options.i18n.locale,
158
159
  locales: options.i18n.locales,
159
- defaultLocale: options.i18n.defaultLocale
160
+ defaultLocale: options.i18n.defaultLocale,
161
+ revalidateReason: "stale"
160
162
  });
161
163
  if (freshResult?.props && typeof freshResult.revalidate === "number" && freshResult.revalidate > 0) {
162
164
  options.applyRequestContexts();
@@ -169,9 +171,10 @@ async function resolvePagesPageData(options) {
169
171
  params: options.params,
170
172
  renderIsrPassToStringAsync: options.renderIsrPassToStringAsync,
171
173
  routePattern: options.routePattern,
172
- safeJsonStringify: options.safeJsonStringify
174
+ safeJsonStringify: options.safeJsonStringify,
175
+ vinext: options.vinext
173
176
  });
174
- await options.isrSet(cacheKey, buildPagesCacheValue(freshHtml, freshResult.props), freshResult.revalidate, void 0, options.expireSeconds);
177
+ await options.isrSet(cacheKey, buildPagesCacheValue(freshHtml, freshResult.props, options.statusCode), freshResult.revalidate, void 0, options.expireSeconds);
175
178
  }
176
179
  });
177
180
  }, {
@@ -181,14 +184,15 @@ async function resolvePagesPageData(options) {
181
184
  });
182
185
  return {
183
186
  kind: "response",
184
- response: buildPagesCacheResponse(cachedValue.html, "STALE", options.fontLinkHeader, void 0, options.expireSeconds, cached.value.cacheControl)
187
+ response: buildPagesCacheResponse(cachedValue.html, "STALE", options.fontLinkHeader, void 0, options.expireSeconds, cached.value.cacheControl, cachedValue.status)
185
188
  };
186
189
  }
187
190
  const result = await options.pageModule.getStaticProps({
188
191
  params: userFacingParams,
189
192
  locale: options.i18n.locale,
190
193
  locales: options.i18n.locales,
191
- defaultLocale: options.i18n.defaultLocale
194
+ defaultLocale: options.i18n.defaultLocale,
195
+ revalidateReason: options.isOnDemandRevalidate ? "on-demand" : options.isBuildTimePrerendering ? "build" : "stale"
192
196
  });
193
197
  if (result?.props) pageProps = result.props;
194
198
  if (result?.redirect) return {
@@ -202,6 +206,7 @@ async function resolvePagesPageData(options) {
202
206
  kind: "response",
203
207
  response: options.isDataReq ? buildPagesDataNotFoundResponse() : buildPagesNotFoundResponse()
204
208
  };
209
+ if (result?.props !== void 0) isSerializableProps(options.routePattern, "getStaticProps", pageProps);
205
210
  if (typeof result?.revalidate === "number" && result.revalidate > 0) isrRevalidateSeconds = result.revalidate;
206
211
  }
207
212
  return {