vxrn 1.27.1 → 2.0.0-beta.45.1

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 (456) hide show
  1. package/dist/cli.mjs +212 -261
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/cli.native.js +216 -265
  4. package/dist/cli.native.js.map +1 -1
  5. package/dist/config/getAdditionalViteConfig.mjs +33 -62
  6. package/dist/config/getAdditionalViteConfig.mjs.map +1 -1
  7. package/dist/config/getAdditionalViteConfig.native.js +33 -62
  8. package/dist/config/getAdditionalViteConfig.native.js.map +1 -1
  9. package/dist/config/getBaseViteConfigOnly.mjs +84 -77
  10. package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
  11. package/dist/config/getBaseViteConfigOnly.native.js +86 -79
  12. package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
  13. package/dist/config/getBaseViteConfigWithPlugins.mjs +6 -4
  14. package/dist/config/getBaseViteConfigWithPlugins.mjs.map +1 -1
  15. package/dist/config/getBaseViteConfigWithPlugins.native.js +6 -4
  16. package/dist/config/getBaseViteConfigWithPlugins.native.js.map +1 -1
  17. package/dist/config/getBaseVitePlugins.mjs +102 -130
  18. package/dist/config/getBaseVitePlugins.mjs.map +1 -1
  19. package/dist/config/getBaseVitePlugins.native.js +123 -152
  20. package/dist/config/getBaseVitePlugins.native.js.map +1 -1
  21. package/dist/config/getNonCliModeOnlyVitePlugins.mjs +3 -3
  22. package/dist/config/getNonCliModeOnlyVitePlugins.mjs.map +1 -1
  23. package/dist/config/getNonCliModeOnlyVitePlugins.native.js +3 -1
  24. package/dist/config/getNonCliModeOnlyVitePlugins.native.js.map +1 -1
  25. package/dist/config/getOptimizeDeps.mjs +138 -42
  26. package/dist/config/getOptimizeDeps.mjs.map +1 -1
  27. package/dist/config/getOptimizeDeps.native.js +138 -42
  28. package/dist/config/getOptimizeDeps.native.js.map +1 -1
  29. package/dist/config/getOptionsFilled.mjs +48 -52
  30. package/dist/config/getOptionsFilled.mjs.map +1 -1
  31. package/dist/config/getOptionsFilled.native.js +51 -55
  32. package/dist/config/getOptionsFilled.native.js.map +1 -1
  33. package/dist/config/getReactNativePlugins.mjs +23 -15
  34. package/dist/config/getReactNativePlugins.mjs.map +1 -1
  35. package/dist/config/getReactNativePlugins.native.js +25 -16
  36. package/dist/config/getReactNativePlugins.native.js.map +1 -1
  37. package/dist/config/getServerOptionsFilled.mjs +33 -35
  38. package/dist/config/getServerOptionsFilled.mjs.map +1 -1
  39. package/dist/config/getServerOptionsFilled.native.js +35 -38
  40. package/dist/config/getServerOptionsFilled.native.js.map +1 -1
  41. package/dist/config/getViteServerConfig.mjs +34 -45
  42. package/dist/config/getViteServerConfig.mjs.map +1 -1
  43. package/dist/config/getViteServerConfig.native.js +35 -46
  44. package/dist/config/getViteServerConfig.native.js.map +1 -1
  45. package/dist/config/mergeUserConfig.mjs +50 -28
  46. package/dist/config/mergeUserConfig.mjs.map +1 -1
  47. package/dist/config/mergeUserConfig.native.js +60 -38
  48. package/dist/config/mergeUserConfig.native.js.map +1 -1
  49. package/dist/constants/defaults.mjs +29 -12
  50. package/dist/constants/defaults.mjs.map +1 -1
  51. package/dist/constants/defaults.native.js +29 -12
  52. package/dist/constants/defaults.native.js.map +1 -1
  53. package/dist/constants.mjs +41 -6
  54. package/dist/constants.mjs.map +1 -1
  55. package/dist/constants.native.js +41 -6
  56. package/dist/constants.native.js.map +1 -1
  57. package/dist/exports/build.mjs +218 -270
  58. package/dist/exports/build.mjs.map +1 -1
  59. package/dist/exports/build.native.js +226 -283
  60. package/dist/exports/build.native.js.map +1 -1
  61. package/dist/exports/clean.mjs +71 -78
  62. package/dist/exports/clean.mjs.map +1 -1
  63. package/dist/exports/clean.native.js +76 -90
  64. package/dist/exports/clean.native.js.map +1 -1
  65. package/dist/exports/createServer.mjs +43 -46
  66. package/dist/exports/createServer.mjs.map +1 -1
  67. package/dist/exports/createServer.native.js +45 -48
  68. package/dist/exports/createServer.native.js.map +1 -1
  69. package/dist/exports/dev.mjs +177 -201
  70. package/dist/exports/dev.mjs.map +1 -1
  71. package/dist/exports/dev.native.js +191 -215
  72. package/dist/exports/dev.native.js.map +1 -1
  73. package/dist/exports/loadEnv.mjs +51 -48
  74. package/dist/exports/loadEnv.mjs.map +1 -1
  75. package/dist/exports/loadEnv.native.js +59 -57
  76. package/dist/exports/loadEnv.native.js.map +1 -1
  77. package/dist/exports/patch.mjs +9 -7
  78. package/dist/exports/patch.mjs.map +1 -1
  79. package/dist/exports/patch.native.js +9 -7
  80. package/dist/exports/patch.native.js.map +1 -1
  81. package/dist/exports/prebuild.mjs +177 -157
  82. package/dist/exports/prebuild.mjs.map +1 -1
  83. package/dist/exports/prebuild.native.js +197 -160
  84. package/dist/exports/prebuild.native.js.map +1 -1
  85. package/dist/exports/prebuildWithoutExpo.mjs +46 -44
  86. package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
  87. package/dist/exports/prebuildWithoutExpo.native.js +48 -46
  88. package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
  89. package/dist/exports/runAndroid.mjs +9 -10
  90. package/dist/exports/runAndroid.mjs.map +1 -1
  91. package/dist/exports/runAndroid.native.js +10 -11
  92. package/dist/exports/runAndroid.native.js.map +1 -1
  93. package/dist/exports/runIos.mjs +9 -10
  94. package/dist/exports/runIos.mjs.map +1 -1
  95. package/dist/exports/runIos.native.js +10 -11
  96. package/dist/exports/runIos.native.js.map +1 -1
  97. package/dist/exports/serve.mjs +23 -31
  98. package/dist/exports/serve.mjs.map +1 -1
  99. package/dist/exports/serve.native.js +26 -34
  100. package/dist/exports/serve.native.js.map +1 -1
  101. package/dist/exports/serveStaticAssets.mjs +109 -113
  102. package/dist/exports/serveStaticAssets.mjs.map +1 -1
  103. package/dist/exports/serveStaticAssets.native.js +180 -192
  104. package/dist/exports/serveStaticAssets.native.js.map +1 -1
  105. package/dist/index.js +25 -14
  106. package/dist/index.mjs +25 -14
  107. package/dist/index.native.js +25 -14
  108. package/dist/patches/builtInDepPatches.mjs +346 -435
  109. package/dist/patches/builtInDepPatches.mjs.map +1 -1
  110. package/dist/patches/builtInDepPatches.native.js +349 -438
  111. package/dist/patches/builtInDepPatches.native.js.map +1 -1
  112. package/dist/plugins/applyBuiltInPatchesPlugin.mjs +11 -11
  113. package/dist/plugins/applyBuiltInPatchesPlugin.mjs.map +1 -1
  114. package/dist/plugins/applyBuiltInPatchesPlugin.native.js +11 -11
  115. package/dist/plugins/applyBuiltInPatchesPlugin.native.js.map +1 -1
  116. package/dist/plugins/autoDepOptimizePlugin.mjs +87 -90
  117. package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
  118. package/dist/plugins/autoDepOptimizePlugin.native.js +99 -102
  119. package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
  120. package/dist/plugins/clientInjectPlugin.mjs +13 -11
  121. package/dist/plugins/clientInjectPlugin.mjs.map +1 -1
  122. package/dist/plugins/clientInjectPlugin.native.js +13 -11
  123. package/dist/plugins/clientInjectPlugin.native.js.map +1 -1
  124. package/dist/plugins/defaultDepOptimizePlugin.mjs +15 -23
  125. package/dist/plugins/defaultDepOptimizePlugin.mjs.map +1 -1
  126. package/dist/plugins/defaultDepOptimizePlugin.native.js +15 -23
  127. package/dist/plugins/defaultDepOptimizePlugin.native.js.map +1 -1
  128. package/dist/plugins/expoManifestRequestHandlerPlugin.mjs +163 -179
  129. package/dist/plugins/expoManifestRequestHandlerPlugin.mjs.map +1 -1
  130. package/dist/plugins/expoManifestRequestHandlerPlugin.native.js +169 -191
  131. package/dist/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
  132. package/dist/plugins/getResolvedConfigSubset.mjs +6 -5
  133. package/dist/plugins/getResolvedConfigSubset.mjs.map +1 -1
  134. package/dist/plugins/getResolvedConfigSubset.native.js +6 -5
  135. package/dist/plugins/getResolvedConfigSubset.native.js.map +1 -1
  136. package/dist/plugins/reactNativeCommonJsPlugin.mjs +210 -178
  137. package/dist/plugins/reactNativeCommonJsPlugin.mjs.map +1 -1
  138. package/dist/plugins/reactNativeCommonJsPlugin.native.js +283 -259
  139. package/dist/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
  140. package/dist/plugins/reactNativeDevAssetPlugin.mjs +72 -83
  141. package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
  142. package/dist/plugins/reactNativeDevAssetPlugin.native.js +75 -92
  143. package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
  144. package/dist/plugins/reactNativeDevServer.mjs +283 -328
  145. package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
  146. package/dist/plugins/reactNativeDevServer.native.js +332 -391
  147. package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
  148. package/dist/plugins/rnCodegenPlugin.mjs +13 -12
  149. package/dist/plugins/rnCodegenPlugin.mjs.map +1 -1
  150. package/dist/plugins/rnCodegenPlugin.native.js +13 -12
  151. package/dist/plugins/rnCodegenPlugin.native.js.map +1 -1
  152. package/dist/plugins/rollupRemoveUnusedImports.mjs +8 -7
  153. package/dist/plugins/rollupRemoveUnusedImports.mjs.map +1 -1
  154. package/dist/plugins/rollupRemoveUnusedImports.native.js +8 -7
  155. package/dist/plugins/rollupRemoveUnusedImports.native.js.map +1 -1
  156. package/dist/plugins/workletImportsPlugin.mjs +127 -132
  157. package/dist/plugins/workletImportsPlugin.mjs.map +1 -1
  158. package/dist/plugins/workletImportsPlugin.native.js +192 -203
  159. package/dist/plugins/workletImportsPlugin.native.js.map +1 -1
  160. package/dist/rn-commands/bundle/buildBundle.mjs +45 -79
  161. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  162. package/dist/rn-commands/bundle/buildBundle.native.js +45 -85
  163. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  164. package/dist/runtime/hmr-client.mjs +133 -140
  165. package/dist/runtime/hmr-client.mjs.map +1 -1
  166. package/dist/runtime/hmr-client.native.js +223 -222
  167. package/dist/runtime/hmr-client.native.js.map +1 -1
  168. package/dist/runtime/hmr-runtime.mjs +192 -194
  169. package/dist/runtime/hmr-runtime.mjs.map +1 -1
  170. package/dist/runtime/hmr-runtime.native.js +424 -411
  171. package/dist/runtime/hmr-runtime.native.js.map +1 -1
  172. package/dist/runtime/hmr-types.mjs +0 -2
  173. package/dist/runtime/hmr-types.native.js +0 -2
  174. package/dist/runtime/native-prelude.mjs +2 -1
  175. package/dist/runtime/native-prelude.mjs.map +1 -1
  176. package/dist/runtime/native-prelude.native.js +2 -1
  177. package/dist/runtime/native-prelude.native.js.map +1 -1
  178. package/dist/runtime/react-refresh-utils.mjs +23 -22
  179. package/dist/runtime/react-refresh-utils.mjs.map +1 -1
  180. package/dist/runtime/react-refresh-utils.native.js +23 -27
  181. package/dist/runtime/react-refresh-utils.native.js.map +1 -1
  182. package/dist/serve/node.mjs +49 -49
  183. package/dist/serve/node.mjs.map +1 -1
  184. package/dist/serve/node.native.js +92 -96
  185. package/dist/serve/node.native.js.map +1 -1
  186. package/dist/types.mjs +0 -2
  187. package/dist/types.native.js +0 -2
  188. package/dist/user-interface/index.mjs +245 -262
  189. package/dist/user-interface/index.mjs.map +1 -1
  190. package/dist/user-interface/index.native.js +274 -298
  191. package/dist/user-interface/index.native.js.map +1 -1
  192. package/dist/utils/assert.mjs +7 -6
  193. package/dist/utils/assert.mjs.map +1 -1
  194. package/dist/utils/assert.native.js +7 -18
  195. package/dist/utils/assert.native.js.map +1 -1
  196. package/dist/utils/bindKeypressInput.mjs +36 -38
  197. package/dist/utils/bindKeypressInput.mjs.map +1 -1
  198. package/dist/utils/bindKeypressInput.native.js +36 -38
  199. package/dist/utils/bindKeypressInput.native.js.map +1 -1
  200. package/dist/utils/coerceToArray.mjs +2 -1
  201. package/dist/utils/coerceToArray.mjs.map +1 -1
  202. package/dist/utils/coerceToArray.native.js +2 -1
  203. package/dist/utils/coerceToArray.native.js.map +1 -1
  204. package/dist/utils/connectedNativeClients.mjs +3 -2
  205. package/dist/utils/connectedNativeClients.mjs.map +1 -1
  206. package/dist/utils/connectedNativeClients.native.js +3 -2
  207. package/dist/utils/connectedNativeClients.native.js.map +1 -1
  208. package/dist/utils/createNativeDevEngine.mjs +992 -966
  209. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  210. package/dist/utils/createNativeDevEngine.native.js +1184 -1179
  211. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  212. package/dist/utils/dispose.mjs +4 -3
  213. package/dist/utils/dispose.mjs.map +1 -1
  214. package/dist/utils/dispose.native.js +6 -5
  215. package/dist/utils/dispose.native.js.map +1 -1
  216. package/dist/utils/environmentUtils.mjs +5 -4
  217. package/dist/utils/environmentUtils.mjs.map +1 -1
  218. package/dist/utils/environmentUtils.native.js +5 -4
  219. package/dist/utils/environmentUtils.native.js.map +1 -1
  220. package/dist/utils/execSync.mjs +7 -5
  221. package/dist/utils/execSync.mjs.map +1 -1
  222. package/dist/utils/execSync.native.js +8 -6
  223. package/dist/utils/execSync.native.js.map +1 -1
  224. package/dist/utils/expoRun.mjs +27 -35
  225. package/dist/utils/expoRun.mjs.map +1 -1
  226. package/dist/utils/expoRun.native.js +27 -35
  227. package/dist/utils/expoRun.native.js.map +1 -1
  228. package/dist/utils/filterViteServerResolvedUrls.mjs +24 -22
  229. package/dist/utils/filterViteServerResolvedUrls.mjs.map +1 -1
  230. package/dist/utils/filterViteServerResolvedUrls.native.js +61 -63
  231. package/dist/utils/filterViteServerResolvedUrls.native.js.map +1 -1
  232. package/dist/utils/getBoundPort.mjs +6 -5
  233. package/dist/utils/getBoundPort.mjs.map +1 -1
  234. package/dist/utils/getBoundPort.native.js +8 -12
  235. package/dist/utils/getBoundPort.native.js.map +1 -1
  236. package/dist/utils/getCacheDir.mjs +3 -1
  237. package/dist/utils/getCacheDir.mjs.map +1 -1
  238. package/dist/utils/getCacheDir.native.js +3 -1
  239. package/dist/utils/getCacheDir.native.js.map +1 -1
  240. package/dist/utils/getServerEntry.mjs +6 -4
  241. package/dist/utils/getServerEntry.mjs.map +1 -1
  242. package/dist/utils/getServerEntry.native.js +8 -11
  243. package/dist/utils/getServerEntry.native.js.map +1 -1
  244. package/dist/utils/getVitePath.mjs +42 -42
  245. package/dist/utils/getVitePath.mjs.map +1 -1
  246. package/dist/utils/getVitePath.native.js +43 -41
  247. package/dist/utils/getVitePath.native.js.map +1 -1
  248. package/dist/utils/globDir.mjs +7 -11
  249. package/dist/utils/globDir.mjs.map +1 -1
  250. package/dist/utils/globDir.native.js +10 -14
  251. package/dist/utils/globDir.native.js.map +1 -1
  252. package/dist/utils/isWithin.mjs +4 -2
  253. package/dist/utils/isWithin.mjs.map +1 -1
  254. package/dist/utils/isWithin.native.js +4 -2
  255. package/dist/utils/isWithin.native.js.map +1 -1
  256. package/dist/utils/patches.mjs +233 -255
  257. package/dist/utils/patches.mjs.map +1 -1
  258. package/dist/utils/patches.native.js +415 -460
  259. package/dist/utils/patches.native.js.map +1 -1
  260. package/dist/utils/printServerUrls.mjs +9 -7
  261. package/dist/utils/printServerUrls.mjs.map +1 -1
  262. package/dist/utils/printServerUrls.native.js +48 -51
  263. package/dist/utils/printServerUrls.native.js.map +1 -1
  264. package/dist/utils/removeUndefined.mjs +8 -7
  265. package/dist/utils/removeUndefined.mjs.map +1 -1
  266. package/dist/utils/removeUndefined.native.js +8 -7
  267. package/dist/utils/removeUndefined.native.js.map +1 -1
  268. package/dist/utils/scanDepsToOptimize.mjs +194 -161
  269. package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
  270. package/dist/utils/scanDepsToOptimize.native.js +227 -197
  271. package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
  272. package/dist/utils/state.mjs +18 -18
  273. package/dist/utils/state.mjs.map +1 -1
  274. package/dist/utils/state.native.js +18 -18
  275. package/dist/utils/state.native.js.map +1 -1
  276. package/dist/utils/symbolicateNativeStack.mjs +54 -54
  277. package/dist/utils/symbolicateNativeStack.mjs.map +1 -1
  278. package/dist/utils/symbolicateNativeStack.native.js +58 -58
  279. package/dist/utils/symbolicateNativeStack.native.js.map +1 -1
  280. package/dist/utils/uniq.mjs +2 -1
  281. package/dist/utils/uniq.mjs.map +1 -1
  282. package/dist/utils/uniq.native.js +2 -1
  283. package/dist/utils/uniq.native.js.map +1 -1
  284. package/dist/utils/utils.mjs +19 -19
  285. package/dist/utils/utils.mjs.map +1 -1
  286. package/dist/utils/utils.native.js +38 -40
  287. package/dist/utils/utils.native.js.map +1 -1
  288. package/dist/vendor/debugger-app/index.mjs +0 -2
  289. package/dist/vendor/debugger-app/index.native.js +0 -2
  290. package/dist/vendor/debugger-app/src/debuggerWorker.mjs +0 -2
  291. package/dist/vendor/debugger-app/src/debuggerWorker.native.js +0 -2
  292. package/dist/vendor/debugger-app/src/index.mjs +0 -2
  293. package/dist/vendor/debugger-app/src/index.native.js +0 -2
  294. package/dist/vxrn-vite-plugin.mjs +34 -33
  295. package/dist/vxrn-vite-plugin.mjs.map +1 -1
  296. package/dist/vxrn-vite-plugin.native.js +35 -34
  297. package/dist/vxrn-vite-plugin.native.js.map +1 -1
  298. package/expo-plugin.cjs +12 -6
  299. package/package.json +12 -13
  300. package/src/config/getBaseViteConfigOnly.ts +6 -0
  301. package/src/exports/prebuild.ts +40 -12
  302. package/src/patches/builtInDepPatches.ts +24 -48
  303. package/src/utils/createNativeDevEngine.test.ts +1 -1
  304. package/src/utils/createNativeDevEngine.ts +15 -9
  305. package/src/utils/scanDepsToOptimize.ts +0 -3
  306. package/types/config/getBaseViteConfigOnly.d.ts.map +1 -1
  307. package/types/config/getOptimizeDeps.d.ts.map +1 -1
  308. package/types/config/getOptionsFilled.d.ts +15 -15
  309. package/types/config/getOptionsFilled.d.ts.map +1 -1
  310. package/types/exports/build.d.ts +11 -11
  311. package/types/exports/build.d.ts.map +1 -1
  312. package/types/exports/clean.d.ts +1 -1
  313. package/types/exports/clean.d.ts.map +1 -1
  314. package/types/exports/createServer.d.ts.map +1 -1
  315. package/types/exports/dev.d.ts.map +1 -1
  316. package/types/exports/patch.d.ts.map +1 -1
  317. package/types/exports/prebuild.d.ts +3 -3
  318. package/types/exports/prebuild.d.ts.map +1 -1
  319. package/types/exports/prebuildWithoutExpo.d.ts +1 -1
  320. package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
  321. package/types/exports/runAndroid.d.ts.map +1 -1
  322. package/types/exports/runIos.d.ts.map +1 -1
  323. package/types/exports/serve.d.ts.map +1 -1
  324. package/types/patches/builtInDepPatches.d.ts.map +1 -1
  325. package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
  326. package/types/plugins/rollupRemoveUnusedImports.d.ts.map +1 -1
  327. package/types/runtime/hmr-client.d.ts.map +1 -1
  328. package/types/runtime/hmr-runtime.d.ts.map +1 -1
  329. package/types/runtime/hmr-types.d.ts.map +1 -1
  330. package/types/utils/createNativeDevEngine.d.ts +1 -1
  331. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
  332. package/types/utils/execSync.d.ts.map +1 -1
  333. package/types/utils/getServerEntry.d.ts.map +1 -1
  334. package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
  335. package/types/vxrn-vite-plugin.d.ts.map +1 -1
  336. package/dist/config/getOptimizeDeps.test.mjs +0 -20
  337. package/dist/config/getOptimizeDeps.test.mjs.map +0 -1
  338. package/dist/config/getOptimizeDeps.test.native.js +0 -39
  339. package/dist/config/getOptimizeDeps.test.native.js.map +0 -1
  340. package/dist/config/getServerOptionsFilled.test.mjs +0 -20
  341. package/dist/config/getServerOptionsFilled.test.mjs.map +0 -1
  342. package/dist/config/getServerOptionsFilled.test.native.js +0 -20
  343. package/dist/config/getServerOptionsFilled.test.native.js.map +0 -1
  344. package/dist/config/getViteServerConfig.test.mjs +0 -26
  345. package/dist/config/getViteServerConfig.test.mjs.map +0 -1
  346. package/dist/config/getViteServerConfig.test.native.js +0 -26
  347. package/dist/config/getViteServerConfig.test.native.js.map +0 -1
  348. package/dist/config/mergeUserConfig.test.mjs +0 -108
  349. package/dist/config/mergeUserConfig.test.mjs.map +0 -1
  350. package/dist/config/mergeUserConfig.test.native.js +0 -108
  351. package/dist/config/mergeUserConfig.test.native.js.map +0 -1
  352. package/dist/exports/clean.test.mjs +0 -81
  353. package/dist/exports/clean.test.mjs.map +0 -1
  354. package/dist/exports/clean.test.native.js +0 -88
  355. package/dist/exports/clean.test.native.js.map +0 -1
  356. package/dist/exports/loadEnv.test.mjs +0 -65
  357. package/dist/exports/loadEnv.test.mjs.map +0 -1
  358. package/dist/exports/loadEnv.test.native.js +0 -65
  359. package/dist/exports/loadEnv.test.native.js.map +0 -1
  360. package/dist/index.js.map +0 -1
  361. package/dist/index.mjs.map +0 -1
  362. package/dist/index.native.js.map +0 -1
  363. package/dist/plugins/autoDepOptimizePlugin.test.mjs +0 -31
  364. package/dist/plugins/autoDepOptimizePlugin.test.mjs.map +0 -1
  365. package/dist/plugins/autoDepOptimizePlugin.test.native.js +0 -39
  366. package/dist/plugins/autoDepOptimizePlugin.test.native.js.map +0 -1
  367. package/dist/plugins/resolveIdScan.test.mjs +0 -31
  368. package/dist/plugins/resolveIdScan.test.mjs.map +0 -1
  369. package/dist/plugins/resolveIdScan.test.native.js +0 -38
  370. package/dist/plugins/resolveIdScan.test.native.js.map +0 -1
  371. package/dist/plugins/rnCodegenPlugin.test.mjs +0 -239
  372. package/dist/plugins/rnCodegenPlugin.test.mjs.map +0 -1
  373. package/dist/plugins/rnCodegenPlugin.test.native.js +0 -242
  374. package/dist/plugins/rnCodegenPlugin.test.native.js.map +0 -1
  375. package/dist/plugins/serverExtensions.test.mjs +0 -106
  376. package/dist/plugins/serverExtensions.test.mjs.map +0 -1
  377. package/dist/plugins/serverExtensions.test.native.js +0 -117
  378. package/dist/plugins/serverExtensions.test.native.js.map +0 -1
  379. package/dist/runtime/hmr-types.mjs.map +0 -1
  380. package/dist/runtime/hmr-types.native.js.map +0 -1
  381. package/dist/serve/node.test.mjs +0 -60
  382. package/dist/serve/node.test.mjs.map +0 -1
  383. package/dist/serve/node.test.native.js +0 -72
  384. package/dist/serve/node.test.native.js.map +0 -1
  385. package/dist/types.mjs.map +0 -1
  386. package/dist/types.native.js.map +0 -1
  387. package/dist/utils/bindKeypressInput.test.mjs +0 -48
  388. package/dist/utils/bindKeypressInput.test.mjs.map +0 -1
  389. package/dist/utils/bindKeypressInput.test.native.js +0 -48
  390. package/dist/utils/bindKeypressInput.test.native.js.map +0 -1
  391. package/dist/utils/createNativeDevEngine.test.mjs +0 -1788
  392. package/dist/utils/createNativeDevEngine.test.mjs.map +0 -1
  393. package/dist/utils/createNativeDevEngine.test.native.js +0 -1942
  394. package/dist/utils/createNativeDevEngine.test.native.js.map +0 -1
  395. package/dist/utils/createNativeDevEngineFailure.test.mjs +0 -44
  396. package/dist/utils/createNativeDevEngineFailure.test.mjs.map +0 -1
  397. package/dist/utils/createNativeDevEngineFailure.test.native.js +0 -54
  398. package/dist/utils/createNativeDevEngineFailure.test.native.js.map +0 -1
  399. package/dist/utils/getBoundPort.test.mjs +0 -71
  400. package/dist/utils/getBoundPort.test.mjs.map +0 -1
  401. package/dist/utils/getBoundPort.test.native.js +0 -82
  402. package/dist/utils/getBoundPort.test.native.js.map +0 -1
  403. package/dist/utils/imageSizePatch.test.mjs +0 -29
  404. package/dist/utils/imageSizePatch.test.mjs.map +0 -1
  405. package/dist/utils/imageSizePatch.test.native.js +0 -30
  406. package/dist/utils/imageSizePatch.test.native.js.map +0 -1
  407. package/dist/utils/patches.test.mjs +0 -242
  408. package/dist/utils/patches.test.mjs.map +0 -1
  409. package/dist/utils/patches.test.native.js +0 -271
  410. package/dist/utils/patches.test.native.js.map +0 -1
  411. package/dist/utils/symbolicateNativeStack.test.mjs +0 -96
  412. package/dist/utils/symbolicateNativeStack.test.mjs.map +0 -1
  413. package/dist/utils/symbolicateNativeStack.test.native.js +0 -96
  414. package/dist/utils/symbolicateNativeStack.test.native.js.map +0 -1
  415. package/dist/vendor/debugger-app/index.mjs.map +0 -1
  416. package/dist/vendor/debugger-app/index.native.js.map +0 -1
  417. package/dist/vendor/debugger-app/src/debuggerWorker.mjs.map +0 -1
  418. package/dist/vendor/debugger-app/src/debuggerWorker.native.js.map +0 -1
  419. package/dist/vendor/debugger-app/src/index.mjs.map +0 -1
  420. package/dist/vendor/debugger-app/src/index.native.js.map +0 -1
  421. package/types/config/getOptimizeDeps.test.d.ts +0 -2
  422. package/types/config/getOptimizeDeps.test.d.ts.map +0 -1
  423. package/types/config/getServerOptionsFilled.test.d.ts +0 -2
  424. package/types/config/getServerOptionsFilled.test.d.ts.map +0 -1
  425. package/types/config/getViteServerConfig.test.d.ts +0 -2
  426. package/types/config/getViteServerConfig.test.d.ts.map +0 -1
  427. package/types/config/mergeUserConfig.test.d.ts +0 -2
  428. package/types/config/mergeUserConfig.test.d.ts.map +0 -1
  429. package/types/exports/clean.test.d.ts +0 -2
  430. package/types/exports/clean.test.d.ts.map +0 -1
  431. package/types/exports/loadEnv.test.d.ts +0 -2
  432. package/types/exports/loadEnv.test.d.ts.map +0 -1
  433. package/types/plugins/autoDepOptimizePlugin.test.d.ts +0 -2
  434. package/types/plugins/autoDepOptimizePlugin.test.d.ts.map +0 -1
  435. package/types/plugins/resolveIdScan.test.d.ts +0 -2
  436. package/types/plugins/resolveIdScan.test.d.ts.map +0 -1
  437. package/types/plugins/rnCodegenPlugin.test.d.ts +0 -2
  438. package/types/plugins/rnCodegenPlugin.test.d.ts.map +0 -1
  439. package/types/plugins/serverExtensions.test.d.ts +0 -2
  440. package/types/plugins/serverExtensions.test.d.ts.map +0 -1
  441. package/types/serve/node.test.d.ts +0 -2
  442. package/types/serve/node.test.d.ts.map +0 -1
  443. package/types/utils/bindKeypressInput.test.d.ts +0 -2
  444. package/types/utils/bindKeypressInput.test.d.ts.map +0 -1
  445. package/types/utils/createNativeDevEngine.test.d.ts +0 -2
  446. package/types/utils/createNativeDevEngine.test.d.ts.map +0 -1
  447. package/types/utils/createNativeDevEngineFailure.test.d.ts +0 -2
  448. package/types/utils/createNativeDevEngineFailure.test.d.ts.map +0 -1
  449. package/types/utils/getBoundPort.test.d.ts +0 -2
  450. package/types/utils/getBoundPort.test.d.ts.map +0 -1
  451. package/types/utils/imageSizePatch.test.d.ts +0 -2
  452. package/types/utils/imageSizePatch.test.d.ts.map +0 -1
  453. package/types/utils/patches.test.d.ts +0 -2
  454. package/types/utils/patches.test.d.ts.map +0 -1
  455. package/types/utils/symbolicateNativeStack.test.d.ts +0 -2
  456. package/types/utils/symbolicateNativeStack.test.d.ts.map +0 -1
