vite-plugin-react-server 1.1.12 → 1.1.13

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 (373) hide show
  1. package/dist/package.json +10 -8
  2. package/dist/plugin/components/css-collector-elements.d.ts +4 -2
  3. package/dist/plugin/components/css-collector-elements.d.ts.map +1 -1
  4. package/dist/plugin/components/css-collector-elements.js +21 -7
  5. package/dist/plugin/components/css-collector-elements.js.map +1 -1
  6. package/dist/plugin/components/css-collector.d.ts +4 -5
  7. package/dist/plugin/components/css-collector.d.ts.map +1 -1
  8. package/dist/plugin/components/css-collector.js +5 -9
  9. package/dist/plugin/components/css-collector.js.map +1 -1
  10. package/dist/plugin/components/html.d.ts +1 -1
  11. package/dist/plugin/components/html.d.ts.map +1 -1
  12. package/dist/plugin/components/html.js +14 -3
  13. package/dist/plugin/components/html.js.map +1 -1
  14. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +4 -4
  15. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
  16. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +14 -9
  17. package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -1
  18. package/dist/plugin/config/defaults.d.ts +66 -12
  19. package/dist/plugin/config/defaults.d.ts.map +1 -1
  20. package/dist/plugin/config/defaults.js +69 -15
  21. package/dist/plugin/config/defaults.js.map +1 -1
  22. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +5 -0
  23. package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +1 -0
  24. package/dist/plugin/config/resolveAutoDiscoverMatcher.js +25 -0
  25. package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +1 -0
  26. package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
  27. package/dist/plugin/config/resolveEnv.js +16 -5
  28. package/dist/plugin/config/resolveEnv.js.map +1 -1
  29. package/dist/plugin/config/resolveOptions.d.ts +3 -3
  30. package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
  31. package/dist/plugin/config/resolveOptions.js +59 -87
  32. package/dist/plugin/config/resolveOptions.js.map +1 -1
  33. package/dist/plugin/config/resolveUserConfig.d.ts +4 -4
  34. package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
  35. package/dist/plugin/config/resolveUserConfig.js +8 -1
  36. package/dist/plugin/config/resolveUserConfig.js.map +1 -1
  37. package/dist/plugin/error/toError.d.ts +3 -0
  38. package/dist/plugin/error/toError.d.ts.map +1 -1
  39. package/dist/plugin/error/toError.js +33 -4
  40. package/dist/plugin/error/toError.js.map +1 -1
  41. package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
  42. package/dist/plugin/helpers/cleanObject.js +19 -5
  43. package/dist/plugin/helpers/cleanObject.js.map +1 -1
  44. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +3 -3
  45. package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
  46. package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
  47. package/dist/plugin/helpers/createCssProps.d.ts +4 -3
  48. package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
  49. package/dist/plugin/helpers/createCssProps.js +7 -2
  50. package/dist/plugin/helpers/createCssProps.js.map +1 -1
  51. package/dist/plugin/helpers/createHandler.d.ts +4 -3
  52. package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
  53. package/dist/plugin/helpers/createHandler.js +1 -1
  54. package/dist/plugin/helpers/createHandler.js.map +1 -1
  55. package/dist/plugin/helpers/createRscStream.d.ts +2 -2
  56. package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
  57. package/dist/plugin/helpers/createRscStream.js +15 -5
  58. package/dist/plugin/helpers/createRscStream.js.map +1 -1
  59. package/dist/plugin/helpers/index.d.ts +2 -2
  60. package/dist/plugin/helpers/index.d.ts.map +1 -1
  61. package/dist/plugin/helpers/index.js +2 -2
  62. package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
  63. package/dist/plugin/helpers/inputNormalizer.js +4 -1
  64. package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
  65. package/dist/plugin/helpers/moduleResolver.d.ts +3 -0
  66. package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -0
  67. package/dist/plugin/helpers/moduleResolver.js +25 -0
  68. package/dist/plugin/helpers/requestInfo.d.ts +18 -3
  69. package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
  70. package/dist/plugin/helpers/requestInfo.js +75 -11
  71. package/dist/plugin/helpers/requestInfo.js.map +1 -1
  72. package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
  73. package/dist/plugin/helpers/resolvePage.js +2 -3
  74. package/dist/plugin/helpers/resolvePage.js.map +1 -1
  75. package/dist/plugin/helpers/resolvePageAndProps.d.ts +4 -3
  76. package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
  77. package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
  78. package/dist/plugin/helpers/serializeUserOptions.d.ts +3 -2
  79. package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
  80. package/dist/plugin/helpers/serializeUserOptions.js +13 -1
  81. package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
  82. package/dist/plugin/helpers/sourceMap.d.ts +8 -0
  83. package/dist/plugin/helpers/sourceMap.d.ts.map +1 -0
  84. package/dist/plugin/helpers/sourceMap.js +136 -0
  85. package/dist/plugin/helpers.js +1 -1
  86. package/dist/plugin/loader/createBuildLoader.d.ts +7 -22
  87. package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
  88. package/dist/plugin/loader/createBuildLoader.js +79 -65
  89. package/dist/plugin/loader/createBuildLoader.js.map +1 -1
  90. package/dist/plugin/loader/createDefaultLoader.d.ts +13 -0
  91. package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -0
  92. package/dist/plugin/loader/createDefaultLoader.js +47 -0
  93. package/dist/plugin/loader/css-loader.development.d.ts +1 -0
  94. package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
  95. package/dist/plugin/loader/css-loader.development.js +1 -1
  96. package/dist/plugin/loader/css-loader.development.js.map +1 -1
  97. package/dist/plugin/loader/handleExports.d.ts +33 -0
  98. package/dist/plugin/loader/handleExports.d.ts.map +1 -0
  99. package/dist/plugin/loader/handleExports.js +174 -0
  100. package/dist/plugin/loader/handleExports.js.map +1 -0
  101. package/dist/plugin/loader/index.d.ts +1 -1
  102. package/dist/plugin/loader/index.d.ts.map +1 -1
  103. package/dist/plugin/loader/index.js +4 -1
  104. package/dist/plugin/loader/parse.d.ts +6 -0
  105. package/dist/plugin/loader/parse.d.ts.map +1 -0
  106. package/dist/plugin/loader/parse.js +23 -0
  107. package/dist/plugin/loader/parse.js.map +1 -0
  108. package/dist/plugin/loader/react-loader.client.d.ts +2 -0
  109. package/dist/plugin/loader/react-loader.client.d.ts.map +1 -0
  110. package/dist/plugin/loader/react-loader.client.js +2 -0
  111. package/dist/plugin/loader/react-loader.d.ts +1 -12
  112. package/dist/plugin/loader/react-loader.d.ts.map +1 -1
  113. package/dist/plugin/loader/react-loader.js +5 -687
  114. package/dist/plugin/loader/react-loader.js.map +1 -1
  115. package/dist/plugin/loader/react-loader.server.d.ts +21 -0
  116. package/dist/plugin/loader/react-loader.server.d.ts.map +1 -0
  117. package/dist/plugin/loader/react-loader.server.js +69 -0
  118. package/dist/plugin/loader/sourceMap.d.ts +35 -0
  119. package/dist/plugin/loader/sourceMap.d.ts.map +1 -0
  120. package/dist/plugin/loader/sourceMap.js +105 -0
  121. package/dist/plugin/loader/temporaryReferences.d.ts +1 -1
  122. package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -1
  123. package/dist/plugin/loader/transformModuleIfNeeded.d.ts +2 -0
  124. package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -0
  125. package/dist/plugin/loader/transformModuleIfNeeded.js +27 -0
  126. package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -0
  127. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +27 -0
  128. package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -0
  129. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +52 -0
  130. package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -0
  131. package/dist/plugin/loader/types.d.ts +8 -0
  132. package/dist/plugin/loader/types.d.ts.map +1 -0
  133. package/dist/plugin/loader/types.js +1 -0
  134. package/dist/plugin/plugin.client.d.ts +2 -2
  135. package/dist/plugin/plugin.client.d.ts.map +1 -1
  136. package/dist/plugin/plugin.client.js +2 -3
  137. package/dist/plugin/plugin.client.js.map +1 -1
  138. package/dist/plugin/plugin.server.d.ts +2 -2
  139. package/dist/plugin/plugin.server.d.ts.map +1 -1
  140. package/dist/plugin/plugin.server.js +2 -2
  141. package/dist/plugin/plugin.server.js.map +1 -1
  142. package/dist/plugin/preserver/plugin.d.ts +2 -2
  143. package/dist/plugin/preserver/plugin.d.ts.map +1 -1
  144. package/dist/plugin/preserver/plugin.js +6 -2
  145. package/dist/plugin/preserver/plugin.js.map +1 -1
  146. package/dist/plugin/react-client/{server.d.ts → configureWorkerRequestHandler.d.ts} +4 -4
  147. package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -0
  148. package/dist/plugin/react-client/{server.js → configureWorkerRequestHandler.js} +11 -8
  149. package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -0
  150. package/dist/plugin/react-client/createMessageHandlers.d.ts +1 -1
  151. package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
  152. package/dist/plugin/react-client/createMessageHandlers.js +18 -11
  153. package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
  154. package/dist/plugin/react-client/createWorkerStream.d.ts +5 -3
  155. package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
  156. package/dist/plugin/react-client/createWorkerStream.js +61 -27
  157. package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
  158. package/dist/plugin/react-client/handleWorkerRscStream.d.ts +1 -1
  159. package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
  160. package/dist/plugin/react-client/handleWorkerRscStream.js +14 -4
  161. package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
  162. package/dist/plugin/react-client/plugin.d.ts +2 -2
  163. package/dist/plugin/react-client/plugin.d.ts.map +1 -1
  164. package/dist/plugin/react-client/plugin.js +7 -8
  165. package/dist/plugin/react-client/plugin.js.map +1 -1
  166. package/dist/plugin/react-client/restartWorker.d.ts +1 -1
  167. package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
  168. package/dist/plugin/react-client/restartWorker.js +9 -3
  169. package/dist/plugin/react-client/restartWorker.js.map +1 -1
  170. package/dist/plugin/react-server/configureReactServer.d.ts +9 -0
  171. package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -0
  172. package/dist/plugin/react-server/{server.js → configureReactServer.js} +26 -8
  173. package/dist/plugin/react-server/configureReactServer.js.map +1 -0
  174. package/dist/plugin/react-server/handleServerAction.d.ts +5 -0
  175. package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -0
  176. package/dist/plugin/react-server/handleServerAction.js +145 -0
  177. package/dist/plugin/react-server/handleServerAction.js.map +1 -0
  178. package/dist/plugin/react-server/plugin.d.ts +2 -2
  179. package/dist/plugin/react-server/plugin.d.ts.map +1 -1
  180. package/dist/plugin/react-server/plugin.js +1 -1
  181. package/dist/plugin/react-server/plugin.js.map +1 -1
  182. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +2 -2
  183. package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
  184. package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
  185. package/dist/plugin/react-static/collectRscContent.d.ts +2 -2
  186. package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
  187. package/dist/plugin/react-static/collectRscContent.js.map +1 -1
  188. package/dist/plugin/react-static/configurePreviewServer.d.ts +3 -3
  189. package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
  190. package/dist/plugin/react-static/configurePreviewServer.js +18 -7
  191. package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
  192. package/dist/plugin/react-static/plugin.d.ts +2 -2
  193. package/dist/plugin/react-static/plugin.d.ts.map +1 -1
  194. package/dist/plugin/react-static/plugin.js +28 -12
  195. package/dist/plugin/react-static/plugin.js.map +1 -1
  196. package/dist/plugin/react-static/renderPage.d.ts +2 -2
  197. package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
  198. package/dist/plugin/react-static/renderPage.js.map +1 -1
  199. package/dist/plugin/react-static/renderPages.d.ts +2 -2
  200. package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
  201. package/dist/plugin/react-static/renderPages.js.map +1 -1
  202. package/dist/plugin/react-static/renderStreams.d.ts +2 -2
  203. package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
  204. package/dist/plugin/react-static/renderStreams.js +4 -4
  205. package/dist/plugin/react-static/renderStreams.js.map +1 -1
  206. package/dist/plugin/source-map/createMappingsSerializer.d.ts +2 -0
  207. package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +1 -0
  208. package/dist/plugin/source-map/createMappingsSerializer.js +159 -0
  209. package/dist/plugin/source-map/readMappings.d.ts +2 -0
  210. package/dist/plugin/source-map/readMappings.d.ts.map +1 -0
  211. package/dist/plugin/source-map/readMappings.js +201 -0
  212. package/dist/plugin/transformer/index.d.ts +0 -1
  213. package/dist/plugin/transformer/index.d.ts.map +1 -1
  214. package/dist/plugin/transformer/index.js +0 -1
  215. package/dist/plugin/transformer/plugin.client.d.ts +1 -3
  216. package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
  217. package/dist/plugin/transformer/plugin.client.js +1 -84
  218. package/dist/plugin/transformer/plugin.server.d.ts +2 -2
  219. package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
  220. package/dist/plugin/transformer/plugin.server.js +52 -20
  221. package/dist/plugin/transformer/plugin.server.js.map +1 -1
  222. package/dist/plugin/types.d.ts +89 -119
  223. package/dist/plugin/types.d.ts.map +1 -1
  224. package/dist/plugin/utils/callServer.d.ts +1 -1
  225. package/dist/plugin/utils/callServer.d.ts.map +1 -1
  226. package/dist/plugin/utils/createCallServer.d.ts +1 -1
  227. package/dist/plugin/utils/createCallServer.d.ts.map +1 -1
  228. package/dist/plugin/utils/createCallServer.js +13 -4
  229. package/dist/plugin/utils/createCallServer.js.map +1 -1
  230. package/dist/plugin/utils/index.d.ts +1 -0
  231. package/dist/plugin/utils/index.d.ts.map +1 -1
  232. package/dist/plugin/utils/index.js +1 -0
  233. package/dist/plugin/utils.js +1 -0
  234. package/dist/plugin/utils.js.map +1 -1
  235. package/dist/plugin/vendor/vendor.client.d.ts +2 -1
  236. package/dist/plugin/vendor/vendor.client.d.ts.map +1 -1
  237. package/dist/plugin/vendor/vendor.client.js +2 -1
  238. package/dist/plugin/vendor/vendor.client.js.map +1 -1
  239. package/dist/plugin/vendor/vendor.server.d.ts.map +1 -1
  240. package/dist/plugin/vendor/vendor.server.js +1 -1
  241. package/dist/plugin/vendor/vendor.server.js.map +1 -1
  242. package/dist/plugin/worker/createWorker.d.ts.map +1 -1
  243. package/dist/plugin/worker/createWorker.js +17 -22
  244. package/dist/plugin/worker/createWorker.js.map +1 -1
  245. package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
  246. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +25 -4
  247. package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
  248. package/dist/plugin/worker/html/html-worker.development.js +15 -13
  249. package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
  250. package/dist/plugin/worker/html/html-worker.production.js +2 -12
  251. package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
  252. package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
  253. package/dist/plugin/worker/html/messageHandler.js +2 -2
  254. package/dist/plugin/worker/html/messageHandler.js.map +1 -1
  255. package/dist/plugin/worker/rsc/handleRender.d.ts +2 -1
  256. package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
  257. package/dist/plugin/worker/rsc/handleRender.js +8 -8
  258. package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
  259. package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
  260. package/dist/plugin/worker/rsc/messageHandler.js +166 -107
  261. package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
  262. package/dist/plugin/worker/rsc/rsc-worker.development.js +112 -52
  263. package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
  264. package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
  265. package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
  266. package/dist/plugin/worker/rsc/state.d.ts +5 -64
  267. package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
  268. package/dist/plugin/worker/rsc/state.js +5 -1
  269. package/dist/plugin/worker/rsc/state.js.map +1 -1
  270. package/dist/plugin/worker/sendMessage.d.ts +2 -0
  271. package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
  272. package/dist/plugin/worker/sendMessage.js +2 -1
  273. package/dist/plugin/worker/sendMessage.js.map +1 -1
  274. package/dist/plugin/worker/types.d.ts +52 -53
  275. package/dist/plugin/worker/types.d.ts.map +1 -1
  276. package/dist/tsconfig.tsbuildinfo +1 -1
  277. package/package.json +10 -8
  278. package/plugin/components/css-collector-elements.tsx +30 -9
  279. package/plugin/components/css-collector.tsx +13 -22
  280. package/plugin/components/html.tsx +12 -5
  281. package/plugin/config/autoDiscover/resolveAutoDiscover.ts +31 -13
  282. package/plugin/config/defaults.tsx +72 -16
  283. package/plugin/config/resolveAutoDiscoverMatcher.ts +23 -0
  284. package/plugin/config/resolveEnv.ts +20 -12
  285. package/plugin/config/resolveOptions.ts +152 -155
  286. package/plugin/config/resolveUserConfig.ts +20 -5
  287. package/plugin/error/toError.ts +35 -1
  288. package/plugin/helpers/cleanObject.ts +79 -15
  289. package/plugin/helpers/collectViteModuleGraphCss.ts +4 -3
  290. package/plugin/helpers/createCssProps.tsx +26 -9
  291. package/plugin/helpers/createHandler.ts +7 -4
  292. package/plugin/helpers/createRscStream.tsx +20 -14
  293. package/plugin/helpers/index.ts +2 -2
  294. package/plugin/helpers/inputNormalizer.ts +4 -2
  295. package/plugin/helpers/moduleResolver.ts +36 -0
  296. package/plugin/helpers/requestInfo.ts +117 -23
  297. package/plugin/helpers/resolvePage.ts +2 -3
  298. package/plugin/helpers/resolvePageAndProps.ts +7 -6
  299. package/plugin/helpers/serializeUserOptions.ts +20 -2
  300. package/plugin/helpers/sourceMap.ts +182 -0
  301. package/plugin/loader/createBuildLoader.ts +124 -104
  302. package/plugin/loader/createDefaultLoader.ts +62 -0
  303. package/plugin/loader/css-loader.development.ts +3 -2
  304. package/plugin/loader/handleExports.ts +276 -0
  305. package/plugin/loader/index.ts +6 -1
  306. package/plugin/loader/parse.ts +22 -0
  307. package/plugin/loader/react-loader.client.ts +1 -0
  308. package/plugin/loader/react-loader.server.ts +107 -0
  309. package/plugin/loader/react-loader.ts +4 -1002
  310. package/plugin/loader/sourceMap.ts +118 -0
  311. package/plugin/loader/transformModuleIfNeeded.ts +33 -0
  312. package/plugin/loader/transformModuleWithPreservedFunctions.ts +119 -0
  313. package/plugin/loader/types.ts +10 -0
  314. package/plugin/plugin.client.ts +18 -11
  315. package/plugin/plugin.server.ts +6 -3
  316. package/plugin/preserver/plugin.ts +37 -17
  317. package/plugin/react-client/{server.ts → configureWorkerRequestHandler.ts} +22 -12
  318. package/plugin/react-client/createMessageHandlers.ts +21 -13
  319. package/plugin/react-client/createWorkerStream.ts +71 -33
  320. package/plugin/react-client/handleWorkerRscStream.ts +15 -5
  321. package/plugin/react-client/plugin.ts +18 -13
  322. package/plugin/react-client/restartWorker.ts +17 -5
  323. package/plugin/react-server/{server.ts → configureReactServer.ts} +40 -9
  324. package/plugin/react-server/handleServerAction.ts +177 -0
  325. package/plugin/react-server/plugin.ts +8 -3
  326. package/plugin/react-static/collectHtmlWorkerContent.ts +11 -3
  327. package/plugin/react-static/collectRscContent.ts +17 -9
  328. package/plugin/react-static/configurePreviewServer.ts +37 -17
  329. package/plugin/react-static/plugin.ts +45 -22
  330. package/plugin/react-static/renderPage.ts +12 -6
  331. package/plugin/react-static/renderPages.ts +15 -4
  332. package/plugin/react-static/renderStreams.ts +13 -12
  333. package/plugin/source-map/createMappingsSerializer.ts +182 -0
  334. package/plugin/source-map/readMappings.ts +195 -0
  335. package/plugin/transformer/README.md +295 -29
  336. package/plugin/transformer/index.ts +0 -1
  337. package/plugin/transformer/plugin.client.ts +0 -111
  338. package/plugin/transformer/plugin.server.ts +94 -25
  339. package/plugin/types/react-server-dom-esm.d.ts +183 -24
  340. package/plugin/types/sourceMap.d.ts +2 -0
  341. package/plugin/types/webpack-sources.d.ts +24 -0
  342. package/plugin/types.ts +169 -132
  343. package/plugin/utils/createCallServer.ts +21 -6
  344. package/plugin/utils/index.ts +2 -1
  345. package/plugin/vendor/vendor.client.ts +2 -1
  346. package/plugin/vendor/vendor.server.ts +1 -1
  347. package/plugin/worker/createWorker.ts +21 -24
  348. package/plugin/worker/html/createHtmlWorkerRenderState.tsx +31 -7
  349. package/plugin/worker/html/html-worker.development.tsx +16 -16
  350. package/plugin/worker/html/html-worker.production.tsx +3 -19
  351. package/plugin/worker/html/messageHandler.tsx +2 -4
  352. package/plugin/worker/rsc/handleRender.ts +15 -12
  353. package/plugin/worker/rsc/messageHandler.tsx +191 -120
  354. package/plugin/worker/rsc/rsc-worker.development.ts +148 -77
  355. package/plugin/worker/rsc/rsc-worker.production.ts +1 -1
  356. package/plugin/worker/rsc/state.ts +10 -0
  357. package/plugin/worker/sendMessage.ts +32 -14
  358. package/plugin/worker/types.ts +99 -64
  359. package/dist/plugin/react-client/server.d.ts.map +0 -1
  360. package/dist/plugin/react-client/server.js.map +0 -1
  361. package/dist/plugin/react-server/server.d.ts +0 -9
  362. package/dist/plugin/react-server/server.d.ts.map +0 -1
  363. package/dist/plugin/react-server/server.js.map +0 -1
  364. package/dist/plugin/transformer/plugin.client.js.map +0 -1
  365. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +0 -2
  366. package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +0 -1
  367. package/dist/plugin/transformer/upgradeCssModuleCode.js +0 -40
  368. package/dist/plugin/worker/loader.d.ts +0 -5
  369. package/dist/plugin/worker/loader.d.ts.map +0 -1
  370. package/dist/plugin/worker/loader.js +0 -11
  371. package/dist/plugin/worker/loader.js.map +0 -1
  372. package/plugin/transformer/upgradeCssModuleCode.ts +0 -42
  373. package/plugin/worker/loader.ts +0 -7
