vxrn 1.25.16 → 1.26.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 (72) hide show
  1. package/dist/index.js +2 -0
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +2 -0
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/index.native.js +2 -0
  6. package/dist/index.native.js.map +1 -1
  7. package/dist/patches/builtInDepPatches.mjs +21 -0
  8. package/dist/patches/builtInDepPatches.mjs.map +1 -1
  9. package/dist/patches/builtInDepPatches.native.js +21 -0
  10. package/dist/patches/builtInDepPatches.native.js.map +1 -1
  11. package/dist/plugins/reactNativeDevServer.mjs +5 -0
  12. package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
  13. package/dist/plugins/reactNativeDevServer.native.js +5 -0
  14. package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
  15. package/dist/plugins/rnCodegenPlugin.mjs +16 -0
  16. package/dist/plugins/rnCodegenPlugin.mjs.map +1 -0
  17. package/dist/plugins/rnCodegenPlugin.native.js +16 -0
  18. package/dist/plugins/rnCodegenPlugin.native.js.map +1 -0
  19. package/dist/plugins/rnCodegenPlugin.test.mjs +239 -0
  20. package/dist/plugins/rnCodegenPlugin.test.mjs.map +1 -0
  21. package/dist/plugins/rnCodegenPlugin.test.native.js +242 -0
  22. package/dist/plugins/rnCodegenPlugin.test.native.js.map +1 -0
  23. package/dist/plugins/workletImportsPlugin.mjs +160 -0
  24. package/dist/plugins/workletImportsPlugin.mjs.map +1 -0
  25. package/dist/plugins/workletImportsPlugin.native.js +230 -0
  26. package/dist/plugins/workletImportsPlugin.native.js.map +1 -0
  27. package/dist/utils/createNativeDevEngine.mjs +198 -92
  28. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  29. package/dist/utils/createNativeDevEngine.native.js +252 -99
  30. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  31. package/dist/utils/createNativeDevEngine.test.mjs +775 -4
  32. package/dist/utils/createNativeDevEngine.test.mjs.map +1 -1
  33. package/dist/utils/createNativeDevEngine.test.native.js +836 -4
  34. package/dist/utils/createNativeDevEngine.test.native.js.map +1 -1
  35. package/dist/utils/patches.mjs +12 -5
  36. package/dist/utils/patches.mjs.map +1 -1
  37. package/dist/utils/patches.native.js +13 -5
  38. package/dist/utils/patches.native.js.map +1 -1
  39. package/dist/utils/patches.test.mjs +28 -0
  40. package/dist/utils/patches.test.mjs.map +1 -1
  41. package/dist/utils/patches.test.native.js +47 -0
  42. package/dist/utils/patches.test.native.js.map +1 -1
  43. package/dist/utils/scanDepsToOptimize.mjs +5 -1
  44. package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
  45. package/dist/utils/scanDepsToOptimize.native.js +5 -1
  46. package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
  47. package/package.json +19 -12
  48. package/src/index.ts +2 -0
  49. package/src/patches/builtInDepPatches.ts +25 -0
  50. package/src/plugins/reactNativeDevServer.ts +12 -0
  51. package/src/plugins/rnCodegenPlugin.test.ts +313 -0
  52. package/src/plugins/rnCodegenPlugin.ts +20 -0
  53. package/src/plugins/workletImportsPlugin.ts +226 -0
  54. package/src/utils/createNativeDevEngine.test.ts +877 -3
  55. package/src/utils/createNativeDevEngine.ts +259 -107
  56. package/src/utils/patches.test.ts +33 -0
  57. package/src/utils/patches.ts +17 -6
  58. package/src/utils/scanDepsToOptimize.ts +9 -0
  59. package/types/index.d.ts +2 -0
  60. package/types/index.d.ts.map +1 -1
  61. package/types/patches/builtInDepPatches.d.ts.map +1 -1
  62. package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
  63. package/types/plugins/rnCodegenPlugin.d.ts +6 -0
  64. package/types/plugins/rnCodegenPlugin.d.ts.map +1 -0
  65. package/types/plugins/rnCodegenPlugin.test.d.ts +2 -0
  66. package/types/plugins/rnCodegenPlugin.test.d.ts.map +1 -0
  67. package/types/plugins/workletImportsPlugin.d.ts +8 -0
  68. package/types/plugins/workletImportsPlugin.d.ts.map +1 -0
  69. package/types/utils/createNativeDevEngine.d.ts +13 -0
  70. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
  71. package/types/utils/patches.d.ts.map +1 -1
  72. package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
