vinext 0.0.29 → 0.0.31

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 (428) hide show
  1. package/README.md +12 -6
  2. package/dist/build/prerender.d.ts +188 -0
  3. package/dist/build/prerender.js +675 -0
  4. package/dist/build/prerender.js.map +1 -0
  5. package/dist/build/report.d.ts +45 -46
  6. package/dist/build/report.js +247 -276
  7. package/dist/build/report.js.map +1 -1
  8. package/dist/build/run-prerender.d.ts +62 -0
  9. package/dist/build/run-prerender.js +183 -0
  10. package/dist/build/run-prerender.js.map +1 -0
  11. package/dist/build/server-manifest.d.ts +19 -0
  12. package/dist/build/server-manifest.js +29 -0
  13. package/dist/build/server-manifest.js.map +1 -0
  14. package/dist/build/static-export.d.ts +51 -66
  15. package/dist/build/static-export.js +51 -545
  16. package/dist/build/static-export.js.map +1 -1
  17. package/dist/check.d.ts +26 -24
  18. package/dist/check.js +591 -567
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts +1 -15
  21. package/dist/cli.js +430 -491
  22. package/dist/cli.js.map +1 -1
  23. package/dist/client/entry.d.ts +1 -2
  24. package/dist/client/entry.js +49 -62
  25. package/dist/client/entry.js.map +1 -1
  26. package/dist/client/validate-module-path.d.ts +4 -1
  27. package/dist/client/validate-module-path.js +23 -28
  28. package/dist/client/validate-module-path.js.map +1 -1
  29. package/dist/client/vinext-next-data.d.ts +15 -20
  30. package/dist/client/vinext-next-data.js +0 -1
  31. package/dist/cloudflare/index.d.ts +3 -8
  32. package/dist/cloudflare/index.js +3 -8
  33. package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
  34. package/dist/cloudflare/kv-cache-handler.js +354 -366
  35. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  36. package/dist/cloudflare/tpr.d.ts +36 -34
  37. package/dist/cloudflare/tpr.js +460 -603
  38. package/dist/cloudflare/tpr.js.map +1 -1
  39. package/dist/config/config-matchers.d.ts +31 -40
  40. package/dist/config/config-matchers.js +727 -936
  41. package/dist/config/config-matchers.js.map +1 -1
  42. package/dist/config/dotenv.d.ts +18 -11
  43. package/dist/config/dotenv.js +79 -84
  44. package/dist/config/dotenv.js.map +1 -1
  45. package/dist/config/next-config.d.ts +156 -146
  46. package/dist/config/next-config.js +374 -464
  47. package/dist/config/next-config.js.map +1 -1
  48. package/dist/deploy.d.ts +87 -96
  49. package/dist/deploy.js +490 -628
  50. package/dist/deploy.js.map +1 -1
  51. package/dist/entries/app-browser-entry.d.ts +4 -1
  52. package/dist/entries/app-browser-entry.js +12 -8
  53. package/dist/entries/app-browser-entry.js.map +1 -1
  54. package/dist/entries/app-rsc-entry.d.ts +33 -20
  55. package/dist/entries/app-rsc-entry.js +618 -343
  56. package/dist/entries/app-rsc-entry.js.map +1 -1
  57. package/dist/entries/app-ssr-entry.d.ts +9 -1
  58. package/dist/entries/app-ssr-entry.js +61 -28
  59. package/dist/entries/app-ssr-entry.js.map +1 -1
  60. package/dist/entries/pages-client-entry.d.ts +6 -2
  61. package/dist/entries/pages-client-entry.js +30 -33
  62. package/dist/entries/pages-client-entry.js.map +1 -1
  63. package/dist/entries/pages-entry-helpers.d.ts +5 -1
  64. package/dist/entries/pages-entry-helpers.js +17 -14
  65. package/dist/entries/pages-entry-helpers.js.map +1 -1
  66. package/dist/entries/pages-server-entry.d.ts +6 -2
  67. package/dist/entries/pages-server-entry.js +229 -207
  68. package/dist/entries/pages-server-entry.js.map +1 -1
  69. package/dist/index.d.ts +82 -62
  70. package/dist/index.js +2172 -3125
  71. package/dist/index.js.map +1 -1
  72. package/dist/init.d.ts +40 -37
  73. package/dist/init.js +201 -258
  74. package/dist/init.js.map +1 -1
  75. package/dist/plugins/async-hooks-stub.d.ts +7 -3
  76. package/dist/plugins/async-hooks-stub.js +39 -42
  77. package/dist/plugins/async-hooks-stub.js.map +1 -1
  78. package/dist/plugins/client-reference-dedup.d.ts +7 -3
  79. package/dist/plugins/client-reference-dedup.js +63 -88
  80. package/dist/plugins/client-reference-dedup.js.map +1 -1
  81. package/dist/routing/app-router.d.ts +100 -96
  82. package/dist/routing/app-router.js +563 -659
  83. package/dist/routing/app-router.js.map +1 -1
  84. package/dist/routing/file-matcher.d.ts +18 -15
  85. package/dist/routing/file-matcher.js +65 -65
  86. package/dist/routing/file-matcher.js.map +1 -1
  87. package/dist/routing/pages-router.d.ts +23 -24
  88. package/dist/routing/pages-router.js +147 -172
  89. package/dist/routing/pages-router.js.map +1 -1
  90. package/dist/routing/route-trie.d.ts +23 -20
  91. package/dist/routing/route-trie.js +131 -151
  92. package/dist/routing/route-trie.js.map +1 -1
  93. package/dist/routing/route-validation.d.ts +5 -2
  94. package/dist/routing/route-validation.js +98 -130
  95. package/dist/routing/route-validation.js.map +1 -1
  96. package/dist/routing/utils.d.ts +10 -7
  97. package/dist/routing/utils.js +75 -111
  98. package/dist/routing/utils.js.map +1 -1
  99. package/dist/server/api-handler.d.ts +8 -13
  100. package/dist/server/api-handler.js +161 -193
  101. package/dist/server/api-handler.js.map +1 -1
  102. package/dist/server/app-router-entry.d.ts +6 -16
  103. package/dist/server/app-router-entry.js +26 -54
  104. package/dist/server/app-router-entry.js.map +1 -1
  105. package/dist/server/dev-module-runner.d.ts +11 -64
  106. package/dist/server/dev-module-runner.js +89 -101
  107. package/dist/server/dev-module-runner.js.map +1 -1
  108. package/dist/server/dev-origin-check.d.ts +12 -10
  109. package/dist/server/dev-origin-check.js +98 -108
  110. package/dist/server/dev-origin-check.js.map +1 -1
  111. package/dist/server/dev-server.d.ts +17 -13
  112. package/dist/server/dev-server.js +547 -874
  113. package/dist/server/dev-server.js.map +1 -1
  114. package/dist/server/html.d.ts +4 -1
  115. package/dist/server/html.js +25 -26
  116. package/dist/server/html.js.map +1 -1
  117. package/dist/server/image-optimization.d.ts +31 -28
  118. package/dist/server/image-optimization.js +183 -200
  119. package/dist/server/image-optimization.js.map +1 -1
  120. package/dist/server/instrumentation.d.ts +25 -22
  121. package/dist/server/instrumentation.js +110 -122
  122. package/dist/server/instrumentation.js.map +1 -1
  123. package/dist/server/isr-cache.d.ts +16 -26
  124. package/dist/server/isr-cache.js +109 -126
  125. package/dist/server/isr-cache.js.map +1 -1
  126. package/dist/server/metadata-routes.d.ts +85 -88
  127. package/dist/server/metadata-routes.js +277 -286
  128. package/dist/server/metadata-routes.js.map +1 -1
  129. package/dist/server/middleware-codegen.d.ts +7 -4
  130. package/dist/server/middleware-codegen.js +98 -65
  131. package/dist/server/middleware-codegen.js.map +1 -1
  132. package/dist/server/middleware-request-headers.d.ts +8 -6
  133. package/dist/server/middleware-request-headers.js +47 -65
  134. package/dist/server/middleware-request-headers.js.map +1 -1
  135. package/dist/server/middleware.d.ts +31 -47
  136. package/dist/server/middleware.js +276 -363
  137. package/dist/server/middleware.js.map +1 -1
  138. package/dist/server/normalize-path.d.ts +4 -1
  139. package/dist/server/normalize-path.js +33 -47
  140. package/dist/server/normalize-path.js.map +1 -1
  141. package/dist/server/pages-i18n.d.ts +58 -0
  142. package/dist/server/pages-i18n.js +125 -0
  143. package/dist/server/pages-i18n.js.map +1 -0
  144. package/dist/server/prod-server.d.ts +19 -31
  145. package/dist/server/prod-server.js +714 -945
  146. package/dist/server/prod-server.js.map +1 -1
  147. package/dist/server/request-log.d.ts +18 -12
  148. package/dist/server/request-log.js +45 -52
  149. package/dist/server/request-log.js.map +1 -1
  150. package/dist/server/request-pipeline.d.ts +9 -17
  151. package/dist/server/request-pipeline.js +133 -184
  152. package/dist/server/request-pipeline.js.map +1 -1
  153. package/dist/server/worker-utils.d.ts +4 -1
  154. package/dist/server/worker-utils.js +31 -37
  155. package/dist/server/worker-utils.js.map +1 -1
  156. package/dist/shims/amp.d.ts +5 -2
  157. package/dist/shims/amp.js +19 -15
  158. package/dist/shims/amp.js.map +1 -1
  159. package/dist/shims/app.d.ts +8 -10
  160. package/dist/shims/app.js +0 -1
  161. package/dist/shims/cache-runtime.d.ts +21 -43
  162. package/dist/shims/cache-runtime.js +271 -405
  163. package/dist/shims/cache-runtime.js.map +1 -1
  164. package/dist/shims/cache.d.ts +131 -119
  165. package/dist/shims/cache.js +339 -418
  166. package/dist/shims/cache.js.map +1 -1
  167. package/dist/shims/client-only.d.ts +1 -18
  168. package/dist/shims/client-only.js +0 -17
  169. package/dist/shims/compat-router.d.ts +4 -1
  170. package/dist/shims/compat-router.js +23 -19
  171. package/dist/shims/compat-router.js.map +1 -1
  172. package/dist/shims/config.d.ts +7 -5
  173. package/dist/shims/config.js +16 -23
  174. package/dist/shims/config.js.map +1 -1
  175. package/dist/shims/constants.d.ts +119 -118
  176. package/dist/shims/constants.js +159 -165
  177. package/dist/shims/constants.js.map +1 -1
  178. package/dist/shims/document.d.ts +20 -16
  179. package/dist/shims/document.js +41 -22
  180. package/dist/shims/document.js.map +1 -1
  181. package/dist/shims/dynamic.d.ts +13 -22
  182. package/dist/shims/dynamic.js +122 -136
  183. package/dist/shims/dynamic.js.map +1 -1
  184. package/dist/shims/error-boundary.d.ts +22 -15
  185. package/dist/shims/error-boundary.js +81 -79
  186. package/dist/shims/error-boundary.js.map +1 -1
  187. package/dist/shims/error.d.ts +11 -12
  188. package/dist/shims/error.js +35 -39
  189. package/dist/shims/error.js.map +1 -1
  190. package/dist/shims/fetch-cache.d.ts +26 -10
  191. package/dist/shims/fetch-cache.js +443 -586
  192. package/dist/shims/fetch-cache.js.map +1 -1
  193. package/dist/shims/font-google-base.d.ts +28 -26
  194. package/dist/shims/font-google-base.js +238 -325
  195. package/dist/shims/font-google-base.js.map +1 -1
  196. package/dist/shims/font-google.d.ts +3 -3
  197. package/dist/shims/font-google.generated.d.ts +1928 -1924
  198. package/dist/shims/font-google.generated.js +1928 -2133
  199. package/dist/shims/font-google.generated.js.map +1 -1
  200. package/dist/shims/font-google.js +3 -3
  201. package/dist/shims/font-local.d.ts +28 -26
  202. package/dist/shims/font-local.js +204 -260
  203. package/dist/shims/font-local.js.map +1 -1
  204. package/dist/shims/form.d.ts +13 -27
  205. package/dist/shims/form.js +128 -180
  206. package/dist/shims/form.js.map +1 -1
  207. package/dist/shims/head-state.d.ts +9 -10
  208. package/dist/shims/head-state.js +25 -39
  209. package/dist/shims/head-state.js.map +1 -1
  210. package/dist/shims/head.d.ts +16 -18
  211. package/dist/shims/head.js +185 -153
  212. package/dist/shims/head.js.map +1 -1
  213. package/dist/shims/headers.d.ts +84 -71
  214. package/dist/shims/headers.js +447 -583
  215. package/dist/shims/headers.js.map +1 -1
  216. package/dist/shims/i18n-context.d.ts +23 -0
  217. package/dist/shims/i18n-context.js +44 -0
  218. package/dist/shims/i18n-context.js.map +1 -0
  219. package/dist/shims/i18n-state.d.ts +14 -0
  220. package/dist/shims/i18n-state.js +45 -0
  221. package/dist/shims/i18n-state.js.map +1 -0
  222. package/dist/shims/image-config.d.ts +11 -8
  223. package/dist/shims/image-config.js +50 -83
  224. package/dist/shims/image-config.js.map +1 -1
  225. package/dist/shims/image.d.ts +37 -44
  226. package/dist/shims/image.js +284 -301
  227. package/dist/shims/image.js.map +1 -1
  228. package/dist/shims/internal/api-utils.d.ts +7 -4
  229. package/dist/shims/internal/api-utils.js +0 -6
  230. package/dist/shims/internal/app-router-context.d.ts +22 -17
  231. package/dist/shims/internal/app-router-context.js +17 -13
  232. package/dist/shims/internal/app-router-context.js.map +1 -1
  233. package/dist/shims/internal/cookies.d.ts +2 -9
  234. package/dist/shims/internal/cookies.js +2 -9
  235. package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
  236. package/dist/shims/internal/parse-cookie-header.js +29 -29
  237. package/dist/shims/internal/parse-cookie-header.js.map +1 -1
  238. package/dist/shims/internal/router-context.d.ts +6 -1
  239. package/dist/shims/internal/router-context.js +11 -7
  240. package/dist/shims/internal/router-context.js.map +1 -1
  241. package/dist/shims/internal/utils.d.ts +40 -36
  242. package/dist/shims/internal/utils.js +24 -30
  243. package/dist/shims/internal/utils.js.map +1 -1
  244. package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
  245. package/dist/shims/internal/work-unit-async-storage.js +14 -11
  246. package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
  247. package/dist/shims/layout-segment-context.d.ts +11 -14
  248. package/dist/shims/layout-segment-context.js +24 -23
  249. package/dist/shims/layout-segment-context.js.map +1 -1
  250. package/dist/shims/legacy-image.d.ts +39 -46
  251. package/dist/shims/legacy-image.js +47 -42
  252. package/dist/shims/legacy-image.js.map +1 -1
  253. package/dist/shims/link.d.ts +32 -36
  254. package/dist/shims/link.js +262 -382
  255. package/dist/shims/link.js.map +1 -1
  256. package/dist/shims/metadata.d.ts +210 -202
  257. package/dist/shims/metadata.js +545 -544
  258. package/dist/shims/metadata.js.map +1 -1
  259. package/dist/shims/navigation-state.d.ts +19 -13
  260. package/dist/shims/navigation-state.js +68 -58
  261. package/dist/shims/navigation-state.js.map +1 -1
  262. package/dist/shims/navigation.d.ts +59 -63
  263. package/dist/shims/navigation.js +508 -690
  264. package/dist/shims/navigation.js.map +1 -1
  265. package/dist/shims/og.d.ts +2 -20
  266. package/dist/shims/og.js +2 -19
  267. package/dist/shims/readonly-url-search-params.d.ts +8 -5
  268. package/dist/shims/readonly-url-search-params.js +26 -22
  269. package/dist/shims/readonly-url-search-params.js.map +1 -1
  270. package/dist/shims/request-context.d.ts +8 -5
  271. package/dist/shims/request-context.js +50 -51
  272. package/dist/shims/request-context.js.map +1 -1
  273. package/dist/shims/request-state-types.d.ts +11 -0
  274. package/dist/shims/request-state-types.js +1 -0
  275. package/dist/shims/router-state.d.ts +15 -1
  276. package/dist/shims/router-state.js +34 -41
  277. package/dist/shims/router-state.js.map +1 -1
  278. package/dist/shims/router.d.ts +81 -81
  279. package/dist/shims/router.js +517 -543
  280. package/dist/shims/router.js.map +1 -1
  281. package/dist/shims/script.d.ts +39 -48
  282. package/dist/shims/script.js +107 -160
  283. package/dist/shims/script.js.map +1 -1
  284. package/dist/shims/server-only.d.ts +1 -19
  285. package/dist/shims/server-only.js +0 -18
  286. package/dist/shims/server.d.ts +175 -157
  287. package/dist/shims/server.js +462 -432
  288. package/dist/shims/server.js.map +1 -1
  289. package/dist/shims/unified-request-context.d.ts +66 -0
  290. package/dist/shims/unified-request-context.js +98 -0
  291. package/dist/shims/unified-request-context.js.map +1 -0
  292. package/dist/shims/url-safety.d.ts +4 -1
  293. package/dist/shims/url-safety.js +15 -11
  294. package/dist/shims/url-safety.js.map +1 -1
  295. package/dist/shims/url-utils.d.ts +8 -5
  296. package/dist/shims/url-utils.js +62 -93
  297. package/dist/shims/url-utils.js.map +1 -1
  298. package/dist/shims/web-vitals.d.ts +10 -8
  299. package/dist/shims/web-vitals.js +9 -15
  300. package/dist/shims/web-vitals.js.map +1 -1
  301. package/dist/utils/base-path.d.ts +5 -2
  302. package/dist/utils/base-path.js +21 -19
  303. package/dist/utils/base-path.js.map +1 -1
  304. package/dist/utils/domain-locale.d.ts +26 -0
  305. package/dist/utils/domain-locale.js +44 -0
  306. package/dist/utils/domain-locale.js.map +1 -0
  307. package/dist/utils/hash.d.ts +4 -1
  308. package/dist/utils/hash.js +19 -17
  309. package/dist/utils/hash.js.map +1 -1
  310. package/dist/utils/manifest-paths.d.ts +6 -3
  311. package/dist/utils/manifest-paths.js +15 -16
  312. package/dist/utils/manifest-paths.js.map +1 -1
  313. package/dist/utils/project.d.ts +13 -11
  314. package/dist/utils/project.js +169 -216
  315. package/dist/utils/project.js.map +1 -1
  316. package/dist/utils/query.d.ts +8 -6
  317. package/dist/utils/query.js +57 -67
  318. package/dist/utils/query.js.map +1 -1
  319. package/package.json +11 -10
  320. package/dist/build/report.d.ts.map +0 -1
  321. package/dist/build/static-export.d.ts.map +0 -1
  322. package/dist/check.d.ts.map +0 -1
  323. package/dist/cli.d.ts.map +0 -1
  324. package/dist/client/entry.d.ts.map +0 -1
  325. package/dist/client/validate-module-path.d.ts.map +0 -1
  326. package/dist/client/vinext-next-data.d.ts.map +0 -1
  327. package/dist/client/vinext-next-data.js.map +0 -1
  328. package/dist/cloudflare/index.d.ts.map +0 -1
  329. package/dist/cloudflare/index.js.map +0 -1
  330. package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
  331. package/dist/cloudflare/tpr.d.ts.map +0 -1
  332. package/dist/config/config-matchers.d.ts.map +0 -1
  333. package/dist/config/dotenv.d.ts.map +0 -1
  334. package/dist/config/next-config.d.ts.map +0 -1
  335. package/dist/deploy.d.ts.map +0 -1
  336. package/dist/entries/app-browser-entry.d.ts.map +0 -1
  337. package/dist/entries/app-rsc-entry.d.ts.map +0 -1
  338. package/dist/entries/app-ssr-entry.d.ts.map +0 -1
  339. package/dist/entries/pages-client-entry.d.ts.map +0 -1
  340. package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
  341. package/dist/entries/pages-server-entry.d.ts.map +0 -1
  342. package/dist/index.d.ts.map +0 -1
  343. package/dist/init.d.ts.map +0 -1
  344. package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
  345. package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
  346. package/dist/routing/app-router.d.ts.map +0 -1
  347. package/dist/routing/file-matcher.d.ts.map +0 -1
  348. package/dist/routing/pages-router.d.ts.map +0 -1
  349. package/dist/routing/route-trie.d.ts.map +0 -1
  350. package/dist/routing/route-validation.d.ts.map +0 -1
  351. package/dist/routing/utils.d.ts.map +0 -1
  352. package/dist/server/api-handler.d.ts.map +0 -1
  353. package/dist/server/app-router-entry.d.ts.map +0 -1
  354. package/dist/server/dev-module-runner.d.ts.map +0 -1
  355. package/dist/server/dev-origin-check.d.ts.map +0 -1
  356. package/dist/server/dev-server.d.ts.map +0 -1
  357. package/dist/server/html.d.ts.map +0 -1
  358. package/dist/server/image-optimization.d.ts.map +0 -1
  359. package/dist/server/instrumentation.d.ts.map +0 -1
  360. package/dist/server/isr-cache.d.ts.map +0 -1
  361. package/dist/server/metadata-routes.d.ts.map +0 -1
  362. package/dist/server/middleware-codegen.d.ts.map +0 -1
  363. package/dist/server/middleware-request-headers.d.ts.map +0 -1
  364. package/dist/server/middleware.d.ts.map +0 -1
  365. package/dist/server/normalize-path.d.ts.map +0 -1
  366. package/dist/server/prod-server.d.ts.map +0 -1
  367. package/dist/server/request-log.d.ts.map +0 -1
  368. package/dist/server/request-pipeline.d.ts.map +0 -1
  369. package/dist/server/worker-utils.d.ts.map +0 -1
  370. package/dist/shims/amp.d.ts.map +0 -1
  371. package/dist/shims/app.d.ts.map +0 -1
  372. package/dist/shims/app.js.map +0 -1
  373. package/dist/shims/cache-runtime.d.ts.map +0 -1
  374. package/dist/shims/cache.d.ts.map +0 -1
  375. package/dist/shims/client-only.d.ts.map +0 -1
  376. package/dist/shims/client-only.js.map +0 -1
  377. package/dist/shims/compat-router.d.ts.map +0 -1
  378. package/dist/shims/config.d.ts.map +0 -1
  379. package/dist/shims/constants.d.ts.map +0 -1
  380. package/dist/shims/document.d.ts.map +0 -1
  381. package/dist/shims/dynamic.d.ts.map +0 -1
  382. package/dist/shims/error-boundary.d.ts.map +0 -1
  383. package/dist/shims/error.d.ts.map +0 -1
  384. package/dist/shims/fetch-cache.d.ts.map +0 -1
  385. package/dist/shims/font-google-base.d.ts.map +0 -1
  386. package/dist/shims/font-google.d.ts.map +0 -1
  387. package/dist/shims/font-google.generated.d.ts.map +0 -1
  388. package/dist/shims/font-google.js.map +0 -1
  389. package/dist/shims/font-local.d.ts.map +0 -1
  390. package/dist/shims/form.d.ts.map +0 -1
  391. package/dist/shims/head-state.d.ts.map +0 -1
  392. package/dist/shims/head.d.ts.map +0 -1
  393. package/dist/shims/headers.d.ts.map +0 -1
  394. package/dist/shims/image-config.d.ts.map +0 -1
  395. package/dist/shims/image.d.ts.map +0 -1
  396. package/dist/shims/internal/api-utils.d.ts.map +0 -1
  397. package/dist/shims/internal/api-utils.js.map +0 -1
  398. package/dist/shims/internal/app-router-context.d.ts.map +0 -1
  399. package/dist/shims/internal/cookies.d.ts.map +0 -1
  400. package/dist/shims/internal/cookies.js.map +0 -1
  401. package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
  402. package/dist/shims/internal/router-context.d.ts.map +0 -1
  403. package/dist/shims/internal/utils.d.ts.map +0 -1
  404. package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
  405. package/dist/shims/layout-segment-context.d.ts.map +0 -1
  406. package/dist/shims/legacy-image.d.ts.map +0 -1
  407. package/dist/shims/link.d.ts.map +0 -1
  408. package/dist/shims/metadata.d.ts.map +0 -1
  409. package/dist/shims/navigation-state.d.ts.map +0 -1
  410. package/dist/shims/navigation.d.ts.map +0 -1
  411. package/dist/shims/og.d.ts.map +0 -1
  412. package/dist/shims/og.js.map +0 -1
  413. package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
  414. package/dist/shims/request-context.d.ts.map +0 -1
  415. package/dist/shims/router-state.d.ts.map +0 -1
  416. package/dist/shims/router.d.ts.map +0 -1
  417. package/dist/shims/script.d.ts.map +0 -1
  418. package/dist/shims/server-only.d.ts.map +0 -1
  419. package/dist/shims/server-only.js.map +0 -1
  420. package/dist/shims/server.d.ts.map +0 -1
  421. package/dist/shims/url-safety.d.ts.map +0 -1
  422. package/dist/shims/url-utils.d.ts.map +0 -1
  423. package/dist/shims/web-vitals.d.ts.map +0 -1
  424. package/dist/utils/base-path.d.ts.map +0 -1
  425. package/dist/utils/hash.d.ts.map +0 -1
  426. package/dist/utils/manifest-paths.d.ts.map +0 -1
  427. package/dist/utils/project.d.ts.map +0 -1
  428. package/dist/utils/query.d.ts.map +0 -1