@@ -9,285 +9,314 @@ import { resolvePath } from "@vxrn/resolve";
9
9
  import { DEFAULT_ASSET_EXTS } from "../constants/defaults.mjs";
10
10
  import { getNativePrelude } from "../runtime/native-prelude.mjs";
11
11
  import { rnCodegenPlugin } from "../plugins/rnCodegenPlugin.mjs";
12
- const HERMES_CLASS_TRANSFORMS = ["transform-classes", "transform-parameters", "transform-block-scoping", "transform-class-properties", "transform-class-static-block", "transform-private-methods", "transform-private-property-in-object"];
12
+
13
+ const HERMES_CLASS_TRANSFORMS = [
14
+ "transform-classes",
15
+ "transform-parameters",
16
+ "transform-block-scoping",
17
+ "transform-class-properties",
18
+ "transform-class-static-block",
19
+ "transform-private-methods",
20
+ "transform-private-property-in-object"
21
+ ];
13
22
  const HERMES_ASYNC_TRANSFORMS = ["transform-async-to-generator"];
14
23
  function getHermesSWCIncludes(dev) {
15
- return [...HERMES_CLASS_TRANSFORMS, ...HERMES_ASYNC_TRANSFORMS];
24
+ return [...HERMES_CLASS_TRANSFORMS, ...HERMES_ASYNC_TRANSFORMS];
16
25
  }
