vxrn 2.0.0-beta.99.1 → 2.6.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 (210) hide show
  1. package/dist/backgroundComputation.mjs +145 -0
  2. package/dist/backgroundComputation.mjs.map +1 -0
  3. package/dist/backgroundComputation.native.js +163 -0
  4. package/dist/backgroundComputation.native.js.map +1 -0
  5. package/dist/backgroundComputationNative.mjs +16 -0
  6. package/dist/backgroundComputationNative.mjs.map +1 -0
  7. package/dist/backgroundComputationNative.native.js +18 -0
  8. package/dist/backgroundComputationNative.native.js.map +1 -0
  9. package/dist/config/getBaseViteConfigOnly.mjs +6 -10
  10. package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
  11. package/dist/config/getBaseViteConfigOnly.native.js +6 -10
  12. package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
  13. package/dist/config/getOptimizeDeps.mjs +2 -1
  14. package/dist/config/getOptimizeDeps.mjs.map +1 -1
  15. package/dist/config/getOptimizeDeps.native.js +2 -1
  16. package/dist/config/getOptimizeDeps.native.js.map +1 -1
  17. package/dist/config/getViteServerConfig.mjs +13 -0
  18. package/dist/config/getViteServerConfig.mjs.map +1 -1
  19. package/dist/config/getViteServerConfig.native.js +15 -1
  20. package/dist/config/getViteServerConfig.native.js.map +1 -1
  21. package/dist/constants/defaults.mjs +4 -0
  22. package/dist/constants/defaults.mjs.map +1 -1
  23. package/dist/constants/defaults.native.js +4 -0
  24. package/dist/constants/defaults.native.js.map +1 -1
  25. package/dist/exports/build.native.js +1 -1
  26. package/dist/exports/build.native.js.map +1 -1
  27. package/dist/exports/clean.native.js +1 -1
  28. package/dist/exports/clean.native.js.map +1 -1
  29. package/dist/exports/createServer.native.js +2 -2
  30. package/dist/exports/createServer.native.js.map +1 -1
  31. package/dist/exports/dev.mjs +3 -0
  32. package/dist/exports/dev.mjs.map +1 -1
  33. package/dist/exports/dev.native.js +6 -3
  34. package/dist/exports/dev.native.js.map +1 -1
  35. package/dist/exports/loadEnv.native.js +1 -1
  36. package/dist/exports/loadEnv.native.js.map +1 -1
  37. package/dist/exports/patch.native.js +1 -1
  38. package/dist/exports/patch.native.js.map +1 -1
  39. package/dist/exports/prebuild.mjs +0 -22
  40. package/dist/exports/prebuild.mjs.map +1 -1
  41. package/dist/exports/prebuild.native.js +1 -23
  42. package/dist/exports/prebuild.native.js.map +1 -1
  43. package/dist/exports/prebuildWithoutExpo.mjs +1116 -178
  44. package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
  45. package/dist/exports/prebuildWithoutExpo.native.js +1592 -243
  46. package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
  47. package/dist/exports/runAndroid.native.js +1 -1
  48. package/dist/exports/runAndroid.native.js.map +1 -1
  49. package/dist/exports/runIos.native.js +1 -1
  50. package/dist/exports/runIos.native.js.map +1 -1
  51. package/dist/exports/serve.native.js +1 -1
  52. package/dist/exports/serve.native.js.map +1 -1
  53. package/dist/exports/serveStaticAssets.native.js +1 -1
  54. package/dist/exports/serveStaticAssets.native.js.map +1 -1
  55. package/dist/index.js +4 -1
  56. package/dist/index.mjs +4 -1
  57. package/dist/index.native.js +4 -1
  58. package/dist/native-source-contract.mjs +3 -0
  59. package/dist/native-source-contract.native.js +3 -0
  60. package/dist/patches/builtInDepPatches.mjs +0 -13
  61. package/dist/patches/builtInDepPatches.mjs.map +1 -1
  62. package/dist/patches/builtInDepPatches.native.js +0 -13
  63. package/dist/patches/builtInDepPatches.native.js.map +1 -1
  64. package/dist/plugins/autoDepOptimizePlugin.mjs +3 -2
  65. package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
  66. package/dist/plugins/autoDepOptimizePlugin.native.js +6 -3
  67. package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
  68. package/dist/plugins/backgroundComputationPlugin.mjs +27 -0
  69. package/dist/plugins/backgroundComputationPlugin.mjs.map +1 -0
  70. package/dist/plugins/backgroundComputationPlugin.native.js +32 -0
  71. package/dist/plugins/backgroundComputationPlugin.native.js.map +1 -0
  72. package/dist/plugins/reactNativeCommonJsPlugin.native.js +3 -3
  73. package/dist/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
  74. package/dist/plugins/reactNativeDevAssetPlugin.mjs +2 -1
  75. package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
  76. package/dist/plugins/reactNativeDevAssetPlugin.native.js +3 -2
  77. package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
  78. package/dist/plugins/reactNativeDevServer.mjs +87 -24
  79. package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
  80. package/dist/plugins/reactNativeDevServer.native.js +162 -45
  81. package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
  82. package/dist/plugins/workletImportsPlugin.mjs +9 -30
  83. package/dist/plugins/workletImportsPlugin.mjs.map +1 -1
  84. package/dist/plugins/workletImportsPlugin.native.js +10 -35
  85. package/dist/plugins/workletImportsPlugin.native.js.map +1 -1
  86. package/dist/rn-commands/bundle/buildBundle.mjs +3 -3
  87. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  88. package/dist/rn-commands/bundle/buildBundle.native.js +3 -3
  89. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  90. package/dist/runtime/hmr-client.native.js +3 -7
  91. package/dist/runtime/hmr-client.native.js.map +1 -1
  92. package/dist/runtime/hmr-runtime.native.js +32 -40
  93. package/dist/runtime/hmr-runtime.native.js.map +1 -1
  94. package/dist/serve/node.native.js +2 -2
  95. package/dist/serve/node.native.js.map +1 -1
  96. package/dist/swift-package-id.mjs +3 -0
  97. package/dist/swift-package-id.native.js +3 -0
  98. package/dist/user-interface/index.native.js +6 -6
  99. package/dist/user-interface/index.native.js.map +1 -1
  100. package/dist/utils/compileNativeDevBytecode.mjs +93 -0
  101. package/dist/utils/compileNativeDevBytecode.mjs.map +1 -0
  102. package/dist/utils/compileNativeDevBytecode.native.js +98 -0
  103. package/dist/utils/compileNativeDevBytecode.native.js.map +1 -0
  104. package/dist/utils/createNativeDevEngine.mjs +227 -20
  105. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  106. package/dist/utils/createNativeDevEngine.native.js +249 -37
  107. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  108. package/dist/utils/execSync.native.js +1 -1
  109. package/dist/utils/execSync.native.js.map +1 -1
  110. package/dist/utils/getServerEntry.native.js +2 -2
  111. package/dist/utils/getServerEntry.native.js.map +1 -1
  112. package/dist/utils/nativeRun.mjs +32 -16
  113. package/dist/utils/nativeRun.mjs.map +1 -1
  114. package/dist/utils/nativeRun.native.js +43 -18
  115. package/dist/utils/nativeRun.native.js.map +1 -1
  116. package/dist/utils/nativeSourceContract.mjs +1823 -0
  117. package/dist/utils/nativeSourceContract.mjs.map +1 -0
  118. package/dist/utils/nativeSourceContract.native.js +2425 -0
  119. package/dist/utils/nativeSourceContract.native.js.map +1 -0
  120. package/dist/utils/patches.native.js +15 -24
  121. package/dist/utils/patches.native.js.map +1 -1
  122. package/dist/utils/printServerUrls.native.js +1 -1
  123. package/dist/utils/printServerUrls.native.js.map +1 -1
  124. package/dist/utils/scanDepsToOptimize.mjs +7 -1
  125. package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
  126. package/dist/utils/scanDepsToOptimize.native.js +27 -2
  127. package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
  128. package/dist/utils/swiftPackageId.mjs +31 -2
  129. package/dist/utils/swiftPackageId.mjs.map +1 -1
  130. package/dist/utils/swiftPackageId.native.js +50 -2
  131. package/dist/utils/swiftPackageId.native.js.map +1 -1
  132. package/dist/vxrn-vite-plugin.native.js +1 -1
  133. package/dist/vxrn-vite-plugin.native.js.map +1 -1
  134. package/expo-plugin.cjs +792 -2
  135. package/native-project-patches.cjs +201 -10
  136. package/package.json +34 -15
  137. package/src/backgroundComputation.ts +220 -0
  138. package/src/backgroundComputationNative.ts +23 -0
  139. package/src/config/getBaseViteConfigOnly.ts +8 -9
  140. package/src/config/getOptimizeDeps.ts +3 -1
  141. package/src/config/getViteServerConfig.ts +16 -0
  142. package/src/config/glbAssets.test.ts +228 -0
  143. package/src/constants/defaults.ts +6 -0
  144. package/src/exports/dev.ts +5 -1
  145. package/src/exports/expoPlugin.test.mjs +337 -15
  146. package/src/exports/prebuild.ts +0 -31
  147. package/src/exports/prebuildWithoutExpo.test.ts +1588 -48
  148. package/src/exports/prebuildWithoutExpo.ts +1573 -213
  149. package/src/index.ts +8 -0
  150. package/src/native-source-contract.ts +16 -0
  151. package/src/patches/builtInDepPatches.ts +0 -21
  152. package/src/plugins/autoDepOptimizePlugin.ts +7 -2
  153. package/src/plugins/backgroundComputationPlugin.test.ts +77 -0
  154. package/src/plugins/backgroundComputationPlugin.ts +29 -0
  155. package/src/plugins/reactNativeDevAssetPlugin.ts +5 -1
  156. package/src/plugins/reactNativeDevServer.test.ts +74 -0
  157. package/src/plugins/reactNativeDevServer.ts +145 -28
  158. package/src/plugins/rnCodegenPlugin.test.ts +30 -0
  159. package/src/plugins/workletImportsPlugin.ts +19 -37
  160. package/src/rn-commands/bundle/buildBundle.ts +5 -3
  161. package/src/swift-package-id.ts +1 -0
  162. package/src/utils/compileNativeDevBytecode.test.ts +168 -0
  163. package/src/utils/compileNativeDevBytecode.ts +117 -0
  164. package/src/utils/createNativeDevEngine.test.ts +643 -18
  165. package/src/utils/createNativeDevEngine.ts +278 -48
  166. package/src/utils/nativeRun.test.ts +125 -23
  167. package/src/utils/nativeRun.ts +51 -23
  168. package/src/utils/nativeSourceArtifacts.test.ts +39 -0
  169. package/src/utils/nativeSourceContract.test.ts +600 -0
  170. package/src/utils/nativeSourceContract.ts +1897 -0
  171. package/src/utils/scanDepsToOptimize.test.ts +80 -0
  172. package/src/utils/scanDepsToOptimize.ts +18 -7
  173. package/src/utils/swiftPackageId.ts +25 -1
  174. package/types/backgroundComputation.d.ts +28 -0
  175. package/types/backgroundComputation.d.ts.map +1 -0
  176. package/types/backgroundComputationNative.d.ts +2 -0
  177. package/types/backgroundComputationNative.d.ts.map +1 -0
  178. package/types/config/getBaseViteConfigOnly.d.ts.map +1 -1
  179. package/types/config/getOptimizeDeps.d.ts.map +1 -1
  180. package/types/config/getViteServerConfig.d.ts.map +1 -1
  181. package/types/constants/defaults.d.ts.map +1 -1
  182. package/types/exports/dev.d.ts.map +1 -1
  183. package/types/exports/prebuild.d.ts.map +1 -1
  184. package/types/exports/prebuildWithoutExpo.d.ts +6 -0
  185. package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
  186. package/types/index.d.ts +2 -0
  187. package/types/index.d.ts.map +1 -1
  188. package/types/native-source-contract.d.ts +2 -0
  189. package/types/native-source-contract.d.ts.map +1 -0
  190. package/types/patches/builtInDepPatches.d.ts.map +1 -1
  191. package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
  192. package/types/plugins/backgroundComputationPlugin.d.ts +3 -0
  193. package/types/plugins/backgroundComputationPlugin.d.ts.map +1 -0
  194. package/types/plugins/reactNativeDevAssetPlugin.d.ts.map +1 -1
  195. package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
  196. package/types/plugins/workletImportsPlugin.d.ts.map +1 -1
  197. package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
  198. package/types/swift-package-id.d.ts +2 -0
  199. package/types/swift-package-id.d.ts.map +1 -0
  200. package/types/utils/compileNativeDevBytecode.d.ts +3 -0
  201. package/types/utils/compileNativeDevBytecode.d.ts.map +1 -0
  202. package/types/utils/createNativeDevEngine.d.ts +7 -22
  203. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
  204. package/types/utils/nativeRun.d.ts.map +1 -1
  205. package/types/utils/nativeSourceContract.d.ts +121 -0
  206. package/types/utils/nativeSourceContract.d.ts.map +1 -0
  207. package/types/utils/scanDepsToOptimize.d.ts +1 -0
  208. package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
  209. package/types/utils/swiftPackageId.d.ts +1 -0
  210. package/types/utils/swiftPackageId.d.ts.map +1 -1
