vinext 0.0.30 → 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 (435) 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 -571
  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 -380
  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 +442 -211
  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 +84 -113
  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 -3133
  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 +560 -670
  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 -14
  112. package/dist/server/dev-server.js +542 -869
  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 +181 -210
  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 +106 -128
  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 +270 -317
  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 +61 -61
  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 +273 -404
  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 +38 -30
  142. package/dist/server/pages-i18n.js +112 -139
  143. package/dist/server/pages-i18n.js.map +1 -1
  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 +20 -45
  162. package/dist/shims/cache-runtime.js +271 -422
  163. package/dist/shims/cache-runtime.js.map +1 -1
  164. package/dist/shims/cache.d.ts +130 -121
  165. package/dist/shims/cache.js +339 -427
  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 -164
  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 +16 -14
  191. package/dist/shims/fetch-cache.js +437 -645
  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 +8 -13
  208. package/dist/shims/head-state.js +25 -42
  209. package/dist/shims/head-state.js.map +1 -1
  210. package/dist/shims/head.d.ts +16 -20
  211. package/dist/shims/head.js +172 -250
  212. package/dist/shims/head.js.map +1 -1
  213. package/dist/shims/headers.d.ts +84 -78
  214. package/dist/shims/headers.js +447 -575
  215. package/dist/shims/headers.js.map +1 -1
  216. package/dist/shims/i18n-context.d.ts +16 -20
  217. package/dist/shims/i18n-context.js +35 -48
  218. package/dist/shims/i18n-context.js.map +1 -1
  219. package/dist/shims/i18n-state.d.ts +8 -14
  220. package/dist/shims/i18n-state.js +34 -42
  221. package/dist/shims/i18n-state.js.map +1 -1
  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 -46
  226. package/dist/shims/image.js +283 -308
  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 -37
  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 +255 -391
  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 -546
  258. package/dist/shims/metadata.js.map +1 -1
  259. package/dist/shims/navigation-state.d.ts +10 -18
  260. package/dist/shims/navigation-state.js +66 -74
  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 +505 -704
  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 -60
  272. package/dist/shims/request-context.js.map +1 -1
  273. package/dist/shims/request-state-types.d.ts +11 -11
  274. package/dist/shims/request-state-types.js +0 -1
  275. package/dist/shims/router-state.d.ts +13 -10
  276. package/dist/shims/router-state.js +34 -43
  277. package/dist/shims/router-state.js.map +1 -1
  278. package/dist/shims/router.d.ts +81 -85
  279. package/dist/shims/router.js +506 -628
  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 -164
  287. package/dist/shims/server.js +462 -478
  288. package/dist/shims/server.js.map +1 -1
  289. package/dist/shims/unified-request-context.d.ts +20 -20
  290. package/dist/shims/unified-request-context.js +81 -99
  291. package/dist/shims/unified-request-context.js.map +1 -1
  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 +17 -9
  305. package/dist/utils/domain-locale.js +36 -56
  306. package/dist/utils/domain-locale.js.map +1 -1
  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 +10 -9
  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/pages-i18n.d.ts.map +0 -1
  367. package/dist/server/prod-server.d.ts.map +0 -1
  368. package/dist/server/request-log.d.ts.map +0 -1
  369. package/dist/server/request-pipeline.d.ts.map +0 -1
  370. package/dist/server/worker-utils.d.ts.map +0 -1
  371. package/dist/shims/amp.d.ts.map +0 -1
  372. package/dist/shims/app.d.ts.map +0 -1
  373. package/dist/shims/app.js.map +0 -1
  374. package/dist/shims/cache-runtime.d.ts.map +0 -1
  375. package/dist/shims/cache.d.ts.map +0 -1
  376. package/dist/shims/client-only.d.ts.map +0 -1
  377. package/dist/shims/client-only.js.map +0 -1
  378. package/dist/shims/compat-router.d.ts.map +0 -1
  379. package/dist/shims/config.d.ts.map +0 -1
  380. package/dist/shims/constants.d.ts.map +0 -1
  381. package/dist/shims/document.d.ts.map +0 -1
  382. package/dist/shims/dynamic.d.ts.map +0 -1
  383. package/dist/shims/error-boundary.d.ts.map +0 -1
  384. package/dist/shims/error.d.ts.map +0 -1
  385. package/dist/shims/fetch-cache.d.ts.map +0 -1
  386. package/dist/shims/font-google-base.d.ts.map +0 -1
  387. package/dist/shims/font-google.d.ts.map +0 -1
  388. package/dist/shims/font-google.generated.d.ts.map +0 -1
  389. package/dist/shims/font-google.js.map +0 -1
  390. package/dist/shims/font-local.d.ts.map +0 -1
  391. package/dist/shims/form.d.ts.map +0 -1
  392. package/dist/shims/head-state.d.ts.map +0 -1
  393. package/dist/shims/head.d.ts.map +0 -1
  394. package/dist/shims/headers.d.ts.map +0 -1
  395. package/dist/shims/i18n-context.d.ts.map +0 -1
  396. package/dist/shims/i18n-state.d.ts.map +0 -1
  397. package/dist/shims/image-config.d.ts.map +0 -1
  398. package/dist/shims/image.d.ts.map +0 -1
  399. package/dist/shims/internal/api-utils.d.ts.map +0 -1
  400. package/dist/shims/internal/api-utils.js.map +0 -1
  401. package/dist/shims/internal/app-router-context.d.ts.map +0 -1
  402. package/dist/shims/internal/cookies.d.ts.map +0 -1
  403. package/dist/shims/internal/cookies.js.map +0 -1
  404. package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
  405. package/dist/shims/internal/router-context.d.ts.map +0 -1
  406. package/dist/shims/internal/utils.d.ts.map +0 -1
  407. package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
  408. package/dist/shims/layout-segment-context.d.ts.map +0 -1
  409. package/dist/shims/legacy-image.d.ts.map +0 -1
  410. package/dist/shims/link.d.ts.map +0 -1
  411. package/dist/shims/metadata.d.ts.map +0 -1
  412. package/dist/shims/navigation-state.d.ts.map +0 -1
  413. package/dist/shims/navigation.d.ts.map +0 -1
  414. package/dist/shims/og.d.ts.map +0 -1
  415. package/dist/shims/og.js.map +0 -1
  416. package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
  417. package/dist/shims/request-context.d.ts.map +0 -1
  418. package/dist/shims/request-state-types.d.ts.map +0 -1
  419. package/dist/shims/request-state-types.js.map +0 -1
  420. package/dist/shims/router-state.d.ts.map +0 -1
  421. package/dist/shims/router.d.ts.map +0 -1
  422. package/dist/shims/script.d.ts.map +0 -1
  423. package/dist/shims/server-only.d.ts.map +0 -1
  424. package/dist/shims/server-only.js.map +0 -1
  425. package/dist/shims/server.d.ts.map +0 -1
  426. package/dist/shims/unified-request-context.d.ts.map +0 -1
  427. package/dist/shims/url-safety.d.ts.map +0 -1
  428. package/dist/shims/url-utils.d.ts.map +0 -1
  429. package/dist/shims/web-vitals.d.ts.map +0 -1
  430. package/dist/utils/base-path.d.ts.map +0 -1
  431. package/dist/utils/domain-locale.d.ts.map +0 -1
  432. package/dist/utils/hash.d.ts.map +0 -1
  433. package/dist/utils/manifest-paths.d.ts.map +0 -1
  434. package/dist/utils/project.d.ts.map +0 -1
  435. package/dist/utils/query.d.ts.map +0 -1
@@ -1,8 +1,16 @@
1
+ //#region src/entries/app-ssr-entry.d.ts
1
2
  /**
2
3
  * Generate the virtual SSR entry module.
3
4
  *
4
5
  * This runs in the `ssr` Vite environment. It receives an RSC stream,
5
6
  * deserializes it to a React tree, and renders to HTML.
7
+ *
8
+ * When `hasPagesDir` is true (hybrid App + Pages Router project), the SSR
9
+ * entry also re-exports `pageRoutes` from `virtual:vinext-server-entry` so
10
+ * that the Cloudflare Workers RSC bundle can access Pages Router route
11
+ * metadata (including `getStaticPaths`) via `import("./ssr/index.js")`.
6
12
  */
7
- export declare function generateSsrEntry(): string;
13
+ declare function generateSsrEntry(hasPagesDir?: boolean): string;
14
+ //#endregion
15
+ export { generateSsrEntry };
8
16
  //# sourceMappingURL=app-ssr-entry.d.ts.map