17
26
  function getResolveExtensions(platform) {
18
- const platformExts = platform === "ios" ? [".ios.tsx", ".ios.ts", ".ios.jsx", ".ios.js"] : [".android.tsx", ".android.ts", ".android.jsx", ".android.js"];
19
- const nativeExts = [".native.tsx", ".native.ts", ".native.jsx", ".native.js"];
20
- const defaultExts = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs", ".json"];
21
- return [...platformExts, ...nativeExts, ...defaultExts];
27
+ const platformExts = platform === "ios" ? [
28
+ ".ios.tsx",
29
+ ".ios.ts",
30
+ ".ios.jsx",
31
+ ".ios.js"
32
+ ] : [
33
+ ".android.tsx",
34
+ ".android.ts",
35
+ ".android.jsx",
36
+ ".android.js"
37
+ ];
38
+ const nativeExts = [
39
+ ".native.tsx",
40
+ ".native.ts",
41
+ ".native.jsx",
42
+ ".native.js"
43
+ ];
44
+ const defaultExts = [
45
+ ".tsx",
46
+ ".ts",
47
+ ".jsx",
48
+ ".js",
49
+ ".mjs",
50
+ ".cjs",
51
+ ".json"
52
+ ];
53
+ return [
54
+ ...platformExts,
55
+ ...nativeExts,
56
+ ...defaultExts
57
+ ];
22
58
  }
23
59
  function getNativeResolveConfig(platform) {
24
- return {
25
- extensions: getResolveExtensions(platform),
26
- conditionNames: ["react-native"],
27
- mainFields: ["react-native", "module", "main"]
28
- };
60
+ return {
61
+ extensions: getResolveExtensions(platform),
62
+ conditionNames: ["react-native"],
63
+ mainFields: [
64
+ "react-native",
65
+ "module",
66
+ "main"
67
+ ]
68
+ };
29
69
  }
30
70
  function getNativeTransformConfig(platform, dev, root) {
31
- const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
32
- const setupFileDefines = (() => {
33
- const sf = entryConfig.setupFile;
34
- if (!sf) return {};
35
- const files = typeof sf === "string" ? {
36
- client: sf,
37
- server: sf,
38
- ios: sf,
39
- android: sf
40
- } : "native" in sf ? {
41
- client: sf.client,
42
- server: sf.server,
43
- ios: sf.native,
44
- android: sf.native
45
- } : sf;
46
- return {
47
- ...(files.client && {
48
- "process.env.ONE_SETUP_FILE_CLIENT": JSON.stringify(files.client)
49
- }),
50
- ...(files.server && {
51
- "process.env.ONE_SETUP_FILE_SERVER": JSON.stringify(files.server)
52
- }),
53
- ...(files.ios && {
54
- "process.env.ONE_SETUP_FILE_IOS": JSON.stringify(files.ios)
55
- }),
56
- ...(files.android && {
57
- "process.env.ONE_SETUP_FILE_ANDROID": JSON.stringify(files.android)
58
- })
59
- };
60
- })();
61
- const userDefines = {};
62
- for (const [key, value] of Object.entries(globalThis.__vxrnNativeUserDefine || {})) userDefines[key] = typeof value === "string" ? value : JSON.stringify(value);
63
- const mode = dev ? "development" : "production";
64
- const publicEnv = loadEnv(mode, root, ["VITE_", "EXPO_PUBLIC_"]);
65
- const envDefines = {};
66
- for (const [key, value] of Object.entries(publicEnv)) {
67
- envDefines[`import.meta.env.${key}`] = JSON.stringify(value);
68
- envDefines[`process.env.${key}`] = JSON.stringify(value);
69
- }
70
- const envObject = {
71
- ...publicEnv,
72
- MODE: mode,
73
- DEV: dev,
74
- PROD: !dev,
75
- SSR: false,
76
- VITE_ENVIRONMENT: platform,
77
- VITE_NATIVE: "1",
78
- EXPO_OS: platform,
79
- TAMAGUI_TARGET: "native",
80
- TAMAGUI_ENVIRONMENT: platform
81
- };
82
- return {
83
- jsx: {
84
- runtime: "classic"
85
- },
86
- define: {
87
- ...userDefines,
88
- ...envDefines,
89
- "process.env.NODE_ENV": JSON.stringify(mode),
90
- "process.env.VXRN_REACT_19": "false",
91
- "process.env.VITE_ENVIRONMENT": JSON.stringify(platform),
92
- "process.env.VITE_NATIVE": "\"1\"",
93
- "process.env.EXPO_OS": JSON.stringify(platform),
94
- "process.env.TAMAGUI_TARGET": "\"native\"",
95
- "process.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
96
- __DEV__: dev ? "true" : "false",
97
- "import.meta.env": JSON.stringify(envObject),
98
- "import.meta.env.MODE": JSON.stringify(mode),
99
- "import.meta.env.DEV": dev ? "true" : "false",
100
- "import.meta.env.PROD": dev ? "false" : "true",
101
- "import.meta.env.SSR": "false",
102
- "import.meta.env.VITE_ENVIRONMENT": JSON.stringify(platform),
103
- "import.meta.env.VITE_NATIVE": "\"1\"",
104
- "import.meta.env.EXPO_OS": JSON.stringify(platform),
105
- "import.meta.env.TAMAGUI_TARGET": "\"native\"",
106
- "import.meta.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
107
- ...setupFileDefines
108
- },
109
- inject: {
110
- React: "react"
111
- }
112
- };
71
+ const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
72
+ const setupFileDefines = (() => {
73
+ const sf = entryConfig.setupFile;
74
+ if (!sf) return {};
75
+ const files = typeof sf === "string" ? {
76
+ client: sf,
77
+ server: sf,
78
+ ios: sf,
79
+ android: sf
80
+ } : "native" in sf ? {
81
+ client: sf.client,
82
+ server: sf.server,
83
+ ios: sf.native,
84
+ android: sf.native
85
+ } : sf;
86
+ return {
87
+ ...files.client && { "process.env.ONE_SETUP_FILE_CLIENT": JSON.stringify(files.client) },
88
+ ...files.server && { "process.env.ONE_SETUP_FILE_SERVER": JSON.stringify(files.server) },
89
+ ...files.ios && { "process.env.ONE_SETUP_FILE_IOS": JSON.stringify(files.ios) },
90
+ ...files.android && { "process.env.ONE_SETUP_FILE_ANDROID": JSON.stringify(files.android) }
91
+ };
92
+ })();
93
+ const userDefines = {};
94
+ for (const [key, value] of Object.entries(globalThis.__vxrnNativeUserDefine || {})) userDefines[key] = typeof value === "string" ? value : JSON.stringify(value);
95
+ const mode = dev ? "development" : "production";
96
+ const publicEnv = loadEnv(mode, root, ["VITE_", "EXPO_PUBLIC_"]);
97
+ const envDefines = {};
98
+ for (const [key, value] of Object.entries(publicEnv)) {
99
+ envDefines[`import.meta.env.${key}`] = JSON.stringify(value);
100
+ envDefines[`process.env.${key}`] = JSON.stringify(value);
101
+ }
102
+ const envObject = {
103
+ ...publicEnv,
104
+ MODE: mode,
105
+ DEV: dev,
106
+ PROD: !dev,
107
+ SSR: false,
108
+ VITE_ENVIRONMENT: platform,
109
+ VITE_NATIVE: "1",
110
+ EXPO_OS: platform,
111
+ TAMAGUI_TARGET: "native",
112
+ TAMAGUI_ENVIRONMENT: platform
113
+ };
114
+ return {
115
+ jsx: { runtime: "classic" },
116
+ define: {
117
+ ...userDefines,
118
+ ...envDefines,
119
+ "process.env.NODE_ENV": JSON.stringify(mode),
120
+ "process.env.VXRN_REACT_19": "false",
121
+ "process.env.VITE_ENVIRONMENT": JSON.stringify(platform),
122
+ "process.env.VITE_NATIVE": "\"1\"",
123
+ "process.env.EXPO_OS": JSON.stringify(platform),
124
+ "process.env.TAMAGUI_TARGET": "\"native\"",
125
+ "process.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
126
+ __DEV__: dev ? "true" : "false",
127
+ "import.meta.env": JSON.stringify(envObject),
128
+ "import.meta.env.MODE": JSON.stringify(mode),
129
+ "import.meta.env.DEV": dev ? "true" : "false",
130
+ "import.meta.env.PROD": dev ? "false" : "true",
131
+ "import.meta.env.SSR": "false",
132
+ "import.meta.env.VITE_ENVIRONMENT": JSON.stringify(platform),
133
+ "import.meta.env.VITE_NATIVE": "\"1\"",
134
+ "import.meta.env.EXPO_OS": JSON.stringify(platform),
135
+ "import.meta.env.TAMAGUI_TARGET": "\"native\"",
136
+ "import.meta.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
137
+ ...setupFileDefines
138
+ },
139
+ inject: { React: "react" }
140
+ };
113
141
  }
114
142
  function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, onAsset, sourceMaps = false, userPlugins = []) {
115
- const context = {
116
- root,
117
- platform,
118
- dev
119
- };
120
- return [...(globalThis.__vxrnAddNativePlugins || []), serverFileExclusionPlugin(), environmentGuardPlugin(), hmrClientNoopPlugin(), ...(dev ? [reactNativeDedupePlugin(root)] : []), cssStubPlugin(), viteImportGlobPlugin({
121
- root
122
- }), vxrnCompilerPlugin(platform, dev, root, sourceMaps), rnCodegenPlugin({
123
- projectRoot: root
124
- }), flowStripPlugin(), nativeAnimatedGuardPlugin(), assetPlugin({
125
- root,
126
- platform,
127
- assetsDest,
128
- onAsset
129
- }), hermesCompatSWCPlugin(dev, sourceMaps), hermesLoopsPlugin(sourceMaps), ...userPlugins].map(plugin => plugin.api?.vxrnNative ? plugin.api.vxrnNative(context) : plugin);
143
+ const context = {
144
+ root,
145
+ platform,
146
+ dev
147
+ };
148
+ return [
149
+ ...globalThis.__vxrnAddNativePlugins || [],
150
+ serverFileExclusionPlugin(),
151
+ environmentGuardPlugin(),
152
+ hmrClientNoopPlugin(),
153
+ {
154
+ name: "vxrn:legacy-asset-registry",
155
+ resolveId(source, importer) {
156
+ if (source === "@react-native/assets-registry/registry") return this.resolve("react-native/asset-registry", importer, { skipSelf: true });
157
+ }
158
+ },
159
+ ...dev ? [reactNativeDedupePlugin(root)] : [],
160
+ cssStubPlugin(),
161
+ viteImportGlobPlugin({ root }),
162
+ vxrnCompilerPlugin(platform, dev, root, sourceMaps),
163
+ rnCodegenPlugin({ projectRoot: root }),
164
+ flowStripPlugin(),
165
+ nativeAnimatedGuardPlugin(),
166
+ assetPlugin({
167
+ root,
168
+ platform,
169
+ assetsDest,
170
+ onAsset
171
+ }),
172
+ hermesCompatSWCPlugin(dev, sourceMaps),
173
+ hermesLoopsPlugin(sourceMaps),
174
+ ...userPlugins
175
+ ].map((plugin) => plugin.api?.vxrnNative ? plugin.api.vxrnNative(context) : plugin);
130
176
  }
131
177
  function getNativeOutputOptions(prelude, sourcemap, minify) {
132
- return {
133
- format: "esm",
134
- sourcemap,
135
- sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => normalizePath(resolve(dirname(sourcemapPath), relativeSourcePath)),
136
- intro: prelude,
137
- codeSplitting: false,
138
- strictExecutionOrder: true,
139
- minify: minify || "dce-only"
140
- };
178
+ return {
179
+ format: "esm",
180
+ sourcemap,
181
+ sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => normalizePath(resolve(dirname(sourcemapPath), relativeSourcePath)),
182
+ intro: prelude,
183
+ codeSplitting: false,
184
+ strictExecutionOrder: true,
185
+ minify: minify || "dce-only"
186
+ };
141
187
  }
