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,136 @@
1
+ import { basename } from "path";
2
+ // VLQ encoding helpers
3
+ const VLQ_SHIFT = 5;
4
+ const VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
5
+ const VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
6
+ const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
7
+ export function encodeVLQ(numbers) {
8
+ return numbers
9
+ .map((num) => {
10
+ // Convert to VLQ
11
+ const vlq = num < 0 ? (-num << 1) | 1 : num << 1;
12
+ let result = "";
13
+ let value = vlq;
14
+ do {
15
+ let digit = value & VLQ_VALUE_MASK;
16
+ value >>>= VLQ_SHIFT;
17
+ if (value > 0) {
18
+ digit |= VLQ_CONTINUATION_BIT;
19
+ }
20
+ result += BASE64_CHARS[digit];
21
+ } while (value > 0);
22
+ return result;
23
+ })
24
+ .join("");
25
+ }
26
+ export function decodeVLQ(str) {
27
+ const numbers = [];
28
+ let value = 0;
29
+ let shift = 0;
30
+ let index = 0;
31
+ while (index < str.length && !/[,;]/.test(str[index])) {
32
+ const digit = BASE64_CHARS.indexOf(str[index]);
33
+ if (digit === -1)
34
+ break;
35
+ value += (digit & VLQ_VALUE_MASK) << shift;
36
+ if ((digit & VLQ_CONTINUATION_BIT) === 0) {
37
+ const negate = value & 1;
38
+ value >>>= 1;
39
+ numbers.push(negate ? -value : value);
40
+ value = shift = 0;
41
+ }
42
+ else {
43
+ shift += VLQ_SHIFT;
44
+ }
45
+ index++;
46
+ }
47
+ return numbers;
48
+ }
49
+ export function readMappings(mappings, callback) {
50
+ let line = 1;
51
+ let column = 0;
52
+ let sourceIndex = 0;
53
+ let originalLine = 1;
54
+ let originalColumn = 0;
55
+ let nameIndex = 0;
56
+ const segments = mappings.split(";");
57
+ for (let i = 0; i < segments.length; i++) {
58
+ const segment = segments[i];
59
+ if (segment === "") {
60
+ line++;
61
+ column = 0;
62
+ continue;
63
+ }
64
+ const parts = segment.split(",");
65
+ for (let j = 0; j < parts.length; j++) {
66
+ const part = parts[j];
67
+ if (part === "")
68
+ continue;
69
+ const numbers = decodeVLQ(part);
70
+ column += numbers[0];
71
+ if (numbers.length > 1) {
72
+ sourceIndex += numbers[1];
73
+ originalLine += numbers[2];
74
+ originalColumn += numbers[3];
75
+ if (numbers.length > 4) {
76
+ nameIndex += numbers[4];
77
+ }
78
+ }
79
+ callback(line, column, sourceIndex, originalLine, originalColumn, nameIndex);
80
+ }
81
+ }
82
+ }
83
+ export function createMappingsSerializer() {
84
+ let previousGeneratedLine = 1;
85
+ let previousGeneratedColumn = 0;
86
+ let previousOriginalFile = 0;
87
+ let previousOriginalLine = 0;
88
+ let previousOriginalColumn = 0;
89
+ let previousNameIndex = 0;
90
+ return function (generatedLine, generatedColumn, originalFile, originalLine, originalColumn, nameIndex) {
91
+ // Reset column when moving to a new line
92
+ if (generatedLine > previousGeneratedLine) {
93
+ previousGeneratedColumn = 0;
94
+ let lines = "";
95
+ for (let i = previousGeneratedLine; i < generatedLine; i++) {
96
+ lines += ";";
97
+ }
98
+ previousGeneratedLine = generatedLine;
99
+ if (lines)
100
+ return lines;
101
+ }
102
+ // Calculate deltas
103
+ const segment = [
104
+ generatedColumn - previousGeneratedColumn,
105
+ originalFile - previousOriginalFile,
106
+ originalLine - previousOriginalLine,
107
+ originalColumn - previousOriginalColumn,
108
+ ];
109
+ if (nameIndex >= 0) {
110
+ segment.push(nameIndex - previousNameIndex);
111
+ }
112
+ // Update previous values
113
+ previousGeneratedColumn = generatedColumn;
114
+ previousOriginalFile = originalFile;
115
+ previousOriginalLine = originalLine;
116
+ previousOriginalColumn = originalColumn;
117
+ previousNameIndex = nameIndex;
118
+ return encodeVLQ(segment) + ",";
119
+ };
120
+ }
121
+ export function createSourceMap(originalSource) {
122
+ return {
123
+ version: 3,
124
+ file: basename(originalSource),
125
+ sources: [originalSource],
126
+ sourcesContent: [originalSource],
127
+ names: [],
128
+ mappings: "AAAA;", // Simple line mapping
129
+ sourceRoot: "",
130
+ };
131
+ }
132
+ export function updateSourceMap(sourceMap, originalSource) {
133
+ // Update the source map with the transformed source
134
+ sourceMap.sourcesContent = [originalSource];
135
+ sourceMap.mappings = "AAAA;"; // Simple line mapping
136
+ }
@@ -9,7 +9,7 @@ export { resolveProps } from './helpers/resolveProps.js';
9
9
  export { resolvePageAndProps } from './helpers/resolvePageAndProps.js';
10
10
  export { requestInfo } from './helpers/requestInfo.js';
11
11
  export { requestToRoute } from './helpers/requestToRoute.js';
