@vxrn/react-native-prebuilt 2.0.0-beta.33.1 → 2.0.0-beta.46.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.
@@ -0,0 +1,433 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
+ RExports: () => RExports,
32
+ RNExportNames: () => RNExportNames,
33
+ buildReact: () => buildReact,
34
+ buildReactJSX: () => buildReactJSX,
35
+ buildReactNative: () => buildReactNative
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_utils = require("@vxrn/utils");
39
+ var import_vite_flow = require("@vxrn/vite-flow");
40
+ var import_esbuild = require("esbuild");
41
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
42
+ var import_promises = require("fs/promises");
43
+ var import_module = require("module");
44
+ const import_meta = {};
45
+ var requireResolve = "url" in import_meta ? (0, import_module.createRequire)(import_meta.url).resolve : require.resolve;
46
+ var external = [
47
+ "react",
48
+ "react/jsx-runtime",
49
+ "react/jsx-dev-runtime"
50
+ ];
51
+ async function buildReactJSX() {
52
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
53
+ var _options_define;
54
+ var isProd = ((_options_define = options.define) === null || _options_define === void 0 ? void 0 : _options_define["__DEV__"]) === "false";
55
+ return (0, import_esbuild.build)({
56
+ bundle: true,
57
+ entryPoints: [requireResolve("react/jsx-dev-runtime")],
58
+ format: "cjs",
59
+ target: "node16",
60
+ jsx: "transform",
61
+ jsxFactory: "react",
62
+ allowOverwrite: true,
63
+ platform: "node",
64
+ define: {
65
+ __DEV__: "true",
66
+ "process.env.NODE_ENV": `"development"`
67
+ },
68
+ external,
69
+ logLevel: "warning",
70
+ ...options
71
+ }).then(async function() {
72
+ var bundled = await (0, import_promises.readFile)(options.outfile, "utf-8");
73
+ var outCode = `
74
+ const run = () => {
75
+ ${(0, import_utils.mustReplace)(bundled, [
76
+ ...isProd ? [{
77
+ find: /module\.exports = require_react_jsx_runtime_production([a-z_]*)\(\);/,
78
+ replace: `return require_react_jsx_runtime_production$1();`
79
+ }] : [{
80
+ find: `module.exports = require_react_jsx_dev_runtime_development();`,
81
+ replace: `return require_react_jsx_dev_runtime_development();`
82
+ }],
83
+ {
84
+ find: `process.env.VXRN_REACT_19`,
85
+ replace: "false",
86
+ optional: true
87
+ },
88
+ {
89
+ find: `Object.assign(exports, eval("require('@vxrn/vendor/react-jsx-19')"));`,
90
+ optional: true,
91
+ replace: ``
92
+ }
93
+ ])}
94
+ }
95
+ const __mod__ = run()
96
+ ${[
97
+ "jsx",
98
+ "jsxs",
99
+ "jsxDEV",
100
+ "Fragment"
101
+ ].map(function(n) {
102
+ return `export const ${n} = __mod__.${n} || __mod__.jsx || ${(function() {
103
+ if (n === "jsxs") {
104
+ return "function (type, props, key) { return __mod__.jsxDEV(type, props, key, true) }";
105
+ }
106
+ return "__mod__.jsxDEV";
107
+ })()}`;
108
+ }).join("\n")}
109
+ `;
110
+ await import_fs_extra.default.writeFile(options.outfile, outCode);
111
+ });
112
+ }
113
+ async function buildReact() {
114
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
115
+ var _options_define;
116
+ var isProd = ((_options_define = options.define) === null || _options_define === void 0 ? void 0 : _options_define["__DEV__"]) === "false";
117
+ return (0, import_esbuild.build)({
118
+ bundle: true,
119
+ entryPoints: [requireResolve("react")],
120
+ format: "cjs",
121
+ target: "node16",
122
+ jsx: "transform",
123
+ jsxFactory: "react",
124
+ allowOverwrite: true,
125
+ platform: "node",
126
+ define: {
127
+ __DEV__: "true",
128
+ "process.env.NODE_ENV": `"development"`
129
+ },
130
+ logLevel: "warning",
131
+ external,
132
+ ...options
133
+ }).then(async function() {
134
+ var bundled = await (0, import_promises.readFile)(options.outfile, "utf-8");
135
+ var outCode = `
136
+ const run = () => {
137
+ ${(0, import_utils.mustReplace)(bundled, [
138
+ isProd ? {
139
+ find: /module\.exports = require_react_production([a-z_]*)\(\);/,
140
+ replace: "return require_react_production$1();"
141
+ } : {
142
+ find: /module\.exports = require_react_development([a-z_]*)\(\);/,
143
+ replace: "return require_react_development$1();"
144
+ },
145
+ {
146
+ find: `process.env.VXRN_REACT_19`,
147
+ optional: true,
148
+ replace: "false"
149
+ },
150
+ {
151
+ find: `Object.assign(exports, eval("require('@vxrn/vendor/react-19')"));`,
152
+ optional: true,
153
+ replace: ``
154
+ }
155
+ ])}
156
+ }
157
+ const __mod__ = run()
158
+ ${RExports.map(function(n) {
159
+ return `export const ${n} = __mod__.${n}`;
160
+ }).join("\n")}
161
+ export default __mod__
162
+ `;
163
+ await import_fs_extra.default.writeFile(options.outfile, outCode);
164
+ });
165
+ }
166
+ async function buildReactNative() {
167
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, { platform } = arguments.length > 1 ? arguments[1] : void 0;
168
+ return (0, import_esbuild.build)({
169
+ bundle: true,
170
+ entryPoints: [requireResolve("react-native")],
171
+ format: "cjs",
172
+ target: "node20",
173
+ allowOverwrite: true,
174
+ platform: "node",
175
+ external,
176
+ loader: {
177
+ ".png": "dataurl",
178
+ ".jpg": "dataurl",
179
+ ".jpeg": "dataurl",
180
+ ".gif": "dataurl"
181
+ },
182
+ define: {
183
+ __DEV__: "true",
184
+ "process.env.NODE_ENV": `"development"`
185
+ },
186
+ logLevel: "warning",
187
+ resolveExtensions: [
188
+ `.${platform}.js`,
189
+ ".native.js",
190
+ ".js",
191
+ ".jsx",
192
+ ".json",
193
+ ".mjs"
194
+ ],
195
+ ...options,
196
+ plugins: [{
197
+ name: "remove-flow",
198
+ setup(build2) {
199
+ build2.onResolve({ filter: /HMRClient/ }, async function(input) {
200
+ var path = requireResolve("@vxrn/vite-native-hmr");
201
+ var possibleEsmPath = path.replace("/cjs/index.cjs", "/esm/index.native.js");
202
+ if (import_fs_extra.default.pathExistsSync(possibleEsmPath)) {
203
+ return { path: possibleEsmPath };
204
+ }
205
+ return { path };
206
+ });
207
+ build2.onLoad({ filter: /.*\.js$/ }, async function(input) {
208
+ if (!input.path.includes("react-native") && !input.path.includes(`vite-native-hmr`)) {
209
+ return;
210
+ }
211
+ var code = await (0, import_promises.readFile)(input.path, "utf-8");
212
+ var outagain = await (0, import_vite_flow.transformFlowBabel)(code, {
213
+ development: true,
214
+ path: input.path
215
+ });
216
+ if (input.path.endsWith("react-native/index.js")) {
217
+ outagain = outagain.replace(/module\.exports *= *{/, `
218
+ module.exports = {
219
+ get _vxrnInternalReactNativeVersionDoNotUse() {
220
+ return require("./Libraries/Core/ReactNativeVersion").default;
221
+ },
222
+ `.trim());
223
+ }
224
+ return {
225
+ contents: outagain,
226
+ loader: "jsx"
227
+ };
228
+ });
229
+ }
230
+ }]
231
+ }).then(async function() {
232
+ var bundled = await (0, import_promises.readFile)(options.outfile, "utf-8");
233
+ var outCode = `
234
+ const run = () => {
235
+ ${(0, import_utils.mustReplace)(bundled, [
236
+ {
237
+ find: esbuildCommonJSFunction,
238
+ replace: `
239
+ // replaced commonjs function to allow importing internals
240
+ var __commonJS = function __commonJS(cb, mod) {
241
+ var path = __getOwnPropNames(cb)[0];
242
+ var modulePath = path.replace(/.*node_modules\\//, '').replace('.js', '');
243
+
244
+ var __require = function __require() {
245
+ if (mod) return mod;
246
+
247
+ var cachedMod = globalThis["__cachedModules"][modulePath];
248
+ if (cachedMod) return cachedMod;
249
+
250
+ var moduleFn = cb[path];
251
+ try {
252
+ mod = {
253
+ exports: {}
254
+ };
255
+ moduleFn(mod.exports, mod);
256
+ mod = mod.exports;
257
+ } catch (e) {
258
+ // match esbuild: don't leave a half-initialized module cached
259
+ throw mod = 0, e;
260
+ }
261
+ // this is one of our patches basically allowing importing the inner contents:
262
+ globalThis["__cachedModules"][modulePath] = mod;
263
+ return mod;
264
+ };
265
+
266
+ // this is another patch basically allowing importing the inner contents:
267
+ if (globalThis['__RN_INTERNAL_MODULE_REQUIRES_MAP__']) {
268
+ globalThis['__RN_INTERNAL_MODULE_REQUIRES_MAP__'][modulePath] = __require;
269
+ }
270
+
271
+ return __require;
272
+ };
273
+ `
274
+ },
275
+ {
276
+ find: /module\.exports = require_(react_native|index)\(\);/,
277
+ replace: [
278
+ `const rn = require_$1();`,
279
+ `rn.AssetRegistry = require_registry();`,
280
+ `require_ReactFabric();`,
281
+ `if (typeof require_InitializeCore === 'function') { require_InitializeCore(); }`,
282
+ `return rn;`
283
+ ].join("\n")
284
+ },
285
+ {
286
+ find: `originalMessage = e.message || "";`,
287
+ replace: `originalMessage = "" + (e.stack || "");`
288
+ }
289
+ ])}
290
+ }
291
+ const RN = run()
292
+
293
+ export const REACT_NATIVE_ESM_MANUAL_EXPORTS_START = 'REACT_NATIVE_ESM_MANUAL_EXPORTS_START';${""}
294
+ ${RNExportNames.map(function(n) {
295
+ return `export const ${n} = RN.${n}`;
296
+ }).join("\n")}
297
+ export const REACT_NATIVE_ESM_MANUAL_EXPORTS_END = 'REACT_NATIVE_ESM_MANUAL_EXPORTS_END';
298
+ `;
299
+ await import_fs_extra.default.writeFile(options.outfile, outCode);
300
+ });
301
+ }
302
+ var esbuildCommonJSFunction = `var __commonJS = (cb, mod) => function __require() {
303
+ try {
304
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
305
+ } catch (e) {
306
+ throw mod = 0, e;
307
+ }
308
+ };`;
309
+ var RNExportNames = [
310
+ "registerCallableModule",
311
+ "AccessibilityInfo",
312
+ "ActivityIndicator",
313
+ "Button",
314
+ "DrawerLayoutAndroid",
315
+ "FlatList",
316
+ "Image",
317
+ "ImageBackground",
318
+ "InputAccessoryView",
319
+ "KeyboardAvoidingView",
320
+ "Modal",
321
+ "Pressable",
322
+ "RefreshControl",
323
+ "SafeAreaView",
324
+ "ScrollView",
325
+ "SectionList",
326
+ "StatusBar",
327
+ "Switch",
328
+ "Text",
329
+ "TextInput",
330
+ "Touchable",
331
+ "TouchableHighlight",
332
+ "TouchableNativeFeedback",
333
+ "TouchableOpacity",
334
+ "TouchableWithoutFeedback",
335
+ "View",
336
+ "VirtualizedList",
337
+ "VirtualizedSectionList",
338
+ "ActionSheetIOS",
339
+ "Alert",
340
+ "Animated",
341
+ "Appearance",
342
+ "AppRegistry",
343
+ "AppState",
344
+ "BackHandler",
345
+ "DeviceInfo",
346
+ "DevSettings",
347
+ "Dimensions",
348
+ "Easing",
349
+ "findNodeHandle",
350
+ "I18nManager",
351
+ "InteractionManager",
352
+ "Keyboard",
353
+ "LayoutAnimation",
354
+ "Linking",
355
+ "LogBox",
356
+ "NativeDialogManagerAndroid",
357
+ "NativeEventEmitter",
358
+ "Networking",
359
+ "PanResponder",
360
+ "PermissionsAndroid",
361
+ "PixelRatio",
362
+ "Settings",
363
+ "Share",
364
+ "StyleSheet",
365
+ "Systrace",
366
+ "ToastAndroid",
367
+ "TurboModuleRegistry",
368
+ "UIManager",
369
+ "unstable_batchedUpdates",
370
+ "useAnimatedValue",
371
+ "useAnimatedValueXY",
372
+ "useAnimatedColor",
373
+ "useColorScheme",
374
+ "usePressability",
375
+ "useWindowDimensions",
376
+ "UTFSequence",
377
+ "Vibration",
378
+ "DeviceEventEmitter",
379
+ "DynamicColorIOS",
380
+ "EventEmitter",
381
+ "NativeAppEventEmitter",
382
+ "NativeModules",
383
+ "Platform",
384
+ "PlatformColor",
385
+ "processColor",
386
+ "requireNativeComponent",
387
+ "RootTagContext",
388
+ "AssetRegistry"
389
+ ];
390
+ var RExports = [
391
+ "Children",
392
+ "Component",
393
+ "Fragment",
394
+ "Profiler",
395
+ "PureComponent",
396
+ "StrictMode",
397
+ "Suspense",
398
+ "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED",
399
+ "__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE",
400
+ "cloneElement",
401
+ "createContext",
402
+ "createElement",
403
+ "createFactory",
404
+ "createRef",
405
+ "forwardRef",
406
+ "isValidElement",
407
+ "lazy",
408
+ "memo",
409
+ "startTransition",
410
+ "unstable_act",
411
+ "useCallback",
412
+ "useContext",
413
+ "useDebugValue",
414
+ "useDeferredValue",
415
+ "useEffect",
416
+ "useId",
417
+ "useImperativeHandle",
418
+ "useInsertionEffect",
419
+ "useLayoutEffect",
420
+ "useMemo",
421
+ "useReducer",
422
+ "useRef",
423
+ "useState",
424
+ "useSyncExternalStore",
425
+ "useTransition",
426
+ "version",
427
+ "act",
428
+ "cache",
429
+ "unstable_useCacheRefresh",
430
+ "use",
431
+ "useActionState",
432
+ "useOptimistic"
433
+ ];