vite-plugin-react-server 0.3.3 → 0.3.5

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 (488) hide show
  1. package/README.md +113 -222
  2. package/bin/patch.mjs +84 -0
  3. package/dist/_virtual/sourcemap-codec.umd.js +11 -0
  4. package/dist/_virtual/sourcemap-codec.umd.js.map +1 -0
  5. package/dist/_virtual/sourcemap-codec.umd2.js +9 -0
  6. package/dist/_virtual/sourcemap-codec.umd2.js.map +1 -0
  7. package/dist/client.d.ts +3 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +7 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/index.d.ts +6 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +32 -3
  14. package/dist/index.js.map +1 -1
  15. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +457 -0
  16. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +1 -0
  17. package/dist/node_modules/magic-string/dist/magic-string.es.js +1283 -0
  18. package/dist/node_modules/magic-string/dist/magic-string.es.js.map +1 -0
  19. package/dist/package.json +131 -0
  20. package/dist/plugin/assertServerCondition.d.ts.map +1 -0
  21. package/dist/plugin/assertServerCondition.js +15 -0
  22. package/dist/plugin/build/createClientBuildConfig.d.ts +3 -0
  23. package/dist/plugin/build/createClientBuildConfig.d.ts.map +1 -0
  24. package/dist/plugin/build/createClientBuildConfig.js +14 -0
  25. package/dist/plugin/build/createServerBuildConfig.d.ts +12 -0
  26. package/dist/plugin/build/createServerBuildConfig.d.ts.map +1 -0
  27. package/dist/plugin/build/createServerBuildConfig.js +40 -0
  28. package/dist/plugin/build/createSharedBuildConfig.d.ts +5 -0
  29. package/dist/plugin/build/createSharedBuildConfig.d.ts.map +1 -0
  30. package/dist/plugin/build/createSharedBuildConfig.js +28 -0
  31. package/dist/plugin/build/mergeInputs.d.ts +9 -0
  32. package/dist/plugin/build/mergeInputs.d.ts.map +1 -0
  33. package/dist/plugin/build/mergeInputs.js +56 -0
  34. package/dist/plugin/checkFilesExist.d.ts +3 -0
  35. package/dist/plugin/checkFilesExist.d.ts.map +1 -0
  36. package/dist/plugin/checkFilesExist.js +78 -0
  37. package/dist/plugin/checkFilesExist.js.map +1 -0
  38. package/dist/{collect-css-manifest.d.ts → plugin/collect-css-manifest.d.ts} +2 -2
  39. package/dist/plugin/collect-css-manifest.d.ts.map +1 -0
  40. package/dist/{src → plugin}/collect-css-manifest.js +8 -5
  41. package/dist/plugin/collect-css-manifest.js.map +1 -0
  42. package/dist/plugin/components.d.ts.map +1 -0
  43. package/dist/{src → plugin}/components.js +9 -4
  44. package/dist/plugin/components.js.map +1 -0
  45. package/dist/plugin/config/defaults.d.ts +51 -0
  46. package/dist/plugin/config/defaults.d.ts.map +1 -0
  47. package/dist/plugin/config/defaults.js +52 -0
  48. package/dist/plugin/config/defaults.js.map +1 -0
  49. package/dist/plugin/config/getCondition.d.ts +2 -0
  50. package/dist/plugin/config/getCondition.d.ts.map +1 -0
  51. package/dist/plugin/config/getCondition.js +11 -0
  52. package/dist/plugin/config/getCondition.js.map +1 -0
  53. package/dist/plugin/config/getPaths.d.ts +5 -0
  54. package/dist/plugin/config/getPaths.d.ts.map +1 -0
  55. package/dist/plugin/config/getPaths.js +21 -0
  56. package/dist/plugin/config/getPaths.js.map +1 -0
  57. package/dist/plugin/config/getWorkerPath.d.ts +2 -0
  58. package/dist/plugin/config/getWorkerPath.d.ts.map +1 -0
  59. package/dist/plugin/config/getWorkerPath.js +4 -0
  60. package/dist/plugin/config/index.d.ts +8 -0
  61. package/dist/plugin/config/index.d.ts.map +1 -0
  62. package/dist/plugin/config/index.js +7 -0
  63. package/dist/plugin/config/moduleIdDefault.d.ts +8 -0
  64. package/dist/plugin/config/moduleIdDefault.d.ts.map +1 -0
  65. package/dist/plugin/config/moduleIdDefault.js +23 -0
  66. package/dist/plugin/config/moduleIdDefault.js.map +1 -0
  67. package/dist/plugin/config/resolveOptions.d.ts +9 -0
  68. package/dist/plugin/config/resolveOptions.d.ts.map +1 -0
  69. package/dist/plugin/config/resolveOptions.js +56 -0
  70. package/dist/plugin/config/resolveOptions.js.map +1 -0
  71. package/dist/plugin/config/resolvePages.d.ts +9 -0
  72. package/dist/plugin/config/resolvePages.d.ts.map +1 -0
  73. package/dist/plugin/config/resolvePages.js +38 -0
  74. package/dist/plugin/config/resolvePages.js.map +1 -0
  75. package/dist/plugin/config/resolveUserConfig.d.ts +18 -0
  76. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -0
  77. package/dist/plugin/config/resolveUserConfig.js +84 -0
  78. package/dist/plugin/config/resolveUserConfig.js.map +1 -0
  79. package/dist/plugin/copy-dir.d.ts.map +1 -0
  80. package/dist/plugin/copy-dir.js +20 -0
  81. package/dist/plugin/getCondition.d.ts +2 -0
  82. package/dist/plugin/getCondition.d.ts.map +1 -0
  83. package/dist/plugin/getCondition.js +1 -0
  84. package/dist/plugin/getEnv.d.ts.map +1 -0
  85. package/dist/plugin/getEnv.js +107 -0
  86. package/dist/plugin/helpers/createClientInputNormalizer.d.ts +8 -0
  87. package/dist/plugin/helpers/createClientInputNormalizer.d.ts.map +1 -0
  88. package/dist/plugin/helpers/createClientInputNormalizer.js +35 -0
  89. package/dist/plugin/helpers/createServerInputNormalizer.d.ts +9 -0
  90. package/dist/plugin/helpers/createServerInputNormalizer.d.ts.map +1 -0
  91. package/dist/plugin/helpers/createServerInputNormalizer.js +37 -0
  92. package/dist/plugin/helpers/createStaticInputNormalizer.d.ts +7 -0
  93. package/dist/plugin/helpers/createStaticInputNormalizer.d.ts.map +1 -0
  94. package/dist/plugin/helpers/createStaticInputNormalizer.js +18 -0
  95. package/dist/plugin/helpers/getModuleManifest.d.ts +12 -0
  96. package/dist/plugin/helpers/getModuleManifest.d.ts.map +1 -0
  97. package/dist/plugin/helpers/getModuleManifest.js +24 -0
  98. package/dist/plugin/helpers/getModuleManifest.js.map +1 -0
  99. package/dist/plugin/helpers/inputNormalizer.d.ts +3 -0
  100. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -0
  101. package/dist/plugin/helpers/inputNormalizer.js +35 -0
  102. package/dist/plugin/helpers/inputNormalizer.js.map +1 -0
  103. package/dist/plugin/helpers/inputNormalizerWorker.d.ts +11 -0
  104. package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +1 -0
  105. package/dist/plugin/helpers/inputNormalizerWorker.js +30 -0
  106. package/dist/plugin/helpers/normalizedRelativePath.d.ts.map +1 -0
  107. package/dist/plugin/helpers/normalizedRelativePath.js +36 -0
  108. package/dist/plugin/helpers/resolveFilePath.d.ts +13 -0
  109. package/dist/plugin/helpers/resolveFilePath.d.ts.map +1 -0
  110. package/dist/plugin/helpers/resolveFilePath.js +74 -0
  111. package/dist/plugin/helpers/resolveWorkerModule.d.ts +6 -0
  112. package/dist/plugin/helpers/resolveWorkerModule.d.ts.map +1 -0
  113. package/dist/plugin/helpers/resolveWorkerModule.js +24 -0
  114. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -0
  115. package/dist/{src → plugin}/helpers/tryManifest.js +11 -6
  116. package/dist/plugin/helpers/tryManifest.js.map +1 -0
  117. package/dist/plugin/helpers/validateModuleBase.d.ts +3 -0
  118. package/dist/plugin/helpers/validateModuleBase.d.ts.map +1 -0
  119. package/dist/plugin/helpers/validateModuleBase.js +16 -0
  120. package/dist/plugin/helpers/validateResolvedConfig.d.ts +3 -0
  121. package/dist/plugin/helpers/validateResolvedConfig.d.ts.map +1 -0
  122. package/dist/plugin/helpers/validateResolvedConfig.js +17 -0
  123. package/dist/plugin/index.d.ts +3 -0
  124. package/dist/plugin/index.d.ts.map +1 -0
  125. package/dist/plugin/index.js +1 -0
  126. package/dist/plugin/loader/createBuildLoader.d.ts +9 -0
  127. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -0
  128. package/dist/plugin/loader/createBuildLoader.js +52 -0
  129. package/dist/plugin/loader/createBuildLoader.js.map +1 -0
  130. package/dist/plugin/loader/createCssLoader.d.ts +30 -0
  131. package/dist/plugin/loader/createCssLoader.d.ts.map +1 -0
  132. package/dist/plugin/loader/createCssLoader.js +35 -0
  133. package/dist/{html → plugin/loader}/createPageLoader.d.ts +2 -4
  134. package/dist/plugin/loader/createPageLoader.d.ts.map +1 -0
  135. package/dist/plugin/loader/createPageLoader.js +57 -0
  136. package/dist/plugin/manifest.d.ts.map +1 -0
  137. package/dist/plugin/manifest.js +13 -0
  138. package/dist/plugin/module-graph.d.ts.map +1 -0
  139. package/dist/plugin/module-graph.js +35 -0
  140. package/dist/plugin/plugin.d.ts +7 -0
  141. package/dist/plugin/plugin.d.ts.map +1 -0
  142. package/dist/plugin/plugin.js +8 -0
  143. package/dist/plugin/preserver/index.d.ts +2 -0
  144. package/dist/plugin/preserver/index.d.ts.map +1 -0
  145. package/dist/plugin/preserver/index.js +1 -0
  146. package/dist/plugin/preserver/plugin.d.ts +4 -0
  147. package/dist/plugin/preserver/plugin.d.ts.map +1 -0
  148. package/dist/plugin/preserver/plugin.js +90 -0
  149. package/dist/plugin/preserver/plugin.js.map +1 -0
  150. package/dist/plugin/react-client/index.d.ts +2 -0
  151. package/dist/plugin/react-client/index.d.ts.map +1 -0
  152. package/dist/plugin/react-client/index.js +1 -0
  153. package/dist/plugin/react-client/plugin.d.ts +4 -0
  154. package/dist/plugin/react-client/plugin.d.ts.map +1 -0
  155. package/dist/plugin/react-client/plugin.js +34 -0
  156. package/dist/plugin/react-client/plugin.js.map +1 -0
  157. package/dist/plugin/react-server/createDevMiddleware.d.ts.map +1 -0
  158. package/dist/plugin/react-server/createDevMiddleware.js +68 -0
  159. package/dist/plugin/react-server/createDevServer.d.ts.map +1 -0
  160. package/dist/plugin/react-server/createDevServer.js +4 -0
  161. package/dist/plugin/react-server/createHandler.d.ts +17 -0
  162. package/dist/plugin/react-server/createHandler.d.ts.map +1 -0
  163. package/dist/{src → plugin}/react-server/createHandler.js +28 -17
  164. package/dist/plugin/react-server/createHandler.js.map +1 -0
  165. package/dist/plugin/react-server/createReactNodeStreamer.d.ts.map +1 -0
  166. package/dist/plugin/react-server/createReactNodeStreamer.js +7 -0
  167. package/dist/{react-server → plugin/react-server}/createRscStream.d.ts +1 -1
  168. package/dist/plugin/react-server/createRscStream.d.ts.map +1 -0
  169. package/dist/{src → plugin}/react-server/createRscStream.js +14 -13
  170. package/dist/plugin/react-server/createRscStream.js.map +1 -0
  171. package/dist/{react-server → plugin/react-server}/createSsrHandler.d.ts +1 -1
  172. package/dist/plugin/react-server/createSsrHandler.d.ts.map +1 -0
  173. package/dist/plugin/react-server/createSsrHandler.js +102 -0
  174. package/dist/plugin/react-server/index.d.ts +4 -0
  175. package/dist/plugin/react-server/index.d.ts.map +1 -0
  176. package/dist/plugin/react-server/index.js +10 -0
  177. package/dist/{react-server → plugin/react-server}/plugin.d.ts +2 -2
  178. package/dist/plugin/react-server/plugin.d.ts.map +1 -0
  179. package/dist/plugin/react-server/plugin.js +375 -0
  180. package/dist/plugin/react-server/plugin.js.map +1 -0
  181. package/dist/plugin/resolvePage.d.ts.map +1 -0
  182. package/dist/{src → plugin}/resolvePage.js +8 -4
  183. package/dist/plugin/resolvePage.js.map +1 -0
  184. package/dist/plugin/resolveProps.d.ts.map +1 -0
  185. package/dist/{src → plugin}/resolveProps.js +21 -8
  186. package/dist/plugin/resolveProps.js.map +1 -0
  187. package/dist/plugin/server.d.ts +2 -0
  188. package/dist/plugin/server.d.ts.map +1 -0
  189. package/dist/plugin/server.js +1 -0
  190. package/dist/plugin/transformer/index.d.ts +2 -0
  191. package/dist/plugin/transformer/index.d.ts.map +1 -0
  192. package/dist/plugin/transformer/index.js +1 -0
  193. package/dist/{transformer/index.d.ts → plugin/transformer/plugin.d.ts} +3 -3
  194. package/dist/plugin/transformer/plugin.d.ts.map +1 -0
  195. package/dist/plugin/transformer/plugin.js +86 -0
  196. package/dist/plugin/transformer/plugin.js.map +1 -0
  197. package/dist/plugin/transformer/transformer-client-components.d.ts +21 -0
  198. package/dist/plugin/transformer/transformer-client-components.d.ts.map +1 -0
  199. package/dist/plugin/transformer/transformer-client-components.js +61 -0
  200. package/dist/plugin/transformer/transformer-client-components.js.map +1 -0
  201. package/dist/{transformer/transformer.d.ts → plugin/transformer/transformer-server-actions.d.ts} +3 -4
  202. package/dist/plugin/transformer/transformer-server-actions.d.ts.map +1 -0
  203. package/dist/plugin/transformer/transformer-server-actions.js +76 -0
  204. package/dist/plugin/transformer/transformer-server-actions.js.map +1 -0
  205. package/dist/plugin/transformer/types.d.ts.map +1 -0
  206. package/dist/plugin/transformer/types.js +1 -0
  207. package/dist/plugin/types.d.ts +225 -0
  208. package/dist/plugin/types.d.ts.map +1 -0
  209. package/dist/plugin/types.js +1 -0
  210. package/dist/plugin/worker/createWorker.d.ts +15 -0
  211. package/dist/plugin/worker/createWorker.d.ts.map +1 -0
  212. package/dist/plugin/worker/createWorker.js +71 -0
  213. package/dist/plugin/worker/createWorker.js.map +1 -0
  214. package/dist/plugin/worker/html/html-worker.d.ts +2 -0
  215. package/dist/plugin/worker/html/html-worker.d.ts.map +1 -0
  216. package/dist/plugin/worker/html/html-worker.development.d.ts +2 -0
  217. package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -0
  218. package/dist/plugin/worker/html/html-worker.development.js +12 -0
  219. package/dist/plugin/worker/html/html-worker.development.js.map +1 -0
  220. package/dist/plugin/worker/html/html-worker.js +4 -0
  221. package/dist/plugin/worker/html/html-worker.production.d.ts +2 -0
  222. package/dist/plugin/worker/html/html-worker.production.d.ts.map +1 -0
  223. package/dist/plugin/worker/html/html-worker.production.js +12 -0
  224. package/dist/plugin/worker/html/html-worker.production.js.map +1 -0
  225. package/dist/plugin/worker/html/index.d.ts +2 -0
  226. package/dist/plugin/worker/html/index.d.ts.map +1 -0
  227. package/dist/plugin/worker/html/index.js +7 -0
  228. package/dist/plugin/worker/html/index.js.map +1 -0
  229. package/dist/plugin/worker/html/messageHandler.d.ts +3 -0
  230. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -0
  231. package/dist/plugin/worker/html/messageHandler.js +98 -0
  232. package/dist/plugin/worker/html/messageHandler.js.map +1 -0
  233. package/dist/plugin/worker/html/plugin.d.ts +4 -0
  234. package/dist/plugin/worker/html/plugin.d.ts.map +1 -0
  235. package/dist/plugin/worker/html/plugin.js +89 -0
  236. package/dist/plugin/worker/html/renderPages.d.ts +38 -0
  237. package/dist/plugin/worker/html/renderPages.d.ts.map +1 -0
  238. package/dist/plugin/worker/html/renderPages.js +121 -0
  239. package/dist/plugin/worker/html/renderPages.js.map +1 -0
  240. package/dist/plugin/worker/loader.d.ts.map +1 -0
  241. package/dist/plugin/worker/loader.js +11 -0
  242. package/dist/plugin/worker/loader.js.map +1 -0
  243. package/dist/plugin/worker/plugin.d.ts +10 -0
  244. package/dist/plugin/worker/plugin.d.ts.map +1 -0
  245. package/dist/plugin/worker/plugin.js +14 -0
  246. package/dist/plugin/worker/rsc/createRscStream.d.ts +5 -0
  247. package/dist/plugin/worker/rsc/createRscStream.d.ts.map +1 -0
  248. package/dist/plugin/worker/rsc/createRscStream.js +39 -0
  249. package/dist/plugin/worker/rsc/createRscStream.js.map +1 -0
  250. package/dist/plugin/worker/rsc/development.d.ts +5 -0
  251. package/dist/plugin/worker/rsc/development.d.ts.map +1 -0
  252. package/dist/plugin/worker/rsc/development.js +13 -0
  253. package/dist/plugin/worker/rsc/development.js.map +1 -0
  254. package/dist/plugin/worker/rsc/index.d.ts +4 -0
  255. package/dist/plugin/worker/rsc/index.d.ts.map +1 -0
  256. package/dist/plugin/worker/rsc/index.js +15 -0
  257. package/dist/plugin/worker/rsc/index.js.map +1 -0
  258. package/dist/plugin/worker/rsc/plugin.d.ts +4 -0
  259. package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -0
  260. package/dist/plugin/worker/rsc/plugin.js +82 -0
  261. package/dist/plugin/worker/rsc/plugin.js.map +1 -0
  262. package/dist/plugin/worker/rsc/production.d.ts +5 -0
  263. package/dist/plugin/worker/rsc/production.d.ts.map +1 -0
  264. package/dist/plugin/worker/rsc/production.js +13 -0
  265. package/dist/plugin/worker/rsc/production.js.map +1 -0
  266. package/dist/plugin/worker/rsc/rsc-worker.d.ts +2 -0
  267. package/dist/plugin/worker/rsc/rsc-worker.d.ts.map +1 -0
  268. package/dist/plugin/worker/rsc/rsc-worker.js +106 -0
  269. package/dist/plugin/worker/types.d.ts +99 -0
  270. package/dist/plugin/worker/types.d.ts.map +1 -0
  271. package/dist/plugin/worker/types.js +1 -0
  272. package/dist/server.d.ts +4 -1
  273. package/dist/server.d.ts.map +1 -1
  274. package/dist/server.js +9 -0
  275. package/dist/server.js.map +1 -0
  276. package/dist/tsconfig.tsbuildinfo +1 -0
  277. package/dist/types.d.ts +1 -201
  278. package/dist/types.d.ts.map +1 -1
  279. package/dist/types.js +1 -0
  280. package/package.json +44 -25
  281. package/plugin/build/createClientBuildConfig.ts +21 -0
  282. package/plugin/build/createServerBuildConfig.ts +66 -0
  283. package/plugin/build/createSharedBuildConfig.ts +35 -0
  284. package/plugin/build/mergeInputs.ts +58 -0
  285. package/plugin/checkFilesExist.ts +82 -0
  286. package/{src → plugin}/collect-css-manifest.ts +4 -2
  287. package/plugin/config/defaults.ts +44 -0
  288. package/plugin/config/getCondition.ts +3 -0
  289. package/plugin/config/getPaths.ts +25 -0
  290. package/plugin/config/getWorkerPath.ts +5 -0
  291. package/plugin/config/index.ts +8 -0
  292. package/plugin/config/moduleIdDefault.ts +23 -0
  293. package/plugin/config/resolveOptions.ts +53 -0
  294. package/plugin/config/resolvePages.ts +43 -0
  295. package/plugin/config/resolveUserConfig.ts +97 -0
  296. package/{src → plugin}/getEnv.ts +1 -1
  297. package/plugin/helpers/createClientInputNormalizer.ts +48 -0
  298. package/plugin/helpers/createServerInputNormalizer.ts +52 -0
  299. package/plugin/helpers/createStaticInputNormalizer.ts +26 -0
  300. package/plugin/helpers/getModuleManifest.ts +31 -0
  301. package/plugin/helpers/inputNormalizer.ts +39 -0
  302. package/plugin/helpers/inputNormalizerWorker.ts +47 -0
  303. package/plugin/helpers/resolveFilePath.ts +108 -0
  304. package/plugin/helpers/resolveWorkerModule.ts +41 -0
  305. package/plugin/helpers/validateModuleBase.ts +30 -0
  306. package/plugin/helpers/validateResolvedConfig.ts +21 -0
  307. package/plugin/index.ts +2 -0
  308. package/plugin/loader/createBuildLoader.ts +60 -0
  309. package/plugin/loader/createCssLoader.ts +73 -0
  310. package/{src/html → plugin/loader}/createPageLoader.ts +35 -27
  311. package/plugin/plugin.ts +8 -0
  312. package/plugin/preserver/index.ts +1 -0
  313. package/plugin/preserver/plugin.ts +110 -0
  314. package/plugin/react-client/index.ts +1 -0
  315. package/plugin/react-client/plugin.ts +33 -0
  316. package/{src → plugin}/react-server/createDevMiddleware.ts +17 -1
  317. package/{src → plugin}/react-server/createDevServer.ts +0 -1
  318. package/{src → plugin}/react-server/createHandler.ts +31 -10
  319. package/{src → plugin}/react-server/createReactNodeStreamer.ts +1 -0
  320. package/{src → plugin}/react-server/createRscStream.ts +8 -12
  321. package/{src → plugin}/react-server/createSsrHandler.ts +16 -19
  322. package/plugin/react-server/index.ts +13 -0
  323. package/plugin/react-server/plugin.ts +465 -0
  324. package/{src → plugin}/resolvePage.ts +1 -1
  325. package/{src → plugin}/resolveProps.ts +15 -6
  326. package/plugin/server.tsx +0 -0
  327. package/plugin/transformer/index.ts +1 -0
  328. package/plugin/transformer/plugin.ts +131 -0
  329. package/plugin/transformer/transformer-client-components.ts +94 -0
  330. package/{src/transformer/transformer.ts → plugin/transformer/transformer-server-actions.ts} +14 -27
  331. package/{src → plugin}/types.ts +97 -55
  332. package/plugin/worker/createWorker.ts +84 -0
  333. package/plugin/worker/html/html-worker.development.tsx +8 -0
  334. package/plugin/worker/html/html-worker.production.tsx +8 -0
  335. package/plugin/worker/html/html-worker.ts +5 -0
  336. package/plugin/worker/html/index.ts +5 -0
  337. package/plugin/worker/html/messageHandler.ts +116 -0
  338. package/plugin/worker/html/plugin.ts +97 -0
  339. package/plugin/worker/html/renderPages.ts +187 -0
  340. package/plugin/worker/plugin.ts +17 -0
  341. package/plugin/worker/rsc/createRscStream.ts +42 -0
  342. package/plugin/worker/rsc/development.ts +6 -0
  343. package/plugin/worker/rsc/index.ts +14 -0
  344. package/plugin/worker/rsc/plugin.ts +83 -0
  345. package/plugin/worker/rsc/production.ts +6 -0
  346. package/plugin/worker/rsc/rsc-worker.tsx +128 -0
  347. package/plugin/worker/types.ts +124 -0
  348. package/scripts/bump-version.mjs +68 -0
  349. package/scripts/check-react-version.mjs +66 -0
  350. package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +4291 -0
  351. package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +108798 -0
  352. package/scripts/react-server-dom-esm+0.0.0-experimental-b3a95caf-20250113.patch +24775 -0
  353. package/{patches → scripts}/react-server-dom-esm+0.0.1.patch +10259 -3
  354. package/tsconfig.json +15 -13
  355. package/dist/assertServerCondition.d.ts.map +0 -1
  356. package/dist/bin/patch.js +0 -51
  357. package/dist/bin/patch.js.map +0 -1
  358. package/dist/build/createBuildConfig.d.ts +0 -13
  359. package/dist/build/createBuildConfig.d.ts.map +0 -1
  360. package/dist/build/mergeInputs.d.ts +0 -5
  361. package/dist/build/mergeInputs.d.ts.map +0 -1
  362. package/dist/checkFilesExist.d.ts +0 -8
  363. package/dist/checkFilesExist.d.ts.map +0 -1
  364. package/dist/collect-css-manifest.d.ts.map +0 -1
  365. package/dist/components.d.ts.map +0 -1
  366. package/dist/copy-dir.d.ts.map +0 -1
  367. package/dist/getEnv.d.ts.map +0 -1
  368. package/dist/helpers/inputNormalizer.d.ts +0 -6
  369. package/dist/helpers/inputNormalizer.d.ts.map +0 -1
  370. package/dist/helpers/normalizedRelativePath.d.ts.map +0 -1
  371. package/dist/helpers/tryManifest.d.ts.map +0 -1
  372. package/dist/html/createPageLoader.d.ts.map +0 -1
  373. package/dist/manifest.d.ts.map +0 -1
  374. package/dist/module-graph.d.ts.map +0 -1
  375. package/dist/options.d.ts +0 -91
  376. package/dist/options.d.ts.map +0 -1
  377. package/dist/plugin.d.ts +0 -3
  378. package/dist/plugin.d.ts.map +0 -1
  379. package/dist/react-client/plugin.d.ts +0 -4
  380. package/dist/react-client/plugin.d.ts.map +0 -1
  381. package/dist/react-client/plugin.js +0 -28
  382. package/dist/react-client/plugin.js.map +0 -1
  383. package/dist/react-server/createDevMiddleware.d.ts.map +0 -1
  384. package/dist/react-server/createDevServer.d.ts.map +0 -1
  385. package/dist/react-server/createHandler.d.ts +0 -23
  386. package/dist/react-server/createHandler.d.ts.map +0 -1
  387. package/dist/react-server/createReactNodeStreamer.d.ts.map +0 -1
  388. package/dist/react-server/createRscStream.d.ts.map +0 -1
  389. package/dist/react-server/createSsrHandler.d.ts.map +0 -1
  390. package/dist/react-server/plugin.d.ts.map +0 -1
  391. package/dist/react-server/plugin.js +0 -345
  392. package/dist/react-server/plugin.js.map +0 -1
  393. package/dist/resolvePage.d.ts.map +0 -1
  394. package/dist/resolveProps.d.ts.map +0 -1
  395. package/dist/src/build/createBuildConfig.js +0 -44
  396. package/dist/src/build/createBuildConfig.js.map +0 -1
  397. package/dist/src/build/mergeInputs.js +0 -16
  398. package/dist/src/build/mergeInputs.js.map +0 -1
  399. package/dist/src/checkFilesExist.js +0 -61
  400. package/dist/src/checkFilesExist.js.map +0 -1
  401. package/dist/src/collect-css-manifest.js.map +0 -1
  402. package/dist/src/components.js.map +0 -1
  403. package/dist/src/getEnv.js +0 -76
  404. package/dist/src/getEnv.js.map +0 -1
  405. package/dist/src/helpers/inputNormalizer.js +0 -11
  406. package/dist/src/helpers/inputNormalizer.js.map +0 -1
  407. package/dist/src/helpers/normalizedRelativePath.js +0 -34
  408. package/dist/src/helpers/normalizedRelativePath.js.map +0 -1
  409. package/dist/src/helpers/tryManifest.js.map +0 -1
  410. package/dist/src/html/createPageLoader.js +0 -72
  411. package/dist/src/html/createPageLoader.js.map +0 -1
  412. package/dist/src/options.js +0 -307
  413. package/dist/src/options.js.map +0 -1
  414. package/dist/src/react-server/createHandler.js.map +0 -1
  415. package/dist/src/react-server/createRscStream.js.map +0 -1
  416. package/dist/src/resolvePage.js.map +0 -1
  417. package/dist/src/resolveProps.js.map +0 -1
  418. package/dist/src/worker/createHtmlStream.js +0 -62
  419. package/dist/src/worker/createHtmlStream.js.map +0 -1
  420. package/dist/src/worker/createWorker.js +0 -34
  421. package/dist/src/worker/createWorker.js.map +0 -1
  422. package/dist/src/worker/renderPages.js +0 -99
  423. package/dist/src/worker/renderPages.js.map +0 -1
  424. package/dist/transformer/index.d.ts.map +0 -1
  425. package/dist/transformer/preserveDirectives.d.ts +0 -4
  426. package/dist/transformer/preserveDirectives.d.ts.map +0 -1
  427. package/dist/transformer/preserver.d.ts +0 -2
  428. package/dist/transformer/preserver.d.ts.map +0 -1
  429. package/dist/transformer/transformer.d.ts.map +0 -1
  430. package/dist/transformer/types.d.ts.map +0 -1
  431. package/dist/worker/createHtmlStream.d.ts +0 -7
  432. package/dist/worker/createHtmlStream.d.ts.map +0 -1
  433. package/dist/worker/createWorker.d.ts +0 -10
  434. package/dist/worker/createWorker.d.ts.map +0 -1
  435. package/dist/worker/loader.d.ts.map +0 -1
  436. package/dist/worker/loader.js +0 -7
  437. package/dist/worker/loader.js.map +0 -1
  438. package/dist/worker/renderPages.d.ts +0 -18
  439. package/dist/worker/renderPages.d.ts.map +0 -1
  440. package/dist/worker/types.d.ts +0 -31
  441. package/dist/worker/types.d.ts.map +0 -1
  442. package/dist/worker/worker.d.ts +0 -7
  443. package/dist/worker/worker.d.ts.map +0 -1
  444. package/dist/worker/worker.js +0 -112
  445. package/dist/worker/worker.js.map +0 -1
  446. package/src/build/createBuildConfig.ts +0 -57
  447. package/src/build/mergeInputs.ts +0 -42
  448. package/src/checkFilesExist.ts +0 -67
  449. package/src/helpers/inputNormalizer.ts +0 -22
  450. package/src/index.ts +0 -4
  451. package/src/options.ts +0 -423
  452. package/src/plugin.ts +0 -5
  453. package/src/react-client/plugin.ts +0 -34
  454. package/src/react-server/plugin.ts +0 -409
  455. package/src/transformer/index.ts +0 -112
  456. package/src/transformer/preserveDirectives.ts +0 -100
  457. package/src/transformer/preserver.ts +0 -47
  458. package/src/worker/createHtmlStream.ts +0 -76
  459. package/src/worker/createWorker.ts +0 -44
  460. package/src/worker/renderPages.ts +0 -144
  461. package/src/worker/types.ts +0 -38
  462. package/src/worker/worker.tsx +0 -136
  463. /package/dist/{assertServerCondition.d.ts → plugin/assertServerCondition.d.ts} +0 -0
  464. /package/dist/{components.d.ts → plugin/components.d.ts} +0 -0
  465. /package/dist/{copy-dir.d.ts → plugin/copy-dir.d.ts} +0 -0
  466. /package/dist/{getEnv.d.ts → plugin/getEnv.d.ts} +0 -0
  467. /package/dist/{helpers → plugin/helpers}/normalizedRelativePath.d.ts +0 -0
  468. /package/dist/{helpers → plugin/helpers}/tryManifest.d.ts +0 -0
  469. /package/dist/{manifest.d.ts → plugin/manifest.d.ts} +0 -0
  470. /package/dist/{module-graph.d.ts → plugin/module-graph.d.ts} +0 -0
  471. /package/dist/{react-server → plugin/react-server}/createDevMiddleware.d.ts +0 -0
  472. /package/dist/{react-server → plugin/react-server}/createDevServer.d.ts +0 -0
  473. /package/dist/{react-server → plugin/react-server}/createReactNodeStreamer.d.ts +0 -0
  474. /package/dist/{resolvePage.d.ts → plugin/resolvePage.d.ts} +0 -0
  475. /package/dist/{resolveProps.d.ts → plugin/resolveProps.d.ts} +0 -0
  476. /package/dist/{transformer → plugin/transformer}/types.d.ts +0 -0
  477. /package/dist/{worker → plugin/worker}/loader.d.ts +0 -0
  478. /package/{src → plugin}/assertServerCondition.ts +0 -0
  479. /package/{src → plugin}/components.tsx +0 -0
  480. /package/{src → plugin}/copy-dir.ts +0 -0
  481. /package/{src/server.tsx → plugin/getCondition.ts} +0 -0
  482. /package/{src → plugin}/helpers/normalizedRelativePath.ts +0 -0
  483. /package/{src → plugin}/helpers/tryManifest.ts +0 -0
  484. /package/{src → plugin}/manifest.ts +0 -0
  485. /package/{src → plugin}/module-graph.ts +0 -0
  486. /package/{src → plugin}/transformer/README.md +0 -0
  487. /package/{src → plugin}/transformer/types.ts +0 -0
  488. /package/{src → plugin}/worker/loader.ts +0 -0