142
188
  function normalizeNativeCommonJSInterop(code) {
143
- return code.replace(/(\b__toESM(?:\$\d+)?\(\s*(?:require[\w$]*\(\)|__rolldown_runtime__\.loadExports\("(?:\\.|[^"\\])*"\))\s*),\s*1(\s*\))/g, "$1$2");
189
+ return code.replace(/(\b__toESM(?:\$\d+)?\(\s*(?:require[\w$]*\(\)|__rolldown_runtime__\.loadExports\("(?:\\.|[^"\\])*"\))\s*),\s*1(\s*\))/g, "$1$2");
144
190
  }
145
191
  function blankPreservingLines(match) {
146
- return "\n".repeat(match.match(/\n/g)?.length ?? 0);
192
+ return "\n".repeat(match.match(/\n/g)?.length ?? 0);
147
193
  }
148
194
  function countLines(code) {
149
- return (code.match(/\n/g)?.length ?? 0) + 1;
195
+ return (code.match(/\n/g)?.length ?? 0) + 1;
150
196
  }
151
197
  function assertBundleLinesPreserved(before, after, stage) {
152
- const beforeLines = countLines(before);
153
- const afterLines = countLines(after);
154
- if (beforeLines !== afterLines) throw new Error(`[vxrn] native bundle post-processing (${stage}) changed the line count (${beforeLines} -> ${afterLines}), which invalidates the source map. Every pass after Rolldown emits the map must preserve lines.`);
198
+ const beforeLines = countLines(before);
199
+ const afterLines = countLines(after);
200
+ if (beforeLines !== afterLines) throw new Error(`[vxrn] native bundle post-processing (${stage}) changed the line count (${beforeLines} -> ${afterLines}), which invalidates the source map. Every pass after Rolldown emits the map must preserve lines.`);
155
201
  }
156
202
  function postProcessNativeBundle(code) {
157
- code = normalizeNativeCommonJSInterop(code);
158
- code = code.replace(/\btypeof\s+import\.meta\b/g, "\"object\"");
159
- code = code.replace(/^[^\S\n]*export[^\S\n]*\{[^}]*\}[^\S\n]*;?[^\S\n]*$/gm, blankPreservingLines);
160
- code = code.replace(/^([^\S\n]*)export[^\S\n]+default[^\S\n]+([^;\n]+);?[^\S\n]*$/gm, "$1$2;");
161
- code = code.replace(/^if \(import\.meta\.hot\).*$/gm, "");
162
- {
163
- const idx = code.indexOf("NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;");
164
- if (idx !== -1) {
165
- const beforeMarker = code.lastIndexOf("NativeAnimatedModule = ", idx);
166
- if (beforeMarker !== -1) {
167
- const lineStart = code.lastIndexOf("\n", beforeMarker);
168
- const snippet = code.slice(lineStart + 1, beforeMarker + 50);
169
- if (snippet.includes("(function()") || snippet.includes("new Proxy")) {
170
- const afterMarker = code.indexOf("})();", idx);
171
- if (afterMarker !== -1) {
172
- const end = afterMarker + 5;
173
- const removed = code.slice(beforeMarker, end);
174
- code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + blankPreservingLines(removed) + code.slice(end);
175
- }
176
- }
177
- }
178
- }
179
- }
180
- return code;
203
+ code = normalizeNativeCommonJSInterop(code);
204
+ code = code.replace(/\btypeof\s+import\.meta\b/g, "\"object\"");
205
+ code = code.replace(/^[^\S\n]*export[^\S\n]*\{[^}]*\}[^\S\n]*;?[^\S\n]*$/gm, blankPreservingLines);
206
+ code = code.replace(/^([^\S\n]*)export[^\S\n]+default[^\S\n]+([^;\n]+);?[^\S\n]*$/gm, "$1$2;");
207
+ code = code.replace(/^if \(import\.meta\.hot\).*$/gm, "");
208
+ {
209
+ const idx = code.indexOf("NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;");
210
+ if (idx !== -1) {
211
+ const beforeMarker = code.lastIndexOf("NativeAnimatedModule = ", idx);
212
+ if (beforeMarker !== -1) {
213
+ const lineStart = code.lastIndexOf("\n", beforeMarker);
214
+ const snippet = code.slice(lineStart + 1, beforeMarker + 50);
215
+ if (snippet.includes("(function()") || snippet.includes("new Proxy")) {
216
+ const afterMarker = code.indexOf("})();", idx);
217
+ if (afterMarker !== -1) {
218
+ const end = afterMarker + 5;
219
+ const removed = code.slice(beforeMarker, end);
220
+ code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + blankPreservingLines(removed) + code.slice(end);
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ return code;
181
227
  }
182
228
  function wrapNativeBundleModuleScope(code) {
183
- const idx = code.indexOf("//#region \\0rolldown/runtime.js");
184
- if (idx === -1) return code;
185
- return code.slice(0, idx) + ";(function() {" + code.slice(idx) + "\n})();\n";
229
+ const idx = code.indexOf("//#region \\0rolldown/runtime.js");
230
+ if (idx === -1) return code;
231
+ return code.slice(0, idx) + ";(function() {" + code.slice(idx) + "\n})();\n";
186
232
  }
187
233
  async function downlevelClassFieldsInBundle(code) {
188
- const startMarker = "//#region \\0rolldown/runtime.js";
189
- const endMarker = "//#endregion";
190
- const startIdx = code.indexOf(startMarker);
191
- if (startIdx === -1) return code;
192
- const endIdx = code.indexOf(endMarker, startIdx);
193
- if (endIdx === -1) return code;
194
- const runtimeEnd = endIdx + 12;
195
- const runtimeSection = code.slice(startIdx, runtimeEnd);
196
- const originalNewlines = runtimeSection.match(/\n/g)?.length ?? 0;
197
- const {
198
- transformSync
199
- } = await import("oxc-transform");
200
- const result = transformSync("rolldown-runtime.js", runtimeSection, {
201
- target: "es2020",
202
- assumptions: {
203
- setPublicClassFields: true
204
- }
205
- });
206
- if (result.errors?.length) throw new Error(result.errors.map(e => e.message).join("\n"));
207
- const transformedCode = result.code.trimEnd();
208
- const transformed = transformedCode.includes(startMarker) ? transformedCode : `${startMarker}
234
+ const startMarker = "//#region \\0rolldown/runtime.js";
235
+ const endMarker = "//#endregion";
236
+ const startIdx = code.indexOf(startMarker);
237
+ if (startIdx === -1) return code;
238
+ const endIdx = code.indexOf(endMarker, startIdx);
239
+ if (endIdx === -1) return code;
240
+ const runtimeEnd = endIdx + 12;
241
+ const runtimeSection = code.slice(startIdx, runtimeEnd);
242
+ const originalNewlines = runtimeSection.match(/\n/g)?.length ?? 0;
243
+ const { transformSync } = await import("oxc-transform");
244
+ const result = transformSync("rolldown-runtime.js", runtimeSection, {
245
+ target: "es2020",
246
+ assumptions: { setPublicClassFields: true }
247
+ });
248
+ if (result.errors?.length) throw new Error(result.errors.map((e) => e.message).join("\n"));
249
+ const transformedCode = result.code.trimEnd();
250
+ const transformed = transformedCode.includes(startMarker) ? transformedCode : `${startMarker}
209
251
  ${transformedCode}`;
210
- const transformedNewlines = transformed.match(/\n/g)?.length ?? 0;
211
- if (transformedNewlines > originalNewlines) throw new Error("[vxrn] Hermes runtime transform added lines and would invalidate the production source map");
212
- const linePreservingRuntime = transformed + "\n".repeat(originalNewlines - transformedNewlines);
213
- return code.slice(0, startIdx) + linePreservingRuntime + code.slice(runtimeEnd);
252
+ const transformedNewlines = transformed.match(/\n/g)?.length ?? 0;
253
+ if (transformedNewlines > originalNewlines) throw new Error("[vxrn] Hermes runtime transform added lines and would invalidate the production source map");
254
+ const linePreservingRuntime = transformed + "\n".repeat(originalNewlines - transformedNewlines);
255
+ return code.slice(0, startIdx) + linePreservingRuntime + code.slice(runtimeEnd);
214
256
  }
215
257
  function nativeBundlePostProcessPlugin() {
216
- return {
217
- name: "vxrn:native-post-process",
218
- async renderChunk(code) {
219
- const processed = await downlevelClassFieldsInBundle(postProcessNativeBundle(code));
220
- assertBundleLinesPreserved(code, processed, "production");
221
- return {
222
- code: processed,
223
- map: null
224
- };
225
- }
226
- };
258
+ return {
259
+ name: "vxrn:native-post-process",
260
+ async renderChunk(code) {
261
+ const processed = await downlevelClassFieldsInBundle(postProcessNativeBundle(code));
262
+ assertBundleLinesPreserved(code, processed, "production");
263
+ return {
264
+ code: processed,
265
+ map: null
266
+ };
267
+ }
268
+ };
227
269
  }
228
270
  async function createNativeDevEngine(options) {
229
- const {
230
- root,
231
- port,
232
- host = "localhost",
233
- platform,
234
- serverUrl,
235
- plugins: userPlugins = [],
236
- onHmrUpdate
237
- } = options;
238
- const {
239
- dev,
240
- viteImportGlobPlugin
241
- } = await import("rolldown/experimental");
242
- const hmrRuntimeSource = getHmrRuntimeSource();
243
- const prelude = getNativePrelude({
244
- dev: true,
245
- platform,
246
- serverUrl: serverUrl || `http://${host}:${port}`
247
- });
248
- const assetRegistry = createNativeDevAssetRegistry();
249
- let currentBundle = null;
250
- let firstBuildError = null;
251
- let bundleResolve = null;
252
- let bundleReject = null;
253
- let bundlePromise = null;
254
- const resolvedHost = host === "0.0.0.0" ? "localhost" : host;
255
- const virtualEntry = nativeVirtualEntryPlugin(root, {
256
- dev: true,
257
- platform,
258
- dynamicRoutes: true
259
- });
260
- let engineWork = Promise.resolve();
261
- const queueEngineWork = work => {
262
- const result = engineWork.then(work, work);
263
- engineWork = result.catch(() => {});
264
- return result;
265
- };
266
- const inputOptions = {
267
- input: VIRTUAL_NATIVE_ENTRY,
268
- cwd: root,
269
- platform: "neutral",
270
- resolve: getNativeResolveConfig(platform),
271
- transform: getNativeTransformConfig(platform, true, root),
272
- experimental: {
273
- devMode: {
274
- implement: hmrRuntimeSource,
275
- host,
276
- port
277
- },
278
- incrementalBuild: true,
279
- lazyBarrel: true
280
- },
281
- treeshake: false,
282
- shimMissingExports: true,
283
- moduleTypes: {
284
- ".js": "jsx"
285
- },
286
- plugins: [virtualEntry.plugin, ...getNativePlugins(root, platform, viteImportGlobPlugin, true, void 0, assetRegistry.register, true, userPlugins)]
287
- };
288
- const outputOptions = {
289
- ...getNativeOutputOptions(prelude, true, false),
290
- outro: `
271
+ const { root, port, host = "localhost", platform, serverUrl, plugins: userPlugins = [], onHmrUpdate } = options;
272
+ const { dev, viteImportGlobPlugin } = await import("rolldown/experimental");
273
+ const hmrRuntimeSource = getHmrRuntimeSource();
274
+ const prelude = getNativePrelude({
275
+ dev: true,
276
+ platform,
277
+ serverUrl: serverUrl || `http://${host}:${port}`
278
+ });
279
+ const assetRegistry = createNativeDevAssetRegistry();
280
+ let currentBundle = null;
281
+ let firstBuildError = null;
282
+ let bundleResolve = null;
283
+ let bundleReject = null;
284
+ let bundlePromise = null;
285
+ const resolvedHost = host === "0.0.0.0" ? "localhost" : host;
286
+ const virtualEntry = nativeVirtualEntryPlugin(root, {
287
+ dev: true,
288
+ platform,
289
+ dynamicRoutes: true
290
+ });
291
+ let engineWork = Promise.resolve();
292
+ const queueEngineWork = (work) => {
293
+ const result = engineWork.then(work, work);
294
+ engineWork = result.catch(() => {});
295
+ return result;
296
+ };
297
+ const inputOptions = {
298
+ input: VIRTUAL_NATIVE_ENTRY,
299
+ cwd: root,
300
+ platform: "neutral",
301
+ resolve: getNativeResolveConfig(platform),
302
+ transform: getNativeTransformConfig(platform, true, root),
303
+ experimental: {
304
+ devMode: {
305
+ implement: hmrRuntimeSource,
306
+ host,
307
+ port
308
+ },
309
+ incrementalBuild: true,
310
+ lazyBarrel: true
311
+ },
312
+ treeshake: false,
313
+ shimMissingExports: true,
314
+ moduleTypes: { ".js": "jsx" },
315
+ plugins: [virtualEntry.plugin, ...getNativePlugins(root, platform, viteImportGlobPlugin, true, void 0, assetRegistry.register, true, userPlugins)]
316
+ };
317
+ const outputOptions = {
318
+ ...getNativeOutputOptions(prelude, true, false),
319
+ outro: `
291
320
  try {
292
321
  var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
293
322
  var __hmrUrl = 'ws://${resolvedHost}:${port}/hot?platform=${platform}&clientId=' + encodeURIComponent(__rolldown_runtime__.clientId);
@@ -298,228 +327,212 @@ try {
298
327
  console.error('[vxrn] HMR client failed to start:', (e && e.message) || e);
299
328
  }
300
329
  `
301
- };
302
- let outputProcessed = Promise.resolve();
303
- let engine;
304
- let routeWatcher;
305
- const rebuildIfRouteGraphChanged = () => queueEngineWork(async () => {
306
- const {
307
- files: knownRoutes,
308
- scanFiles,
309
- updateFiles
310
- } = virtualEntry.routes;
311
- const currentRoutes = scanFiles();
312
- if (!(currentRoutes.size !== knownRoutes.size || [...currentRoutes].some(route => !knownRoutes.has(route)))) return false;
313
- updateFiles(currentRoutes);
314
- return true;
315
- });
316
- engine = await dev(inputOptions, outputOptions, {
317
- onOutput: async result => {
318
- let finishOutput = () => {};
319
- outputProcessed = new Promise(resolve2 => {
320
- finishOutput = resolve2;
321
- });
322
- try {
323
- await handleOutput(result);
324
- } finally {
325
- finishOutput();
326
- }
327
- },
328
- onHmrUpdates: async result => {
329
- if (result instanceof Error) {
330
- console.error("[vxrn] HMR error:", result.message);
331
- onHmrUpdate?.({
332
- type: "hmr:error"
333
- });
334
- return;
335
- }
336
- if (await rebuildIfRouteGraphChanged()) return;
337
- for (const {
338
- clientId,
339
- update
340
- } of result.updates) if (update.type === "Patch" && update.code) onHmrUpdate?.({
341
- type: "hmr:update",
342
- clientId,
343
- code: normalizeNativeCommonJSInterop(update.code),
344
- changedIds: update.changedIds,
345
- seq: update.seq
346
- });else if (update.type === "FullReload") onHmrUpdate?.({
347
- type: "hmr:reload",
348
- clientId
349
- });
350
- },
351
- rebuildStrategy: "never",
352
- watch: {}
353
- });
354
- async function handleOutput(result) {
355
- if (result instanceof Error) {
356
- console.error("[vxrn] native bundle error:", result.message);
357
- if (/panic/i.test(result.message)) console.error("[vxrn] rolldown itself panicked. Fast Refresh will full-reload until you restart the dev server.");
358
- if (!currentBundle) {
359
- firstBuildError ||= result;
360
- if (bundleReject) {
361
- const reject = bundleReject;
362
- bundleResolve = null;
363
- bundleReject = null;
364
- bundlePromise = null;
365
- reject(firstBuildError);
366
- }
367
- }
368
- return;
369
- }
370
- const chunk = result.output.find(o => o.type === "chunk" && o.isEntry);
371
- if (chunk && "code" in chunk) {
372
- firstBuildError = null;
373
- let code = postProcessNativeBundle(chunk.code);
374
- code = await downlevelClassFieldsInBundle(code);
375
- assertBundleLinesPreserved(chunk.code, code, "dev");
376
- code = wrapNativeBundleModuleScope(code);
377
- if (!chunk.map) throw new Error("[vxrn] rolldown produced no source map for the dev bundle, so /symbolicate cannot resolve a frame");
378
- currentBundle = {
379
- code,
380
- map: chunk.map.toString()
381
- };
382
- console.info(`[vxrn] native bundle ready (${Math.round(code.length / 1024)}KB)`);
383
- if (bundleResolve) {
384
- bundleResolve(currentBundle);
385
- bundleResolve = null;
386
- bundleReject = null;
387
- bundlePromise = null;
388
- }
389
- }
390
- }
391
- await engine.run();
392
- let routeWatchTarget = virtualEntry.routes.routeRoot;
393
- while (!statSync(routeWatchTarget, {
394
- throwIfNoEntry: false
395
- })?.isDirectory()) {
396
- const parent = dirname(routeWatchTarget);
397
- if (parent === routeWatchTarget) break;
398
- routeWatchTarget = parent;
399
- }
400
- const normalizedRouteRoot = normalizePath(virtualEntry.routes.routeRoot);
401
- routeWatcher = watch(routeWatchTarget, {
402
- recursive: true
403
- }, (_eventType, file) => {
404
- if (file === null) return;
405
- const changed = normalizePath(resolve(routeWatchTarget, file.toString()));
406
- if (changed !== normalizedRouteRoot && !changed.startsWith(`${normalizedRouteRoot}/`)) return;
407
- rebuildIfRouteGraphChanged().catch(error => {
408
- console.error(`[vxrn] rebuilding the native route map failed`, error);
409
- });
410
- });
411
- routeWatcher.on("error", error => {
412
- console.error(`[vxrn] watching the native route map failed`, error);
413
- });
414
- await rebuildIfRouteGraphChanged();
415
- return {
416
- engine,
417
- async getBundle() {
418
- await queueEngineWork(async () => {
419
- await engine.ensureLatestBuildOutput();
420
- await outputProcessed;
421
- });
422
- if (currentBundle) return currentBundle;
423
- if (firstBuildError) throw firstBuildError;
424
- if (!bundlePromise) {
425
- let timeoutId;
426
- bundlePromise = new Promise((resolve2, reject) => {
427
- bundleResolve = value => {
428
- clearTimeout(timeoutId);
429
- resolve2(value);
430
- };
431
- bundleReject = error => {
432
- clearTimeout(timeoutId);
433
- reject(error);
434
- };
435
- timeoutId = setTimeout(() => {
436
- bundleResolve = null;
437
- bundleReject = null;
438
- bundlePromise = null;
439
- reject(/* @__PURE__ */new Error("[vxrn] bundle build timed out after 120s"));
440
- }, 12e4);
441
- });
442
- }
443
- return bundlePromise;
444
- },
445
- getAsset(pathname, hash) {
446
- return assetRegistry.resolve(pathname, hash);
447
- },
448
- async close() {
449
- routeWatcher?.close();
450
- await engine.close();
451
- }
452
- };
330
+ };
331
+ let outputProcessed = Promise.resolve();
332
+ let engine;
333
+ let routeWatcher;
334
+ const rebuildIfRouteGraphChanged = () => queueEngineWork(async () => {
335
+ const { files: knownRoutes, scanFiles, updateFiles } = virtualEntry.routes;
336
+ const currentRoutes = scanFiles();
337
+ if (!(currentRoutes.size !== knownRoutes.size || [...currentRoutes].some((route) => !knownRoutes.has(route)))) return false;
338
+ updateFiles(currentRoutes);
339
+ return true;
340
+ });
341
+ engine = await dev(inputOptions, outputOptions, {
342
+ onOutput: async (result) => {
343
+ let finishOutput = () => {};
344
+ outputProcessed = new Promise((resolve2) => {
345
+ finishOutput = resolve2;
346
+ });
347
+ try {
348
+ await handleOutput(result);
349
+ } finally {
350
+ finishOutput();
351
+ }
352
+ },
353
+ onHmrUpdates: async (result) => {
354
+ if (result instanceof Error) {
355
+ console.error("[vxrn] HMR error:", result.message);
356
+ onHmrUpdate?.({ type: "hmr:error" });
357
+ return;
358
+ }
359
+ if (await rebuildIfRouteGraphChanged()) return;
360
+ for (const { clientId, update } of result.updates) if (update.type === "Patch" && update.code) onHmrUpdate?.({
361
+ type: "hmr:update",
362
+ clientId,
363
+ code: normalizeNativeCommonJSInterop(update.code),
364
+ changedIds: update.changedIds,
365
+ seq: update.seq
366
+ });
367
+ else if (update.type === "FullReload") onHmrUpdate?.({
368
+ type: "hmr:reload",
369
+ clientId
370
+ });
371
+ },
372
+ rebuildStrategy: "never",
373
+ watch: {}
374
+ });
375
+ async function handleOutput(result) {
376
+ if (result instanceof Error) {
377
+ console.error("[vxrn] native bundle error:", result.message);
378
+ if (/panic/i.test(result.message)) console.error("[vxrn] rolldown itself panicked. Fast Refresh will full-reload until you restart the dev server.");
379
+ if (!currentBundle) {
380
+ firstBuildError ||= result;
381
+ if (bundleReject) {
382
+ const reject = bundleReject;
383
+ bundleResolve = null;
384
+ bundleReject = null;
385
+ bundlePromise = null;
386
+ reject(firstBuildError);
387
+ }
388
+ }
389
+ return;
390
+ }
391
+ const chunk = result.output.find((o) => o.type === "chunk" && o.isEntry);
392
+ if (chunk && "code" in chunk) {
393
+ firstBuildError = null;
394
+ let code = postProcessNativeBundle(chunk.code);
395
+ code = await downlevelClassFieldsInBundle(code);
396
+ assertBundleLinesPreserved(chunk.code, code, "dev");
397
+ code = wrapNativeBundleModuleScope(code);
398
+ if (!chunk.map) throw new Error("[vxrn] rolldown produced no source map for the dev bundle, so /symbolicate cannot resolve a frame");
399
+ currentBundle = {
400
+ code,
401
+ map: chunk.map.toString()
402
+ };
403
+ console.info(`[vxrn] native bundle ready (${Math.round(code.length / 1024)}KB)`);
404
+ if (bundleResolve) {
405
+ bundleResolve(currentBundle);
406
+ bundleResolve = null;
407
+ bundleReject = null;
408
+ bundlePromise = null;
409
+ }
410
+ }
411
+ }
412
+ await engine.run();
413
+ let routeWatchTarget = virtualEntry.routes.routeRoot;
414
+ while (!statSync(routeWatchTarget, { throwIfNoEntry: false })?.isDirectory()) {
415
+ const parent = dirname(routeWatchTarget);
416
+ if (parent === routeWatchTarget) break;
417
+ routeWatchTarget = parent;
418
+ }
419
+ const normalizedRouteRoot = normalizePath(virtualEntry.routes.routeRoot);
420
+ routeWatcher = watch(routeWatchTarget, { recursive: true }, (_eventType, file) => {
421
+ if (file === null) return;
422
+ const changed = normalizePath(resolve(routeWatchTarget, file.toString()));
423
+ if (changed !== normalizedRouteRoot && !changed.startsWith(`${normalizedRouteRoot}/`)) return;
424
+ rebuildIfRouteGraphChanged().catch((error) => {
425
+ console.error(`[vxrn] rebuilding the native route map failed`, error);
426
+ });
427
+ });
428
+ routeWatcher.on("error", (error) => {
429
+ console.error(`[vxrn] watching the native route map failed`, error);
430
+ });
431
+ await rebuildIfRouteGraphChanged();
432
+ return {
433
+ engine,
434
+ async getBundle() {
435
+ await queueEngineWork(async () => {
436
+ await engine.ensureLatestBuildOutput();
437
+ await outputProcessed;
438
+ });
439
+ if (currentBundle) return currentBundle;
440
+ if (firstBuildError) throw firstBuildError;
441
+ if (!bundlePromise) {
442
+ let timeoutId;
443
+ bundlePromise = new Promise((resolve2, reject) => {
444
+ bundleResolve = (value) => {
445
+ clearTimeout(timeoutId);
446
+ resolve2(value);
447
+ };
448
+ bundleReject = (error) => {
449
+ clearTimeout(timeoutId);
450
+ reject(error);
451
+ };
452
+ timeoutId = setTimeout(() => {
453
+ bundleResolve = null;
454
+ bundleReject = null;
455
+ bundlePromise = null;
456
+ reject(/* @__PURE__ */ new Error("[vxrn] bundle build timed out after 120s"));
457
+ }, 12e4);
458
+ });
459
+ }
460
+ return bundlePromise;
461
+ },
462
+ getAsset(pathname, hash) {
463
+ return assetRegistry.resolve(pathname, hash);
464
+ },
465
+ async close() {
466
+ routeWatcher?.close();
467
+ await engine.close();
468
+ }
469
+ };
453
470
  }
454
471
  async function buildNativeBundle(options) {
455
- const {
456
- root,
457
- platform,
458
- dev = false,
459
- serverUrl,
460
- entryFile,
461
- assetsDest,
462
- plugins: userPlugins = [],
463
- sourcemap = false,
464
- minify = !dev
465
- } = options;
466
- const {
467
- build
468
- } = await import("rolldown");
469
- const {
470
- viteImportGlobPlugin
471
- } = await import("rolldown/experimental");
472
- const prelude = getNativePrelude({
473
- dev,
474
- platform,
475
- serverUrl
476
- });
477
- const chunk = (await build({
478
- input: entryFile ? normalizePath(resolve(root, entryFile)) : VIRTUAL_NATIVE_ENTRY,
479
- cwd: root,
480
- platform: "neutral",
481
- resolve: getNativeResolveConfig(platform),
482
- transform: getNativeTransformConfig(platform, dev, root),
483
- treeshake: !dev,
484
- experimental: {
485
- lazyBarrel: false
486
- },
487
- shimMissingExports: true,
488
- moduleTypes: {
489
- ".js": "jsx"
490
- },
491
- plugins: [...(entryFile ? [] : [nativeVirtualEntryPlugin(root, {
492
- dev,
493
- platform
494
- }).plugin]), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap, userPlugins), nativeBundlePostProcessPlugin()],
495
- output: getNativeOutputOptions(prelude, sourcemap, minify)
496
- })).output.find(o => o.type === "chunk" && o.isEntry);
497
- if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
498
- if (sourcemap && !chunk.map) throw new Error("[vxrn] a source map was requested but rolldown produced none for the production bundle");
499
- return {
500
- code: chunk.code,
501
- map: sourcemap ? chunk.map?.toString() : void 0
502
- };
472
+ const { root, platform, dev = false, serverUrl, entryFile, assetsDest, plugins: userPlugins = [], sourcemap = false, minify = !dev } = options;
473
+ const { build } = await import("rolldown");
474
+ const { viteImportGlobPlugin } = await import("rolldown/experimental");
475
+ const prelude = getNativePrelude({
476
+ dev,
477
+ platform,
478
+ serverUrl
479
+ });
480
+ const chunk = (await build({
481
+ input: entryFile ? normalizePath(resolve(root, entryFile)) : VIRTUAL_NATIVE_ENTRY,
482
+ cwd: root,
483
+ platform: "neutral",
484
+ resolve: getNativeResolveConfig(platform),
485
+ transform: getNativeTransformConfig(platform, dev, root),
486
+ treeshake: !dev,
487
+ experimental: { lazyBarrel: false },
488
+ shimMissingExports: true,
489
+ moduleTypes: { ".js": "jsx" },
490
+ plugins: [
491
+ ...entryFile ? [] : [nativeVirtualEntryPlugin(root, {
492
+ dev,
493
+ platform
494
+ }).plugin],
495
+ ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap, userPlugins),
496
+ nativeBundlePostProcessPlugin()
497
+ ],
498
+ output: getNativeOutputOptions(prelude, sourcemap, minify)
499
+ })).output.find((o) => o.type === "chunk" && o.isEntry);
500
+ if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
501
+ if (sourcemap && !chunk.map) throw new Error("[vxrn] a source map was requested but rolldown produced none for the production bundle");
502
+ return {
503
+ code: chunk.code,
504
+ map: sourcemap ? chunk.map?.toString() : void 0
505
+ };
503
506
  }
504
507
  const VIRTUAL_NATIVE_ENTRY = "virtual:native-entry";
505
508
  function nativeVirtualEntryPlugin(root, opts) {
506
- const isDev = opts?.dev !== false;
507
- const useDynamicRouteRegistry = opts.dynamicRoutes === true;
508
- const resolvedId = normalizePath(resolve(root, "__virtual-native-entry.tsx"));
509
- const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
510
- const routerRoot = entryConfig.routerRoot || "app";
511
- const flags = entryConfig.flags || {};
512
- const linking = entryConfig.linking;
513
- const setupFileImport = (() => {
514
- const sf = entryConfig.setupFile;
515
- if (!sf) return "";
516
- const file = typeof sf === "string" ? sf : "native" in sf ? sf.native : sf.ios;
517
- if (!file) return "";
518
- const resolved = pathToFileURL(resolve(root, file)).href;
519
- return `import ${JSON.stringify(resolved)};`;
520
- })();
521
- const routeGlobs = [`./${routerRoot}/**/*.tsx`, `./${routerRoot}/**/*.ts`, `!./${routerRoot}/**/*+api.*`, `!./${routerRoot}/**/*.test.*`, `!./${routerRoot}/**/*.d.ts`, `!./${routerRoot}/**/*.server.*`, `!./${routerRoot}/**/_middleware.*`, `!./${routerRoot}/**/*.web.*`, ...(entryConfig.ignoredRouteFiles || []).map(pattern => `!./${routerRoot}/${pattern}`)];
522
- const refreshSetup = isDev ? `
509
+ const isDev = opts?.dev !== false;
510
+ const useDynamicRouteRegistry = opts.dynamicRoutes === true;
511
+ const resolvedId = normalizePath(resolve(root, "__virtual-native-entry.tsx"));
512
+ const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
513
+ const routerRoot = entryConfig.routerRoot || "app";
514
+ const flags = entryConfig.flags || {};
515
+ const linking = entryConfig.linking;
516
+ const setupFileImport = (() => {
517
+ const sf = entryConfig.setupFile;
518
+ if (!sf) return "";
519
+ const file = typeof sf === "string" ? sf : "native" in sf ? sf.native : sf.ios;
520
+ if (!file) return "";
521
+ const resolved = pathToFileURL(resolve(root, file)).href;
522
+ return `import ${JSON.stringify(resolved)};`;
523
+ })();
524
+ const routeGlobs = [
525
+ `./${routerRoot}/**/*.tsx`,
526
+ `./${routerRoot}/**/*.ts`,
527
+ `!./${routerRoot}/**/*+api.*`,
528
+ `!./${routerRoot}/**/*.test.*`,
529
+ `!./${routerRoot}/**/*.d.ts`,
530
+ `!./${routerRoot}/**/*.server.*`,
531
+ `!./${routerRoot}/**/_middleware.*`,
532
+ `!./${routerRoot}/**/*.web.*`,
533
+ ...(entryConfig.ignoredRouteFiles || []).map((pattern) => `!./${routerRoot}/${pattern}`)
534
+ ];
535
+ const refreshSetup = isDev ? `
523
536
  // react-refresh/runtime MUST initialize before React loads
524
537
  import RefreshRuntime from 'react-refresh/runtime';
525
538
  RefreshRuntime.injectIntoGlobalHook(globalThis);
@@ -529,7 +542,7 @@ globalThis.$RefreshReg$ = function(type, id) {
529
542
  };
530
543
  globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
531
544
  ` : "";
532
- const entryCode = () => `
545
+ const entryCode = () => `
533
546
  ${refreshSetup}
534
547
  import * as ReactNativeInitializeCore from 'react-native/Libraries/Core/InitializeCore';
535
548
  import NativeWebSocket from 'react-native/Libraries/WebSocket/WebSocket';
@@ -557,317 +570,312 @@ createApp({
557
570
 
558
571
  ${routeHmr}
559
572
  `;
560
- const routeRoot = resolve(root, routerRoot);
561
- const stripDot = pattern => pattern.replace(/^\.\//, "");
562
- const includeGlobs = routeGlobs.filter(p => !p.startsWith("!")).map(stripDot);
563
- const excludeGlobs = routeGlobs.filter(p => p.startsWith("!")).map(p => stripDot(p.slice(1)));
564
- const isRouteFile = file => {
565
- const relativeToRoot = normalizePath(relative(root, file));
566
- return micromatch.isMatch(relativeToRoot, includeGlobs) && !micromatch.isMatch(relativeToRoot, excludeGlobs);
567
- };
568
- const scanFiles = () => {
569
- const files = /* @__PURE__ */new Set();
570
- const walkRouteRoot = dir => {
571
- for (const entry of readdirSync(dir, {
572
- withFileTypes: true
573
- })) {
574
- const child = resolve(dir, entry.name);
575
- if (entry.isDirectory()) walkRouteRoot(child);else if (isRouteFile(child)) files.add(normalizePath(child));
576
- }
577
- };
578
- if (statSync(routeRoot, {
579
- throwIfNoEntry: false
580
- })?.isDirectory()) walkRouteRoot(routeRoot);
581
- return files;
582
- };
583
- const registrySpecifier = `./node_modules/.vxrn/native-routes-${opts.platform}.mjs`;
584
- const registryPath = resolve(root, registrySpecifier);
585
- const routes = {
586
- routeRoot,
587
- files: /* @__PURE__ */new Set(),
588
- isRouteFile,
589
- scanFiles,
590
- updateFiles(files) {
591
- routes.files = files;
592
- if (!useDynamicRouteRegistry) return;
593
- const source = `export const routes = {
594
- ${[...files].sort().map(file => {
595
- const routeKey = `/${normalizePath(relative(root, file))}`;
596
- let importPath = normalizePath(relative(dirname(registryPath), file));
597
- if (!importPath.startsWith(".")) importPath = `./${importPath}`;
598
- return ` ${JSON.stringify(routeKey)}: () => import(${JSON.stringify(importPath)})`;
599
- }).join(",\n")}
573
+ const routeRoot = resolve(root, routerRoot);
574
+ const stripDot = (pattern) => pattern.replace(/^\.\//, "");
575
+ const includeGlobs = routeGlobs.filter((p) => !p.startsWith("!")).map(stripDot);
576
+ const excludeGlobs = routeGlobs.filter((p) => p.startsWith("!")).map((p) => stripDot(p.slice(1)));
577
+ const isRouteFile = (file) => {
578
+ const relativeToRoot = normalizePath(relative(root, file));
579
+ return micromatch.isMatch(relativeToRoot, includeGlobs) && !micromatch.isMatch(relativeToRoot, excludeGlobs);
580
+ };
581
+ const scanFiles = () => {
582
+ const files = /* @__PURE__ */ new Set();
583
+ const walkRouteRoot = (dir) => {
584
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
585
+ const child = resolve(dir, entry.name);
586
+ if (entry.isDirectory()) walkRouteRoot(child);
587
+ else if (isRouteFile(child)) files.add(normalizePath(child));
588
+ }
589
+ };
590
+ if (statSync(routeRoot, { throwIfNoEntry: false })?.isDirectory()) walkRouteRoot(routeRoot);
591
+ return files;
592
+ };
593
+ const registrySpecifier = `./node_modules/.vxrn/native-routes-${opts.platform}.mjs`;
594
+ const registryPath = resolve(root, registrySpecifier);
595
+ const routes = {
596
+ routeRoot,
597
+ files: /* @__PURE__ */ new Set(),
598
+ isRouteFile,
599
+ scanFiles,
600
+ updateFiles(files) {
601
+ routes.files = files;
602
+ if (!useDynamicRouteRegistry) return;
603
+ const source = `export const routes = {
604
+ ${[...files].sort().map((file) => {
605
+ const routeKey = `/${normalizePath(relative(root, file))}`;
606
+ let importPath = normalizePath(relative(dirname(registryPath), file));
607
+ if (!importPath.startsWith(".")) importPath = `./${importPath}`;
608
+ return ` ${JSON.stringify(routeKey)}: () => import(${JSON.stringify(importPath)})`;
609
+ }).join(",\n")}
600
610
  }
601
611
  `;
602
- mkdirSync(dirname(registryPath), {
603
- recursive: true
604
- });
605
- if (!existsSync(registryPath) || readFileSync(registryPath, "utf8") !== source) writeFileSync(registryPath, source);
606
- }
607
- };
608
- routes.updateFiles(routes.scanFiles());
609
- const routeImports = useDynamicRouteRegistry ? `import { routes } from ${JSON.stringify(registrySpecifier)};` : `var _routes = import.meta.glob(${JSON.stringify(routeGlobs)}, { exhaustive: true });
612
+ mkdirSync(dirname(registryPath), { recursive: true });
613
+ if (!existsSync(registryPath) || readFileSync(registryPath, "utf8") !== source) writeFileSync(registryPath, source);
614
+ }
615
+ };
616
+ routes.updateFiles(routes.scanFiles());
617
+ const routeImports = useDynamicRouteRegistry ? `import { routes } from ${JSON.stringify(registrySpecifier)};` : `var _routes = import.meta.glob(${JSON.stringify(routeGlobs)}, { exhaustive: true });
610
618
  // fix route keys: One expects '/${routerRoot}/...' prefix but import.meta.glob returns './${routerRoot}/...'
611
619
  var routes = {};
612
620
  Object.keys(_routes).forEach(function(key) {
613
621
  var normalizedKey = key.replace(/^\\.\\//, '');
614
622
  routes['/' + normalizedKey] = _routes[key];
615
623
  });`;
616
- const routeHmr = useDynamicRouteRegistry ? `if (import.meta.hot) {
624
+ const routeHmr = useDynamicRouteRegistry ? `if (import.meta.hot) {
617
625
  import.meta.hot.accept(${JSON.stringify(registrySpecifier)}, function(next) {
618
626
  if (globalThis.__VXRN_UPDATE_NATIVE_ROUTES__) {
619
627
  globalThis.__VXRN_UPDATE_NATIVE_ROUTES__(next.routes);
620
628
  }
621
629
  });
622
630
  }` : "";
623
- return {
624
- routes,
625
- plugin: {
626
- name: "vxrn:native-virtual-entry",
627
- resolveId(id) {
628
- if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
629
- },
630
- load(id) {
631
- if (id !== resolvedId) return;
632
- return entryCode();
633
- }
634
- }
635
- };
631
+ return {
632
+ routes,
633
+ plugin: {
634
+ name: "vxrn:native-virtual-entry",
635
+ resolveId(id) {
636
+ if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
637
+ },
638
+ load(id) {
639
+ if (id !== resolvedId) return;
640
+ return entryCode();
641
+ }
642
+ }
643
+ };
636
644
  }
637
645
  function nativeAnimatedGuardPlugin() {
638
- return {
639
- name: "vxrn:native-animated-guard",
640
- transform(code, id) {
641
- if (!id.includes("animated/NativeAnimatedHelper")) return;
642
- const target = "const method = nullthrows(NativeAnimatedModule)[methodName];";
643
- if (!code.includes(target)) return;
644
- return {
645
- code: code.replace(target, `${target} if (typeof method !== 'function') return;`),
646
- map: {
647
- version: 3,
648
- sources: [id],
649
- sourcesContent: [code],
650
- names: [],
651
- mappings: code.split("\n").map((_, index) => index === 0 ? "AAAA" : "AACA").join(";")
652
- }
653
- };
654
- }
655
- };
646
+ return {
647
+ name: "vxrn:native-animated-guard",
648
+ transform(code, id) {
649
+ if (!id.includes("animated/NativeAnimatedHelper")) return;
650
+ const target = "const method = nullthrows(NativeAnimatedModule)[methodName];";
651
+ if (!code.includes(target)) return;
652
+ return {
653
+ code: code.replace(target, `${target} if (typeof method !== 'function') return;`),
654
+ map: {
655
+ version: 3,
656
+ sources: [id],
657
+ sourcesContent: [code],
658
+ names: [],
659
+ mappings: code.split("\n").map((_, index) => index === 0 ? "AAAA" : "AACA").join(";")
660
+ }
661
+ };
662
+ }
663
+ };
656
664
  }
657
665
  function serverFileExclusionPlugin() {
658
- return {
659
- name: "vxrn:server-file-exclusion",
660
- load(id) {
661
- if (/\.server\.\w+$/.test(id)) return {
662
- code: "export default undefined;",
663
- moduleType: "js"
664
- };
665
- if (/[\\/]_middleware\.\w+$/.test(id)) return {
666
- code: "export default undefined;",
667
- moduleType: "js"
668
- };
669
- }
670
- };
666
+ return {
667
+ name: "vxrn:server-file-exclusion",
668
+ load(id) {
669
+ if (/\.server\.\w+$/.test(id)) return {
670
+ code: "export default undefined;",
671
+ moduleType: "js"
672
+ };
673
+ if (/[\\/]_middleware\.\w+$/.test(id)) return {
674
+ code: "export default undefined;",
675
+ moduleType: "js"
676
+ };
677
+ }
678
+ };
671
679
  }
672
680
  function environmentGuardPlugin() {
673
- const THROWING = ["server-only", "client-only", "web-only"];
674
- const NOOP = ["native-only"];
675
- return {
676
- name: "vxrn:environment-guard",
677
- resolveId(source) {
678
- if (THROWING.includes(source)) return {
679
- id: `\0env-guard-throw:${source}`,
680
- external: false
681
- };
682
- if (NOOP.includes(source)) return {
683
- id: `\0env-guard-noop:${source}`,
684
- external: false
685
- };
686
- },
687
- load(id) {
688
- if (id.startsWith("\0env-guard-throw:")) return {
689
- code: `throw new Error("Cannot import '${id.slice(17)}' in a native bundle.");`,
690
- moduleType: "js"
691
- };
692
- if (id.startsWith("\0env-guard-noop:")) return {
693
- code: "",
694
- moduleType: "js"
695
- };
696
- }
697
- };
681
+ const THROWING = [
682
+ "server-only",
683
+ "client-only",
684
+ "web-only"
685
+ ];
686
+ const NOOP = ["native-only"];
687
+ return {
688
+ name: "vxrn:environment-guard",
689
+ resolveId(source) {
690
+ if (THROWING.includes(source)) return {
691
+ id: `\0env-guard-throw:${source}`,
692
+ external: false
693
+ };
694
+ if (NOOP.includes(source)) return {
695
+ id: `\0env-guard-noop:${source}`,
696
+ external: false
697
+ };
698
+ },
699
+ load(id) {
700
+ if (id.startsWith("\0env-guard-throw:")) return {
701
+ code: `throw new Error("Cannot import '${id.slice(17)}' in a native bundle.");`,
702
+ moduleType: "js"
703
+ };
704
+ if (id.startsWith("\0env-guard-noop:")) return {
705
+ code: "",
706
+ moduleType: "js"
707
+ };
708
+ }
709
+ };
698
710
  }
699
711
  function hmrClientNoopPlugin() {
700
- const RN_HMR_CLIENT_RE = /(^|[\\/])Utilities[\\/]HMRClient(\.[cm]?[jt]sx?)?$/;
701
- return {
702
- name: "vxrn:hmr-client-noop",
703
- resolveId(source, importer) {
704
- if ((source.startsWith("react-native/") || importer != null && /(^|[\\/])react-native[\\/]/.test(importer)) && RN_HMR_CLIENT_RE.test(source)) return {
705
- id: "\0vxrn-hmr-client-noop",
706
- external: false
707
- };
708
- },
709
- load(id) {
710
- if (id === "\0vxrn-hmr-client-noop") return {
711
- code: `const HMRClient = { setup() {}, enable() {}, disable() {}, registerBundle() {}, log() {}, isEnabled() { return false } }
712
+ const RN_HMR_CLIENT_RE = /(^|[\\/])Utilities[\\/]HMRClient(\.[cm]?[jt]sx?)?$/;
713
+ return {
714
+ name: "vxrn:hmr-client-noop",
715
+ resolveId(source, importer) {
716
+ if ((source.startsWith("react-native/") || importer != null && /(^|[\\/])react-native[\\/]/.test(importer)) && RN_HMR_CLIENT_RE.test(source)) return {
717
+ id: "\0vxrn-hmr-client-noop",
718
+ external: false
719
+ };
720
+ },
721
+ load(id) {
722
+ if (id === "\0vxrn-hmr-client-noop") return {
723
+ code: `const HMRClient = { setup() {}, enable() {}, disable() {}, registerBundle() {}, log() {}, isEnabled() { return false } }
712
724
  export default HMRClient`,
713
- moduleType: "js"
714
- };
715
- }
716
- };
725
+ moduleType: "js"
726
+ };
727
+ }
728
+ };
717
729
  }
718
730
  function reactNativeDedupePlugin(root) {
719
- let reactNativeRoot;
720
- return {
721
- name: "vxrn:react-native-dedupe",
722
- async resolveId(source, importer) {
723
- if (source !== "react-native" && !source.startsWith("react-native/")) return;
724
- reactNativeRoot ||= realpathSync(dirname(resolvePath("react-native/package.json", root)));
725
- const subpath = source === "react-native" ? "index.js" : source.slice(13);
726
- return this.resolve(normalizePath(resolve(reactNativeRoot, subpath)), importer, {
727
- skipSelf: true
728
- });
729
- }
730
- };
731
+ let reactNativeRoot;
732
+ return {
733
+ name: "vxrn:react-native-dedupe",
734
+ async resolveId(source, importer) {
735
+ if (source !== "react-native" && !source.startsWith("react-native/")) return;
736
+ reactNativeRoot ||= realpathSync(dirname(resolvePath("react-native/package.json", root)));
737
+ const subpath = source === "react-native" ? "index.js" : source.slice(13);
738
+ return this.resolve(normalizePath(resolve(reactNativeRoot, subpath)), importer, { skipSelf: true });
739
+ }
740
+ };
731
741
  }
732
742
  function cssStubPlugin() {
733
- return {
734
- name: "vxrn:css-stub",
735
- load: {
736
- handler(id) {
737
- if (id.endsWith(".css")) return {
738
- code: "",
739
- moduleType: "js"
740
- };
741
- }
742
- }
743
- };
743
+ return {
744
+ name: "vxrn:css-stub",
745
+ load: { handler(id) {
746
+ if (id.endsWith(".css")) return {
747
+ code: "",
748
+ moduleType: "js"
749
+ };
750
+ } }
751
+ };
744
752
  }
745
753
  function vxrnCompilerPlugin(platform, dev, projectRoot = process.cwd(), sourceMaps = false) {
746
- let compiler = null;
747
- const isRefreshCandidate = id => dev && !id.includes("node_modules") && !id.includes("__virtual-native-entry") && /\.[tj]sx?$/.test(id);
748
- return {
749
- name: "vxrn:compiler",
750
- async transform(code, id) {
751
- if (!/\.[cm]?[jt]sx?$/.test(id)) return;
752
- if (id.includes("\0") || id.includes("virtual:")) return;
753
- const needsRefresh = isRefreshCandidate(id);
754
- if (!compiler) compiler = await import("@vxrn/compiler");
755
- const props = {
756
- id,
757
- code,
758
- projectRoot,
759
- development: dev,
760
- environment: platform,
761
- reactForRNVersion: "19"
762
- };
763
- let babelOptions = compiler.getBabelOptions(props);
764
- let curCode = code;
765
- const intermediateMaps = [];
766
- const isWorkletPlugin = entry => {
767
- if (!entry) return false;
768
- const name = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : null;
769
- return typeof name === "string" && (name.includes("react-native-worklets") || name.includes("react-native-reanimated"));
770
- };
771
- const workletEntry = babelOptions?.plugins?.find(isWorkletPlugin);
772
- const workletPluginOptions = Array.isArray(workletEntry) ? workletEntry[1] : void 0;
773
- const useWorklets = compiler.isNativeWorkletsEnabled() && (Boolean(workletEntry) || compiler.shouldTransformWorklets({
774
- id,
775
- code
776
- }));
777
- const compilerPluginIndex = babelOptions?.plugins?.findIndex(x => Array.isArray(x) && x[0] === "babel-plugin-react-compiler") ?? -1;
778
- if (compilerPluginIndex !== -1) {
779
- if (useWorklets) {
780
- const prepared = compiler.prepareWorkletsForReactCompiler(id, curCode, sourceMaps);
781
- if (prepared) {
782
- curCode = prepared.code;
783
- if (prepared.map) intermediateMaps.push(prepared.map);
784
- }
785
- }
786
- const compilerPluginOptions = babelOptions.plugins[compilerPluginIndex][1] || {};
787
- if (!(compilerPluginOptions.compiler === "babel" || process.env.ONE_REACT_COMPILER === "babel" || process.env.VXRN_REACT_COMPILER === "babel")) {
788
- const compilerOut = await compiler.transformOxcReactCompiler(id, curCode, compilerPluginOptions, sourceMaps);
789
- if (compilerOut?.code) {
790
- curCode = compilerOut.code;
791
- if (sourceMaps && compilerOut.map) intermediateMaps.push(compilerOut.map);
792
- }
793
- babelOptions.plugins.splice(compilerPluginIndex, 1);
794
- if (babelOptions.plugins.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) babelOptions = null;
795
- }
796
- }
797
- if (useWorklets) {
798
- const workletOut = await compiler.transformWorklets(id, curCode, sourceMaps, {
799
- projectRoot,
800
- ...workletPluginOptions
801
- });
802
- if (workletOut?.code) {
803
- curCode = workletOut.code;
804
- if (sourceMaps && workletOut.map) intermediateMaps.push(workletOut.map);
805
- }
806
- if (babelOptions?.plugins) {
807
- babelOptions.plugins = babelOptions.plugins.filter(entry => !isWorkletPlugin(entry));
808
- if (babelOptions.plugins.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) babelOptions = null;
809
- }
810
- }
811
- if (!babelOptions && !needsRefresh) {
812
- if (curCode !== code) {
813
- let finalMap = void 0;
814
- if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap = intermediateMaps[0];else {
815
- const remapping = (await import("@jridgewell/remapping")).default;
816
- finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
817
- }
818
- return {
819
- code: curCode,
820
- map: finalMap
821
- };
822
- }
823
- return;
824
- }
825
- if (sourceMaps && babelOptions) {
826
- babelOptions = {
827
- ...babelOptions,
828
- sourceMaps: true,
829
- sourceFileName: id
830
- };
831
- delete babelOptions.inputSourceMap;
832
- }
833
- if (babelOptions) {
834
- const result = await compiler.transformBabel(id, curCode, babelOptions);
835
- if (result?.code) {
836
- curCode = result.code;
837
- if (sourceMaps && result.map) intermediateMaps.push(result.map);
838
- if (!needsRefresh) {
839
- let finalMap = void 0;
840
- if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap = intermediateMaps[0];else {
841
- const remapping = (await import("@jridgewell/remapping")).default;
842
- finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
843
- }
844
- return {
845
- code: curCode,
846
- map: finalMap
847
- };
848
- }
849
- }
850
- }
851
- if (needsRefresh) {
852
- const {
853
- transformSync
854
- } = await import("oxc-transform-react");
855
- const jsxImportSource = compiler.configuration?.enableNativewind && !id.includes("node_modules") ? "nativewind" : "react";
856
- const res = transformSync(id, curCode, {
857
- jsx: {
858
- development: dev,
859
- runtime: "automatic",
860
- importSource: jsxImportSource,
861
- refresh: {
862
- refreshReg: "__vxrnRefreshReg",
863
- refreshSig: "__vxrnRefreshSig"
864
- }
865
- },
866
- reactCompiler: false,
867
- sourcemap: sourceMaps
868
- });
869
- if (res.fatal) throw new Error(`[vxrn:compiler] oxc react transform failed on ${id}: ${(res.errors ?? []).map(e => e.message ?? String(e)).join(", ")}`);
870
- const header = `var __prevRefreshReg = globalThis.$RefreshReg$;
754
+ let compiler = null;
755
+ const isRefreshCandidate = (id) => dev && !id.includes("node_modules") && !id.includes("__virtual-native-entry") && /\.[tj]sx?$/.test(id);
756
+ return {
757
+ name: "vxrn:compiler",
758
+ async transform(code, id) {
759
+ if (!/\.[cm]?[jt]sx?$/.test(id)) return;
760
+ if (id.includes("\0") || id.includes("virtual:")) return;
761
+ const needsRefresh = isRefreshCandidate(id);
762
+ if (!compiler) compiler = await import("@vxrn/compiler");
763
+ const props = {
764
+ id,
765
+ code,
766
+ projectRoot,
767
+ development: dev,
768
+ environment: platform,
769
+ reactForRNVersion: "19"
770
+ };
771
+ let babelOptions = compiler.getBabelOptions(props);
772
+ let curCode = code;
773
+ const intermediateMaps = [];
774
+ const isWorkletPlugin = (entry) => {
775
+ if (!entry) return false;
776
+ const name = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : null;
777
+ return typeof name === "string" && (name.includes("react-native-worklets") || name.includes("react-native-reanimated"));
778
+ };
779
+ const workletEntry = babelOptions?.plugins?.find(isWorkletPlugin);
780
+ const workletPluginOptions = Array.isArray(workletEntry) ? workletEntry[1] : void 0;
781
+ const useWorklets = compiler.isNativeWorkletsEnabled() && (Boolean(workletEntry) || compiler.shouldTransformWorklets({
782
+ id,
783
+ code
784
+ }));
785
+ const compilerPluginIndex = babelOptions?.plugins?.findIndex((x) => Array.isArray(x) && x[0] === "babel-plugin-react-compiler") ?? -1;
786
+ if (compilerPluginIndex !== -1) {
787
+ if (useWorklets) {
788
+ const prepared = compiler.prepareWorkletsForReactCompiler(id, curCode, sourceMaps);
789
+ if (prepared) {
790
+ curCode = prepared.code;
791
+ if (prepared.map) intermediateMaps.push(prepared.map);
792
+ }
793
+ }
794
+ const compilerPluginOptions = babelOptions.plugins[compilerPluginIndex][1] || {};
795
+ if (!(compilerPluginOptions.compiler === "babel" || process.env.ONE_REACT_COMPILER === "babel" || process.env.VXRN_REACT_COMPILER === "babel")) {
796
+ const compilerOut = await compiler.transformOxcReactCompiler(id, curCode, compilerPluginOptions, sourceMaps);
797
+ if (compilerOut?.code) {
798
+ curCode = compilerOut.code;
799
+ if (sourceMaps && compilerOut.map) intermediateMaps.push(compilerOut.map);
800
+ }
801
+ babelOptions.plugins.splice(compilerPluginIndex, 1);
802
+ if (babelOptions.plugins.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) babelOptions = null;
803
+ }
804
+ }
805
+ if (useWorklets) {
806
+ const workletOut = await compiler.transformWorklets(id, curCode, sourceMaps, {
807
+ projectRoot,
808
+ ...workletPluginOptions
809
+ });
810
+ if (workletOut?.code) {
811
+ curCode = workletOut.code;
812
+ if (sourceMaps && workletOut.map) intermediateMaps.push(workletOut.map);
813
+ }
814
+ if (babelOptions?.plugins) {
815
+ babelOptions.plugins = babelOptions.plugins.filter((entry) => !isWorkletPlugin(entry));
816
+ if (babelOptions.plugins.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) babelOptions = null;
817
+ }
818
+ }
819
+ if (!babelOptions && !needsRefresh) {
820
+ if (curCode !== code) {
821
+ let finalMap = void 0;
822
+ if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap = intermediateMaps[0];
823
+ else {
824
+ const remapping = (await import("@jridgewell/remapping")).default;
825
+ finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
826
+ }
827
+ return {
828
+ code: curCode,
829
+ map: finalMap
830
+ };
831
+ }
832
+ return;
833
+ }
834
+ if (sourceMaps && babelOptions) {
835
+ babelOptions = {
836
+ ...babelOptions,
837
+ sourceMaps: true,
838
+ sourceFileName: id
839
+ };
840
+ delete babelOptions.inputSourceMap;
841
+ }
842
+ if (babelOptions) {
843
+ const result = await compiler.transformBabel(id, curCode, babelOptions);
844
+ if (result?.code) {
845
+ curCode = result.code;
846
+ if (sourceMaps && result.map) intermediateMaps.push(result.map);
847
+ if (!needsRefresh) {
848
+ let finalMap = void 0;
849
+ if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap = intermediateMaps[0];
850
+ else {
851
+ const remapping = (await import("@jridgewell/remapping")).default;
852
+ finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
853
+ }
854
+ return {
855
+ code: curCode,
856
+ map: finalMap
857
+ };
858
+ }
859
+ }
860
+ }
861
+ if (needsRefresh) {
862
+ const { transformSync } = await import("oxc-transform-react");
863
+ const jsxImportSource = compiler.configuration?.enableNativewind && !id.includes("node_modules") ? "nativewind" : "react";
864
+ const res = transformSync(id, curCode, {
865
+ jsx: {
866
+ development: dev,
867
+ runtime: "automatic",
868
+ importSource: jsxImportSource,
869
+ refresh: {
870
+ refreshReg: "__vxrnRefreshReg",
871
+ refreshSig: "__vxrnRefreshSig"
872
+ }
873
+ },
874
+ reactCompiler: false,
875
+ sourcemap: sourceMaps
876
+ });
877
+ if (res.fatal) throw new Error(`[vxrn:compiler] oxc react transform failed on ${id}: ${(res.errors ?? []).map((e) => e.message ?? String(e)).join(", ")}`);
878
+ const header = `var __prevRefreshReg = globalThis.$RefreshReg$;
871
879
  var __prevRefreshSig = globalThis.$RefreshSig$;
872
880
  if (globalThis.__ReactRefresh) {
873
881
  globalThis.$RefreshReg$ = function(type, id) {
@@ -880,7 +888,7 @@ var __vxrnRefreshReg = globalThis.$RefreshReg$;
880
888
  var __vxrnRefreshSig = globalThis.$RefreshSig$;
881
889
 
882
890
  `;
883
- const footer = `
891
+ const footer = `
884
892
 
885
893
  globalThis.$RefreshReg$ = __prevRefreshReg;
886
894
  globalThis.$RefreshSig$ = __prevRefreshSig;
@@ -892,251 +900,268 @@ if (import.meta.hot) {
892
900
  });
893
901
  }
894
902
  `;
895
- let out;
896
- let finalMap = void 0;
897
- if (sourceMaps) {
898
- const MagicString = (await import("magic-string")).default;
899
- const ms = new MagicString(res.code);
900
- ms.prepend(header);
901
- ms.append(footer);
902
- out = ms.toString();
903
- const allMaps = [ms.generateMap({
904
- source: id,
905
- hires: true
906
- }), res.map, ...intermediateMaps.slice().reverse()].filter(Boolean);
907
- const remapping = (await import("@jridgewell/remapping")).default;
908
- finalMap = remapping(allMaps, () => null);
909
- } else out = header + res.code + footer;
910
- return {
911
- code: out,
912
- map: finalMap
913
- };
914
- }
915
- }
916
- };
903
+ let out;
904
+ let finalMap = void 0;
905
+ if (sourceMaps) {
906
+ const MagicString = (await import("magic-string")).default;
907
+ const ms = new MagicString(res.code);
908
+ ms.prepend(header);
909
+ ms.append(footer);
910
+ out = ms.toString();
911
+ const allMaps = [
912
+ ms.generateMap({
913
+ source: id,
914
+ hires: true
915
+ }),
916
+ res.map,
917
+ ...intermediateMaps.slice().reverse()
918
+ ].filter(Boolean);
919
+ const remapping = (await import("@jridgewell/remapping")).default;
920
+ finalMap = remapping(allMaps, () => null);
921
+ } else out = header + res.code + footer;
922
+ return {
923
+ code: out,
924
+ map: finalMap
925
+ };
926
+ }
927
+ }
928
+ };
917
929
  }