@@ -10,6 +10,7 @@ import { withExpoPublicEnvAliases } from "@vxrn/utils/publicEnv";
10
10
  import { DEFAULT_ASSET_EXTS } from "../constants/defaults.native.js";
11
11
  import { getNativePrelude } from "../runtime/native-prelude.native.js";
12
12
  import { rnCodegenPlugin } from "../plugins/rnCodegenPlugin.native.js";
13
+ import { dedupe } from "../config/getBaseViteConfigOnly.native.js";
13
14
 
14
15
  var HERMES_CLASS_TRANSFORMS = [
15
16
  "transform-classes",
@@ -60,12 +61,14 @@ function getResolveExtensions(platform) {
60
61
  function getNativeResolveConfig(platform) {
61
62
  return {
62
63
  extensions: getResolveExtensions(platform),
63
- conditionNames: ["react-native"],
64
+ conditionNames: ["react-native", "browser"],
64
65
  mainFields: [
65
66
  "react-native",
66
- "module",
67
- "main"
68
- ]
67
+ "browser",
68
+ "main",
69
+ "module"
70
+ ],
71
+ aliasFields: [["react-native"], ["browser"]]
69
72
  };
70
73
  }
71
74
  function getNativeTransformConfig(platform, dev, root) {
@@ -187,14 +190,12 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest,
187
190
  ...((_globalThis___vxrnAddNativePlugins = (_globalThis = globalThis).__vxrnAddNativePlugins) === null || _globalThis___vxrnAddNativePlugins === void 0 ? void 0 : _globalThis___vxrnAddNativePlugins.call(_globalThis, platform)) || [],
188
191
  serverFileExclusionPlugin(),
189
192
  environmentGuardPlugin(),
193
+ missingDynamicImportPlugin(),
190
194
  hmrClientNoopPlugin(),
191
- {
192
- name: "vxrn:legacy-asset-registry",
193
- resolveId(source, importer) {
194
- if (source === "@react-native/assets-registry/registry") return this.resolve("react-native/asset-registry", importer, { skipSelf: true });
195
- }
196
- },
195
+ nativeIdentityAliasPlugin(platform),
196
+ nativeAssetRegistryPlugin(root),
197
197
  reactNativeDedupePlugin(root),
198
+ nativePackageDedupePlugin(root),
198
199
  cssStubPlugin(),
199
200
  viteImportGlobPlugin({ root }),
200
201
  vxrnCompilerPlugin(platform, dev, root, sourceMaps),
@@ -209,7 +210,9 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest,
209
210
  }),
