vite-plugin-react-server 1.1.19 → 1.2.0-alpha.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 (783) hide show
  1. package/README.md +102 -395
  2. package/dist/_virtual/dynamic-import-helper.js +1 -1
  3. package/dist/client.d.ts +1 -1
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +5 -2
  6. package/dist/index.js +1 -1
  7. package/dist/package.json +58 -25
  8. package/dist/plugin/components/{css-collector-elements.d.ts → css.d.ts} +2 -2
  9. package/dist/plugin/components/css.d.ts.map +1 -0
  10. package/dist/plugin/components/css.js +33 -0
  11. package/dist/plugin/components/html.d.ts +1 -1
  12. package/dist/plugin/components/html.d.ts.map +1 -1
  13. package/dist/plugin/components/html.js +5 -5
  14. package/dist/plugin/components/index.d.ts +3 -3
  15. package/dist/plugin/components/index.d.ts.map +1 -1
  16. package/dist/plugin/components/index.js +9 -3
  17. package/dist/plugin/components/root.d.ts +7 -0
  18. package/dist/plugin/components/root.d.ts.map +1 -0
  19. package/dist/plugin/components/root.js +18 -0
  20. package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +1 -1
  21. package/dist/plugin/config/autoDiscover/customWorkerFiles.js +1 -1
  22. package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +1 -1
  23. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +5 -4
  24. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
  25. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +26 -7
  26. package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +25 -2
  27. package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -1
  28. package/dist/plugin/config/autoDiscover/resolveBuildPages.js +84 -5
  29. package/dist/plugin/config/createModuleID.d.ts +3 -6
  30. package/dist/plugin/config/createModuleID.d.ts.map +1 -1
  31. package/dist/plugin/config/createModuleID.js +42 -32
  32. package/dist/plugin/config/defaults.d.ts +199 -121
  33. package/dist/plugin/config/defaults.d.ts.map +1 -1
  34. package/dist/plugin/config/defaults.js +155 -89
  35. package/dist/plugin/config/extMap.d.ts +6 -2
  36. package/dist/plugin/config/extMap.d.ts.map +1 -1
  37. package/dist/plugin/config/extMap.js +38 -48
  38. package/dist/plugin/config/flightBindings.d.ts +4 -0
  39. package/dist/plugin/config/flightBindings.d.ts.map +1 -0
  40. package/dist/plugin/config/flightBindings.js +215 -0
  41. package/dist/plugin/config/getCondition.d.ts +2 -0
  42. package/dist/plugin/config/getCondition.d.ts.map +1 -1
  43. package/dist/plugin/config/getCondition.js +4 -2
  44. package/dist/plugin/config/getPaths.js +1 -1
  45. package/dist/plugin/config/index.d.ts +17 -4
  46. package/dist/plugin/config/index.d.ts.map +1 -1
  47. package/dist/plugin/config/index.js +29 -7
  48. package/dist/plugin/config/interpolatePattern.d.ts +13 -0
  49. package/dist/plugin/config/interpolatePattern.d.ts.map +1 -0
  50. package/dist/plugin/config/interpolatePattern.js +13 -0
  51. package/dist/plugin/config/mimeTypes.js +1 -1
  52. package/dist/plugin/config/parsePattern.d.ts +25 -0
  53. package/dist/plugin/config/parsePattern.d.ts.map +1 -0
  54. package/dist/plugin/config/parsePattern.js +30 -0
  55. package/dist/plugin/config/resolveAllowedDirectives.d.ts +26 -0
  56. package/dist/plugin/config/resolveAllowedDirectives.d.ts.map +1 -0
  57. package/dist/plugin/config/resolveAllowedDirectives.js +35 -0
  58. package/dist/plugin/config/resolveDirectiveMatcher.d.ts +25 -0
  59. package/dist/plugin/config/resolveDirectiveMatcher.d.ts.map +1 -0
  60. package/dist/plugin/config/resolveDirectiveMatcher.js +33 -0
  61. package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
  62. package/dist/plugin/config/resolveEnv.js +14 -4
  63. package/dist/plugin/config/resolveOptions.d.ts +13 -3
  64. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  65. package/dist/plugin/config/resolveOptions.js +228 -206
  66. package/dist/plugin/config/resolvePages.js +1 -1
  67. package/dist/plugin/config/resolvePatternWithValues.d.ts +39 -0
  68. package/dist/plugin/config/resolvePatternWithValues.d.ts.map +1 -0
  69. package/dist/plugin/config/resolvePatternWithValues.js +36 -0
  70. package/dist/plugin/config/resolveRegExp.d.ts +29 -0
  71. package/dist/plugin/config/resolveRegExp.d.ts.map +1 -0
  72. package/dist/plugin/config/resolveRegExp.js +39 -0
  73. package/dist/plugin/config/resolveUrlOption.d.ts +37 -6
  74. package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -1
  75. package/dist/plugin/config/resolveUrlOption.js +42 -12
  76. package/dist/plugin/config/resolveUserConfig.d.ts +5 -4
  77. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  78. package/dist/plugin/config/resolveUserConfig.js +86 -40
  79. package/dist/plugin/env/plugin.d.ts +6 -0
  80. package/dist/plugin/env/plugin.d.ts.map +1 -1
  81. package/dist/plugin/env/plugin.js +111 -93
  82. package/dist/plugin/error/directiveError.d.ts +13 -0
  83. package/dist/plugin/error/directiveError.d.ts.map +1 -0
  84. package/dist/plugin/error/directiveError.js +21 -0
  85. package/dist/plugin/error/enhanceError.d.ts +14 -0
  86. package/dist/plugin/error/enhanceError.d.ts.map +1 -0
  87. package/dist/plugin/error/enhanceError.js +24 -0
  88. package/dist/plugin/error/index.d.ts +4 -0
  89. package/dist/plugin/error/index.d.ts.map +1 -0
  90. package/dist/plugin/error/index.js +9 -0
  91. package/dist/plugin/error/logError.d.ts +3 -0
  92. package/dist/plugin/error/logError.d.ts.map +1 -0
  93. package/dist/plugin/error/logError.js +47 -0
  94. package/dist/plugin/error/serializeError.d.ts +7 -0
  95. package/dist/plugin/error/serializeError.d.ts.map +1 -0
  96. package/dist/plugin/error/serializeError.js +37 -0
  97. package/dist/plugin/error/toError.d.ts +1 -8
  98. package/dist/plugin/error/toError.d.ts.map +1 -1
  99. package/dist/plugin/error/toError.js +62 -34
  100. package/dist/plugin/file-preserver/plugin.js +93 -105
  101. package/dist/plugin/getNodeEnv.d.ts +11 -0
  102. package/dist/plugin/getNodeEnv.d.ts.map +1 -0
  103. package/dist/plugin/getNodeEnv.js +17 -0
  104. package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
  105. package/dist/plugin/helpers/cleanObject.js +2 -1
  106. package/dist/plugin/helpers/collectManifestCss.js +1 -1
  107. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +6 -4
  108. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
  109. package/dist/plugin/helpers/collectViteModuleGraphCss.js +15 -9
  110. package/dist/plugin/helpers/createCssProps.d.ts +3 -4
  111. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
  112. package/dist/plugin/helpers/createCssProps.js +16 -4
  113. package/dist/plugin/helpers/createEventHandler.d.ts +2 -2
  114. package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -1
  115. package/dist/plugin/helpers/createEventHandler.js +1 -1
  116. package/dist/plugin/helpers/createHandler.d.ts +10 -8
  117. package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
  118. package/dist/plugin/helpers/createHandler.js +11 -5
  119. package/dist/plugin/helpers/createRscStream.d.ts +18 -5
  120. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
  121. package/dist/plugin/helpers/createRscStream.js +48 -14
  122. package/dist/plugin/helpers/formatMetrics.d.ts +1 -5
  123. package/dist/plugin/helpers/formatMetrics.d.ts.map +1 -1
  124. package/dist/plugin/helpers/formatMetrics.js +2 -39
  125. package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
  126. package/dist/plugin/helpers/getBundleManifest.js +9 -2
  127. package/dist/plugin/helpers/getRouteFiles.d.ts +30 -2
  128. package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -1
  129. package/dist/plugin/helpers/getRouteFiles.js +70 -7
  130. package/dist/plugin/helpers/handleServerAction.d.ts +8 -7
  131. package/dist/plugin/helpers/handleServerAction.d.ts.map +1 -1
  132. package/dist/plugin/helpers/handleServerAction.js +5 -2
  133. package/dist/plugin/helpers/hydrateUserOptions.d.ts +9 -0
  134. package/dist/plugin/helpers/hydrateUserOptions.d.ts.map +1 -0
  135. package/dist/plugin/helpers/hydrateUserOptions.js +22 -0
  136. package/dist/plugin/helpers/index.d.ts +2 -0
  137. package/dist/plugin/helpers/index.d.ts.map +1 -1
  138. package/dist/plugin/helpers/index.js +31 -31
  139. package/dist/plugin/helpers/inputNormalizer.d.ts +1 -1
  140. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  141. package/dist/plugin/helpers/inputNormalizer.js +33 -20
  142. package/dist/plugin/helpers/metrics.d.ts +4 -10
  143. package/dist/plugin/helpers/metrics.d.ts.map +1 -1
  144. package/dist/plugin/helpers/metrics.js +3 -59
  145. package/dist/plugin/helpers/moduleRefs.js +1 -1
  146. package/dist/plugin/helpers/moduleResolver.d.ts +24 -2
  147. package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -1
  148. package/dist/plugin/helpers/moduleResolver.js +61 -22
  149. package/dist/plugin/helpers/requestInfo.d.ts +28 -1
  150. package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
  151. package/dist/plugin/helpers/requestInfo.js +43 -30
  152. package/dist/plugin/helpers/requestToRoute.d.ts +1 -1
  153. package/dist/plugin/helpers/requestToRoute.d.ts.map +1 -1
  154. package/dist/plugin/helpers/requestToRoute.js +17 -9
  155. package/dist/plugin/helpers/resolveComponent.d.ts +57 -0
  156. package/dist/plugin/helpers/resolveComponent.d.ts.map +1 -0
  157. package/dist/plugin/helpers/resolveComponent.js +71 -0
  158. package/dist/plugin/helpers/resolveComponents.d.ts +27 -0
  159. package/dist/plugin/helpers/resolveComponents.d.ts.map +1 -0
  160. package/dist/plugin/helpers/resolveComponents.js +137 -0
  161. package/dist/plugin/helpers/resolvePage.d.ts +15 -11
  162. package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
  163. package/dist/plugin/helpers/resolvePage.js +11 -7
  164. package/dist/plugin/helpers/resolvePageAndProps.d.ts +3 -10
  165. package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
  166. package/dist/plugin/helpers/resolvePageAndProps.js +28 -18
  167. package/dist/plugin/helpers/resolveProps.d.ts +13 -7
  168. package/dist/plugin/helpers/resolveProps.d.ts.map +1 -1
  169. package/dist/plugin/helpers/resolveProps.js +55 -25
  170. package/dist/plugin/helpers/resolveUserComponents.d.ts +33 -0
  171. package/dist/plugin/helpers/resolveUserComponents.d.ts.map +1 -0
  172. package/dist/plugin/helpers/resolveUserComponents.js +163 -0
  173. package/dist/plugin/helpers/serializeUserOptions.d.ts +7 -7
  174. package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
  175. package/dist/plugin/helpers/serializeUserOptions.js +127 -42
  176. package/dist/plugin/helpers/stashReturnValue.d.ts +2 -1
  177. package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -1
  178. package/dist/plugin/helpers/stashReturnValue.js +6 -3
  179. package/dist/plugin/helpers/tryManifest.d.ts +1 -2
  180. package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
  181. package/dist/plugin/helpers/tryManifest.js +1 -1
  182. package/dist/plugin/loader/createDefaultLoader.d.ts +19 -8
  183. package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
  184. package/dist/plugin/loader/createDefaultLoader.js +69 -107
  185. package/dist/plugin/loader/createTransformer.d.ts +6 -0
  186. package/dist/plugin/loader/createTransformer.d.ts.map +1 -0
  187. package/dist/plugin/loader/createTransformer.js +97 -0
  188. package/dist/plugin/loader/{css-loader.development.d.ts → css-loader.d.ts} +6 -8
  189. package/dist/plugin/loader/css-loader.d.ts.map +1 -0
  190. package/dist/plugin/loader/css-loader.js +134 -0
  191. package/dist/plugin/loader/directives/addLocalExportedNames.d.ts +4 -0
  192. package/dist/plugin/loader/directives/addLocalExportedNames.d.ts.map +1 -0
  193. package/dist/plugin/loader/directives/addLocalExportedNames.js +57 -0
  194. package/dist/plugin/loader/directives/analyzeDirectives.d.ts +9 -0
  195. package/dist/plugin/loader/directives/analyzeDirectives.d.ts.map +1 -0
  196. package/dist/plugin/loader/directives/analyzeDirectives.js +221 -0
  197. package/dist/plugin/loader/directives/analyzeModule.d.ts +11 -0
  198. package/dist/plugin/loader/directives/analyzeModule.d.ts.map +1 -0
  199. package/dist/plugin/loader/directives/analyzeModule.js +34 -0
  200. package/dist/plugin/loader/directives/collectExports.d.ts +13 -0
  201. package/dist/plugin/loader/directives/collectExports.d.ts.map +1 -0
  202. package/dist/plugin/loader/directives/collectExports.js +116 -0
  203. package/dist/plugin/loader/directives/collectExportsFromModule.d.ts +6 -0
  204. package/dist/plugin/loader/directives/collectExportsFromModule.d.ts.map +1 -0
  205. package/dist/plugin/loader/directives/collectExportsFromModule.js +24 -0
  206. package/dist/plugin/loader/directives/findDirectiveMatches.d.ts +3 -0
  207. package/dist/plugin/loader/directives/findDirectiveMatches.d.ts.map +1 -0
  208. package/dist/plugin/loader/directives/findDirectiveMatches.js +46 -0
  209. package/dist/plugin/loader/directives/getExportedName.d.ts +3 -0
  210. package/dist/plugin/loader/directives/getExportedName.d.ts.map +1 -0
  211. package/dist/plugin/loader/directives/getExportedName.js +59 -0
  212. package/dist/plugin/loader/directives/getExports.d.ts +7 -0
  213. package/dist/plugin/loader/directives/getExports.d.ts.map +1 -0
  214. package/dist/plugin/loader/directives/getExports.js +28 -0
  215. package/dist/plugin/loader/directives/getFunctionBody.d.ts +3 -0
  216. package/dist/plugin/loader/directives/getFunctionBody.d.ts.map +1 -0
  217. package/dist/plugin/loader/directives/getFunctionBody.js +31 -0
  218. package/dist/plugin/loader/directives/getFunctionName.d.ts +10 -0
  219. package/dist/plugin/loader/directives/getFunctionName.d.ts.map +1 -0
  220. package/dist/plugin/loader/directives/getFunctionName.js +42 -0
  221. package/dist/plugin/loader/directives/getQualifiedName.d.ts +3 -0
  222. package/dist/plugin/loader/directives/getQualifiedName.d.ts.map +1 -0
  223. package/dist/plugin/loader/directives/getQualifiedName.js +65 -0
  224. package/dist/plugin/loader/directives/index.d.ts +14 -0
  225. package/dist/plugin/loader/directives/index.d.ts.map +1 -0
  226. package/dist/plugin/loader/directives/index.js +18 -0
  227. package/dist/plugin/loader/directives/processFunctionNode.d.ts +4 -0
  228. package/dist/plugin/loader/directives/processFunctionNode.d.ts.map +1 -0
  229. package/dist/plugin/loader/directives/processFunctionNode.js +86 -0
  230. package/dist/plugin/loader/directives/typeGuards.d.ts +37 -0
  231. package/dist/plugin/loader/directives/typeGuards.d.ts.map +1 -0
  232. package/dist/plugin/loader/directives/typeGuards.js +100 -0
  233. package/dist/plugin/loader/directives/types.d.ts +154 -0
  234. package/dist/plugin/loader/directives/types.d.ts.map +1 -0
  235. package/dist/plugin/loader/directives/utils.d.ts +14 -0
  236. package/dist/plugin/loader/directives/utils.d.ts.map +1 -0
  237. package/dist/plugin/loader/directives/utils.js +21 -0
  238. package/dist/plugin/loader/env-loader.d.ts +11 -0
  239. package/dist/plugin/loader/env-loader.d.ts.map +1 -0
  240. package/dist/plugin/loader/env-loader.js +65 -0
  241. package/dist/plugin/loader/index.d.ts +8 -1
  242. package/dist/plugin/loader/index.d.ts.map +1 -1
  243. package/dist/plugin/loader/index.js +13 -4
  244. package/dist/plugin/loader/parse.d.ts +11 -2
  245. package/dist/plugin/loader/parse.d.ts.map +1 -1
  246. package/dist/plugin/loader/parse.js +29 -6
  247. package/dist/plugin/loader/react-loader.d.ts +22 -1
  248. package/dist/plugin/loader/react-loader.d.ts.map +1 -1
  249. package/dist/plugin/loader/react-loader.js +169 -6
  250. package/dist/plugin/loader/removeDirectives.d.ts +5 -0
  251. package/dist/plugin/loader/removeDirectives.d.ts.map +1 -0
  252. package/dist/plugin/loader/removeDirectives.js +17 -0
  253. package/dist/plugin/loader/removeRanges.d.ts +5 -0
  254. package/dist/plugin/loader/removeRanges.d.ts.map +1 -0
  255. package/dist/plugin/loader/removeRanges.js +20 -0
  256. package/dist/plugin/loader/sourceMap.d.ts +16 -24
  257. package/dist/plugin/loader/sourceMap.d.ts.map +1 -1
  258. package/dist/plugin/loader/sourceMap.js +125 -97
  259. package/dist/plugin/loader/transformClientModule.d.ts +10 -0
  260. package/dist/plugin/loader/transformClientModule.d.ts.map +1 -0
  261. package/dist/plugin/loader/transformClientModule.js +46 -0
  262. package/dist/plugin/loader/transformModule.d.ts +6 -0
  263. package/dist/plugin/loader/transformModule.d.ts.map +1 -0
  264. package/dist/plugin/loader/transformModule.js +33 -0
  265. package/dist/plugin/loader/transformModuleIfNeeded.d.ts +12 -1
  266. package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
  267. package/dist/plugin/loader/transformModuleIfNeeded.js +9 -20
  268. package/dist/plugin/loader/transformServerModule.d.ts +11 -0
  269. package/dist/plugin/loader/transformServerModule.d.ts.map +1 -0
  270. package/dist/plugin/loader/transformServerModule.js +84 -0
  271. package/dist/plugin/loader/transformWithAcornLoose.d.ts +12 -0
  272. package/dist/plugin/loader/transformWithAcornLoose.d.ts.map +1 -0
  273. package/dist/plugin/loader/transformWithAcornLoose.js +18 -0
  274. package/dist/plugin/loader/types.d.ts +59 -12
  275. package/dist/plugin/loader/types.d.ts.map +1 -1
  276. package/dist/plugin/metrics/collectStreamMetrics.d.ts +9 -0
  277. package/dist/plugin/metrics/collectStreamMetrics.d.ts.map +1 -0
  278. package/dist/plugin/metrics/collectStreamMetrics.js +35 -0
  279. package/dist/plugin/metrics/createRenderMetrics.d.ts +3 -0
  280. package/dist/plugin/metrics/createRenderMetrics.d.ts.map +1 -0
  281. package/dist/plugin/metrics/createRenderMetrics.js +24 -0
  282. package/dist/plugin/metrics/createStreamMetrics.d.ts +3 -0
  283. package/dist/plugin/metrics/createStreamMetrics.d.ts.map +1 -0
  284. package/dist/plugin/metrics/createStreamMetrics.js +19 -0
  285. package/dist/plugin/metrics/formatMetrics.d.ts +6 -3
  286. package/dist/plugin/metrics/formatMetrics.d.ts.map +1 -1
  287. package/dist/plugin/metrics/formatMetrics.js +5 -2
  288. package/dist/plugin/metrics/index.d.ts +3 -1
  289. package/dist/plugin/metrics/index.d.ts.map +1 -1
  290. package/dist/plugin/metrics/index.js +9 -1
  291. package/dist/plugin/metrics/types.d.ts +23 -0
  292. package/dist/plugin/metrics/types.d.ts.map +1 -0
  293. package/dist/plugin/metrics/types.js +1 -0
  294. package/dist/plugin/plugin.client.d.ts +23 -2
  295. package/dist/plugin/plugin.client.d.ts.map +1 -1
  296. package/dist/plugin/plugin.client.js +30 -17
  297. package/dist/plugin/plugin.server.d.ts +13 -2
  298. package/dist/plugin/plugin.server.d.ts.map +1 -1
  299. package/dist/plugin/plugin.server.js +7 -4
  300. package/dist/plugin/preserver/plugin.d.ts +2 -2
  301. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  302. package/dist/plugin/preserver/plugin.js +33 -29
  303. package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts +11 -0
  304. package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts.map +1 -0
  305. package/dist/plugin/react-client/cleanupWorkerServerAction.js +18 -0
  306. package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts +9 -9
  307. package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -1
  308. package/dist/plugin/react-client/configureWorkerRequestHandler.js +25 -14
  309. package/dist/plugin/react-client/createMessageHandlers.d.ts +1 -1
  310. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
  311. package/dist/plugin/react-client/createMessageHandlers.js +15 -3
  312. package/dist/plugin/react-client/createWorkerStream.d.ts +12 -10
  313. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  314. package/dist/plugin/react-client/createWorkerStream.js +27 -29
  315. package/dist/plugin/react-client/handleWorkerRscStream.d.ts +13 -8
  316. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
  317. package/dist/plugin/react-client/handleWorkerRscStream.js +59 -24
  318. package/dist/plugin/react-client/handleWorkerServerAction.d.ts +2 -1
  319. package/dist/plugin/react-client/handleWorkerServerAction.d.ts.map +1 -1
  320. package/dist/plugin/react-client/handleWorkerServerAction.js +43 -28
  321. package/dist/plugin/react-client/index.d.ts +4 -1
  322. package/dist/plugin/react-client/index.d.ts.map +1 -1
  323. package/dist/plugin/react-client/index.js +10 -1
  324. package/dist/plugin/react-client/plugin.d.ts +5 -3
  325. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  326. package/dist/plugin/react-client/plugin.js +9 -11
  327. package/dist/plugin/react-client/restartWorker.d.ts +5 -4
  328. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  329. package/dist/plugin/react-client/restartWorker.js +12 -10
  330. package/dist/plugin/react-server/configureReactServer.d.ts +5 -4
  331. package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -1
  332. package/dist/plugin/react-server/configureReactServer.js +98 -43
  333. package/dist/plugin/react-server/handleServerAction.d.ts +3 -2
  334. package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -1
  335. package/dist/plugin/react-server/handleServerAction.js +14 -20
  336. package/dist/plugin/react-server/plugin.d.ts +3 -4
  337. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  338. package/dist/plugin/react-server/plugin.js +14 -17
  339. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +8 -6
  340. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
  341. package/dist/plugin/react-static/collectHtmlWorkerContent.js +4 -4
  342. package/dist/plugin/react-static/collectRscContent.d.ts +8 -6
  343. package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
  344. package/dist/plugin/react-static/collectRscContent.js +4 -4
  345. package/dist/plugin/react-static/configurePreviewServer.d.ts +6 -4
  346. package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
  347. package/dist/plugin/react-static/configurePreviewServer.js +38 -31
  348. package/dist/plugin/react-static/createBuildLoader.d.ts +5 -5
  349. package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -1
  350. package/dist/plugin/react-static/createBuildLoader.js +122 -30
  351. package/dist/plugin/react-static/fileWriter.js +1 -1
  352. package/dist/plugin/react-static/plugin.d.ts +3 -4
  353. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  354. package/dist/plugin/react-static/plugin.js +62 -47
  355. package/dist/plugin/react-static/renderPage.d.ts +4 -2
  356. package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
  357. package/dist/plugin/react-static/renderPage.js +33 -17
  358. package/dist/plugin/react-static/renderPages.d.ts +4 -2
  359. package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
  360. package/dist/plugin/react-static/renderPages.js +7 -6
  361. package/dist/plugin/react-static/renderStreams.d.ts +5 -22
  362. package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
  363. package/dist/plugin/react-static/renderStreams.js +6 -6
  364. package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -1
  365. package/dist/plugin/react-static/rscToHtmlStream.js +1 -1
  366. package/dist/plugin/react-static/temporaryReferences.js +1 -1
  367. package/dist/plugin/react-static/types.d.ts +0 -1
  368. package/dist/plugin/react-static/types.d.ts.map +1 -1
  369. package/dist/plugin/root.js +1 -1
  370. package/dist/plugin/transformer/plugin.js +1 -1
  371. package/dist/plugin/transformer/plugin.server.d.ts +5 -3
  372. package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
  373. package/dist/plugin/transformer/plugin.server.js +43 -44
  374. package/dist/plugin/types/css-tracking.d.ts +2 -2
  375. package/dist/plugin/types/css-tracking.d.ts.map +1 -1
  376. package/dist/plugin/types.d.ts +452 -192
  377. package/dist/plugin/types.d.ts.map +1 -1
  378. package/dist/plugin/types.js +2 -1
  379. package/dist/plugin/utils/callServer.js +1 -1
  380. package/dist/plugin/utils/createCallServer.d.ts +1 -1
  381. package/dist/plugin/utils/createCallServer.d.ts.map +1 -1
  382. package/dist/plugin/utils/createCallServer.js +1 -1
  383. package/dist/plugin/utils/createReactFetcher.d.ts +2 -3
  384. package/dist/plugin/utils/createReactFetcher.d.ts.map +1 -1
  385. package/dist/plugin/utils/createReactFetcher.js +1 -1
  386. package/dist/plugin/utils/env.js +1 -1
  387. package/dist/plugin/utils/envUrls.node.js +1 -1
  388. package/dist/plugin/utils/index.d.ts +1 -0
  389. package/dist/plugin/utils/index.d.ts.map +1 -1
  390. package/dist/plugin/utils/index.js +12 -5
  391. package/dist/plugin/utils/routeToURL.d.ts +12 -0
  392. package/dist/plugin/utils/routeToURL.d.ts.map +1 -0
  393. package/dist/plugin/utils/routeToURL.js +26 -0
  394. package/dist/plugin/utils/urls.d.ts.map +1 -1
  395. package/dist/plugin/utils/urls.js +5 -3
  396. package/dist/plugin/vendor/index.js +7 -1
  397. package/dist/plugin/vendor/vendor.client.js +1 -1
  398. package/dist/plugin/vendor/vendor.js +1 -1
  399. package/dist/plugin/vendor/vendor.server.js +1 -1
  400. package/dist/plugin/worker/createWorker.d.ts +31 -17
  401. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  402. package/dist/plugin/worker/createWorker.js +18 -12
  403. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +2 -2
  404. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
  405. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +5 -2
  406. package/dist/plugin/worker/html/html-worker.development.js +3 -3
  407. package/dist/plugin/worker/html/html-worker.production.js +1 -1
  408. package/dist/plugin/worker/html/index.d.ts +1 -1
  409. package/dist/plugin/worker/html/index.d.ts.map +1 -1
  410. package/dist/plugin/worker/html/index.js +1 -1
  411. package/dist/plugin/worker/html/messageHandler.d.ts +1 -1
  412. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  413. package/dist/plugin/worker/html/messageHandler.js +9 -11
  414. package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts +3 -0
  415. package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts.map +1 -0
  416. package/dist/plugin/worker/html/sendHtmlWorkerMessage.js +2 -0
  417. package/dist/plugin/worker/html/types.d.ts +20 -2
  418. package/dist/plugin/worker/html/types.d.ts.map +1 -1
  419. package/dist/plugin/worker/index.d.ts +3 -0
  420. package/dist/plugin/worker/index.d.ts.map +1 -0
  421. package/dist/plugin/worker/index.js +7 -0
  422. package/dist/plugin/worker/registerLoaders.js +2 -2
  423. package/dist/plugin/worker/rsc/handleRender.d.ts +4 -3
  424. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  425. package/dist/plugin/worker/rsc/handleRender.js +54 -32
  426. package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -1
  427. package/dist/plugin/worker/rsc/handlers.js +19 -15
  428. package/dist/plugin/worker/rsc/index.d.ts +1 -1
  429. package/dist/plugin/worker/rsc/index.d.ts.map +1 -1
  430. package/dist/plugin/worker/rsc/index.js +1 -1
  431. package/dist/plugin/worker/rsc/messageHandler.d.ts +1 -1
  432. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  433. package/dist/plugin/worker/rsc/messageHandler.js +16 -4
  434. package/dist/plugin/worker/rsc/rsc-worker.development.js +77 -11
  435. package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
  436. package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts +3 -0
  437. package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts.map +1 -0
  438. package/dist/plugin/worker/rsc/sendRscWorkerMessage.js +11 -0
  439. package/dist/plugin/worker/rsc/state.js +1 -1
  440. package/dist/plugin/worker/rsc/types.d.ts +95 -0
  441. package/dist/plugin/worker/rsc/types.d.ts.map +1 -0
  442. package/dist/plugin/worker/rsc/types.js +1 -0
  443. package/dist/plugin/worker/rsc/userOptions.d.ts +1 -1
  444. package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -1
  445. package/dist/plugin/worker/rsc/userOptions.js +3 -4
  446. package/dist/plugin/worker/sendMessage.d.ts +3 -4
  447. package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
  448. package/dist/plugin/worker/sendMessage.js +15 -5
  449. package/dist/plugin/worker/types.d.ts +109 -260
  450. package/dist/plugin/worker/types.d.ts.map +1 -1
  451. package/dist/server.js +1 -1
  452. package/dist/tsconfig.tsbuildinfo +1 -1
  453. package/package.json +58 -25
  454. package/plugin/components/{css-collector-elements.tsx → css.tsx} +3 -3
  455. package/plugin/components/html.tsx +4 -4
  456. package/plugin/components/index.ts +3 -3
  457. package/plugin/components/root.tsx +20 -0
  458. package/plugin/config/autoDiscover/resolveAutoDiscover.ts +173 -134
  459. package/plugin/config/autoDiscover/resolveBuildPages.ts +120 -7
  460. package/plugin/config/createModuleID.ts +60 -39
  461. package/plugin/config/defaults.tsx +184 -95
  462. package/plugin/config/extMap.ts +51 -56
  463. package/plugin/config/flightBindings.ts +221 -0
  464. package/plugin/config/getCondition.ts +6 -0
  465. package/plugin/config/index.ts +17 -4
  466. package/plugin/config/interpolatePattern.ts +19 -0
  467. package/plugin/config/parsePattern.ts +81 -0
  468. package/plugin/config/resolveAllowedDirectives.ts +59 -0
  469. package/plugin/config/resolveDirectiveMatcher.ts +57 -0
  470. package/plugin/config/resolveEnv.ts +5 -10
  471. package/plugin/config/resolveOptions.ts +415 -299
  472. package/plugin/config/resolvePatternWithValues.ts +70 -0
  473. package/plugin/config/resolveRegExp.ts +89 -0
  474. package/plugin/config/resolveUrlOption.ts +92 -20
  475. package/plugin/config/resolveUserConfig.ts +417 -351
  476. package/plugin/env/plugin.ts +71 -7
  477. package/plugin/error/directiveError.ts +29 -0
  478. package/plugin/error/enhanceError.ts +41 -0
  479. package/plugin/error/index.ts +3 -0
  480. package/plugin/error/logError.ts +45 -0
  481. package/plugin/error/serializeError.ts +34 -0
  482. package/plugin/error/toError.ts +75 -45
  483. package/plugin/file-preserver/plugin.ts +3 -3
  484. package/plugin/getNodeEnv.ts +24 -0
  485. package/plugin/helpers/cleanObject.ts +2 -1
  486. package/plugin/helpers/collectViteModuleGraphCss.ts +138 -118
  487. package/plugin/helpers/createCssProps.tsx +41 -20
  488. package/plugin/helpers/createEventHandler.ts +1 -1
  489. package/plugin/helpers/createHandler.ts +40 -12
  490. package/plugin/helpers/createRscStream.tsx +97 -35
  491. package/plugin/helpers/formatMetrics.ts +2 -37
  492. package/plugin/helpers/getBundleManifest.ts +10 -1
  493. package/plugin/helpers/getRouteFiles.ts +112 -8
  494. package/plugin/helpers/handleServerAction.ts +10 -6
  495. package/plugin/helpers/hydrateUserOptions.ts +23 -0
  496. package/plugin/helpers/index.ts +4 -0
  497. package/plugin/helpers/inputNormalizer.ts +44 -24
  498. package/plugin/helpers/metrics.ts +4 -64
  499. package/plugin/helpers/moduleResolver.ts +74 -19
  500. package/plugin/helpers/requestInfo.ts +72 -52
  501. package/plugin/helpers/requestToRoute.ts +38 -12
  502. package/plugin/helpers/resolveComponent.ts +173 -0
  503. package/plugin/helpers/resolveComponents.ts +185 -0
  504. package/plugin/helpers/resolvePage.ts +35 -29
  505. package/plugin/helpers/resolvePageAndProps.ts +82 -61
  506. package/plugin/helpers/resolveProps.ts +100 -37
  507. package/plugin/helpers/resolveUserComponents.ts +190 -0
  508. package/plugin/helpers/serializeUserOptions.ts +190 -69
  509. package/plugin/helpers/stashReturnValue.ts +7 -4
  510. package/plugin/helpers/tryManifest.ts +1 -1
  511. package/plugin/loader/createDefaultLoader.ts +119 -119
  512. package/plugin/loader/createTransformer.ts +118 -0
  513. package/plugin/loader/css-loader.ts +206 -0
  514. package/plugin/loader/directives/addLocalExportedNames.ts +78 -0
  515. package/plugin/loader/directives/analyzeDirectives.ts +298 -0
  516. package/plugin/loader/directives/analyzeModule.ts +39 -0
  517. package/plugin/loader/directives/collectExports.ts +181 -0
  518. package/plugin/loader/directives/collectExportsFromModule.ts +25 -0
  519. package/plugin/loader/directives/findDirectiveMatches.ts +58 -0
  520. package/plugin/loader/directives/getExportedName.ts +73 -0
  521. package/plugin/loader/directives/getExports.ts +27 -0
  522. package/plugin/loader/directives/getFunctionBody.ts +32 -0
  523. package/plugin/loader/directives/getFunctionName.ts +70 -0
  524. package/plugin/loader/directives/getQualifiedName.ts +76 -0
  525. package/plugin/loader/directives/index.ts +13 -0
  526. package/plugin/loader/directives/processFunctionNode.ts +97 -0
  527. package/plugin/loader/directives/typeGuards.ts +160 -0
  528. package/plugin/loader/directives/types.ts +174 -0
  529. package/plugin/loader/directives/utils.ts +35 -0
  530. package/plugin/loader/{env-loader.development.ts → env-loader.ts} +8 -22
  531. package/plugin/loader/index.ts +8 -6
  532. package/plugin/loader/parse.ts +42 -12
  533. package/plugin/loader/react-loader.ts +255 -4
  534. package/plugin/loader/removeDirectives.ts +14 -0
  535. package/plugin/loader/removeRanges.ts +21 -0
  536. package/plugin/loader/sourceMap.ts +174 -84
  537. package/plugin/loader/transformClientModule.ts +64 -0
  538. package/plugin/loader/transformModule.ts +54 -0
  539. package/plugin/loader/transformModuleIfNeeded.ts +40 -40
  540. package/plugin/loader/transformServerModule.ts +136 -0
  541. package/plugin/loader/transformWithAcornLoose.ts +27 -0
  542. package/plugin/loader/types.ts +65 -13
  543. package/plugin/metrics/collectStreamMetrics.ts +38 -0
  544. package/plugin/metrics/createRenderMetrics.ts +17 -0
  545. package/plugin/metrics/createStreamMetrics.ts +14 -0
  546. package/plugin/metrics/formatMetrics.ts +7 -3
  547. package/plugin/metrics/index.ts +3 -1
  548. package/plugin/metrics/types.ts +24 -0
  549. package/plugin/plugin.client.ts +39 -15
  550. package/plugin/plugin.server.ts +39 -18
  551. package/plugin/preserver/plugin.ts +42 -42
  552. package/plugin/react-client/cleanupWorkerServerAction.ts +33 -0
  553. package/plugin/react-client/configureWorkerRequestHandler.ts +212 -201
  554. package/plugin/react-client/createMessageHandlers.ts +17 -3
  555. package/plugin/react-client/createWorkerStream.ts +55 -51
  556. package/plugin/react-client/handleWorkerRscStream.ts +141 -61
  557. package/plugin/react-client/handleWorkerServerAction.ts +59 -37
  558. package/plugin/react-client/index.ts +4 -1
  559. package/plugin/react-client/plugin.ts +17 -18
  560. package/plugin/react-client/restartWorker.ts +75 -70
  561. package/plugin/react-server/configureReactServer.ts +200 -142
  562. package/plugin/react-server/handleServerAction.ts +156 -160
  563. package/plugin/react-server/plugin.ts +18 -25
  564. package/plugin/react-static/collectHtmlWorkerContent.ts +109 -102
  565. package/plugin/react-static/collectRscContent.ts +55 -51
  566. package/plugin/react-static/configurePreviewServer.ts +110 -100
  567. package/plugin/react-static/createBuildLoader.ts +157 -48
  568. package/plugin/react-static/plugin.ts +368 -357
  569. package/plugin/react-static/renderPage.ts +43 -24
  570. package/plugin/react-static/renderPages.ts +21 -14
  571. package/plugin/react-static/renderStreams.ts +13 -15
  572. package/plugin/react-static/rscToHtmlStream.ts +4 -6
  573. package/plugin/react-static/types.ts +0 -3
  574. package/plugin/transformer/README.md +82 -8
  575. package/plugin/transformer/plugin.server.ts +55 -82
  576. package/plugin/types/css-tracking.ts +1 -1
  577. package/plugin/types/global.d.ts +2 -2
  578. package/plugin/types/react-server-dom-esm.d.ts +12 -13
  579. package/plugin/types.ts +685 -309
  580. package/plugin/utils/createCallServer.ts +5 -5
  581. package/plugin/utils/createReactFetcher.ts +4 -6
  582. package/plugin/utils/index.ts +2 -1
  583. package/plugin/utils/routeToURL.ts +34 -0
  584. package/plugin/utils/urls.ts +9 -6
  585. package/plugin/worker/createWorker.ts +67 -34
  586. package/plugin/worker/html/README.md +10 -0
  587. package/plugin/worker/html/createHtmlWorkerRenderState.tsx +7 -4
  588. package/plugin/worker/html/html-worker.development.tsx +4 -3
  589. package/plugin/worker/html/index.ts +3 -1
  590. package/plugin/worker/html/messageHandler.tsx +10 -16
  591. package/plugin/worker/html/sendHtmlWorkerMessage.ts +8 -0
  592. package/plugin/worker/html/types.ts +67 -1
  593. package/plugin/worker/index.ts +2 -0
  594. package/plugin/worker/registerLoaders.ts +3 -3
  595. package/plugin/worker/rsc/README.md +203 -1
  596. package/plugin/worker/rsc/handleRender.ts +76 -39
  597. package/plugin/worker/rsc/handlers.ts +30 -22
  598. package/plugin/worker/rsc/index.ts +2 -0
  599. package/plugin/worker/rsc/messageHandler.tsx +17 -10
  600. package/plugin/worker/rsc/rsc-worker.development.ts +104 -17
  601. package/plugin/worker/rsc/sendRscWorkerMessage.ts +7 -0
  602. package/plugin/worker/rsc/state.ts +1 -1
  603. package/plugin/worker/rsc/types.ts +185 -0
  604. package/plugin/worker/rsc/userOptions.ts +2 -3
  605. package/plugin/worker/sendMessage.ts +23 -14
  606. package/plugin/worker/types.ts +131 -386
  607. package/scripts/check-react-version.mjs +3 -3
  608. package/scripts/fix-unused-imports.mjs +77 -0
  609. package/tsconfig.json +1 -1
  610. package/dist/_virtual/dynamic-import-helper.js.map +0 -1
  611. package/dist/client.js.map +0 -1
  612. package/dist/index.js.map +0 -1
  613. package/dist/plugin/components/css-collector-elements.d.ts.map +0 -1
  614. package/dist/plugin/components/css-collector-elements.js +0 -33
  615. package/dist/plugin/components/css-collector-elements.js.map +0 -1
  616. package/dist/plugin/components/css-collector.d.ts +0 -7
  617. package/dist/plugin/components/css-collector.d.ts.map +0 -1
  618. package/dist/plugin/components/css-collector.js +0 -18
  619. package/dist/plugin/components/css-collector.js.map +0 -1
  620. package/dist/plugin/components/html.js.map +0 -1
  621. package/dist/plugin/components.js +0 -9
  622. package/dist/plugin/components.js.map +0 -1
  623. package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +0 -1
  624. package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +0 -1
  625. package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +0 -1
  626. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +0 -1
  627. package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +0 -1
  628. package/dist/plugin/config/defaults.js.map +0 -1
  629. package/dist/plugin/config/extMap.js.map +0 -1
  630. package/dist/plugin/config/getCondition.js.map +0 -1
  631. package/dist/plugin/config/getPaths.js.map +0 -1
  632. package/dist/plugin/config/mimeTypes.js.map +0 -1
  633. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +0 -5
  634. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +0 -1
  635. package/dist/plugin/config/resolveAutoDiscoverMatcher.js +0 -25
  636. package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +0 -1
  637. package/dist/plugin/config/resolveEnv.js.map +0 -1
  638. package/dist/plugin/config/resolveOptions.js.map +0 -1
  639. package/dist/plugin/config/resolvePages.js.map +0 -1
  640. package/dist/plugin/config/resolveUrlOption.js.map +0 -1
  641. package/dist/plugin/config/resolveUserConfig.js.map +0 -1
  642. package/dist/plugin/config.js +0 -17
  643. package/dist/plugin/config.js.map +0 -1
  644. package/dist/plugin/env.js +0 -79
  645. package/dist/plugin/env.js.map +0 -1
  646. package/dist/plugin/error/toError.js.map +0 -1
  647. package/dist/plugin/file-preserver.js +0 -96
  648. package/dist/plugin/file-preserver.js.map +0 -1
  649. package/dist/plugin/helpers/cleanObject.js.map +0 -1
  650. package/dist/plugin/helpers/collectManifestCss.js.map +0 -1
  651. package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +0 -1
  652. package/dist/plugin/helpers/createCssProps.js.map +0 -1
  653. package/dist/plugin/helpers/createEventHandler.js.map +0 -1
  654. package/dist/plugin/helpers/createHandler.js.map +0 -1
  655. package/dist/plugin/helpers/createRscStream.js.map +0 -1
  656. package/dist/plugin/helpers/formatMetrics.js.map +0 -1
  657. package/dist/plugin/helpers/getBundleManifest.js.map +0 -1
  658. package/dist/plugin/helpers/getRouteFiles.js.map +0 -1
  659. package/dist/plugin/helpers/handleServerAction.js.map +0 -1
  660. package/dist/plugin/helpers/inputNormalizer.js.map +0 -1
  661. package/dist/plugin/helpers/metrics.js.map +0 -1
  662. package/dist/plugin/helpers/moduleRefs.js.map +0 -1
  663. package/dist/plugin/helpers/requestInfo.js.map +0 -1
  664. package/dist/plugin/helpers/requestToRoute.js.map +0 -1
  665. package/dist/plugin/helpers/resolvePage.js.map +0 -1
  666. package/dist/plugin/helpers/resolvePageAndProps.js.map +0 -1
  667. package/dist/plugin/helpers/resolveProps.js.map +0 -1
  668. package/dist/plugin/helpers/serializeUserOptions.js.map +0 -1
  669. package/dist/plugin/helpers/sourceMap.d.ts +0 -8
  670. package/dist/plugin/helpers/sourceMap.d.ts.map +0 -1
  671. package/dist/plugin/helpers/sourceMap.js +0 -136
  672. package/dist/plugin/helpers/stashReturnValue.js.map +0 -1
  673. package/dist/plugin/helpers/tryManifest.js.map +0 -1
  674. package/dist/plugin/helpers.js +0 -27
  675. package/dist/plugin/helpers.js.map +0 -1
  676. package/dist/plugin/loader/css-loader.development.d.ts.map +0 -1
  677. package/dist/plugin/loader/css-loader.development.js +0 -76
  678. package/dist/plugin/loader/css-loader.development.js.map +0 -1
  679. package/dist/plugin/loader/css-loader.production.d.ts +0 -31
  680. package/dist/plugin/loader/css-loader.production.d.ts.map +0 -1
  681. package/dist/plugin/loader/css-loader.production.js +0 -45
  682. package/dist/plugin/loader/css-loader.production.js.map +0 -1
  683. package/dist/plugin/loader/env-loader.development.d.ts +0 -13
  684. package/dist/plugin/loader/env-loader.development.d.ts.map +0 -1
  685. package/dist/plugin/loader/env-loader.development.js +0 -68
  686. package/dist/plugin/loader/handleExports.d.ts +0 -40
  687. package/dist/plugin/loader/handleExports.d.ts.map +0 -1
  688. package/dist/plugin/loader/handleExports.js +0 -209
  689. package/dist/plugin/loader/handleExports.js.map +0 -1
  690. package/dist/plugin/loader/parse.js.map +0 -1
  691. package/dist/plugin/loader/react-loader.client.d.ts +0 -2
  692. package/dist/plugin/loader/react-loader.client.d.ts.map +0 -1
  693. package/dist/plugin/loader/react-loader.client.js +0 -2
  694. package/dist/plugin/loader/react-loader.js.map +0 -1
  695. package/dist/plugin/loader/react-loader.server.d.ts +0 -21
  696. package/dist/plugin/loader/react-loader.server.d.ts.map +0 -1
  697. package/dist/plugin/loader/react-loader.server.js +0 -131
  698. package/dist/plugin/loader/transformModuleIfNeeded.js.map +0 -1
  699. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +0 -48
  700. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +0 -1
  701. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +0 -431
  702. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +0 -1
  703. package/dist/plugin/metrics/formatMetrics.js.map +0 -1
  704. package/dist/plugin/metrics.js +0 -7
  705. package/dist/plugin/metrics.js.map +0 -1
  706. package/dist/plugin/plugin.client.js.map +0 -1
  707. package/dist/plugin/plugin.server.js.map +0 -1
  708. package/dist/plugin/preserver/plugin.js.map +0 -1
  709. package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +0 -1
  710. package/dist/plugin/react-client/createMessageHandlers.js.map +0 -1
  711. package/dist/plugin/react-client/createWorkerStream.js.map +0 -1
  712. package/dist/plugin/react-client/handleWorkerRscStream.js.map +0 -1
  713. package/dist/plugin/react-client/handleWorkerServerAction.js.map +0 -1
  714. package/dist/plugin/react-client/plugin.js.map +0 -1
  715. package/dist/plugin/react-client/restartWorker.js.map +0 -1
  716. package/dist/plugin/react-server/configureReactServer.js.map +0 -1
  717. package/dist/plugin/react-server/handleServerAction.js.map +0 -1
  718. package/dist/plugin/react-server/plugin.js.map +0 -1
  719. package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +0 -1
  720. package/dist/plugin/react-static/collectRscContent.js.map +0 -1
  721. package/dist/plugin/react-static/configurePreviewServer.js.map +0 -1
  722. package/dist/plugin/react-static/createBuildLoader.js.map +0 -1
  723. package/dist/plugin/react-static/fileWriter.js.map +0 -1
  724. package/dist/plugin/react-static/plugin.js.map +0 -1
  725. package/dist/plugin/react-static/renderPage.js.map +0 -1
  726. package/dist/plugin/react-static/renderPages.js.map +0 -1
  727. package/dist/plugin/react-static/renderStreams.js.map +0 -1
  728. package/dist/plugin/react-static/rscToHtmlStream.js.map +0 -1
  729. package/dist/plugin/react-static/temporaryReferences.js.map +0 -1
  730. package/dist/plugin/root.js.map +0 -1
  731. package/dist/plugin/source-map/createMappingsSerializer.d.ts +0 -2
  732. package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +0 -1
  733. package/dist/plugin/source-map/createMappingsSerializer.js +0 -129
  734. package/dist/plugin/source-map/createMappingsSerializer.js.map +0 -1
  735. package/dist/plugin/source-map/readMappings.d.ts +0 -2
  736. package/dist/plugin/source-map/readMappings.d.ts.map +0 -1
  737. package/dist/plugin/source-map/readMappings.js +0 -200
  738. package/dist/plugin/transformer/plugin.client.d.ts +0 -2
  739. package/dist/plugin/transformer/plugin.client.d.ts.map +0 -1
  740. package/dist/plugin/transformer/plugin.js.map +0 -1
  741. package/dist/plugin/transformer/plugin.server.js.map +0 -1
  742. package/dist/plugin/utils/callServer.js.map +0 -1
  743. package/dist/plugin/utils/createCallServer.js.map +0 -1
  744. package/dist/plugin/utils/createReactFetcher.js.map +0 -1
  745. package/dist/plugin/utils/env.js.map +0 -1
  746. package/dist/plugin/utils/envUrls.node.js.map +0 -1
  747. package/dist/plugin/utils/urls.js.map +0 -1
  748. package/dist/plugin/utils.js +0 -11
  749. package/dist/plugin/utils.js.map +0 -1
  750. package/dist/plugin/vendor/vendor.client.js.map +0 -1
  751. package/dist/plugin/vendor/vendor.js.map +0 -1
  752. package/dist/plugin/vendor/vendor.server.js.map +0 -1
  753. package/dist/plugin/vendor.js +0 -7
  754. package/dist/plugin/vendor.js.map +0 -1
  755. package/dist/plugin/worker/createWorker.js.map +0 -1
  756. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +0 -1
  757. package/dist/plugin/worker/html/html-worker.development.js.map +0 -1
  758. package/dist/plugin/worker/html/html-worker.production.js.map +0 -1
  759. package/dist/plugin/worker/html/index.js.map +0 -1
  760. package/dist/plugin/worker/html/messageHandler.js.map +0 -1
  761. package/dist/plugin/worker/rsc/handleRender.js.map +0 -1
  762. package/dist/plugin/worker/rsc/handlers.js.map +0 -1
  763. package/dist/plugin/worker/rsc/index.js.map +0 -1
  764. package/dist/plugin/worker/rsc/messageHandler.js.map +0 -1
  765. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +0 -1
  766. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +0 -1
  767. package/dist/plugin/worker/rsc/state.js.map +0 -1
  768. package/dist/plugin/worker/rsc/userOptions.js.map +0 -1
  769. package/dist/plugin/worker/sendMessage.js.map +0 -1
  770. package/dist/server.js.map +0 -1
  771. package/plugin/components/css-collector.tsx +0 -20
  772. package/plugin/config/resolveAutoDiscoverMatcher.ts +0 -23
  773. package/plugin/helpers/sourceMap.ts +0 -182
  774. package/plugin/loader/css-loader.development.ts +0 -135
  775. package/plugin/loader/css-loader.production.ts +0 -84
  776. package/plugin/loader/handleExports.ts +0 -309
  777. package/plugin/loader/react-loader.client.ts +0 -1
  778. package/plugin/loader/react-loader.server.ts +0 -185
  779. package/plugin/loader/transformModuleWithPreservedFunctions.ts +0 -596
  780. package/plugin/source-map/createMappingsSerializer.ts +0 -181
  781. package/plugin/source-map/readMappings.ts +0 -194
  782. package/plugin/transformer/plugin.client.ts +0 -0
  783. /package/dist/plugin/{transformer/plugin.client.js → loader/directives/types.js} +0 -0
