@vxrn/compiler 2.0.0-beta.33.1 → 2.0.0-beta.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/cjs/cache.cjs +112 -109
  2. package/dist/cjs/configure.cjs +26 -28
  3. package/dist/cjs/constants.cjs +56 -60
  4. package/dist/cjs/index.cjs +420 -438
  5. package/dist/cjs/reactNativeCodegen.cjs +105 -114
  6. package/dist/cjs/reactNativeViewConfig.cjs +362 -381
  7. package/dist/cjs/refresh-runtime.cjs +390 -397
  8. package/dist/cjs/transformBabel.cjs +278 -218
  9. package/dist/cjs/transformHermesAsync.cjs +36 -47
  10. package/dist/cjs/transformHermesLoops.cjs +279 -281
  11. package/dist/cjs/transformSWC.cjs +183 -200
  12. package/dist/cjs/transformWorklets.cjs +107 -95
  13. package/dist/cjs/types.cjs +9 -11
  14. package/dist/cjs/worklets/autoworklet.cjs +277 -222
  15. package/dist/cjs/worklets/globals.cjs +124 -60
  16. package/dist/cjs/worklets/hash.cjs +23 -27
  17. package/dist/cjs/worklets/scope.cjs +338 -359
  18. package/dist/cjs/worklets/serialize.cjs +73 -75
  19. package/dist/cjs/worklets/transform.cjs +217 -222
  20. package/dist/cjs/worklets/types.cjs +9 -11
  21. package/dist/esm/cache.mjs +96 -89
  22. package/dist/esm/cache.mjs.map +1 -1
  23. package/dist/esm/configure.mjs +11 -10
  24. package/dist/esm/configure.mjs.map +1 -1
  25. package/dist/esm/constants.mjs +41 -41
  26. package/dist/esm/constants.mjs.map +1 -1
  27. package/dist/esm/index.js +417 -420
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/index.mjs +417 -420
  30. package/dist/esm/index.mjs.map +1 -1
  31. package/dist/esm/reactNativeCodegen.mjs +90 -88
  32. package/dist/esm/reactNativeCodegen.mjs.map +1 -1
  33. package/dist/esm/reactNativeViewConfig.mjs +347 -362
  34. package/dist/esm/reactNativeViewConfig.mjs.map +1 -1
  35. package/dist/esm/refresh-runtime.mjs +372 -376
  36. package/dist/esm/refresh-runtime.mjs.map +1 -1
  37. package/dist/esm/transformBabel.mjs +261 -194
  38. package/dist/esm/transformBabel.mjs.map +1 -1
  39. package/dist/esm/transformHermesAsync.mjs +20 -21
  40. package/dist/esm/transformHermesAsync.mjs.map +1 -1
  41. package/dist/esm/transformHermesLoops.mjs +264 -255
  42. package/dist/esm/transformHermesLoops.mjs.map +1 -1
  43. package/dist/esm/transformSWC.mjs +163 -171
  44. package/dist/esm/transformSWC.mjs.map +1 -1
  45. package/dist/esm/transformWorklets.mjs +89 -69
  46. package/dist/esm/transformWorklets.mjs.map +1 -1
  47. package/dist/esm/types.mjs +0 -2
  48. package/dist/esm/worklets/autoworklet.mjs +258 -200
  49. package/dist/esm/worklets/autoworklet.mjs.map +1 -1
  50. package/dist/esm/worklets/globals.mjs +109 -42
  51. package/dist/esm/worklets/globals.mjs.map +1 -1
  52. package/dist/esm/worklets/hash.mjs +10 -9
  53. package/dist/esm/worklets/hash.mjs.map +1 -1
  54. package/dist/esm/worklets/scope.mjs +325 -341
  55. package/dist/esm/worklets/scope.mjs.map +1 -1
  56. package/dist/esm/worklets/serialize.mjs +60 -58
  57. package/dist/esm/worklets/serialize.mjs.map +1 -1
  58. package/dist/esm/worklets/transform.mjs +201 -197
  59. package/dist/esm/worklets/transform.mjs.map +1 -1
  60. package/dist/esm/worklets/types.mjs +0 -2
  61. package/package.json +7 -6
  62. package/src/cache.ts +37 -7
  63. package/src/index.ts +33 -18
  64. package/src/transformBabel.test.ts +311 -1
  65. package/src/transformBabel.ts +110 -13
  66. package/types/cache.d.ts +2 -2
  67. package/types/cache.d.ts.map +1 -1
  68. package/types/index.d.ts.map +1 -1
  69. package/types/transformBabel.d.ts +16 -1
  70. package/types/transformBabel.d.ts.map +1 -1
  71. package/types/transformSWC.d.ts +1 -4
  72. package/types/transformSWC.d.ts.map +1 -1
  73. package/dist/cjs/transformBabel.test.cjs +0 -360
  74. package/dist/cjs/transformHermesLoops.test.cjs +0 -257
  75. package/dist/cjs/transformSWC.test.cjs +0 -117
  76. package/dist/cjs/transformWorklets.test.cjs +0 -604
  77. package/dist/esm/transformBabel.test.mjs +0 -337
  78. package/dist/esm/transformBabel.test.mjs.map +0 -1
  79. package/dist/esm/transformHermesLoops.test.mjs +0 -234
  80. package/dist/esm/transformHermesLoops.test.mjs.map +0 -1
  81. package/dist/esm/transformSWC.test.mjs +0 -118
  82. package/dist/esm/transformSWC.test.mjs.map +0 -1
  83. package/dist/esm/transformWorklets.test.mjs +0 -581
  84. package/dist/esm/transformWorklets.test.mjs.map +0 -1
  85. package/dist/esm/types.mjs.map +0 -1
  86. package/dist/esm/worklets/types.mjs.map +0 -1
  87. package/types/transformBabel.test.d.ts +0 -2
  88. package/types/transformBabel.test.d.ts.map +0 -1
  89. package/types/transformHermesLoops.test.d.ts +0 -2
  90. package/types/transformHermesLoops.test.d.ts.map +0 -1
  91. package/types/transformSWC.test.d.ts +0 -2
  92. package/types/transformSWC.test.d.ts.map +0 -1
  93. package/types/transformWorklets.test.d.ts +0 -2
  94. package/types/transformWorklets.test.d.ts.map +0 -1