210
211
  hermesCompatSWCPlugin(dev, sourceMaps),
211
212
  hermesLoopsPlugin(sourceMaps),
212
- ...userPlugins
213
+ ...userPlugins,
214
+ nativeExportsPrecedencePlugin(root, platform),
215
+ nativeDeclarationAliasPlugin(root, platform)
213
216
  ].map(function(plugin) {
214
217
  var _plugin_api;
215
218
  return ((_plugin_api = plugin.api) === null || _plugin_api === void 0 ? void 0 : _plugin_api.vxrnNative) ? plugin.api.vxrnNative(context) : plugin;
@@ -219,7 +222,7 @@ function getNativeOutputOptions(prelude, sourcemap, minify) {
219
222
  return {
220
223
  format: "esm",
221
224
  sourcemap,
222
- sourcemapPathTransform: function(relativeSourcePath, sourcemapPath) {
225
+ sourcemapPathTransform: function sourcemapPathTransform(relativeSourcePath, sourcemapPath) {
223
226
  return normalizePath(resolve(dirname(sourcemapPath), relativeSourcePath));
224
227
  },
225
228
  intro: prelude,
@@ -332,14 +335,13 @@ async function createNativeDevEngine(options) {
332
335
  var bundleResolve = null;
333
336
  var bundleReject = null;
334
337
  var bundlePromise = null;
335
- var resolvedHost = host === "0.0.0.0" ? "localhost" : host;
336
338
  var virtualEntry = nativeVirtualEntryPlugin(root, {
337
339
  dev: true,
338
340
  platform,
339
341
  dynamicRoutes: true
340
342
  });
341
343
  var engineWork = Promise.resolve();
342
- var queueEngineWork = function(work) {
344
+ var queueEngineWork = function queueEngineWork2(work) {
343
345
  var result = engineWork.then(work, work);
344
346
  engineWork = result.catch(function() {});
345
347
  return result;
@@ -369,7 +371,8 @@ async function createNativeDevEngine(options) {
369
371
  outro: `
370
372
  try {
371
373
  var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
372
- var __hmrUrl = 'ws://${resolvedHost}:${port}/hot?platform=${platform}&clientId=' + encodeURIComponent(__rolldown_runtime__.clientId);
374
+ var __devServer = (init_getDevServer(), __toCommonJS(getDevServer_exports)).default();
375
+ var __hmrUrl = __devServer.url.replace(/^http/, 'ws') + 'hot?platform=${platform}&clientId=' + encodeURIComponent(__rolldown_runtime__.clientId);
373
376
  __rolldown_runtime__.setup(new __WS(__hmrUrl));
374
377
  } catch(e) {
375
378
  // a swallowed failure here leaves the app permanently without Fast Refresh and
@@ -381,7 +384,7 @@ try {
381
384
  var outputProcessed = Promise.resolve();
382
385
  var engine;
383
386
  var routeWatcher;
384
- var rebuildIfRouteGraphChanged = function() {
387
+ var rebuildIfRouteGraphChanged = function rebuildIfRouteGraphChanged2() {
385
388
  return queueEngineWork(async function() {
386
389
  var { files: knownRoutes, scanFiles, updateFiles } = virtualEntry.routes;
387
390
  var currentRoutes = scanFiles();
@@ -393,8 +396,8 @@ try {
393
396
  });
394
397
  };
395
398
  engine = await dev(inputOptions, outputOptions, {
396
- onOutput: async function(result) {
397
- var finishOutput = function() {};
399
+ onOutput: async function onOutput(result) {
400
+ var finishOutput = function finishOutput2() {};
398
401
  outputProcessed = new Promise(function(resolve2) {
399
402
  finishOutput = resolve2;
400
403
  });
@@ -404,7 +407,7 @@ try {
404
407
  finishOutput();
405
408
  }
406
409
  },
407
- onHmrUpdates: async function(result) {
410
+ onHmrUpdates: async function onHmrUpdates(result) {
408
411
  if (result instanceof Error) {
409
412
  console.error("[vxrn] HMR error:", result.message);
410
413
  onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({ type: "hmr:error" });
@@ -512,11 +515,11 @@ try {
512
515
  if (!bundlePromise) {
513
516
  var timeoutId;
514
517
  bundlePromise = new Promise(function(resolve2, reject) {
515
- bundleResolve = function(value) {
518
+ bundleResolve = function bundleResolve2(value) {
516
519
  clearTimeout(timeoutId);
517
520
  resolve2(value);
518
521
  };
519
- bundleReject = function(error) {
522
+ bundleReject = function bundleReject2(error) {
520
523
  clearTimeout(timeoutId);
521
524
  reject(error);
522
525
  };
@@ -567,7 +570,10 @@ async function buildNativeBundle(options) {
567
570
  ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap, userPlugins),
568
571
  nativeBundlePostProcessPlugin()
569
572
  ],
570
- output: getNativeOutputOptions(prelude, sourcemap, minify)
573
+ output: {
574
+ ...getNativeOutputOptions(prelude, sourcemap, minify),
575
+ format: "iife"
576
+ }
571
577
  })).output.find(function(o) {
572
578
  return o.type === "chunk" && o.isEntry;
573
579
  });
@@ -618,7 +624,7 @@ globalThis.$RefreshReg$ = function(type, id) {
618
624
  };
619
625
  globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
620
626
  ` : "";
621
- var entryCode = function() {
627
+ var entryCode = function entryCode2() {
622
628
  return `
623
629
  ${refreshSetup}
624
630
  import * as ReactNativeInitializeCore from 'react-native/Libraries/Core/InitializeCore';
@@ -649,7 +655,7 @@ ${routeHmr}
649
655
  `;
650
656
  };
651
657
  var routeRoot = resolve(root, routerRoot);
652
- var stripDot = function(pattern) {
658
+ var stripDot = function stripDot2(pattern) {
653
659
  return pattern.replace(/^\.\//, "");
654
660
  };
655
661
  var includeGlobs = routeGlobs.filter(function(p) {
@@ -660,14 +666,14 @@ ${routeHmr}
660
666
  }).map(function(p) {
661
667
  return stripDot(p.slice(1));
662
668
  });
663
- var isRouteFile = function(file) {
669
+ var isRouteFile = function isRouteFile2(file) {
664
670
  var relativeToRoot = normalizePath(relative(root, file));
665
671
  return micromatch.isMatch(relativeToRoot, includeGlobs) && !micromatch.isMatch(relativeToRoot, excludeGlobs);
666
672
  };
667
- var scanFiles = function() {
673
+ var scanFiles = function scanFiles2() {
668
674
  var _statSync;
669
675
  var files = /* @__PURE__ */ new Set();
670
- var walkRouteRoot = function(dir) {
676
+ var walkRouteRoot = function walkRouteRoot1(dir) {
671
677
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
672
678
  try {
673
679
  for (var _iterator = readdirSync(dir, { withFileTypes: true })[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
@@ -700,16 +706,17 @@ ${routeHmr}
700
706
  updateFiles(files) {
701
707
  routes.files = files;
702
708
  if (!useDynamicRouteRegistry) return;
709
+ mkdirSync(dirname(registryPath), { recursive: true });
710
+ var registryDir = realpathSync(dirname(registryPath));
703
711
  var source = `export const routes = {
704
712
  ${[...files].sort().map(function(file) {
705
713
  var routeKey = `/${normalizePath(relative(root, file))}`;
706
- var importPath = normalizePath(relative(dirname(registryPath), file));
714
+ var importPath = normalizePath(relative(registryDir, file));
707
715
  if (!importPath.startsWith(".")) importPath = `./${importPath}`;
708
716
  return ` ${JSON.stringify(routeKey)}: () => import(${JSON.stringify(importPath)})`;
709
717
  }).join(",\n")}
710
718
  }
711
719
  `;
712
- mkdirSync(dirname(registryPath), { recursive: true });
713
720
  if (!existsSync(registryPath) || readFileSync(registryPath, "utf8") !== source) writeFileSync(registryPath, source);
714
721
  }
715
722
  };
@@ -779,6 +786,33 @@ function serverFileExclusionPlugin() {
779
786
  }
780
787
  };
781
788
  }
789
+ function missingDynamicImportPlugin() {
790
+ var PREFIX = "\0vxrn-missing-module:";
791
+ return {
792
+ name: "vxrn:missing-dynamic-import",
793
+ async resolveId(source, importer, options) {
794
+ if (options.kind !== "dynamic-import") return;
795
+ if (source.startsWith(".") || source.startsWith("/") || source.includes(":")) return;
796
+ if (source.startsWith("\0")) return;
797
+ var resolved = await this.resolve(source, importer, {
798
+ skipSelf: true,
799
+ kind: options.kind
800
+ });
801
+ if (resolved) return resolved;
802
+ return {
803
+ id: `${PREFIX}${source}`,
804
+ external: false
805
+ };
806
+ },
807
+ load(id) {
808
+ if (!id.startsWith(PREFIX)) return;
809
+ return {
810
+ code: `throw new Error(${JSON.stringify(`Cannot find module '${id.slice(21)}'`)});`,
811
+ moduleType: "js"
812
+ };
813
+ }
814
+ };
815
+ }
782
816
  function environmentGuardPlugin() {
783
817
  var THROWING = [
784
818
  "server-only",
@@ -829,6 +863,170 @@ export default HMRClient`,
829
863
  }
830
864
  };
831
865
  }
866
+ function nativeIdentityAliasPlugin(platform) {
867
+ var packages = /* @__PURE__ */ new Map();
868
+ var resolver;
869
+ var findPackage = function findPackage1(directory) {
870
+ if (packages.has(directory)) return packages.get(directory);
871
+ var result = null;
872
+ var manifest = join(directory, "package.json");
873
+ if (existsSync(manifest)) try {
874
+ var field = JSON.parse(readFileSync(manifest, "utf8"))["react-native"];
875
+ result = {
876
+ root: directory,
877
+ aliases: field && typeof field === "object" ? field : {}
878
+ };
879
+ } catch (unused) {}
880
+ else {
881
+ var parent = dirname(directory);
882
+ if (parent !== directory) result = findPackage(parent);
883
+ }
884
+ packages.set(directory, result);
885
+ return result;
886
+ };
887
+ return {
888
+ name: "vxrn:native-identity-alias",
889
+ async resolveId(source, importer) {
890
+ if (!importer || !source.startsWith(".")) return;
891
+ var pkg = findPackage(dirname(importer));
892
+ if (!pkg) return;
893
+ var key = `./${normalizePath(relative(pkg.root, resolve(dirname(importer), source)))}`;
894
+ if (pkg.aliases[key] !== key) return;
895
+ if (!resolver) {
896
+ var { ResolverFactory } = await import("rolldown/experimental");
897
+ resolver = new ResolverFactory({
898
+ ...getNativeResolveConfig(platform),
899
+ aliasFields: []
900
+ });
901
+ }
902
+ var result = resolver.sync(dirname(importer), source);
903
+ if (result.path) return result.path;
904
+ }
905
+ };
906
+ }
907
+ function nativeExportsPrecedencePlugin(root, platform) {
908
+ var manifests = /* @__PURE__ */ new Map();
909
+ var readManifest = function readManifest2(directory) {
910
+ if (!manifests.has(directory)) {
911
+ var manifest = null;
912
+ try {
913
+ manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
914
+ } catch (unused) {}
915
+ manifests.set(directory, manifest);
916
+ }
917
+ return manifests.get(directory);
918
+ };
919
+ var resolvers = /* @__PURE__ */ new Map();
920
+ return {
921
+ name: "vxrn:native-exports-precedence",
922
+ async resolveId(source, importer, options) {
923
+ var _ref;
924
+ var _readManifest, _readManifest1;
925
+ if (source.startsWith(".") || source.startsWith("/") || source.includes(":")) return;
926
+ var resolved = await this.resolve(source, importer, {
927
+ skipSelf: true,
928
+ kind: options.kind
929
+ });
930
+ if (!resolved || resolved.external || resolved.id.startsWith("\0")) return resolved;
931
+ var name = source.split("/").slice(0, source.startsWith("@") ? 2 : 1).join("/");
932
+ var directory = dirname(resolved.id);
933
+ while (((_readManifest = readManifest(directory)) === null || _readManifest === void 0 ? void 0 : _readManifest.name) !== name) {
934
+ if (dirname(directory) === directory) return resolved;
935
+ directory = dirname(directory);
936
+ }
937
+ var exportsMap = JSON.stringify((_ref = (_readManifest1 = readManifest(directory)) === null || _readManifest1 === void 0 ? void 0 : _readManifest1.exports) !== null && _ref !== void 0 ? _ref : null);
938
+ if (!exportsMap.includes("\"react-native\"") || !exportsMap.includes("\"browser\"")) return resolved;
939
+ var kind = options.kind === "require-call" ? "require" : "import";
940
+ var resolver = resolvers.get(kind);
941
+ if (!resolver) {
942
+ var { ResolverFactory } = await import("rolldown/experimental");
943
+ resolver = new ResolverFactory({
944
+ ...getNativeResolveConfig(platform),
945
+ conditionNames: [
946
+ "react-native",
947
+ kind,
948
+ "default"
949
+ ]
950
+ });
951
+ resolvers.set(kind, resolver);
952
+ }
953
+ var native = resolver.sync(importer ? dirname(importer) : root, source);
954
+ if (!native.path || native.path === resolved.id) return resolved;
955
+ return this.resolve(native.path, importer, {
956
+ skipSelf: true,
957
+ kind: options.kind
958
+ });
959
+ }
960
+ };
961
+ }
962
+ function nativeDeclarationAliasPlugin(root, platform) {
963
+ var resolvers = /* @__PURE__ */ new Map();
964
+ return {
965
+ name: "vxrn:declaration-alias",
966
+ async resolveId(source, importer, options) {
967
+ if (source.startsWith(".") || source.startsWith("/") || source.includes(":")) return;
968
+ var resolved = await this.resolve(source, importer, {
969
+ skipSelf: true,
970
+ kind: options.kind
971
+ });
972
+ if (!resolved || resolved.external || !/\.d\.[cm]?ts$/.test(resolved.id)) return resolved;
973
+ var kind = options.kind === "require-call" ? "require" : "import";
974
+ var resolver = resolvers.get(kind);
975
+ if (!resolver) {
976
+ var { ResolverFactory } = await import("rolldown/experimental");
977
+ resolver = new ResolverFactory({
978
+ ...getNativeResolveConfig(platform),
979
+ conditionNames: [
980
+ "react-native",
981
+ "browser",
982
+ kind,
983
+ "default"
984
+ ]
985
+ });
986
+ resolvers.set(kind, resolver);
987
+ }
988
+ var runtime = resolver.sync(importer ? dirname(importer) : root, source);
989
+ if (!runtime.path || /\.d\.[cm]?ts$/.test(runtime.path)) this.error(`Native import ${source} resolves to a declaration without a runtime export`);
990
+ return this.resolve(runtime.path, importer, {
991
+ skipSelf: true,
992
+ kind: options.kind
993
+ });
994
+ }
995
+ };
996
+ }
997
+ function nativeAssetRegistryPlugin(root) {
998
+ var registryPath;
999
+ return {
1000
+ name: "vxrn:asset-registry",
1001
+ async resolveId(source, importer) {
1002
+ if (source !== "react-native/asset-registry" && source !== "@react-native/assets-registry/registry") return;
1003
+ if (registryPath === void 0) try {
1004
+ var reactNativeRoot = dirname(resolvePath("react-native/package.json", root));
1005
+ var exportedRegistry = join(reactNativeRoot, "src/asset-registry.js");
1006
+ registryPath = existsSync(exportedRegistry) ? exportedRegistry : resolvePath("@react-native/assets-registry/registry", reactNativeRoot);
1007
+ } catch (unused) {
1008
+ registryPath = null;
1009
+ }
1010
+ if (registryPath) return this.resolve(normalizePath(registryPath), importer, { skipSelf: true });
1011
+ }
1012
+ };
1013
+ }
1014
+ function nativePackageDedupePlugin(root) {
1015
+ var packages = /* @__PURE__ */ new Set([
1016
+ ...dedupe,
1017
+ "react-native-worklets",
1018
+ "react-native-nitro-modules"
1019
+ ]);
1020
+ return {
1021
+ name: "vxrn:native-package-dedupe",
1022
+ async resolveId(source) {
1023
+ var parts = source.split("/");
1024
+ var packageName = source.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
1025
+ if (!packages.has(packageName)) return;
1026
+ return this.resolve(source, join(root, "package.json"), { skipSelf: true });
1027
+ }
1028
+ };
1029
+ }
832
1030
  function reactNativeDedupePlugin(root) {
833
1031
  var reactNativeRoot;
834
1032
  return {
@@ -860,7 +1058,7 @@ function cssStubPlugin() {
860
1058
  function vxrnCompilerPlugin(platform, dev) {
861
1059
  var projectRoot = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : process.cwd(), sourceMaps = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
862
1060
  var compiler = null;
863
- var isRefreshCandidate = function(id) {
1061
+ var isRefreshCandidate = function isRefreshCandidate2(id) {
864
1062
  return dev && !id.includes("node_modules") && !id.includes("__virtual-native-entry") && /\.[tj]sx?$/.test(id);
865
1063
  };
866
1064
  return {
@@ -883,7 +1081,7 @@ function vxrnCompilerPlugin(platform, dev) {
883
1081
  var babelOptions = compiler.getBabelOptions(props);
884
1082
  var curCode = code;
885
1083
  var intermediateMaps = [];
886
- var isWorkletPlugin = function(entry) {
1084
+ var isWorkletPlugin = function isWorkletPlugin2(entry) {
887
1085
  if (!entry) return false;
888
1086
  var name = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : null;
889
1087
  return typeof name === "string" && (name.includes("react-native-worklets") || name.includes("react-native-reanimated"));
@@ -1297,12 +1495,12 @@ function hermesCompatSWCPlugin(dev) {
1297
1495
  var _ref;
1298
1496
  if (!/\.[cm]?[jt]sx?$/.test(id)) return;
1299
1497
  if (id.includes("\0") || id.includes("virtual:")) return;
1300
- var hasClass = code.includes("class ") || code.includes("class{");
1498
+ var hasClass = /\bclass(?:\s|\{)/.test(code);
1301
1499
  var hasAsync = code.includes("async");
1302
- var hasBlockScopedLoop = /\bfor\s*\(\s*(?:const|let)\b/.test(code);
1303
- if (!hasClass && !hasAsync && !hasBlockScopedLoop) return;
1500
+ var hasBlockScopedBinding = /\b(?:const|let)\s/.test(code);
1501
+ if (!hasClass && !hasAsync && !hasBlockScopedBinding) return;
1304
1502
  var output;
1305
- if (code.length <= 5e5) {
1503
+ if (code.length <= 5e5 || hasClass) {
1306
1504
  var _result_errors;
1307
1505
  if (!oxc) oxc = await import("oxc-transform");
1308
1506
  var lang = /\.[cm]?ts$/.test(id) ? "ts" : id.endsWith(".tsx") ? "tsx" : "jsx";
@@ -1324,11 +1522,25 @@ ${err.codeframe}` : ""));
1324
1522
  map: sourceMaps ? result.map : void 0
1325
1523
  };
1326
1524
  }
1525
+ if (hasClass || hasBlockScopedBinding) {
1526
+ var _ref1;
1527
+ var { transformHermesClasses } = await import("@vxrn/compiler");
1528
+ var classes = await transformHermesClasses((_ref1 = output === null || output === void 0 ? void 0 : output.code) !== null && _ref1 !== void 0 ? _ref1 : code, id, sourceMaps);
1529
+ if (classes) {
1530
+ if (classes.map && (output === null || output === void 0 ? void 0 : output.map)) {
1531
+ var remapping = (await import("@jridgewell/remapping")).default;
1532
+ classes.map = remapping([classes.map, output.map], function() {
1533
+ return null;
1534
+ });
1535
+ }
1536
+ output = classes;
1537
+ }
1538
+ }
1327
1539
  var lowered = await transformHermesAsync((_ref = output === null || output === void 0 ? void 0 : output.code) !== null && _ref !== void 0 ? _ref : code, id, sourceMaps);
1328
1540
  if (!lowered) return output;
1329
1541
  if (lowered.map && (output === null || output === void 0 ? void 0 : output.map)) {
1330
- var remapping = (await import("@jridgewell/remapping")).default;
1331
- lowered.map = remapping([lowered.map, output.map], function() {
1542
+ var remapping1 = (await import("@jridgewell/remapping")).default;
1543
+ lowered.map = remapping1([lowered.map, output.map], function() {
1332
1544
  return null;
1333
1545
  });
1334
1546
  }