@@ -1,17 +1,26 @@
1
+ //#region src/entries/app-ssr-entry.ts
1
2
  /**
2
- * Generate the virtual SSR entry module.
3
- *
4
- * This runs in the `ssr` Vite environment. It receives an RSC stream,
5
- * deserializes it to a React tree, and renders to HTML.
6
- */
7
- export function generateSsrEntry() {
8
- return `
3
+ * Generate the virtual SSR entry module.
4
+ *
5
+ * This runs in the `ssr` Vite environment. It receives an RSC stream,
6
+ * deserializes it to a React tree, and renders to HTML.
7
+ *
8
+ * When `hasPagesDir` is true (hybrid App + Pages Router project), the SSR
9
+ * entry also re-exports `pageRoutes` from `virtual:vinext-server-entry` so
10
+ * that the Cloudflare Workers RSC bundle can access Pages Router route
11
+ * metadata (including `getStaticPaths`) via `import("./ssr/index.js")`.
12
+ */
13
+ function generateSsrEntry(hasPagesDir = false) {
14
+ return `
9
15
  import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
10
16
  import { renderToReadableStream, renderToStaticMarkup } from "react-dom/server.edge";
11
17
  import { setNavigationContext, ServerInsertedHTMLContext } from "next/navigation";
12
18
  import { runWithNavigationContext as _runWithNavCtx } from "vinext/navigation-state";
13
19
  import { safeJsonStringify } from "vinext/html";
14
20
  import { createElement as _ssrCE } from "react";
21
+ import * as _clientRefs from "virtual:vite-rsc/client-references";
22
+
23
+ let _clientRefsPreloaded = false;
15
24
 
16
25
  /**
17
26
  * Collect all chunks from a ReadableStream into an array of text strings.
@@ -54,7 +63,7 @@ async function collectStreamChunks(stream) {
54
63
  * for the entire RSC payload before hydration can begin.
55
64
  *
56
65
  * Each chunk is written as:
57
- * <script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push("...")</script>
66
+ * <script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push("...")<\/script>
58
67
  *
59
68
  * Chunks are embedded as text strings (not byte arrays) since the RSC flight
60
69
  * protocol is text-based. The browser entry encodes them back to Uint8Array.
@@ -67,20 +76,13 @@ function createRscEmbedTransform(embedStream) {
67
76
  let pendingChunks = [];
68
77
  let reading = false;
69
78
 
70
- // Fix invalid preload "as" values in RSC Flight hint lines before
71
- // they reach the client. React Flight emits HL hints with
72
- // as="stylesheet" for CSS, but the HTML spec requires as="style"
73
- // for <link rel="preload">. The fixPreloadAs() below only fixes the
74
- // server-rendered HTML stream; this fixes the raw Flight data that
75
- // gets embedded as __VINEXT_RSC_CHUNKS__ and processed client-side.
76
- function fixFlightHints(text) {
77
- // Flight hint format: <id>:HL["url","stylesheet"] or with options
78
- return text.replace(/(\\d+:HL\\[.*?),"stylesheet"(\\]|,)/g, '$1,"style"$2');
79
- }
80
-
81
79
  // Start reading RSC chunks in the background, accumulating them as text strings.
82
80
  // The RSC flight protocol is text-based, so decoding to strings and embedding
83
81
  // as JSON strings is ~3x more compact than the byte-array format.
82
+ //
83
+ // Note: Flight HL hint "stylesheet" → "style" rewriting is handled upstream
84
+ // in the renderToReadableStream wrapper (app-rsc-entry.ts), so the stream
85
+ // arriving here is already clean.
84
86
  async function pumpReader() {
85
87
  if (reading) return;
86
88
  reading = true;
@@ -92,7 +94,7 @@ function createRscEmbedTransform(embedStream) {
92
94
  break;
93
95
  }
94
96
  const text = _decoder.decode(result.value, { stream: true });
95
- pendingChunks.push(fixFlightHints(text));
97
+ pendingChunks.push(text);
96
98
  }
97
99
  } catch (err) {
98
100
  if (process.env.NODE_ENV !== "production") {
@@ -117,7 +119,7 @@ function createRscEmbedTransform(embedStream) {
117
119
  pendingChunks = [];
118
120
  let scripts = "";
119
121
  for (const chunk of chunks) {
120
- scripts += "<script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push(" + safeJsonStringify(chunk) + ")</script>";
122
+ scripts += "<script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push(" + safeJsonStringify(chunk) + ")<\/script>";
121
123
  }
122
124
  return scripts;
123
125
  },
@@ -131,7 +133,7 @@ function createRscEmbedTransform(embedStream) {
131
133
  let scripts = this.flush();
132
134
  // Signal that all RSC chunks have been sent.
133
135
  // Params are already embedded in <head> — no need to include here.
134
- scripts += "<script>self.__VINEXT_RSC_DONE__=true</script>";
136
+ scripts += "<script>self.__VINEXT_RSC_DONE__=true<\/script>";
135
137
  return scripts;
136
138
  },
137
139
  };
@@ -150,6 +152,29 @@ function createRscEmbedTransform(embedStream) {
150
152
  * and the data needs to be passed to SSR since they're separate module instances.
151
153
  */
152
154
  export async function handleSsr(rscStream, navContext, fontData) {
155
+ // Eagerly preload all client reference modules before SSR rendering.
156
+ // On the first request after server start, client component modules are
157
+ // loaded lazily via async import(). Without this preload, React's
158
+ // renderToReadableStream rejects because the shell can't resolve client
159
+ // components synchronously (there is no Suspense boundary wrapping the
160
+ // root). The memoized require cache ensures this is only async on the
161
+ // very first call; subsequent requests resolve from cache immediately.
162
+ // See: https://github.com/cloudflare/vinext/issues/256
163
+ // _clientRefs.default is the default export from the virtual:vite-rsc/client-references
164
+ // namespace import — a map of client component IDs to their async import functions.
165
+ if (!_clientRefsPreloaded && _clientRefs.default && globalThis.__vite_rsc_client_require__) {
166
+ await Promise.all(
167
+ Object.keys(_clientRefs.default).map((id) =>
168
+ globalThis.__vite_rsc_client_require__(id).catch((err) => {
169
+ if (process.env.NODE_ENV !== "production") {
170
+ console.warn("[vinext] failed to preload client ref:", id, err);
171
+ }
172
+ })
173
+ )
174
+ );
175
+ _clientRefsPreloaded = true;
176
+ }
177
+
153
178
  // Wrap in a navigation ALS scope for per-request isolation in the SSR
154
179
  // environment. The SSR environment has separate module instances from RSC,
155
180
  // so it needs its own ALS scope.
@@ -297,7 +322,7 @@ export async function handleSsr(rscStream, navContext, fontData) {
297
322
  // RSC payload is now embedded progressively via script tags in the body stream.
298
323
  // Params are embedded eagerly in <head> so they're available before client
299
324
  // hydration starts, avoiding the need for polling on the client.
300
- const paramsScript = '<script>self.__VINEXT_RSC_PARAMS__=' + safeJsonStringify(navContext?.params || {}) + '</script>';
325
+ const paramsScript = '<script>self.__VINEXT_RSC_PARAMS__=' + safeJsonStringify(navContext?.params || {}) + '<\/script>';
301
326
  // Embed the initial navigation context (pathname + searchParams) so the
302
327
  // browser useSyncExternalStore getServerSnapshot can return the correct
303
328
  // value during hydration. Without this, getServerSnapshot returns "/" and
@@ -306,7 +331,7 @@ export async function handleSsr(rscStream, navContext, fontData) {
306
331
  // duplicate keys (e.g. ?tag=a&tag=b). Object.fromEntries() would keep
307
332
  // only the last value, causing a hydration mismatch for multi-value params.
308
333
  const __navPayload = { pathname: navContext?.pathname ?? '/', searchParams: navContext?.searchParams ? [...navContext.searchParams.entries()] : [] };
309
- const navScript = '<script>self.__VINEXT_RSC_NAV__=' + safeJsonStringify(__navPayload) + '</script>';
334
+ const navScript = '<script>self.__VINEXT_RSC_NAV__=' + safeJsonStringify(__navPayload) + '<\/script>';
310
335
  const injectHTML = paramsScript + navScript + modulePreloadHTML + insertedHTML + fontHTML;
311
336
 
312
337
  // Inject the collected HTML before </head> and progressively embed RSC
@@ -318,9 +343,8 @@ export async function handleSsr(rscStream, navContext, fontData) {
318
343
  // Fix invalid preload "as" values in server-rendered HTML.
319
344
  // React Fizz emits <link rel="preload" as="stylesheet"> for CSS,
320
345
  // but the HTML spec requires as="style" for <link rel="preload">.
321
- // Note: fixFlightHints() in createRscEmbedTransform handles the
322
- // complementary case fixing the raw Flight stream data before
323
- // it's embedded as __VINEXT_RSC_CHUNKS__ for client-side processing.
346
+ // Note: Flight HL hints are fixed upstream in the renderToReadableStream
347
+ // wrapper (app-rsc-entry.ts); this only handles the Fizz HTML stream.
324
348
  // See: https://html.spec.whatwg.org/multipage/links.html#link-type-preload
325
349
  function fixPreloadAs(html) {
326
350
  // Match <link ...rel="preload"... as="stylesheet"...> in any attribute order
@@ -444,6 +468,15 @@ export default {
444
468
  return new Response(String(result), { status: 200 });
445
469
  },
446
470
  };
447
- `;
471
+ ${hasPagesDir ? `
472
+ // Re-export pageRoutes and renderPage from the Pages Router server entry so
473
+ // that the Cloudflare Workers RSC bundle can access Pages Router route metadata
474
+ // (including getStaticPaths) via import("./ssr/index.js").pageRoutes, and can
475
+ // delegate unmatched App Router requests to renderPage for hybrid builds.
476
+ export { pageRoutes, renderPage } from "virtual:vinext-server-entry";
477
+ ` : ""}`;
448
478
  }
479
+ //#endregion
480
+ export { generateSsrEntry };
481
+
449
482
  //# sourceMappingURL=app-ssr-entry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-ssr-entry.js","sourceRoot":"","sources":["../../src/entries/app-ssr-entry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAubR,CAAC;AACF,CAAC","sourcesContent":["/**\n * Generate the virtual SSR entry module.\n *\n * This runs in the `ssr` Vite environment. It receives an RSC stream,\n * deserializes it to a React tree, and renders to HTML.\n */\nexport function generateSsrEntry(): string {\n return `\nimport { createFromReadableStream } from \"@vitejs/plugin-rsc/ssr\";\nimport { renderToReadableStream, renderToStaticMarkup } from \"react-dom/server.edge\";\nimport { setNavigationContext, ServerInsertedHTMLContext } from \"next/navigation\";\nimport { runWithNavigationContext as _runWithNavCtx } from \"vinext/navigation-state\";\nimport { safeJsonStringify } from \"vinext/html\";\nimport { createElement as _ssrCE } from \"react\";\n\n/**\n * Collect all chunks from a ReadableStream into an array of text strings.\n * Used to capture the RSC payload for embedding in HTML.\n * The RSC flight protocol is text-based (line-delimited key:value pairs),\n * so we decode to text strings instead of byte arrays — this is dramatically\n * more compact when JSON-serialized into inline <script> tags.\n */\nasync function collectStreamChunks(stream) {\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n const chunks = [];\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n // Decode Uint8Array to text string for compact JSON serialization\n chunks.push(decoder.decode(value, { stream: true }));\n }\n return chunks;\n}\n\n// React 19 dev-mode workaround (see VinextFlightRoot in handleSsr):\n//\n// In dev, Flight error decoding in react-server-dom-webpack/client.edge\n// can hit resolveErrorDev() which (via React's dev error stack capture)\n// expects a non-null hooks dispatcher.\n//\n// Vinext previously called createFromReadableStream() outside of any React render.\n// When an RSC stream contains an error, dev-mode decoding could crash with:\n// - \"Invalid hook call\"\n// - \"Cannot read properties of null (reading 'useContext')\"\n//\n// Fix: call createFromReadableStream() lazily inside a React component render.\n// This mirrors Next.js behavior and ensures the dispatcher is set.\n\n/**\n * Create a TransformStream that appends RSC chunks as inline <script> tags\n * to the HTML stream. This allows progressive hydration — the browser receives\n * RSC data incrementally as Suspense boundaries resolve, rather than waiting\n * for the entire RSC payload before hydration can begin.\n *\n * Each chunk is written as:\n * <script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push(\"...\")</script>\n *\n * Chunks are embedded as text strings (not byte arrays) since the RSC flight\n * protocol is text-based. The browser entry encodes them back to Uint8Array.\n * This is ~3x more compact than the previous byte-array format.\n */\nfunction createRscEmbedTransform(embedStream) {\n const reader = embedStream.getReader();\n const _decoder = new TextDecoder();\n let done = false;\n let pendingChunks = [];\n let reading = false;\n\n // Fix invalid preload \"as\" values in RSC Flight hint lines before\n // they reach the client. React Flight emits HL hints with\n // as=\"stylesheet\" for CSS, but the HTML spec requires as=\"style\"\n // for <link rel=\"preload\">. The fixPreloadAs() below only fixes the\n // server-rendered HTML stream; this fixes the raw Flight data that\n // gets embedded as __VINEXT_RSC_CHUNKS__ and processed client-side.\n function fixFlightHints(text) {\n // Flight hint format: <id>:HL[\"url\",\"stylesheet\"] or with options\n return text.replace(/(\\\\d+:HL\\\\[.*?),\"stylesheet\"(\\\\]|,)/g, '$1,\"style\"$2');\n }\n\n // Start reading RSC chunks in the background, accumulating them as text strings.\n // The RSC flight protocol is text-based, so decoding to strings and embedding\n // as JSON strings is ~3x more compact than the byte-array format.\n async function pumpReader() {\n if (reading) return;\n reading = true;\n try {\n while (true) {\n const result = await reader.read();\n if (result.done) {\n done = true;\n break;\n }\n const text = _decoder.decode(result.value, { stream: true });\n pendingChunks.push(fixFlightHints(text));\n }\n } catch (err) {\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(\"[vinext] RSC embed stream read error:\", err);\n }\n done = true;\n }\n reading = false;\n }\n\n // Fire off the background reader immediately\n const pumpPromise = pumpReader();\n\n return {\n /**\n * Flush any accumulated RSC chunks as <script> tags.\n * Called after each HTML chunk is enqueued.\n */\n flush() {\n if (pendingChunks.length === 0) return \"\";\n const chunks = pendingChunks;\n pendingChunks = [];\n let scripts = \"\";\n for (const chunk of chunks) {\n scripts += \"<script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push(\" + safeJsonStringify(chunk) + \")</script>\";\n }\n return scripts;\n },\n\n /**\n * Wait for the RSC stream to fully complete and return any final\n * script tags plus the closing signal.\n */\n async finalize() {\n await pumpPromise;\n let scripts = this.flush();\n // Signal that all RSC chunks have been sent.\n // Params are already embedded in <head> — no need to include here.\n scripts += \"<script>self.__VINEXT_RSC_DONE__=true</script>\";\n return scripts;\n },\n };\n}\n\n/**\n * Render the RSC stream to HTML.\n *\n * @param rscStream - The RSC payload stream from the RSC environment\n * @param navContext - Navigation context for client component SSR hooks.\n * \"use client\" components like those using usePathname() need the current\n * request URL during SSR, and they run in this SSR environment (separate\n * from the RSC environment where the context was originally set).\n * @param fontData - Font links and styles collected from the RSC environment.\n * Fonts are loaded during RSC rendering (when layout calls Geist() etc.),\n * and the data needs to be passed to SSR since they're separate module instances.\n */\nexport async function handleSsr(rscStream, navContext, fontData) {\n // Wrap in a navigation ALS scope for per-request isolation in the SSR\n // environment. The SSR environment has separate module instances from RSC,\n // so it needs its own ALS scope.\n return _runWithNavCtx(async () => {\n // Set navigation context so hooks like usePathname() work during SSR\n // of \"use client\" components\n if (navContext) {\n setNavigationContext(navContext);\n }\n\n // Clear any stale callbacks from previous requests\n const { clearServerInsertedHTML, flushServerInsertedHTML, useServerInsertedHTML: _addInsertedHTML } = await import(\"next/navigation\");\n clearServerInsertedHTML();\n\n try {\n // Tee the RSC stream - one for SSR rendering, one for embedding in HTML.\n // This ensures the browser uses the SAME RSC payload for hydration that\n // was used to generate the HTML, avoiding hydration mismatches (React #418).\n const [ssrStream, embedStream] = rscStream.tee();\n\n // Create the progressive RSC embed helper — it reads the embed stream\n // in the background and provides script tags to inject into the HTML stream.\n const rscEmbed = createRscEmbedTransform(embedStream);\n\n // Deserialize RSC stream back to React VDOM.\n // IMPORTANT: Do NOT await this — createFromReadableStream returns a thenable\n // that React's renderToReadableStream can consume progressively. By passing\n // the unresolved thenable, React will render Suspense fallbacks (loading.tsx)\n // immediately in the HTML shell, then stream in resolved content as RSC\n // chunks arrive. Awaiting here would block until all async server components\n // complete, collapsing the streaming behavior.\n // Lazily create the Flight root inside render so React's hook dispatcher is set\n // (avoids React 19 dev-mode resolveErrorDev() crash). VinextFlightRoot returns\n // a thenable (not a ReactNode), which React 19 consumes via its internal\n // thenable-as-child suspend/resume behavior. This matches Next.js's approach.\n let flightRoot;\n function VinextFlightRoot() {\n if (!flightRoot) {\n flightRoot = createFromReadableStream(ssrStream);\n }\n return flightRoot;\n }\n const root = _ssrCE(VinextFlightRoot);\n\n // Wrap with ServerInsertedHTMLContext.Provider so libraries that use\n // useContext(ServerInsertedHTMLContext) (Apollo Client, styled-components,\n // etc.) get a working callback registration function during SSR.\n // The provider value is useServerInsertedHTML — same function that direct\n // callers use — so both paths push to the same ALS-backed callback array.\n const ssrRoot = ServerInsertedHTMLContext\n ? _ssrCE(ServerInsertedHTMLContext.Provider, { value: _addInsertedHTML }, root)\n : root;\n\n // Get the bootstrap script content for the browser entry\n const bootstrapScriptContent =\n await import.meta.viteRsc.loadBootstrapScriptContent(\"index\");\n\n // djb2 hash for digest generation in the SSR environment.\n // Matches the RSC environment's __errorDigest function.\n function ssrErrorDigest(str) {\n let hash = 5381;\n for (let i = str.length - 1; i >= 0; i--) {\n hash = (hash * 33) ^ str.charCodeAt(i);\n }\n return (hash >>> 0).toString();\n }\n\n // Render HTML (streaming SSR)\n // useServerInsertedHTML callbacks are registered during this render.\n // The onError callback preserves the digest for Next.js navigation errors\n // (redirect, notFound, forbidden, unauthorized) thrown inside Suspense\n // boundaries during RSC streaming. Without this, React's default onError\n // returns undefined and the digest is lost in the $RX() call, preventing\n // client-side error boundaries from identifying the error type.\n // In production, non-navigation errors also get a digest hash so they\n // can be correlated with server logs without leaking details to clients.\n const htmlStream = await renderToReadableStream(ssrRoot, {\n bootstrapScriptContent,\n onError(error) {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n return String(error.digest);\n }\n // In production, generate a digest hash for non-navigation errors\n if (process.env.NODE_ENV === \"production\" && error) {\n const msg = error instanceof Error ? error.message : String(error);\n const stack = error instanceof Error ? (error.stack || \"\") : \"\";\n return ssrErrorDigest(msg + stack);\n }\n return undefined;\n },\n });\n\n // Flush useServerInsertedHTML callbacks (CSS-in-JS style injection)\n const insertedElements = flushServerInsertedHTML();\n\n // Render the inserted elements to HTML strings\n const { Fragment } = await import(\"react\");\n let insertedHTML = \"\";\n for (const el of insertedElements) {\n try {\n insertedHTML += renderToStaticMarkup(_ssrCE(Fragment, null, el));\n } catch {\n // Skip elements that can't be rendered\n }\n }\n\n // Escape HTML attribute values (defense-in-depth for font URLs/types).\n function _escAttr(s) { return s.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\"); }\n\n // Build font HTML from data passed from RSC environment\n // (Fonts are loaded during RSC rendering, and RSC/SSR are separate module instances)\n let fontHTML = \"\";\n if (fontData) {\n if (fontData.links && fontData.links.length > 0) {\n for (const url of fontData.links) {\n fontHTML += '<link rel=\"stylesheet\" href=\"' + _escAttr(url) + '\" />\\\\n';\n }\n }\n // Emit <link rel=\"preload\"> for local font files\n if (fontData.preloads && fontData.preloads.length > 0) {\n for (const preload of fontData.preloads) {\n fontHTML += '<link rel=\"preload\" href=\"' + _escAttr(preload.href) + '\" as=\"font\" type=\"' + _escAttr(preload.type) + '\" crossorigin />\\\\n';\n }\n }\n if (fontData.styles && fontData.styles.length > 0) {\n fontHTML += '<style data-vinext-fonts>' + fontData.styles.join(\"\\\\n\") + '</style>\\\\n';\n }\n }\n\n // Extract client entry module URL from bootstrapScriptContent to emit\n // a <link rel=\"modulepreload\"> hint. The RSC plugin formats bootstrap\n // content as: import(\"URL\") — we extract the URL so the browser can\n // speculatively fetch and parse the JS module while still processing\n // the HTML body, instead of waiting until it reaches the inline script.\n let modulePreloadHTML = \"\";\n if (bootstrapScriptContent) {\n const m = bootstrapScriptContent.match(/import\\\\(\"([^\"]+)\"\\\\)/);\n if (m && m[1]) {\n modulePreloadHTML = '<link rel=\"modulepreload\" href=\"' + _escAttr(m[1]) + '\" />\\\\n';\n }\n }\n\n // Head-injected HTML: server-inserted HTML, font HTML, route params,\n // and modulepreload hints.\n // RSC payload is now embedded progressively via script tags in the body stream.\n // Params are embedded eagerly in <head> so they're available before client\n // hydration starts, avoiding the need for polling on the client.\n const paramsScript = '<script>self.__VINEXT_RSC_PARAMS__=' + safeJsonStringify(navContext?.params || {}) + '</script>';\n // Embed the initial navigation context (pathname + searchParams) so the\n // browser useSyncExternalStore getServerSnapshot can return the correct\n // value during hydration. Without this, getServerSnapshot returns \"/\" and\n // React detects a mismatch against the SSR-rendered HTML.\n // Serialise searchParams as an array of [key, value] pairs to preserve\n // duplicate keys (e.g. ?tag=a&tag=b). Object.fromEntries() would keep\n // only the last value, causing a hydration mismatch for multi-value params.\n const __navPayload = { pathname: navContext?.pathname ?? '/', searchParams: navContext?.searchParams ? [...navContext.searchParams.entries()] : [] };\n const navScript = '<script>self.__VINEXT_RSC_NAV__=' + safeJsonStringify(__navPayload) + '</script>';\n const injectHTML = paramsScript + navScript + modulePreloadHTML + insertedHTML + fontHTML;\n\n // Inject the collected HTML before </head> and progressively embed RSC\n // chunks as script tags throughout the HTML body stream.\n const decoder = new TextDecoder();\n const encoder = new TextEncoder();\n let injected = false;\n\n // Fix invalid preload \"as\" values in server-rendered HTML.\n // React Fizz emits <link rel=\"preload\" as=\"stylesheet\"> for CSS,\n // but the HTML spec requires as=\"style\" for <link rel=\"preload\">.\n // Note: fixFlightHints() in createRscEmbedTransform handles the\n // complementary case — fixing the raw Flight stream data before\n // it's embedded as __VINEXT_RSC_CHUNKS__ for client-side processing.\n // See: https://html.spec.whatwg.org/multipage/links.html#link-type-preload\n function fixPreloadAs(html) {\n // Match <link ...rel=\"preload\"... as=\"stylesheet\"...> in any attribute order\n return html.replace(/<link(?=[^>]*\\\\srel=\"preload\")[^>]*>/g, function(tag) {\n return tag.replace(' as=\"stylesheet\"', ' as=\"style\"');\n });\n }\n\n // Tick-buffered RSC script injection.\n //\n // React's renderToReadableStream (Fizz) flushes chunks synchronously\n // within one microtask — all chunks from a single flushCompletedQueues\n // call arrive in the same macrotask. We buffer HTML chunks as they\n // arrive, then use setTimeout(0) to defer emitting them plus any\n // accumulated RSC scripts to the next macrotask. This guarantees we\n // never inject <script> tags between partial HTML chunks (which would\n // corrupt split elements like \"<linearGradi\" + \"ent>\"), while still\n // delivering RSC data progressively as Suspense boundaries resolve.\n //\n // Reference: rsc-html-stream by Devon Govett (credited by Next.js)\n // https://github.com/devongovett/rsc-html-stream\n let buffered = [];\n let timeoutId = null;\n\n const transform = new TransformStream({\n transform(chunk, controller) {\n const text = decoder.decode(chunk, { stream: true });\n const fixed = fixPreloadAs(text);\n buffered.push(fixed);\n\n if (timeoutId !== null) return;\n\n timeoutId = setTimeout(() => {\n // Flush all buffered HTML chunks from this React flush cycle\n for (const buf of buffered) {\n if (!injected) {\n const headEnd = buf.indexOf(\"</head>\");\n if (headEnd !== -1) {\n const before = buf.slice(0, headEnd);\n const after = buf.slice(headEnd);\n controller.enqueue(encoder.encode(before + injectHTML + after));\n injected = true;\n continue;\n }\n }\n controller.enqueue(encoder.encode(buf));\n }\n buffered = [];\n\n // Now safe to inject any accumulated RSC scripts — we're between\n // React flush cycles, so no partial HTML chunks can follow until\n // the next macrotask.\n const rscScripts = rscEmbed.flush();\n if (rscScripts) {\n controller.enqueue(encoder.encode(rscScripts));\n }\n\n timeoutId = null;\n }, 0);\n },\n async flush(controller) {\n // Cancel any pending setTimeout callback — flush() drains\n // everything itself, so the callback would be a no-op but\n // cancelling makes the code obviously correct.\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n // Flush any remaining buffered HTML chunks\n for (const buf of buffered) {\n if (!injected) {\n const headEnd = buf.indexOf(\"</head>\");\n if (headEnd !== -1) {\n const before = buf.slice(0, headEnd);\n const after = buf.slice(headEnd);\n controller.enqueue(encoder.encode(before + injectHTML + after));\n injected = true;\n continue;\n }\n }\n controller.enqueue(encoder.encode(buf));\n }\n buffered = [];\n\n if (!injected && injectHTML) {\n controller.enqueue(encoder.encode(injectHTML));\n }\n // Finalize: wait for the RSC stream to complete and emit remaining\n // chunks plus the __VINEXT_RSC_DONE__ signal.\n const finalScripts = await rscEmbed.finalize();\n if (finalScripts) {\n controller.enqueue(encoder.encode(finalScripts));\n }\n },\n });\n\n return htmlStream.pipeThrough(transform);\n } finally {\n // Clean up so we don't leak context between requests\n setNavigationContext(null);\n clearServerInsertedHTML();\n }\n }); // end _runWithNavCtx\n}\n\nexport default {\n async fetch(request) {\n const url = new URL(request.url);\n if (url.pathname.startsWith(\"//\")) {\n return new Response(\"404 Not Found\", { status: 404 });\n }\n const rscModule = await import.meta.viteRsc.loadModule(\"rsc\", \"index\");\n const result = await rscModule.default(request);\n if (result instanceof Response) {\n return result;\n }\n if (result === null || result === undefined) {\n return new Response(\"Not Found\", { status: 404 });\n }\n return new Response(String(result), { status: 200 });\n },\n};\n`;\n}\n"]}
1
+ {"version":3,"file":"app-ssr-entry.js","names":[],"sources":["../../src/entries/app-ssr-entry.ts"],"sourcesContent":["/**\n * Generate the virtual SSR entry module.\n *\n * This runs in the `ssr` Vite environment. It receives an RSC stream,\n * deserializes it to a React tree, and renders to HTML.\n *\n * When `hasPagesDir` is true (hybrid App + Pages Router project), the SSR\n * entry also re-exports `pageRoutes` from `virtual:vinext-server-entry` so\n * that the Cloudflare Workers RSC bundle can access Pages Router route\n * metadata (including `getStaticPaths`) via `import(\"./ssr/index.js\")`.\n */\nexport function generateSsrEntry(hasPagesDir = false): string {\n return `\nimport { createFromReadableStream } from \"@vitejs/plugin-rsc/ssr\";\nimport { renderToReadableStream, renderToStaticMarkup } from \"react-dom/server.edge\";\nimport { setNavigationContext, ServerInsertedHTMLContext } from \"next/navigation\";\nimport { runWithNavigationContext as _runWithNavCtx } from \"vinext/navigation-state\";\nimport { safeJsonStringify } from \"vinext/html\";\nimport { createElement as _ssrCE } from \"react\";\nimport * as _clientRefs from \"virtual:vite-rsc/client-references\";\n\nlet _clientRefsPreloaded = false;\n\n/**\n * Collect all chunks from a ReadableStream into an array of text strings.\n * Used to capture the RSC payload for embedding in HTML.\n * The RSC flight protocol is text-based (line-delimited key:value pairs),\n * so we decode to text strings instead of byte arrays — this is dramatically\n * more compact when JSON-serialized into inline <script> tags.\n */\nasync function collectStreamChunks(stream) {\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n const chunks = [];\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n // Decode Uint8Array to text string for compact JSON serialization\n chunks.push(decoder.decode(value, { stream: true }));\n }\n return chunks;\n}\n\n// React 19 dev-mode workaround (see VinextFlightRoot in handleSsr):\n//\n// In dev, Flight error decoding in react-server-dom-webpack/client.edge\n// can hit resolveErrorDev() which (via React's dev error stack capture)\n// expects a non-null hooks dispatcher.\n//\n// Vinext previously called createFromReadableStream() outside of any React render.\n// When an RSC stream contains an error, dev-mode decoding could crash with:\n// - \"Invalid hook call\"\n// - \"Cannot read properties of null (reading 'useContext')\"\n//\n// Fix: call createFromReadableStream() lazily inside a React component render.\n// This mirrors Next.js behavior and ensures the dispatcher is set.\n\n/**\n * Create a TransformStream that appends RSC chunks as inline <script> tags\n * to the HTML stream. This allows progressive hydration — the browser receives\n * RSC data incrementally as Suspense boundaries resolve, rather than waiting\n * for the entire RSC payload before hydration can begin.\n *\n * Each chunk is written as:\n * <script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push(\"...\")</script>\n *\n * Chunks are embedded as text strings (not byte arrays) since the RSC flight\n * protocol is text-based. The browser entry encodes them back to Uint8Array.\n * This is ~3x more compact than the previous byte-array format.\n */\nfunction createRscEmbedTransform(embedStream) {\n const reader = embedStream.getReader();\n const _decoder = new TextDecoder();\n let done = false;\n let pendingChunks = [];\n let reading = false;\n\n // Start reading RSC chunks in the background, accumulating them as text strings.\n // The RSC flight protocol is text-based, so decoding to strings and embedding\n // as JSON strings is ~3x more compact than the byte-array format.\n //\n // Note: Flight HL hint \"stylesheet\" → \"style\" rewriting is handled upstream\n // in the renderToReadableStream wrapper (app-rsc-entry.ts), so the stream\n // arriving here is already clean.\n async function pumpReader() {\n if (reading) return;\n reading = true;\n try {\n while (true) {\n const result = await reader.read();\n if (result.done) {\n done = true;\n break;\n }\n const text = _decoder.decode(result.value, { stream: true });\n pendingChunks.push(text);\n }\n } catch (err) {\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(\"[vinext] RSC embed stream read error:\", err);\n }\n done = true;\n }\n reading = false;\n }\n\n // Fire off the background reader immediately\n const pumpPromise = pumpReader();\n\n return {\n /**\n * Flush any accumulated RSC chunks as <script> tags.\n * Called after each HTML chunk is enqueued.\n */\n flush() {\n if (pendingChunks.length === 0) return \"\";\n const chunks = pendingChunks;\n pendingChunks = [];\n let scripts = \"\";\n for (const chunk of chunks) {\n scripts += \"<script>self.__VINEXT_RSC_CHUNKS__=self.__VINEXT_RSC_CHUNKS__||[];self.__VINEXT_RSC_CHUNKS__.push(\" + safeJsonStringify(chunk) + \")</script>\";\n }\n return scripts;\n },\n\n /**\n * Wait for the RSC stream to fully complete and return any final\n * script tags plus the closing signal.\n */\n async finalize() {\n await pumpPromise;\n let scripts = this.flush();\n // Signal that all RSC chunks have been sent.\n // Params are already embedded in <head> — no need to include here.\n scripts += \"<script>self.__VINEXT_RSC_DONE__=true</script>\";\n return scripts;\n },\n };\n}\n\n/**\n * Render the RSC stream to HTML.\n *\n * @param rscStream - The RSC payload stream from the RSC environment\n * @param navContext - Navigation context for client component SSR hooks.\n * \"use client\" components like those using usePathname() need the current\n * request URL during SSR, and they run in this SSR environment (separate\n * from the RSC environment where the context was originally set).\n * @param fontData - Font links and styles collected from the RSC environment.\n * Fonts are loaded during RSC rendering (when layout calls Geist() etc.),\n * and the data needs to be passed to SSR since they're separate module instances.\n */\nexport async function handleSsr(rscStream, navContext, fontData) {\n // Eagerly preload all client reference modules before SSR rendering.\n // On the first request after server start, client component modules are\n // loaded lazily via async import(). Without this preload, React's\n // renderToReadableStream rejects because the shell can't resolve client\n // components synchronously (there is no Suspense boundary wrapping the\n // root). The memoized require cache ensures this is only async on the\n // very first call; subsequent requests resolve from cache immediately.\n // See: https://github.com/cloudflare/vinext/issues/256\n // _clientRefs.default is the default export from the virtual:vite-rsc/client-references\n // namespace import — a map of client component IDs to their async import functions.\n if (!_clientRefsPreloaded && _clientRefs.default && globalThis.__vite_rsc_client_require__) {\n await Promise.all(\n Object.keys(_clientRefs.default).map((id) =>\n globalThis.__vite_rsc_client_require__(id).catch((err) => {\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(\"[vinext] failed to preload client ref:\", id, err);\n }\n })\n )\n );\n _clientRefsPreloaded = true;\n }\n\n // Wrap in a navigation ALS scope for per-request isolation in the SSR\n // environment. The SSR environment has separate module instances from RSC,\n // so it needs its own ALS scope.\n return _runWithNavCtx(async () => {\n // Set navigation context so hooks like usePathname() work during SSR\n // of \"use client\" components\n if (navContext) {\n setNavigationContext(navContext);\n }\n\n // Clear any stale callbacks from previous requests\n const { clearServerInsertedHTML, flushServerInsertedHTML, useServerInsertedHTML: _addInsertedHTML } = await import(\"next/navigation\");\n clearServerInsertedHTML();\n\n try {\n // Tee the RSC stream - one for SSR rendering, one for embedding in HTML.\n // This ensures the browser uses the SAME RSC payload for hydration that\n // was used to generate the HTML, avoiding hydration mismatches (React #418).\n const [ssrStream, embedStream] = rscStream.tee();\n\n // Create the progressive RSC embed helper — it reads the embed stream\n // in the background and provides script tags to inject into the HTML stream.\n const rscEmbed = createRscEmbedTransform(embedStream);\n\n // Deserialize RSC stream back to React VDOM.\n // IMPORTANT: Do NOT await this — createFromReadableStream returns a thenable\n // that React's renderToReadableStream can consume progressively. By passing\n // the unresolved thenable, React will render Suspense fallbacks (loading.tsx)\n // immediately in the HTML shell, then stream in resolved content as RSC\n // chunks arrive. Awaiting here would block until all async server components\n // complete, collapsing the streaming behavior.\n // Lazily create the Flight root inside render so React's hook dispatcher is set\n // (avoids React 19 dev-mode resolveErrorDev() crash). VinextFlightRoot returns\n // a thenable (not a ReactNode), which React 19 consumes via its internal\n // thenable-as-child suspend/resume behavior. This matches Next.js's approach.\n let flightRoot;\n function VinextFlightRoot() {\n if (!flightRoot) {\n flightRoot = createFromReadableStream(ssrStream);\n }\n return flightRoot;\n }\n const root = _ssrCE(VinextFlightRoot);\n\n // Wrap with ServerInsertedHTMLContext.Provider so libraries that use\n // useContext(ServerInsertedHTMLContext) (Apollo Client, styled-components,\n // etc.) get a working callback registration function during SSR.\n // The provider value is useServerInsertedHTML — same function that direct\n // callers use — so both paths push to the same ALS-backed callback array.\n const ssrRoot = ServerInsertedHTMLContext\n ? _ssrCE(ServerInsertedHTMLContext.Provider, { value: _addInsertedHTML }, root)\n : root;\n\n // Get the bootstrap script content for the browser entry\n const bootstrapScriptContent =\n await import.meta.viteRsc.loadBootstrapScriptContent(\"index\");\n\n // djb2 hash for digest generation in the SSR environment.\n // Matches the RSC environment's __errorDigest function.\n function ssrErrorDigest(str) {\n let hash = 5381;\n for (let i = str.length - 1; i >= 0; i--) {\n hash = (hash * 33) ^ str.charCodeAt(i);\n }\n return (hash >>> 0).toString();\n }\n\n // Render HTML (streaming SSR)\n // useServerInsertedHTML callbacks are registered during this render.\n // The onError callback preserves the digest for Next.js navigation errors\n // (redirect, notFound, forbidden, unauthorized) thrown inside Suspense\n // boundaries during RSC streaming. Without this, React's default onError\n // returns undefined and the digest is lost in the $RX() call, preventing\n // client-side error boundaries from identifying the error type.\n // In production, non-navigation errors also get a digest hash so they\n // can be correlated with server logs without leaking details to clients.\n const htmlStream = await renderToReadableStream(ssrRoot, {\n bootstrapScriptContent,\n onError(error) {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n return String(error.digest);\n }\n // In production, generate a digest hash for non-navigation errors\n if (process.env.NODE_ENV === \"production\" && error) {\n const msg = error instanceof Error ? error.message : String(error);\n const stack = error instanceof Error ? (error.stack || \"\") : \"\";\n return ssrErrorDigest(msg + stack);\n }\n return undefined;\n },\n });\n\n // Flush useServerInsertedHTML callbacks (CSS-in-JS style injection)\n const insertedElements = flushServerInsertedHTML();\n\n // Render the inserted elements to HTML strings\n const { Fragment } = await import(\"react\");\n let insertedHTML = \"\";\n for (const el of insertedElements) {\n try {\n insertedHTML += renderToStaticMarkup(_ssrCE(Fragment, null, el));\n } catch {\n // Skip elements that can't be rendered\n }\n }\n\n // Escape HTML attribute values (defense-in-depth for font URLs/types).\n function _escAttr(s) { return s.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\"); }\n\n // Build font HTML from data passed from RSC environment\n // (Fonts are loaded during RSC rendering, and RSC/SSR are separate module instances)\n let fontHTML = \"\";\n if (fontData) {\n if (fontData.links && fontData.links.length > 0) {\n for (const url of fontData.links) {\n fontHTML += '<link rel=\"stylesheet\" href=\"' + _escAttr(url) + '\" />\\\\n';\n }\n }\n // Emit <link rel=\"preload\"> for local font files\n if (fontData.preloads && fontData.preloads.length > 0) {\n for (const preload of fontData.preloads) {\n fontHTML += '<link rel=\"preload\" href=\"' + _escAttr(preload.href) + '\" as=\"font\" type=\"' + _escAttr(preload.type) + '\" crossorigin />\\\\n';\n }\n }\n if (fontData.styles && fontData.styles.length > 0) {\n fontHTML += '<style data-vinext-fonts>' + fontData.styles.join(\"\\\\n\") + '</style>\\\\n';\n }\n }\n\n // Extract client entry module URL from bootstrapScriptContent to emit\n // a <link rel=\"modulepreload\"> hint. The RSC plugin formats bootstrap\n // content as: import(\"URL\") — we extract the URL so the browser can\n // speculatively fetch and parse the JS module while still processing\n // the HTML body, instead of waiting until it reaches the inline script.\n let modulePreloadHTML = \"\";\n if (bootstrapScriptContent) {\n const m = bootstrapScriptContent.match(/import\\\\(\"([^\"]+)\"\\\\)/);\n if (m && m[1]) {\n modulePreloadHTML = '<link rel=\"modulepreload\" href=\"' + _escAttr(m[1]) + '\" />\\\\n';\n }\n }\n\n // Head-injected HTML: server-inserted HTML, font HTML, route params,\n // and modulepreload hints.\n // RSC payload is now embedded progressively via script tags in the body stream.\n // Params are embedded eagerly in <head> so they're available before client\n // hydration starts, avoiding the need for polling on the client.\n const paramsScript = '<script>self.__VINEXT_RSC_PARAMS__=' + safeJsonStringify(navContext?.params || {}) + '</script>';\n // Embed the initial navigation context (pathname + searchParams) so the\n // browser useSyncExternalStore getServerSnapshot can return the correct\n // value during hydration. Without this, getServerSnapshot returns \"/\" and\n // React detects a mismatch against the SSR-rendered HTML.\n // Serialise searchParams as an array of [key, value] pairs to preserve\n // duplicate keys (e.g. ?tag=a&tag=b). Object.fromEntries() would keep\n // only the last value, causing a hydration mismatch for multi-value params.\n const __navPayload = { pathname: navContext?.pathname ?? '/', searchParams: navContext?.searchParams ? [...navContext.searchParams.entries()] : [] };\n const navScript = '<script>self.__VINEXT_RSC_NAV__=' + safeJsonStringify(__navPayload) + '</script>';\n const injectHTML = paramsScript + navScript + modulePreloadHTML + insertedHTML + fontHTML;\n\n // Inject the collected HTML before </head> and progressively embed RSC\n // chunks as script tags throughout the HTML body stream.\n const decoder = new TextDecoder();\n const encoder = new TextEncoder();\n let injected = false;\n\n // Fix invalid preload \"as\" values in server-rendered HTML.\n // React Fizz emits <link rel=\"preload\" as=\"stylesheet\"> for CSS,\n // but the HTML spec requires as=\"style\" for <link rel=\"preload\">.\n // Note: Flight HL hints are fixed upstream in the renderToReadableStream\n // wrapper (app-rsc-entry.ts); this only handles the Fizz HTML stream.\n // See: https://html.spec.whatwg.org/multipage/links.html#link-type-preload\n function fixPreloadAs(html) {\n // Match <link ...rel=\"preload\"... as=\"stylesheet\"...> in any attribute order\n return html.replace(/<link(?=[^>]*\\\\srel=\"preload\")[^>]*>/g, function(tag) {\n return tag.replace(' as=\"stylesheet\"', ' as=\"style\"');\n });\n }\n\n // Tick-buffered RSC script injection.\n //\n // React's renderToReadableStream (Fizz) flushes chunks synchronously\n // within one microtask — all chunks from a single flushCompletedQueues\n // call arrive in the same macrotask. We buffer HTML chunks as they\n // arrive, then use setTimeout(0) to defer emitting them plus any\n // accumulated RSC scripts to the next macrotask. This guarantees we\n // never inject <script> tags between partial HTML chunks (which would\n // corrupt split elements like \"<linearGradi\" + \"ent>\"), while still\n // delivering RSC data progressively as Suspense boundaries resolve.\n //\n // Reference: rsc-html-stream by Devon Govett (credited by Next.js)\n // https://github.com/devongovett/rsc-html-stream\n let buffered = [];\n let timeoutId = null;\n\n const transform = new TransformStream({\n transform(chunk, controller) {\n const text = decoder.decode(chunk, { stream: true });\n const fixed = fixPreloadAs(text);\n buffered.push(fixed);\n\n if (timeoutId !== null) return;\n\n timeoutId = setTimeout(() => {\n // Flush all buffered HTML chunks from this React flush cycle\n for (const buf of buffered) {\n if (!injected) {\n const headEnd = buf.indexOf(\"</head>\");\n if (headEnd !== -1) {\n const before = buf.slice(0, headEnd);\n const after = buf.slice(headEnd);\n controller.enqueue(encoder.encode(before + injectHTML + after));\n injected = true;\n continue;\n }\n }\n controller.enqueue(encoder.encode(buf));\n }\n buffered = [];\n\n // Now safe to inject any accumulated RSC scripts — we're between\n // React flush cycles, so no partial HTML chunks can follow until\n // the next macrotask.\n const rscScripts = rscEmbed.flush();\n if (rscScripts) {\n controller.enqueue(encoder.encode(rscScripts));\n }\n\n timeoutId = null;\n }, 0);\n },\n async flush(controller) {\n // Cancel any pending setTimeout callback — flush() drains\n // everything itself, so the callback would be a no-op but\n // cancelling makes the code obviously correct.\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n // Flush any remaining buffered HTML chunks\n for (const buf of buffered) {\n if (!injected) {\n const headEnd = buf.indexOf(\"</head>\");\n if (headEnd !== -1) {\n const before = buf.slice(0, headEnd);\n const after = buf.slice(headEnd);\n controller.enqueue(encoder.encode(before + injectHTML + after));\n injected = true;\n continue;\n }\n }\n controller.enqueue(encoder.encode(buf));\n }\n buffered = [];\n\n if (!injected && injectHTML) {\n controller.enqueue(encoder.encode(injectHTML));\n }\n // Finalize: wait for the RSC stream to complete and emit remaining\n // chunks plus the __VINEXT_RSC_DONE__ signal.\n const finalScripts = await rscEmbed.finalize();\n if (finalScripts) {\n controller.enqueue(encoder.encode(finalScripts));\n }\n },\n });\n\n return htmlStream.pipeThrough(transform);\n } finally {\n // Clean up so we don't leak context between requests\n setNavigationContext(null);\n clearServerInsertedHTML();\n }\n }); // end _runWithNavCtx\n}\n\nexport default {\n async fetch(request) {\n const url = new URL(request.url);\n if (url.pathname.startsWith(\"//\")) {\n return new Response(\"404 Not Found\", { status: 404 });\n }\n const rscModule = await import.meta.viteRsc.loadModule(\"rsc\", \"index\");\n const result = await rscModule.default(request);\n if (result instanceof Response) {\n return result;\n }\n if (result === null || result === undefined) {\n return new Response(\"Not Found\", { status: 404 });\n }\n return new Response(String(result), { status: 200 });\n },\n};\n${\n hasPagesDir\n ? `\n// Re-export pageRoutes and renderPage from the Pages Router server entry so\n// that the Cloudflare Workers RSC bundle can access Pages Router route metadata\n// (including getStaticPaths) via import(\"./ssr/index.js\").pageRoutes, and can\n// delegate unmatched App Router requests to renderPage for hybrid builds.\nexport { pageRoutes, renderPage } from \"virtual:vinext-server-entry\";\n`\n : \"\"\n}`;\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,iBAAiB,cAAc,OAAe;AAC5D,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0cP,cACI;;;;;;IAOA"}
@@ -1,4 +1,8 @@
1
1
  import { createValidFileMatcher } from "../routing/file-matcher.js";
2
- import { type ResolvedNextConfig } from "../config/next-config.js";
3
- export declare function generateClientEntry(pagesDir: string, nextConfig: ResolvedNextConfig, fileMatcher: ReturnType<typeof createValidFileMatcher>): Promise<string>;
2
+ import { ResolvedNextConfig } from "../config/next-config.js";
3
+
4
+ //#region src/entries/pages-client-entry.d.ts
5
+ declare function generateClientEntry(pagesDir: string, nextConfig: ResolvedNextConfig, fileMatcher: ReturnType<typeof createValidFileMatcher>): Promise<string>;
6
+ //#endregion
7
+ export { generateClientEntry };
4
8
  //# sourceMappingURL=pages-client-entry.d.ts.map
@@ -1,33 +1,29 @@
1
- /**
2
- * Pages Router client hydration entry generator.
3
- *
4
- * Generates the virtual client entry module (`virtual:vinext-client-entry`).
5
- * This is the entry point for `vite build` (client bundle). It maps route
6
- * patterns to dynamic imports of page modules so Vite code-splits each page
7
- * into its own chunk. At runtime it reads __NEXT_DATA__ to determine which
8
- * page to hydrate.
9
- *
10
- * Extracted from index.ts.
11
- */
12
- import { pagesRouter, patternToNextFormat as pagesPatternToNextFormat, } from "../routing/pages-router.js";
1
+ import { patternToNextFormat } from "../routing/route-validation.js";
2
+ import { pagesRouter } from "../routing/pages-router.js";
13
3
  import { findFileWithExts } from "./pages-entry-helpers.js";
14
- export async function generateClientEntry(pagesDir, nextConfig, fileMatcher) {
15
- const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
16
- const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
17
- const hasApp = appFilePath !== null;
18
- // Build a map of route pattern -> dynamic import.
19
- // Keys must use Next.js bracket format (e.g. "/user/[id]") to match
20
- // __NEXT_DATA__.page which is set via patternToNextFormat() during SSR.
21
- const loaderEntries = pageRoutes.map((r) => {
22
- const absPath = r.filePath.replace(/\\/g, "/");
23
- const nextFormatPattern = pagesPatternToNextFormat(r.pattern);
24
- // JSON.stringify safely escapes quotes, backslashes, and special chars in
25
- // both the route pattern and the absolute file path.
26
- // lgtm[js/bad-code-sanitization]
27
- return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;
28
- });
29
- const appFileBase = appFilePath?.replace(/\\/g, "/");
30
- return `
4
+ //#region src/entries/pages-client-entry.ts
5
+ /**
6
+ * Pages Router client hydration entry generator.
7
+ *
8
+ * Generates the virtual client entry module (`virtual:vinext-client-entry`).
9
+ * This is the entry point for `vite build` (client bundle). It maps route
10
+ * patterns to dynamic imports of page modules so Vite code-splits each page
11
+ * into its own chunk. At runtime it reads __NEXT_DATA__ to determine which
12
+ * page to hydrate.
13
+ *
14
+ * Extracted from index.ts.
15
+ */
16
+ async function generateClientEntry(pagesDir, nextConfig, fileMatcher) {
17
+ const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
18
+ const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
19
+ const hasApp = appFilePath !== null;
20
+ const loaderEntries = pageRoutes.map((r) => {
21
+ const absPath = r.filePath.replace(/\\/g, "/");
22
+ const nextFormatPattern = patternToNextFormat(r.pattern);
23
+ return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;
24
+ });
25
+ const appFileBase = appFilePath?.replace(/\\/g, "/");
26
+ return `
31
27
  import React from "react";
32
28
  import { hydrateRoot } from "react-dom/client";
33
29
  // Eagerly import the router shim so its module-level popstate listener is
@@ -61,8 +57,7 @@ async function hydrate() {
61
57
  }
62
58
 
63
59
  let element;
64
- ${hasApp
65
- ? `
60
+ ${hasApp ? `
66
61
  try {
67
62
  const appModule = await import(${JSON.stringify(appFileBase)});
68
63
  const AppComponent = appModule.default;
@@ -71,8 +66,7 @@ async function hydrate() {
71
66
  } catch {
72
67
  element = React.createElement(PageComponent, pageProps);
73
68
  }
74
- `
75
- : `
69
+ ` : `
76
70
  element = React.createElement(PageComponent, pageProps);
77
71
  `}
78
72
 
@@ -93,4 +87,7 @@ async function hydrate() {
93
87
  hydrate();
94
88
  `;
95
89
  }
90
+ //#endregion
91
+ export { generateClientEntry };
92
+
96
93
  //# sourceMappingURL=pages-client-entry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pages-client-entry.js","sourceRoot":"","sources":["../../src/entries/pages-client-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,WAAW,EACX,mBAAmB,IAAI,wBAAwB,GAEhD,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAgB,EAChB,UAA8B,EAC9B,WAAsD;IAEtD,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;IAExF,MAAM,WAAW,GAAG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,WAAW,KAAK,IAAI,CAAC;IAEpC,kDAAkD;IAClD,oEAAoE;IACpE,wEAAwE;IACxE,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAQ,EAAE,EAAE;QAChD,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/C,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC9D,0EAA0E;QAC1E,qDAAqD;QACrD,iCAAiC;QACjC,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;IAC5F,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAErD,OAAO;;;;;;;;;EASP,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;IA0BvB,MAAM;QACJ,CAAC,CAAC;;qCAE6B,IAAI,CAAC,SAAS,CAAC,WAAY,CAAC;;;;;;;GAO9D;QACG,CAAC,CAAC;;GAGN;;;;;;;;;;;;;;;;;CAiBD,CAAC;AACF,CAAC","sourcesContent":["/**\n * Pages Router client hydration entry generator.\n *\n * Generates the virtual client entry module (`virtual:vinext-client-entry`).\n * This is the entry point for `vite build` (client bundle). It maps route\n * patterns to dynamic imports of page modules so Vite code-splits each page\n * into its own chunk. At runtime it reads __NEXT_DATA__ to determine which\n * page to hydrate.\n *\n * Extracted from index.ts.\n */\nimport {\n pagesRouter,\n patternToNextFormat as pagesPatternToNextFormat,\n type Route,\n} from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nexport async function generateClientEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const hasApp = appFilePath !== null;\n\n // Build a map of route pattern -> dynamic import.\n // Keys must use Next.js bracket format (e.g. \"/user/[id]\") to match\n // __NEXT_DATA__.page which is set via patternToNextFormat() during SSR.\n const loaderEntries = pageRoutes.map((r: Route) => {\n const absPath = r.filePath.replace(/\\\\/g, \"/\");\n const nextFormatPattern = pagesPatternToNextFormat(r.pattern);\n // JSON.stringify safely escapes quotes, backslashes, and special chars in\n // both the route pattern and the absolute file path.\n // lgtm[js/bad-code-sanitization]\n return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;\n });\n\n const appFileBase = appFilePath?.replace(/\\\\/g, \"/\");\n\n return `\nimport React from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\n// Eagerly import the router shim so its module-level popstate listener is\n// registered. Without this, browser back/forward buttons do nothing because\n// navigateClient() is never invoked on history changes.\nimport \"next/router\";\n\nconst pageLoaders = {\n${loaderEntries.join(\",\\n\")}\n};\n\nasync function hydrate() {\n const nextData = window.__NEXT_DATA__;\n if (!nextData) {\n console.error(\"[vinext] No __NEXT_DATA__ found\");\n return;\n }\n\n const { pageProps } = nextData.props;\n const loader = pageLoaders[nextData.page];\n if (!loader) {\n console.error(\"[vinext] No page loader for route:\", nextData.page);\n return;\n }\n\n const pageModule = await loader();\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n console.error(\"[vinext] Page module has no default export\");\n return;\n }\n\n let element;\n ${\n hasApp\n ? `\n try {\n const appModule = await import(${JSON.stringify(appFileBase!)});\n const AppComponent = appModule.default;\n window.__VINEXT_APP__ = AppComponent;\n element = React.createElement(AppComponent, { Component: PageComponent, pageProps });\n } catch {\n element = React.createElement(PageComponent, pageProps);\n }\n `\n : `\n element = React.createElement(PageComponent, pageProps);\n `\n }\n\n // Wrap with RouterContext.Provider so next/compat/router works during hydration\n const { wrapWithRouterContext } = await import(\"next/router\");\n element = wrapWithRouterContext(element);\n\n const container = document.getElementById(\"__next\");\n if (!container) {\n console.error(\"[vinext] No #__next element found\");\n return;\n }\n\n const root = hydrateRoot(container, element);\n window.__VINEXT_ROOT__ = root;\n}\n\nhydrate();\n`;\n}\n"]}
1
+ {"version":3,"file":"pages-client-entry.js","names":["pagesPatternToNextFormat"],"sources":["../../src/entries/pages-client-entry.ts"],"sourcesContent":["/**\n * Pages Router client hydration entry generator.\n *\n * Generates the virtual client entry module (`virtual:vinext-client-entry`).\n * This is the entry point for `vite build` (client bundle). It maps route\n * patterns to dynamic imports of page modules so Vite code-splits each page\n * into its own chunk. At runtime it reads __NEXT_DATA__ to determine which\n * page to hydrate.\n *\n * Extracted from index.ts.\n */\nimport {\n pagesRouter,\n patternToNextFormat as pagesPatternToNextFormat,\n type Route,\n} from \"../routing/pages-router.js\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\nimport { type ResolvedNextConfig } from \"../config/next-config.js\";\nimport { findFileWithExts } from \"./pages-entry-helpers.js\";\n\nexport async function generateClientEntry(\n pagesDir: string,\n nextConfig: ResolvedNextConfig,\n fileMatcher: ReturnType<typeof createValidFileMatcher>,\n): Promise<string> {\n const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);\n\n const appFilePath = findFileWithExts(pagesDir, \"_app\", fileMatcher);\n const hasApp = appFilePath !== null;\n\n // Build a map of route pattern -> dynamic import.\n // Keys must use Next.js bracket format (e.g. \"/user/[id]\") to match\n // __NEXT_DATA__.page which is set via patternToNextFormat() during SSR.\n const loaderEntries = pageRoutes.map((r: Route) => {\n const absPath = r.filePath.replace(/\\\\/g, \"/\");\n const nextFormatPattern = pagesPatternToNextFormat(r.pattern);\n // JSON.stringify safely escapes quotes, backslashes, and special chars in\n // both the route pattern and the absolute file path.\n // lgtm[js/bad-code-sanitization]\n return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;\n });\n\n const appFileBase = appFilePath?.replace(/\\\\/g, \"/\");\n\n return `\nimport React from \"react\";\nimport { hydrateRoot } from \"react-dom/client\";\n// Eagerly import the router shim so its module-level popstate listener is\n// registered. Without this, browser back/forward buttons do nothing because\n// navigateClient() is never invoked on history changes.\nimport \"next/router\";\n\nconst pageLoaders = {\n${loaderEntries.join(\",\\n\")}\n};\n\nasync function hydrate() {\n const nextData = window.__NEXT_DATA__;\n if (!nextData) {\n console.error(\"[vinext] No __NEXT_DATA__ found\");\n return;\n }\n\n const { pageProps } = nextData.props;\n const loader = pageLoaders[nextData.page];\n if (!loader) {\n console.error(\"[vinext] No page loader for route:\", nextData.page);\n return;\n }\n\n const pageModule = await loader();\n const PageComponent = pageModule.default;\n if (!PageComponent) {\n console.error(\"[vinext] Page module has no default export\");\n return;\n }\n\n let element;\n ${\n hasApp\n ? `\n try {\n const appModule = await import(${JSON.stringify(appFileBase!)});\n const AppComponent = appModule.default;\n window.__VINEXT_APP__ = AppComponent;\n element = React.createElement(AppComponent, { Component: PageComponent, pageProps });\n } catch {\n element = React.createElement(PageComponent, pageProps);\n }\n `\n : `\n element = React.createElement(PageComponent, pageProps);\n `\n }\n\n // Wrap with RouterContext.Provider so next/compat/router works during hydration\n const { wrapWithRouterContext } = await import(\"next/router\");\n element = wrapWithRouterContext(element);\n\n const container = document.getElementById(\"__next\");\n if (!container) {\n console.error(\"[vinext] No #__next element found\");\n return;\n }\n\n const root = hydrateRoot(container, element);\n window.__VINEXT_ROOT__ = root;\n}\n\nhydrate();\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eAAsB,oBACpB,UACA,YACA,aACiB;CACjB,MAAM,aAAa,MAAM,YAAY,UAAU,YAAY,gBAAgB,YAAY;CAEvF,MAAM,cAAc,iBAAiB,UAAU,QAAQ,YAAY;CACnE,MAAM,SAAS,gBAAgB;CAK/B,MAAM,gBAAgB,WAAW,KAAK,MAAa;EACjD,MAAM,UAAU,EAAE,SAAS,QAAQ,OAAO,IAAI;EAC9C,MAAM,oBAAoBA,oBAAyB,EAAE,QAAQ;AAI7D,SAAO,KAAK,KAAK,UAAU,kBAAkB,CAAC,iBAAiB,KAAK,UAAU,QAAQ,CAAC;GACvF;CAEF,MAAM,cAAc,aAAa,QAAQ,OAAO,IAAI;AAEpD,QAAO;;;;;;;;;EASP,cAAc,KAAK,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;IA0BxB,SACI;;qCAE6B,KAAK,UAAU,YAAa,CAAC;;;;;;;MAQ1D;;IAGL"}
@@ -1,7 +1,11 @@
1
1
  import { createValidFileMatcher } from "../routing/file-matcher.js";
2
+
3
+ //#region src/entries/pages-entry-helpers.d.ts
2
4
  /**
3
5
  * Find a file with any of the valid extensions in the given directory.
4
6
  * Returns the first matching absolute path, or null if not found.
5
7
  */
6
- export declare function findFileWithExts(dir: string, name: string, matcher: ReturnType<typeof createValidFileMatcher>): string | null;
8
+ declare function findFileWithExts(dir: string, name: string, matcher: ReturnType<typeof createValidFileMatcher>): string | null;
9
+ //#endregion
10
+ export { findFileWithExts };
7
11
  //# sourceMappingURL=pages-entry-helpers.d.ts.map
@@ -1,18 +1,21 @@
1
- /**
2
- * Shared helpers used by the Pages Router entry generators.
3
- */
4
- import path from "node:path";
5
1
  import fs from "node:fs";
2
+ import path from "node:path";
3
+ //#region src/entries/pages-entry-helpers.ts
4
+ /**
5
+ * Shared helpers used by the Pages Router entry generators.
6
+ */
6
7
  /**
7
- * Find a file with any of the valid extensions in the given directory.
8
- * Returns the first matching absolute path, or null if not found.
9
- */
10
- export function findFileWithExts(dir, name, matcher) {
11
- for (const ext of matcher.dottedExtensions) {
12
- const filePath = path.join(dir, name + ext);
13
- if (fs.existsSync(filePath))
14
- return filePath;
15
- }
16
- return null;
8
+ * Find a file with any of the valid extensions in the given directory.
9
+ * Returns the first matching absolute path, or null if not found.
10
+ */
11
+ function findFileWithExts(dir, name, matcher) {
12
+ for (const ext of matcher.dottedExtensions) {
13
+ const filePath = path.join(dir, name + ext);
14
+ if (fs.existsSync(filePath)) return filePath;
15
+ }
16
+ return null;
17
17
  }
18
+ //#endregion
19
+ export { findFileWithExts };
20
+
18
21
  //# sourceMappingURL=pages-entry-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pages-entry-helpers.js","sourceRoot":"","sources":["../../src/entries/pages-entry-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,IAAY,EACZ,OAAkD;IAElD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,GAAG,GAAG,CAAC,CAAC;QAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,QAAQ,CAAC;IAC/C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Shared helpers used by the Pages Router entry generators.\n */\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\n\n/**\n * Find a file with any of the valid extensions in the given directory.\n * Returns the first matching absolute path, or null if not found.\n */\nexport function findFileWithExts(\n dir: string,\n name: string,\n matcher: ReturnType<typeof createValidFileMatcher>,\n): string | null {\n for (const ext of matcher.dottedExtensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"pages-entry-helpers.js","names":[],"sources":["../../src/entries/pages-entry-helpers.ts"],"sourcesContent":["/**\n * Shared helpers used by the Pages Router entry generators.\n */\nimport path from \"node:path\";\nimport fs from \"node:fs\";\nimport { createValidFileMatcher } from \"../routing/file-matcher.js\";\n\n/**\n * Find a file with any of the valid extensions in the given directory.\n * Returns the first matching absolute path, or null if not found.\n */\nexport function findFileWithExts(\n dir: string,\n name: string,\n matcher: ReturnType<typeof createValidFileMatcher>,\n): string | null {\n for (const ext of matcher.dottedExtensions) {\n const filePath = path.join(dir, name + ext);\n if (fs.existsSync(filePath)) return filePath;\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,iBACd,KACA,MACA,SACe;AACf,MAAK,MAAM,OAAO,QAAQ,kBAAkB;EAC1C,MAAM,WAAW,KAAK,KAAK,KAAK,OAAO,IAAI;AAC3C,MAAI,GAAG,WAAW,SAAS,CAAE,QAAO;;AAEtC,QAAO"}
@@ -1,8 +1,12 @@
1
1
  import { createValidFileMatcher } from "../routing/file-matcher.js";
2
- import { type ResolvedNextConfig } from "../config/next-config.js";
2
+ import { ResolvedNextConfig } from "../config/next-config.js";
3
+
4
+ //#region src/entries/pages-server-entry.d.ts
3
5
  /**
4
6
  * Generate the virtual SSR server entry module.
5
7
  * This is the entry point for `vite build --ssr`.
6
8
  */
7
- export declare function generateServerEntry(pagesDir: string, nextConfig: ResolvedNextConfig, fileMatcher: ReturnType<typeof createValidFileMatcher>, middlewarePath: string | null, instrumentationPath: string | null): Promise<string>;
9
+ declare function generateServerEntry(pagesDir: string, nextConfig: ResolvedNextConfig, fileMatcher: ReturnType<typeof createValidFileMatcher>, middlewarePath: string | null, instrumentationPath: string | null): Promise<string>;
10
+ //#endregion
11
+ export { generateServerEntry };
8
12
  //# sourceMappingURL=pages-server-entry.d.ts.map