@@ -5,250 +5,310 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
12
  };
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
21
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
30
25
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
27
  var transformBabel_exports = {};
35
28
  __export(transformBabel_exports, {
36
- getBabelOptions: () => getBabelOptions,
37
- transformBabel: () => transformBabel,
38
- transformOxcReactCompiler: () => transformOxcReactCompiler
29
+ findUserBabelConfig: () => findUserBabelConfig,
30
+ getBabelOptions: () => getBabelOptions,
31
+ stripFlowTypes: () => stripFlowTypes,
32
+ transformBabel: () => transformBabel,
33
+ transformOxcReactCompiler: () => transformOxcReactCompiler
39
34
  });
40
35
  module.exports = __toCommonJS(transformBabel_exports);
36
+ var import_node_fs = require("node:fs");
41
37
  var import_node_path = require("node:path");
42
38
  var import_utils = require("@vxrn/utils");
43
39
  var import_vite = require("vite");
44
40
  var import_configure = require("./configure.cjs");
45
41
  var import_constants = require("./constants.cjs");
42
+ const USER_BABEL_CONFIG_FILES = [
43
+ "babel.config.js",
44
+ "babel.config.cjs",
45
+ "babel.config.mjs",
46
+ "babel.config.json",
47
+ ".babelrc",
48
+ ".babelrc.js",
49
+ ".babelrc.json"
50
+ ];
51
+ const ONE_GENERATED_MARKER = "@one/generated bundler-config";
52
+ function findUserBabelConfig(projectRoot) {
53
+ if (!projectRoot) return null;
54
+ for (const name of USER_BABEL_CONFIG_FILES) {
55
+ const fullPath = (0, import_node_path.join)(projectRoot, name);
56
+ if ((0, import_node_fs.existsSync)(fullPath)) {
57
+ try {
58
+ const content = (0, import_node_fs.readFileSync)(fullPath, "utf8");
59
+ if (content.includes(ONE_GENERATED_MARKER)) {
60
+ continue;
61
+ }
62
+ } catch {
63
+ continue;
64
+ }
65
+ return fullPath;
66
+ }
67
+ }
68
+ return null;
69
+ }
46
70
  function getBabelOptions(props) {
47
- props = {
48
- ...props,
49
- id: (0, import_vite.normalizePath)(props.id.split("?")[0])
50
- };
51
- if (props.userSetting === "babel") {
52
- return getOptions(props, true);
53
- }
54
- if (typeof props.userSetting === "undefined" || typeof props.userSetting === "object" && props.userSetting.transform === "babel") {
55
- if (props.userSetting?.excludeDefaultPlugins) {
56
- return props.userSetting;
57
- }
58
- return getOptions(props);
59
- }
60
- return null;
71
+ props = {
72
+ ...props,
73
+ id: (0, import_vite.normalizePath)(props.id.split("?")[0])
74
+ };
75
+ const isProjectFile = !props.id.includes("node_modules");
76
+ const userBabelConfig = isProjectFile && props.projectRoot ? findUserBabelConfig(props.projectRoot) : null;
77
+ if (props.userSetting === "babel") {
78
+ return getOptions(props, true, userBabelConfig);
79
+ }
80
+ if (typeof props.userSetting === "undefined" || typeof props.userSetting === "object" && props.userSetting.transform === "babel") {
81
+ if (props.userSetting?.excludeDefaultPlugins) {
82
+ return {
83
+ ...props.userSetting,
84
+ ...userBabelConfig ? {
85
+ configFile: userBabelConfig,
86
+ babelrc: true
87
+ } : {}
88
+ };
89
+ }
90
+ return getOptions(props, false, userBabelConfig);
91
+ }
92
+ const userSetting = props.userSetting;
93
+ if (userSetting === "swc" || userSetting === "oxc" || userSetting === false || typeof userSetting === "object" && userSetting !== null && (userSetting.transform === "swc" || userSetting.transform === "oxc")) {
94
+ return null;
95
+ }
96
+ if (userBabelConfig) {
97
+ return getOptions(props, false, userBabelConfig);
98
+ }
99
+ return null;
61
100
  }
