vxrn 1.14.4 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/dist/cli.mjs +263 -248
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/cli.native.js +267 -252
  4. package/dist/cli.native.js.map +1 -1
  5. package/dist/config/getAdditionalViteConfig.mjs +8 -8
  6. package/dist/config/getAdditionalViteConfig.mjs.map +1 -1
  7. package/dist/config/getAdditionalViteConfig.native.js +8 -8
  8. package/dist/config/getAdditionalViteConfig.native.js.map +1 -1
  9. package/dist/config/getBaseViteConfigOnly.mjs +14 -12
  10. package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
  11. package/dist/config/getBaseViteConfigOnly.native.js +16 -14
  12. package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
  13. package/dist/config/getBaseVitePlugins.mjs +34 -19
  14. package/dist/config/getBaseVitePlugins.mjs.map +1 -1
  15. package/dist/config/getBaseVitePlugins.native.js +47 -32
  16. package/dist/config/getBaseVitePlugins.native.js.map +1 -1
  17. package/dist/config/getOptimizeDeps.mjs +12 -9
  18. package/dist/config/getOptimizeDeps.mjs.map +1 -1
  19. package/dist/config/getOptimizeDeps.native.js +12 -9
  20. package/dist/config/getOptimizeDeps.native.js.map +1 -1
  21. package/dist/config/getOptionsFilled.mjs +47 -41
  22. package/dist/config/getOptionsFilled.mjs.map +1 -1
  23. package/dist/config/getOptionsFilled.native.js +53 -50
  24. package/dist/config/getOptionsFilled.native.js.map +1 -1
  25. package/dist/config/getReactNativePlugins.mjs +5 -2
  26. package/dist/config/getReactNativePlugins.mjs.map +1 -1
  27. package/dist/config/getReactNativePlugins.native.js +8 -5
  28. package/dist/config/getReactNativePlugins.native.js.map +1 -1
  29. package/dist/config/getServerOptionsFilled.mjs +21 -14
  30. package/dist/config/getServerOptionsFilled.mjs.map +1 -1
  31. package/dist/config/getServerOptionsFilled.native.js +25 -21
  32. package/dist/config/getServerOptionsFilled.native.js.map +1 -1
  33. package/dist/config/getViteServerConfig.mjs +25 -16
  34. package/dist/config/getViteServerConfig.mjs.map +1 -1
  35. package/dist/config/getViteServerConfig.native.js +37 -28
  36. package/dist/config/getViteServerConfig.native.js.map +1 -1
  37. package/dist/config/mergeUserConfig.mjs +25 -7
  38. package/dist/config/mergeUserConfig.mjs.map +1 -1
  39. package/dist/config/mergeUserConfig.native.js +32 -14
  40. package/dist/config/mergeUserConfig.native.js.map +1 -1
  41. package/dist/config/mergeUserConfig.test.mjs +53 -26
  42. package/dist/config/mergeUserConfig.test.mjs.map +1 -1
  43. package/dist/config/mergeUserConfig.test.native.js +94 -74
  44. package/dist/config/mergeUserConfig.test.native.js.map +1 -1
  45. package/dist/constants.mjs +6 -6
  46. package/dist/constants.mjs.map +1 -1
  47. package/dist/constants.native.js +6 -6
  48. package/dist/constants.native.js.map +1 -1
  49. package/dist/exports/build.mjs +241 -191
  50. package/dist/exports/build.mjs.map +1 -1
  51. package/dist/exports/build.native.js +257 -221
  52. package/dist/exports/build.native.js.map +1 -1
  53. package/dist/exports/clean.mjs +17 -12
  54. package/dist/exports/clean.mjs.map +1 -1
  55. package/dist/exports/clean.native.js +22 -13
  56. package/dist/exports/clean.native.js.map +1 -1
  57. package/dist/exports/createServer.mjs +49 -35
  58. package/dist/exports/createServer.mjs.map +1 -1
  59. package/dist/exports/createServer.native.js +50 -34
  60. package/dist/exports/createServer.native.js.map +1 -1
  61. package/dist/exports/dev.mjs +119 -74
  62. package/dist/exports/dev.mjs.map +1 -1
  63. package/dist/exports/dev.native.js +131 -90
  64. package/dist/exports/dev.native.js.map +1 -1
  65. package/dist/exports/loadEnv.mjs +28 -19
  66. package/dist/exports/loadEnv.mjs.map +1 -1
  67. package/dist/exports/loadEnv.native.js +33 -28
  68. package/dist/exports/loadEnv.native.js.map +1 -1
  69. package/dist/exports/patch.mjs +4 -1
  70. package/dist/exports/patch.mjs.map +1 -1
  71. package/dist/exports/patch.native.js +4 -1
  72. package/dist/exports/patch.native.js.map +1 -1
  73. package/dist/exports/prebuild.mjs +106 -42
  74. package/dist/exports/prebuild.mjs.map +1 -1
  75. package/dist/exports/prebuild.native.js +116 -63
  76. package/dist/exports/prebuild.native.js.map +1 -1
  77. package/dist/exports/prebuildWithoutExpo.mjs +44 -39
  78. package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
  79. package/dist/exports/prebuildWithoutExpo.native.js +45 -42
  80. package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
  81. package/dist/exports/runAndroid.mjs +8 -5
  82. package/dist/exports/runAndroid.mjs.map +1 -1
  83. package/dist/exports/runAndroid.native.js +2 -1
  84. package/dist/exports/runAndroid.native.js.map +1 -1
  85. package/dist/exports/runIos.mjs +8 -5
  86. package/dist/exports/runIos.mjs.map +1 -1
  87. package/dist/exports/runIos.native.js +2 -1
  88. package/dist/exports/runIos.native.js.map +1 -1
  89. package/dist/exports/serve.mjs +14 -6
  90. package/dist/exports/serve.mjs.map +1 -1
  91. package/dist/exports/serve.native.js +21 -13
  92. package/dist/exports/serve.native.js.map +1 -1
  93. package/dist/exports/serveStaticAssets.mjs +37 -22
  94. package/dist/exports/serveStaticAssets.mjs.map +1 -1
  95. package/dist/exports/serveStaticAssets.native.js +65 -41
  96. package/dist/exports/serveStaticAssets.native.js.map +1 -1
  97. package/dist/patches/builtInDepPatches.mjs +145 -62
  98. package/dist/patches/builtInDepPatches.mjs.map +1 -1
  99. package/dist/patches/builtInDepPatches.native.js +116 -70
  100. package/dist/patches/builtInDepPatches.native.js.map +1 -1
  101. package/dist/plugins/autoDepOptimizePlugin.mjs +66 -42
  102. package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
  103. package/dist/plugins/autoDepOptimizePlugin.native.js +83 -63
  104. package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
  105. package/dist/plugins/autoDepOptimizePlugin.test.mjs +23 -17
  106. package/dist/plugins/autoDepOptimizePlugin.test.mjs.map +1 -1
  107. package/dist/plugins/autoDepOptimizePlugin.test.native.js +31 -27
  108. package/dist/plugins/autoDepOptimizePlugin.test.native.js.map +1 -1
  109. package/dist/plugins/defaultDepOptimizePlugin.mjs +6 -2
  110. package/dist/plugins/defaultDepOptimizePlugin.mjs.map +1 -1
  111. package/dist/plugins/defaultDepOptimizePlugin.native.js +6 -2
  112. package/dist/plugins/defaultDepOptimizePlugin.native.js.map +1 -1
  113. package/dist/plugins/expoManifestRequestHandlerPlugin.mjs +80 -36
  114. package/dist/plugins/expoManifestRequestHandlerPlugin.mjs.map +1 -1
  115. package/dist/plugins/expoManifestRequestHandlerPlugin.native.js +93 -46
  116. package/dist/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
  117. package/dist/plugins/getResolvedConfigSubset.mjs +3 -1
  118. package/dist/plugins/getResolvedConfigSubset.mjs.map +1 -1
  119. package/dist/plugins/getResolvedConfigSubset.native.js +3 -1
  120. package/dist/plugins/getResolvedConfigSubset.native.js.map +1 -1
  121. package/dist/plugins/reactNativeCommonJsPlugin.mjs +70 -46
  122. package/dist/plugins/reactNativeCommonJsPlugin.mjs.map +1 -1
  123. package/dist/plugins/reactNativeCommonJsPlugin.native.js +99 -68
  124. package/dist/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
  125. package/dist/plugins/reactNativeDevAssetPlugin.mjs +41 -27
  126. package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
  127. package/dist/plugins/reactNativeDevAssetPlugin.native.js +61 -48
  128. package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
  129. package/dist/plugins/reactNativeDevServer.mjs +126 -83
  130. package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
  131. package/dist/plugins/reactNativeDevServer.native.js +156 -107
  132. package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
  133. package/dist/plugins/resolveIdScan.test.mjs +22 -17
  134. package/dist/plugins/resolveIdScan.test.mjs.map +1 -1
  135. package/dist/plugins/resolveIdScan.test.native.js +25 -21
  136. package/dist/plugins/resolveIdScan.test.native.js.map +1 -1
  137. package/dist/plugins/serverExtensions.test.mjs +66 -38
  138. package/dist/plugins/serverExtensions.test.mjs.map +1 -1
  139. package/dist/plugins/serverExtensions.test.native.js +63 -49
  140. package/dist/plugins/serverExtensions.test.native.js.map +1 -1
  141. package/dist/rn-commands/bundle/buildBundle.mjs +48 -31
  142. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  143. package/dist/rn-commands/bundle/buildBundle.native.js +52 -35
  144. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  145. package/dist/runtime/hmr-client.mjs +59 -39
  146. package/dist/runtime/hmr-client.mjs.map +1 -1
  147. package/dist/runtime/hmr-client.native.js +132 -92
  148. package/dist/runtime/hmr-client.native.js.map +1 -1
  149. package/dist/runtime/hmr-runtime.mjs +65 -29
  150. package/dist/runtime/hmr-runtime.mjs.map +1 -1
  151. package/dist/runtime/hmr-runtime.native.js +361 -268
  152. package/dist/runtime/hmr-runtime.native.js.map +1 -1
  153. package/dist/runtime/react-refresh-utils.mjs +19 -9
  154. package/dist/runtime/react-refresh-utils.mjs.map +1 -1
  155. package/dist/runtime/react-refresh-utils.native.js +20 -10
  156. package/dist/runtime/react-refresh-utils.native.js.map +1 -1
  157. package/dist/serve/node.mjs +33 -19
  158. package/dist/serve/node.mjs.map +1 -1
  159. package/dist/serve/node.native.js +57 -39
  160. package/dist/serve/node.native.js.map +1 -1
  161. package/dist/user-interface/index.mjs +114 -61
  162. package/dist/user-interface/index.mjs.map +1 -1
  163. package/dist/user-interface/index.native.js +158 -111
  164. package/dist/user-interface/index.native.js.map +1 -1
  165. package/dist/utils/assert.mjs +6 -2
  166. package/dist/utils/assert.mjs.map +1 -1
  167. package/dist/utils/assert.native.js +12 -4
  168. package/dist/utils/assert.native.js.map +1 -1
  169. package/dist/utils/bindKeypressInput.mjs +38 -23
  170. package/dist/utils/bindKeypressInput.mjs.map +1 -1
  171. package/dist/utils/bindKeypressInput.native.js +38 -23
  172. package/dist/utils/bindKeypressInput.native.js.map +1 -1
  173. package/dist/utils/createNativeDevEngine.mjs +421 -319
  174. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  175. package/dist/utils/createNativeDevEngine.native.js +529 -425
  176. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  177. package/dist/utils/execSync.mjs +6 -4
  178. package/dist/utils/execSync.mjs.map +1 -1
  179. package/dist/utils/execSync.native.js.map +1 -1
  180. package/dist/utils/expoRun.mjs +5 -3
  181. package/dist/utils/expoRun.mjs.map +1 -1
  182. package/dist/utils/expoRun.native.js +13 -13
  183. package/dist/utils/expoRun.native.js.map +1 -1
  184. package/dist/utils/filterViteServerResolvedUrls.mjs +17 -5
  185. package/dist/utils/filterViteServerResolvedUrls.mjs.map +1 -1
  186. package/dist/utils/filterViteServerResolvedUrls.native.js +41 -23
  187. package/dist/utils/filterViteServerResolvedUrls.native.js.map +1 -1
  188. package/dist/utils/getServerEntry.mjs +6 -4
  189. package/dist/utils/getServerEntry.mjs.map +1 -1
  190. package/dist/utils/getServerEntry.native.js +9 -9
  191. package/dist/utils/getServerEntry.native.js.map +1 -1
  192. package/dist/utils/getVitePath.mjs +41 -17
  193. package/dist/utils/getVitePath.mjs.map +1 -1
  194. package/dist/utils/getVitePath.native.js +38 -16
  195. package/dist/utils/getVitePath.native.js.map +1 -1
  196. package/dist/utils/patches.mjs +143 -73
  197. package/dist/utils/patches.mjs.map +1 -1
  198. package/dist/utils/patches.native.js +299 -188
  199. package/dist/utils/patches.native.js.map +1 -1
  200. package/dist/utils/patches.test.mjs +106 -69
  201. package/dist/utils/patches.test.mjs.map +1 -1
  202. package/dist/utils/patches.test.native.js +100 -75
  203. package/dist/utils/patches.test.native.js.map +1 -1
  204. package/dist/utils/printServerUrls.mjs +6 -2
  205. package/dist/utils/printServerUrls.mjs.map +1 -1
  206. package/dist/utils/printServerUrls.native.js +28 -18
  207. package/dist/utils/printServerUrls.native.js.map +1 -1
  208. package/dist/utils/removeUndefined.mjs +5 -1
  209. package/dist/utils/removeUndefined.mjs.map +1 -1
  210. package/dist/utils/removeUndefined.native.js +5 -1
  211. package/dist/utils/removeUndefined.native.js.map +1 -1
  212. package/dist/utils/scanDepsToOptimize.mjs +131 -87
  213. package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
  214. package/dist/utils/scanDepsToOptimize.native.js +163 -117
  215. package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
  216. package/dist/utils/state.mjs +4 -2
  217. package/dist/utils/state.mjs.map +1 -1
  218. package/dist/utils/state.native.js +3 -2
  219. package/dist/utils/state.native.js.map +1 -1
  220. package/dist/utils/utils.mjs +4 -3
  221. package/dist/utils/utils.mjs.map +1 -1
  222. package/dist/utils/utils.native.js +22 -16
  223. package/dist/utils/utils.native.js.map +1 -1
  224. package/dist/vendor/debugger-app/src/index.css +1 -1
  225. package/dist/vendor/debugger-app/src/index.css.map +1 -1
  226. package/dist/vxrn-vite-plugin.mjs +10 -6
  227. package/dist/vxrn-vite-plugin.mjs.map +1 -1
  228. package/dist/vxrn-vite-plugin.native.js +25 -21
  229. package/dist/vxrn-vite-plugin.native.js.map +1 -1
  230. package/package.json +12 -12
  231. package/src/plugins/reactNativeDevServer.ts +0 -6
  232. package/src/utils/createNativeDevEngine.ts +55 -1
  233. package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
  234. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
