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
@@ -0,0 +1,110 @@
1
+ import { createCssProps } from "./createCssProps.js";
2
+ import { join } from "node:path";
3
+ import { readFile } from "node:fs/promises";
4
+ /**
5
+ * Recursively collects CSS files from a bundle manifest
6
+ */
7
+ async function collectCssFromModule(moduleKey, manifest, cssMap, options) {
8
+ const mod = manifest[moduleKey];
9
+ if (!mod)
10
+ return;
11
+ // Handle CSS imports
12
+ if (mod.imports) {
13
+ for (const importPath of mod.imports) {
14
+ if (importPath === moduleKey)
15
+ continue;
16
+ if (importPath) {
17
+ const cssEntry = manifest[importPath];
18
+ // Handle CSS array
19
+ if (Array.isArray(cssEntry.css)) {
20
+ for (const cssFile of cssEntry.css) {
21
+ if (cssMap.has(cssFile))
22
+ continue;
23
+ const file = join(options.projectRoot, options.build.outDir, options.build.static, cssFile);
24
+ const code = "source" in cssEntry && typeof cssEntry.source === "string"
25
+ ? cssEntry.source
26
+ : await readFile(file, "utf-8");
27
+ cssMap.set(importPath, createCssProps({
28
+ id: cssFile,
29
+ css: options.css,
30
+ code,
31
+ moduleBaseURL: options.moduleBaseURL,
32
+ moduleBasePath: options.moduleBasePath,
33
+ moduleRootPath: options.moduleRootPath,
34
+ projectRoot: options.projectRoot,
35
+ }));
36
+ }
37
+ }
38
+ }
39
+ // Recursively process non-CSS imports
40
+ await collectCssFromModule(importPath, manifest, cssMap, options);
41
+ }
42
+ }
43
+ // Handle direct CSS files
44
+ if (mod.css) {
45
+ for (const cssFile of mod.css) {
46
+ if (cssMap.has(cssFile)) {
47
+ continue;
48
+ }
49
+ try {
50
+ const file = join(options.projectRoot, options.build.outDir, options.build.server, cssFile);
51
+ const code = "code" in manifest[cssFile] &&
52
+ typeof manifest[cssFile].code === "string"
53
+ ? manifest[cssFile].code
54
+ : await readFile(file, "utf-8");
55
+ cssMap.set(moduleKey, createCssProps({
56
+ id: cssFile,
57
+ css: options.css,
58
+ code,
59
+ moduleBaseURL: options.moduleBaseURL,
60
+ moduleBasePath: options.moduleBasePath,
61
+ moduleRootPath: options.moduleRootPath,
62
+ projectRoot: options.projectRoot,
63
+ }));
64
+ }
65
+ catch {
66
+ continue;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ /**
72
+ * Collects CSS files from a bundle manifest using async generators
73
+ */
74
+ export async function collectBundleManifestCss(pages, options, _bundleManifest) {
75
+ const cssMap = new Map();
76
+ if (options.cssFiles) {
77
+ for (const [key, value] of options.cssFiles.entries()) {
78
+ if (typeof value !== "string") {
79
+ cssMap.set(key, value);
80
+ continue;
81
+ }
82
+ const file = join(options.projectRoot, options.build.outDir, options.build.server, value);
83
+ const code = options.manifest != null &&
84
+ value in options.manifest &&
85
+ "code" in options.manifest[value] &&
86
+ typeof options.manifest[value].code === "string"
87
+ ? options.manifest[value].code
88
+ : await readFile(file, "utf-8");
89
+ cssMap.set(file, createCssProps({
90
+ id: file,
91
+ code: code,
92
+ css: options.css,
93
+ moduleBaseURL: options.moduleBaseURL,
94
+ moduleBasePath: options.moduleBasePath,
95
+ moduleRootPath: options.moduleRootPath,
96
+ projectRoot: options.projectRoot,
97
+ }));
98
+ }
99
+ }
100
+ // Process page and props modules
101
+ if (typeof pages === "string") {
102
+ await collectCssFromModule(pages, options.manifest, cssMap, options);
103
+ }
104
+ else if (Array.isArray(pages)) {
105
+ for (const _id of pages) {
106
+ await collectCssFromModule(_id, options.manifest, cssMap, options);
107
+ }
108
+ }
109
+ return cssMap;
110
+ }
@@ -0,0 +1,7 @@
1
+ import type { Manifest } from "vite";
2
+ import type { ResolvedUserOptions } from "../types.js";
3
+ /**
4
+ * Collects CSS file paths from a manifest by walking through imports starting from a given file
5
+ */
6
+ export declare function collectManifestCss(manifest: Manifest, startFile: string | string[], userOptions: Pick<ResolvedUserOptions, "normalizer">): Record<string, string>;
7
+ //# sourceMappingURL=collectManifestCss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectManifestCss.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/collectManifestCss.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,WAAW,EAAE,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,GACnD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkDxB"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ function collectManifestCss(manifest, startFile, userOptions) {
7
+ const cssInputs = {};
8
+ const visited = /* @__PURE__ */ new Set();
9
+ const toVisit = Array.isArray(startFile) ? startFile : [startFile];
10
+ while (toVisit.length > 0) {
11
+ const currentFile = toVisit.pop();
12
+ if (visited.has(currentFile)) continue;
13
+ visited.add(currentFile);
14
+ const fileInfo = manifest[currentFile];
15
+ if (!fileInfo) {
16
+ continue;
17
+ }
18
+ if (fileInfo.css) {
19
+ for (const cssFile of fileInfo.css) {
20
+ const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);
21
+ cssInputs[keyNormalized] = valueNormalized;
22
+ }
23
+ }
24
+ if (fileInfo.imports) {
25
+ for (const importPath of fileInfo.imports) {
26
+ if (visited.has(importPath)) {
27
+ continue;
28
+ }
29
+ toVisit.push(importPath);
30
+ const importedFile = manifest[importPath];
31
+ if (importedFile?.css) {
32
+ for (const cssFile of importedFile.css) {
33
+ const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);
34
+ cssInputs[keyNormalized] = valueNormalized;
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ return cssInputs;
41
+ }
42
+
43
+ export { collectManifestCss };
44
+ //# sourceMappingURL=collectManifestCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectManifestCss.js","sources":["../../../plugin/helpers/collectManifestCss.ts"],"sourcesContent":["import type { Manifest } from \"vite\";\nimport type { ResolvedUserOptions } from \"../types.js\";\n\n/**\n * Collects CSS file paths from a manifest by walking through imports starting from a given file\n */\nexport function collectManifestCss(\n manifest: Manifest,\n startFile: string | string[],\n userOptions: Pick<ResolvedUserOptions, \"normalizer\">\n): Record<string, string> {\n const cssInputs: Record<string, string> = {};\n const visited = new Set<string>();\n \n // Convert startFile to array and ensure we have valid file paths\n const toVisit = Array.isArray(startFile) ? startFile : [startFile];\n\n \n while (toVisit.length > 0) {\n const currentFile = toVisit.pop()!;\n if (visited.has(currentFile)) continue;\n visited.add(currentFile);\n \n const fileInfo = manifest[currentFile];\n if (!fileInfo) {\n continue;\n }\n\n // Add CSS files from the css property\n if (fileInfo.css) {\n for (const cssFile of fileInfo.css) {\n const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);\n cssInputs[keyNormalized] = valueNormalized;\n }\n }\n\n // Add imports to visit\n if (fileInfo.imports) {\n for (const importPath of fileInfo.imports) {\n // Skip if we've already visited this import\n if (visited.has(importPath)) {\n continue;\n }\n \n // Add the import to visit\n toVisit.push(importPath);\n \n // Check if the imported file has CSS\n const importedFile = manifest[importPath];\n if (importedFile?.css) {\n for (const cssFile of importedFile.css) {\n const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);\n cssInputs[keyNormalized] = valueNormalized;\n }\n }\n }\n }\n }\n\n return cssInputs;\n} "],"names":[],"mappings":";;;;;AAMgB,SAAA,kBAAA,CACd,QACA,EAAA,SAAA,EACA,WACwB,EAAA;AACxB,EAAA,MAAM,YAAoC,EAAC;AAC3C,EAAM,MAAA,OAAA,uBAAc,GAAY,EAAA;AAGhC,EAAA,MAAM,UAAU,KAAM,CAAA,OAAA,CAAQ,SAAS,CAAI,GAAA,SAAA,GAAY,CAAC,SAAS,CAAA;AAGjE,EAAO,OAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AACzB,IAAM,MAAA,WAAA,GAAc,QAAQ,GAAI,EAAA;AAChC,IAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,WAAW,CAAG,EAAA;AAC9B,IAAA,OAAA,CAAQ,IAAI,WAAW,CAAA;AAEvB,IAAM,MAAA,QAAA,GAAW,SAAS,WAAW,CAAA;AACrC,IAAA,IAAI,CAAC,QAAU,EAAA;AACb,MAAA;AAAA;AAIF,IAAA,IAAI,SAAS,GAAK,EAAA;AAChB,MAAW,KAAA,MAAA,OAAA,IAAW,SAAS,GAAK,EAAA;AAClC,QAAA,MAAM,CAAC,aAAe,EAAA,eAAe,CAAI,GAAA,WAAA,CAAY,WAAW,OAAO,CAAA;AACvE,QAAA,SAAA,CAAU,aAAa,CAAI,GAAA,eAAA;AAAA;AAC7B;AAIF,IAAA,IAAI,SAAS,OAAS,EAAA;AACpB,MAAW,KAAA,MAAA,UAAA,IAAc,SAAS,OAAS,EAAA;AAEzC,QAAI,IAAA,OAAA,CAAQ,GAAI,CAAA,UAAU,CAAG,EAAA;AAC3B,UAAA;AAAA;AAIF,QAAA,OAAA,CAAQ,KAAK,UAAU,CAAA;AAGvB,QAAM,MAAA,YAAA,GAAe,SAAS,UAAU,CAAA;AACxC,QAAA,IAAI,cAAc,GAAK,EAAA;AACrB,UAAW,KAAA,MAAA,OAAA,IAAW,aAAa,GAAK,EAAA;AACtC,YAAA,MAAM,CAAC,aAAe,EAAA,eAAe,CAAI,GAAA,WAAA,CAAY,WAAW,OAAO,CAAA;AACvE,YAAA,SAAA,CAAU,aAAa,CAAI,GAAA,eAAA;AAAA;AAC7B;AACF;AACF;AACF;AAGF,EAAO,OAAA,SAAA;AACT;;;;"}
@@ -0,0 +1,31 @@
1
+ import type { EnvironmentModuleGraph, ModuleGraph } from "vite";
2
+ import type { CreateHandlerOptions, CssContent } from "../types.js";
3
+ type CollectViteModuleGraphCssResult = {
4
+ type: "success";
5
+ cssFiles: Map<string, CssContent>;
6
+ error?: never;
7
+ metrics: {
8
+ cssFiles: number;
9
+ processing: number;
10
+ };
11
+ } | {
12
+ type: "error";
13
+ error: Error;
14
+ cssFiles?: never;
15
+ metrics: {
16
+ cssFiles: number;
17
+ processing: number;
18
+ };
19
+ } | {
20
+ type: "skip";
21
+ cssFiles?: never;
22
+ error?: never;
23
+ metrics?: never;
24
+ };
25
+ export declare function collectViteModuleGraphCss<InlineCSS extends boolean | undefined = undefined>({ moduleGraph, pagePath, onCss, loader, parentUrl, moduleBaseURL, moduleBasePath, moduleRootPath, projectRoot, css, }: Pick<CreateHandlerOptions<InlineCSS>, "pagePath" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "projectRoot" | "css" | "loader"> & {
26
+ moduleGraph: ModuleGraph | EnvironmentModuleGraph;
27
+ onCss?: (cssContent: CssContent, parentUrl: string) => void;
28
+ parentUrl?: string;
29
+ }): Promise<CollectViteModuleGraphCssResult>;
30
+ export {};
31
+ //# sourceMappingURL=collectViteModuleGraphCss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectViteModuleGraphCss.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/collectViteModuleGraphCss.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGpE,KAAK,+BAA+B,GAChC;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEN,wBAAsB,yBAAyB,CAC7C,SAAS,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EACjD,EACA,WAAW,EACX,QAAQ,EACR,KAAK,EACL,MAAM,EACN,SAAS,EACT,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,GAAG,GACJ,EAAE,IAAI,CACL,oBAAoB,CAAC,SAAS,CAAC,EAC7B,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,GACb,KAAK,GACL,QAAQ,CACX,GAAG;IACF,WAAW,EAAE,WAAW,GAAG,sBAAsB,CAAC;IAClD,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAqG3C"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ import { createCssProps } from './createCssProps.js';
7
+
8
+ async function collectViteModuleGraphCss({
9
+ moduleGraph,
10
+ pagePath,
11
+ onCss,
12
+ loader,
13
+ parentUrl,
14
+ moduleBaseURL,
15
+ moduleBasePath,
16
+ moduleRootPath,
17
+ projectRoot,
18
+ css
19
+ }) {
20
+ if (!pagePath) return { type: "skip" };
21
+ const cssFiles = /* @__PURE__ */ new Map();
22
+ const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);
23
+ if (!pageModule) {
24
+ return { type: "skip" };
25
+ }
26
+ const seen = /* @__PURE__ */ new Set();
27
+ const processing = /* @__PURE__ */ new Set();
28
+ const walkModule = async (mod) => {
29
+ if (!mod?.id) {
30
+ return;
31
+ }
32
+ if (seen.has(mod.id)) {
33
+ return;
34
+ }
35
+ if (processing.has(mod.id)) {
36
+ return;
37
+ }
38
+ processing.add(mod.id);
39
+ if (mod.id.endsWith(".css")) {
40
+ const string = await loader(mod.id + "?inline").then(
41
+ (m) => m?.["default"] ?? ""
42
+ );
43
+ if (typeof string !== "string") {
44
+ throw new Error(`CSS module ${mod.id}?inline did not return a string`);
45
+ } else if (string === "") {
46
+ throw new Error(`CSS module ${mod.id}?inline returned an empty string`);
47
+ }
48
+ const cssContent = createCssProps({
49
+ id: mod?.url,
50
+ code: string,
51
+ moduleBaseURL,
52
+ moduleBasePath,
53
+ moduleRootPath,
54
+ projectRoot,
55
+ css
56
+ });
57
+ cssFiles.set(mod?.url, cssContent);
58
+ onCss?.(cssContent, parentUrl ?? pagePath);
59
+ }
60
+ if (mod.importedModules) {
61
+ const importedModules = Array.from(mod.importedModules);
62
+ for (const importedMod of importedModules) {
63
+ if (typeof importedMod === "object" && importedMod != null) {
64
+ if ("id" in importedMod && importedMod.id && typeof importedMod.id === "string") {
65
+ await walkModule(importedMod);
66
+ } else {
67
+ throw new Error(
68
+ `Imported module has no id`
69
+ );
70
+ }
71
+ } else {
72
+ throw new Error(
73
+ `Imported module is not an object`
74
+ );
75
+ }
76
+ }
77
+ }
78
+ processing.delete(mod.id);
79
+ seen.add(mod.id);
80
+ };
81
+ try {
82
+ await walkModule(pageModule);
83
+ } catch (error) {
84
+ return {
85
+ type: "error",
86
+ error,
87
+ metrics: {
88
+ cssFiles: cssFiles.size,
89
+ processing: processing.size
90
+ }
91
+ };
92
+ }
93
+ return {
94
+ type: "success",
95
+ cssFiles,
96
+ metrics: {
97
+ cssFiles: cssFiles.size,
98
+ processing: processing.size
99
+ }
100
+ };
101
+ }
102
+
103
+ export { collectViteModuleGraphCss };
104
+ //# sourceMappingURL=collectViteModuleGraphCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectViteModuleGraphCss.js","sources":["../../../plugin/helpers/collectViteModuleGraphCss.ts"],"sourcesContent":["import type { EnvironmentModuleGraph, ModuleGraph } from \"vite\";\nimport type { CreateHandlerOptions, CssContent } from \"../types.js\";\nimport { createCssProps } from \"./createCssProps.js\";\n\ntype CollectViteModuleGraphCssResult =\n | {\n type: \"success\";\n cssFiles: Map<string, CssContent>;\n error?: never;\n metrics: {\n cssFiles: number;\n processing: number;\n };\n }\n | {\n type: \"error\";\n error: Error;\n cssFiles?: never;\n metrics: {\n cssFiles: number;\n processing: number;\n };\n }\n | {\n type: \"skip\";\n cssFiles?: never;\n error?: never;\n metrics?: never;\n };\n\nexport async function collectViteModuleGraphCss<\n InlineCSS extends boolean | undefined = undefined\n>({\n moduleGraph,\n pagePath,\n onCss,\n loader,\n parentUrl,\n moduleBaseURL,\n moduleBasePath,\n moduleRootPath,\n projectRoot,\n css,\n}: Pick<\n CreateHandlerOptions<InlineCSS>,\n | \"pagePath\"\n | \"moduleBaseURL\"\n | \"moduleBasePath\"\n | \"moduleRootPath\"\n | \"projectRoot\"\n | \"css\"\n | \"loader\"\n> & {\n moduleGraph: ModuleGraph | EnvironmentModuleGraph;\n onCss?: (cssContent: CssContent, parentUrl: string) => void;\n parentUrl?: string;\n}): Promise<CollectViteModuleGraphCssResult> {\n if (!pagePath) return { type: \"skip\" };\n\n const cssFiles = new Map<string, CssContent>();\n const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);\n if (!pageModule) {\n return { type: \"skip\" };\n }\n\n const seen = new Set<string>();\n const processing = new Set<string>();\n\n const walkModule = async (mod: any) => {\n if (!mod?.id) {\n // Module has no id\n return;\n }\n\n if (seen.has(mod.id)) {\n // Already processed module\n return;\n }\n\n if (processing.has(mod.id)) {\n // Circular dependency detected for module\n return;\n }\n\n processing.add(mod.id);\n // Processing module\n if (mod.id.endsWith(\".css\")) {\n const string = await loader(mod.id + \"?inline\").then(\n (m) => m?.['default'] ?? \"\"\n );\n if (typeof string !== \"string\") {\n throw new Error(`CSS module ${mod.id}?inline did not return a string`);\n } else if (string === \"\") {\n throw new Error(`CSS module ${mod.id}?inline returned an empty string`);\n }\n const cssContent = createCssProps({\n id: mod?.url,\n code: string,\n moduleBaseURL: moduleBaseURL,\n moduleBasePath: moduleBasePath,\n moduleRootPath: moduleRootPath,\n projectRoot: projectRoot,\n css: css,\n });\n cssFiles.set(mod?.url, cssContent);\n onCss?.(cssContent, parentUrl ?? pagePath);\n }\n\n if (mod.importedModules) {\n // Processing imports for module\n const importedModules = Array.from(mod.importedModules);\n // Found imported modules\n for (const importedMod of importedModules) {\n if (typeof importedMod === \"object\" && importedMod != null) {\n if (\n \"id\" in importedMod &&\n importedMod.id &&\n typeof importedMod.id === \"string\"\n ) {\n await walkModule(importedMod);\n } else {\n throw new Error(\n `Imported module has no id`\n );\n }\n } else {\n throw new Error(\n `Imported module is not an object`\n );\n }\n }\n }\n\n processing.delete(mod.id);\n seen.add(mod.id);\n };\n\n try {\n await walkModule(pageModule);\n } catch (error) {\n return {\n type: \"error\",\n error: error as Error,\n metrics: {\n cssFiles: cssFiles.size,\n processing: processing.size,\n },\n };\n }\n return {\n type: \"success\",\n cssFiles,\n metrics: {\n cssFiles: cssFiles.size,\n processing: processing.size,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;AA8BA,eAAsB,yBAEpB,CAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAa6C,EAAA;AAC3C,EAAA,IAAI,CAAC,QAAA,EAAiB,OAAA,EAAE,MAAM,MAAO,EAAA;AAErC,EAAM,MAAA,QAAA,uBAAe,GAAwB,EAAA;AAC7C,EAAA,MAAM,UAAa,GAAA,MAAM,WAAY,CAAA,cAAA,CAAe,UAAU,IAAI,CAAA;AAClE,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAO,OAAA,EAAE,MAAM,MAAO,EAAA;AAAA;AAGxB,EAAM,MAAA,IAAA,uBAAW,GAAY,EAAA;AAC7B,EAAM,MAAA,UAAA,uBAAiB,GAAY,EAAA;AAEnC,EAAM,MAAA,UAAA,GAAa,OAAO,GAAa,KAAA;AACrC,IAAI,IAAA,CAAC,KAAK,EAAI,EAAA;AAEZ,MAAA;AAAA;AAGF,IAAA,IAAI,IAAK,CAAA,GAAA,CAAI,GAAI,CAAA,EAAE,CAAG,EAAA;AAEpB,MAAA;AAAA;AAGF,IAAA,IAAI,UAAW,CAAA,GAAA,CAAI,GAAI,CAAA,EAAE,CAAG,EAAA;AAE1B,MAAA;AAAA;AAGF,IAAW,UAAA,CAAA,GAAA,CAAI,IAAI,EAAE,CAAA;AAErB,IAAA,IAAI,GAAI,CAAA,EAAA,CAAG,QAAS,CAAA,MAAM,CAAG,EAAA;AAC3B,MAAA,MAAM,SAAS,MAAM,MAAA,CAAO,GAAI,CAAA,EAAA,GAAK,SAAS,CAAE,CAAA,IAAA;AAAA,QAC9C,CAAC,CAAA,KAAM,CAAI,GAAA,SAAS,CAAK,IAAA;AAAA,OAC3B;AACA,MAAI,IAAA,OAAO,WAAW,QAAU,EAAA;AAC9B,QAAA,MAAM,IAAI,KAAA,CAAM,CAAc,WAAA,EAAA,GAAA,CAAI,EAAE,CAAiC,+BAAA,CAAA,CAAA;AAAA,OACvE,MAAA,IAAW,WAAW,EAAI,EAAA;AACxB,QAAA,MAAM,IAAI,KAAA,CAAM,CAAc,WAAA,EAAA,GAAA,CAAI,EAAE,CAAkC,gCAAA,CAAA,CAAA;AAAA;AAExE,MAAA,MAAM,aAAa,cAAe,CAAA;AAAA,QAChC,IAAI,GAAK,EAAA,GAAA;AAAA,QACT,IAAM,EAAA,MAAA;AAAA,QACN,aAAA;AAAA,QACA,cAAA;AAAA,QACA,cAAA;AAAA,QACA,WAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAS,QAAA,CAAA,GAAA,CAAI,GAAK,EAAA,GAAA,EAAK,UAAU,CAAA;AACjC,MAAQ,KAAA,GAAA,UAAA,EAAY,aAAa,QAAQ,CAAA;AAAA;AAG3C,IAAA,IAAI,IAAI,eAAiB,EAAA;AAEvB,MAAA,MAAM,eAAkB,GAAA,KAAA,CAAM,IAAK,CAAA,GAAA,CAAI,eAAe,CAAA;AAEtD,MAAA,KAAA,MAAW,eAAe,eAAiB,EAAA;AACzC,QAAA,IAAI,OAAO,WAAA,KAAgB,QAAY,IAAA,WAAA,IAAe,IAAM,EAAA;AAC1D,UAAA,IACE,QAAQ,WACR,IAAA,WAAA,CAAY,MACZ,OAAO,WAAA,CAAY,OAAO,QAC1B,EAAA;AACA,YAAA,MAAM,WAAW,WAAW,CAAA;AAAA,WACvB,MAAA;AACL,YAAA,MAAM,IAAI,KAAA;AAAA,cACR,CAAA,yBAAA;AAAA,aACF;AAAA;AACF,SACK,MAAA;AACL,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAA,gCAAA;AAAA,WACF;AAAA;AACF;AACF;AAGF,IAAW,UAAA,CAAA,MAAA,CAAO,IAAI,EAAE,CAAA;AACxB,IAAK,IAAA,CAAA,GAAA,CAAI,IAAI,EAAE,CAAA;AAAA,GACjB;AAEA,EAAI,IAAA;AACF,IAAA,MAAM,WAAW,UAAU,CAAA;AAAA,WACpB,KAAO,EAAA;AACd,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,UAAU,QAAS,CAAA,IAAA;AAAA,QACnB,YAAY,UAAW,CAAA;AAAA;AACzB,KACF;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,SAAA;AAAA,IACN,QAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,UAAU,QAAS,CAAA,IAAA;AAAA,MACnB,YAAY,UAAW,CAAA;AAAA;AACzB,GACF;AACF;;;;"}
@@ -0,0 +1,25 @@
1
+ import type { ResolvedUserOptions, CssContent } from "../types.js";
2
+ /**
3
+ * Creates a CssContent object for a given path and css options
4
+ *
5
+ * Requirements:
6
+ * - path is a string
7
+ * - css is an object with the following properties:
8
+ * - inlineCss: boolean
9
+ * - purgeCss: boolean
10
+ * - inlineThreshold: number
11
+ * - inlinePatterns: RegExp[]
12
+ * - linkPatterns: RegExp[]
13
+ * based on the bundle, we retrieve the css content and check if it should be inlined or linked
14
+ * inlined tags get the as:style and the children are the css content
15
+ * linked tags get the as:link and the href is the path
16
+ *
17
+ * @param path - The path to the css file
18
+ * @param css - The css options
19
+ * @returns A CssContent object
20
+ */
21
+ export declare const createCssProps: ({ id, css, code, projectRoot, moduleBaseURL, moduleBasePath, moduleRootPath, }: {
22
+ id: string;
23
+ code: string;
24
+ } & Pick<ResolvedUserOptions, "css" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "projectRoot">) => CssContent;
25
+ //# sourceMappingURL=createCssProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCssProps.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createCssProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAInE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,mFAQxB;IACD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,IAAI,CACN,mBAAmB,EACnB,KAAK,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,aAAa,CAC9E,KAAG,UA+CH,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ import { relative, join } from 'node:path';
7
+ import { deserializeRegExp } from './serializeUserOptions.js';
8
+
9
+ const createCssProps = ({
10
+ id,
11
+ css,
12
+ code,
13
+ projectRoot,
14
+ moduleBaseURL,
15
+ moduleBasePath,
16
+ moduleRootPath
17
+ }) => {
18
+ let inline = typeof code === "string" && code.length > css.inlineThreshold;
19
+ const normalizedId = id.startsWith(projectRoot) ? relative(projectRoot, id) : id;
20
+ if (css.inlinePatterns?.length) {
21
+ const inlinePatterns = css.inlinePatterns?.map(
22
+ (pattern) => typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
23
+ );
24
+ if (inlinePatterns.some((pattern) => pattern.test?.(normalizedId))) {
25
+ inline = true;
26
+ }
27
+ }
28
+ if (css.linkPatterns?.length) {
29
+ const linkPatterns = css.linkPatterns?.map(
30
+ (pattern) => typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
31
+ );
32
+ if (linkPatterns.some((pattern) => pattern.test?.(normalizedId))) {
33
+ inline = false;
34
+ }
35
+ }
36
+ if (inline) {
37
+ return {
38
+ type: "text/css",
39
+ id: normalizedId,
40
+ as: "style",
41
+ children: code.trim(),
42
+ ...process.env["NODE_ENV"] !== "production" ? {
43
+ "data-vite-dev-id": join(projectRoot, moduleRootPath, normalizedId)
44
+ } : {}
45
+ };
46
+ }
47
+ return {
48
+ id: normalizedId,
49
+ as: "link",
50
+ rel: "stylesheet",
51
+ href: join(moduleBaseURL, moduleBasePath, normalizedId),
52
+ precedence: "high"
53
+ };
54
+ };
55
+
56
+ export { createCssProps };
57
+ //# sourceMappingURL=createCssProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createCssProps.js","sources":["../../../plugin/helpers/createCssProps.tsx"],"sourcesContent":["import type { ResolvedUserOptions, CssContent } from \"../types.js\";\nimport { join, relative } from \"node:path\";\nimport { deserializeRegExp } from \"./serializeUserOptions.js\";\n\n/**\n * Creates a CssContent object for a given path and css options\n *\n * Requirements:\n * - path is a string\n * - css is an object with the following properties:\n * - inlineCss: boolean\n * - purgeCss: boolean\n * - inlineThreshold: number\n * - inlinePatterns: RegExp[]\n * - linkPatterns: RegExp[]\n * based on the bundle, we retrieve the css content and check if it should be inlined or linked\n * inlined tags get the as:style and the children are the css content\n * linked tags get the as:link and the href is the path\n *\n * @param path - The path to the css file\n * @param css - The css options\n * @returns A CssContent object\n */\nexport const createCssProps = ({\n id,\n css,\n code,\n projectRoot,\n moduleBaseURL,\n moduleBasePath,\n moduleRootPath,\n}: {\n id: string;\n code: string;\n} & Pick<\n ResolvedUserOptions,\n \"css\" | \"moduleBaseURL\" | \"moduleBasePath\" | \"moduleRootPath\" | \"projectRoot\"\n>): CssContent => {\n // If we don't have a bundle entry, create a linked CSS file\n let inline = typeof code === \"string\" && code.length > css.inlineThreshold;\n // Normalize the ID to be relative to src/\n const normalizedId = id.startsWith(projectRoot)\n ? relative(projectRoot, id)\n : id;\n\n if (css.inlinePatterns?.length) {\n // Deserialize RegExp patterns if they exist\n const inlinePatterns = css.inlinePatterns?.map((pattern) =>\n typeof pattern === \"string\" ? deserializeRegExp(pattern) : pattern\n );\n if (inlinePatterns.some((pattern) => pattern.test?.(normalizedId))) {\n inline = true;\n }\n }\n if (css.linkPatterns?.length) {\n const linkPatterns = css.linkPatterns?.map((pattern) =>\n typeof pattern === \"string\" ? deserializeRegExp(pattern) : pattern\n );\n if (linkPatterns.some((pattern) => pattern.test?.(normalizedId))) {\n inline = false;\n }\n }\n if (inline) {\n return {\n type: \"text/css\",\n id: normalizedId,\n as: \"style\",\n children: code.trim(),\n ...(process.env[\"NODE_ENV\"] !== \"production\"\n ? {\n \"data-vite-dev-id\": join(projectRoot, moduleRootPath, normalizedId),\n }\n : {}),\n } as CssContent<true>;\n }\n\n // Default case\n return {\n id: normalizedId,\n as: \"link\",\n rel: \"stylesheet\",\n href: join(moduleBaseURL, moduleBasePath, normalizedId),\n precedence: \"high\",\n } as CssContent<false>;\n};\n"],"names":[],"mappings":";;;;;;;;AAuBO,MAAM,iBAAiB,CAAC;AAAA,EAC7B,EAAA;AAAA,EACA,GAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAMkB,KAAA;AAEhB,EAAA,IAAI,SAAS,OAAO,IAAA,KAAS,QAAY,IAAA,IAAA,CAAK,SAAS,GAAI,CAAA,eAAA;AAE3D,EAAM,MAAA,YAAA,GAAe,GAAG,UAAW,CAAA,WAAW,IAC1C,QAAS,CAAA,WAAA,EAAa,EAAE,CACxB,GAAA,EAAA;AAEJ,EAAI,IAAA,GAAA,CAAI,gBAAgB,MAAQ,EAAA;AAE9B,IAAM,MAAA,cAAA,GAAiB,IAAI,cAAgB,EAAA,GAAA;AAAA,MAAI,CAAC,OAC9C,KAAA,OAAO,YAAY,QAAW,GAAA,iBAAA,CAAkB,OAAO,CAAI,GAAA;AAAA,KAC7D;AACA,IAAI,IAAA,cAAA,CAAe,KAAK,CAAC,OAAA,KAAY,QAAQ,IAAO,GAAA,YAAY,CAAC,CAAG,EAAA;AAClE,MAAS,MAAA,GAAA,IAAA;AAAA;AACX;AAEF,EAAI,IAAA,GAAA,CAAI,cAAc,MAAQ,EAAA;AAC5B,IAAM,MAAA,YAAA,GAAe,IAAI,YAAc,EAAA,GAAA;AAAA,MAAI,CAAC,OAC1C,KAAA,OAAO,YAAY,QAAW,GAAA,iBAAA,CAAkB,OAAO,CAAI,GAAA;AAAA,KAC7D;AACA,IAAI,IAAA,YAAA,CAAa,KAAK,CAAC,OAAA,KAAY,QAAQ,IAAO,GAAA,YAAY,CAAC,CAAG,EAAA;AAChE,MAAS,MAAA,GAAA,KAAA;AAAA;AACX;AAEF,EAAA,IAAI,MAAQ,EAAA;AACV,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,UAAA;AAAA,MACN,EAAI,EAAA,YAAA;AAAA,MACJ,EAAI,EAAA,OAAA;AAAA,MACJ,QAAA,EAAU,KAAK,IAAK,EAAA;AAAA,MACpB,GAAI,OAAA,CAAQ,GAAI,CAAA,UAAU,MAAM,YAC5B,GAAA;AAAA,QACE,kBAAoB,EAAA,IAAA,CAAK,WAAa,EAAA,cAAA,EAAgB,YAAY;AAAA,UAEpE;AAAC,KACP;AAAA;AAIF,EAAO,OAAA;AAAA,IACL,EAAI,EAAA,YAAA;AAAA,IACJ,EAAI,EAAA,MAAA;AAAA,IACJ,GAAK,EAAA,YAAA;AAAA,IACL,IAAM,EAAA,IAAA,CAAK,aAAe,EAAA,cAAA,EAAgB,YAAY,CAAA;AAAA,IACtD,UAAY,EAAA;AAAA,GACd;AACF;;;;"}
@@ -0,0 +1,22 @@
1
+ import type { PluginEvent } from "../types.js";
2
+ /**
3
+ * Creates a unified event handler that can be used by both static and server plugins.
4
+ * This handler converts React stream events into plugin events and provides a consistent
5
+ * interface for event handling across the codebase.
6
+ *
7
+ * @param options Options for the event handler
8
+ * @returns A function that handles both React stream events and plugin events
9
+ */
10
+ export interface EventHandlerOptions {
11
+ onEvent?: (event: PluginEvent) => void | Promise<void>;
12
+ }
13
+ export declare function createEventHandler(onEvent: EventHandlerOptions['onEvent']): (event: PluginEvent) => Promise<import("../types.js").FileWriteEvent | import("../types.js").FileWriteDoneEvent | import("../types.js").RouteProcessEvent | import("../types.js").RouteErrorEvent | import("../types.js").RoutePostponeEvent | import("../types.js").PropsLoadEvent | import("../types.js").CssProcessEvent | import("../types.js").BuildStartEvent | import("../types.js").BuildWriteBundleEvent | {
14
+ type: string;
15
+ data: void;
16
+ error?: undefined;
17
+ } | {
18
+ type: string;
19
+ error: Error;
20
+ data?: undefined;
21
+ }>;
22
+ //# sourceMappingURL=createEventHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createEventHandler.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAG,mBAAmB,CAAC,SAAS,CAAC,WAChC,WAAW;;;;;;WAoB1B,KAAK;;GAQhC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ function createEventHandler(onEvent) {
7
+ return async function handleEvent(event) {
8
+ if (onEvent) {
9
+ const result = onEvent(event);
10
+ if (!result) {
11
+ return {
12
+ type: "success",
13
+ data: undefined
14
+ };
15
+ }
16
+ if (result instanceof Promise) {
17
+ try {
18
+ const awaited = await result;
19
+ return {
20
+ type: "success",
21
+ data: awaited
22
+ };
23
+ } catch (error) {
24
+ return {
25
+ type: "error",
26
+ error
27
+ };
28
+ }
29
+ }
30
+ }
31
+ return event;
32
+ };
33
+ }
34
+
35
+ export { createEventHandler };
36
+ //# sourceMappingURL=createEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createEventHandler.js","sources":["../../../plugin/helpers/createEventHandler.ts"],"sourcesContent":["import type { PluginEvent } from \"../types.js\";\n\n/**\n * Creates a unified event handler that can be used by both static and server plugins.\n * This handler converts React stream events into plugin events and provides a consistent\n * interface for event handling across the codebase.\n * \n * @param options Options for the event handler\n * @returns A function that handles both React stream events and plugin events\n */\nexport interface EventHandlerOptions {\n onEvent?: (event: PluginEvent) => void | Promise<void>;\n}\n\nexport function createEventHandler(onEvent : EventHandlerOptions['onEvent']) {\n return async function handleEvent(event: PluginEvent) {\n // Call the user's event handler if provided\n if (onEvent) {\n const result = onEvent(event);\n if (!result) {\n return {\n type: \"success\",\n data: undefined,\n };\n }\n if (result instanceof Promise) {\n try {\n const awaited = await result;\n return {\n type: \"success\",\n data: awaited,\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error as Error,\n };\n }\n }\n }\n\n return event;\n };\n} "],"names":[],"mappings":";;;;;AAcO,SAAS,mBAAmB,OAA0C,EAAA;AAC3E,EAAO,OAAA,eAAe,YAAY,KAAoB,EAAA;AAEpD,IAAA,IAAI,OAAS,EAAA;AACX,MAAM,MAAA,MAAA,GAAS,QAAQ,KAAK,CAAA;AAC5B,MAAA,IAAI,CAAC,MAAQ,EAAA;AACX,QAAO,OAAA;AAAA,UACL,IAAM,EAAA,SAAA;AAAA,UACN,IAAM,EAAA;AAAA,SACR;AAAA;AAEF,MAAA,IAAI,kBAAkB,OAAS,EAAA;AAC7B,QAAI,IAAA;AACF,UAAA,MAAM,UAAU,MAAM,MAAA;AACtB,UAAO,OAAA;AAAA,YACL,IAAM,EAAA,SAAA;AAAA,YACN,IAAM,EAAA;AAAA,WACR;AAAA,iBACO,KAAO,EAAA;AACd,UAAO,OAAA;AAAA,YACL,IAAM,EAAA,OAAA;AAAA,YACN;AAAA,WACF;AAAA;AACF;AACF;AAGF,IAAO,OAAA,KAAA;AAAA,GACT;AACF;;;;"}
@@ -1,17 +1,11 @@
1
- import type { PipeableStream } from "react-dom/server";
2
1
  import type { CreateHandlerOptions } from "../types.js";
3
- type CreateHandlerResult = {
4
- type: "success";
5
- controller: AbortController;
6
- stream: PipeableStream;
7
- assets: any;
8
- route: string;
2
+ export declare function createHandler(handlerOptions: CreateHandlerOptions): Promise<{
3
+ type: string;
4
+ stream: any;
5
+ error?: undefined;
9
6
  } | {
10
- type: "error";
7
+ type: string;
11
8
  error: Error;
12
- } | {
13
- type: "skip";
14
- };
15
- export declare function createHandler<T>({ getCss, root, cssFiles, cssModules, onCssFile, logger, loader, Html, CssCollector, pagePath, propsPath, pageExportName, propsExportName, inlineCss, moduleBase, preserveModulesRoot: _preserveModulesRoot, moduleBasePath, moduleRootPath, moduleBaseURL, route, pipableStreamOptions, }: CreateHandlerOptions<T>): Promise<CreateHandlerResult>;
16
- export {};
9
+ stream?: undefined;
10
+ }>;
17
11
  //# sourceMappingURL=createHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createHandler.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,aAAa,CAAC;AAEpE,KAAK,mBAAmB,GACpB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,eAAe,CAAC;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAOrB,wBAAsB,aAAa,CAAC,CAAC,EAAE,EACrC,MAAM,EACN,IAAI,EACJ,QAAa,EACb,UAAmD,EACnD,SAAS,EACT,MAAM,EACN,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,cAAc,EACd,eAAe,EACf,SAAS,EACT,UAAU,EACV,mBAAmB,EAAE,oBAAoB,EACzC,cAAc,EACd,cAAc,EACd,aAAa,EACb,KAAK,EACL,oBAAoB,GACrB,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA2FxD"}
1
+ {"version":3,"file":"createHandler.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIxD,wBAAsB,aAAa,CAAC,cAAc,EAAE,oBAAoB;;;;;;WA0DlD,KAAK;;GAG1B"}