vite-plugin-react-server 1.0.2 → 1.1.0

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 (490) hide show
  1. package/README.md +49 -76
  2. package/bin/patch.mjs +27 -20
  3. package/dist/_virtual/dynamic-import-helper.js +24 -0
  4. package/dist/_virtual/dynamic-import-helper.js.map +1 -0
  5. package/dist/client.d.ts +1 -1
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +1 -1
  8. package/dist/index.d.ts +2 -4
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +9 -26
  11. package/dist/index.js.map +1 -1
  12. package/dist/package.json +24 -14
  13. package/dist/plugin/components.d.ts +1 -1
  14. package/dist/plugin/components.d.ts.map +1 -1
  15. package/dist/plugin/components.js +1 -1
  16. package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts +6 -0
  17. package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts.map +1 -0
  18. package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +30 -0
  19. package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +1 -0
  20. package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts +13 -0
  21. package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts.map +1 -0
  22. package/dist/plugin/config/autoDiscover/customWorkerFiles.js +24 -0
  23. package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +1 -0
  24. package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts +11 -0
  25. package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts.map +1 -0
  26. package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +29 -0
  27. package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +1 -0
  28. package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +6 -0
  29. package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -0
  30. package/dist/plugin/config/autoDiscover/resolveBuildPages.js +83 -0
  31. package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -0
  32. package/dist/plugin/config/defaults.d.ts +18 -14
  33. package/dist/plugin/config/defaults.d.ts.map +1 -1
  34. package/dist/plugin/config/defaults.js +42 -21
  35. package/dist/plugin/config/defaults.js.map +1 -1
  36. package/dist/plugin/config/getCondition.d.ts +1 -1
  37. package/dist/plugin/config/getCondition.d.ts.map +1 -1
  38. package/dist/plugin/config/getCondition.js +2 -2
  39. package/dist/plugin/config/getCondition.js.map +1 -1
  40. package/dist/plugin/config/getPaths.d.ts +0 -1
  41. package/dist/plugin/config/getPaths.d.ts.map +1 -1
  42. package/dist/plugin/config/getPaths.js.map +1 -1
  43. package/dist/plugin/config/index.d.ts +0 -1
  44. package/dist/plugin/config/index.d.ts.map +1 -1
  45. package/dist/plugin/config/index.js +0 -1
  46. package/dist/plugin/config/resolveAutoDiscover.d.ts +20 -0
  47. package/dist/plugin/config/resolveAutoDiscover.d.ts.map +1 -0
  48. package/dist/plugin/config/resolveAutoDiscover.js +128 -0
  49. package/dist/plugin/config/resolveAutoDiscover.js.map +1 -0
  50. package/dist/plugin/config/resolveOptions.d.ts +1 -1
  51. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  52. package/dist/plugin/config/resolveOptions.js +109 -77
  53. package/dist/plugin/config/resolveOptions.js.map +1 -1
  54. package/dist/plugin/config/resolvePages.d.ts +0 -1
  55. package/dist/plugin/config/resolvePages.d.ts.map +1 -1
  56. package/dist/plugin/config/resolvePages.js +6 -8
  57. package/dist/plugin/config/resolvePages.js.map +1 -1
  58. package/dist/plugin/config/resolveUrlOption.d.ts +16 -0
  59. package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -0
  60. package/dist/plugin/config/resolveUrlOption.js +37 -0
  61. package/dist/plugin/config/resolveUrlOption.js.map +1 -0
  62. package/dist/plugin/config/resolveUserConfig.d.ts +4 -5
  63. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  64. package/dist/plugin/config/resolveUserConfig.js +80 -132
  65. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  66. package/dist/plugin/copy.d.ts +7 -0
  67. package/dist/plugin/copy.d.ts.map +1 -0
  68. package/dist/plugin/copy.js +30 -0
  69. package/dist/plugin/css-collector-elements.d.ts +4 -0
  70. package/dist/plugin/css-collector-elements.d.ts.map +1 -0
  71. package/dist/plugin/css-collector-elements.js +19 -0
  72. package/dist/plugin/css-collector-elements.js.map +1 -0
  73. package/dist/plugin/css-collector.d.ts +2 -8
  74. package/dist/plugin/css-collector.d.ts.map +1 -1
  75. package/dist/plugin/css-collector.js +9 -36
  76. package/dist/plugin/css-collector.js.map +1 -1
  77. package/dist/plugin/helpers/cleanObject.d.ts +3 -0
  78. package/dist/plugin/helpers/cleanObject.d.ts.map +1 -0
  79. package/dist/plugin/helpers/cleanObject.js +47 -0
  80. package/dist/plugin/helpers/cleanObject.js.map +1 -0
  81. package/dist/plugin/helpers/collectBundleManifestCss.d.ts +8 -0
  82. package/dist/plugin/helpers/collectBundleManifestCss.d.ts.map +1 -0
  83. package/dist/plugin/helpers/collectBundleManifestCss.js +110 -0
  84. package/dist/plugin/helpers/collectManifestCss.d.ts +7 -0
  85. package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -0
  86. package/dist/plugin/helpers/collectManifestCss.js +44 -0
  87. package/dist/plugin/helpers/collectManifestCss.js.map +1 -0
  88. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +31 -0
  89. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -0
  90. package/dist/plugin/helpers/collectViteModuleGraphCss.js +104 -0
  91. package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -0
  92. package/dist/plugin/helpers/createCssProps.d.ts +25 -0
  93. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -0
  94. package/dist/plugin/helpers/createCssProps.js +57 -0
  95. package/dist/plugin/helpers/createCssProps.js.map +1 -0
  96. package/dist/plugin/helpers/createEventHandler.d.ts +22 -0
  97. package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -0
  98. package/dist/plugin/helpers/createEventHandler.js +36 -0
  99. package/dist/plugin/helpers/createEventHandler.js.map +1 -0
  100. package/dist/plugin/helpers/createHandler.d.ts +7 -13
  101. package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
  102. package/dist/plugin/helpers/createHandler.js +54 -96
  103. package/dist/plugin/helpers/createHandler.js.map +1 -1
  104. package/dist/plugin/helpers/createRscStream.d.ts +12 -26
  105. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
  106. package/dist/plugin/helpers/createRscStream.js +105 -51
  107. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  108. package/dist/plugin/helpers/defaultFileWriter.d.ts +2 -0
  109. package/dist/plugin/helpers/defaultFileWriter.d.ts.map +1 -0
  110. package/dist/plugin/helpers/defaultFileWriter.js +1 -0
  111. package/dist/plugin/helpers/getBundleManifest.d.ts +10 -16
  112. package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
  113. package/dist/plugin/helpers/getBundleManifest.js +30 -22
  114. package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
  115. package/dist/plugin/helpers/getRouteFiles.d.ts +14 -0
  116. package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -0
  117. package/dist/plugin/helpers/getRouteFiles.js +36 -0
  118. package/dist/plugin/helpers/getRouteFiles.js.map +1 -0
  119. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  120. package/dist/plugin/helpers/inputNormalizer.js +38 -32
  121. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  122. package/dist/plugin/helpers/metrics.d.ts +11 -0
  123. package/dist/plugin/helpers/metrics.d.ts.map +1 -0
  124. package/dist/plugin/helpers/metrics.js +35 -0
  125. package/dist/plugin/helpers/metrics.js.map +1 -0
  126. package/dist/plugin/helpers/resolvePageAndProps.d.ts +27 -0
  127. package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -0
  128. package/dist/plugin/helpers/resolvePageAndProps.js +51 -0
  129. package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -0
  130. package/dist/plugin/helpers/serializeUserOptions.d.ts +8 -0
  131. package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -0
  132. package/dist/plugin/helpers/serializeUserOptions.js +182 -0
  133. package/dist/plugin/helpers/serializeUserOptions.js.map +1 -0
  134. package/dist/plugin/helpers/stashReturnValue.d.ts +2 -0
  135. package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -0
  136. package/dist/plugin/helpers/stashReturnValue.js +14 -0
  137. package/dist/plugin/helpers/tryManifest.d.ts +5 -3
  138. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
  139. package/dist/plugin/helpers/tryManifest.js +16 -7
  140. package/dist/plugin/helpers/tryManifest.js.map +1 -1
  141. package/dist/plugin/html.d.ts +2 -3
  142. package/dist/plugin/html.d.ts.map +1 -1
  143. package/dist/plugin/html.js +7 -1
  144. package/dist/plugin/html.js.map +1 -1
  145. package/dist/plugin/index.d.ts +1 -2
  146. package/dist/plugin/index.d.ts.map +1 -1
  147. package/dist/plugin/index.js +3 -1
  148. package/dist/plugin/loader/createBuildLoader.d.ts +26 -4
  149. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  150. package/dist/plugin/loader/createBuildLoader.js +98 -33
  151. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  152. package/dist/plugin/loader/css-loader.development.d.ts +57 -0
  153. package/dist/plugin/loader/css-loader.development.d.ts.map +1 -0
  154. package/dist/plugin/loader/css-loader.development.js +81 -0
  155. package/dist/plugin/loader/css-loader.development.js.map +1 -0
  156. package/dist/plugin/loader/css-loader.production.d.ts +31 -0
  157. package/dist/plugin/loader/css-loader.production.d.ts.map +1 -0
  158. package/dist/plugin/loader/css-loader.production.js +45 -0
  159. package/dist/plugin/loader/css-loader.production.js.map +1 -0
  160. package/dist/plugin/loader/index.d.ts +2 -0
  161. package/dist/plugin/loader/index.d.ts.map +1 -0
  162. package/dist/plugin/loader/index.js +1 -0
  163. package/dist/plugin/loader/plugin.d.ts +22 -0
  164. package/dist/plugin/loader/plugin.d.ts.map +1 -0
  165. package/dist/plugin/loader/plugin.js +27 -0
  166. package/dist/plugin/loader/react-loader.d.ts +3 -7
  167. package/dist/plugin/loader/react-loader.d.ts.map +1 -1
  168. package/dist/plugin/loader/react-loader.js +85 -30
  169. package/dist/plugin/loader/react-loader.js.map +1 -1
  170. package/dist/plugin/loader/temporaryReferences.d.ts +2 -0
  171. package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -0
  172. package/dist/plugin/loader/temporaryReferences.js +11 -0
  173. package/dist/plugin/loader/temporaryReferences.js.map +1 -0
  174. package/dist/plugin/moduleRefs.d.ts +7 -0
  175. package/dist/plugin/moduleRefs.d.ts.map +1 -0
  176. package/dist/plugin/moduleRefs.js +17 -0
  177. package/dist/plugin/moduleRefs.js.map +1 -0
  178. package/dist/plugin/plugin.client.d.ts +3 -0
  179. package/dist/plugin/plugin.client.d.ts.map +1 -0
  180. package/dist/plugin/plugin.client.js +19 -0
  181. package/dist/plugin/plugin.client.js.map +1 -0
  182. package/dist/plugin/plugin.d.ts +1 -5
  183. package/dist/plugin/plugin.d.ts.map +1 -1
  184. package/dist/plugin/plugin.js +3 -9
  185. package/dist/plugin/plugin.server.d.ts +3 -0
  186. package/dist/plugin/plugin.server.d.ts.map +1 -0
  187. package/dist/plugin/plugin.server.js +28 -0
  188. package/dist/plugin/plugin.server.js.map +1 -0
  189. package/dist/plugin/preserver/plugin.js +1 -1
  190. package/dist/plugin/preserver/plugin.js.map +1 -1
  191. package/dist/plugin/react-client/index.d.ts +1 -2
  192. package/dist/plugin/react-client/index.d.ts.map +1 -1
  193. package/dist/plugin/react-client/index.js +1 -19
  194. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  195. package/dist/plugin/react-client/plugin.js +60 -219
  196. package/dist/plugin/react-client/plugin.js.map +1 -1
  197. package/dist/plugin/react-client/server.d.ts +27 -0
  198. package/dist/plugin/react-client/server.d.ts.map +1 -0
  199. package/dist/plugin/react-client/server.js +197 -0
  200. package/dist/plugin/react-client/server.js.map +1 -0
  201. package/dist/plugin/react-server/index.d.ts +1 -2
  202. package/dist/plugin/react-server/index.d.ts.map +1 -1
  203. package/dist/plugin/react-server/index.js +1 -21
  204. package/dist/plugin/react-server/plugin.d.ts +0 -1
  205. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  206. package/dist/plugin/react-server/plugin.js +60 -186
  207. package/dist/plugin/react-server/plugin.js.map +1 -1
  208. package/dist/plugin/react-server/server.d.ts +9 -0
  209. package/dist/plugin/react-server/server.d.ts.map +1 -0
  210. package/dist/plugin/react-server/server.js +120 -0
  211. package/dist/plugin/react-server/server.js.map +1 -0
  212. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +23 -0
  213. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -0
  214. package/dist/plugin/react-static/collectHtmlWorkerContent.js +85 -0
  215. package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -0
  216. package/dist/plugin/react-static/collectRscContent.d.ts +24 -0
  217. package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -0
  218. package/dist/plugin/react-static/collectRscContent.js +49 -0
  219. package/dist/plugin/react-static/collectRscContent.js.map +1 -0
  220. package/dist/plugin/react-static/configurePreviewServer.d.ts +7 -0
  221. package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -0
  222. package/dist/plugin/react-static/configurePreviewServer.js +67 -0
  223. package/dist/plugin/react-static/configurePreviewServer.js.map +1 -0
  224. package/dist/plugin/react-static/fileWriter.d.ts +23 -0
  225. package/dist/plugin/react-static/fileWriter.d.ts.map +1 -0
  226. package/dist/plugin/react-static/fileWriter.js +65 -0
  227. package/dist/plugin/react-static/fileWriter.js.map +1 -0
  228. package/dist/plugin/react-static/plugin.d.ts +15 -0
  229. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  230. package/dist/plugin/react-static/plugin.js +248 -149
  231. package/dist/plugin/react-static/plugin.js.map +1 -1
  232. package/dist/plugin/react-static/renderPage.d.ts +3 -0
  233. package/dist/plugin/react-static/renderPage.d.ts.map +1 -0
  234. package/dist/plugin/react-static/renderPage.js +116 -0
  235. package/dist/plugin/react-static/renderPage.js.map +1 -0
  236. package/dist/plugin/react-static/renderPages.d.ts +3 -0
  237. package/dist/plugin/react-static/renderPages.d.ts.map +1 -0
  238. package/dist/plugin/react-static/renderPages.js +125 -0
  239. package/dist/plugin/react-static/renderPages.js.map +1 -0
  240. package/dist/plugin/react-static/renderStreams.d.ts +26 -0
  241. package/dist/plugin/react-static/renderStreams.d.ts.map +1 -0
  242. package/dist/plugin/react-static/renderStreams.js +27 -0
  243. package/dist/plugin/react-static/renderStreams.js.map +1 -0
  244. package/dist/plugin/react-static/rscToHtmlStream.d.ts +22 -0
  245. package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -0
  246. package/dist/plugin/react-static/rscToHtmlStream.js +54 -0
  247. package/dist/plugin/react-static/rscToHtmlStream.js.map +1 -0
  248. package/dist/plugin/react-static/streamHandler.d.ts +2 -0
  249. package/dist/plugin/react-static/streamHandler.d.ts.map +1 -0
  250. package/dist/plugin/react-static/streamHandler.js +1 -0
  251. package/dist/plugin/react-static/types.d.ts +11 -0
  252. package/dist/plugin/react-static/types.d.ts.map +1 -1
  253. package/dist/plugin/resolvePage.d.ts +26 -9
  254. package/dist/plugin/resolvePage.d.ts.map +1 -1
  255. package/dist/plugin/resolvePage.js +41 -39
  256. package/dist/plugin/resolvePage.js.map +1 -1
  257. package/dist/plugin/resolveProps.d.ts +40 -7
  258. package/dist/plugin/resolveProps.d.ts.map +1 -1
  259. package/dist/plugin/resolveProps.js +100 -75
  260. package/dist/plugin/resolveProps.js.map +1 -1
  261. package/dist/plugin/root.d.ts +1 -0
  262. package/dist/plugin/root.d.ts.map +1 -1
  263. package/dist/plugin/root.js +1 -0
  264. package/dist/plugin/root.js.map +1 -1
  265. package/dist/plugin/transformer/index.d.ts +2 -1
  266. package/dist/plugin/transformer/index.d.ts.map +1 -1
  267. package/dist/plugin/transformer/index.js +2 -1
  268. package/dist/plugin/transformer/plugin.client.d.ts +4 -0
  269. package/dist/plugin/transformer/plugin.client.d.ts.map +1 -0
  270. package/dist/plugin/transformer/plugin.client.js +83 -0
  271. package/dist/plugin/transformer/plugin.client.js.map +1 -0
  272. package/dist/plugin/transformer/plugin.d.ts +1 -27
  273. package/dist/plugin/transformer/plugin.d.ts.map +1 -1
  274. package/dist/plugin/transformer/plugin.js +3 -87
  275. package/dist/plugin/transformer/plugin.js.map +1 -1
  276. package/dist/plugin/transformer/plugin.server.d.ts +4 -0
  277. package/dist/plugin/transformer/plugin.server.d.ts.map +1 -0
  278. package/dist/plugin/transformer/plugin.server.js +76 -0
  279. package/dist/plugin/transformer/plugin.server.js.map +1 -0
  280. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +11 -0
  281. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -0
  282. package/dist/plugin/transformer/upgradeCssModuleCode.js +38 -0
  283. package/dist/plugin/types/css-tracking.d.ts +6 -0
  284. package/dist/plugin/types/css-tracking.d.ts.map +1 -0
  285. package/dist/plugin/types/css-tracking.js +1 -0
  286. package/dist/plugin/types.d.ts +372 -86
  287. package/dist/plugin/types.d.ts.map +1 -1
  288. package/dist/plugin/types.js +1 -1
  289. package/dist/plugin/vendor.client.d.ts +4 -0
  290. package/dist/plugin/vendor.client.d.ts.map +1 -0
  291. package/dist/plugin/vendor.client.js +16 -0
  292. package/dist/plugin/vendor.client.js.map +1 -0
  293. package/dist/plugin/vendor.server.d.ts +4 -0
  294. package/dist/plugin/vendor.server.d.ts.map +1 -0
  295. package/dist/plugin/vendor.server.js +16 -0
  296. package/dist/plugin/vendor.server.js.map +1 -0
  297. package/dist/plugin/worker/createWorker.d.ts +25 -7
  298. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  299. package/dist/plugin/worker/createWorker.js +108 -33
  300. package/dist/plugin/worker/createWorker.js.map +1 -1
  301. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +12 -0
  302. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -0
  303. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +103 -0
  304. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -0
  305. package/dist/plugin/worker/html/html-worker.development.d.ts +0 -30
  306. package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
  307. package/dist/plugin/worker/html/html-worker.development.js +3 -17
  308. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  309. package/dist/plugin/worker/html/html-worker.production.js +12 -5
  310. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  311. package/dist/plugin/worker/html/messageHandler.d.ts +2 -2
  312. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  313. package/dist/plugin/worker/html/messageHandler.js +87 -84
  314. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  315. package/dist/plugin/worker/html/types.d.ts +18 -0
  316. package/dist/plugin/worker/html/types.d.ts.map +1 -0
  317. package/dist/plugin/worker/html/types.js +1 -0
  318. package/dist/plugin/worker/registerLoaders.d.ts +9 -0
  319. package/dist/plugin/worker/registerLoaders.d.ts.map +1 -0
  320. package/dist/plugin/worker/registerLoaders.js +45 -0
  321. package/dist/plugin/worker/rsc/handleRender.d.ts +4 -0
  322. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -0
  323. package/dist/plugin/worker/rsc/handleRender.js +147 -0
  324. package/dist/plugin/worker/rsc/handleRender.js.map +1 -0
  325. package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -2
  326. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  327. package/dist/plugin/worker/rsc/messageHandler.js +47 -112
  328. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  329. package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +0 -30
  330. package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -1
  331. package/dist/plugin/worker/rsc/rsc-worker.development.js +29 -4
  332. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  333. package/dist/plugin/worker/rsc/rsc-worker.production.js +3 -3
  334. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  335. package/dist/plugin/worker/rsc/state.d.ts +73 -2
  336. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  337. package/dist/plugin/worker/rsc/state.js +40 -3
  338. package/dist/plugin/worker/rsc/state.js.map +1 -1
  339. package/dist/plugin/worker/sendMessage.d.ts +3 -0
  340. package/dist/plugin/worker/sendMessage.d.ts.map +1 -0
  341. package/dist/plugin/worker/sendMessage.js +48 -0
  342. package/dist/plugin/worker/types.d.ts +218 -76
  343. package/dist/plugin/worker/types.d.ts.map +1 -1
  344. package/dist/server.d.ts +1 -1
  345. package/dist/server.d.ts.map +1 -1
  346. package/dist/server.js +6 -1
  347. package/dist/server.js.map +1 -1
  348. package/dist/tsconfig.tsbuildinfo +1 -1
  349. package/package.json +24 -14
  350. package/plugin/components.ts +1 -1
  351. package/plugin/config/autoDiscover/createGlobAutoDiscover.ts +29 -0
  352. package/plugin/config/autoDiscover/customWorkerFiles.ts +27 -0
  353. package/plugin/config/autoDiscover/pageAndPropFiles.ts +36 -0
  354. package/plugin/config/autoDiscover/resolveBuildPages.ts +98 -0
  355. package/plugin/config/defaults.tsx +38 -29
  356. package/plugin/config/getCondition.ts +7 -3
  357. package/plugin/config/getPaths.ts +1 -7
  358. package/plugin/config/index.ts +0 -1
  359. package/plugin/config/resolveAutoDiscover.ts +177 -0
  360. package/plugin/config/resolveOptions.ts +220 -118
  361. package/plugin/config/resolvePages.ts +5 -7
  362. package/plugin/config/resolveUrlOption.ts +43 -0
  363. package/plugin/config/resolveUserConfig.ts +116 -166
  364. package/plugin/copy.ts +39 -0
  365. package/plugin/css-collector-elements.tsx +21 -0
  366. package/plugin/css-collector.tsx +20 -53
  367. package/plugin/helpers/cleanObject.ts +50 -0
  368. package/plugin/helpers/collectBundleManifestCss.ts +160 -0
  369. package/plugin/helpers/collectManifestCss.ts +61 -0
  370. package/plugin/helpers/collectViteModuleGraphCss.ts +158 -0
  371. package/plugin/helpers/createCssProps.tsx +85 -0
  372. package/plugin/helpers/createEventHandler.ts +44 -0
  373. package/plugin/helpers/createHandler.ts +57 -126
  374. package/plugin/helpers/createRscStream.tsx +156 -0
  375. package/plugin/helpers/defaultFileWriter.ts +0 -0
  376. package/plugin/helpers/getBundleManifest.ts +42 -37
  377. package/plugin/helpers/getRouteFiles.ts +47 -0
  378. package/plugin/helpers/inputNormalizer.ts +16 -10
  379. package/plugin/helpers/metrics.ts +64 -0
  380. package/plugin/helpers/resolvePageAndProps.ts +81 -0
  381. package/plugin/helpers/serializeUserOptions.ts +209 -0
  382. package/plugin/helpers/stashReturnValue.ts +16 -0
  383. package/plugin/helpers/tryManifest.ts +35 -18
  384. package/plugin/html.tsx +14 -3
  385. package/plugin/index.ts +5 -2
  386. package/plugin/loader/createBuildLoader.ts +152 -47
  387. package/plugin/loader/css-loader.development.ts +157 -0
  388. package/plugin/loader/css-loader.production.ts +86 -0
  389. package/plugin/loader/index.ts +1 -0
  390. package/plugin/loader/plugin.ts +33 -0
  391. package/plugin/loader/react-loader.ts +109 -41
  392. package/plugin/loader/temporaryReferences.ts +3 -0
  393. package/plugin/moduleRefs.ts +11 -0
  394. package/plugin/plugin.client.ts +12 -0
  395. package/plugin/plugin.server.ts +25 -0
  396. package/plugin/plugin.ts +5 -9
  397. package/plugin/preserver/plugin.ts +1 -1
  398. package/plugin/react-client/index.ts +1 -12
  399. package/plugin/react-client/plugin.ts +70 -259
  400. package/plugin/react-client/server.ts +276 -0
  401. package/plugin/react-server/index.ts +1 -14
  402. package/plugin/react-server/plugin.ts +69 -220
  403. package/plugin/react-server/server.ts +128 -0
  404. package/plugin/react-static/collectHtmlWorkerContent.ts +120 -0
  405. package/plugin/react-static/collectRscContent.ts +77 -0
  406. package/plugin/react-static/configurePreviewServer.ts +68 -0
  407. package/plugin/react-static/fileWriter.ts +103 -0
  408. package/plugin/react-static/plugin.ts +308 -181
  409. package/plugin/react-static/renderPage.ts +151 -0
  410. package/plugin/react-static/renderPages.ts +154 -0
  411. package/plugin/react-static/renderStreams.ts +48 -0
  412. package/plugin/react-static/rscToHtmlStream.ts +85 -0
  413. package/plugin/react-static/streamHandler.ts +0 -0
  414. package/plugin/react-static/types.ts +10 -0
  415. package/plugin/resolvePage.ts +67 -57
  416. package/plugin/resolveProps.ts +148 -104
  417. package/plugin/root.ts +1 -1
  418. package/plugin/transformer/index.ts +2 -1
  419. package/plugin/transformer/plugin.client.ts +109 -0
  420. package/plugin/transformer/plugin.server.ts +98 -0
  421. package/plugin/transformer/plugin.ts +2 -115
  422. package/plugin/transformer/upgradeCssModuleCode.ts +42 -0
  423. package/plugin/types/css-tracking.ts +5 -0
  424. package/plugin/types/react-server-dom-esm.d.ts +54 -0
  425. package/plugin/types.ts +508 -97
  426. package/plugin/vendor.client.ts +12 -0
  427. package/plugin/vendor.server.ts +12 -0
  428. package/plugin/worker/createWorker.ts +158 -53
  429. package/plugin/worker/html/createHtmlWorkerRenderState.tsx +112 -0
  430. package/plugin/worker/html/html-worker.development.tsx +5 -75
  431. package/plugin/worker/html/html-worker.production.tsx +18 -7
  432. package/plugin/worker/html/messageHandler.tsx +126 -0
  433. package/plugin/worker/html/types.ts +19 -0
  434. package/plugin/worker/registerLoaders.ts +54 -0
  435. package/plugin/worker/rsc/handleRender.ts +180 -0
  436. package/plugin/worker/rsc/messageHandler.tsx +58 -132
  437. package/plugin/worker/rsc/rsc-worker.development.ts +49 -63
  438. package/plugin/worker/rsc/rsc-worker.production.ts +5 -5
  439. package/plugin/worker/rsc/state.ts +79 -2
  440. package/plugin/worker/sendMessage.ts +49 -0
  441. package/plugin/worker/types.ts +299 -100
  442. package/scripts/check-react-version.mjs +60 -48
  443. package/scripts/react+0.0.0-experimental-0ca8420f-20250504.patch +57 -0
  444. package/scripts/react-dom+0.0.0-experimental-0ca8420f-20250504.patch +819 -0
  445. package/scripts/{react-server-dom-esm+0.0.0-experimental-eda36a1c-20250228.patch → react-server-dom-esm+0.0.0-experimental-0ca8420f-20250504.patch} +1702 -2820
  446. package/tsconfig.json +7 -2
  447. package/dist/plugin/assertServerCondition.d.ts +0 -6
  448. package/dist/plugin/assertServerCondition.d.ts.map +0 -1
  449. package/dist/plugin/assertServerCondition.js +0 -13
  450. package/dist/plugin/checkFilesExist.d.ts +0 -3
  451. package/dist/plugin/checkFilesExist.d.ts.map +0 -1
  452. package/dist/plugin/checkFilesExist.js +0 -67
  453. package/dist/plugin/checkFilesExist.js.map +0 -1
  454. package/dist/plugin/collect-manifest-client-files.d.ts +0 -23
  455. package/dist/plugin/collect-manifest-client-files.d.ts.map +0 -1
  456. package/dist/plugin/collect-manifest-client-files.js +0 -131
  457. package/dist/plugin/collect-manifest-client-files.js.map +0 -1
  458. package/dist/plugin/config/getWorkerPath.d.ts +0 -2
  459. package/dist/plugin/config/getWorkerPath.d.ts.map +0 -1
  460. package/dist/plugin/config/getWorkerPath.js +0 -4
  461. package/dist/plugin/copy-dir.d.ts +0 -4
  462. package/dist/plugin/copy-dir.d.ts.map +0 -1
  463. package/dist/plugin/copy-dir.js +0 -25
  464. package/dist/plugin/copy-dir.js.map +0 -1
  465. package/dist/plugin/css-collector-inline.d.ts +0 -10
  466. package/dist/plugin/css-collector-inline.d.ts.map +0 -1
  467. package/dist/plugin/css-collector-inline.js +0 -55
  468. package/dist/plugin/css-collector-inline.js.map +0 -1
  469. package/dist/plugin/loader/css-loader.d.ts +0 -16
  470. package/dist/plugin/loader/css-loader.d.ts.map +0 -1
  471. package/dist/plugin/loader/css-loader.js +0 -70
  472. package/dist/plugin/loader/css-loader.js.map +0 -1
  473. package/dist/plugin/react-client/index.js.map +0 -1
  474. package/dist/plugin/react-server/index.js.map +0 -1
  475. package/dist/plugin/worker/html/renderPages.d.ts +0 -26
  476. package/dist/plugin/worker/html/renderPages.d.ts.map +0 -1
  477. package/dist/plugin/worker/html/renderPages.js +0 -241
  478. package/dist/plugin/worker/html/renderPages.js.map +0 -1
  479. package/plugin/assertServerCondition.ts +0 -12
  480. package/plugin/checkFilesExist.ts +0 -66
  481. package/plugin/collect-manifest-client-files.ts +0 -167
  482. package/plugin/config/getWorkerPath.ts +0 -5
  483. package/plugin/copy-dir.ts +0 -27
  484. package/plugin/css-collector-inline.tsx +0 -60
  485. package/plugin/helpers/createRscStream.ts +0 -109
  486. package/plugin/loader/css-loader.ts +0 -94
  487. package/plugin/worker/html/messageHandler.ts +0 -130
  488. package/plugin/worker/html/renderPages.ts +0 -293
  489. package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +0 -159
  490. package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +0 -12508