@@ -0,0 +1,124 @@
1
+ interface PipeableStreamOptions {
2
+ bootstrapModules?: string[];
3
+ bootstrapScripts?: string[];
4
+ bootstrapScriptContent?: string;
5
+ signal?: AbortSignal;
6
+ identifierPrefix?: string;
7
+ namespaceURI?: string;
8
+ nonce?: string;
9
+ progressiveChunkSize?: number;
10
+ onShellReady?: () => void;
11
+ onAllReady?: () => void;
12
+ onError?: (error: unknown) => void;
13
+ importMap?: {
14
+ imports?: Record<string, string>;
15
+ };
16
+ }
17
+
18
+ export interface HtmlRenderState {
19
+ chunks: string[];
20
+ complete: boolean;
21
+ rendered: boolean;
22
+ outDir: string;
23
+ moduleRootPath: string;
24
+ moduleBaseURL: string;
25
+ htmlOutputPath: string;
26
+ id: string;
27
+ pipableStreamOptions: PipeableStreamOptions;
28
+ }
29
+
30
+ export interface RscRenderState {
31
+ id: string;
32
+ pipableStreamOptions: PipeableStreamOptions;
33
+ outDir: string;
34
+ moduleRootPath: string;
35
+ moduleBaseURL: string;
36
+ rscOutputPath: string;
37
+ componentImport: string;
38
+ propsImport: string;
39
+ }
40
+
41
+ export interface WorkerRscChunkMessage {
42
+ type: "RSC_CHUNK";
43
+ id: string;
44
+ chunk: string;
45
+ moduleRootPath: string;
46
+ moduleBaseURL: string;
47
+ outDir: string;
48
+ htmlOutputPath: string;
49
+ pipableStreamOptions: PipeableStreamOptions;
50
+ }
51
+
52
+ export interface ShutdownMessage {
53
+ type: "SHUTDOWN";
54
+ id: string;
55
+ }
56
+
57
+ export interface RscRenderMessage {
58
+ type: "RSC_RENDER";
59
+ id: string;
60
+ pageImport: string;
61
+ propsImport: string;
62
+ outDir: string;
63
+ moduleRootPath: string;
64
+ moduleBaseURL: string;
65
+ pipableStreamOptions: PipeableStreamOptions;
66
+ }
67
+
68
+ export interface RscCompleteMessage {
69
+ type: "RSC_COMPLETE";
70
+ id: string;
71
+ outputPath: string;
72
+ }
73
+
74
+ export interface RscErrorMessage {
75
+ type: "ERROR";
76
+ id: string;
77
+ error: string;
78
+ }
79
+
80
+ export interface RscWroteFileMessage {
81
+ type: "WROTE_FILE";
82
+ id: string;
83
+ outputPath: string;
84
+ }
85
+
86
+ export interface RscEndMessage {
87
+ type: "RSC_END";
88
+ id: string;
89
+ }
90
+
91
+ export interface ClientReferenceMessage {
92
+ type: "CLIENT_REFERENCE";
93
+ id: string;
94
+ location: string;
95
+ key: string;
96
+ ref: unknown;
97
+ }
98
+
99
+ export interface ServerReferenceMessage {
100
+ type: "SERVER_REFERENCE";
101
+ id: string;
102
+ location: string;
103
+ key: string;
104
+ ref: unknown;
105
+ }
106
+
107
+ export type HtmlWorkerMessage =
108
+ | WorkerRscChunkMessage
109
+ | RscEndMessage
110
+ | ShutdownMessage;
111
+
112
+ export type RscWorkerMessage =
113
+ | RscRenderMessage
114
+ | RscEndMessage
115
+ | ShutdownMessage
116
+ | ClientReferenceMessage
117
+ | ServerReferenceMessage;
118
+
119
+ export type RscWorkerResponse =
120
+ | RscCompleteMessage
121
+ | RscErrorMessage
122
+ | RscWroteFileMessage
123
+ | ClientReferenceMessage
124
+ | ServerReferenceMessage;
@@ -0,0 +1,68 @@
1
+ import fs from 'node:fs/promises'
2
+ import path from 'node:path'
3
+
4
+
5
+ /**
6
+ * Bumps the version of the package.
7
+ * @param {'major' | 'minor' | 'patch'} type - The type of version to bump.
8
+ */
9
+ async function bumpVersion(type) {
10
+ // Read package.json
11
+ const packageJson = JSON.parse(
12
+ await fs.readFile(path.resolve('package.json'), 'utf-8')
13
+ )
14
+ const packageLockJson = JSON.parse(
15
+ await fs.readFile(path.resolve('package-lock.json'), 'utf-8')
16
+ )
17
+
18
+ // Parse current version
19
+ const [major, minor, patch] = packageJson.version.split('.').map(Number)
20
+
21
+ // Calculate new version
22
+ /**
23
+ * The new version of the package.
24
+ * @type {string}
25
+ */
26
+ let newVersion
27
+ switch (type) {
28
+ case 'major':
29
+ newVersion = `${major + 1}.0.0`
30
+ break
31
+ case 'minor':
32
+ newVersion = `${major}.${minor + 1}.0`
33
+ break
34
+ case 'patch':
35
+ newVersion = `${major}.${minor}.${patch + 1}`
36
+ break
37
+ }
38
+
39
+ // Update both files
40
+ packageJson.version = newVersion
41
+ packageLockJson.version = newVersion
42
+ packageLockJson.packages[''].version = newVersion
43
+
44
+ // Write back
45
+ await fs.writeFile(
46
+ path.resolve('package.json'),
47
+ JSON.stringify(packageJson, null, 2) + '\n'
48
+ )
49
+ await fs.writeFile(
50
+ path.resolve('package-lock.json'),
51
+ JSON.stringify(packageLockJson, null, 2) + '\n'
52
+ )
53
+
54
+ console.log(`Version bumped to ${newVersion}`)
55
+ }
56
+
57
+ // Get version type from command line argument
58
+ /**
59
+ * The type of version to bump.
60
+ * @type {'major' | 'minor' | 'patch'}
61
+ */
62
+ const type = process.argv[2]
63
+ if (!type || !['major', 'minor', 'patch'].includes(type)) {
64
+ console.error('Please specify version type: major, minor, or patch')
65
+ process.exit(1)
66
+ }
67
+
68
+ bumpVersion(type).catch(console.error)
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs/promises'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
+
8
+ const TEMPLATE_VERSION = '0.0.0-experimental-b3a95caf-20250113'
9
+ const STUB_VERSION = '0.0.1'
10
+
11
+ async function main() {
12
+ // Read installed React version
13
+ const reactPkgPath = path.resolve(process.cwd(), 'node_modules/react/package.json')
14
+ const reactPkg = JSON.parse(await fs.readFile(reactPkgPath, 'utf-8'))
15
+ const userPkg = JSON.parse(await fs.readFile(path.resolve(process.cwd(), 'package.json'), 'utf-8'))
16
+ const patchVersion = reactPkg.version
17
+ let userVersion = userPkg.dependencies?.react ?? userPkg.devDependencies?.react ?? userPkg.peerDependencies?.react
18
+ if(!userVersion) {
19
+ throw new Error('React version not found in package.json')
20
+ } else {
21
+ userVersion = userVersion.replace('^', '')
22
+ }
23
+ // Define patches to process
24
+ const patches = [
25
+ {
26
+ template: path.resolve(__dirname, `react-server-dom-esm+${TEMPLATE_VERSION}.patch`),
27
+ output: `react-server-dom-esm+${STUB_VERSION}.patch`
28
+ },
29
+ {
30
+ template: path.resolve(__dirname, `react+${TEMPLATE_VERSION}.patch`),
31
+ output: `react+${userVersion}.patch`
32
+ },
33
+ {
34
+ template: path.resolve(__dirname, `react-dom+${TEMPLATE_VERSION}.patch`),
35
+ output: `react-dom+${userVersion}.patch`
36
+ }
37
+ ]
38
+
39
+ // Create patches dir
40
+ const userPatchesDir = path.resolve(process.cwd(), 'patches')
41
+ await fs.mkdir(userPatchesDir, { recursive: true })
42
+
43
+ // Process each patch
44
+ for (const {template, output} of patches) {
45
+ let patchContent = await fs.readFile(template, 'utf-8')
46
+
47
+ // Replace versions
48
+ patchContent = patchContent
49
+ .replace(new RegExp(TEMPLATE_VERSION, 'g'), patchVersion)
50
+
51
+ // Write patched file
52
+ const outputPath = path.resolve(userPatchesDir, output)
53
+ await fs.writeFile(outputPath, patchContent)
54
+ console.log(`Wrote patch file to ${outputPath}`)
55
+ }
56
+
57
+ console.log(`Updated patches to match React version ${userVersion} (actual version: ${patchVersion})`)
58
+ }
59
+
60
+ const PATCH = ``
61
+
62
+ try {
63
+ main()
64
+ } catch (error) {
65
+ console.error('error applying patch', error)
66
+ }