@@ -1,21 +0,0 @@
1
- import type { LoaderContext, SerializedUserOptions } from "../types.js";
2
- import type { ModuleInfo } from "rollup";
3
- import type { MessagePort } from "node:worker_threads";
4
- export interface LoaderOptions {
5
- id: string;
6
- resolveDependencies?: boolean;
7
- format?: string;
8
- conditions?: string[];
9
- importAssertions?: Record<string, any>;
10
- importAttributes?: Record<string, any>;
11
- source: string;
12
- }
13
- export type LoaderFunction = (options: LoaderOptions) => Promise<ModuleInfo>;
14
- export declare function initialize(data: {
15
- id: string;
16
- port: MessagePort;
17
- userOptions: SerializedUserOptions;
18
- }): Promise<void>;
19
- export declare function load(url: string, context: LoaderContext, nextLoad: any): Promise<any>;
20
- export declare function resolve(specifier: string, context: any, nextResolve: any): Promise<any>;
21
- //# sourceMappingURL=react-loader.server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-loader.server.d.ts","sourceRoot":"","sources":["../../../plugin/loader/react-loader.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAUvD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAI7E,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,qBAAqB,CAAC;CACpC,iBAgBA;AAED,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,gBAmH5E;AAED,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,GAAG,gBAWjB"}
@@ -1,131 +0,0 @@
1
- import { transformModuleIfNeeded } from "./transformModuleIfNeeded.js";
2
- import { fileURLToPath } from "node:url";
3
- import { join } from "node:path";
4
- import { resolveOptions } from "../config/resolveOptions.js";
5
- import { hydrateUserOptions } from "../helpers/index.js";
6
- let userOptions;
7
- let loaderPort;
8
- export async function initialize(data) {
9
- if (userOptions?.verbose) {
10
- console.log("[react-loader] Initializing with options:", data.id);
11
- }
12
- const resolvedUserOptions = resolveOptions(hydrateUserOptions(data.userOptions));
13
- if (resolvedUserOptions.type === "error") {
14
- throw new Error(resolvedUserOptions.error.message);
15
- }
16
- userOptions = resolvedUserOptions.userOptions;
17
- loaderPort = data.port;
18
- loaderPort.postMessage({
19
- type: "INITIALIZED_REACT_LOADER",
20
- id: data.id,
21
- });
22
- }
23
- export async function load(url, context, nextLoad) {
24
- if (userOptions?.verbose) {
25
- console.log("[react-loader] Attempting to load:", url);
26
- console.log("[react-loader] Context:", {
27
- format: context.format,
28
- conditions: context.conditions,
29
- });
30
- }
31
- const { format } = context;
32
- if (format === "module" || format === "module-typescript") {
33
- if (userOptions?.verbose) {
34
- console.log("[react-loader] Loading module:", url);
35
- }
36
- const result = await nextLoad(url, context);
37
- if (userOptions?.verbose) {
38
- console.log("[react-loader] Next load result:", {
39
- format: result.format,
40
- shortCircuit: result.shortCircuit,
41
- source: typeof result.source,
42
- });
43
- }
44
- const source = typeof result.source === "string"
45
- ? result.source
46
- : result.source instanceof Uint8Array
47
- ? new TextDecoder().decode(result.source)
48
- : String(result.source);
49
- const isServer = userOptions?.autoDiscover?.isServerFunctionCode(source);
50
- const isClient = userOptions?.autoDiscover?.isClientComponentCode(source);
51
- if (userOptions?.verbose) {
52
- console.log("[react-loader] Module analysis:", {
53
- url,
54
- isServer,
55
- isClient,
56
- sourceLength: source.length,
57
- sourcePreview: source.slice(0, 100) + "...",
58
- });
59
- }
60
- if (!isServer && !isClient) {
61
- if (userOptions?.verbose) {
62
- console.log("[react-loader] Skipping non-server/non-client module:", url);
63
- }
64
- return result;
65
- }
66
- // Handle file URLs
67
- const filePath = url.startsWith("file://") ? fileURLToPath(url) : url;
68
- if (userOptions?.verbose) {
69
- console.log("[react-loader] File path:", filePath);
70
- }
71
- // Normalize the URL using the same logic as plugin.server.ts
72
- let moduleID = filePath;
73
- let finalID = filePath;
74
- if (userOptions?.normalizer) {
75
- const [, value] = userOptions.normalizer(filePath);
76
- moduleID = join(userOptions.moduleBasePath, value);
77
- finalID = userOptions.moduleID(moduleID);
78
- if (userOptions?.verbose) {
79
- console.log("[react-loader] Normalized IDs:", { moduleID, finalID });
80
- }
81
- }
82
- const transformed = transformModuleIfNeeded(source, finalID, isServer, isClient, true // isServerEnvironment
83
- );
84
- if (userOptions?.verbose) {
85
- console.log("[react-loader] Transformation result:", {
86
- originalLength: source.length,
87
- transformedLength: transformed.length,
88
- wasTransformed: source !== transformed,
89
- });
90
- }
91
- if (loaderPort) {
92
- if (userOptions?.verbose) {
93
- console.log("[react-loader] Sending SERVER_MODULE message");
94
- }
95
- loaderPort.postMessage({
96
- type: "SERVER_MODULE",
97
- id: finalID,
98
- url: filePath,
99
- source: transformed,
100
- });
101
- }
102
- // If we have a source map, update it to point to the transformed source
103
- const map = result.map
104
- ? {
105
- ...result.map,
106
- sourcesContent: [transformed],
107
- mappings: result.map.mappings,
108
- }
109
- : null;
110
- return {
111
- ...result,
112
- source: transformed,
113
- map,
114
- };
115
- }
116
- if (userOptions?.verbose) {
117
- console.log("[react-loader] Skipping non-module format:", format);
118
- }
119
- return nextLoad(url, context);
120
- }
121
- export async function resolve(specifier, context, nextResolve) {
122
- if (userOptions?.verbose) {
123
- console.log("[react-loader] Resolving:", specifier);
124
- console.log("[react-loader] Resolve context:", context);
125
- }
126
- const result = await nextResolve(specifier, context);
127
- if (userOptions?.verbose) {
128
- console.log("[react-loader] Resolve result:", result);
129
- }
130
- return result;
131
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformModuleIfNeeded.js","sources":["../../../plugin/loader/transformModuleIfNeeded.ts"],"sourcesContent":["import { getCondition } from \"../config/getCondition.js\";\nimport { transformModuleWithPreservedFunctions } from \"./transformModuleWithPreservedFunctions.js\";\nimport { parse } from \"./parse.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\n// --- React RSC Directive Handling ---\n//\n// 1. 'use client' at file top:\n// - Pass through code as-is (after removing directive).\n// - Do not transform or register anything.\n// - Required for React client features to work.\n// - See: https://react.dev/reference/rsc/use-client\n//\n// 2. 'use server' at file top:\n// - Register all exported async functions as server actions.\n// - See: https://react.dev/reference/rsc/use-server\n//\n// 3. 'use server' at function top:\n// - Register only that async function as a server action.\n// - See: https://react.dev/reference/rsc/use-server\n//\n// 4. No directive:\n// - Treat as a normal shared or server-only module.\n// - No special registration or transformation.\n\nexport function transformModuleIfNeeded(\n source: string,\n moduleId: string,\n isServerFunction: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isServerFunctionCode(source, moduleId),\n isClientComponent: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isClientComponentCode(source, moduleId),\n isServerEnvironment = getCondition() === \"react-server\"\n) {\n // Handle environment-specific cases\n if (isServerEnvironment) {\n // In server environment:\n // - Server functions need transformation\n // - Client components need transformation\n // - Other modules can pass through\n if (!isServerFunction && !isClientComponent) {\n return source;\n }\n } else {\n // In client environment:\n // - Only client components should pass through\n // - Server functions should be transformed\n if (isClientComponent) {\n return source;\n }\n }\n\n try {\n const result = transformModuleWithPreservedFunctions(\n source,\n moduleId,\n parse(source),\n isServerFunction,\n isClientComponent\n );\n return result;\n } catch (error) {\n // Log the error and rethrow\n console.error(`Error transforming module ${moduleId}:`, error);\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAyBO,SAAS,uBAAA,CACd,QACA,QACA,EAAA,gBAAA,GAAsD,eAAe,aAAc,CAAA,oBAAA,CAAqB,QAAQ,QAAQ,CAAA,EACxH,oBAAuD,cAAe,CAAA,aAAA,CAAc,sBAAsB,MAAQ,EAAA,QAAQ,GAC1H,mBAAsB,GAAA,YAAA,OAAmB,cACzC,EAAA;AAEA,EAAA,IAAI,mBAAqB,EAAA;AAKvB,IAAI,IAAA,CAAC,gBAAoB,IAAA,CAAC,iBAAmB,EAAA;AAC3C,MAAO,OAAA,MAAA;AAAA;AACT,GACK,MAAA;AAIL,IAAA,IAAI,iBAAmB,EAAA;AACrB,MAAO,OAAA,MAAA;AAAA;AACT;AAGF,EAAI,IAAA;AACF,IAAA,MAAM,MAAS,GAAA,qCAAA;AAAA,MACb,MAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAM,MAAM,CAAA;AAAA,MACZ,gBAAA;AAAA,MACA;AAAA,KACF;AACA,IAAO,OAAA,MAAA;AAAA,WACA,KAAO,EAAA;AAEd,IAAA,OAAA,CAAQ,KAAM,CAAA,CAAA,0BAAA,EAA6B,QAAQ,CAAA,CAAA,CAAA,EAAK,KAAK,CAAA;AAC7D,IAAM,MAAA,KAAA;AAAA;AAEV;;;;"}
@@ -1,48 +0,0 @@
1
- import type { Program } from "./types.js";
2
- export interface TransformOptions {
3
- id: string;
4
- exportNames: string[];
5
- beforeExports: string;
6
- afterExports: string;
7
- isServerModule?: boolean;
8
- isClientModule?: boolean;
9
- program?: Program;
10
- }
11
- /**
12
- * --- React RSC Directive Handling ---
13
- *
14
- * 1. 'use client' at file top:
15
- * - Pass through code as-is (after removing directive).
16
- * - Do not transform or register anything.
17
- * - Required for React client features to work.
18
- * - See: https://react.dev/reference/rsc/use-client
19
- *
20
- * 2. 'use server' at file top:
21
- * - Register all exported async functions as server actions.
22
- * - See: https://react.dev/reference/rsc/use-server#caveats
23
- *
24
- * 3. 'use server' at function top:
25
- * - Register only that async function as a server action.
26
- * - See: https://react.dev/reference/rsc/use-server#caveats
27
- *
28
- * 4. No directive:
29
- * - Treat as a normal shared or server-only module.
30
- * - No special registration or transformation.
31
- */
32
- /**
33
- * Transforms a module for RSC boundaries.
34
- * - Server modules: exports are wrapped with server references while preserving functionality.
35
- * - Client modules: exports are replaced with client references or errors, depending on environment.
36
- * - Only the correct references are exported; implementation is never leaked across boundaries.
37
- *
38
- * @param source - The original module source code.
39
- * @param moduleId - The module's unique identifier.
40
- * @param url - The module's URL.
41
- * @param program - The parsed AST.
42
- * @param map - The source map for the source code.
43
- * @param isServerFunction - Whether the module is a server function.
44
- * @param isClientComponent - Whether the module is a client component.
45
- * @returns The transformed source code.
46
- */
47
- export declare function transformModuleWithPreservedFunctions(source: string, moduleId: string, program: Program, isServerFunction: boolean | RegExpMatchArray | null, isClientComponent: boolean | RegExpMatchArray | null): string;
48
- //# sourceMappingURL=transformModuleWithPreservedFunctions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformModuleWithPreservedFunctions.d.ts","sourceRoot":"","sources":["../../../plugin/loader/transformModuleWithPreservedFunctions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAuDD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,EACnD,iBAAiB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,GACnD,MAAM,CAmdR"}
@@ -1,431 +0,0 @@
1
- /**
2
- * vite-plugin-react-server
3
- * Copyright (c) Nico Brinkkemper
4
- * MIT License
5
- */
6
- import { handleExports } from './handleExports.js';
7
- import { createMappingsSerializer } from '../source-map/createMappingsSerializer.js';
8
-
9
- function generateSourceMap(moduleId, source, lines, mappingInfos, originalSourceMap) {
10
- const createMapping = createMappingsSerializer();
11
- let mappings = "";
12
- for (let i = 0; i < lines.length; i++) {
13
- const info = mappingInfos[i] || { generatedLine: i + 1, originalLine: 1, originalColumn: 0 };
14
- mappings += createMapping(
15
- info.generatedLine,
16
- 0,
17
- 0,
18
- // sourceIndex
19
- info.originalLine,
20
- info.originalColumn,
21
- -1
22
- // nameIndex
23
- );
24
- }
25
- mappings += createMapping(
26
- lines.length + 1,
27
- 0,
28
- 0,
29
- source.split("\n").length,
30
- 0,
31
- -1
32
- );
33
- const sourceMap = {
34
- version: 3,
35
- file: moduleId,
36
- sources: originalSourceMap?.sources || [moduleId],
37
- sourcesContent: originalSourceMap?.sourcesContent || [source],
38
- mappings,
39
- sourceRoot: originalSourceMap?.sourceRoot || "",
40
- names: originalSourceMap?.names || []
41
- };
42
- return `data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(sourceMap)).toString("base64")}`;
43
- }
44
- function transformModuleWithPreservedFunctions(source, moduleId, program, isServerFunction, isClientComponent) {
45
- let sourceMappingURL = null;
46
- let sourceMappingStart = 0;
47
- let sourceMappingEnd = 0;
48
- let sourceMappingLines = 0;
49
- let originalSourceMap = null;
50
- const sourceMapMatch = source.match(/\/\/[#@] sourceMappingURL=(.+)$/m);
51
- if (sourceMapMatch) {
52
- sourceMappingURL = sourceMapMatch[1];
53
- sourceMappingStart = sourceMapMatch.index;
54
- sourceMappingEnd = sourceMapMatch.index + sourceMapMatch[0].length;
55
- sourceMappingLines = sourceMapMatch[0].split("\n").length - 1;
56
- if (sourceMappingURL.startsWith("data:application/json;base64,")) {
57
- const base64 = sourceMappingURL.slice("data:application/json;base64,".length);
58
- originalSourceMap = JSON.parse(Buffer.from(base64, "base64").toString());
59
- }
60
- }
61
- let sourceWithoutMap = source;
62
- if (sourceMappingStart > 0) {
63
- sourceWithoutMap = source.slice(0, sourceMappingStart) + "\n".repeat(sourceMappingLines) + source.slice(sourceMappingEnd);
64
- }
65
- let sourceWithoutDirective = sourceWithoutMap;
66
- let directiveEnd = 0;
67
- let hasFileLevelServerDirective = false;
68
- let hasFileLevelClientDirective = false;
69
- let hasFunctionLevelClientDirective = false;
70
- let hasFunctionLevelServerDirective = false;
71
- const { exportNames, exports } = handleExports(
72
- sourceWithoutDirective,
73
- program,
74
- isServerFunction,
75
- isClientComponent
76
- );
77
- const moduleIdLiteral = JSON.stringify(moduleId);
78
- function checkForDirective(node) {
79
- if (node.type === "ExpressionStatement") {
80
- if ("directive" in node && typeof node.directive === "string") {
81
- return node.directive;
82
- } else if (node.expression.type === "Literal" && typeof node.expression.value === "string" && (node.expression.value === "use server" || node.expression.value === "use client")) {
83
- return node.expression.value;
84
- }
85
- }
86
- return null;
87
- }
88
- for (const node of program.body) {
89
- const directive = checkForDirective(node);
90
- if (directive) {
91
- if (directive === "use server") {
92
- if (node.start === 0) {
93
- hasFileLevelServerDirective = true;
94
- } else {
95
- hasFunctionLevelServerDirective = true;
96
- }
97
- }
98
- if (directive === "use client") {
99
- if (node.start === 0) {
100
- hasFileLevelClientDirective = true;
101
- } else {
102
- hasFunctionLevelClientDirective = true;
103
- }
104
- }
105
- if ("start" in node && "end" in node) {
106
- directiveEnd = Math.max(directiveEnd, node.end);
107
- }
108
- }
109
- if (node.type === "ExportNamedDeclaration" && node.declaration?.type === "FunctionDeclaration") {
110
- const funcNode = node.declaration;
111
- if (funcNode.body?.body) {
112
- for (const stmt of funcNode.body.body) {
113
- const directive2 = checkForDirective(stmt);
114
- if (directive2 === "use server") {
115
- hasFunctionLevelServerDirective = true;
116
- const name = funcNode.id?.name;
117
- if (name) {
118
- const exportInfo = exports.get(name);
119
- if (exportInfo) {
120
- exportInfo.declaration = exportInfo.declaration?.replace(
121
- /^export\s+function\s+/,
122
- "export async function "
123
- );
124
- exportInfo.isAsync = true;
125
- }
126
- }
127
- break;
128
- }
129
- }
130
- }
131
- } else if (node.type === "FunctionDeclaration") {
132
- if (node.body?.body) {
133
- for (const stmt of node.body.body) {
134
- const directive2 = checkForDirective(stmt);
135
- if (directive2 === "use server") {
136
- hasFunctionLevelServerDirective = true;
137
- const name = node.id?.name;
138
- if (name) {
139
- const exportInfo = exports.get(name);
140
- if (exportInfo) {
141
- exportInfo.declaration = exportInfo.declaration?.replace(
142
- /^export\s+function\s+/,
143
- "export async function "
144
- );
145
- exportInfo.isAsync = true;
146
- }
147
- }
148
- break;
149
- }
150
- }
151
- }
152
- } else if (node.type === "VariableDeclaration") {
153
- for (const decl of node.declarations) {
154
- if (decl.init?.type === "FunctionExpression" || decl.init?.type === "ArrowFunctionExpression") {
155
- const body = decl.init.body;
156
- if (body.type === "BlockStatement" && body.body) {
157
- for (const stmt of body.body) {
158
- const directive2 = checkForDirective(stmt);
159
- if (directive2 === "use server") {
160
- hasFunctionLevelServerDirective = true;
161
- const name = decl.id.type === "Identifier" ? decl.id.name : void 0;
162
- if (name) {
163
- const exportInfo = exports.get(name);
164
- if (exportInfo) {
165
- exportInfo.declaration = exportInfo.declaration?.replace(
166
- /^export\s+function\s+/,
167
- "export async function "
168
- );
169
- exportInfo.isAsync = true;
170
- }
171
- }
172
- break;
173
- }
174
- }
175
- }
176
- }
177
- }
178
- }
179
- }
180
- if (hasFileLevelClientDirective && hasFileLevelServerDirective) {
181
- throw new Error(`Module ${moduleId} cannot have both "use client" and "use server" directives`);
182
- }
183
- if (hasFunctionLevelClientDirective) {
184
- throw new Error(`Module ${moduleId} cannot have function-level "use client" directives - only file-level is allowed`);
185
- }
186
- if (Boolean(isClientComponent) && !hasFileLevelClientDirective) {
187
- throw new Error(`Module ${moduleId} is marked as a client component but has no "use client" directive`);
188
- }
189
- if (Boolean(isServerFunction) && !hasFileLevelServerDirective && !hasFunctionLevelServerDirective) {
190
- if (process.env["NODE_ENV"] !== "production") {
191
- console.log("Error for file", moduleId, source);
192
- }
193
- throw new Error(`Module ${moduleId} is marked as a server function but has no "use server" directive`);
194
- }
195
- if (directiveEnd > 0) {
196
- sourceWithoutDirective = source.slice(directiveEnd).trim();
197
- }
198
- if (Boolean(isClientComponent) && exportNames.length === 0) {
199
- throw new Error(`Module ${moduleId} is marked as a client component but has no exports to transform`);
200
- }
201
- if (Boolean(isServerFunction) && exportNames.length === 0) {
202
- throw new Error(`Module ${moduleId} is marked as a server function but has no exports to transform`);
203
- }
204
- if (Boolean(isClientComponent)) {
205
- const output = [];
206
- const mappingInfos = [];
207
- const clientImport = process.env["NODE_ENV"] === "production" ? 'import { registerClientReference } from "react-server-dom-esm/server";' : 'import { registerClientReference } from "react-server-dom-esm/server.node";';
208
- output.push(clientImport);
209
- mappingInfos.push({ generatedLine: 1, originalLine: 1, originalColumn: 0 });
210
- let lineNum = 2;
211
- for (const name of exportNames) {
212
- const exportInfo = exports.get(name);
213
- if (exportInfo) {
214
- const exportName = name === "default" && exportInfo.localName ? exportInfo.localName : name;
215
- if (name === "default") {
216
- output.push(
217
- `export default registerClientReference(function() {throw new Error("Attempted to call the default export of ${moduleIdLiteral} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");}, ${moduleIdLiteral}, "default");`
218
- );
219
- } else {
220
- output.push(
221
- `export const ${exportName} = registerClientReference(function() {throw new Error("Attempted to call ${exportName}() from the server but ${exportName} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");}, ${moduleIdLiteral}, ${JSON.stringify(name)});`
222
- );
223
- }
224
- mappingInfos.push({
225
- generatedLine: lineNum,
226
- originalLine: exportInfo.loc?.line || 1,
227
- originalColumn: exportInfo.loc?.column || 0
228
- });
229
- lineNum++;
230
- }
231
- }
232
- const newClientSource = output.join("\n\n");
233
- const sourceMapBase64 = generateSourceMap(
234
- moduleId,
235
- source,
236
- output,
237
- mappingInfos,
238
- originalSourceMap
239
- );
240
- return `${newClientSource}
241
- //# sourceMappingURL=${sourceMapBase64}`;
242
- }
243
- if (Boolean(isServerFunction)) {
244
- let hasServerDirective = function(node) {
245
- if (hasFileLevelServerDirective) return true;
246
- if (node.body?.body) {
247
- for (const stmt of node.body.body) {
248
- const directive = checkForDirective(stmt);
249
- if (directive === "use server") return true;
250
- }
251
- }
252
- return false;
253
- };
254
- const exportedEntries = [];
255
- const localNames = /* @__PURE__ */ new Set();
256
- let newSource = source;
257
- let directiveEnd2 = 0;
258
- for (const node of program.body) {
259
- const directive = checkForDirective(node);
260
- if (directive === "use server" || directive === "use client") {
261
- if (node.start === 0) {
262
- directiveEnd2 = node.end;
263
- } else {
264
- newSource = newSource.slice(0, node.start) + newSource.slice(node.end);
265
- }
266
- continue;
267
- }
268
- switch (node.type) {
269
- case "ExportDefaultDeclaration":
270
- if (node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
271
- const name = node.declaration.id.name;
272
- if (hasServerDirective(node.declaration)) {
273
- exportedEntries.push({
274
- localName: name,
275
- exportedName: "default",
276
- type: "function",
277
- loc: node.declaration.id.loc?.start || { line: 1, column: 0 }
278
- });
279
- localNames.add(name);
280
- }
281
- } else if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
282
- const name = node.declaration.id.name;
283
- exportedEntries.push({
284
- localName: name,
285
- exportedName: "default",
286
- type: "class",
287
- loc: node.declaration.id.loc?.start || { line: 1, column: 0 }
288
- });
289
- localNames.add(name);
290
- }
291
- break;
292
- case "ExportNamedDeclaration":
293
- if (node.declaration) {
294
- if (node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
295
- const name = node.declaration.id.name;
296
- if (hasServerDirective(node.declaration)) {
297
- exportedEntries.push({
298
- localName: name,
299
- exportedName: name,
300
- type: "function",
301
- loc: node.declaration.id.loc?.start || { line: 1, column: 0 }
302
- });
303
- localNames.add(name);
304
- }
305
- } else if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
306
- const name = node.declaration.id.name;
307
- exportedEntries.push({
308
- localName: name,
309
- exportedName: name,
310
- type: "class",
311
- loc: node.declaration.id.loc?.start || { line: 1, column: 0 }
312
- });
313
- localNames.add(name);
314
- } else if (node.declaration.type === "VariableDeclaration") {
315
- for (const decl of node.declaration.declarations) {
316
- if (decl.id.type === "Identifier") {
317
- const name = decl.id.name;
318
- if (decl.init) {
319
- if (decl.init.type === "FunctionExpression" || decl.init.type === "ArrowFunctionExpression") {
320
- if (hasServerDirective(decl.init)) {
321
- exportedEntries.push({
322
- localName: name,
323
- exportedName: name,
324
- type: "function",
325
- loc: decl.id.loc?.start || { line: 1, column: 0 }
326
- });
327
- localNames.add(name);
328
- }
329
- } else {
330
- exportedEntries.push({
331
- localName: name,
332
- exportedName: name,
333
- type: "value",
334
- loc: decl.id.loc?.start || { line: 1, column: 0 }
335
- });
336
- localNames.add(name);
337
- }
338
- }
339
- }
340
- }
341
- }
342
- }
343
- if (node.specifiers) {
344
- for (const spec of node.specifiers) {
345
- if (spec.type === "ExportSpecifier") {
346
- const localName = spec.local.type === "Identifier" ? spec.local.name : "";
347
- const exportedName = spec.exported.type === "Identifier" ? spec.exported.name : "";
348
- if (localName && exportedName) {
349
- const originalDecl = program.body.find(
350
- (n) => n.type === "FunctionDeclaration" && n.id?.name === localName || n.type === "ClassDeclaration" && n.id?.name === localName || n.type === "VariableDeclaration" && n.declarations.some(
351
- (d) => d.id.type === "Identifier" && d.id.name === localName
352
- )
353
- );
354
- let loc = { line: 1, column: 0 };
355
- if (originalDecl) {
356
- if (originalDecl.type === "FunctionDeclaration" && hasServerDirective(originalDecl)) {
357
- loc = originalDecl.id?.loc?.start || loc;
358
- exportedEntries.push({
359
- localName,
360
- exportedName,
361
- type: "function",
362
- loc
363
- });
364
- localNames.add(localName);
365
- } else if (originalDecl.type === "ClassDeclaration") {
366
- loc = originalDecl.id?.loc?.start || loc;
367
- exportedEntries.push({
368
- localName,
369
- exportedName,
370
- type: "class",
371
- loc
372
- });
373
- localNames.add(localName);
374
- } else if (originalDecl.type === "VariableDeclaration") {
375
- const decl = originalDecl.declarations.find((d) => d.id.type === "Identifier" && d.id.name === localName);
376
- loc = decl?.id?.loc?.start || loc;
377
- exportedEntries.push({
378
- localName,
379
- exportedName,
380
- type: "value",
381
- loc
382
- });
383
- localNames.add(localName);
384
- }
385
- }
386
- }
387
- }
388
- }
389
- }
390
- break;
391
- }
392
- }
393
- if (directiveEnd2 > 0) {
394
- newSource = newSource.slice(directiveEnd2).trim();
395
- }
396
- const lines = [];
397
- const mappingInfos = [];
398
- const serverImport = process.env["NODE_ENV"] === "production" ? 'import { registerServerReference } from "react-server-dom-esm/server";' : 'import { registerServerReference } from "react-server-dom-esm/server.node";';
399
- lines.push(serverImport);
400
- mappingInfos.push({ generatedLine: 1, originalLine: 1, originalColumn: 0 });
401
- lines.push(newSource);
402
- mappingInfos.push({ generatedLine: 2, originalLine: 1, originalColumn: 0 });
403
- let lineNum = lines.length + 1;
404
- for (const entry of exportedEntries) {
405
- if (entry.type === "function") {
406
- lines.push(`if (typeof ${entry.localName} === "function") `);
407
- }
408
- lines.push(`registerServerReference(${entry.localName}, ${JSON.stringify(moduleId)}, ${JSON.stringify(entry.exportedName)});`);
409
- mappingInfos.push({
410
- generatedLine: lineNum,
411
- originalLine: entry.loc?.line || 1,
412
- originalColumn: entry.loc?.column || 0
413
- });
414
- lineNum++;
415
- }
416
- const newTransformedSource = lines.join("\n");
417
- const sourceMapBase64 = generateSourceMap(
418
- moduleId,
419
- source,
420
- lines,
421
- mappingInfos,
422
- originalSourceMap
423
- );
424
- return `${newTransformedSource}
425
- //# sourceMappingURL=${sourceMapBase64}`;
426
- }
427
- return sourceWithoutMap;
428
- }
429
-
430
- export { transformModuleWithPreservedFunctions };
431
- //# sourceMappingURL=transformModuleWithPreservedFunctions.js.map