@@ -0,0 +1,174 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ function handleExports(source, program, isServerFunction, isClientComponent) {
7
+ const imports = [];
8
+ const declarations = [];
9
+ const exportNames = [];
10
+ const exports = /* @__PURE__ */ new Map();
11
+ let lastEnd = 0;
12
+ let currentBefore = [];
13
+ for (const node of program.body) {
14
+ if (node.start > lastEnd) {
15
+ const beforeCode = source.slice(lastEnd, node.start);
16
+ if (beforeCode.trim()) {
17
+ currentBefore.push(beforeCode);
18
+ }
19
+ }
20
+ if (node.type === "ImportDeclaration") {
21
+ imports.push(source.slice(node.start, node.end));
22
+ } else if (node.type === "ExportAllDeclaration") {
23
+ exports.set("*", {
24
+ type: "all",
25
+ before: [...currentBefore]
26
+ });
27
+ currentBefore = [];
28
+ exportNames.push("*");
29
+ } else if (node.type === "ExportNamedDeclaration") {
30
+ if (node.declaration) {
31
+ if (node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
32
+ const name = node.declaration.id.name;
33
+ exports.set(name, {
34
+ type: "function",
35
+ declaration: source.slice(node.declaration.start, node.declaration.end),
36
+ before: [...currentBefore],
37
+ // Copy the current before array
38
+ isAsync: node.declaration.async
39
+ });
40
+ exportNames.push(name);
41
+ currentBefore = [];
42
+ } else if (node.declaration.type === "ClassDeclaration" && node.declaration.id) {
43
+ const name = node.declaration.id.name;
44
+ exports.set(name, {
45
+ type: "class",
46
+ declaration: source.slice(node.declaration.start, node.declaration.end),
47
+ before: [...currentBefore]
48
+ // Copy the current before array
49
+ });
50
+ exportNames.push(name);
51
+ currentBefore = [];
52
+ } else if (node.declaration.type === "VariableDeclaration") {
53
+ for (const decl of node.declaration.declarations) {
54
+ if (decl.id && decl.id.type === "Identifier") {
55
+ const name = decl.id.name;
56
+ const init = decl.init;
57
+ const isFunction = init && (init.type === "FunctionExpression" || init.type === "ArrowFunctionExpression");
58
+ const isAsync = isFunction && (init.type === "FunctionExpression" && init.async === true || init.type === "ArrowFunctionExpression" && init.async === true);
59
+ exports.set(name, {
60
+ type: isFunction ? "function" : "variable",
61
+ declaration: source.slice(decl.start, decl.end),
62
+ before: [...currentBefore],
63
+ // Copy the current before array
64
+ isAsync: isAsync || false
65
+ });
66
+ exportNames.push(name);
67
+ currentBefore = [];
68
+ }
69
+ }
70
+ }
71
+ } else if (node.specifiers) {
72
+ for (const spec of node.specifiers) {
73
+ if (spec.type === "ExportSpecifier") {
74
+ const localName = spec.local.type === "Identifier" ? spec.local.name : "";
75
+ const exportedName = spec.exported.type === "Identifier" ? spec.exported.name : "";
76
+ if (localName && exportedName) {
77
+ const functionDecl = program.body.find(
78
+ (node2) => node2.type === "FunctionDeclaration" && node2.id?.name === localName
79
+ );
80
+ if (functionDecl) {
81
+ exports.set(exportedName, {
82
+ type: "function",
83
+ localName,
84
+ declaration: source.slice(functionDecl.start, functionDecl.end),
85
+ before: [...currentBefore],
86
+ isAsync: functionDecl.async
87
+ });
88
+ exportNames.push(exportedName);
89
+ } else {
90
+ const varDecl = program.body.find(
91
+ (node2) => node2.type === "VariableDeclaration" && node2.declarations.some(
92
+ (decl) => decl.id.type === "Identifier" && decl.id.name === localName && decl.init && (decl.init.type === "FunctionExpression" || decl.init.type === "ArrowFunctionExpression")
93
+ )
94
+ );
95
+ if (varDecl) {
96
+ const decl = varDecl.declarations.find(
97
+ (d) => d.id.type === "Identifier" && d.id.name === localName
98
+ );
99
+ if (decl && decl.init) {
100
+ const isAsync = decl.init.type === "FunctionExpression" ? decl.init.async : decl.init.type === "ArrowFunctionExpression" ? decl.init.async : false;
101
+ exports.set(exportedName, {
102
+ type: "function",
103
+ localName,
104
+ declaration: source.slice(decl.start, decl.end),
105
+ before: [...currentBefore],
106
+ isAsync
107
+ });
108
+ exportNames.push(exportedName);
109
+ }
110
+ } else {
111
+ exports.set(exportedName, {
112
+ type: "variable",
113
+ localName,
114
+ before: [...currentBefore]
115
+ });
116
+ exportNames.push(exportedName);
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ currentBefore = [];
123
+ }
124
+ } else if (node.type === "ExportDefaultDeclaration") {
125
+ if (node.declaration && node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
126
+ exports.set("default", {
127
+ type: "default",
128
+ before: [...currentBefore],
129
+ localName: node.declaration.id.name,
130
+ // Capture the function name
131
+ isAsync: node.declaration.async
132
+ });
133
+ } else {
134
+ exports.set("default", {
135
+ type: "default",
136
+ before: [...currentBefore]
137
+ });
138
+ }
139
+ currentBefore = [];
140
+ } else if (node.type === "FunctionDeclaration" || node.type === "VariableDeclaration" || node.type === "ClassDeclaration") {
141
+ if (isServerFunction || !isClientComponent || node.type !== "FunctionDeclaration") {
142
+ declarations.push(source.slice(node.start, node.end));
143
+ }
144
+ }
145
+ lastEnd = node.end;
146
+ }
147
+ if (lastEnd < source.length) {
148
+ const afterCode = source.slice(lastEnd);
149
+ if (afterCode.trim()) {
150
+ const lastExport = Array.from(exports.values()).pop();
151
+ if (lastExport) {
152
+ lastExport.after = [afterCode];
153
+ }
154
+ }
155
+ }
156
+ for (const [name, info] of exports) {
157
+ if (info.before) {
158
+ declarations.push(...info.before);
159
+ }
160
+ if (info.declaration) {
161
+ declarations.push(info.declaration);
162
+ }
163
+ if (info.after) {
164
+ declarations.push(...info.after);
165
+ }
166
+ if (!exportNames.includes(name)) {
167
+ exportNames.push(name);
168
+ }
169
+ }
170
+ return { imports, declarations, exportNames, exports };
171
+ }
172
+
173
+ export { handleExports };
174
+ //# sourceMappingURL=handleExports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleExports.js","sources":["../../../plugin/loader/handleExports.ts"],"sourcesContent":["import type { Program } from \"./types.js\";\nimport type { FunctionDeclaration, VariableDeclaration, VariableDeclarator } from \"acorn\";\n\n/**\n * Collects and organizes export information from a module.\n *\n * For all modules:\n * - Collects import statements\n * - Collects export names\n * - Collects declarations\n *\n * The actual transformation of exports (like wrapping with registerServerReference)\n * happens in transformModuleWithPreservedFunctions.\n *\n * @param source - The source code of the module\n * @param url - The URL of the module\n * @param program - The parsed AST program\n * @param isServerFunction - Whether this is a server module\n * @param isClientComponent - Whether this is a client module\n * @returns Object containing imports, declarations, and export names\n */\nexport function handleExports(\n source: string,\n program: Program,\n isServerFunction: boolean | RegExpMatchArray | null,\n isClientComponent: boolean | RegExpMatchArray | null\n): {\n imports: string[];\n declarations: string[];\n exportNames: string[];\n exports: Map<\n string,\n {\n type: \"function\" | \"class\" | \"variable\" | \"default\" | \"all\";\n declaration?: string;\n localName?: string;\n before?: string[];\n after?: string[];\n isAsync?: boolean;\n }\n >;\n} {\n const imports: string[] = [];\n const declarations: string[] = [];\n const exportNames: string[] = [];\n // Track exports and their types\n const exports = new Map<\n string,\n {\n type: \"function\" | \"class\" | \"variable\" | \"default\" | \"all\";\n declaration?: string;\n localName?: string;\n before?: string[];\n after?: string[];\n isAsync?: boolean;\n }\n >();\n\n let lastEnd = 0;\n let currentBefore: string[] = [];\n let foundFirstExport = false;\n\n // First pass: collect all exports and code between them\n for (const node of program.body) {\n // Add any code before this node\n if (node.start > lastEnd) {\n const beforeCode = source.slice(lastEnd, node.start);\n if (beforeCode.trim()) {\n currentBefore.push(beforeCode);\n }\n }\n\n if (node.type === \"ImportDeclaration\") {\n imports.push(source.slice(node.start, node.end));\n } else if (node.type === \"ExportAllDeclaration\") {\n // For export * from './other', just add the * export\n exports.set(\"*\", {\n type: \"all\",\n before: [...currentBefore],\n });\n currentBefore = [];\n exportNames.push(\"*\");\n } else if (node.type === \"ExportNamedDeclaration\") {\n if (!foundFirstExport) {\n // This is the first export, so all code before it goes into its before array\n foundFirstExport = true;\n }\n\n if (node.declaration) {\n if (\n node.declaration.type === \"FunctionDeclaration\" &&\n node.declaration.id\n ) {\n const name = node.declaration.id.name;\n exports.set(name, {\n type: \"function\",\n declaration: source.slice(node.declaration.start, node.declaration.end),\n before: [...currentBefore], // Copy the current before array\n isAsync: node.declaration.async,\n });\n exportNames.push(name);\n currentBefore = []; // Reset for next export\n } else if (\n node.declaration.type === \"ClassDeclaration\" &&\n node.declaration.id\n ) {\n const name = node.declaration.id.name;\n exports.set(name, {\n type: \"class\",\n declaration: source.slice(node.declaration.start, node.declaration.end),\n before: [...currentBefore], // Copy the current before array\n });\n exportNames.push(name);\n currentBefore = []; // Reset for next export\n } else if (node.declaration.type === \"VariableDeclaration\") {\n for (const decl of node.declaration.declarations) {\n if (decl.id && decl.id.type === \"Identifier\") {\n const name = decl.id.name;\n // Check if the declaration is a function expression or arrow function\n const init = decl.init;\n const isFunction = init && (\n init.type === \"FunctionExpression\" ||\n init.type === \"ArrowFunctionExpression\"\n );\n // For function expressions and arrow functions, we want to mark them as async\n // if they are explicitly marked as async\n const isAsync = isFunction && (\n (init.type === \"FunctionExpression\" && init.async === true) ||\n (init.type === \"ArrowFunctionExpression\" && init.async === true)\n );\n exports.set(name, {\n type: isFunction ? \"function\" : \"variable\",\n declaration: source.slice(decl.start, decl.end),\n before: [...currentBefore], // Copy the current before array\n isAsync: isAsync || false\n });\n exportNames.push(name);\n currentBefore = []; // Reset for next export\n }\n }\n }\n } else if (node.specifiers) {\n // For named exports (export { a, b, c })\n for (const spec of node.specifiers) {\n if (spec.type === \"ExportSpecifier\") {\n const localName = spec.local.type === \"Identifier\" ? spec.local.name : \"\";\n const exportedName = spec.exported.type === \"Identifier\" ? spec.exported.name : \"\";\n if (localName && exportedName) {\n // Find the function declaration in the AST\n const functionDecl = program.body.find(\n (node): node is FunctionDeclaration =>\n node.type === \"FunctionDeclaration\" &&\n node.id?.name === localName\n );\n\n if (functionDecl) {\n exports.set(exportedName, {\n type: \"function\",\n localName,\n declaration: source.slice(functionDecl.start, functionDecl.end),\n before: [...currentBefore],\n isAsync: functionDecl.async\n });\n exportNames.push(exportedName);\n } else {\n // If we can't find a function declaration, check if it's a variable declaration\n const varDecl = program.body.find(\n (node): node is VariableDeclaration =>\n node.type === \"VariableDeclaration\" &&\n node.declarations.some(\n (decl) =>\n decl.id.type === \"Identifier\" &&\n decl.id.name === localName &&\n decl.init &&\n (decl.init.type === \"FunctionExpression\" ||\n decl.init.type === \"ArrowFunctionExpression\")\n )\n );\n\n if (varDecl) {\n const decl = varDecl.declarations.find(\n (d: VariableDeclarator) => d.id.type === \"Identifier\" && d.id.name === localName\n );\n if (decl && decl.init) {\n const isAsync = decl.init.type === \"FunctionExpression\" ? decl.init.async :\n decl.init.type === \"ArrowFunctionExpression\" ? decl.init.async : false;\n exports.set(exportedName, {\n type: \"function\",\n localName,\n declaration: source.slice(decl.start, decl.end),\n before: [...currentBefore],\n isAsync\n });\n exportNames.push(exportedName);\n }\n } else {\n exports.set(exportedName, {\n type: \"variable\",\n localName,\n before: [...currentBefore],\n });\n exportNames.push(exportedName);\n }\n }\n }\n }\n }\n currentBefore = []; // Reset for next export\n }\n } else if (node.type === \"ExportDefaultDeclaration\") {\n if (node.declaration && node.declaration.type === \"FunctionDeclaration\" && node.declaration.id) {\n exports.set(\"default\", {\n type: \"default\",\n before: [...currentBefore],\n localName: node.declaration.id.name, // Capture the function name\n isAsync: node.declaration.async\n });\n } else {\n exports.set(\"default\", {\n type: \"default\",\n before: [...currentBefore]\n });\n }\n currentBefore = []; // Reset for next export\n } else if (\n node.type === \"FunctionDeclaration\" ||\n node.type === \"VariableDeclaration\" ||\n node.type === \"ClassDeclaration\"\n ) {\n // For non-exported declarations:\n // - Keep all declarations for server functions\n // - Remove function declarations for client components\n if (\n isServerFunction ||\n !isClientComponent ||\n node.type !== \"FunctionDeclaration\"\n ) {\n declarations.push(source.slice(node.start, node.end));\n }\n }\n\n lastEnd = node.end;\n }\n\n // Add any remaining code after the last node\n if (lastEnd < source.length) {\n const afterCode = source.slice(lastEnd);\n if (afterCode.trim()) {\n // Add to the last export's after array\n const lastExport = Array.from(exports.values()).pop();\n if (lastExport) {\n lastExport.after = [afterCode];\n }\n }\n }\n\n // Second pass: generate transformed exports\n // Process all exports regardless of environment - the actual transformation\n // happens in transformModuleWithPreservedFunctions\n for (const [name, info] of exports) {\n if (info.before) {\n declarations.push(...info.before);\n }\n if (info.declaration) {\n declarations.push(info.declaration);\n }\n if (info.after) {\n declarations.push(...info.after);\n }\n if (!exportNames.includes(name)) {\n exportNames.push(name);\n }\n }\n\n return { imports, declarations, exportNames, exports };\n}\n"],"names":["node"],"mappings":";;;;;AAqBO,SAAS,aACd,CAAA,MAAA,EACA,OACA,EAAA,gBAAA,EACA,iBAgBA,EAAA;AACA,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,MAAM,eAAyB,EAAC;AAChC,EAAA,MAAM,cAAwB,EAAC;AAE/B,EAAM,MAAA,OAAA,uBAAc,GAUlB,EAAA;AAEF,EAAA,IAAI,OAAU,GAAA,CAAA;AACd,EAAA,IAAI,gBAA0B,EAAC;AAI/B,EAAW,KAAA,MAAA,IAAA,IAAQ,QAAQ,IAAM,EAAA;AAE/B,IAAI,IAAA,IAAA,CAAK,QAAQ,OAAS,EAAA;AACxB,MAAA,MAAM,UAAa,GAAA,MAAA,CAAO,KAAM,CAAA,OAAA,EAAS,KAAK,KAAK,CAAA;AACnD,MAAI,IAAA,UAAA,CAAW,MAAQ,EAAA;AACrB,QAAA,aAAA,CAAc,KAAK,UAAU,CAAA;AAAA;AAC/B;AAGF,IAAI,IAAA,IAAA,CAAK,SAAS,mBAAqB,EAAA;AACrC,MAAA,OAAA,CAAQ,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EAAM,IAAI,CAAA,IAAK,OAAS,EAAA;AAClC,IAAA,IAAI,KAAK,MAAQ,EAAA;AACf,MAAa,YAAA,CAAA,IAAA,CAAK,GAAG,IAAA,CAAK,MAAM,CAAA;AAAA;AAElC,IAAA,IAAI,KAAK,WAAa,EAAA;AACpB,MAAa,YAAA,CAAA,IAAA,CAAK,KAAK,WAAW,CAAA;AAAA;AAEpC,IAAA,IAAI,KAAK,KAAO,EAAA;AACd,MAAa,YAAA,CAAA,IAAA,CAAK,GAAG,IAAA,CAAK,KAAK,CAAA;AAAA;AAEjC,IAAA,IAAI,CAAC,WAAA,CAAY,QAAS,CAAA,IAAI,CAAG,EAAA;AAC/B,MAAA,WAAA,CAAY,KAAK,IAAI,CAAA;AAAA;AACvB;AAGF,EAAA,OAAO,EAAE,OAAA,EAAS,YAAc,EAAA,WAAA,EAAa,OAAQ,EAAA;AACvD;;;;"}
@@ -1,2 +1,2 @@
1
- export { reactLoaderPlugin } from "./plugin.js";
1
+ export declare const load: any, resolve: any;
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/loader/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/loader/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAQ,IAAI,OAAE,OAAO,KAAW,CAAC"}
@@ -1 +1,4 @@
1
- export { reactLoaderPlugin } from "./plugin.js";
1
+ import { getCondition } from "../config/getCondition.js";
2
+ const condition = getCondition('');
3
+ const loader = await import(`react-loader.${condition}.ts`);
4
+ export const { load, resolve } = loader;
@@ -0,0 +1,6 @@
1
+ import type { Program } from "./types.js";
2
+ /**
3
+ * Parses source code and handles source maps
4
+ */
5
+ export declare function parse(source: string): Program;
6
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../plugin/loader/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAe7C"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * vite-plugin-react-server
3
+ * Copyright (c) Nico Brinkkemper
4
+ * MIT License
5
+ */
6
+ import * as acorn from 'acorn-loose';
7
+
8
+ function parse(source) {
9
+ let program;
10
+ program = acorn.parse(source, {
11
+ ecmaVersion: "latest",
12
+ sourceType: "module",
13
+ locations: true,
14
+ allowAwaitOutsideFunction: true,
15
+ allowImportExportEverywhere: true,
16
+ allowReturnOutsideFunction: true,
17
+ allowReserved: true
18
+ });
19
+ return program;
20
+ }
21
+
22
+ export { parse };
23
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sources":["../../../plugin/loader/parse.ts"],"sourcesContent":["import * as acorn from \"acorn-loose\";\nimport type { Program } from \"./types.js\";\n\n/**\n * Parses source code and handles source maps\n */\nexport function parse(source: string): Program {\n let program: Program;\n\n // Parse the transformed code with acorn\n program = acorn.parse(source, {\n ecmaVersion: \"latest\" as const,\n sourceType: \"module\",\n locations: true,\n allowAwaitOutsideFunction: true,\n allowImportExportEverywhere: true,\n allowReturnOutsideFunction: true,\n allowReserved: true,\n }) as Program;\n\n return program\n}\n"],"names":[],"mappings":";;;;;;;AAMO,SAAS,MAAM,MAAyB,EAAA;AAC7C,EAAI,IAAA,OAAA;AAGJ,EAAU,OAAA,GAAA,KAAA,CAAM,MAAM,MAAQ,EAAA;AAAA,IAC5B,WAAa,EAAA,QAAA;AAAA,IACb,UAAY,EAAA,QAAA;AAAA,IACZ,SAAW,EAAA,IAAA;AAAA,IACX,yBAA2B,EAAA,IAAA;AAAA,IAC3B,2BAA6B,EAAA,IAAA;AAAA,IAC7B,0BAA4B,EAAA,IAAA;AAAA,IAC5B,aAAe,EAAA;AAAA,GAChB,CAAA;AAED,EAAO,OAAA,OAAA;AACT;;;;"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=react-loader.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-loader.client.d.ts","sourceRoot":"","sources":["../../../plugin/loader/react-loader.client.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ throw new Error("Not supported on the client");
2
+ export {};
@@ -1,13 +1,2 @@
1
- import { type LoadHookContext, type ResolveHookContext } from "node:module";
2
- import type { MessagePort } from "node:worker_threads";
3
- import type { LoaderContext } from "../types.js";
4
- export declare let loaderPort: MessagePort | undefined;
5
- export declare function getSource(url: string, context: any, defaultGetSource: any): Promise<any>;
6
- export declare function transformModuleIfNeeded(source: string, url: string, loader: any, port?: MessagePort): Promise<string | null>;
7
- export declare function initialize(data: {
8
- port: MessagePort;
9
- }): Promise<void>;
10
- export declare function resolve(specifier: string, context: ResolveHookContext, nextResolve: any): Promise<any>;
11
- export declare function load(url: string, context: LoadHookContext & LoaderContext, nextLoad: any): Promise<any>;
12
- export declare function transformSource(source: string, context: any, defaultTransformSource: any): Promise<any>;
1
+ export declare const load: any, resolve: any, transformModuleIfNeeded: any;
13
2
  //# sourceMappingURL=react-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-loader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/react-loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAcjD,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C,wBAAsB,SAAS,CAC7B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,GAAG,EACZ,gBAAgB,EAAE,GAAG,gBAKtB;AA0mBD,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,GAAG,EACX,IAAI,CAAC,EAAE,WAAW,0BAuDnB;AA4KD,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,iBAI3D;AAGD,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,GAAG,gBAGjB;AAGD,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,EACxC,QAAQ,EAAE,GAAG,gBA0Dd;AAGD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,sBAAsB,EAAE,GAAG,gBAkC5B"}
1
+ {"version":3,"file":"react-loader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/react-loader.ts"],"names":[],"mappings":"AAKA,eAAO,MAAQ,IAAI,OAAE,OAAO,OAAE,uBAAuB,KAAW,CAAC"}