918
930
  function flowStripPlugin() {
919
- return {
920
- name: "vxrn:flow-strip",
921
- transform: {
922
- async handler(code, id) {
923
- if (!shouldStripFlow(id, code)) return;
924
- const result = await (await import("fast-flow-transform")).default({
925
- filename: id,
926
- source: code,
927
- sourcemap: true,
928
- dialect: "flow",
929
- format: "pretty"
930
- });
931
- return {
932
- code: result.code,
933
- map: result.map
934
- };
935
- }
936
- }
937
- };
931
+ return {
932
+ name: "vxrn:flow-strip",
933
+ transform: { async handler(code, id) {
934
+ if (!shouldStripFlow(id, code)) return;
935
+ const { stripFlowTypes } = await import("@vxrn/compiler");
936
+ const result = await stripFlowTypes(id, code);
937
+ return {
938
+ code: result.code,
939
+ map: result.map
940
+ };
941
+ } }
942
+ };
938
943
  }
939
944
  function assetPlugin(opts) {
940
- const assetRegex = new RegExp(`\\.(?:${DEFAULT_ASSET_EXTS.join("|")})$`);
941
- return {
942
- name: "vxrn:asset",
943
- load: {
944
- async handler(id) {
945
- if (!assetRegex.test(id)) return;
946
- const assetData = await getNativeAssetData(id, opts.root, opts.platform);
947
- opts.onAsset?.(assetData);
948
- if (opts.assetsDest) copyNativeAssetFiles(assetData, opts.assetsDest, opts.platform);
949
- return {
950
- code: `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`,
951
- moduleType: "js"
952
- };
953
- }
954
- }
955
- };
945
+ const assetRegex = new RegExp(`\\.(?:${DEFAULT_ASSET_EXTS.join("|")})$`);
946
+ return {
947
+ name: "vxrn:asset",
948
+ load: { async handler(id) {
949
+ if (!assetRegex.test(id)) return;
950
+ const assetData = await getNativeAssetData(id, opts.root, opts.platform);
951
+ opts.onAsset?.(assetData);
952
+ if (opts.assetsDest) copyNativeAssetFiles(assetData, opts.assetsDest, opts.platform);
953
+ return {
954
+ code: `module.exports = require('react-native/asset-registry').registerAsset(${JSON.stringify(assetData)});`,
955
+ moduleType: "js"
956
+ };
957
+ } }
958
+ };
956
959
  }