12
- export { deserializeRegExp, processForSerialization, serializeResolvedConfig, serializedDevServerConfig, serializedOptions } from './helpers/serializeUserOptions.js';
12
+ export { deserializeRegExp, hydrateUserOptions, processForSerialization, serializeResolvedConfig, serializedDevServerConfig, serializedOptions } from './helpers/serializeUserOptions.js';
13
13
  export { cleanObject } from './helpers/cleanObject.js';
14
14
  export { createInputNormalizer } from './helpers/inputNormalizer.js';
15
15
  export { collectManifestCss } from './helpers/collectManifestCss.js';
@@ -1,9 +1,9 @@
1
- import type { ResolvedUserConfig, ResolvedUserOptions } from "../../server.js";
1
+ import type { InlineCssOpt, PagePropOpt, ResolvedUserConfig, ResolvedUserOptions } from "../../server.js";
2
2
  import type { Manifest } from "vite";
3
3
  import type { OutputBundle } from "rollup";
4
- export interface BuildLoaderOptions {
4
+ export interface BuildLoaderOptions<T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt> {
5
5
  userConfig: ResolvedUserConfig;
6
- userOptions: ResolvedUserOptions;
6
+ userOptions: ResolvedUserOptions<T, InlineCSS>;
7
7
  serverManifest: Manifest;
8
8
  clientManifest: Manifest;
9
9
  staticManifest: Manifest;
@@ -12,24 +12,9 @@ export interface BuildLoaderOptions {
12
12
  * Creates a loader function for handling module resolution during build.
13
13
  *
14
14
  * The loader handles the following strategy:
15
- * - Just load any file from any manifest we can find in the order of client, server, static
16
- * - Ideally the buildLoader is only used form loading pages, props and inline css modules
17
- * -
18
- *
19
- * During build:
20
- * - We use the manifest information to get module exports
21
- * - The manifest contains the transformed modules with their exports
22
- * - We store the module in temporaryReferences for later use
23
- *
24
- * @param options.root - The project root directory
25
- * @param options.pluginContext - The Rollup plugin context
26
- * @param options.userConfig - Resolved user configuration
27
- * @param options.userOptions - Resolved user options
28
- * @param options.serverManifest - Vite server manifest
29
- * @param options.clientManifest - Vite client manifest
30
- * @param options.options - Additional options including temporaryReferences
31
- *
32
- * @returns A loader function that resolves module paths to their exports
15
+ * - For client components: Use client manifest and client.browser.js
16
+ * - For server components: Use server manifest and server.js
17
+ * - For static assets: Use static manifest
33
18
  */
34
- export declare function createBuildLoader({ userOptions, serverManifest, clientManifest, staticManifest, }: BuildLoaderOptions, bundle: OutputBundle): Promise<(id: string) => Promise<any>>;
19
+ export declare function createBuildLoader<T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>({ userOptions, serverManifest, clientManifest, staticManifest, }: BuildLoaderOptions<T, InlineCSS>, bundle: OutputBundle): Promise<(id: string) => Promise<any>>;
35
20
  //# sourceMappingURL=createBuildLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,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,EACd,cAAc,EACd,cAAc,GACf,EAAE,kBAAkB,CAAC,CAAC,EAAE,SAAS,CAAC,EACnC,MAAM,EAAE,YAAY,gBAOkB,MAAM,mBAgJ7C"}
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { join } from 'node:path';
7
7
  import { getModuleRef } from '../helpers/moduleRefs.js';
8
- import { readFile } from 'node:fs/promises';
9
8
  import { temporaryReferences } from './temporaryReferences.js';
9
+ import { toError } from '../error/toError.js';
10
10
 
11
11
  async function createBuildLoader({
12
12
  userOptions,
@@ -20,7 +20,7 @@ async function createBuildLoader({
20
20
  }
21
21
  return async function buildLoader(id) {
22
22
  const [withoutQuery, query] = id.split("?", 2);
23
- const [, normalizedValue] = userOptions.normalizer(withoutQuery);
23
+ const [normalizedKey, normalizedValue] = userOptions.normalizer(withoutQuery);
24
24
  const moduleRef = getModuleRef(id);
25
25
  if (temporaryReferences?.has(moduleRef)) {
26
26
  const mod = temporaryReferences.get(moduleRef);
@@ -30,88 +30,102 @@ async function createBuildLoader({
30
30
  }
31
31
  try {
32
32
  if (query === "inline") {
33
- const serverChunk = bundle[serverManifest[normalizedValue]?.file] ?? bundle[staticManifest[normalizedValue]?.file] ?? bundle[clientManifest[normalizedValue]?.file] ?? bundle[withoutQuery];
33
+ const startsWithMarker = normalizedKey.split("-")[0];
34
+ const serverChunk = bundle[serverManifest[normalizedValue]?.file] ?? bundle[staticManifest[normalizedValue]?.file] ?? bundle[clientManifest[normalizedValue]?.file] ?? bundle[withoutQuery] ?? bundle[normalizedValue] ?? Object.entries(bundle).find(
35
+ ([, value]) => value.name === normalizedValue
36
+ )?.[1] ?? Object.entries(bundle).find(
37
+ ([_key]) => _key.startsWith(startsWithMarker)
38
+ )?.[1];
34
39
  if (serverChunk) {
35
40
  if (serverChunk.type === "asset") {
41
+ if (userOptions.autoDiscover.jsonPattern(normalizedValue)) {
42
+ const jsonContent = serverChunk.source;
43
+ if (typeof jsonContent === "string") {
44
+ return { default: JSON.parse(jsonContent) };
45
+ }
46
+ } else if (userOptions.autoDiscover.cssPattern(normalizedValue)) {
47
+ const cssContent = serverChunk.source;
48
+ if (typeof cssContent === "string") {
49
+ return { default: cssContent };
50
+ }
51
+ }
36
52
  return { default: serverChunk.source };
37
53
  } else if ("code" in serverChunk) {
38
54
  return { default: serverChunk.code };
39
- } else {
40
- console.warn("Could not find inline module for: " + normalizedValue);
41
55
  }
42
56
  }
43
- const module = {
44
- default: await readFile(
45
- join(
57
+ console.warn("Could not find inline module for: " + normalizedValue);
58
+ return null;
59
+ }
60
+ const isClientComponent = userOptions.autoDiscover.clientComponents(normalizedValue);
61
+ const isServerAction = userOptions.autoDiscover.serverFunctions(normalizedValue);
62
+ const isPage = userOptions.autoDiscover.pagePattern(normalizedValue);
63
+ const isProps = userOptions.autoDiscover.propsPattern(normalizedValue);
64
+ if (isClientComponent) {
65
+ const clientEntry = clientManifest[normalizedValue];
66
+ if (clientEntry) {
67
+ try {
68
+ const module = await import(join(
46
69
  userOptions.projectRoot,
47
70
  userOptions.build.outDir,
48
- userOptions.build.static,
49
- normalizedValue
50
- ),
51
- "utf-8"
52
- )
53
- };
54
- temporaryReferences?.set(moduleRef, module);
55
- return module;
56
- }
57
- const clientEntry = clientManifest[normalizedValue];
58
- if (clientEntry) {
59
- const module = await import(join(
60
- userOptions.projectRoot,
61
- userOptions.build.outDir,
62
- userOptions.build.client,
63
- clientEntry.file
64
- ));
65
- console.warn(
66
- "client module used in buildLoader, consider making this available in the server manifest",
67
- module
68
- );
69
- temporaryReferences?.set(moduleRef, module);
70
- return module;
71
- }
72
- const bundleEntry = bundle[withoutQuery];
73
- if (bundleEntry) {
74
- const module = await import(join(
75
- userOptions.projectRoot,
76
- userOptions.build.outDir,
77
- userOptions.build.server,
78
- bundleEntry.fileName
79
- ));
80
- temporaryReferences?.set(moduleRef, module);
71
+ userOptions.build.client,
72
+ clientEntry.file
73
+ ));
74
+ temporaryReferences?.set(moduleRef, module);
75
+ return module;
76
+ } catch (error) {
77
+ const err = toError(error);
78
+ console.warn("Error loading client module:", err);
79
+ temporaryReferences?.delete(moduleRef);
80
+ throw err;
81
+ }
82
+ }
81
83
  }
82
- const serverEntry = serverManifest[normalizedValue];
83
- if (serverEntry) {
84
- const module = await import(join(
85
- userOptions.projectRoot,
86
- userOptions.build.outDir,
87
- userOptions.build.server,
88
- serverEntry.file
89
- ));
90
- temporaryReferences?.set(moduleRef, module);
91
- return module;
84
+ if (isServerAction || isPage || isProps) {
85
+ const serverEntry = serverManifest[normalizedValue];
86
+ if (serverEntry) {
87
+ try {
88
+ const module = await import(join(
89
+ userOptions.projectRoot,
90
+ userOptions.build.outDir,
91
+ userOptions.build.server,
92
+ serverEntry.file
93
+ ));
94
+ temporaryReferences?.set(moduleRef, module);
95
+ return module;
96
+ } catch (error) {
97
+ const err = toError(error);
98
+ console.warn("Error loading server module:", err);
99
+ temporaryReferences?.delete(moduleRef);
100
+ throw err;
101
+ }
102
+ }
92
103
  }
93
104
  const staticEntry = staticManifest[normalizedValue];
94
105
  if (staticEntry) {
95
- const module = await import(join(
96
- userOptions.projectRoot,
97
- userOptions.build.outDir,
98
- userOptions.build.static,
99
- staticEntry.file
100
- ));
101
- console.warn(
102
- "static module used in buildLoader, consider making this available in the server manifest",
103
- module
104
- );
105
- temporaryReferences?.set(moduleRef, module);
106
- return module;
106
+ try {
107
+ const module = await import(join(
108
+ userOptions.projectRoot,
109
+ userOptions.build.outDir,
110
+ userOptions.build.static,
111
+ staticEntry.file
112
+ ));
113
+ temporaryReferences?.set(moduleRef, module);
114
+ return module;
115
+ } catch (error) {
116
+ const err = toError(error);
117
+ console.warn("Error loading static module:", err);
118
+ temporaryReferences?.delete(moduleRef);
119
+ throw err;
120
+ }
107
121
  }
108
- throw new Error(`Module ${normalizedValue} not found`);
122
+ throw new Error(`Module ${normalizedValue} not found during build`);
109
123
  } catch (error) {
110
124
  const emptyExports = {
111
125
  error: error instanceof Error ? error : new Error(String(error)),
112
126
  id
113
127
  };
114
- temporaryReferences?.set(moduleRef, emptyExports);
128
+ temporaryReferences?.delete(moduleRef);
115
129
  return emptyExports;
116
130
  }
117
131
  };
@@ -1 +1 @@
1
- {"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type { ResolvedUserConfig, ResolvedUserOptions } from \"../../server.js\";\nimport type { Manifest } from \"vite\";\nimport { getModuleRef } from \"../helpers/moduleRefs.js\";\nimport { readFile } from \"node:fs/promises\";\nimport type { OutputBundle } from \"rollup\";\nimport { temporaryReferences } from \"./temporaryReferences.js\";\n\nexport interface BuildLoaderOptions {\n userConfig: ResolvedUserConfig;\n userOptions: ResolvedUserOptions;\n serverManifest: Manifest;\n clientManifest: Manifest;\n staticManifest: Manifest;\n}\n\n/**\n * Creates a loader function for handling module resolution during build.\n *\n * The loader handles the following strategy:\n * - Just load any file from any manifest we can find in the order of client, server, static\n * - Ideally the buildLoader is only used form loading pages, props and inline css modules\n * -\n *\n * During build:\n * - We use the manifest information to get module exports\n * - The manifest contains the transformed modules with their exports\n * - We store the module in temporaryReferences for later use\n *\n * @param options.root - The project root directory\n * @param options.pluginContext - The Rollup plugin context\n * @param options.userConfig - Resolved user configuration\n * @param options.userOptions - Resolved user options\n * @param options.serverManifest - Vite server manifest\n * @param options.clientManifest - Vite client manifest\n * @param options.options - Additional options including temporaryReferences\n *\n * @returns A loader function that resolves module paths to their exports\n */\nexport async function createBuildLoader(\n {\n userOptions,\n serverManifest,\n clientManifest,\n staticManifest,\n }: BuildLoaderOptions,\n bundle: OutputBundle\n) {\n const manifestKeys = Object.keys(serverManifest);\n if (!manifestKeys.length) {\n throw new Error(\"Server manifest is empty\");\n }\n return async function buildLoader(id: string) {\n const [withoutQuery, query] = id.split(\"?\", 2);\n const [, normalizedValue] = userOptions.normalizer(withoutQuery);\n const moduleRef = getModuleRef(id);\n // Check if we have a temporary reference (cached module)\n if (temporaryReferences?.has(moduleRef)) {\n const mod = temporaryReferences.get(moduleRef);\n if (typeof mod === \"object\" && mod !== null && \"error\" in mod) {\n // ignore it\n } else {\n return mod;\n }\n }\n\n try {\n // For inline modules, handle them directly\n if (query === \"inline\") {\n // Then check server manifest\n const serverChunk =\n bundle[serverManifest[normalizedValue]?.file] ??\n bundle[staticManifest[normalizedValue]?.file] ??\n bundle[clientManifest[normalizedValue]?.file] ??\n bundle[withoutQuery];\n if (serverChunk) {\n if (serverChunk.type === \"asset\") {\n return { default: serverChunk.source };\n } else if (\"code\" in serverChunk) {\n return { default: serverChunk.code };\n } else {\n console.warn(\"Could not find inline module for: \" + normalizedValue);\n }\n }\n\n // If not found in either manifest, try reading the file directly\n const module = {\n default: await readFile(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.static,\n normalizedValue\n ),\n \"utf-8\"\n ),\n };\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n const clientEntry = clientManifest[normalizedValue];\n if (clientEntry) {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.client,\n clientEntry.file\n )\n );\n console.warn(\n \"client module used in buildLoader, consider making this available in the server manifest\",\n module\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n const bundleEntry = bundle[withoutQuery];\n if (bundleEntry) {\n // Load the module\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.server,\n bundleEntry.fileName\n )\n );\n temporaryReferences?.set(moduleRef, module);\n }\n // Try to resolve the module using Vite's resolution\n const serverEntry = serverManifest[normalizedValue];\n if (serverEntry) {\n // Load the module\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.server,\n serverEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n // try static manifest\n const staticEntry = staticManifest[normalizedValue];\n if (staticEntry) {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.static,\n staticEntry.file\n )\n );\n console.warn(\n \"static module used in buildLoader, consider making this available in the server manifest\",\n module\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n throw new Error(`Module ${normalizedValue} not found`);\n } catch (error) {\n const emptyExports = {\n error: error instanceof Error ? error : new Error(String(error)),\n id: id,\n };\n temporaryReferences?.set(moduleRef, emptyExports);\n return emptyExports;\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAuCA,eAAsB,iBACpB,CAAA;AAAA,EACE,WAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,EACA,MACA,EAAA;AACA,EAAM,MAAA,YAAA,GAAe,MAAO,CAAA,IAAA,CAAK,cAAc,CAAA;AAC/C,EAAI,IAAA,CAAC,aAAa,MAAQ,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA;AAAA;AAE5C,EAAO,OAAA,eAAe,YAAY,EAAY,EAAA;AAC5C,IAAA,MAAM,CAAC,YAAc,EAAA,KAAK,IAAI,EAAG,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AAC7C,IAAA,MAAM,GAAG,eAAe,CAAI,GAAA,WAAA,CAAY,WAAW,YAAY,CAAA;AAC/D,IAAM,MAAA,SAAA,GAAY,aAAa,EAAE,CAAA;AAEjC,IAAI,IAAA,mBAAA,EAAqB,GAAI,CAAA,SAAS,CAAG,EAAA;AACvC,MAAM,MAAA,GAAA,GAAM,mBAAoB,CAAA,GAAA,CAAI,SAAS,CAAA;AAC7C,MAAA,IAAI,OAAO,GAAQ,KAAA,QAAA,IAAY,GAAQ,KAAA,IAAA,IAAQ,WAAW,GAAK,EAAA,CAExD,MAAA;AACL,QAAO,OAAA,GAAA;AAAA;AACT;AAGF,IAAI,IAAA;AAEF,MAAA,IAAI,UAAU,QAAU,EAAA;AAEtB,QAAM,MAAA,WAAA,GACJ,OAAO,cAAe,CAAA,eAAe,GAAG,IAAI,CAAA,IAC5C,OAAO,cAAe,CAAA,eAAe,GAAG,IAAI,CAAA,IAC5C,OAAO,cAAe,C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AC,CAAA;AAAA,QAC/D;AAAA,OACF;AACA,MAAqB,mBAAA,EAAA,GAAA,CAAI,WAAW,YAAY,CAAA;AAChD,MAAO,OAAA,YAAA;AAAA;AACT,GACF;AACF;;;;"}
1
+ {"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type {\n InlineCssOpt,\n PagePropOpt,\n ResolvedUserConfig,\n ResolvedUserOptions,\n} from \"../../server.js\";\nimport type { Manifest } from \"vite\";\nimport { getModuleRef } from \"../helpers/moduleRefs.js\";\nimport type { OutputBundle } from \"rollup\";\nimport { temporaryReferences } from \"./temporaryReferences.js\";\nimport { toError } from \"../error/toError.js\";\n\nexport interface BuildLoaderOptions<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n> {\n userConfig: ResolvedUserConfig;\n userOptions: ResolvedUserOptions<T, InlineCSS>;\n serverManifest: Manifest;\n clientManifest: Manifest;\n staticManifest: Manifest;\n}\n\n/**\n * Creates a loader function for handling module resolution during build.\n *\n * The loader handles the following strategy:\n * - For client components: Use client manifest and client.browser.js\n * - For server components: Use server manifest and server.js\n * - For static assets: Use static manifest\n */\nexport async function createBuildLoader<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>(\n {\n userOptions,\n serverManifest,\n clientManifest,\n staticManifest,\n }: BuildLoaderOptions<T, InlineCSS>,\n bundle: OutputBundle\n) {\n const manifestKeys = Object.keys(serverManifest);\n if (!manifestKeys.length) {\n throw new Error(\"Server manifest is empty\");\n }\n\n return async function buildLoader(id: string) {\n const [withoutQuery, query] = id.split(\"?\", 2);\n const [normalizedKey, normalizedValue] =\n userOptions.normalizer(withoutQuery);\n const moduleRef = getModuleRef(id);\n\n // Check if we have a temporary reference (cached module)\n if (temporaryReferences?.has(moduleRef)) {\n const mod = temporaryReferences.get(moduleRef);\n if (typeof mod === \"object\" && mod !== null && \"error\" in mod) {\n // ignore it\n } else {\n return mod;\n }\n }\n\n try {\n // For inline modules, handle them directly\n if (query === \"inline\") {\n const startsWithMarker = normalizedKey.split(\"-\")[0];\n const serverChunk =\n bundle[serverManifest[normalizedValue]?.file] ??\n bundle[staticManifest[normalizedValue]?.file] ??\n bundle[clientManifest[normalizedValue]?.file] ??\n bundle[withoutQuery] ??\n bundle[normalizedValue] ??\n Object.entries(bundle).find(\n ([, value]) => value.name === normalizedValue\n )?.[1] ??\n Object.entries(bundle).find(([_key]) =>\n _key.startsWith(startsWithMarker)\n )?.[1];\n\n if (serverChunk) {\n if (serverChunk.type === \"asset\") {\n // For CSS files, ensure we're in the React Server environment\n if (userOptions.autoDiscover.jsonPattern(normalizedValue)) {\n const jsonContent = serverChunk.source;\n if (typeof jsonContent === \"string\") {\n return { default: JSON.parse(jsonContent) };\n }\n } else if (userOptions.autoDiscover.cssPattern(normalizedValue)) {\n const cssContent = serverChunk.source;\n if (typeof cssContent === \"string\") {\n return { default: cssContent };\n }\n }\n return { default: serverChunk.source };\n } else if (\"code\" in serverChunk) {\n return { default: serverChunk.code };\n }\n }\n console.warn(\"Could not find inline module for: \" + normalizedValue);\n return null;\n }\n\n // Determine if this is a client component\n const isClientComponent =\n userOptions.autoDiscover.clientComponents(normalizedValue);\n const isServerAction =\n userOptions.autoDiscover.serverFunctions(normalizedValue);\n const isPage = userOptions.autoDiscover.pagePattern(normalizedValue);\n const isProps = userOptions.autoDiscover.propsPattern(normalizedValue);\n\n // For client components, use client manifest\n if (isClientComponent) {\n const clientEntry = clientManifest[normalizedValue];\n if (clientEntry) {\n try {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.client,\n clientEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n } catch (error) {\n const err = toError(error);\n console.warn(\"Error loading client module:\", err);\n temporaryReferences?.delete(moduleRef);\n throw err;\n }\n }\n }\n\n // For server components and actions, use server manifest\n if (isServerAction || isPage || isProps) {\n const serverEntry = serverManifest[normalizedValue];\n if (serverEntry) {\n try {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.server,\n serverEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n } catch (error) {\n const err = toError(error);\n console.warn(\"Error loading server module:\", err);\n temporaryReferences?.delete(moduleRef);\n throw err;\n }\n }\n }\n\n // For static assets, use static manifest\n const staticEntry = staticManifest[normalizedValue];\n if (staticEntry) {\n try {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.static,\n staticEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n } catch (error) {\n const err = toError(error);\n console.warn(\"Error loading static module:\", err);\n temporaryReferences?.delete(moduleRef);\n throw err;\n }\n }\n\n throw new Error(`Module ${normalizedValue} not found during build`);\n } catch (error) {\n const emptyExports = {\n error: error instanceof Error ? error : new Error(String(error)),\n id: id,\n };\n temporaryReferences?.delete(moduleRef);\n return emptyExports;\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAgCA,eAAsB,iBAIpB,CAAA;AAAA,EACE,WAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,EACA,MACA,EAAA;AACA,EAAM,MAAA,YAAA,GAAe,MAAO,CAAA,IAAA,CAAK,cAAc,CAAA;AAC/C,EAAI,IAAA,CAAC,aAAa,MAAQ,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA;AAAA;AAG5C,EAAO,OAAA,eAAe,YAAY,EAAY,EAAA;AAC5C,IAAA,MAAM,CAAC,YAAc,EAAA,KAAK,IAAI,EAAG,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AAC7C,IAAA,MAAM,CAAC,aAAe,EAAA,eAAe,CACnC,GAAA,WAAA,CAAY,WAAW,YAAY,CAAA;AACrC,IAAM,MAAA,SAAA,GAAY,aAAa,EAAE,CAAA;AAGjC,IAAI,IA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KAAO,EAAA;AACd,UAAM,MAAA,GAAA,GAAM,QAAQ,KAAK,CAAA;AACzB,UAAQ,OAAA,CAAA,IAAA,CAAK,gCAAgC,GAAG,CAAA;AAChD,UAAA,mBAAA,EAAqB,OAAO,SAAS,CAAA;AACrC,UAAM,MAAA,GAAA;AAAA;AACR;AAGF,MAAA,MAAM,IAAI,KAAA,CAAM,CAAU,OAAA,EAAA,eAAe,CAAyB,uBAAA,CAAA,CAAA;AAAA,aAC3D,KAAO,EAAA;AACd,MAAA,MAAM,YAAe,GAAA;AAAA,QACnB,KAAA,EAAO,iBAAiB,KAAQ,GAAA,KAAA,GAAQ,IAAI,KAAM,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,QAC/D;AAAA,OACF;AACA,MAAA,mBAAA,EAAqB,OAAO,SAAS,CAAA;AACrC,MAAO,OAAA,YAAA;AAAA;AACT,GACF;AACF;;;;"}
@@ -0,0 +1,13 @@
1
+ import type { LoaderContext } from "../types.js";
2
+ export interface LoaderResult {
3
+ source: string;
4
+ map: any | null;
5
+ }
6
+ export interface Loader {
7
+ (id: string, context?: LoaderContext, nextLoad?: any): LoaderResult;
8
+ }
9
+ /**
10
+ * Creates a default loader function that either uses provided source or reads from file
11
+ */
12
+ export declare function createDefaultLoader(source?: string): Loader;
13
+ //# sourceMappingURL=createDefaultLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDefaultLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createDefaultLoader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,YAAY,CAAC;CACrE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CA6C3D"}
@@ -0,0 +1,47 @@
1
+ import { readFileSync } from "fs";
2
+ import * as esbuild from "esbuild";
3
+ /**
4
+ * Creates a default loader function that either uses provided source or reads from file
5
+ */
6
+ export function createDefaultLoader(source) {
7
+ if (typeof source === "string") {
8
+ return function load(id) {
9
+ // Use esbuild to transform the code
10
+ const result = esbuild.transformSync(source, {
11
+ loader: "tsx",
12
+ format: "esm",
13
+ target: "esnext",
14
+ sourcemap: true,
15
+ sourcefile: id,
16
+ });
17
+ return {
18
+ source: result.code,
19
+ map: result.map ? JSON.parse(result.map) : null,
20
+ };
21
+ };
22
+ }
23
+ return function load(id, context, nextLoad) {
24
+ if (!nextLoad) {
25
+ nextLoad = (id) => {
26
+ const source = readFileSync(id, "utf-8");
27
+ // Use esbuild to transform the code
28
+ const result = esbuild.transformSync(source, {
29
+ loader: "tsx",
30
+ format: "esm",
31
+ target: "esnext",
32
+ sourcemap: true,
33
+ sourcefile: id,
34
+ });
35
+ return {
36
+ source: result.code,
37
+ map: result.map ? JSON.parse(result.map) : null,
38
+ };
39
+ };
40
+ }
41
+ const result = nextLoad(id, context);
42
+ return {
43
+ ...result,
44
+ map: "map" in result ? result.map : null,
45
+ };
46
+ };
47
+ }
@@ -14,6 +14,7 @@ export declare let loaderPort: MessagePort | undefined;
14
14
  * @param data.port - The message port for communication
15
15
  */
16
16
  export declare function initialize(data: {
17
+ id: string;
17
18
  port: MessagePort;
18
19
  resolvedConfig: SerializedUserConfig;
19
20
  }): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAQvE;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAY/C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,oBAAoB,CAAA;CAAE,iBAIjG;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,QAEjD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzD;AA2DD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,GAAG;IAAE,cAAc,EAAE,oBAAoB,CAAA;CAAE,EACnF,WAAW,EAAE,GAAG,gBAQjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,OAE3E"}
1
+ {"version":3,"file":"css-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASvE;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAY/C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,oBAAoB,CAAA;CAAE,iBAI7G;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,QAEjD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzD;AA2DD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,GAAG;IAAE,cAAc,EAAE,oBAAoB,CAAA;CAAE,EACnF,WAAW,EAAE,GAAG,gBAQjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,OAE3E"}
@@ -17,7 +17,7 @@ let resolvedConfig;
17
17
  async function initialize(data) {
18
18
  loaderPort = data.port;
19
19
  resolvedConfig = data.resolvedConfig;
20
- data.port.postMessage({ type: "INITIALIZED_CSS_LOADER" });
20
+ data.port.postMessage({ type: "INITIALIZED_CSS_LOADER", id: data.id });
21
21
  }
22
22
  function setCurrentPage(page) {
23
23
  currentPage = page;
@@ -1 +1 @@
1
- {"version":3,"file":"css-loader.development.js","sources":["../../../plugin/loader/css-loader.development.ts"],"sourcesContent":["import { type MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext, SerializedUserConfig } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { preprocessCSS } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { env } from \"../utils/env.js\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\n/**\n * Tracks CSS files used by each page.\n * Maps page URLs to sets of CSS file paths that are used by that page.\n */\nconst cssFilesByPage = new Map<string, Set<string>>();\n\nlet currentPage: string | null = null;\nlet resolvedConfig: ResolvedConfig | undefined;\n\n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n */\nexport async function initialize(data: { port: MessagePort, resolvedConfig: SerializedUserConfig }) {\n loaderPort = data.port;\n resolvedConfig = data.resolvedConfig;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\" });\n}\n\n/**\n * Sets the current page being processed.\n * Used to track which CSS files are associated with which pages.\n *\n * @param page - The URL of the current page, or null if no page is active\n */\nexport function setCurrentPage(page: string | null) {\n currentPage = page;\n}\n\n/**\n * Retrieves all CSS files associated with a specific page.\n *\n * @param page - The URL of the page\n * @returns An array of CSS file paths used by the page\n */\nexport function getCssFilesForPage(page: string): string[] {\n return Array.from(cssFilesByPage.get(page) || []);\n}\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @param config - The Vite config\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string,\n config: ResolvedConfig,\n inline: boolean\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n const processed = await preprocessCSS(source, path, {\n ...config,\n env: env\n });\n\n // If we're processing CSS for a specific page, notify the message handler\n if (loaderPort) {\n loaderPort.postMessage({\n type: \"CSS_FILE\",\n id: currentPage ? join(path, \"?page=\" + currentPage) : path,\n path: path,\n content: processed.code,\n modules: processed.modules || {},\n inline,\n });\n }\n\n // Return a module that can be used by React components\n if (inline) {\n return {\n format: \"module\",\n source: processed.code,\n shortCircuit: true,\n };\n }\n return {\n format: \"module\",\n source: `export default ${JSON.stringify(processed.modules || {})};`,\n shortCircuit: true,\n };\n } catch (error) {\n console.error(`[css-loader] Error processing CSS file: ${error}`);\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext & { resolvedConfig: SerializedUserConfig },\n defaultLoad: any\n) {\n const [name, query] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url, resolvedConfig as ResolvedConfig, query === \"inline\");\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n\n/**\n * Vite's resolve hook implementation.\n * Handles module resolution during development.\n *\n * @param specifier - The module specifier to resolve\n * @param context - The resolve hook context\n * @param defaultResolve - The default resolve function\n * @returns A promise that resolves to the resolved module\n */\nexport function resolve(specifier: string, context: any, defaultResolve: any) {\n return defaultResolve(specifier, context, defaultResolve);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAcW,IAAA;AAMX,MAAM,cAAA,uBAAqB,GAAyB,EAAA;AAEpD,IAAI,WAA6B,GAAA,IAAA;AACjC,IAAI,cAAA;AAUJ,eAAsB,WAAW,IAAmE,EAAA;AAClG,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAA,cAAA,GAAiB,IAAK,CAAA,cAAA;AACtB,EAAA,IAAA,CAAK,IAAK,CAAA,WAAA,CAAY,EAAE,IAAA,EAAM,0BAA0B,CAAA;AAC1D;AAQO,SAAS,eAAe,IAAqB,EAAA;AAClD,EAAc,WAAA,GAAA,IAAA;AAChB;AAQO,SAAS,mBAAmB,IAAwB,EAAA;AACzD,EAAA,OAAO,MAAM,IAAK,CAAA,cAAA,CAAe,IAAI,IAAI,CAAA,IAAK,EAAE,CAAA;AAClD;AAUA,eAAe,cAAA,CACb,QACA,EAAA,MAAA,EACA,MACoE,EAAA;AACpE,EAAI,IAAA;AAEF,IAAA,MAAM,OAAO,QAAS,CAAA,UAAA,CAAW,SAAS,CACtC,GA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AA,MAAM,CAAG,EAAA;AACzB,IAAA,OAAO,cAAe,CAAA,GAAA,EAAK,cAAkC,EAAA,KAAA,KAAU,QAAQ,CAAA;AAAA;AAGjF,EAAO,OAAA,WAAA,CAAY,GAAK,EAAA,OAAA,EAAS,WAAW,CAAA;AAC9C;AAWO,SAAS,OAAA,CAAQ,SAAmB,EAAA,OAAA,EAAc,cAAqB,EAAA;AAC5E,EAAO,OAAA,cAAA,CAAe,SAAW,EAAA,OAAA,EAAS,cAAc,CAAA;AAC1D;;;;"}
1
+ {"version":3,"file":"css-loader.development.js","sources":["../../../plugin/loader/css-loader.development.ts"],"sourcesContent":["import { type MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext, SerializedUserConfig } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { preprocessCSS } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { env } from \"../utils/env.js\";\nimport type { InitializedCssLoaderMessage } from \"../worker/types.js\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\n/**\n * Tracks CSS files used by each page.\n * Maps page URLs to sets of CSS file paths that are used by that page.\n */\nconst cssFilesByPage = new Map<string, Set<string>>();\n\nlet currentPage: string | null = null;\nlet resolvedConfig: ResolvedConfig | undefined;\n\n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n */\nexport async function initialize(data: { id: string, port: MessagePort, resolvedConfig: SerializedUserConfig }) {\n loaderPort = data.port;\n resolvedConfig = data.resolvedConfig;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\", id: data.id } satisfies InitializedCssLoaderMessage);\n}\n\n/**\n * Sets the current page being processed.\n * Used to track which CSS files are associated with which pages.\n *\n * @param page - The URL of the current page, or null if no page is active\n */\nexport function setCurrentPage(page: string | null) {\n currentPage = page;\n}\n\n/**\n * Retrieves all CSS files associated with a specific page.\n *\n * @param page - The URL of the page\n * @returns An array of CSS file paths used by the page\n */\nexport function getCssFilesForPage(page: string): string[] {\n return Array.from(cssFilesByPage.get(page) || []);\n}\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @param config - The Vite config\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string,\n config: ResolvedConfig,\n inline: boolean\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n const processed = await preprocessCSS(source, path, {\n ...config,\n env: env\n });\n\n // If we're processing CSS for a specific page, notify the message handler\n if (loaderPort) {\n loaderPort.postMessage({\n type: \"CSS_FILE\",\n id: currentPage ? join(path, \"?page=\" + currentPage) : path,\n path: path,\n content: processed.code,\n modules: processed.modules || {},\n inline,\n });\n }\n\n // Return a module that can be used by React components\n if (inline) {\n return {\n format: \"module\",\n source: processed.code,\n shortCircuit: true,\n };\n }\n return {\n format: \"module\",\n source: `export default ${JSON.stringify(processed.modules || {})};`,\n shortCircuit: true,\n };\n } catch (error) {\n console.error(`[css-loader] Error processing CSS file: ${error}`);\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext & { resolvedConfig: SerializedUserConfig },\n defaultLoad: any\n) {\n const [name, query] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url, resolvedConfig as ResolvedConfig, query === \"inline\");\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n\n/**\n * Vite's resolve hook implementation.\n * Handles module resolution during development.\n *\n * @param specifier - The module specifier to resolve\n * @param context - The resolve hook context\n * @param defaultResolve - The default resolve function\n * @returns A promise that resolves to the resolved module\n */\nexport function resolve(specifier: string, context: any, defaultResolve: any) {\n return defaultResolve(specifier, context, defaultResolve);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAeW,IAAA;AAMX,MAAM,cAAA,uBAAqB,GAAyB,EAAA;AAEpD,IAAI,WAA6B,GAAA,IAAA;AACjC,IAAI,cAAA;AAUJ,eAAsB,WAAW,IAA+E,EAAA;AAC9G,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAA,cAAA,GAAiB,IAAK,CAAA,cAAA;AACtB,EAAK,IAAA,CAAA,IAAA,CAAK,YAAY,EAAE,IAAA,EAAM,0BAA0B,EAAI,EAAA,IAAA,CAAK,IAA0C,CAAA;AAC7G;AAQO,SAAS,eAAe,IAAqB,EAAA;AAClD,EAAc,WAAA,GAAA,IAAA;AAChB;AAQO,SAAS,mBAAmB,IAAwB,EAAA;AACzD,EAAA,OAAO,MAAM,IAAK,CAAA,cAAA,CAAe,IAAI,IAAI,CAAA,IAAK,EAAE,CAAA;AAClD;AAUA,eAAe,cAAA,CACb,QACA,EAAA,MAAA,EACA,MACoE,EAAA;AACpE,EAAI,IAAA;AAEF,IAAA,MAAM,OAAO,QAAS,CAAA,UAAA,CAAW,SAAS,CACtC,GAAA,aAAA,CAAc,QAAQ,CACtB,GAAA,QAAA;AAGJ,IAAA,MAAM,MAAS,GAAA,MAAM,QAAS,CAAA,IAAA,EAAM,OAAO,CAAA;AAC3C,IAAA,MAAM,SAAY,GAAA,MAAM,aAAc,CAAA,MAAA,EAAQ,IAAM,EAAA;AAAA,MAClD,GAAG,MAAA;AAAA,MACH;AAAA,KACD,CAAA;AAGD,IAAA,IAAI,UAAY,EAAA;AAC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AAe,SAAW,EAAA,OAAA,EAAS,cAAc,CAAA;AAC1D;;;;"}
@@ -0,0 +1,33 @@
1
+ import type { Program } from "./types.js";
2
+ /**
3
+ * Collects and organizes export information from a module.
4
+ *
5
+ * For all modules:
6
+ * - Collects import statements
7
+ * - Collects export names
8
+ * - Collects declarations
9
+ *
10
+ * The actual transformation of exports (like wrapping with registerServerReference)
11
+ * happens in transformModuleWithPreservedFunctions.
12
+ *
13
+ * @param source - The source code of the module
14
+ * @param url - The URL of the module
15
+ * @param program - The parsed AST program
16
+ * @param isServerFunction - Whether this is a server module
17
+ * @param isClientComponent - Whether this is a client module
18
+ * @returns Object containing imports, declarations, and export names
19
+ */
20
+ export declare function handleExports(source: string, program: Program, isServerFunction: boolean | RegExpMatchArray | null, isClientComponent: boolean | RegExpMatchArray | null): {
21
+ imports: string[];
22
+ declarations: string[];
23
+ exportNames: string[];
24
+ exports: Map<string, {
25
+ type: "function" | "class" | "variable" | "default" | "all";
26
+ declaration?: string;
27
+ localName?: string;
28
+ before?: string[];
29
+ after?: string[];
30
+ isAsync?: boolean;
31
+ }>;
32
+ };
33
+ //# sourceMappingURL=handleExports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleExports.d.ts","sourceRoot":"","sources":["../../../plugin/loader/handleExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,EACnD,iBAAiB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,GACnD;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,GAAG,CACV,MAAM,EACN;QACE,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;QAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CACF,CAAC;CACH,CA0OA"}