62
- const getOptions = (props, force = false) => {
63
- let plugins = [];
64
- if (force || shouldBabelGenerators(props)) {
65
- plugins = getBasePlugins(props);
66
- }
67
- const enableNativewind = import_configure.configuration.enableNativewind && (props.environment === "ios" || props.environment === "android") &&
68
- // if reanimated gets wrapped in transform it causes circular dep issues
69
- !/node_modules/.test(props.id) &&
70
- // only needed for createElement calls, so be a bit conservative
71
- props.code.includes("createElement");
72
- if (enableNativewind) {
73
- if (!props.id.includes("node_modules")) {
74
- plugins.push((0, import_utils.resolvePath)("react-native-css-interop/dist/babel-plugin.js"));
75
- }
76
- }
77
- if (enableNativewind || shouldBabelReanimated(props)) {
78
- try {
79
- const workletsPlugin = (0, import_utils.resolvePath)("react-native-worklets/plugin", props.projectRoot);
80
- (0, import_constants.debug)?.(`Using babel worklets on file ${props.id}`);
81
- plugins.push(workletsPlugin);
82
- } catch {}
83
- }
84
- if (shouldBabelReactCompiler(props)) {
85
- (0, import_constants.debug)?.(`Using babel react compiler on file`);
86
- plugins.push(getBabelReactCompilerPlugin(props));
87
- }
88
- if (plugins.length) {
89
- return {
90
- plugins
91
- };
92
- }
93
- return null;
101
+ const getOptions = (props, force = false, userBabelConfig = null) => {
102
+ let plugins = [];
103
+ if (force || shouldBabelGenerators(props)) {
104
+ plugins = getBasePlugins(props);
105
+ }
106
+ const enableNativewind = import_configure.configuration.enableNativewind && (props.environment === "ios" || props.environment === "android") && !/node_modules/.test(props.id) && props.code.includes("createElement");
107
+ if (enableNativewind) {
108
+ if (!props.id.includes("node_modules")) {
109
+ plugins.push((0, import_utils.resolvePath)("react-native-css-interop/dist/babel-plugin.js"));
110
+ }
111
+ }
112
+ if (enableNativewind || shouldBabelReanimated(props)) {
113
+ try {
114
+ const workletsPlugin = (0, import_utils.resolvePath)("react-native-worklets/plugin", props.projectRoot);
115
+ (0, import_constants.debug)?.(`Using babel worklets on file ${props.id}`);
116
+ plugins.push(workletsPlugin);
117
+ } catch {}
118
+ }
119
+ if (shouldBabelReactCompiler(props)) {
120
+ (0, import_constants.debug)?.(`Using babel react compiler on file`);
121
+ plugins.push(getBabelReactCompilerPlugin(props));
122
+ }
123
+ if (plugins.length || userBabelConfig) {
124
+ return {
125
+ plugins,
126
+ ...userBabelConfig ? {
127
+ configFile: userBabelConfig,
128
+ babelrc: true
129
+ } : {}
130
+ };
131
+ }
132
+ return null;
94
133
  };
95
- async function transformOxcReactCompiler(id, code, target, sourceMap = false) {
96
- const {
97
- transform
98
- } = await import("oxc-transform-react");
99
- const result = await transform(id, code, {
100
- jsx: "preserve",
101
- sourcemap: sourceMap,
102
- reactCompiler: {
103
- target
104
- }
105
- });
106
- if (result.fatal) {
107
- throw new Error(`[vxrn:compiler] oxc react compiler failed on ${id}: ${(result.errors ?? []).map(e => e.message ?? String(e)).join(", ")}`);
108
- }
109
- if (result.errors?.length) {
110
- (0, import_constants.debug)?.(`[compiler/bailout] ${id}: ${result.errors.map(e => e.message ?? String(e)).join(", ")}`);
111
- }
112
- return {
113
- code: result.code,
114
- map: sourceMap ? result.map : void 0
115
- };
134
+ async function transformOxcReactCompiler(id, code, optionsOrTarget = "19", sourceMap = false) {
135
+ const { transform } = await import("oxc-transform-react");
136
+ const compilerOptions = typeof optionsOrTarget === "string" ? { target: optionsOrTarget } : optionsOrTarget || {};
137
+ const target = compilerOptions.target ?? "19";
138
+ const result = await transform(id, code, {
139
+ jsx: "preserve",
140
+ sourcemap: sourceMap,
141
+ reactCompiler: {
142
+ target,
143
+ ...compilerOptions,
144
+ environment: {
145
+ enableCustomTypeDefinitionForReanimated: true,
146
+ ...compilerOptions.environment
147
+ }
148
+ }
149
+ });
150
+ if (result.fatal) {
151
+ throw new Error(`[vxrn:compiler] oxc react compiler failed on ${id}: ${(result.errors ?? []).map((e) => e.message ?? String(e)).join(", ")}`);
152
+ }
153
+ if (result.errors?.length) {
154
+ (0, import_constants.debug)?.(`[compiler/bailout] ${id}: ${result.errors.map((e) => e.message ?? String(e)).join(", ")}`);
155
+ }
156
+ return {
157
+ code: result.code,
158
+ map: sourceMap ? result.map : void 0
159
+ };
116
160
  }
117
161
  async function transformBabel(id, code, options) {
118
- const [{
119
- default: babelCore
120
- }, {
121
- default: hermesParserPlugin
122
- }] = await Promise.all([import("@babel/core"), import("babel-plugin-syntax-hermes-parser")]);
123
- const extension = (0, import_node_path.extname)(id);
124
- const isTSX = extension === ".tsx";
125
- const isTS = isTSX || extension === ".ts";
126
- const babelOptions = {
127
- filename: id,
128
- compact: false,
129
- babelrc: false,
130
- configFile: false,
131
- sourceMaps: false,
132
- minified: false,
133
- ...options,
134
- presets: [isTS ? ["@babel/preset-typescript", {
135
- isTSX,
136
- allExtensions: isTSX
137
- }] : "", ...(options.presets || [])].filter(Boolean),
138
- // non-TS files use React Native's Flow dialect. RN's own component specs are
139
- // Flow `.js` (`import type`, `codegenNativeComponent<T>(…)`, `(expr: Type)` casts).
140
- // enable Hermes Flow parsing + stripping, mirroring the TypeScript preset above
141
- // (`@react-native/babel-preset` uses the same parser for JS). without it babel
142
- // can't parse current RN Flow syntax such as `call<T>(...) as HostComponent<T>`, so
143
- // plugins like
144
- // @react-native/babel-plugin-codegen silently fail on RN specs and the runtime
145
- // "Codegen didn't run" warning fires. TS path is byte-identical (empty slice).
146
- plugins: [...(isTS ? [] : [[hermesParserPlugin, {
147
- parseLangTypes: "flow",
148
- reactRuntimeTarget: "19"
149
- }]]), ...(options.plugins || []), ...(isTS ? [] : ["@babel/plugin-transform-flow-strip-types"])]
150
- };
151
- return await new Promise((res, rej) => {
152
- babelCore.transform(code, babelOptions, (err, result) => {
153
- if (!result || err) {
154
- return rej(err || new Error(`[vxrn:compiler] babel returned no result for ${id}`));
155
- }
156
- res(result);
157
- });
158
- });
162
+ const [{ default: babelCore }, { default: hermesParserPlugin }] = await Promise.all([import("@babel/core"), import("babel-plugin-syntax-hermes-parser")]);
163
+ const extension = (0, import_node_path.extname)(id);
164
+ const isTSX = extension === ".tsx";
165
+ const isTS = isTSX || extension === ".ts";
166
+ const babelOptions = {
167
+ filename: id,
168
+ compact: false,
169
+ babelrc: options.babelrc ?? false,
170
+ configFile: options.configFile ?? false,
171
+ sourceMaps: false,
172
+ minified: false,
173
+ ...options,
174
+ caller: {
175
+ name: "vxrn",
176
+ supportsStaticESM: true,
177
+ supportsDynamicImport: true
178
+ },
179
+ presets: [isTS ? ["@babel/preset-typescript", {
180
+ isTSX,
181
+ allExtensions: isTSX
182
+ }] : "", ...options.presets || []].filter(Boolean),
183
+ plugins: [
184
+ ...isTS ? [] : [[hermesParserPlugin, {
185
+ parseLangTypes: "flow",
186
+ reactRuntimeTarget: "19"
187
+ }], "babel-plugin-transform-flow-enums"],
188
+ ...options.plugins || [],
189
+ ...isTS ? [] : ["@babel/plugin-transform-flow-strip-types"]
190
+ ]
191
+ };
192
+ return await new Promise((res, rej) => {
193
+ babelCore.transform(code, babelOptions, (err, result) => {
194
+ if (!result || err) {
195
+ return rej(err || new Error(`[vxrn:compiler] babel returned no result for ${id}`));
196
+ }
197
+ res(result);
198
+ });
199
+ });
200
+ }
201
+ async function stripFlowTypes(id, code, sourceMaps = true) {
202
+ const result = await transformBabel(id, code, { sourceMaps });
203
+ return {
204
+ code: result.code,
205
+ map: result.map
206
+ };
159
207
  }
160
- const getBasePlugins = ({
161
- development
162
- }) => [["@babel/plugin-transform-destructuring"], ["@babel/plugin-transform-react-jsx", {
163
- development
164
- }], ["@babel/plugin-transform-async-generator-functions"], ["@babel/plugin-transform-async-to-generator"], ["@babel/plugin-transform-runtime", {
165
- helpers: true,
166
- // NOTE THIS WAS SPELLED WRONG BEFOER THIS COMMIT MAYBE IT WAS UNINTENTIONALLY WORKING
167
- regenerator: false
168
- }]];
169
- const shouldBabelReactCompiler = props => {
170
- if (props.environment === "ssr") {
171
- return false;
172
- }
173
- if (!import_configure.configuration.enableCompiler) {
174
- return false;
175
- }
176
- const {
177
- enableCompiler
178
- } = import_configure.configuration;
179
- if (typeof enableCompiler === "object" && !Array.isArray(enableCompiler) && !(enableCompiler instanceof RegExp)) {
180
- const isNative = props.environment === "ios" || props.environment === "android";
181
- const filter = isNative ? enableCompiler.native : enableCompiler.web;
182
- if (!filter) return false;
183
- return applyCompilerFilter(filter, props);
184
- }
185
- if (typeof enableCompiler === "function") {
186
- return enableCompiler(props.id, props.environment);
187
- }
188
- if (enableCompiler instanceof RegExp) {
189
- return enableCompiler.test(props.id);
190
- }
191
- if (Array.isArray(enableCompiler)) {
192
- if (!enableCompiler.includes(props.environment)) {
193
- return false;
194
- }
195
- }
196
- return applyDefaultFilters(props);
208
+ const getBasePlugins = ({ development }) => [
209
+ ["@babel/plugin-transform-destructuring"],
210
+ ["@babel/plugin-transform-react-jsx", { development }],
211
+ ["@babel/plugin-transform-async-generator-functions"],
212
+ ["@babel/plugin-transform-async-to-generator"],
213
+ ["@babel/plugin-transform-runtime", {
214
+ helpers: true,
215
+ regenerator: false
216
+ }]
217
+ ];
218
+ const shouldBabelReactCompiler = (props) => {
219
+ if (props.environment === "ssr") {
220
+ return false;
221
+ }
222
+ if (!import_configure.configuration.enableCompiler) {
223
+ return false;
224
+ }
225
+ const { enableCompiler } = import_configure.configuration;
226
+ if (typeof enableCompiler === "object" && !Array.isArray(enableCompiler) && !(enableCompiler instanceof RegExp)) {
227
+ const isNative = props.environment === "ios" || props.environment === "android";
228
+ const filter = isNative ? enableCompiler.native : enableCompiler.web;
229
+ if (!filter) return false;
230
+ return applyCompilerFilter(filter, props);
231
+ }
232
+ if (typeof enableCompiler === "function") {
233
+ return enableCompiler(props.id, props.environment);
234
+ }
235
+ if (enableCompiler instanceof RegExp) {
236
+ return enableCompiler.test(props.id);
237
+ }
238
+ if (Array.isArray(enableCompiler)) {
239
+ if (!enableCompiler.includes(props.environment)) {
240
+ return false;
241
+ }
242
+ }
243
+ return applyDefaultFilters(props);
197
244
  };
198
245
  function applyCompilerFilter(filter, props) {
199
- if (typeof filter === "function") {
200
- return filter(props.id, props.environment);
201
- }
202
- if (filter instanceof RegExp) {
203
- return filter.test(props.id);
204
- }
205
- if (filter === true) {
206
- return applyDefaultFilters(props);
207
- }
208
- return false;
246
+ if (typeof filter === "function") {
247
+ return filter(props.id, props.environment);
248
+ }
249
+ if (filter instanceof RegExp) {
250
+ return filter.test(props.id);
251
+ }
252
+ if (filter === true) {
253
+ return applyDefaultFilters(props);
254
+ }
255
+ return false;
209
256
  }
210
257
  function applyDefaultFilters(props) {
211
- if (!/(\.tsx?)$/.test(props.id)) return false;
212
- if (props.id.includes("node_modules")) return false;
213
- if (props.id.includes("+api.")) return false;
214
- if (props.code.startsWith("// disable-compiler")) return false;
215
- return true;
258
+ if (!/(\.tsx?)$/.test(props.id)) return false;
259
+ if (props.id.includes("node_modules")) return false;
260
+ if (props.id.includes("+api.")) return false;
261
+ if (props.code.startsWith("// disable-compiler")) return false;
262
+ return true;
216
263
  }
217
- const getBabelReactCompilerPlugin = props => {
218
- const target = props.reactForRNVersion === "18" && (props.environment === "ios" || props.environment === "android") ? "18" : "19";
219
- return ["babel-plugin-react-compiler", {
220
- target
221
- }];
264
+ const getBabelReactCompilerPlugin = (props) => {
265
+ const target = props.reactForRNVersion === "18" && (props.environment === "ios" || props.environment === "android") ? "18" : "19";
266
+ return ["babel-plugin-react-compiler", { target }];
222
267
  };
223
- function shouldBabelGenerators({
224
- code
225
- }) {
226
- if (process.env.VXRN_USE_BABEL_FOR_GENERATORS) {
227
- return import_constants.asyncGeneratorRegex.test(code);
228
- }
268
+ function shouldBabelGenerators({ code }) {
269
+ if (process.env.VXRN_USE_BABEL_FOR_GENERATORS) {
270
+ return import_constants.asyncGeneratorRegex.test(code);
271
+ }
229
272
  }
230
- const REANIMATED_AUTOWORKLETIZATION_KEYWORDS = ["worklet", "useAnimatedGestureHandler", "useAnimatedScrollHandler", "useFrameCallback", "useAnimatedStyle", "useAnimatedProps", "createAnimatedPropAdapter", "useDerivedValue", "useAnimatedReaction", "useWorkletCallback", "withTiming", "withSpring", "withDecay", "withRepeat", "runOnUI", "executeOnUIRuntimeSync"];
273
+ const REANIMATED_AUTOWORKLETIZATION_KEYWORDS = [
274
+ "worklet",
275
+ "useAnimatedGestureHandler",
276
+ "useAnimatedScrollHandler",
277
+ "useFrameCallback",
278
+ "useAnimatedStyle",
279
+ "useAnimatedProps",
280
+ "createAnimatedPropAdapter",
281
+ "useDerivedValue",
282
+ "useAnimatedReaction",
283
+ "useWorkletCallback",
284
+ "withTiming",
285
+ "withSpring",
286
+ "withDecay",
287
+ "withRepeat",
288
+ "runOnUI",
289
+ "executeOnUIRuntimeSync"
290
+ ];
231
291
  const REANIMATED_REGEX = new RegExp(REANIMATED_AUTOWORKLETIZATION_KEYWORDS.join("|"));
232
292
  const REANIMATED_IGNORED_PATHS = [
233
- // Prebuilt/vendored react-native that shouldn't be transformed
234
- "react-native-prebuilt", "node_modules/.vxrn/react-native",
235
- // Known false positives - they mention worklet keywords in comments/strings but don't use them
236
- "node_modules/react/", "node_modules/react-dom/", "node_modules/react-native/", "node_modules/react-native-web/"];
293
+ "react-native-prebuilt",
294
+ "node_modules/.vxrn/react-native",
295
+ "node_modules/react/",
296
+ "node_modules/react-dom/",
297
+ "node_modules/react-native/",
298
+ "node_modules/react-native-web/"
299
+ ];
237
300
  const REANIMATED_IGNORED_PATHS_REGEX = new RegExp(REANIMATED_IGNORED_PATHS.join("|"));
238
- function shouldBabelReanimated({
239
- code,
240
- id
241
- }) {
242
- if (!import_configure.configuration.enableReanimated) {
243
- return false;
244
- }
245
- if (REANIMATED_IGNORED_PATHS_REGEX.test(id)) {
246
- return false;
247
- }
248
- if (REANIMATED_REGEX.test(code)) {
249
- const location = id.includes("node_modules") ? "node_modules" : "user-code";
250
- (0, import_constants.debug)?.(` \u{1FA84} [reanimated/${location}] ${(0, import_node_path.relative)(process.cwd(), id)}`);
251
- return true;
252
- }
253
- return false;
254
- }
301
+ function shouldBabelReanimated({ code, id }) {
302
+ if (!import_configure.configuration.enableReanimated) {
303
+ return false;
304
+ }
305
+ if (REANIMATED_IGNORED_PATHS_REGEX.test(id)) {
306
+ return false;
307
+ }
308
+ if (REANIMATED_REGEX.test(code)) {
309
+ const location = id.includes("node_modules") ? "node_modules" : "user-code";
310
+ (0, import_constants.debug)?.(` \u{1FA84} [reanimated/${location}] ${(0, import_node_path.relative)(process.cwd(), id)}`);
311
+ return true;
312
+ }
313
+ return false;
314
+ }
@@ -5,57 +5,46 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
12
  };
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
21
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
30
25
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
27
  var transformHermesAsync_exports = {};
35
- __export(transformHermesAsync_exports, {
36
- transformHermesAsync: () => transformHermesAsync
37
- });
28
+ __export(transformHermesAsync_exports, { transformHermesAsync: () => transformHermesAsync });
38
29
  module.exports = __toCommonJS(transformHermesAsync_exports);
39
30
  async function transformHermesAsync(code, filename, sourceMaps = false, format) {
40
- if (!format && !code.includes("async")) return;
41
- const {
42
- transformSync
43
- } = await import("esbuild");
44
- const cleanId = filename.split("?")[0];
45
- const result = transformSync(code, {
46
- loader: /\.[cm]?ts$/.test(cleanId) ? "ts" : cleanId.endsWith(".tsx") ? "tsx" : "jsx",
47
- jsx: "preserve",
48
- format,
49
- supported: {
50
- "async-await": false,
51
- "async-generator": false,
52
- "for-await": false
53
- },
54
- sourcefile: filename,
55
- sourcemap: sourceMaps ? "external" : false
56
- });
57
- return {
58
- code: result.code,
59
- map: result.map ? JSON.parse(result.map) : void 0
60
- };
61
- }
31
+ if (!format && !code.includes("async")) return;
32
+ const { transformSync } = await import("esbuild");
33
+ const cleanId = filename.split("?")[0];
34
+ const result = transformSync(code, {
35
+ loader: /\.[cm]?ts$/.test(cleanId) ? "ts" : cleanId.endsWith(".tsx") ? "tsx" : "jsx",
36
+ jsx: "preserve",
37
+ format,
38
+ supported: {
39
+ "async-await": false,
40
+ "async-generator": false,
41
+ "for-await": false
42
+ },
43
+ sourcefile: filename,
44
+ sourcemap: sourceMaps ? "external" : false
45
+ });
46
+ return {
47
+ code: result.code,
48
+ map: result.map ? JSON.parse(result.map) : void 0
49
+ };
50
+ }