957
960
  function createNativeDevAssetRegistry() {
958
- const assets = /* @__PURE__ */new Map();
959
- return {
960
- register(asset) {
961
- for (const [index, scale] of asset.scales.entries()) {
962
- const filePath = asset.files[index];
963
- if (!filePath) continue;
964
- const fileName = `${asset.name}${scale === 1 ? "" : `@${scale}x`}.${asset.type}`;
965
- assets.set(`${asset.httpServerLocation}/${fileName}`, {
966
- filePath,
967
- hash: asset.hash,
968
- type: asset.type
969
- });
970
- }
971
- },
972
- resolve(pathname, hash) {
973
- const asset = assets.get(pathname);
974
- if (!asset || hash !== void 0 && hash !== asset.hash) return;
975
- return asset;
976
- }
977
- };
961
+ const assets = /* @__PURE__ */ new Map();
962
+ return {
963
+ register(asset) {
964
+ for (const [index, scale] of asset.scales.entries()) {
965
+ const filePath = asset.files[index];
966
+ if (!filePath) continue;
967
+ const fileName = `${asset.name}${scale === 1 ? "" : `@${scale}x`}.${asset.type}`;
968
+ assets.set(`${asset.httpServerLocation}/${fileName}`, {
969
+ filePath,
970
+ hash: asset.hash,
971
+ type: asset.type
972
+ });
973
+ }
974
+ },
975
+ resolve(pathname, hash) {
976
+ const asset = assets.get(pathname);
977
+ if (!asset || hash !== void 0 && hash !== asset.hash) return;
978
+ return asset;
979
+ }
980
+ };
978
981
  }