@@ -4,9 +4,9 @@ import { DEFAULT_ASSET_EXTS } from "../constants/defaults.mjs";
4
4
  import { getNativePrelude } from "../runtime/native-prelude.mjs";
5
5
  const FLOW_FILE_PATTERN = /node_modules[\\/](?:react-native|@react-native)[\\/].*\.js$/;
6
6
  function getResolveExtensions(platform) {
7
- const platformExts = platform === "ios" ? [".ios.tsx", ".ios.ts", ".ios.jsx", ".ios.js"] : [".android.tsx", ".android.ts", ".android.jsx", ".android.js"],
8
- nativeExts = [".native.tsx", ".native.ts", ".native.jsx", ".native.js"],
9
- defaultExts = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs", ".json"];
7
+ const platformExts = platform === "ios" ? [".ios.tsx", ".ios.ts", ".ios.jsx", ".ios.js"] : [".android.tsx", ".android.ts", ".android.jsx", ".android.js"];
8
+ const nativeExts = [".native.tsx", ".native.ts", ".native.jsx", ".native.js"];
9
+ const defaultExts = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs", ".json"];
10
10
  return [...platformExts, ...nativeExts, ...defaultExts];
11
11
  }
12
12
  function getNativeResolveConfig(platform) {
@@ -17,73 +17,75 @@ function getNativeResolveConfig(platform) {
17
17
  };
18
18
  }