package/plugin/types.ts CHANGED
@@ -1,4 +1,8 @@
1
- import type { PreRenderedChunk } from "rollup";
1
+ import type {
2
+ NormalizedOutputOptions,
3
+ OutputBundle,
4
+ PreRenderedChunk,
5
+ } from "rollup";
2
6
  import type { PreRenderedAsset } from "rollup";
3
7
  import type {
4
8
  UserConfig,
@@ -7,14 +11,91 @@ import type {
7
11
  AliasOptions,
8
12
  Connect,
9
13
  ResolveOptions,
14
+ Manifest,
15
+ Logger,
10
16
  } from "vite";
11
- import type { PipeableStreamOptions } from "./worker/types.js";
17
+ import type { ReactServerDomEsmOptions } from "./worker/types.js";
18
+ import type React from "react";
19
+ import type { PassThrough, Transform } from "stream";
20
+ import type { MessagePort } from "node:worker_threads";
21
+ import type { PropsWithChildren } from "react";
22
+ import { Readable } from "node:stream";
23
+
24
+ export type OnEvent = (event: PluginEvent) => void;
25
+
26
+ export type Serializable =
27
+ | string
28
+ | number
29
+ | boolean
30
+ | null
31
+ | undefined
32
+ | Serializable[]
33
+ | SerializableRecord;
34
+ export type SerializableRecord = {
35
+ [key: string]: Serializable | SerializableRecord;
36
+ };
37
+
38
+ // Track HMR state
39
+ export type HmrState = {
40
+ timestamp: number;
41
+ invalidated: boolean;
42
+ routes: string[];
43
+ };
44
+
45
+ export type RenderPageResult =
46
+ | {
47
+ type: "skip";
48
+ }
49
+ | {
50
+ type: "error";
51
+ error: Error;
52
+ }
53
+ | {
54
+ type: "success";
55
+ html: PassThrough;
56
+ rsc: PassThrough;
57
+ metrics: {
58
+ rscFull: StreamMetrics;
59
+ rscHeadless: StreamMetrics;
60
+ };
61
+ };
62
+
63
+ export type AutoDiscoveredFiles = ResolvedBuildPages & {
64
+ workerPaths: Record<string, string>;
65
+ serverEntry: Record<string, string> | null;
66
+ clientEntry: Record<string, string>;
67
+ inputs: Record<string, string>;
68
+ staticManifest: Manifest;
69
+ };
70
+ export type FileWriterOptions = Pick<
71
+ CreateHandlerOptions,
72
+ "onEvent" | "route" | "build"
73
+ >;
12
74
 
13
75
  // Input can be a string path, React component, tuple, or array
14
76
  export type NormalizerInput = unknown;
15
77
 
16
78
  export type InputNormalizer = (input: NormalizerInput) => [string, string];
17
79
 
80
+ export interface HtmlContent {
81
+ raw: string;
82
+ transformed?: string;
83
+ assets?: string[];
84
+ }
85
+
86
+ export interface PartialPageData {
87
+ route: string;
88
+ html?: {
89
+ raw: string;
90
+ transformed?: string;
91
+ assets?: string[];
92
+ };
93
+ rsc?: {
94
+ modules: any[];
95
+ content: string;
96
+ };
97
+ }
98
+
18
99
  export type InputNormalizerWorker = (
19
100
  input: NormalizerInput
20
101
  ) => Promise<[string, string]>;
@@ -23,7 +104,7 @@ export type ResolvedUserConfig = Required<
23
104
  Pick<UserConfig, "root" | "mode" | "build" | "resolve">
24
105
  > &
25
106
  Omit<UserConfig, "root" | "mode" | "build" | "resolve"> & {
26
- resolve: ResolveOptions;
107
+ resolve: ResolveOptions;
27
108
  } & {
28
109
  build: NonNullable<
29
110
  Required<
@@ -52,6 +133,10 @@ export type ResolvedUserConfig = Required<
52
133
  >;
53
134
  };
54
135
 
136
+ export type SerializedUserConfig = Extract<
137
+ ResolvedUserConfig,
138
+ SerializableRecord
139
+ >;
55
140
  // Client plugin options
56
141
  export interface StreamPluginOptionsClient {
57
142
  outDir?: string;
@@ -65,33 +150,42 @@ export interface StreamPluginOptionsClient {
65
150
  cssFiles?: AliasOptions;
66
151
  }
67
152
 
68
- export type ResolvedUserOptions<InlineCSS extends boolean = boolean> = Required<
153
+ export type ResolvedUserOptions<
154
+ InlineCSS extends boolean | undefined = boolean | undefined
155
+ > = Required<
69
156
  Pick<
70
157
  StreamPluginOptions,
71
158
  | "moduleBase"
72
159
  | "moduleBasePath"
73
160
  | "moduleBaseURL"
161
+ | "moduleRootPath"
74
162
  | "projectRoot"
75
163
  | "build"
76
164
  | "Page"
77
- | "props"
78
165
  | "Html"
79
166
  | "CssCollector"
80
167
  | "pageExportName"
81
168
  | "propsExportName"
82
- | "collectCss"
83
- | "collectAssets"
84
- | "inlineCss"
85
169
  | "htmlWorkerPath"
86
170
  | "rscWorkerPath"
87
171
  | "loaderPath"
88
172
  | "clientEntry"
89
173
  | "serverEntry"
90
174
  | "moduleBaseExceptions"
91
- | "pipableStreamOptions"
175
+ | "pipeableStreamOptions"
176
+ | "onMetrics"
177
+ | "onEvent"
178
+ | "css"
179
+ | "normalizer"
92
180
  >
93
181
  > & {
182
+ props:
183
+ | undefined
184
+ | string
185
+ | ((url: string) => string)
186
+ | ((url: string) => Promise<string>);
94
187
  build: NonNullable<Required<StreamPluginOptions<InlineCSS>["build"]>>;
188
+ css: NonNullable<Required<StreamPluginOptions<InlineCSS>["css"]>>;
95
189
  autoDiscover: {
96
190
  modulePattern: (path: string) => boolean;
97
191
  cssPattern: (path: string) => boolean;
@@ -99,9 +193,14 @@ export type ResolvedUserOptions<InlineCSS extends boolean = boolean> = Required<
99
193
  clientComponents: (path: string) => boolean;
100
194
  propsPattern: (path: string) => boolean;
101
195
  pagePattern: (path: string) => boolean;
196
+ htmlPattern: (path: string) => boolean;
197
+ rscPattern: (path: string) => boolean;
102
198
  serverFunctions: (path: string) => boolean;
103
199
  cssModulePattern: (path: string) => boolean;
104
200
  vendorPattern: (path: string) => boolean;
201
+ nodeOnly: (path: string) => boolean;
202
+ dotFiles: (path: string) => boolean;
203
+ virtualPattern: (path: string) => boolean;
105
204
  };
106
205
  };
107
206
 
@@ -118,16 +217,141 @@ export type createBuildConfigFn<C extends "react-client" | "react-server"> =
118
217
  ? Promise<InlineConfig>
119
218
  : Promise<InlineConfig>;
120
219
 
121
- export interface StreamPluginOptions<InlineCSS extends boolean = boolean> {
220
+ export interface StreamMetrics {
221
+ chunks: number;
222
+ bytes: number;
223
+ backpressureCount: number;
224
+ drainCount: number;
225
+ errorCount: number;
226
+ duration: number;
227
+ startTime: number;
228
+ }
229
+
230
+ export interface RenderMetrics {
231
+ route: string;
232
+ htmlSize: number;
233
+ rscSize: number;
234
+ processingTime: number;
235
+ chunks: number;
236
+ chunkRate: number;
237
+ memoryUsage: NodeJS.MemoryUsage;
238
+ streamMetrics: StreamMetrics;
239
+ htmlSizes: Map<string, number>;
240
+ rscSizes: Map<string, number>;
241
+ }
242
+
243
+ export interface CssCollectorOptions {
244
+ inlineCss?: boolean;
245
+ purgeCss?: boolean;
246
+ inlineThreshold?: number;
247
+ inlinePatterns?: RegExp[];
248
+ linkPatterns?: RegExp[];
249
+ }
250
+
251
+ export type FileWriteEvent = {
252
+ type: "file.write";
253
+ data: {
254
+ path: string;
255
+ fileType: "html" | "rsc";
256
+ route: string;
257
+ stream: Readable;
258
+ onComplete: () => Promise<void>;
259
+ };
260
+ };
261
+
262
+ export type FileWriteDoneEvent = {
263
+ type: "file.write.done";
264
+ data: {
265
+ route: string;
266
+ fileType: "html" | "rsc";
267
+ content: string;
268
+ };
269
+ };
270
+
271
+ export type RouteProcessEvent = {
272
+ type: "route.process";
273
+ data: {
274
+ route: string;
275
+ pagePath: string;
276
+ propsPath?: string | undefined;
277
+ };
278
+ };
279
+
280
+ export type RouteErrorEvent = {
281
+ type: "route.error";
282
+ data: {
283
+ route: string;
284
+ error: any;
285
+ };
286
+ };
287
+
288
+ export type RoutePostponeEvent = {
289
+ type: "route.postpone";
290
+ data: {
291
+ route: string;
292
+ reason: string;
293
+ };
294
+ };
295
+
296
+ export type PropsLoadEvent = {
297
+ type: "props.load";
298
+ data: {
299
+ route: string;
300
+ propsPath: string;
301
+ props: any;
302
+ };
303
+ };
304
+
305
+ export type CssProcessEvent = {
306
+ type: "css.process";
307
+ data: CssContent;
308
+ };
309
+
310
+ export type BuildStartEvent = {
311
+ type: "build.start";
312
+ data: {
313
+ pages: string[];
314
+ files: AutoDiscoveredFiles;
315
+ };
316
+ };
317
+
318
+ export type BuildWriteBundleEvent = {
319
+ type: "build.writeBundle";
320
+ data: {
321
+ pages: string[];
322
+ options: NormalizedOutputOptions;
323
+ bundle: OutputBundle;
324
+ manifest: Manifest | undefined;
325
+ };
326
+ };
327
+
328
+ export type PluginEvent =
329
+ | FileWriteEvent
330
+ | FileWriteDoneEvent
331
+ | RouteProcessEvent
332
+ | RouteErrorEvent
333
+ | RoutePostponeEvent
334
+ | PropsLoadEvent
335
+ | CssProcessEvent
336
+ | BuildStartEvent
337
+ | BuildWriteBundleEvent;
338
+
339
+ export type PluginEventType = PluginEvent["type"];
340
+
341
+ export interface StreamPluginOptions<
342
+ InlineCSS extends boolean | undefined = boolean | undefined
343
+ > {
122
344
  projectRoot?: string;
123
345
  moduleBase: string;
124
346
  moduleBasePath?: string;
125
347
  moduleBaseURL?: string;
348
+ moduleRootPath?: string;
126
349
  clientEntry?: string;
127
350
  serverEntry?: string;
128
351
  // Auto-discovery (zero-config)
129
352
  autoDiscover?:
130
353
  | {
354
+ moduleExtension?: RegExp;
131
355
  // default: /\.(m|c)?(j|t)sx?$/
132
356
  modulePattern?: string | RegExp | ((path: string) => boolean);
133
357
  // default: [Pp]age.tsx
@@ -148,56 +372,107 @@ export interface StreamPluginOptions<InlineCSS extends boolean = boolean> {
148
372
  cssModulePattern?: string | RegExp | ((path: string) => boolean);
149
373
  // default: /node_modules|(_virtual)/
150
374
  vendorPattern?: string | RegExp | ((path: string) => boolean);
375
+ // default: /\.node\.js$/
376
+ nodeOnly?: string | RegExp | ((path: string) => boolean);
377
+ // default: /\.node\.js$/
378
+ dotFiles?: string | RegExp | ((path: string) => boolean);
379
+ // default: /^\/_virtual\//
380
+ virtualPattern?: string | RegExp | ((path: string) => boolean);
381
+ // default: /\.rsc$/
382
+ rscPattern?: string | RegExp | ((path: string) => boolean);
151
383
  }
152
384
  | undefined;
153
385
  // Manual configuration
154
- Page: string | ((url: string) => string);
155
- props?: undefined | string | ((url: string) => string);
386
+ Page: string | ((url: string) => string) | ((url: string) => Promise<string>);
387
+ props?:
388
+ | undefined
389
+ | string
390
+ | ((url: string) => string)
391
+ | ((url: string) => Promise<string>);
156
392
  // Escape hatches
157
393
  htmlWorkerPath?: string;
158
394
  rscWorkerPath?: string;
159
395
  loaderPath?: string;
160
396
  pageExportName?: string;
161
397
  propsExportName?: string;
162
- Html?: React.FC<{
163
- manifest: import("vite").Manifest;
164
- pageProps: any;
165
- route: string;
166
- url: string;
167
- children: React.ReactNode;
168
- }>;
169
- CssCollector?: InlineCSS extends true ? React.FC<React.PropsWithChildren<InlineCssCollectorProps>> : React.FC<React.PropsWithChildren<CssCollectorProps>>;
170
- collectCss?: boolean;
171
- collectAssets?: boolean;
172
- inlineCss?: InlineCSS;
398
+ Html?: React.FC<PropsWithChildren<HtmlProps>>;
399
+ CssCollector?: React.FC<
400
+ React.PropsWithChildren<CssCollectorProps<InlineCSS>>
401
+ >;
173
402
  build?: BuildConfig;
403
+ css?: CssCollectorOptions;
174
404
  moduleBaseExceptions?: string[];
175
- pipableStreamOptions?: PipeableStreamOptions;
405
+ pipeableStreamOptions?: ReactServerDomEsmOptions;
406
+ onMetrics?: (metrics: RenderMetrics) => void;
407
+ onEvent?: (event: PluginEvent) => void;
408
+ normalizer?: InputNormalizer;
176
409
  }
177
410
 
178
- export interface CreateHandlerOptions<T = any, InlineCSS extends boolean = boolean> {
179
- root: string;
180
- url: string;
181
- route: string;
182
- getCss: (id: string) => Promise<Map<string, string | CssContent>> | Map<string, string | CssContent>;
183
- loader: (id: string) => Promise<T>;
184
- Html: NonNullable<StreamPluginOptions['Html']>
185
- CssCollector: InlineCSS extends true ? React.FC<React.PropsWithChildren<InlineCssCollectorProps>> : React.FC<React.PropsWithChildren<CssCollectorProps>>;
186
- inlineCss: InlineCSS;
411
+ export type MultiPageHandlerOptions = Omit<
412
+ CreateHandlerOptions,
413
+ | "pagePath"
414
+ | "route"
415
+ | "cssFiles"
416
+ | "propsPath"
417
+ | "pageProps"
418
+ | "PageComponent"
419
+ >;
420
+
421
+ export type CreateHandlerOptions<
422
+ T = unknown,
423
+ C extends React.ComponentType<T> = React.ComponentType<T>,
424
+ InlineCSS extends boolean | undefined = undefined
425
+ > = Pick<
426
+ ResolvedUserOptions<InlineCSS>,
427
+ | "autoDiscover"
428
+ | "css"
429
+ | "pageExportName"
430
+ | "propsExportName"
431
+ | "Html"
432
+ | "CssCollector"
433
+ | "moduleBase"
434
+ | "moduleRootPath"
435
+ | "moduleBasePath"
436
+ | "moduleBaseURL"
437
+ | "pipeableStreamOptions"
438
+ | "onEvent"
439
+ | "onMetrics"
440
+ | "projectRoot"
441
+ > & {
442
+ logger: Logger;
443
+ loader: ModuleLoader;
444
+ pagePath: string;
187
445
  propsPath?: string;
188
- pagePath?: string;
189
- pageExportName: string
190
- propsExportName: string
191
- moduleBase: string
192
- preserveModulesRoot?: boolean | undefined
193
- moduleBasePath: string;
194
- moduleRootPath: string;
195
- moduleBaseURL: string;
196
- cssFiles: (string | CssContent)[];
197
- cssModules?: Map<string, string | CssContent> | undefined;
198
- onCssFile?: (path: string, parentUrl: string) => void;
199
- logger: import("vite").Logger;
200
- pipableStreamOptions: PipeableStreamOptions;
446
+ pageProps?: T;
447
+ PageComponent?: C;
448
+ route: string;
449
+ manifest: Manifest;
450
+ worker?: any;
451
+ importedCss?: Set<string>;
452
+ cssFiles: Map<string, CssContent>;
453
+ globalCss: Map<string, CssContent>;
454
+ build: Pick<
455
+ ResolvedUserOptions["build"],
456
+ | "outDir"
457
+ | "pages"
458
+ | "server"
459
+ | "static"
460
+ | "client"
461
+ | "rscOutputPath"
462
+ | "htmlOutputPath"
463
+ >;
464
+ };
465
+
466
+ export interface ResolvePageOptions {
467
+ pagePath: string;
468
+ pageExportName: string;
469
+ url: string;
470
+ }
471
+
472
+ export interface ResolvePropsOptions {
473
+ propsPath: string;
474
+ propsExportName: string;
475
+ url: string;
201
476
  }
202
477
 
203
478
  export type ModuleLoader = (
@@ -225,19 +500,6 @@ export type StreamResult =
225
500
  | { type: "error"; error: unknown }
226
501
  | { type: "skip" };
227
502
 
228
- export interface RscStreamOptions {
229
- Page: React.ComponentType;
230
- props: any;
231
- Html: any;
232
- logger?: Console | import("vite").Logger;
233
- cssFiles?: string[];
234
- htmlProps: any;
235
- route: string;
236
- url: string;
237
- pipableStreamOptions?: PipeableStreamOptions;
238
- moduleBasePath: string;
239
- }
240
-
241
503
  export interface RouteConfig {
242
504
  path: string;
243
505
  // Define page/props paths using patterns
@@ -268,9 +530,11 @@ export interface BuildConfig {
268
530
  outDir?: string;
269
531
  hash?: string;
270
532
  preserveModulesRoot?: boolean;
271
- entryFile?: (n: PreRenderedChunk) => string;
272
- chunkFile?: (n: PreRenderedChunk) => string;
273
- assetFile?: (n: PreRenderedAsset) => string;
533
+ rscOutputPath?: string; // defaults: `index.rsc`
534
+ htmlOutputPath?: string; // defaults: `index.html`
535
+ entryFile?: (n: PreRenderedChunk, ssr: boolean) => string;
536
+ chunkFile?: (n: PreRenderedChunk, ssr: boolean) => string;
537
+ assetFile?: (n: PreRenderedAsset, ssr: boolean) => string;
274
538
  }
275
539
 
276
540
  export interface RscResolver {
@@ -343,16 +607,17 @@ export interface BuildTiming {
343
607
  buildEnd?: number;
344
608
  renderStart?: number;
345
609
  renderEnd?: number;
610
+ closeBundle?: number;
611
+ render?: number;
346
612
  total?: number;
347
613
  }
348
614
 
349
- export type CheckFilesExistReturn = {
615
+ export type ResolvedBuildPages = {
350
616
  propsMap: Map<string, string>;
351
- propsSet: Set<string>;
352
617
  pageMap: Map<string, string>;
353
- pageSet: Set<string>;
354
- urlMap: Map<string, {props: string, page: string}>;
355
- errors: string[];
618
+ routeMap: Map<string, string[]>;
619
+ urlMap: Map<string, { props?: string; page: string }>;
620
+ errors: Error[];
356
621
  };
357
622
 
358
623
  // Add strict type checking for worker messages
@@ -361,7 +626,11 @@ export type WorkerMessage =
361
626
  | { type: "ERROR"; error: string | Error }
362
627
  | { type: "RSC_CHUNK"; id: string; chunk: Buffer }
363
628
  | { type: "RSC_END"; id: string }
364
- | { type: "SHUTDOWN" };
629
+ | { type: "SHUTDOWN"; id: string }
630
+ | { type: "SHUTDOWN_COMPLETE" }
631
+ | { type: "CHUNK_PROCESSED"; id: string; success: boolean }
632
+ | { type: "CHUNK_ERROR"; id: string; error: string }
633
+ | { type: "METRICS"; metrics: StreamMetrics };
365
634
 
366
635
  // Add branded types for safety
367
636
  export type ModuleId = string & { readonly __brand: unique symbol };
@@ -371,52 +640,194 @@ export type HtmlProps = {
371
640
  pageProps: any;
372
641
  route: string;
373
642
  url: string;
374
- cssFiles: string[];
643
+ projectRoot: string;
644
+ moduleBase: string;
645
+ moduleBaseURL: string;
646
+ moduleBasePath: string;
647
+ moduleRootPath: string;
648
+ cssFiles: Map<string, CssContent>;
649
+ manifest: Manifest;
650
+ CssCollector: React.FC<React.PropsWithChildren<CssCollectorProps>>;
651
+ globalCss: Map<string, CssContent>;
375
652
  };
376
653
 
377
654
  export interface PageAsset {
378
- type: 'css' | 'js';
655
+ type: "css" | "js";
379
656
  path: string;
380
657
  parentUrl: string;
381
658
  }
382
659
 
383
- export interface PageData {
384
- route: string;
385
- clientComponents?: string[];
386
- html?: {
387
- raw: string;
388
- transformed?: string;
389
- assets: PageAsset[];
390
- };
391
- rsc?: {
392
- content: string;
393
- modules: Array<[string, string]>; // [modulePath, exportName]
394
- };
395
- }
660
+ type BaseCssProps = {
661
+ as: string;
662
+ id: string;
663
+ };
664
+
665
+ type CssProps = BaseCssProps & {
666
+ as: "link";
667
+ type?: never;
668
+ children?: InlineCssProps extends false ? never : React.ReactNode;
669
+ id: string;
670
+ href: string;
671
+ rel: "stylesheet";
672
+ precedence?: string;
673
+ };
674
+ type InlineCssProps = BaseCssProps & {
675
+ as: "style";
676
+ type: "text/css";
677
+ children?: React.ReactNode;
678
+ precedence?: never;
679
+ rel?: never;
680
+ href?: never;
681
+ };
682
+
683
+ export type CssContent<InlineCSS extends boolean | undefined = undefined> =
684
+ InlineCSS extends true
685
+ ? InlineCssProps
686
+ : InlineCSS extends false
687
+ ? CssProps
688
+ : CssProps | InlineCssProps;
396
689
 
397
- export interface CssContent {
690
+ export interface JsContent {
398
691
  type?: string;
399
692
  content: string;
400
693
  key?: string;
401
694
  path: string;
695
+ id?: string;
402
696
  }
403
697
 
698
+ export type CssCollectorProps<
699
+ InlineCSS extends boolean | undefined = undefined
700
+ > = {
701
+ // to render the head tag or not
702
+ as?: React.ElementType;
703
+ children?: React.ReactNode;
704
+ /** A map containing all the css files imported by the route and their proxy values
705
+ * - when inlineCss is true, will contain the `content` property
706
+ * - when prugeCss is true, will contain the module proxy which includes a `userClasses`
707
+ * @example ```tsx
708
+ * import styles from './styles.module.css';
709
+ * export const Page = () => {
710
+ * return <div className={styles.userClass}>Hello World</div>
711
+ * }
712
+ * ```
713
+ * then the module will basically contain whatever `styles` exported here. But how does it track css class usages
714
+ * during streaming?
715
+ *
716
+ * const tags = Array.from(importedCss?.values() ?? []).map(cssFile => {
717
+ * return <link rel="stylesheet" href={cssFile.path} />
718
+ * })
719
+ * ```
720
+ *
721
+ *
722
+ * */
723
+
724
+ cssFiles?: Map<string, CssContent<InlineCSS>>;
725
+ } & React.HTMLAttributes<HTMLElement>;
726
+
404
727
  export interface InlineCssCollectorProps {
405
- cssFiles: CssContent[];
406
- root: string;
728
+ cssFiles: Map<string, CssContent>;
407
729
  moduleBaseURL: string;
408
- moduleBasePath: string;
409
730
  moduleRootPath: string;
410
- route: string;
731
+ moduleBasePath: string;
732
+ route?: string;
733
+ purgeCss?: boolean;
411
734
  children?: React.ReactNode;
412
735
  }
413
736
 
414
- export interface CssCollectorProps {
415
- cssFiles: CssContent[];
416
- root: string;
417
- moduleBaseURL: string;
418
- moduleBasePath: string;
419
- moduleRootPath: string;
420
- route: string;
421
- children?: React.ReactNode;
422
- }
737
+ export interface HtmlRenderState {
738
+ id: string;
739
+ rscStream: PassThrough;
740
+ htmlStream: PassThrough;
741
+ progressStream: PassThrough;
742
+ errorTransform: Transform;
743
+ htmlChunks: string[];
744
+ pipeableStreamOptions: Omit<
745
+ ReactServerDomEsmOptions,
746
+ "onError" | "onPostpone"
747
+ >;
748
+ streamState: StreamMetrics;
749
+ }
750
+
751
+ export type RenderPagesResult =
752
+ | {
753
+ type: "error";
754
+ error: Error;
755
+ failedRoutes: Set<string>;
756
+ completedRoutes: Set<string>;
757
+ htmlSizes: Map<string, number>;
758
+ rscSizes: Map<string, number>;
759
+ streamMetrics: StreamMetrics;
760
+ results: Map<
761
+ string,
762
+ {
763
+ html: PassThrough;
764
+ rsc: PassThrough;
765
+ metrics: {
766
+ rscFull: StreamMetrics;
767
+ rscHeadless: StreamMetrics;
768
+ };
769
+ }
770
+ >;
771
+ }
772
+ | {
773
+ type: "success";
774
+ completedRoutes: Set<string>;
775
+ failedRoutes?: never;
776
+ htmlSizes: Map<string, number>;
777
+ rscSizes: Map<string, number>;
778
+ streamMetrics: StreamMetrics;
779
+ results: Map<
780
+ string,
781
+ {
782
+ html: PassThrough;
783
+ rsc: PassThrough;
784
+ metrics: {
785
+ rscFull: StreamMetrics;
786
+ rscHeadless: StreamMetrics;
787
+ };
788
+ }
789
+ >;
790
+ };
791
+
792
+ export type HandlerAssets = {
793
+ css: CssContent[];
794
+ js: string[];
795
+ bootstrapModules: string[];
796
+ };
797
+
798
+ export type CreateHandlerResult =
799
+ | {
800
+ type: "success";
801
+ controller: AbortController;
802
+ stream: any;
803
+ assets: {
804
+ css: CssContent[];
805
+ js: string[];
806
+ bootstrapModules: string[];
807
+ };
808
+ route: string;
809
+ metrics: StreamMetrics;
810
+ }
811
+ | { type: "error"; error: Error }
812
+ | { type: "skip" };
813
+
814
+ export type ReactStaticEvent =
815
+ | FileWriteEvent
816
+ | {
817
+ type: "build.start";
818
+ data: {
819
+ pages: string[];
820
+ files: Array<[string, { page: string; props?: string }]>;
821
+ };
822
+ };
823
+
824
+ // Define LoaderContext interface locally
825
+ export interface LoaderContext {
826
+ data?: { port?: MessagePort };
827
+ }
828
+ // Add type declaration for import.meta.cssModules
829
+ declare global {
830
+ interface ImportMeta {
831
+ cssModules?: Record<string, Record<string, string>>;
832
+ }
833
+ }