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
@@ -10,7 +10,12 @@
10
10
  */
11
11
 
12
12
  import { PassThrough, Transform } from "node:stream";
13
- import type { CreateHandlerOptions, StreamMetrics } from "../types.js";
13
+ import type {
14
+ CreateHandlerOptions,
15
+ StreamMetrics,
16
+ PagePropOpt,
17
+ InlineCssOpt,
18
+ } from "../types.js";
14
19
  import { createStreamMetrics } from "../helpers/metrics.js";
15
20
  import { createRscToHtmlStream } from "./rscToHtmlStream.js";
16
21
  import { fileWriter } from "./fileWriter.js";
@@ -21,9 +26,12 @@ import { fileWriter } from "./fileWriter.js";
21
26
  * @param rscFull The stream containing the RSC content
22
27
  * @returns A promise that resolves with the complete RSC content
23
28
  */
24
- export async function collectHtmlWorkerContent(
29
+ export async function collectHtmlWorkerContent<
30
+ T extends PagePropOpt = PagePropOpt,
31
+ InlineCSS extends InlineCssOpt = InlineCssOpt
32
+ >(
25
33
  rscStream: PassThrough,
26
- handlerOptions: CreateHandlerOptions
34
+ handlerOptions: CreateHandlerOptions<T, InlineCSS>
27
35
  ): Promise<{ stream: PassThrough; metrics: StreamMetrics }> {
28
36
  if (!handlerOptions.worker) {
29
37
  throw new Error("Worker is not a valid worker");
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * rscHandler.ts
3
- *
3
+ *
4
4
  * PURPOSE: Handles collecting RSC content from the rscHeadless stream
5
- *
5
+ *
6
6
  * This module:
7
7
  * 1. Collects RSC content from the rscHeadless stream
8
8
  * 2. Returns the complete RSC content when the stream is done
@@ -12,20 +12,28 @@
12
12
  import { PassThrough, Transform } from "node:stream";
13
13
  import { dirname, join } from "node:path";
14
14
  import { mkdir } from "node:fs/promises";
15
- import type { CreateHandlerOptions, StreamMetrics } from "../types.js";
15
+ import type {
16
+ CreateHandlerOptions,
17
+ StreamMetrics,
18
+ PagePropOpt,
19
+ InlineCssOpt,
20
+ } from "../types.js";
16
21
  import { createStreamMetrics } from "../helpers/metrics.js";
17
22
  import { fileWriter } from "./fileWriter.js";
18
23
 
19
24
  /**
20
25
  * Collects RSC content from the rscHeadless stream
21
- *
26
+ *
22
27
  * @param rscStream The stream containing the RSC content
23
28
  * @param handlerOptions The options for the handler
24
29
  * @returns A promise that resolves with the complete RSC content and metrics
25
30
  */
26
- export async function collectRscContent(
31
+ export async function collectRscContent<
32
+ T extends PagePropOpt = PagePropOpt,
33
+ InlineCSS extends InlineCssOpt = InlineCssOpt
34
+ >(
27
35
  rscStream: PassThrough,
28
- handlerOptions: CreateHandlerOptions
36
+ handlerOptions: CreateHandlerOptions<T, InlineCSS>
29
37
  ): Promise<{ stream: PassThrough; metrics: StreamMetrics }> {
30
38
  const metrics = createStreamMetrics();
31
39
  const startTime = performance.now();
@@ -51,7 +59,7 @@ export async function collectRscContent(
51
59
  flush(callback) {
52
60
  metrics.duration = performance.now() - startTime;
53
61
  callback();
54
- }
62
+ },
55
63
  });
56
64
 
57
65
  try {
@@ -63,7 +71,7 @@ export async function collectRscContent(
63
71
 
64
72
  // Wait for stream to complete
65
73
  await new Promise<void>((resolve) => {
66
- metricsTransform.on('end', resolve);
74
+ metricsTransform.on("end", resolve);
67
75
  });
68
76
 
69
77
  // Wait for file writing to complete
@@ -74,4 +82,4 @@ export async function collectRscContent(
74
82
  metricsTransform.destroy();
75
83
  throw error;
76
84
  }
77
- }
85
+ }
@@ -1,5 +1,9 @@
1
1
  import type { PreviewServer } from "vite";
2
- import type { ResolvedUserOptions } from "../types.js";
2
+ import type {
3
+ ResolvedUserOptions,
4
+ PagePropOpt,
5
+ InlineCssOpt,
6
+ } from "../types.js";
3
7
  import { join } from "node:path";
4
8
  import { createReadStream } from "node:fs";
5
9
  import { stat } from "node:fs/promises";
@@ -10,12 +14,15 @@ interface StreamError extends Error {
10
14
  code?: string;
11
15
  }
12
16
 
13
- export async function configurePreviewServer({
17
+ export async function configurePreviewServer<
18
+ T extends PagePropOpt = PagePropOpt,
19
+ InlineCSS extends InlineCssOpt = InlineCssOpt
20
+ >({
14
21
  server,
15
22
  userOptions,
16
23
  }: {
17
24
  server: PreviewServer;
18
- userOptions: ResolvedUserOptions;
25
+ userOptions: ResolvedUserOptions<T, InlineCSS>;
19
26
  }) {
20
27
  const staticHostDir = join(
21
28
  userOptions.projectRoot,
@@ -26,15 +33,20 @@ export async function configurePreviewServer({
26
33
  if (!req.url) {
27
34
  return next();
28
35
  }
29
- const { contentType, filePath } = requestInfo(req, userOptions, staticHostDir);
30
-
36
+ const { contentType, filePath } = requestInfo(
37
+ req,
38
+ userOptions,
39
+ staticHostDir,
40
+ server.config.logger
41
+ );
42
+
31
43
  // Handle static files including CSS
32
44
  if (filePath) {
33
45
  try {
34
46
  const stats = await stat(filePath);
35
47
  if (stats.isFile()) {
36
48
  res.setHeader("Content-Type", contentType);
37
-
49
+
38
50
  // Create abort controller for the stream
39
51
  const controller = new AbortController();
40
52
  const { signal } = controller;
@@ -48,7 +60,7 @@ export async function configurePreviewServer({
48
60
 
49
61
  try {
50
62
  const readStream = createReadStream(filePath);
51
- readStream.on('error', () => {
63
+ readStream.on("error", () => {
52
64
  if (!res.writable) {
53
65
  controller.abort();
54
66
  }
@@ -57,25 +69,33 @@ export async function configurePreviewServer({
57
69
  } catch (error) {
58
70
  const streamError = error as StreamError;
59
71
  // Handle different error cases
60
- if (streamError.code === 'ERR_STREAM_PREMATURE_CLOSE' ||
61
- streamError.name === 'AbortError') {
72
+ if (
73
+ streamError.code === "ERR_STREAM_PREMATURE_CLOSE" ||
74
+ streamError.name === "AbortError"
75
+ ) {
62
76
  // Client closed the connection
63
77
  if (res.writable) {
64
78
  res.statusCode = 499;
65
79
  res.end("Client closed request");
66
80
  }
67
- } else if (streamError.code === 'ENOENT') {
81
+ } else if (streamError.code === "ENOENT") {
68
82
  // File not found
69
83
  res.statusCode = 404;
70
- server.config.logger.error(`File not found: ${filePath}. ${streamError.message}`, {
71
- error: streamError,
72
- });
84
+ server.config.logger.error(
85
+ `File not found: ${filePath}. ${streamError.message}`,
86
+ {
87
+ error: streamError,
88
+ }
89
+ );
73
90
  res.end("File not found");
74
91
  } else {
75
92
  // Server error
76
- server.config.logger.error(`Error loading file: ${filePath}. ${streamError.message}`, {
77
- error: streamError,
78
- });
93
+ server.config.logger.error(
94
+ `Error loading file: ${filePath}. ${streamError.message}`,
95
+ {
96
+ error: streamError,
97
+ }
98
+ );
79
99
  res.statusCode = 500;
80
100
  res.end("Internal server error");
81
101
  }
@@ -86,7 +106,7 @@ export async function configurePreviewServer({
86
106
  } catch (error) {
87
107
  const err = error as Error;
88
108
  // Handle file system errors
89
- if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
109
+ if ((err as NodeJS.ErrnoException).code === "ENOENT") {
90
110
  res.statusCode = 404;
91
111
  res.end("File not found");
92
112
  } else {
@@ -34,6 +34,8 @@ import type {
34
34
  RenderPagesResult,
35
35
  AutoDiscoveredFiles,
36
36
  CssContent,
37
+ PagePropOpt,
38
+ InlineCssOpt,
37
39
  } from "../types.js";
38
40
  import { type StreamPluginOptions } from "../types.js";
39
41
  import { renderPages } from "./renderPages.js";
@@ -51,6 +53,7 @@ import { tryManifest } from "../helpers/tryManifest.js";
51
53
  import { performance } from "node:perf_hooks";
52
54
  import { DEFAULT_CONFIG } from "../config/defaults.js";
53
55
  import { baseURL } from "../utils/envUrls.node.js";
56
+ import { readFile } from "node:fs/promises";
54
57
 
55
58
  if (getCondition() !== "react-server") {
56
59
  throw new Error(
@@ -59,16 +62,21 @@ if (getCondition() !== "react-server") {
59
62
  );
60
63
  }
61
64
 
62
- let worker: Worker;
63
- let userConfig: ResolvedUserConfig;
64
- let resolvedConfig: ResolvedConfig;
65
- let userOptions: ResolvedUserOptions;
66
- let autoDiscoveredFiles: AutoDiscoveredFiles | null = null;
67
- let serverManifest: Manifest | undefined = undefined;
68
- let buildLoader: Awaited<ReturnType<typeof createBuildLoader>> | undefined;
69
- export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
65
+ export function reactStaticPlugin<
66
+ T extends PagePropOpt = PagePropOpt,
67
+ InlineCSS extends InlineCssOpt = InlineCssOpt
68
+ >(
69
+ options: StreamPluginOptions<T, InlineCSS>
70
+ ): VitePlugin<{
70
71
  meta: ReactStreamPluginMeta;
71
72
  }> {
73
+ let worker: Worker;
74
+ let userConfig: ResolvedUserConfig;
75
+ let resolvedConfig: ResolvedConfig;
76
+ let userOptions: ResolvedUserOptions<T, InlineCSS>;
77
+ let autoDiscoveredFiles: AutoDiscoveredFiles | null = null;
78
+ let serverManifest: Manifest | undefined = undefined;
79
+ let buildLoader: Awaited<ReturnType<typeof createBuildLoader>> | undefined;
72
80
  const timing: BuildTiming = {
73
81
  start: Date.now(),
74
82
  configResolved: 0,
@@ -93,6 +101,10 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
93
101
  if (config.root && config.root !== userOptions.projectRoot) {
94
102
  userOptions.projectRoot = config.root;
95
103
  }
104
+ if(configEnv.command !== "build") {
105
+ return;
106
+ }
107
+ // Initialize autoDiscoveredFiles for both server and client builds
96
108
  const autoDiscoverResult = await resolveAutoDiscover({
97
109
  config,
98
110
  configEnv,
@@ -134,7 +146,6 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
134
146
  },
135
147
 
136
148
  async renderStart() {
137
-
138
149
  timing.renderStart = Date.now();
139
150
  },
140
151
 
@@ -165,7 +176,7 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
165
176
  if (!serverManifest) {
166
177
  throw new Error("Failed to parse server manifest");
167
178
  }
168
-
179
+
169
180
  const clientManifestResult = await tryManifest({
170
181
  root: userOptions.projectRoot,
171
182
  outDir: join(userOptions.build.outDir, userOptions.build.client),
@@ -175,11 +186,11 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
175
186
  throw clientManifestResult.error;
176
187
  }
177
188
  const clientManifest = clientManifestResult.manifest;
178
-
179
- buildLoader = await createBuildLoader(
189
+
190
+ buildLoader = await createBuildLoader<T, InlineCSS>(
180
191
  {
181
192
  userConfig,
182
- userOptions,
193
+ userOptions: userOptions as ResolvedUserOptions<T, InlineCSS>,
183
194
  serverManifest: serverManifest ?? {},
184
195
  staticManifest: autoDiscoveredFiles?.staticManifest ?? {},
185
196
  clientManifest: clientManifest ?? {},
@@ -197,7 +208,7 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
197
208
  userOptions
198
209
  );
199
210
 
200
- const globalCss: Map<string, CssContent> = new Map();
211
+ const globalCss: Map<string, CssContent<InlineCSS>> = new Map();
201
212
  // Collect CSS files for each page and its props
202
213
  for (const [url, { page, props }] of autoDiscoveredFiles?.urlMap ??
203
214
  []) {
@@ -226,17 +237,25 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
226
237
  const pageCssMap: Map<string, CssContent> = new Map();
227
238
  // Add global styles if they exist
228
239
  if (Object.keys(globalCssInputs).length > 0) {
229
- for (const [, value] of Object.entries(globalCssInputs)) {
230
- const cssContent = await buildLoader(value + "?inline").then(
231
- (r) => String(r.default)
240
+ for (const [key, value] of Object.entries(globalCssInputs)) {
241
+ let cssContent = await buildLoader(value + "?inline").then((r) =>
242
+ String(r.default)
232
243
  );
233
- if (cssContent === "undefined") {
234
- throw new Error(`CSS content is undefined for ${value}`);
244
+ if (cssContent === "undefined" || !cssContent) {
245
+ cssContent = await readFile(
246
+ join(
247
+ userOptions.projectRoot,
248
+ userOptions.build.outDir,
249
+ userOptions.build.static,
250
+ key + ".css"
251
+ ),
252
+ "utf-8"
253
+ ) ?? ""
235
254
  }
236
255
  if (cssContent) {
237
256
  globalCss.set(
238
257
  value,
239
- createCssProps({
258
+ createCssProps<T, InlineCSS>({
240
259
  id: value,
241
260
  code: cssContent,
242
261
  userOptions: userOptions,
@@ -355,6 +374,10 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
355
374
  client: userOptions.build.client,
356
375
  },
357
376
  globalCss: globalCss,
377
+ css: {
378
+ ...handlerOptions.css,
379
+ inlineCss: handlerOptions.css?.inlineCss ?? true,
380
+ },
358
381
  },
359
382
  cssFilesByPage
360
383
  );
@@ -378,9 +401,9 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
378
401
  this.environment.logger.info(
379
402
  `Rendered ${finalResult.completedRoutes.size} unique routes in ${finalResult.streamMetrics.duration}ms`
380
403
  );
381
- if(process.env['NODE_ENV'] !== 'production') {
404
+ if (process.env["NODE_ENV"] !== "production") {
382
405
  this.environment.logger.warn(
383
- `THIS IS BUILD IS NOT INTENDED FOR PRODUCTION (${process.env['NODE_ENV']})`
406
+ `THIS IS BUILD IS NOT INTENDED FOR PRODUCTION (${process.env["NODE_ENV"]})`
384
407
  );
385
408
  }
386
409
 
@@ -1,12 +1,18 @@
1
1
  import { createRenderMetrics } from "../helpers/metrics.js";
2
2
  import { resolvePageAndProps } from "../helpers/resolvePageAndProps.js";
3
- import type { CreateHandlerOptions, RenderPageResult } from "../types.js";
3
+ import type {
4
+ CreateHandlerOptions,
5
+ RenderPageResult,
6
+ PagePropOpt,
7
+ } from "../types.js";
4
8
  import { renderStreams } from "./renderStreams.js";
5
9
  import { collectHtmlWorkerContent } from "./collectHtmlWorkerContent.js";
6
10
  import { collectRscContent } from "./collectRscContent.js";
7
11
 
8
- export async function* renderPage(
9
- handlerOptions: CreateHandlerOptions<unknown, React.ComponentType<unknown>>
12
+ export async function* renderPage<
13
+ T extends PagePropOpt = PagePropOpt
14
+ >(
15
+ handlerOptions: CreateHandlerOptions<T>
10
16
  ): AsyncGenerator<RenderPageResult, void, unknown> {
11
17
  if (!handlerOptions.pagePath) {
12
18
  yield {
@@ -39,9 +45,9 @@ export async function* renderPage(
39
45
 
40
46
  const newHandlerOptions = {
41
47
  ...handlerOptions,
42
- PageComponent: PageComponent,
43
- pageProps: pageProps,
44
- } satisfies CreateHandlerOptions;
48
+ PageComponent,
49
+ pageProps,
50
+ } as CreateHandlerOptions<T>;
45
51
  // Create streams with CSS files
46
52
  const [rscFull, rscHeadless] = await renderStreams(newHandlerOptions);
47
53
  // Handle stream creation errors
@@ -12,12 +12,23 @@
12
12
  import { createRenderMetrics } from "../helpers/metrics.js";
13
13
  import { renderPage } from "./renderPage.js";
14
14
  import { PassThrough } from "node:stream";
15
- import type { StreamMetrics, RenderPagesResult, AutoDiscoveredFiles, CssContent, MultiPageHandlerOptions } from "../types.js";
15
+ import type {
16
+ StreamMetrics,
17
+ RenderPagesResult,
18
+ AutoDiscoveredFiles,
19
+ CssContent,
20
+ MultiPageHandlerOptions,
21
+ PagePropOpt,
22
+ InlineCssOpt,
23
+ } from "../types.js";
16
24
 
17
- export async function* renderPages(
25
+ export async function* renderPages<
26
+ T extends PagePropOpt = PagePropOpt,
27
+ InlineCSS extends InlineCssOpt = InlineCssOpt
28
+ >(
18
29
  autoDiscoveredFiles: AutoDiscoveredFiles,
19
- handlerOptions: MultiPageHandlerOptions,
20
- cssFilesByPage: Map<string, Map<string, CssContent>>,
30
+ handlerOptions: MultiPageHandlerOptions<T>,
31
+ cssFilesByPage: Map<string, Map<string, CssContent<InlineCSS>>>
21
32
  ): AsyncGenerator<RenderPagesResult, RenderPagesResult, unknown> {
22
33
  const routes = Array.from(autoDiscoveredFiles.urlMap.keys());
23
34
  const completedRoutes = new Set<string>();
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * renderStreams.ts
3
- *
3
+ *
4
4
  * PURPOSE: Creates specialized streams for React Server Components (RSC) rendering
5
- *
5
+ *
6
6
  * This module:
7
7
  * 1. Creates RSC stream (React.Fragment wrapper) for client-side navigation
8
8
  * - This stream is saved to .rsc files and used when navigating between pages
@@ -17,32 +17,33 @@
17
17
  import { createHandler } from "../helpers/createHandler.js";
18
18
  import type {
19
19
  CreateHandlerOptions,
20
+ PagePropOpt
20
21
  } from "../types.js";
21
22
  import React from "react";
22
23
 
23
24
  /**
24
25
  * Creates handlers for both document and RSC streams
25
- *
26
+ *
26
27
  * @param handler The handler options for creating streams
27
28
  * @param options The render options
28
29
  * @returns A tuple containing the document worker result and RSC direct result
29
30
  */
30
- export function renderStreams(
31
- handler: CreateHandlerOptions,
32
- ) {
31
+ export function renderStreams<
32
+ T extends PagePropOpt = PagePropOpt
33
+ >(handler: CreateHandlerOptions<T>) {
33
34
  return Promise.all([
34
35
  /**
35
- * This stream goes to the document worker for client side rendering with full HTML structure,
36
- * links are already bubbled up in the static document which required us
36
+ * This stream goes to the document worker for client side rendering with full HTML structure,
37
+ * links are already bubbled up in the static document which required us
37
38
  * to include the head in the stream as well
38
39
  */
39
40
  createHandler(handler),
40
-
41
+
41
42
  /**
42
- * This stream is saved to index.rsc file (if configured) and can be used
43
- * for navigating to pages (without the Html wrapper, but does contain
43
+ * This stream is saved to index.rsc file (if configured) and can be used
44
+ * for navigating to pages (without the Html wrapper, but does contain
44
45
  * css/head information that can bubble up to the browser's dom)
45
46
  */
46
- createHandler({...handler, Html: React.Fragment}),
47
+ createHandler({ ...handler, Html: React.Fragment }),
47
48
  ]);
48
49
  }
@@ -0,0 +1,182 @@
1
+ // alternative to webpack-sources/lib/helpers/createMappingsSerializer.js
2
+ // unused for now, but it's a dependency of react-server-dom-esm and you may or may not want to download webpack-sources
3
+ export function createMappingsSerializer() {
4
+ let generatedLine = 1;
5
+ let generatedColumn = 0;
6
+ let sourceIndex = 0;
7
+ let originalLine = 1;
8
+ let originalColumn = 0;
9
+ let nameIndex = 0;
10
+ let mappings = "";
11
+
12
+ return function serializeMapping(
13
+ newGeneratedLine: number,
14
+ newGeneratedColumn: number,
15
+ newSourceIndex: number,
16
+ newOriginalLine: number,
17
+ newOriginalColumn: number,
18
+ newNameIndex: number
19
+ ) {
20
+ if (newGeneratedLine !== generatedLine) {
21
+ generatedLine = newGeneratedLine;
22
+ generatedColumn = newGeneratedColumn;
23
+ if (mappings) {
24
+ mappings += ";";
25
+ }
26
+ } else if (mappings) {
27
+ mappings += ",";
28
+ }
29
+
30
+ // Encode the generated column.
31
+ let value = newGeneratedColumn - generatedColumn;
32
+ generatedColumn = newGeneratedColumn;
33
+ let isNegative = value < 0;
34
+ if (isNegative) {
35
+ value = -value;
36
+ }
37
+ value = value << 1;
38
+ if (isNegative) {
39
+ value = value | 1;
40
+ }
41
+ while (value > 0) {
42
+ let digit = value & 63;
43
+ value = value >>> 6;
44
+ if (value > 0) {
45
+ digit = digit | 64;
46
+ }
47
+ mappings += String.fromCharCode(
48
+ digit < 26
49
+ ? digit + 65
50
+ : digit < 52
51
+ ? digit + 97 - 26
52
+ : digit < 62
53
+ ? digit + 48 - 52
54
+ : digit === 62
55
+ ? 43
56
+ : 47
57
+ );
58
+ }
59
+
60
+ // Encode the source index.
61
+ value = newSourceIndex - sourceIndex;
62
+ sourceIndex = newSourceIndex;
63
+ isNegative = value < 0;
64
+ if (isNegative) {
65
+ value = -value;
66
+ }
67
+ value = value << 1;
68
+ if (isNegative) {
69
+ value = value | 1;
70
+ }
71
+ while (value > 0) {
72
+ let digit = value & 63;
73
+ value = value >>> 6;
74
+ if (value > 0) {
75
+ digit = digit | 64;
76
+ }
77
+ mappings += String.fromCharCode(
78
+ digit < 26
79
+ ? digit + 65
80
+ : digit < 52
81
+ ? digit + 97 - 26
82
+ : digit < 62
83
+ ? digit + 48 - 52
84
+ : digit === 62
85
+ ? 43
86
+ : 47
87
+ );
88
+ }
89
+
90
+ // Encode the original line.
91
+ value = newOriginalLine - originalLine;
92
+ originalLine = newOriginalLine;
93
+ isNegative = value < 0;
94
+ if (isNegative) {
95
+ value = -value;
96
+ }
97
+ value = value << 1;
98
+ if (isNegative) {
99
+ value = value | 1;
100
+ }
101
+ while (value > 0) {
102
+ let digit = value & 63;
103
+ value = value >>> 6;
104
+ if (value > 0) {
105
+ digit = digit | 64;
106
+ }
107
+ mappings += String.fromCharCode(
108
+ digit < 26
109
+ ? digit + 65
110
+ : digit < 52
111
+ ? digit + 97 - 26
112
+ : digit < 62
113
+ ? digit + 48 - 52
114
+ : digit === 62
115
+ ? 43
116
+ : 47
117
+ );
118
+ }
119
+
120
+ // Encode the original column.
121
+ value = newOriginalColumn - originalColumn;
122
+ originalColumn = newOriginalColumn;
123
+ isNegative = value < 0;
124
+ if (isNegative) {
125
+ value = -value;
126
+ }
127
+ value = value << 1;
128
+ if (isNegative) {
129
+ value = value | 1;
130
+ }
131
+ while (value > 0) {
132
+ let digit = value & 63;
133
+ value = value >>> 6;
134
+ if (value > 0) {
135
+ digit = digit | 64;
136
+ }
137
+ mappings += String.fromCharCode(
138
+ digit < 26
139
+ ? digit + 65
140
+ : digit < 52
141
+ ? digit + 97 - 26
142
+ : digit < 62
143
+ ? digit + 48 - 52
144
+ : digit === 62
145
+ ? 43
146
+ : 47
147
+ );
148
+ }
149
+
150
+ // Encode the name index.
151
+ value = newNameIndex - nameIndex;
152
+ nameIndex = newNameIndex;
153
+ isNegative = value < 0;
154
+ if (isNegative) {
155
+ value = -value;
156
+ }
157
+ value = value << 1;
158
+ if (isNegative) {
159
+ value = value | 1;
160
+ }
161
+ while (value > 0) {
162
+ let digit = value & 63;
163
+ value = value >>> 6;
164
+ if (value > 0) {
165
+ digit = digit | 64;
166
+ }
167
+ mappings += String.fromCharCode(
168
+ digit < 26
169
+ ? digit + 65
170
+ : digit < 52
171
+ ? digit + 97 - 26
172
+ : digit < 62
173
+ ? digit + 48 - 52
174
+ : digit === 62
175
+ ? 43
176
+ : 47
177
+ );
178
+ }
179
+
180
+ return mappings;
181
+ };
182
+ }