@@ -1,99 +1,77 @@
1
- /**
2
- * Pages Router server entry generator.
3
- *
4
- * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).
5
- * This is the entry point for `vite build --ssr`. It handles SSR, API routes,
6
- * middleware, ISR, and i18n for the Pages Router.
7
- *
8
- * Extracted from index.ts.
9
- */
10
- import path from "node:path";
11
- import { fileURLToPath } from "node:url";
12
- import { pagesRouter, apiRouter } from "../routing/pages-router.js";
1
+ import { apiRouter, pagesRouter } from "../routing/pages-router.js";
13
2
  import { isProxyFile } from "../server/middleware.js";
14
- import { generateSafeRegExpCode, generateMiddlewareMatcherCode, generateNormalizePathCode, generateRouteMatchNormalizationCode, } from "../server/middleware-codegen.js";
3
+ import { generateMiddlewareMatcherCode, generateNormalizePathCode, generateRouteMatchNormalizationCode, generateSafeRegExpCode } from "../server/middleware-codegen.js";
15
4
  import { findFileWithExts } from "./pages-entry-helpers.js";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ //#region src/entries/pages-server-entry.ts
8
+ /**
9
+ * Pages Router server entry generator.
10
+ *
11
+ * Generates the virtual SSR server entry module (`virtual:vinext-server-entry`).
12
+ * This is the entry point for `vite build --ssr`. It handles SSR, API routes,
13
+ * middleware, ISR, and i18n for the Pages Router.
14
+ *
15
+ * Extracted from index.ts.
16
+ */
16
17
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
17
18
  const _requestContextShimPath = fileURLToPath(new URL("../shims/request-context.js", import.meta.url)).replace(/\\/g, "/");