@@ -3,12 +3,13 @@ import { basename, dirname, extname, join, relative, resolve } from "path";
3
3
  import { copyFileSync, mkdirSync, readFileSync, readdirSync, realpathSync } from "fs";
4
4
  import { pathToFileURL } from "url";
5
5
  import { loadEnv, normalizePath } from "vite";
6
+ import { shouldStripFlow, transformHermesAsync } from "@vxrn/compiler";
6
7
  import { DEFAULT_ASSET_EXTS } from "../constants/defaults.native.js";
7
8
  import { getNativePrelude } from "../runtime/native-prelude.native.js";
9
+ import { rnCodegenPlugin } from "../plugins/rnCodegenPlugin.native.js";
8
10
  function _instanceof(left, right) {
9
11
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);else return left instanceof right;
10
12
  }
11
- var FLOW_FILE_PATTERN = /node_modules[\\/](?:react-native|@react-native)[\\/].*\.js$/;
12
13
  var 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"];
13
14
  var HERMES_ASYNC_TRANSFORMS = ["transform-async-to-generator"];
14
15
  function getHermesSWCIncludes(dev) {
@@ -58,17 +59,14 @@ function getNativeTransformConfig(platform, dev, root) {
58
59
  })
59
60
  };
60
61
  }();
61
- var mode = dev ? "development" : "production";
62
- var publicEnv = loadEnv(mode, root, ["VITE_", "EXPO_PUBLIC_"]);
63
- var envDefines = {};
62
+ var userDefines = {};
64
63
  var _iteratorNormalCompletion = true,
65
64
  _didIteratorError = false,
66
65
  _iteratorError = void 0;
67
66
  try {
68
- for (var _iterator = Object.entries(publicEnv)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
67
+ for (var _iterator = Object.entries(globalThis.__vxrnNativeUserDefine || {})[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
69
68
  var [key, value] = _step.value;
70
- envDefines[`import.meta.env.${key}`] = JSON.stringify(value);
71
- envDefines[`process.env.${key}`] = JSON.stringify(value);
69
+ userDefines[key] = typeof value === "string" ? value : JSON.stringify(value);
72
70
  }
73
71
  } catch (err) {
74
72
  _didIteratorError = true;
@@ -80,6 +78,28 @@ function getNativeTransformConfig(platform, dev, root) {
80
78
  if (_didIteratorError) throw _iteratorError;
81
79
  }
82
80
  }
81
+ var mode = dev ? "development" : "production";
82
+ var publicEnv = loadEnv(mode, root, ["VITE_", "EXPO_PUBLIC_"]);
83
+ var envDefines = {};
84
+ var _iteratorNormalCompletion1 = true,
85
+ _didIteratorError1 = false,
86
+ _iteratorError1 = void 0;
87
+ try {
88
+ for (var _iterator1 = Object.entries(publicEnv)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
89
+ var [key1, value1] = _step1.value;
90
+ envDefines[`import.meta.env.${key1}`] = JSON.stringify(value1);
91
+ envDefines[`process.env.${key1}`] = JSON.stringify(value1);
92
+ }
93
+ } catch (err) {
94
+ _didIteratorError1 = true;
95
+ _iteratorError1 = err;
96
+ } finally {
97
+ try {
98
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) _iterator1.return();
99
+ } finally {
100
+ if (_didIteratorError1) throw _iteratorError1;
101
+ }
102
+ }
83
103
  var envObject = {
84
104
  ...publicEnv,
85
105
  MODE: mode,
@@ -97,6 +117,7 @@ function getNativeTransformConfig(platform, dev, root) {
97
117
  runtime: "classic"
98
118
  },
99
119
  define: {
120
+ ...userDefines,
100
121
  ...envDefines,
101
122
  "process.env.NODE_ENV": JSON.stringify(mode),
102
123
  "process.env.VXRN_REACT_19": "false",
@@ -127,12 +148,14 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest,
127
148
  var sourceMaps = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : false;
128
149
  return [...(globalThis.__vxrnAddNativePlugins || []), serverFileExclusionPlugin(), environmentGuardPlugin(), hmrClientNoopPlugin(), cssStubPlugin(), viteImportGlobPlugin({
129
150
  root
130
- }), vxrnCompilerPlugin(platform, dev, root, sourceMaps), flowStripPlugin(), nativeAnimatedGuardPlugin(), assetPlugin({
151
+ }), vxrnCompilerPlugin(platform, dev, root, sourceMaps), rnCodegenPlugin({
152
+ projectRoot: root
153
+ }), flowStripPlugin(), nativeAnimatedGuardPlugin(), assetPlugin({
131
154
  root,
132
155
  platform,
133
156
  assetsDest,
134
157
  onAsset
135
- }), hermesCompatSWCPlugin(dev, sourceMaps)];
158
+ }), hermesCompatSWCPlugin(dev, sourceMaps), hermesLoopsPlugin(sourceMaps)];
136
159
  }