979
- const NATIVE_IMAGE_EXTS = /* @__PURE__ */new Set(["png", "jpg", "jpeg", "gif", "webp", "bmp", "psd", "svg", "tiff", "ktx"]);
982
+ const NATIVE_IMAGE_EXTS = /* @__PURE__ */ new Set([
983
+ "png",
984
+ "jpg",
985
+ "jpeg",
986
+ "gif",
987
+ "webp",
988
+ "bmp",
989
+ "psd",
990
+ "svg",
991
+ "tiff",
992
+ "ktx"
993
+ ]);
980
994
  function parseNativeAssetName(filePath) {
981
- const type = extname(filePath).slice(1);
982
- if (!type) return;
983
- const stem = basename(filePath, `.${type}`);
984
- const platformMatch = stem.match(/^(.*)\.(ios|android)$/);
985
- const platform = platformMatch?.[2];
986
- const scaleMatch = (platformMatch?.[1] ?? stem).match(/^(.+?)(?:@([\d.]+)x)?$/);
987
- if (!scaleMatch) return;
988
- const scale = scaleMatch[2] === void 0 ? 1 : Number.parseFloat(scaleMatch[2]);
989
- if (!Number.isFinite(scale) || scale <= 0) return;
990
- return {
991
- name: scaleMatch[1],
992
- scale,
993
- platform,
994
- type
995
- };
995
+ const type = extname(filePath).slice(1);
996
+ if (!type) return;
997
+ const stem = basename(filePath, `.${type}`);
998
+ const platformMatch = stem.match(/^(.*)\.(ios|android)$/);
999
+ const platform = platformMatch?.[2];
1000
+ const scaleMatch = (platformMatch?.[1] ?? stem).match(/^(.+?)(?:@([\d.]+)x)?$/);
1001
+ if (!scaleMatch) return;
1002
+ const scale = scaleMatch[2] === void 0 ? 1 : Number.parseFloat(scaleMatch[2]);
1003
+ if (!Number.isFinite(scale) || scale <= 0) return;
1004
+ return {
1005
+ name: scaleMatch[1],
1006
+ scale,
1007
+ platform,
1008
+ type
1009
+ };
996
1010
  }