18
19
  const _routeTriePath = fileURLToPath(new URL("../routing/route-trie.js", import.meta.url)).replace(/\\/g, "/");
20
+ const _pagesI18nPath = fileURLToPath(new URL("../server/pages-i18n.js", import.meta.url)).replace(/\\/g, "/");
19
21
  /**
20
- * Generate the virtual SSR server entry module.
21
- * This is the entry point for `vite build --ssr`.
22
- */
23
- export async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath) {
24
- const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
25
- const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
26
- // Generate import statements using absolute paths since virtual
27
- // modules don't have a real file location for relative resolution.
28
- const pageImports = pageRoutes.map((r, i) => {
29
- const absPath = r.filePath.replace(/\\/g, "/");
30
- return `import * as page_${i} from ${JSON.stringify(absPath)};`;
31
- });
32
- const apiImports = apiRoutes.map((r, i) => {
33
- const absPath = r.filePath.replace(/\\/g, "/");
34
- return `import * as api_${i} from ${JSON.stringify(absPath)};`;
35
- });
36
- // Build the route table include filePath for SSR manifest lookup
37
- const pageRouteEntries = pageRoutes.map((r, i) => {
38
- const absPath = r.filePath.replace(/\\/g, "/");
39
- 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)} }`;
40
- });
41
- const apiRouteEntries = apiRoutes.map((r, i) => {
42
- return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`;
43
- });
44
- // Check for _app and _document
45
- const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
46
- const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
47
- const hasApp = appFilePath !== null;
48
- const hasDoc = docFilePath !== null;
49
- const appImportCode = hasApp
50
- ? `import { default as AppComponent } from ${JSON.stringify(appFilePath.replace(/\\/g, "/"))};`
51
- : `const AppComponent = null;`;
52
- const docImportCode = hasDoc
53
- ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath.replace(/\\/g, "/"))};`
54
- : `const DocumentComponent = null;`;
55
- // Serialize i18n config for embedding in the server entry
56
- const i18nConfigJson = nextConfig?.i18n
57
- ? JSON.stringify({
58
- locales: nextConfig.i18n.locales,
59
- defaultLocale: nextConfig.i18n.defaultLocale,
60
- localeDetection: nextConfig.i18n.localeDetection,
61
- })
62
- : "null";
63
- // Embed the resolved build ID at build time
64
- const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);
65
- // Serialize the full resolved config for the production server.
66
- // This embeds redirects, rewrites, headers, basePath, trailingSlash
67
- // so prod-server.ts can apply them without loading next.config.js at runtime.
68
- const vinextConfigJson = JSON.stringify({
69
- basePath: nextConfig?.basePath ?? "",
70
- trailingSlash: nextConfig?.trailingSlash ?? false,
71
- redirects: nextConfig?.redirects ?? [],
72
- rewrites: nextConfig?.rewrites ?? { beforeFiles: [], afterFiles: [], fallback: [] },
73
- headers: nextConfig?.headers ?? [],
74
- i18n: nextConfig?.i18n ?? null,
75
- images: {
76
- deviceSizes: nextConfig?.images?.deviceSizes,
77
- imageSizes: nextConfig?.images?.imageSizes,
78
- dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
79
- contentDispositionType: nextConfig?.images?.contentDispositionType,
80
- contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy,
81
- },
82
- });
83
- // Generate instrumentation code if instrumentation.ts exists.
84
- // For production (Cloudflare Workers), instrumentation.ts is bundled into the
85
- // Worker and register() is called as a top-level await at module evaluation time —
86
- // before any request is handled. This mirrors App Router behavior (generateRscEntry)
87
- // and matches Next.js semantics: register() runs once on startup in the process
88
- // that handles requests.
89
- //
90
- // The onRequestError handler is stored on globalThis so it is visible across
91
- // all code within the Worker (same global scope).
92
- const instrumentationImportCode = instrumentationPath
93
- ? `import * as _instrumentation from ${JSON.stringify(instrumentationPath.replace(/\\/g, "/"))};`
94
- : "";
95
- const instrumentationInitCode = instrumentationPath
96
- ? `// Run instrumentation register() once at module evaluation time — before any
22
+ * Generate the virtual SSR server entry module.
23
+ * This is the entry point for `vite build --ssr`.
24
+ */
25
+ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath) {
26
+ const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
27
+ const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
28
+ const pageImports = pageRoutes.map((r, i) => {
29
+ const absPath = r.filePath.replace(/\\/g, "/");
30
+ return `import * as page_${i} from ${JSON.stringify(absPath)};`;
31
+ });
32
+ const apiImports = apiRoutes.map((r, i) => {
33
+ const absPath = r.filePath.replace(/\\/g, "/");
34
+ return `import * as api_${i} from ${JSON.stringify(absPath)};`;
35
+ });
36
+ const pageRouteEntries = pageRoutes.map((r, i) => {
37
+ const absPath = r.filePath.replace(/\\/g, "/");
38
+ 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)} }`;
39
+ });
40
+ const apiRouteEntries = apiRoutes.map((r, i) => {
41
+ return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`;
42
+ });
43
+ const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
44
+ const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
45
+ const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(appFilePath.replace(/\\/g, "/"))};` : `const AppComponent = null;`;
46
+ const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath.replace(/\\/g, "/"))};` : `const DocumentComponent = null;`;
47
+ const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
48
+ locales: nextConfig.i18n.locales,
49
+ defaultLocale: nextConfig.i18n.defaultLocale,
50
+ localeDetection: nextConfig.i18n.localeDetection,
51
+ domains: nextConfig.i18n.domains
52
+ }) : "null";
53
+ const buildIdJson = JSON.stringify(nextConfig?.buildId ?? null);
54
+ const vinextConfigJson = JSON.stringify({
55
+ basePath: nextConfig?.basePath ?? "",
56
+ trailingSlash: nextConfig?.trailingSlash ?? false,
57
+ redirects: nextConfig?.redirects ?? [],
58
+ rewrites: nextConfig?.rewrites ?? {
59
+ beforeFiles: [],
60
+ afterFiles: [],
61
+ fallback: []
62
+ },
63
+ headers: nextConfig?.headers ?? [],
64
+ i18n: nextConfig?.i18n ?? null,
65
+ images: {
66
+ deviceSizes: nextConfig?.images?.deviceSizes,
67
+ imageSizes: nextConfig?.images?.imageSizes,
68
+ dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
69
+ contentDispositionType: nextConfig?.images?.contentDispositionType,
70
+ contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
71
+ }
72
+ });
73
+ const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(instrumentationPath.replace(/\\/g, "/"))};` : "";
74
+ const instrumentationInitCode = instrumentationPath ? `// Run instrumentation register() once at module evaluation time — before any
97
75
  // requests are handled. Matches Next.js semantics: register() is called once