137
160
  function getNativeOutputOptions(prelude, sourcemap) {
138
161
  return {
@@ -144,7 +167,7 @@ function getNativeOutputOptions(prelude, sourcemap) {
144
167
  };
145
168
  }
146
169
  function normalizeNativeCommonJSInterop(code) {
147
- return code.replace(/(\b__toESM(?:\$\d+)?\(\s*require[\w$]*\(\)\s*),\s*1(\s*\))/g, "$1$2");
170
+ return code.replace(/(\b__toESM(?:\$\d+)?\(\s*(?:require[\w$]*\(\)|__rolldown_runtime__\.loadExports\("(?:\\.|[^"\\])*"\))\s*),\s*1(\s*\))/g, "$1$2");
148
171
  }
149
172
  function postProcessNativeBundle(code) {
150
173
  code = normalizeNativeCommonJSInterop(code);
@@ -176,7 +199,7 @@ function wrapNativeBundleModuleScope(code) {
176
199
  }
177
200
  async function downlevelClassFieldsInBundle(code) {
178
201
  var _ref, _ref1;
179
- var _runtimeSection_match, _transformed_match;
202
+ var _runtimeSection_match, _result_errors, _transformed_match;
180
203
  var startMarker = "//#region \\0rolldown/runtime.js";
181
204
  var endMarker = "//#endregion";
182
205
  var startIdx = code.indexOf(startMarker);
@@ -186,36 +209,19 @@ async function downlevelClassFieldsInBundle(code) {
186
209
  var runtimeEnd = endIdx + endMarker.length;
187
210
  var runtimeSection = code.slice(startIdx, runtimeEnd);
188
211
  var originalNewlines = (_ref = (_runtimeSection_match = runtimeSection.match(/\n/g)) === null || _runtimeSection_match === void 0 ? void 0 : _runtimeSection_match.length) !== null && _ref !== void 0 ? _ref : 0;
189
- var transformedCode = (await (await import("@swc/core")).transform(runtimeSection, {
190
- filename: "rolldown-runtime.js",
191
- configFile: false,
192
- swcrc: false,
193
- sourceMaps: false,
194
- inputSourceMap: false,
195
- isModule: false,
196
- minify: true,
197
- env: {
198
- targets: {
199
- node: 9999
200
- },
201
- include: [...HERMES_CLASS_TRANSFORMS]
202
- },
203
- jsc: {
204
- parser: {
205
- syntax: "ecmascript"
206
- },
207
- transform: {
208
- react: {
209
- runtime: "preserve"
210
- }
211
- },
212
- externalHelpers: false,
213
- assumptions: {
214
- setPublicClassFields: true,
215
- privateFieldsAsProperties: true
216
- }
212
+ var {
213
+ transformSync
214
+ } = await import("oxc-transform");
215
+ var result = transformSync("rolldown-runtime.js", runtimeSection, {
216
+ target: "es2020",
217
+ assumptions: {
218
+ setPublicClassFields: true
217
219
  }
218
- })).code.trimEnd();
220
+ });
221
+ if ((_result_errors = result.errors) === null || _result_errors === void 0 ? void 0 : _result_errors.length) throw new Error(result.errors.map(function (e) {
222
+ return e.message;
223
+ }).join("\n"));
224
+ var transformedCode = result.code.trimEnd();
219
225
  var transformed = transformedCode.includes(startMarker) ? transformedCode : `${startMarker}
220
226
  ${transformedCode}`;
221
227
  var transformedNewlines = (_ref1 = (_transformed_match = transformed.match(/\n/g)) === null || _transformed_match === void 0 ? void 0 : _transformed_match.length) !== null && _ref1 !== void 0 ? _ref1 : 0;
@@ -360,7 +366,7 @@ try {
360
366
  if (update.type === "Patch" && update.code) onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({
361
367
  type: "hmr:update",
362
368
  clientId,
363
- code: update.code,
369
+ code: normalizeNativeCommonJSInterop(update.code),
364
370
  changedIds: update.changedIds,
365
371
  seq: update.seq
366
372
  });else if (update.type === "FullReload") onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({
@@ -639,6 +645,8 @@ function vxrnCompilerPlugin(platform, dev) {
639
645
  return {
640
646
  name: "vxrn:compiler",
641
647
  async transform(code, id) {
648
+ var _ref;
649
+ var _babelOptions_plugins, _babelOptions_plugins1;
642
650
  if (!/\.[cm]?[jt]sx?$/.test(id)) return;
643
651
  if (id.includes("\0") || id.includes("virtual:")) return;
644
652
  var needsRefresh = isRefreshCandidate(id);
@@ -652,28 +660,128 @@ function vxrnCompilerPlugin(platform, dev) {
652
660
  reactForRNVersion: "19"
653
661
  };
654
662
  var babelOptions = compiler.getBabelOptions(props);
655
- if (needsRefresh) {
656
- var existingPlugins = (babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) || [];
663
+ var curCode = code;
664
+ var intermediateMaps = [];
665
+ var isWorkletPlugin = function (entry) {
666
+ if (!entry) return false;
667
+ var name = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : null;
668
+ return typeof name === "string" && (name.includes("react-native-worklets") || name.includes("react-native-reanimated"));
669
+ };
670
+ var workletEntry = babelOptions === null || babelOptions === void 0 ? void 0 : (_babelOptions_plugins = babelOptions.plugins) === null || _babelOptions_plugins === void 0 ? void 0 : _babelOptions_plugins.find(isWorkletPlugin);
671
+ var workletPluginOptions = Array.isArray(workletEntry) ? workletEntry[1] : void 0;
672
+ var useWorklets = compiler.isNativeWorkletsEnabled() && (Boolean(workletEntry) || compiler.shouldTransformWorklets({
673
+ id,
674
+ code
675
+ }));
676
+ var compilerPluginIndex = (_ref = babelOptions === null || babelOptions === void 0 ? void 0 : (_babelOptions_plugins1 = babelOptions.plugins) === null || _babelOptions_plugins1 === void 0 ? void 0 : _babelOptions_plugins1.findIndex(function (x) {
677
+ return Array.isArray(x) && x[0] === "babel-plugin-react-compiler";
678
+ })) !== null && _ref !== void 0 ? _ref : -1;
679
+ if (compilerPluginIndex !== -1) {
680
+ var _ref1;
681
+ var _babelOptions_plugins_compilerPluginIndex_;
682
+ if (useWorklets) {
683
+ var prepared = compiler.prepareWorkletsForReactCompiler(id, curCode, sourceMaps);
684
+ if (prepared) {
685
+ curCode = prepared.code;
686
+ if (prepared.map) intermediateMaps.push(prepared.map);
687
+ }
688
+ }
689
+ var compilerTarget = (_ref1 = (_babelOptions_plugins_compilerPluginIndex_ = babelOptions.plugins[compilerPluginIndex][1]) === null || _babelOptions_plugins_compilerPluginIndex_ === void 0 ? void 0 : _babelOptions_plugins_compilerPluginIndex_.target) !== null && _ref1 !== void 0 ? _ref1 : "19";
690
+ var compilerOut = await compiler.transformOxcReactCompiler(id, curCode, compilerTarget, sourceMaps);
691
+ if (compilerOut === null || compilerOut === void 0 ? void 0 : compilerOut.code) {
692
+ curCode = compilerOut.code;
693
+ if (sourceMaps && compilerOut.map) intermediateMaps.push(compilerOut.map);
694
+ }
695
+ babelOptions.plugins.splice(compilerPluginIndex, 1);
696
+ if (babelOptions.plugins.length === 0) babelOptions = null;
697
+ }
698
+ if (useWorklets) {
699
+ var workletOut = await compiler.transformWorklets(id, curCode, sourceMaps, {
700
+ projectRoot,
701
+ ...workletPluginOptions
702
+ });
703
+ if (workletOut === null || workletOut === void 0 ? void 0 : workletOut.code) {
704
+ curCode = workletOut.code;
705
+ if (sourceMaps && workletOut.map) intermediateMaps.push(workletOut.map);
706
+ }
707
+ if (babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) {
708
+ babelOptions.plugins = babelOptions.plugins.filter(function (entry) {
709
+ return !isWorkletPlugin(entry);
710
+ });
711
+ if (babelOptions.plugins.length === 0) babelOptions = null;
712
+ }
713
+ }
714
+ if (!babelOptions && !needsRefresh) {
715
+ if (curCode !== code) {
716
+ var finalMap = void 0;
717
+ if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap = intermediateMaps[0];else {
718
+ var remapping = (await import("@jridgewell/remapping")).default;
719
+ finalMap = remapping(intermediateMaps.slice().reverse(), function () {
720
+ return null;
721
+ });
722
+ }
723
+ return {
724
+ code: curCode,
725
+ map: finalMap
726
+ };
727
+ }
728
+ return;
729
+ }
730
+ if (sourceMaps && babelOptions) {
657
731
  babelOptions = {
658
732
  ...babelOptions,
659
- plugins: [...existingPlugins, ["react-refresh/babel", {
660
- skipEnvCheck: true,
661
- refreshReg: "__vxrnRefreshReg",
662
- refreshSig: "__vxrnRefreshSig"
663
- }]]
733
+ sourceMaps: true,
734
+ sourceFileName: id
664
735
  };
736
+ delete babelOptions.inputSourceMap;
665
737
  }
666
- if (!babelOptions) return;
667
- if (sourceMaps) babelOptions = {
668
- ...babelOptions,
669
- sourceMaps: true,
670
- sourceFileName: id
671
- };
672
- var result = await compiler.transformBabel(id, code, babelOptions);
673
- if (result === null || result === void 0 ? void 0 : result.code) {
674
- var out = result.code;
675
- if (needsRefresh) out = `
676
- var __prevRefreshReg = globalThis.$RefreshReg$;
738
+ if (babelOptions) {
739
+ var result = await compiler.transformBabel(id, curCode, babelOptions);
740
+ if (result === null || result === void 0 ? void 0 : result.code) {
741
+ curCode = result.code;
742
+ if (sourceMaps && result.map) intermediateMaps.push(result.map);
743
+ if (!needsRefresh) {
744
+ var finalMap1 = void 0;
745
+ if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap1 = intermediateMaps[0];else {
746
+ var remapping1 = (await import("@jridgewell/remapping")).default;
747
+ finalMap1 = remapping1(intermediateMaps.slice().reverse(), function () {
748
+ return null;
749
+ });
750
+ }
751
+ return {
752
+ code: curCode,
753
+ map: finalMap1
754
+ };
755
+ }
756
+ }
757
+ }
758
+ if (needsRefresh) {
759
+ var _compiler_configuration;
760
+ var {
761
+ transformSync
762
+ } = await import("oxc-transform-react");
763
+ var jsxImportSource = ((_compiler_configuration = compiler.configuration) === null || _compiler_configuration === void 0 ? void 0 : _compiler_configuration.enableNativewind) && !id.includes("node_modules") ? "nativewind" : "react";
764
+ var res = transformSync(id, curCode, {
765
+ jsx: {
766
+ development: dev,
767
+ runtime: "automatic",
768
+ importSource: jsxImportSource,
769
+ refresh: {
770
+ refreshReg: "__vxrnRefreshReg",
771
+ refreshSig: "__vxrnRefreshSig"
772
+ }
773
+ },
774
+ reactCompiler: false,
775
+ sourcemap: sourceMaps
776
+ });
777
+ if (res.fatal) {
778
+ var _res_errors;
779
+ throw new Error(`[vxrn:compiler] oxc react transform failed on ${id}: ${((_res_errors = res.errors) !== null && _res_errors !== void 0 ? _res_errors : []).map(function (e) {
780
+ var _e_message;
781
+ return (_e_message = e.message) !== null && _e_message !== void 0 ? _e_message : String(e);
782
+ }).join(", ")}`);
783
+ }
784
+ var header = `var __prevRefreshReg = globalThis.$RefreshReg$;
677
785
  var __prevRefreshSig = globalThis.$RefreshSig$;
678
786
  if (globalThis.__ReactRefresh) {
679
787
  globalThis.$RefreshReg$ = function(type, id) {
@@ -685,7 +793,8 @@ if (globalThis.__ReactRefresh) {
685
793
  var __vxrnRefreshReg = globalThis.$RefreshReg$;
686
794
  var __vxrnRefreshSig = globalThis.$RefreshSig$;
687
795
 
688
- ${out}
796
+ `;
797
+ var footer = `
689
798
 
690
799
  globalThis.$RefreshReg$ = __prevRefreshReg;
691
800
  globalThis.$RefreshSig$ = __prevRefreshSig;
@@ -697,9 +806,26 @@ if (import.meta.hot) {
697
806
  });
698
807
  }
699
808
  `;
809
+ var out;
810
+ var finalMap2 = void 0;
811
+ if (sourceMaps) {
812
+ var MagicString = (await import("magic-string")).default;
813
+ var ms = new MagicString(res.code);
814
+ ms.prepend(header);
815
+ ms.append(footer);
816
+ out = ms.toString();
817
+ var allMaps = [ms.generateMap({
818
+ source: id,
819
+ hires: true
820
+ }), res.map, ...intermediateMaps.slice().reverse()].filter(Boolean);
821
+ var remapping2 = (await import("@jridgewell/remapping")).default;
822
+ finalMap2 = remapping2(allMaps, function () {
823
+ return null;
824
+ });
825
+ } else out = header + res.code + footer;
700
826
  return {
701
827
  code: out,
702
- map: sourceMaps ? result.map : void 0
828
+ map: finalMap2
703
829
  };
704
830
  }
705
831
  }
@@ -710,7 +836,7 @@ function flowStripPlugin() {
710
836
  name: "vxrn:flow-strip",
711
837
  transform: {
712
838
  async handler(code, id) {
713
- if (!FLOW_FILE_PATTERN.test(id)) return;
839
+ if (!shouldStripFlow(id, code)) return;
714
840
  var result = await (await import("fast-flow-transform")).default({
715
841
  filename: id,
716
842
  source: code,
@@ -932,53 +1058,80 @@ function copyNativeAssetFiles(asset, assetsDest, platform) {
932
1058
  }
933
1059
  function hermesCompatSWCPlugin(dev) {
934
1060
  var sourceMaps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
935
- var swc = null;
1061
+ var oxc = null;
936
1062
  return {
937
1063
  name: "vxrn:hermes-compat",
938
1064
  async transform(code, id) {
1065
+ var _ref;
939
1066
  if (!/\.[cm]?[jt]sx?$/.test(id)) return;
940
1067
  if (id.includes("\0") || id.includes("virtual:")) return;
941
1068
  var hasClass = code.includes("class ") || code.includes("class{");
942
- var hasAsync = code.includes("async ");
1069
+ var hasAsync = code.includes("async");
943
1070
  var hasBlockScopedLoop = /\bfor\s*\(\s*(?:const|let)\b/.test(code);
944
1071
  if (!hasClass && !hasAsync && !hasBlockScopedLoop) return;
945
- if (code.length > 5e5) return;
946
- if (!swc) swc = await import("@swc/core");
947
- var envIncludes = getHermesSWCIncludes(dev);
948
- var result = await swc.transform(code, {
949
- filename: id,
950
- configFile: false,
951
- swcrc: false,
952
- sourceMaps,
953
- sourceFileName: sourceMaps ? id : void 0,
954
- inputSourceMap: false,
955
- env: {
956
- targets: {
957
- node: 9999
958
- },
959
- include: envIncludes
960
- },
961
- jsc: {
962
- parser: {
963
- syntax: "typescript",
964
- tsx: true
965
- },
966
- transform: {
967
- react: {
968
- runtime: "preserve"
969
- }
970
- },
971
- externalHelpers: false,
1072
+ var output;
1073
+ if (code.length <= 5e5) {
1074
+ var _result_errors;
1075
+ if (!oxc) oxc = await import("oxc-transform");
1076
+ var lang = /\.[cm]?ts$/.test(id) ? "ts" : id.endsWith(".tsx") ? "tsx" : "jsx";
1077
+ var result = oxc.transformSync(id, code, {
1078
+ lang,
1079
+ target: "es2020",
972
1080
  assumptions: {
973
- setPublicClassFields: true,
974
- privateFieldsAsProperties: true
975
- }
976
- },
977
- isModule: !id.endsWith(".cjs")
978
- });
1081
+ setPublicClassFields: true
1082
+ },
1083
+ jsx: "preserve",
1084
+ sourcemap: sourceMaps,
1085
+ sourceType: id.endsWith(".cjs") ? "script" : "module"
1086
+ });
1087
+ if ((_result_errors = result.errors) === null || _result_errors === void 0 ? void 0 : _result_errors.length) {
1088
+ var err = result.errors[0];
1089
+ throw new Error(err.message + (err.codeframe ? `
1090
+ ${err.codeframe}` : ""));
1091
+ }
1092
+ output = {
1093
+ code: result.code,
1094
+ map: sourceMaps ? result.map : void 0
1095
+ };
1096
+ }
1097
+ var lowered = await transformHermesAsync((_ref = output === null || output === void 0 ? void 0 : output.code) !== null && _ref !== void 0 ? _ref : code, id, sourceMaps);
1098
+ if (!lowered) return output;
1099
+ if (lowered.map && (output === null || output === void 0 ? void 0 : output.map)) {
1100
+ var remapping = (await import("@jridgewell/remapping")).default;
1101
+ lowered.map = remapping([lowered.map, output.map], function () {
1102
+ return null;
1103
+ });
1104
+ }
1105
+ return lowered;
1106
+ }
1107
+ };
1108
+ }
1109
+ var hermesCompatPlugin = hermesCompatSWCPlugin;
1110
+ function hermesLoopsPlugin() {
1111
+ var sourceMaps = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
1112
+ var compiler = null;
1113
+ return {
1114
+ name: "vxrn:hermes-loops",
1115
+ async transform(code, id) {
1116
+ if (!/\.[cm]?[jt]sx?$/.test(id)) return;
1117
+ if (id.includes("\0") || id.includes("virtual:")) return;
1118
+ if (!compiler) compiler = await import("@vxrn/compiler");
1119
+ var result = compiler.transformHermesLoops(code, id);
1120
+ if (!result) return;
1121
+ if (!sourceMaps) return {
1122
+ code: result.code,
1123
+ map: null
1124
+ };
1125
+ if (result.maps.length === 1) return {
1126
+ code: result.code,
1127
+ map: result.maps[0]
1128
+ };
1129
+ var remapping = (await import("@jridgewell/remapping")).default;
979
1130
  return {
980
1131
  code: result.code,
981
- map: sourceMaps ? result.map : void 0
1132
+ map: remapping(result.maps.slice().reverse(), function () {
1133
+ return null;
1134
+ })
982
1135
  };
983
1136
  }
984
1137
  };
@@ -1184,5 +1337,5 @@ class ReactNativeDevRuntime extends BaseDevRuntime {
1184
1337
  globalThis.__rolldown_runtime__ = new ReactNativeDevRuntime();
1185
1338
  `;
1186
1339
  }
1187
- export { buildNativeBundle, createNativeDevAssetRegistry, createNativeDevEngine, getHermesSWCIncludes, getHmrRuntimeSource, getNativeAssetData, getNativeTransformConfig, hermesCompatSWCPlugin, hmrClientNoopPlugin, nativeAnimatedGuardPlugin, normalizeNativeCommonJSInterop, vxrnCompilerPlugin, wrapNativeBundleModuleScope };
1340
+ export { buildNativeBundle, createNativeDevAssetRegistry, createNativeDevEngine, getHermesSWCIncludes, getHmrRuntimeSource, getNativeAssetData, getNativeTransformConfig, hermesCompatPlugin, hermesCompatSWCPlugin, hermesLoopsPlugin, hmrClientNoopPlugin, nativeAnimatedGuardPlugin, normalizeNativeCommonJSInterop, vxrnCompilerPlugin, wrapNativeBundleModuleScope };
1188
1341
  //# sourceMappingURL=createNativeDevEngine.native.js.map