997
1011
  function getNativeAssetUrlDirectory(root, assetDirectory) {
998
- const safeDirectory = relative(realpathSync(root), realpathSync(assetDirectory)).replace(/\\/g, "/").split("/").filter(segment => segment && segment !== ".").map(segment => segment === ".." ? "_" : segment).join("/");
999
- return safeDirectory ? `/assets/${safeDirectory}` : "/assets";
1012
+ const safeDirectory = relative(realpathSync(root), realpathSync(assetDirectory)).replace(/\\/g, "/").split("/").filter((segment) => segment && segment !== ".").map((segment) => segment === ".." ? "_" : segment).join("/");
1013
+ return safeDirectory ? `/assets/${safeDirectory}` : "/assets";
1000
1014
  }
1001
1015
  async function getNativeAssetData(id, root, platform) {
1002
- const requested = parseNativeAssetName(id);
1003
- if (!requested) throw new Error(`[vxrn] invalid native asset path: ${id}`);
1004
- const assetDirectory = dirname(id);
1005
- const filesByScale = /* @__PURE__ */new Map();
1006
- for (const fileName of readdirSync(assetDirectory)) {
1007
- const candidate = parseNativeAssetName(fileName);
1008
- if (!candidate || candidate.name !== requested.name || candidate.type !== requested.type || candidate.platform !== void 0 && candidate.platform !== platform) continue;
1009
- const platformSpecific = candidate.platform === platform;
1010
- const existing = filesByScale.get(candidate.scale);
1011
- if (!existing || platformSpecific && !existing.platformSpecific) filesByScale.set(candidate.scale, {
1012
- file: join(assetDirectory, fileName),
1013
- platformSpecific
1014
- });
1015
- }
1016
- const scales = [...filesByScale.keys()].sort((a, b) => a - b);
1017
- const files = scales.map(scale => filesByScale.get(scale).file);
1018
- if (files.length === 0) throw new Error(`[vxrn] native asset has no files for ${platform}: ${id}`);
1019
- const hash = createHash("md5");
1020
- for (const file of files) hash.update(readFileSync(file));
1021
- const assetData = {
1022
- __packager_asset: true,
1023
- name: requested.name,
1024
- type: requested.type,
1025
- scales,
1026
- files,
1027
- httpServerLocation: getNativeAssetUrlDirectory(root, assetDirectory),
1028
- fileSystemLocation: assetDirectory,
1029
- hash: hash.digest("hex")
1030
- };
1031
- if (NATIVE_IMAGE_EXTS.has(requested.type)) try {
1032
- const {
1033
- imageSize
1034
- } = await import("image-size");
1035
- const dims = imageSize(files[0]);
1036
- assetData.width = dims.width === void 0 ? void 0 : dims.width / scales[0];
1037
- assetData.height = dims.height === void 0 ? void 0 : dims.height / scales[0];
1038
- } catch {}
1039
- return assetData;
1016
+ const requested = parseNativeAssetName(id);
1017
+ if (!requested) throw new Error(`[vxrn] invalid native asset path: ${id}`);
1018
+ const assetDirectory = dirname(id);
1019
+ const filesByScale = /* @__PURE__ */ new Map();
1020
+ for (const fileName of readdirSync(assetDirectory)) {
1021
+ const candidate = parseNativeAssetName(fileName);
1022
+ if (!candidate || candidate.name !== requested.name || candidate.type !== requested.type || candidate.platform !== void 0 && candidate.platform !== platform) continue;
1023
+ const platformSpecific = candidate.platform === platform;
1024
+ const existing = filesByScale.get(candidate.scale);
1025
+ if (!existing || platformSpecific && !existing.platformSpecific) filesByScale.set(candidate.scale, {
1026
+ file: join(assetDirectory, fileName),
1027
+ platformSpecific
1028
+ });
1029
+ }
1030
+ const scales = [...filesByScale.keys()].sort((a, b) => a - b);
1031
+ const files = scales.map((scale) => filesByScale.get(scale).file);
1032
+ if (files.length === 0) throw new Error(`[vxrn] native asset has no files for ${platform}: ${id}`);
1033
+ const hash = createHash("md5");
1034
+ for (const file of files) hash.update(readFileSync(file));
1035
+ const assetData = {
1036
+ __packager_asset: true,
1037
+ name: requested.name,
1038
+ type: requested.type,
1039
+ scales,
1040
+ files,
1041
+ httpServerLocation: getNativeAssetUrlDirectory(root, assetDirectory),
1042
+ fileSystemLocation: assetDirectory,
1043
+ hash: hash.digest("hex")
1044
+ };
1045
+ if (NATIVE_IMAGE_EXTS.has(requested.type)) try {
1046
+ const { imageSize } = await import("image-size");
1047
+ const dims = imageSize(files[0]);
1048
+ assetData.width = dims.width === void 0 ? void 0 : dims.width / scales[0];
1049
+ assetData.height = dims.height === void 0 ? void 0 : dims.height / scales[0];
1050
+ } catch {}
1051
+ return assetData;
1040
1052
  }
1041
1053
  function getIOSAssetScales(scales) {
1042
- const supported = scales.filter(scale => scale === 1 || scale === 2 || scale === 3);
1043
- if (supported.length > 0 || scales.length === 0) return supported;
1044
- return [scales.find(scale => scale > 3) ?? scales[scales.length - 1]];
1054
+ const supported = scales.filter((scale) => scale === 1 || scale === 2 || scale === 3);
1055
+ if (supported.length > 0 || scales.length === 0) return supported;
1056
+ return [scales.find((scale) => scale > 3) ?? scales[scales.length - 1]];
1045
1057
  }
1046
1058
  function getAndroidAssetDirectory(type, scale) {
1047
- if (!(/* @__PURE__ */new Set(["gif", "heic", "heif", "jpeg", "jpg", "ktx", "png", "webp", "xml"])).has(type)) return "raw";
1048
- const density = (/* @__PURE__ */new Map([[.75, "ldpi"], [1, "mdpi"], [1.5, "hdpi"], [2, "xhdpi"], [3, "xxhdpi"], [4, "xxxhdpi"]])).get(scale);
1049
- if (density) return `drawable-${density}`;
1050
- return `drawable-${Math.round(scale * 160)}dpi`;
1059
+ if (!(/* @__PURE__ */ new Set([
1060
+ "gif",
1061
+ "heic",
1062
+ "heif",
1063
+ "jpeg",
1064
+ "jpg",
1065
+ "ktx",
1066
+ "png",
1067
+ "webp",
1068
+ "xml"
1069
+ ])).has(type)) return "raw";
1070
+ const density = (/* @__PURE__ */ new Map([
1071
+ [.75, "ldpi"],
1072
+ [1, "mdpi"],
1073
+ [1.5, "hdpi"],
1074
+ [2, "xhdpi"],
1075
+ [3, "xxhdpi"],
1076
+ [4, "xxxhdpi"]
1077
+ ])).get(scale);
1078
+ if (density) return `drawable-${density}`;
1079
+ return `drawable-${Math.round(scale * 160)}dpi`;
1051
1080
  }
1052
1081
  function getAndroidAssetName(asset) {
1053
- return `${asset.httpServerLocation}/${asset.name}`.toLowerCase().replace(/^\//, "").replace(/\//g, "_").replace(/([^a-z0-9_])/g, "").replace(/^assets_/, "");
1082
+ return `${asset.httpServerLocation}/${asset.name}`.toLowerCase().replace(/^\//, "").replace(/\//g, "_").replace(/([^a-z0-9_])/g, "").replace(/^assets_/, "");
1054
1083
  }
1055
1084
  function copyNativeAssetFiles(asset, assetsDest, platform) {
1056
- const validIOSScales = new Set(getIOSAssetScales(asset.scales));
1057
- for (const [index, scale] of asset.scales.entries()) {
1058
- if (platform === "ios" && !validIOSScales.has(scale)) continue;
1059
- const destination = platform === "android" ? join(assetsDest, getAndroidAssetDirectory(asset.type, scale), `${getAndroidAssetName(asset)}.${asset.type}`) : join(assetsDest, asset.httpServerLocation.slice(1), `${asset.name}${scale === 1 ? "" : `@${scale}x`}.${asset.type}`);
1060
- mkdirSync(dirname(destination), {
1061
- recursive: true
1062
- });
1063
- copyFileSync(asset.files[index], destination);
1064
- }
1085
+ const validIOSScales = new Set(getIOSAssetScales(asset.scales));
1086
+ for (const [index, scale] of asset.scales.entries()) {
1087
+ if (platform === "ios" && !validIOSScales.has(scale)) continue;
1088
+ const destination = platform === "android" ? join(assetsDest, getAndroidAssetDirectory(asset.type, scale), `${getAndroidAssetName(asset)}.${asset.type}`) : join(assetsDest, asset.httpServerLocation.slice(1), `${asset.name}${scale === 1 ? "" : `@${scale}x`}.${asset.type}`);
1089
+ mkdirSync(dirname(destination), { recursive: true });
1090
+ copyFileSync(asset.files[index], destination);
1091
+ }
1065
1092
  }
1066
1093
  function hermesCompatSWCPlugin(dev, sourceMaps = false) {
1067
- let oxc = null;
1068
- return {
1069
- name: "vxrn:hermes-compat",
1070
- async transform(code, id) {
1071
- if (!/\.[cm]?[jt]sx?$/.test(id)) return;
1072
- if (id.includes("\0") || id.includes("virtual:")) return;
1073
- const hasClass = code.includes("class ") || code.includes("class{");
1074
- const hasAsync = code.includes("async");
1075
- const hasBlockScopedLoop = /\bfor\s*\(\s*(?:const|let)\b/.test(code);
1076
- if (!hasClass && !hasAsync && !hasBlockScopedLoop) return;
1077
- let output;
1078
- if (code.length <= 5e5) {
1079
- if (!oxc) oxc = await import("oxc-transform");
1080
- const lang = /\.[cm]?ts$/.test(id) ? "ts" : id.endsWith(".tsx") ? "tsx" : "jsx";
1081
- const result = oxc.transformSync(id, code, {
1082
- lang,
1083
- target: "es2020",
1084
- assumptions: {
1085
- setPublicClassFields: true
1086
- },
1087
- jsx: "preserve",
1088
- sourcemap: sourceMaps,
1089
- sourceType: id.endsWith(".cjs") ? "script" : "module"
1090
- });
1091
- if (result.errors?.length) {
1092
- const err = result.errors[0];
1093
- throw new Error(err.message + (err.codeframe ? `
1094
+ let oxc = null;
1095
+ return {
1096
+ name: "vxrn:hermes-compat",
1097
+ async transform(code, id) {
1098
+ if (!/\.[cm]?[jt]sx?$/.test(id)) return;
1099
+ if (id.includes("\0") || id.includes("virtual:")) return;
1100
+ const hasClass = code.includes("class ") || code.includes("class{");
1101
+ const hasAsync = code.includes("async");
1102
+ const hasBlockScopedLoop = /\bfor\s*\(\s*(?:const|let)\b/.test(code);
1103
+ if (!hasClass && !hasAsync && !hasBlockScopedLoop) return;
1104
+ let output;
1105
+ if (code.length <= 5e5) {
1106
+ if (!oxc) oxc = await import("oxc-transform");
1107
+ const lang = /\.[cm]?ts$/.test(id) ? "ts" : id.endsWith(".tsx") ? "tsx" : "jsx";
1108
+ const result = oxc.transformSync(id, code, {
1109
+ lang,
1110
+ target: "es2020",
1111
+ assumptions: { setPublicClassFields: true },
1112
+ jsx: "preserve",
1113
+ sourcemap: sourceMaps,
1114
+ sourceType: id.endsWith(".cjs") ? "script" : "module"
1115
+ });
1116
+ if (result.errors?.length) {
1117
+ const err = result.errors[0];
1118
+ throw new Error(err.message + (err.codeframe ? `
1094
1119
  ${err.codeframe}` : ""));
1095
- }
1096
- output = {
1097
- code: result.code,
1098
- map: sourceMaps ? result.map : void 0
1099
- };
1100
- }
1101
- const lowered = await transformHermesAsync(output?.code ?? code, id, sourceMaps);
1102
- if (!lowered) return output;
1103
- if (lowered.map && output?.map) {
1104
- const remapping = (await import("@jridgewell/remapping")).default;
1105
- lowered.map = remapping([lowered.map, output.map], () => null);
1106
- }
1107
- return lowered;
1108
- }
1109
- };
1120
+ }
1121
+ output = {
1122
+ code: result.code,
1123
+ map: sourceMaps ? result.map : void 0
1124
+ };
1125
+ }
1126
+ const lowered = await transformHermesAsync(output?.code ?? code, id, sourceMaps);
1127
+ if (!lowered) return output;
1128
+ if (lowered.map && output?.map) {
1129
+ const remapping = (await import("@jridgewell/remapping")).default;
1130
+ lowered.map = remapping([lowered.map, output.map], () => null);
1131
+ }
1132
+ return lowered;
1133
+ }
1134
+ };
1110
1135
  }
1111
1136
  const hermesCompatPlugin = hermesCompatSWCPlugin;
1112
1137
  function hermesLoopsPlugin(sourceMaps = false) {
1113
- let compiler = null;
1114
- return {
1115
- name: "vxrn:hermes-loops",
1116
- async transform(code, id) {
1117
- if (!/\.[cm]?[jt]sx?$/.test(id)) return;
1118
- if (id.includes("\0") || id.includes("virtual:")) return;
1119
- if (!compiler) compiler = await import("@vxrn/compiler");
1120
- const result = compiler.transformHermesLoops(code, id);
1121
- if (!result) return;
1122
- if (!sourceMaps) return {
1123
- code: result.code,
1124
- map: null
1125
- };
1126
- if (result.maps.length === 1) return {
1127
- code: result.code,
1128
- map: result.maps[0]
1129
- };
1130
- const remapping = (await import("@jridgewell/remapping")).default;
1131
- return {
1132
- code: result.code,
1133
- map: remapping(result.maps.slice().reverse(), () => null)
1134
- };
1135
- }
1136
- };
1138
+ let compiler = null;
1139
+ return {
1140
+ name: "vxrn:hermes-loops",
1141
+ async transform(code, id) {
1142
+ if (!/\.[cm]?[jt]sx?$/.test(id)) return;
1143
+ if (id.includes("\0") || id.includes("virtual:")) return;
1144
+ if (!compiler) compiler = await import("@vxrn/compiler");
1145
+ const result = compiler.transformHermesLoops(code, id);
1146
+ if (!result) return;
1147
+ if (!sourceMaps) return {
1148
+ code: result.code,
1149
+ map: null
1150
+ };
1151
+ if (result.maps.length === 1) return {
1152
+ code: result.code,
1153
+ map: result.maps[0]
1154
+ };
1155
+ const remapping = (await import("@jridgewell/remapping")).default;
1156
+ return {
1157
+ code: result.code,
1158
+ map: remapping(result.maps.slice().reverse(), () => null)
1159
+ };
1160
+ }
1161
+ };
1137
1162
  }
1138
1163
  function getHmrRuntimeSource() {
1139
- return `
1164
+ return `
1140
1165
  // vxrn HMR runtime for rolldown devMode
1141
1166
  var BaseDevRuntime = DevRuntime;
1142
1167
 
@@ -1373,5 +1398,6 @@ class ReactNativeDevRuntime extends BaseDevRuntime {
1373
1398
  globalThis.__rolldown_runtime__ = new ReactNativeDevRuntime();
1374
1399
  `;
1375
1400
  }
1401
+
1376
1402
  export { buildNativeBundle, createNativeDevAssetRegistry, createNativeDevEngine, getHermesSWCIncludes, getHmrRuntimeSource, getNativeAssetData, getNativeTransformConfig, hermesCompatPlugin, hermesCompatSWCPlugin, hermesLoopsPlugin, hmrClientNoopPlugin, nativeAnimatedGuardPlugin, normalizeNativeCommonJSInterop, postProcessNativeBundle, vxrnCompilerPlugin, wrapNativeBundleModuleScope };
1377
1403
  //# sourceMappingURL=createNativeDevEngine.mjs.map