98
76
  // on startup in the process that handles requests.
99
77
  if (typeof _instrumentation.register === "function") {
@@ -103,17 +81,10 @@ if (typeof _instrumentation.register === "function") {
103
81
  // code within the Worker (same global scope).
104
82
  if (typeof _instrumentation.onRequestError === "function") {
105
83
  globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;
106
- }`
107
- : "";
108
- // Generate middleware code if middleware.ts exists
109
- const middlewareImportCode = middlewarePath
110
- ? `import * as middlewareModule from ${JSON.stringify(middlewarePath.replace(/\\/g, "/"))};
111
- import { NextRequest, NextFetchEvent } from "next/server";`
112
- : "";
113
- // The matcher config is read from the middleware module at import time.
114
- // We inline the matching + execution logic so the prod server can call it.
115
- const middlewareExportCode = middlewarePath
116
- ? `
84
+ }` : "";
85
+ const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(middlewarePath.replace(/\\/g, "/"))};
86
+ import { NextRequest, NextFetchEvent } from "next/server";` : "";
87
+ const middlewareExportCode = middlewarePath ? `
117
88
  // --- Middleware support (generated from middleware-codegen.ts) ---
118
89
  ${generateNormalizePathCode("es5")}
119
90
  ${generateRouteMatchNormalizationCode("es5")}
@@ -211,32 +182,33 @@ async function _runMiddleware(request) {
211
182
 
212
183
  return { continue: false, response: response };
213
184
  }
214
- `
215
- : `
185
+ ` : `
216
186
  export async function runMiddleware() { return { continue: true }; }
217
187
  `;
218
- // The server entry is a self-contained module that uses Web-standard APIs
219
- // (Request/Response, renderToReadableStream) so it runs on Cloudflare Workers.
220
- return `
188
+ return `
221
189
  import React from "react";
222
190
  import { renderToReadableStream } from "react-dom/server.edge";
223
191
  import { resetSSRHead, getSSRHeadHTML } from "next/head";
224
192
  import { flushPreloads } from "next/dynamic";
225
193
  import { setSSRContext, wrapWithRouterContext } from "next/router";
226
- import { getCacheHandler } from "next/cache";
227
- import { runWithFetchCache } from "vinext/fetch-cache";
228
- import { _runWithCacheState } from "next/cache";
194
+ import { getCacheHandler, _runWithCacheState } from "next/cache";
229
195
  import { runWithPrivateCache } from "vinext/cache-runtime";
230
- import { runWithRouterState } from "vinext/router-state";
196
+ import { ensureFetchPatch, runWithFetchCache } from "vinext/fetch-cache";
197
+ import { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from "vinext/unified-request-context";
198
+ import "vinext/router-state";
199
+ import { runWithServerInsertedHTMLState } from "vinext/navigation-state";
231
200
  import { runWithHeadState } from "vinext/head-state";
201
+ import "vinext/i18n-state";
202
+ import { setI18nContext } from "vinext/i18n-context";
232
203
  import { safeJsonStringify } from "vinext/html";
233
204
  import { decode as decodeQueryString } from "node:querystring";
234
205
  import { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from "next/font/google";
235
206
  import { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from "next/font/local";
236
- import { parseCookies } from ${JSON.stringify(path.resolve(__dirname, "../config/config-matchers.js").replace(/\\/g, "/"))};
207
+ import { parseCookies, sanitizeDestination as sanitizeDestinationLocal } from ${JSON.stringify(path.resolve(__dirname, "../config/config-matchers.js").replace(/\\/g, "/"))};
237
208
  import { runWithExecutionContext as _runWithExecutionContext, getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(_requestContextShimPath)};
238
209
  import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(_routeTriePath)};
239
210
  import { reportRequestError as _reportRequestError } from "vinext/instrumentation";
211
+ import { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};
240
212
  ${instrumentationImportCode}
241
213
  ${middlewareImportCode}
242
214
 
@@ -322,13 +294,28 @@ async function renderToStringAsync(element) {
322
294
  return new Response(stream).text();
323
295
  }
324
296
 
297
+ async function renderIsrPassToStringAsync(element) {
298
+ // The cache-fill render is a second render pass for the same request.
299
+ // Reset render-scoped state so it cannot leak from the streamed response
300
+ // render or affect async work that is still draining from that stream.
301
+ // Keep request identity state (pathname/query/locale/executionContext)
302
+ // intact: this second pass still belongs to the same request.
303
+ return await runWithServerInsertedHTMLState(() =>
304
+ runWithHeadState(() =>
305
+ _runWithCacheState(() =>
306
+ runWithPrivateCache(() => runWithFetchCache(async () => renderToStringAsync(element))),
307
+ ),
308
+ ),
309
+ );
310
+ }
311
+
325
312
  ${pageImports.join("\n")}
326
313
  ${apiImports.join("\n")}
327
314
 
328
315
  ${appImportCode}
329
316
  ${docImportCode}
330
317
 
331
- const pageRoutes = [
318
+ export const pageRoutes = [
332
319
  ${pageRouteEntries.join(",\n")}
333
320
  ];
334
321
  const _pageRouteTrie = _buildRouteTrie(pageRoutes);
@@ -390,7 +377,7 @@ function collectAssetTags(manifest, moduleIds) {
390
377
  const entry = globalThis.__VINEXT_CLIENT_ENTRY__;
391
378
  seen.add(entry);
392
379
  tags.push('<link rel="modulepreload" href="/' + entry + '" />');
393
- tags.push('<script type="module" src="/' + entry + '" crossorigin></script>');
380
+ tags.push('<script type="module" src="/' + entry + '" crossorigin><\/script>');
394
381
  }
395
382
  if (m) {
396
383
  // Always inject shared chunks (framework, vinext runtime, entry) and
@@ -471,7 +458,7 @@ function collectAssetTags(manifest, moduleIds) {
471
458
  // (React.lazy, next/dynamic) and should only be fetched on demand.
472
459
  if (lazySet && lazySet.has(tf)) continue;
473
460
  tags.push('<link rel="modulepreload" href="/' + tf + '" />');
474
- tags.push('<script type="module" src="/' + tf + '" crossorigin></script>');
461
+ tags.push('<script type="module" src="/' + tf + '" crossorigin><\/script>');
475
462
  }
476
463
  }
477
464
  }
@@ -651,23 +638,25 @@ export async function renderPage(request, url, manifest, ctx) {
651
638
  }
652
639
 
653
640
  async function _renderPage(request, url, manifest) {
654
- const localeInfo = extractLocale(url);
641
+ const localeInfo = i18nConfig
642
+ ? resolvePagesI18nRequest(
643
+ url,
644
+ i18nConfig,
645
+ request.headers,
646
+ new URL(request.url).hostname,
647
+ vinextConfig.basePath,
648
+ vinextConfig.trailingSlash,
649
+ )
650
+ : { locale: undefined, url, hadPrefix: false, domainLocale: undefined, redirectUrl: undefined };
655
651
  const locale = localeInfo.locale;
656
652
  const routeUrl = localeInfo.url;
657
- const cookieHeader = request.headers.get("cookie") || "";
653
+ const currentDefaultLocale = i18nConfig
654
+ ? (localeInfo.domainLocale ? localeInfo.domainLocale.defaultLocale : i18nConfig.defaultLocale)
655
+ : undefined;
656
+ const domainLocales = i18nConfig ? i18nConfig.domains : undefined;
658
657
 
659
- // i18n redirect: check NEXT_LOCALE cookie first, then Accept-Language
660
- if (i18nConfig && !localeInfo.hadPrefix) {
661
- const cookieLocale = parseCookieLocaleFromHeader(cookieHeader);
662
- if (cookieLocale && cookieLocale !== i18nConfig.defaultLocale) {
663
- return new Response(null, { status: 307, headers: { Location: "/" + cookieLocale + routeUrl } });
664
- }
665
- if (!cookieLocale && i18nConfig.localeDetection !== false) {
666
- const detected = detectLocaleFromHeaders(request.headers);
667
- if (detected && detected !== i18nConfig.defaultLocale) {
668
- return new Response(null, { status: 307, headers: { Location: "/" + detected + routeUrl } });
669
- }
670
- }
658
+ if (localeInfo.redirectUrl) {
659
+ return new Response(null, { status: 307, headers: { Location: localeInfo.redirectUrl } });
671
660
  }
672
661
 
673
662
  const match = matchRoute(routeUrl, pageRoutes);
@@ -677,12 +666,12 @@ async function _renderPage(request, url, manifest) {
677
666
  }
678
667
 
679
668
  const { route, params } = match;
680
- return runWithRouterState(() =>
681
- runWithHeadState(() =>
682
- _runWithCacheState(() =>
683
- runWithPrivateCache(() =>
684
- runWithFetchCache(async () => {
685
- try {
669
+ const __uCtx = _createUnifiedCtx({
670
+ executionContext: _getRequestExecutionContext(),
671
+ });
672
+ return _runWithUnifiedCtx(__uCtx, async () => {
673
+ ensureFetchPatch();
674
+ try {
686
675
  if (typeof setSSRContext === "function") {
687
676
  setSSRContext({
688
677
  pathname: patternToNextFormat(route.pattern),
@@ -690,14 +679,19 @@ async function _renderPage(request, url, manifest) {
690
679
  asPath: routeUrl,
691
680
  locale: locale,
692
681
  locales: i18nConfig ? i18nConfig.locales : undefined,
693
- defaultLocale: i18nConfig ? i18nConfig.defaultLocale : undefined,
682
+ defaultLocale: currentDefaultLocale,
683
+ domainLocales: domainLocales,
694
684
  });
695
685
  }
696
686
 
697
687
  if (i18nConfig) {
698
- globalThis.__VINEXT_LOCALE__ = locale;
699
- globalThis.__VINEXT_LOCALES__ = i18nConfig.locales;
700
- globalThis.__VINEXT_DEFAULT_LOCALE__ = i18nConfig.defaultLocale;
688
+ setI18nContext({
689
+ locale: locale,
690
+ locales: i18nConfig.locales,
691
+ defaultLocale: currentDefaultLocale,
692
+ domainLocales: domainLocales,
693
+ hostname: new URL(request.url).hostname,
694
+ });
701
695
  }
702
696
 
703
697
  const pageModule = route.module;
@@ -710,7 +704,7 @@ async function _renderPage(request, url, manifest) {
710
704
  if (typeof pageModule.getStaticPaths === "function" && route.isDynamic) {
711
705
  const pathsResult = await pageModule.getStaticPaths({
712
706
  locales: i18nConfig ? i18nConfig.locales : [],
713
- defaultLocale: i18nConfig ? i18nConfig.defaultLocale : "",
707
+ defaultLocale: currentDefaultLocale || "",
714
708
  });
715
709
  const fallback = pathsResult && pathsResult.fallback !== undefined ? pathsResult.fallback : false;
716
710
 
@@ -743,7 +737,7 @@ async function _renderPage(request, url, manifest) {
743
737
  resolvedUrl: routeUrl,
744
738
  locale: locale,
745
739
  locales: i18nConfig ? i18nConfig.locales : undefined,
746
- defaultLocale: i18nConfig ? i18nConfig.defaultLocale : undefined,
740
+ defaultLocale: currentDefaultLocale,
747
741
  };
748
742
  const result = await pageModule.getServerSideProps(ctx);
749
743
  // If gSSP called res.end() directly (short-circuit), return that response.
@@ -792,61 +786,89 @@ async function _renderPage(request, url, manifest) {
792
786
 
793
787
  if (cached && cached.isStale && cached.value.value && cached.value.value.kind === "PAGES") {
794
788
  triggerBackgroundRegeneration(cacheKey, async function() {
795
- var freshResult = await pageModule.getStaticProps({
796
- params: params,
797
- locale: locale,
798
- locales: i18nConfig ? i18nConfig.locales : undefined,
799
- defaultLocale: i18nConfig ? i18nConfig.defaultLocale : undefined,
789
+ var revalCtx = _createUnifiedCtx({
790
+ executionContext: _getRequestExecutionContext(),
800
791
  });
801
- if (freshResult && freshResult.props && typeof freshResult.revalidate === "number" && freshResult.revalidate > 0) {
802
- var _fp = freshResult.props;
803
- // Re-render the page with fresh props
804
- var _el = AppComponent
805
- ? React.createElement(AppComponent, { Component: PageComponent, pageProps: _fp })
806
- : React.createElement(PageComponent, _fp);
807
- _el = wrapWithRouterContext(_el);
808
- var _freshBody = await renderToStringAsync(_el);
809
- // Rebuild __NEXT_DATA__ with fresh props
810
- var _regenPayload = {
811
- props: { pageProps: _fp }, page: patternToNextFormat(route.pattern),
812
- query: params, buildId: buildId, isFallback: false,
813
- };
814
- if (i18nConfig) {
815
- _regenPayload.locale = locale;
816
- _regenPayload.locales = i18nConfig.locales;
817
- _regenPayload.defaultLocale = i18nConfig.defaultLocale;
818
- }
819
- var _lGlobals = i18nConfig
820
- ? ";window.__VINEXT_LOCALE__=" + safeJsonStringify(locale) +
821
- ";window.__VINEXT_LOCALES__=" + safeJsonStringify(i18nConfig.locales) +
822
- ";window.__VINEXT_DEFAULT_LOCALE__=" + safeJsonStringify(i18nConfig.defaultLocale)
823
- : "";
824
- var _freshNDS = "<script>window.__NEXT_DATA__ = " + safeJsonStringify(_regenPayload) + _lGlobals + "</script>";
825
- // Reconstruct ISR HTML preserving the document shell from the
826
- // cached entry (head, fonts, assets, custom _document markup).
827
- var _cachedStr = cached.value.value.html;
828
- var _btag = '<div id="__next">';
829
- var _bstart = _cachedStr.indexOf(_btag);
830
- var _bodyStart = _bstart >= 0 ? _bstart + _btag.length : -1;
831
- // Locate __NEXT_DATA__ script to split body from suffix
832
- var _ndMarker = '<script>window.__NEXT_DATA__';
833
- var _ndStart = _cachedStr.indexOf(_ndMarker);
834
- var _freshHtml;
835
- if (_bodyStart >= 0 && _ndStart >= 0) {
836
- // Region between body start and __NEXT_DATA__ contains:
837
- // BODY_HTML + </div> + optional gap (custom _document content)
838
- var _region = _cachedStr.slice(_bodyStart, _ndStart);
839
- var _lastClose = _region.lastIndexOf('</div>');
840
- var _gap = _lastClose >= 0 ? _region.slice(_lastClose + 6) : '';
841
- // Tail: everything after the old __NEXT_DATA__ </script>
842
- var _ndEnd = _cachedStr.indexOf('</script>', _ndStart) + 9;
843
- var _tail = _cachedStr.slice(_ndEnd);
844
- _freshHtml = _cachedStr.slice(0, _bodyStart) + _freshBody + '</div>' + _gap + _freshNDS + _tail;
845
- } else {
846
- _freshHtml = '<!DOCTYPE html>\\n<html>\\n<head>\\n</head>\\n<body>\\n <div id="__next">' + _freshBody + '</div>\\n ' + _freshNDS + '\\n</body>\\n</html>';
847
- }
848
- await isrSet(cacheKey, { kind: "PAGES", html: _freshHtml, pageData: _fp, headers: undefined, status: undefined }, freshResult.revalidate);
849
- }
792
+ return _runWithUnifiedCtx(revalCtx, async () => {
793
+ ensureFetchPatch();
794
+ var freshResult = await pageModule.getStaticProps({
795
+ params: params,
796
+ locale: locale,
797
+ locales: i18nConfig ? i18nConfig.locales : undefined,
798
+ defaultLocale: currentDefaultLocale,
799
+ });
800
+ if (freshResult && freshResult.props && typeof freshResult.revalidate === "number" && freshResult.revalidate > 0) {
801
+ var _fp = freshResult.props;
802
+ if (typeof setSSRContext === "function") {
803
+ setSSRContext({
804
+ pathname: patternToNextFormat(route.pattern),
805
+ query: { ...params, ...parseQuery(routeUrl) },
806
+ asPath: routeUrl,
807
+ locale: locale,
808
+ locales: i18nConfig ? i18nConfig.locales : undefined,
809
+ defaultLocale: currentDefaultLocale,
810
+ domainLocales: domainLocales,
811
+ });
812
+ }
813
+ if (i18nConfig) {
814
+ setI18nContext({
815
+ locale: locale,
816
+ locales: i18nConfig.locales,
817
+ defaultLocale: currentDefaultLocale,
818
+ domainLocales: domainLocales,
819
+ hostname: new URL(request.url).hostname,
820
+ });
821
+ }
822
+ // Re-render the page with fresh props inside fresh render sub-scopes
823
+ // so head/cache state cannot leak across passes.
824
+ var _el = AppComponent
825
+ ? React.createElement(AppComponent, { Component: PageComponent, pageProps: _fp })
826
+ : React.createElement(PageComponent, _fp);
827
+ _el = wrapWithRouterContext(_el);
828
+ var _freshBody = await renderIsrPassToStringAsync(_el);
829
+ // Rebuild __NEXT_DATA__ with fresh props
830
+ var _regenPayload = {
831
+ props: { pageProps: _fp }, page: patternToNextFormat(route.pattern),
832
+ query: params, buildId: buildId, isFallback: false,
833
+ };
834
+ if (i18nConfig) {
835
+ _regenPayload.locale = locale;
836
+ _regenPayload.locales = i18nConfig.locales;
837
+ _regenPayload.defaultLocale = currentDefaultLocale;
838
+ _regenPayload.domainLocales = domainLocales;
839
+ }
840
+ var _lGlobals = i18nConfig
841
+ ? ";window.__VINEXT_LOCALE__=" + safeJsonStringify(locale) +
842
+ ";window.__VINEXT_LOCALES__=" + safeJsonStringify(i18nConfig.locales) +
843
+ ";window.__VINEXT_DEFAULT_LOCALE__=" + safeJsonStringify(currentDefaultLocale)
844
+ : "";
845
+ var _freshNDS = "<script>window.__NEXT_DATA__ = " + safeJsonStringify(_regenPayload) + _lGlobals + "<\/script>";
846
+ // Reconstruct ISR HTML preserving the document shell from the
847
+ // cached entry (head, fonts, assets, custom _document markup).
848
+ var _cachedStr = cached.value.value.html;
849
+ var _btag = '<div id="__next">';
850
+ var _bstart = _cachedStr.indexOf(_btag);
851
+ var _bodyStart = _bstart >= 0 ? _bstart + _btag.length : -1;
852
+ // Locate __NEXT_DATA__ script to split body from suffix
853
+ var _ndMarker = '<script>window.__NEXT_DATA__';
854
+ var _ndStart = _cachedStr.indexOf(_ndMarker);
855
+ var _freshHtml;
856
+ if (_bodyStart >= 0 && _ndStart >= 0) {
857
+ // Region between body start and __NEXT_DATA__ contains:
858
+ // BODY_HTML + </div> + optional gap (custom _document content)
859
+ var _region = _cachedStr.slice(_bodyStart, _ndStart);
860
+ var _lastClose = _region.lastIndexOf('</div>');
861
+ var _gap = _lastClose >= 0 ? _region.slice(_lastClose + 6) : '';
862
+ // Tail: everything after the old __NEXT_DATA__ <\/script>
863
+ var _ndEnd = _cachedStr.indexOf('<\/script>', _ndStart) + 9;
864
+ var _tail = _cachedStr.slice(_ndEnd);
865
+ _freshHtml = _cachedStr.slice(0, _bodyStart) + _freshBody + '</div>' + _gap + _freshNDS + _tail;
866
+ } else {
867
+ _freshHtml = '<!DOCTYPE html>\\n<html>\\n<head>\\n</head>\\n<body>\\n <div id="__next">' + _freshBody + '</div>\\n ' + _freshNDS + '\\n</body>\\n</html>';
868
+ }
869
+ await isrSet(cacheKey, { kind: "PAGES", html: _freshHtml, pageData: _fp, headers: undefined, status: undefined }, freshResult.revalidate);
870
+ }
871
+ });
850
872
  });
851
873
  var _staleHeaders = {
852
874
  "Content-Type": "text/html", "X-Vinext-Cache": "STALE",
@@ -860,7 +882,7 @@ async function _renderPage(request, url, manifest) {
860
882
  params,
861
883
  locale: locale,
862
884
  locales: i18nConfig ? i18nConfig.locales : undefined,
863
- defaultLocale: i18nConfig ? i18nConfig.defaultLocale : undefined,
885
+ defaultLocale: currentDefaultLocale,
864
886
  };
865
887
  const result = await pageModule.getStaticProps(ctx);
866
888
  if (result && result.props) pageProps = result.props;
@@ -913,14 +935,15 @@ async function _renderPage(request, url, manifest) {
913
935
  if (i18nConfig) {
914
936
  nextDataPayload.locale = locale;
915
937
  nextDataPayload.locales = i18nConfig.locales;
916
- nextDataPayload.defaultLocale = i18nConfig.defaultLocale;
938
+ nextDataPayload.defaultLocale = currentDefaultLocale;
939
+ nextDataPayload.domainLocales = domainLocales;
917
940
  }
918
941
  const localeGlobals = i18nConfig
919
942
  ? ";window.__VINEXT_LOCALE__=" + safeJsonStringify(locale) +
920
943
  ";window.__VINEXT_LOCALES__=" + safeJsonStringify(i18nConfig.locales) +
921
- ";window.__VINEXT_DEFAULT_LOCALE__=" + safeJsonStringify(i18nConfig.defaultLocale)
944
+ ";window.__VINEXT_DEFAULT_LOCALE__=" + safeJsonStringify(currentDefaultLocale)
922
945
  : "";
923
- const nextDataScript = "<script>window.__NEXT_DATA__ = " + safeJsonStringify(nextDataPayload) + localeGlobals + "</script>";
946
+ const nextDataScript = "<script>window.__NEXT_DATA__ = " + safeJsonStringify(nextDataPayload) + localeGlobals + "<\/script>";
924
947
 
925
948
  // Build the document shell with a placeholder for the streamed body
926
949
  var BODY_MARKER = "<!--VINEXT_STREAM_BODY-->";
@@ -981,7 +1004,7 @@ async function _renderPage(request, url, manifest) {
981
1004
  isrElement = React.createElement(PageComponent, pageProps);
982
1005
  }
983
1006
  isrElement = wrapWithRouterContext(isrElement);
984
- var isrHtml = await renderToStringAsync(isrElement);
1007
+ var isrHtml = await renderIsrPassToStringAsync(isrElement);
985
1008
  var fullHtml = shellPrefix + isrHtml + shellSuffix;
986
1009
  var isrPathname = url.split("?")[0];
987
1010
  var _cacheKey = isrCacheKey("pages", isrPathname);
@@ -1015,20 +1038,16 @@ async function _renderPage(request, url, manifest) {
1015
1038
  responseHeaders.set("Link", _fontLinkHeader);
1016
1039
  }
1017
1040
  return new Response(compositeStream, { status: finalStatus, headers: responseHeaders });
1018
- } catch (e) {
1041
+ } catch (e) {
1019
1042
  console.error("[vinext] SSR error:", e);
1020
1043
  _reportRequestError(
1021
1044
  e instanceof Error ? e : new Error(String(e)),
1022
1045
  { path: url, method: request.method, headers: Object.fromEntries(request.headers.entries()) },
1023
1046
  { routerKind: "Pages Router", routePath: route.pattern, routeType: "render" },
1024
- );
1047
+ ).catch(() => { /* ignore reporting errors */ });
1025
1048
  return new Response("Internal Server Error", { status: 500 });
1026
- }
1027
- }) // end runWithFetchCache
1028
- ) // end runWithPrivateCache
1029
- ) // end _runWithCacheState
1030
- ) // end runWithHeadState
1031
- ); // end runWithRouterState
1049
+ }
1050
+ });
1032
1051
  }
1033
1052
 
1034
1053
  export async function handleApiRoute(request, url) {
@@ -1108,4 +1127,7 @@ export async function handleApiRoute(request, url) {
1108
1127
  ${middlewareExportCode}
1109
1128
  `;
1110
1129
  }
1130
+ //#endregion
1131
+ export { generateServerEntry };
1132
+
1111
1133
  //# sourceMappingURL=pages-server-entry.js.map