19
19
  function getNativeTransformConfig(platform, dev, root) {
20
- const entryConfig = globalThis.__vxrnNativeEntryConfig || {},
21
- setupFileDefines = (() => {
22
- const sf = entryConfig.setupFile;
23
- if (!sf) return {};
24
- const files = typeof sf == "string" ? {
25
- client: sf,
26
- server: sf,
27
- ios: sf,
28
- android: sf
29
- } : "native" in sf ? {
30
- client: sf.client,
31
- server: sf.server,
32
- ios: sf.native,
33
- android: sf.native
34
- } : sf;
35
- return {
36
- ...(files.client && {
37
- "process.env.ONE_SETUP_FILE_CLIENT": JSON.stringify(files.client)
38
- }),
39
- ...(files.server && {
40
- "process.env.ONE_SETUP_FILE_SERVER": JSON.stringify(files.server)
41
- }),
42
- ...(files.ios && {
43
- "process.env.ONE_SETUP_FILE_IOS": JSON.stringify(files.ios)
44
- }),
45
- ...(files.android && {
46
- "process.env.ONE_SETUP_FILE_ANDROID": JSON.stringify(files.android)
47
- })
48
- };
49
- })(),
50
- envDefines = (() => {
51
- const defines = {};
52
- try {
53
- const mode2 = dev ? "development" : "production";
54
- for (const envFile of [".env", ".env.local", `.env.${mode2}`, `.env.${mode2}.local`]) {
55
- const envPath = join(root, envFile);
56
- if (!existsSync(envPath)) continue;
57
- const content = readFileSync(envPath, "utf8");
58
- for (const line of content.split(`
59
- `)) {
60
- const match = line.match(/^\s*(VITE_\w+)\s*=\s*(.*)$/);
61
- if (match) {
62
- const [, key, rawVal] = match,
63
- val = rawVal.replace(/^['"]|['"]$/g, "").trim();
64
- defines[`import.meta.env.${key}`] = JSON.stringify(val), defines[`process.env.${key}`] = JSON.stringify(val);
65
- }
20
+ const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
21
+ const setupFileDefines = (() => {
22
+ const sf = entryConfig.setupFile;
23
+ if (!sf) return {};
24
+ const files = typeof sf === "string" ? {
25
+ client: sf,
26
+ server: sf,
27
+ ios: sf,
28
+ android: sf
29
+ } : "native" in sf ? {
30
+ client: sf.client,
31
+ server: sf.server,
32
+ ios: sf.native,
33
+ android: sf.native
34
+ } : sf;
35
+ return {
36
+ ...(files.client && {
37
+ "process.env.ONE_SETUP_FILE_CLIENT": JSON.stringify(files.client)
38
+ }),
39
+ ...(files.server && {
40
+ "process.env.ONE_SETUP_FILE_SERVER": JSON.stringify(files.server)
41
+ }),
42
+ ...(files.ios && {
43
+ "process.env.ONE_SETUP_FILE_IOS": JSON.stringify(files.ios)
44
+ }),
45
+ ...(files.android && {
46
+ "process.env.ONE_SETUP_FILE_ANDROID": JSON.stringify(files.android)
47
+ })
48
+ };
49
+ })();
50
+ const envDefines = (() => {
51
+ const defines = {};
52
+ try {
53
+ const mode2 = dev ? "development" : "production";
54
+ for (const envFile of [".env", ".env.local", `.env.${mode2}`, `.env.${mode2}.local`]) {
55
+ const envPath = join(root, envFile);
56
+ if (!existsSync(envPath)) continue;
57
+ const content = readFileSync(envPath, "utf8");
58
+ for (const line of content.split("\n")) {
59
+ const match = line.match(/^\s*(VITE_\w+)\s*=\s*(.*)$/);
60
+ if (match) {
61
+ const [, key, rawVal] = match;
62
+ const val = rawVal.replace(/^['"]|['"]$/g, "").trim();
63
+ defines[`import.meta.env.${key}`] = JSON.stringify(val);
64
+ defines[`process.env.${key}`] = JSON.stringify(val);
66
65
  }
67
66
  }
68
- } catch {}
69
- return defines;
70
- })(),
71
- mode = dev ? "development" : "production",
72
- envObject = {
73
- MODE: mode,
74
- DEV: dev,
75
- PROD: !dev,
76
- SSR: !1,
77
- VITE_ENVIRONMENT: platform,
78
- VITE_NATIVE: "1",
79
- EXPO_OS: platform
80
- };
67
+ }
68
+ } catch {}
69
+ return defines;
70
+ })();
71
+ const mode = dev ? "development" : "production";
72
+ const envObject = {
73
+ MODE: mode,
74
+ DEV: dev,
75
+ PROD: !dev,
76
+ SSR: false,
77
+ VITE_ENVIRONMENT: platform,
78
+ VITE_NATIVE: "1",
79
+ EXPO_OS: platform
80
+ };
81
81
  for (const [key, val] of Object.entries(envDefines)) {
82
82
  const match = key.match(/^import\.meta\.env\.(.+)$/);
83
- if (match) try {
84
- envObject[match[1]] = JSON.parse(val);
85
- } catch {
86
- envObject[match[1]] = val;
83
+ if (match) {
84
+ try {
85
+ envObject[match[1]] = JSON.parse(val);
86
+ } catch {
87
+ envObject[match[1]] = val;
88
+ }
87
89
  }
88
90
  }
89
91
  return {
@@ -135,6 +137,8 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev) {
135
137
  }),
136
138
  // strip Flow types from react-native and @react-native packages
137
139
  flowStripPlugin(),
140
+ // guard undefined native methods in NativeAnimatedHelper
141
+ nativeAnimatedGuardPlugin(),
138
142
  // handle asset imports (.png, .jpg, .ttf, etc.)
139
143
  assetPlugin({
140
144
  root,
@@ -149,32 +153,53 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev) {
149
153
  function getNativeOutputOptions(prelude) {
150
154
  return {
151
155
  format: "esm",
152
- sourcemap: !0,
156
+ sourcemap: true,
153
157
  intro: prelude,
154
- codeSplitting: !1,
155
- strictExecutionOrder: !0
158
+ codeSplitting: false,
159
+ strictExecutionOrder: true
156
160
  };
157
161
  }
158
162
  function postProcessNativeBundle(code) {
159
- return code = code.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm, ""), code = code.replace(/^if \(import\.meta\.hot\).*$/gm, ""), code;
163
+ code = code.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm, "");
164
+ code = code.replace(/^if \(import\.meta\.hot\).*$/gm, "");
165
+ {
166
+ const marker = "NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;";
167
+ const idx = code.indexOf(marker);
168
+ if (idx !== -1) {
169
+ const beforeMarker = code.lastIndexOf("NativeAnimatedModule = ", idx);
170
+ if (beforeMarker !== -1) {
171
+ const lineStart = code.lastIndexOf("\n", beforeMarker);
172
+ const snippet = code.slice(lineStart + 1, beforeMarker + 50);
173
+ if (snippet.includes("(function()") || snippet.includes("new Proxy")) {
174
+ const afterMarker = code.indexOf("})();", idx);
175
+ if (afterMarker !== -1) {
176
+ const end = afterMarker + "})();".length;
177
+ code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + code.slice(end);
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ return code;
160
184
  }
161
185
  async function downlevelClassFieldsInBundle(code) {
162
- const startMarker = "//#region \\0rolldown/runtime.js",
163
- endMarker = "//#endregion",
164
- startIdx = code.indexOf(startMarker);
186
+ const startMarker = "//#region \\0rolldown/runtime.js";
187
+ const endMarker = "//#endregion";
188
+ const startIdx = code.indexOf(startMarker);
165
189
  if (startIdx === -1) return code;
166
190
  const endIdx = code.indexOf(endMarker, startIdx);
167
191
  if (endIdx === -1) return code;
168
- const runtimeEnd = endIdx + endMarker.length,
169
- runtimeSection = code.slice(startIdx, runtimeEnd);
192
+ const runtimeEnd = endIdx + endMarker.length;
193
+ const runtimeSection = code.slice(startIdx, runtimeEnd);
170
194
  try {
171
- const result = await (await import("@swc/core")).transform(runtimeSection, {
195
+ const swc = await import("@swc/core");
196
+ const result = await swc.transform(runtimeSection, {
172
197
  filename: "rolldown-runtime.js",
173
- configFile: !1,
174
- swcrc: !1,
175
- sourceMaps: !1,
176
- inputSourceMap: !1,
177
- isModule: !1,
198
+ configFile: false,
199
+ swcrc: false,
200
+ sourceMaps: false,
201
+ inputSourceMap: false,
202
+ isModule: false,
178
203
  env: {
179
204
  targets: {
180
205
  node: 9999
@@ -190,73 +215,78 @@ async function downlevelClassFieldsInBundle(code) {
190
215
  runtime: "preserve"
191
216
  }
192
217
  },
193
- externalHelpers: !1,
218
+ externalHelpers: false,
194
219
  assumptions: {
195
- setPublicClassFields: !0,
196
- privateFieldsAsProperties: !0
220
+ setPublicClassFields: true,
221
+ privateFieldsAsProperties: true
197
222
  }
198
223
  }
199
224
  });
200
225
  return code.slice(0, startIdx) + result.code + code.slice(runtimeEnd);
201
226
  } catch (err) {
202
- return console.warn("[vxrn] downlevelClassFieldsInBundle failed, returning original:", err), code;
227
+ console.warn("[vxrn] downlevelClassFieldsInBundle failed, returning original:", err);
228
+ return code;
203
229
  }
204
230
  }
205
231
  async function createNativeDevEngine(options) {
206
232
  const {
207
- root,
208
- port,
209
- host = "localhost",
210
- platform,
211
- serverUrl,
212
- plugins: userPlugins = [],
213
- onHmrUpdate
214
- } = options,
215
- {
216
- dev,
217
- viteImportGlobPlugin
218
- } = await import("rolldown/experimental"),
219
- hmrRuntimeSource = getHmrRuntimeSource(),
220
- prelude = getNativePrelude({
221
- dev: !0,
222
- platform,
223
- serverUrl: serverUrl || `http://${host}:${port}`
224
- });
225
- let currentBundle = null,
226
- bundleResolve = null,
227
- bundlePromise = null;
228
- const resolvedHost = host === "0.0.0.0" ? "localhost" : host,
229
- inputOptions = {
230
- input: VIRTUAL_NATIVE_ENTRY,
231
- cwd: root,
232
- platform: "neutral",
233
- resolve: getNativeResolveConfig(platform),
234
- transform: getNativeTransformConfig(platform, !0, root),
235
- experimental: {
236
- devMode: {
237
- implement: hmrRuntimeSource,
238
- host,
239
- port
240
- },
241
- incrementalBuild: !0
242
- },
243
- treeshake: !1,
244
- // some react-native ecosystem packages import symbols that don't exist in
245
- // the declared entry (e.g. @react-navigation/elements imports NavigationProvider
246
- // from @react-navigation/native which doesn't export it). metro silently shims
247
- // these — rolldown needs an explicit opt-in.
248
- shimMissingExports: !0,
249
- moduleTypes: {
250
- ".js": "jsx"
233
+ root,
234
+ port,
235
+ host = "localhost",
236
+ platform,
237
+ serverUrl,
238
+ plugins: userPlugins = [],
239
+ onHmrUpdate
240
+ } = options;
241
+ const {
242
+ dev,
243
+ viteImportGlobPlugin
244
+ } = await import("rolldown/experimental");
245
+ const hmrRuntimeSource = getHmrRuntimeSource();
246
+ const prelude = getNativePrelude({
247
+ dev: true,
248
+ platform,
249
+ serverUrl: serverUrl || `http://${host}:${port}`
250
+ });
251
+ let currentBundle = null;
252
+ let bundleResolve = null;
253
+ let bundlePromise = null;
254
+ const resolvedHost = host === "0.0.0.0" ? "localhost" : host;
255
+ const inputOptions = {
256
+ input: VIRTUAL_NATIVE_ENTRY,
257
+ cwd: root,
258
+ platform: "neutral",
259
+ resolve: getNativeResolveConfig(platform),
260
+ transform: getNativeTransformConfig(platform, true, root),
261
+ experimental: {
262
+ devMode: {
263
+ implement: hmrRuntimeSource,
264
+ host,
265
+ port
251
266
  },
252
- plugins: [nativeVirtualEntryPlugin(root, {
253
- dev: !0
254
- }), ...getNativePlugins(root, platform, viteImportGlobPlugin, !0), ...userPlugins]
267
+ incrementalBuild: true,
268
+ // lazyBarrel defers barrel re-export initialization — needed in dev mode
269
+ // to avoid breaking worklet closure serialization order.
270
+ // removed from prod builds (buildNativeBundle) where it caused build errors.
271
+ lazyBarrel: true
272
+ },
273
+ treeshake: false,
274
+ // some react-native ecosystem packages import symbols that don't exist in
275
+ // the declared entry (e.g. @react-navigation/elements imports NavigationProvider
276
+ // from @react-navigation/native which doesn't export it). metro silently shims
277
+ // these — rolldown needs an explicit opt-in.
278
+ shimMissingExports: true,
279
+ moduleTypes: {
280
+ ".js": "jsx"
255
281
  },
256
- outputOptions = {
257
- ...getNativeOutputOptions(prelude),
258
- // connect HMR WebSocket using RN's WebSocket module (not the global)
259
- outro: `
282
+ plugins: [nativeVirtualEntryPlugin(root, {
283
+ dev: true
284
+ }), ...getNativePlugins(root, platform, viteImportGlobPlugin, true), ...userPlugins]
285
+ };
286
+ const outputOptions = {
287
+ ...getNativeOutputOptions(prelude),
288
+ // connect HMR WebSocket using RN's WebSocket module (not the global)
289
+ outro: `
260
290
  try {
261
291
  var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
262
292
  var __hmrUrl = 'ws://${resolvedHost}:${port}/hot';
@@ -285,49 +315,65 @@ try {
285
315
  __hmrWS.onerror = function(e) { console.warn('[vxrn] HMR connection error:', e.message || e); };
286
316
  } catch(e) {}
287
317
  `
288
- },
289
- engine = await dev(inputOptions, outputOptions, {
290
- onOutput: async result => {
291
- if (result instanceof Error) {
292
- console.error("[vxrn] native bundle error:", result.message);
293
- return;
294
- }
295
- const chunk = result.output.find(o => o.type === "chunk" && o.isEntry);
296
- if (chunk && "code" in chunk) {
297
- let code = postProcessNativeBundle(chunk.code);
298
- code = await downlevelClassFieldsInBundle(code);
299
- const hmrClientStub = 'registerCallableModule("HMRClient",{setup:function(){},enable:function(){},disable:function(){},registerBundle:function(){},log:function(){}})';
300
- code = code.replace(/registerCallableModule\s*\(\s*["']AppRegistry["']/, match => hmrClientStub + "," + match), currentBundle = {
301
- code,
302
- map: chunk.map?.toString()
303
- }, console.info(`[vxrn] native bundle ready (${Math.round(chunk.code.length / 1024)}KB)`), bundleResolve && (bundleResolve(currentBundle), bundleResolve = null, bundlePromise = null);
304
- }
305
- },
306
- onHmrUpdates: async result => {
307
- if (result instanceof Error) {
308
- console.error("[vxrn] HMR error:", result.message), onHmrUpdate?.({
309
- type: "hmr:error"
310
- });
311
- return;
318
+ };
319
+ const engine = await dev(inputOptions, outputOptions, {
320
+ onOutput: async result => {
321
+ if (result instanceof Error) {
322
+ console.error("[vxrn] native bundle error:", result.message);
323
+ return;
324
+ }
325
+ const output = result;
326
+ const chunk = output.output.find(o => o.type === "chunk" && o.isEntry);
327
+ if (chunk && "code" in chunk) {
328
+ let code = postProcessNativeBundle(chunk.code);
329
+ code = await downlevelClassFieldsInBundle(code);
330
+ const hmrClientStub = `registerCallableModule("HMRClient",{setup:function(){},enable:function(){},disable:function(){},registerBundle:function(){},log:function(){}})`;
331
+ code = code.replace(/registerCallableModule\s*\(\s*["']AppRegistry["']/, match => hmrClientStub + "," + match);
332
+ currentBundle = {
333
+ code,
334
+ map: chunk.map?.toString()
335
+ };
336
+ console.info(`[vxrn] native bundle ready (${Math.round(chunk.code.length / 1024)}KB)`);
337
+ if (bundleResolve) {
338
+ bundleResolve(currentBundle);
339
+ bundleResolve = null;
340
+ bundlePromise = null;
312
341
  }
313
- const updates = result.updates || [];
314
- for (const item of updates) {
315
- const update = item.update || item;
316
- update.type === "Patch" && update.code ? onHmrUpdate?.({
342
+ }
343
+ },
344
+ onHmrUpdates: async result => {
345
+ if (result instanceof Error) {
346
+ console.error("[vxrn] HMR error:", result.message);
347
+ onHmrUpdate?.({
348
+ type: "hmr:error"
349
+ });
350
+ return;
351
+ }
352
+ const updates = result.updates || [];
353
+ for (const item of updates) {
354
+ const update = item.update || item;
355
+ if (update.type === "Patch" && update.code) {
356
+ onHmrUpdate?.({
317
357
  type: "hmr:update",
318
358
  code: update.code
319
- }) : update.type === "FullReload" && onHmrUpdate?.({
359
+ });
360
+ } else if (update.type === "FullReload") {
361
+ onHmrUpdate?.({
320
362
  type: "hmr:reload"
321
363
  });
322
364
  }
323
- updates.length === 0 && onHmrUpdate?.({
365
+ }
366
+ if (updates.length === 0) {
367
+ onHmrUpdate?.({
324
368
  type: "hmr:reload"
325
369
  });
326
- },
327
- rebuildStrategy: "auto",
328
- watch: {}
329
- });
330
- return await engine.run(), {
370
+ }
371
+ },
372
+ rebuildStrategy: "auto",
373
+ watch: {}
374
+ });
375
+ await engine.run();
376
+ return {
331
377
  engine,
332
378
  async getBundle() {
333
379
  if (currentBundle) return currentBundle;
@@ -335,11 +381,15 @@ try {
335
381
  let timeoutId;
336
382
  bundlePromise = new Promise((resolve2, reject) => {
337
383
  bundleResolve = value => {
338
- clearTimeout(timeoutId), resolve2(value);
339
- }, timeoutId = setTimeout(() => reject(new Error("[vxrn] bundle build timed out after 120s")), 12e4);
384
+ clearTimeout(timeoutId);
385
+ resolve2(value);
386
+ };
387
+ timeoutId = setTimeout(() => reject(new Error("[vxrn] bundle build timed out after 120s")), 12e4);
340
388
  });
341
389
  }
342
- return await engine.ensureLatestBuildOutput(), currentBundle || bundlePromise;
390
+ await engine.ensureLatestBuildOutput();
391
+ if (currentBundle) return currentBundle;
392
+ return bundlePromise;
343
393
  },
344
394
  async close() {
345
395
  await engine.close();
@@ -348,66 +398,69 @@ try {
348
398
  }
349
399
  async function buildNativeBundle(options) {
350
400
  const {
351
- root,
352
- platform,
353
- dev = !1,
354
- serverUrl,
355
- plugins: userPlugins = []
356
- } = options,
357
- {
358
- build
359
- } = await import("rolldown"),
360
- {
361
- viteImportGlobPlugin
362
- } = await import("rolldown/experimental"),
363
- prelude = getNativePrelude({
364
- dev,
365
- platform,
366
- serverUrl
367
- }),
368
- chunk = (await build({
369
- input: VIRTUAL_NATIVE_ENTRY,
370
- cwd: root,
371
- platform: "neutral",
372
- resolve: getNativeResolveConfig(platform),
373
- transform: getNativeTransformConfig(platform, dev, root),
374
- treeshake: !dev,
375
- shimMissingExports: !0,
376
- moduleTypes: {
377
- ".js": "jsx"
378
- },
379
- plugins: [nativeVirtualEntryPlugin(root, {
380
- dev
381
- }), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev), ...userPlugins],
382
- output: getNativeOutputOptions(prelude)
383
- })).output.find(o => o.type === "chunk" && o.isEntry);
384
- if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
401
+ root,
402
+ platform,
403
+ dev = false,
404
+ serverUrl,
405
+ plugins: userPlugins = []
406
+ } = options;
407
+ const {
408
+ build
409
+ } = await import("rolldown");
410
+ const {
411
+ viteImportGlobPlugin
412
+ } = await import("rolldown/experimental");
413
+ const prelude = getNativePrelude({
414
+ dev,
415
+ platform,
416
+ serverUrl
417
+ });
418
+ const result = await build({
419
+ input: VIRTUAL_NATIVE_ENTRY,
420
+ cwd: root,
421
+ platform: "neutral",
422
+ resolve: getNativeResolveConfig(platform),
423
+ transform: getNativeTransformConfig(platform, dev, root),
424
+ treeshake: !dev,
425
+ shimMissingExports: true,
426
+ moduleTypes: {
427
+ ".js": "jsx"
428
+ },
429
+ plugins: [nativeVirtualEntryPlugin(root, {
430
+ dev
431
+ }), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev), ...userPlugins],
432
+ output: getNativeOutputOptions(prelude)
433
+ });
434
+ const chunk = result.output.find(o => o.type === "chunk" && o.isEntry);
435
+ if (!chunk || !("code" in chunk)) {
436
+ throw new Error("[vxrn] production build produced no output");
437
+ }
385
438
  let code = postProcessNativeBundle(chunk.code);
386
- return code = await downlevelClassFieldsInBundle(code), {
439
+ code = await downlevelClassFieldsInBundle(code);
440
+ return {
387
441
  code,
388
442
  map: chunk.map?.toString()
389
443
  };
390
444
  }
391
445
  const VIRTUAL_NATIVE_ENTRY = "virtual:native-entry";
392
446
  function nativeVirtualEntryPlugin(root, opts) {
393
- const isDev = opts?.dev !== !1,
394
- resolvedId = resolve(root, "__virtual-native-entry.tsx"),
395
- entryConfig = globalThis.__vxrnNativeEntryConfig || {},
396
- routerRoot = entryConfig.routerRoot || "app",
397
- flags = entryConfig.flags || {},
398
- setupFileImport = (() => {
399
- const sf = entryConfig.setupFile;
400
- if (!sf) return "";
401
- const file = typeof sf == "string" ? sf : "native" in sf ? sf.native : sf.ios;
402
- if (!file) return "";
403
- const resolved = resolve(root, file);
404
- return `import ${JSON.stringify(resolved)};`;
405
- })(),
406
- routeGlobs = [`./${routerRoot}/**/*.tsx`, `./${routerRoot}/**/*.ts`, `!./${routerRoot}/**/*+api.*`, `!./${routerRoot}/**/*.test.*`, `!./${routerRoot}/**/*.d.ts`, `!./${routerRoot}/**/*.server.*`, `!./${routerRoot}/**/_middleware.*`, `!./${routerRoot}/**/*.web.*`,
407
- // ignoredRouteFiles from One's router config
408
- ...(entryConfig.ignoredRouteFiles || []).map(pattern => `!./${routerRoot}/${pattern}`)],
409
- entryCode = `
410
- ${isDev ? `
447
+ const isDev = opts?.dev !== false;
448
+ const resolvedId = resolve(root, "__virtual-native-entry.tsx");
449
+ const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
450
+ const routerRoot = entryConfig.routerRoot || "app";
451
+ const flags = entryConfig.flags || {};
452
+ const setupFileImport = (() => {
453
+ const sf = entryConfig.setupFile;
454
+ if (!sf) return "";
455
+ const file = typeof sf === "string" ? sf : "native" in sf ? sf.native : sf.ios;
456
+ if (!file) return "";
457
+ const resolved = resolve(root, file);
458
+ return `import ${JSON.stringify(resolved)};`;
459
+ })();
460
+ const routeGlobs = [`./${routerRoot}/**/*.tsx`, `./${routerRoot}/**/*.ts`, `!./${routerRoot}/**/*+api.*`, `!./${routerRoot}/**/*.test.*`, `!./${routerRoot}/**/*.d.ts`, `!./${routerRoot}/**/*.server.*`, `!./${routerRoot}/**/_middleware.*`, `!./${routerRoot}/**/*.web.*`,
461
+ // ignoredRouteFiles from One's router config
462
+ ...(entryConfig.ignoredRouteFiles || []).map(pattern => `!./${routerRoot}/${pattern}`)];
463
+ const refreshSetup = isDev ? `
411
464
  // react-refresh/runtime MUST initialize before React loads
412
465
  import RefreshRuntime from 'react-refresh/runtime';
413
466
  RefreshRuntime.injectIntoGlobalHook(globalThis);
@@ -416,7 +469,9 @@ globalThis.$RefreshReg$ = function(type, id) {
416
469
  RefreshRuntime.register(type, id);
417
470
  };
418
471
  globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
419
- ` : ""}
472
+ ` : "";
473
+ const entryCode = `
474
+ ${refreshSetup}
420
475
  ${setupFileImport}
421
476
  import { createApp } from 'one';
422
477
 
@@ -436,10 +491,28 @@ createApp({
436
491
  return {
437
492
  name: "vxrn:native-virtual-entry",
438
493
  resolveId(id) {
439
- if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
494
+ if (id === VIRTUAL_NATIVE_ENTRY) {
495
+ return resolvedId;
496
+ }
440
497
  },
441
498
  load(id) {
442
- if (id === resolvedId) return entryCode;
499
+ if (id === resolvedId) {
500
+ return entryCode;
501
+ }
502
+ }
503
+ };
504
+ }
505
+ function nativeAnimatedGuardPlugin() {
506
+ return {
507
+ name: "vxrn:native-animated-guard",
508
+ transform(code, id) {
509
+ if (!id.includes("animated/NativeAnimatedHelper")) return;
510
+ const target = "const method = nullthrows(NativeAnimatedModule)[methodName];";
511
+ if (!code.includes(target)) return;
512
+ return {
513
+ code: code.replace(target, `const method = nullthrows(NativeAnimatedModule)[methodName];
514
+ if (typeof method !== 'function') return;`)
515
+ };
443
516
  }
444
517
  };
445
518
  }
@@ -447,37 +520,44 @@ function serverFileExclusionPlugin() {
447
520
  return {
448
521
  name: "vxrn:server-file-exclusion",
449
522
  load(id) {
450
- if (/\.server\.\w+$/.test(id)) return {
451
- code: "export default undefined;",
452
- moduleType: "js"
453
- };
454
- if (/[\\/]_middleware\.\w+$/.test(id)) return {
455
- code: "export default undefined;",
456
- moduleType: "js"
457
- };
523
+ if (/\.server\.\w+$/.test(id)) {
524
+ return {
525
+ code: "export default undefined;",
526
+ moduleType: "js"
527
+ };
528
+ }
529
+ if (/[\\/]_middleware\.\w+$/.test(id)) {
530
+ return {
531
+ code: "export default undefined;",
532
+ moduleType: "js"
533
+ };
534
+ }
458
535
  }
459
536
  };
460
537
  }
461
538
  function environmentGuardPlugin() {
462
- const THROWING = ["server-only", "client-only", "web-only"],
463
- NOOP = ["native-only"];
539
+ const THROWING = ["server-only", "client-only", "web-only"];
540
+ const NOOP = ["native-only"];
464
541
  return {
465
542
  name: "vxrn:environment-guard",
466
543
  resolveId(source) {
467
544
  if (THROWING.includes(source)) return {
468
545
  id: `\0env-guard-throw:${source}`,
469
- external: !1
546
+ external: false
470
547
  };
471
548
  if (NOOP.includes(source)) return {
472
549
  id: `\0env-guard-noop:${source}`,
473
- external: !1
550
+ external: false
474
551
  };
475
552
  },
476
553
  load(id) {
477
- if (id.startsWith("\0env-guard-throw:")) return {
478
- code: `throw new Error("Cannot import '${id.slice(17)}' in a native bundle.");`,
479
- moduleType: "js"
480
- };
554
+ if (id.startsWith("\0env-guard-throw:")) {
555
+ const pkg = id.slice("\0env-guard-throw:".length);
556
+ return {
557
+ code: `throw new Error("Cannot import '${pkg}' in a native bundle.");`,
558
+ moduleType: "js"
559
+ };
560
+ }
481
561
  if (id.startsWith("\0env-guard-noop:")) return {
482
562
  code: "",
483
563
  moduleType: "js"
@@ -490,10 +570,12 @@ function cssStubPlugin() {
490
570
  name: "vxrn:css-stub",
491
571
  load: {
492
572
  handler(id) {
493
- if (/\.css$/.test(id)) return {
494
- code: "",
495
- moduleType: "js"
496
- };
573
+ if (id.endsWith(".css")) {
574
+ return {
575
+ code: "",
576
+ moduleType: "js"
577
+ };
578
+ }
497
579
  }
498
580
  }
499
581
  };
@@ -504,10 +586,11 @@ function vxrnCompilerPlugin(platform, dev) {
504
586
  return {
505
587
  name: "vxrn:compiler",
506
588
  async transform(code, id) {
507
- if (!/\.[cm]?[jt]sx?$/.test(id) || id.includes("\0") || id.includes("virtual:")) return;
589
+ if (!/\.[cm]?[jt]sx?$/.test(id)) return;
590
+ if (id.includes("\0") || id.includes("virtual:")) return;
508
591
  const needsRefresh = isRefreshCandidate(id);
509
592
  try {
510
- compiler || (compiler = await import("@vxrn/compiler"));
593
+ if (!compiler) compiler = await import("@vxrn/compiler");
511
594
  const props = {
512
595
  id,
513
596
  code,
@@ -527,12 +610,14 @@ function vxrnCompilerPlugin(platform, dev) {
527
610
  const result = await compiler.transformBabel(id, code, babelOptions);
528
611
  if (result?.code) {
529
612
  let out = result.code;
530
- return needsRefresh && (out = `
613
+ if (needsRefresh) {
614
+ const escapedId = id.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
615
+ out = `
531
616
  var __prevRefreshReg = globalThis.$RefreshReg$;
532
617
  var __prevRefreshSig = globalThis.$RefreshSig$;
533
618
  if (globalThis.__ReactRefresh) {
534
619
  globalThis.$RefreshReg$ = function(type, id) {
535
- globalThis.__ReactRefresh.register(type, "${id.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}" + " " + id);
620
+ globalThis.__ReactRefresh.register(type, "${escapedId}" + " " + id);
536
621
  };
537
622
  globalThis.$RefreshSig$ = globalThis.__ReactRefresh.createSignatureFunctionForTransform;
538
623
  }
@@ -548,16 +633,23 @@ if (import.meta.hot) {
548
633
  }
549
634
  });
550
635
  }
551
- `), {
636
+ `;
637
+ }
638
+ return {
552
639
  code: out
553
640
  };
554
641
  }
555
642
  } catch (err) {
556
- if (dev && console.warn(`[vxrn:compiler] ${id}: ${err.message || err}`), needsRefresh) return {
557
- code: code + `
643
+ if (dev) {
644
+ console.warn(`[vxrn:compiler] ${id}: ${err.message || err}`);
645
+ }
646
+ if (needsRefresh) {
647
+ return {
648
+ code: code + `
558
649
  if (import.meta.hot) { import.meta.hot.accept(); }
559
650
  `
560
- };
651
+ };
652
+ }
561
653
  }
562
654
  }
563
655
  };
@@ -567,11 +659,13 @@ function flowStripPlugin() {
567
659
  name: "vxrn:flow-strip",
568
660
  transform: {
569
661
  async handler(code, id) {
570
- if (FLOW_FILE_PATTERN.test(id)) try {
571
- const result = await (await import("fast-flow-transform")).default({
662
+ if (!FLOW_FILE_PATTERN.test(id)) return;
663
+ try {
664
+ const fft = await import("fast-flow-transform");
665
+ const result = await fft.default({
572
666
  filename: id,
573
667
  source: code,
574
- sourcemap: !0,
668
+ sourcemap: true,
575
669
  dialect: "flow",
576
670
  format: "pretty"
577
671
  });
@@ -593,31 +687,35 @@ function assetPlugin(opts) {
593
687
  load: {
594
688
  async handler(id) {
595
689
  if (!assetRegex.test(id)) return;
596
- const ext = extname(id).slice(1),
597
- name = basename(id, `.${ext}`),
598
- dir = dirname(id),
599
- relativePath = relative(opts.root, id),
600
- httpLocation = "/assets/" + dirname(relativePath),
601
- assetData = {
602
- __packager_asset: !0,
603
- name,
604
- type: ext,
605
- scales: [1],
606
- httpServerLocation: httpLocation,
607
- fileSystemLocation: dir,
608
- hash: "",
609
- width: void 0,
610
- height: void 0
611
- };
612
- if (["png", "jpg", "jpeg", "gif", "webp", "bmp"].includes(ext)) try {
613
- const {
690
+ const ext = extname(id).slice(1);
691
+ const name = basename(id, `.${ext}`);
692
+ const dir = dirname(id);
693
+ const relativePath = relative(opts.root, id);
694
+ const httpLocation = "/assets/" + dirname(relativePath);
695
+ const assetData = {
696
+ __packager_asset: true,
697
+ name,
698
+ type: ext,
699
+ scales: [1],
700
+ httpServerLocation: httpLocation,
701
+ fileSystemLocation: dir,
702
+ hash: "",
703
+ width: void 0,
704
+ height: void 0
705
+ };
706
+ if (["png", "jpg", "jpeg", "gif", "webp", "bmp"].includes(ext)) {
707
+ try {
708
+ const {
614
709
  imageSize
615
- } = await import("image-size"),
616
- dims = imageSize(id);
617
- assetData.width = dims.width, assetData.height = dims.height;
618
- } catch {}
710
+ } = await import("image-size");
711
+ const dims = imageSize(id);
712
+ assetData.width = dims.width;
713
+ assetData.height = dims.height;
714
+ } catch {}
715
+ }
716
+ const code = `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`;
619
717
  return {
620
- code: `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`,
718
+ code,
621
719
  moduleType: "js"
622
720
  };
623
721
  }
@@ -629,45 +727,49 @@ function hermesCompatSWCPlugin(dev) {
629
727
  return {
630
728
  name: "vxrn:hermes-compat",
631
729
  async transform(code, id) {
632
- if (!/\.[cm]?[jt]sx?$/.test(id) || id.includes("\0") || id.includes("virtual:")) return;
633
- const hasClass = code.includes("class ") || code.includes("class{"),
634
- hasAsync = !dev && code.includes("async ");
635
- if (!(!hasClass && !hasAsync) && !(code.length > 5e5)) try {
636
- swc || (swc = await import("@swc/core"));
637
- const envIncludes = ["transform-class-properties", "transform-class-static-block", "transform-private-methods", "transform-private-property-in-object", ...(dev ? [] : ["transform-classes", "transform-async-to-generator"])];
638
- return {
639
- code: (await swc.transform(code, {
640
- filename: id,
641
- configFile: !1,
642
- swcrc: !1,
643
- sourceMaps: !1,
644
- inputSourceMap: !1,
645
- env: {
646
- targets: {
647
- node: 9999
648
- },
649
- include: envIncludes
730
+ if (!/\.[cm]?[jt]sx?$/.test(id)) return;
731
+ if (id.includes("\0") || id.includes("virtual:")) return;
732
+ const hasClass = code.includes("class ") || code.includes("class{");
733
+ const hasAsync = !dev && code.includes("async ");
734
+ if (!hasClass && !hasAsync) return;
735
+ if (code.length > 5e5) return;
736
+ try {
737
+ if (!swc) swc = await import("@swc/core");
738
+ const envIncludes = ["transform-class-properties", "transform-class-static-block", "transform-private-methods", "transform-private-property-in-object", ...(!dev ? ["transform-classes", "transform-async-to-generator"] : [])];
739
+ const result = await swc.transform(code, {
740
+ filename: id,
741
+ configFile: false,
742
+ swcrc: false,
743
+ sourceMaps: false,
744
+ inputSourceMap: false,
745
+ env: {
746
+ targets: {
747
+ node: 9999
650
748
  },
651
- jsc: {
652
- parser: {
653
- syntax: "typescript",
654
- tsx: !0
655
- },
656
- transform: {
657
- react: {
658
- runtime: "preserve"
659
- }
660
- },
661
- externalHelpers: !1,
662
- assumptions: {
663
- setPublicClassFields: !0,
664
- privateFieldsAsProperties: !0
749
+ include: envIncludes
750
+ },
751
+ jsc: {
752
+ parser: {
753
+ syntax: "typescript",
754
+ tsx: true
755
+ },
756
+ transform: {
757
+ react: {
758
+ runtime: "preserve"
665
759
  }
666
760
  },
667
- isModule: !id.endsWith(".cjs")
668
- })).code
761
+ externalHelpers: false,
762
+ assumptions: {
763
+ setPublicClassFields: true,
764
+ privateFieldsAsProperties: true
765
+ }
766
+ },
767
+ isModule: !id.endsWith(".cjs")
768
+ });
769
+ return {
770
+ code: result.code
669
771
  };
670
- } catch {}
772
+ } catch (err) {}
671
773
  }
672
774
  };
673
775
  }