@vxrn/react-native-prebuilt 1.14.4 → 1.14.5
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.
- package/dist/cjs/index.cjs +135 -122
- package/dist/cjs/index.native.js +160 -150
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/index.test.cjs +14 -10
- package/dist/cjs/index.test.native.js +14 -10
- package/dist/cjs/index.test.native.js.map +1 -1
- package/dist/esm/index.js +104 -93
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +104 -93
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +130 -122
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/index.test.mjs +3 -1
- package/dist/esm/index.test.mjs.map +1 -1
- package/dist/esm/index.test.native.js +3 -1
- package/dist/esm/index.test.native.js.map +1 -1
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var index_exports = {};
|
|
33
35
|
__export(index_exports, {
|
|
34
36
|
RExports: () => RExports,
|
|
@@ -38,102 +40,105 @@ __export(index_exports, {
|
|
|
38
40
|
buildReactNative: () => buildReactNative
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(index_exports);
|
|
41
|
-
var import_utils = require("@vxrn/utils")
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const import_meta = {}
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
var import_utils = require("@vxrn/utils");
|
|
44
|
+
var import_vite_flow = require("@vxrn/vite-flow");
|
|
45
|
+
var import_esbuild = require("esbuild");
|
|
46
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
47
|
+
var import_promises = require("node:fs/promises");
|
|
48
|
+
var import_node_module = require("node:module");
|
|
49
|
+
const import_meta = {};
|
|
50
|
+
const requireResolve = "url" in import_meta ? (0, import_node_module.createRequire)(import_meta.url).resolve : require.resolve;
|
|
51
|
+
const external = ["react", "react/jsx-runtime", "react/jsx-dev-runtime"];
|
|
50
52
|
async function buildReactJSX(options = {}) {
|
|
51
|
-
const isProd = options.define?.__DEV__ === "false";
|
|
53
|
+
const isProd = options.define?.["__DEV__"] === "false";
|
|
52
54
|
return (0, import_esbuild.build)({
|
|
53
|
-
bundle:
|
|
55
|
+
bundle: true,
|
|
54
56
|
entryPoints: [requireResolve("react/jsx-dev-runtime")],
|
|
55
57
|
format: "cjs",
|
|
56
58
|
target: "node16",
|
|
57
59
|
jsx: "transform",
|
|
58
60
|
jsxFactory: "react",
|
|
59
|
-
allowOverwrite:
|
|
61
|
+
allowOverwrite: true,
|
|
60
62
|
platform: "node",
|
|
61
63
|
define: {
|
|
62
64
|
__DEV__: "true",
|
|
63
|
-
"process.env.NODE_ENV":
|
|
65
|
+
"process.env.NODE_ENV": `"development"`
|
|
64
66
|
},
|
|
65
67
|
external,
|
|
66
68
|
logLevel: "warning",
|
|
67
69
|
...options
|
|
68
70
|
}).then(async () => {
|
|
69
|
-
const bundled = await (0, import_promises.readFile)(options.outfile, "utf-8")
|
|
70
|
-
|
|
71
|
+
const bundled = await (0, import_promises.readFile)(options.outfile, "utf-8");
|
|
72
|
+
const outCode = `
|
|
71
73
|
const run = () => {
|
|
72
74
|
${(0, import_utils.mustReplace)(bundled, [...(isProd ? [{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
75
|
+
// react 18 and 19 (18 has _min)
|
|
76
|
+
find: /module\.exports = require_react_jsx_runtime_production([a-z_]*)\(\);/,
|
|
77
|
+
replace: `return require_react_jsx_runtime_production$1();`
|
|
78
|
+
}] : [{
|
|
79
|
+
find: `module.exports = require_react_jsx_dev_runtime_development();`,
|
|
80
|
+
replace: `return require_react_jsx_dev_runtime_development();`
|
|
81
|
+
}]), {
|
|
82
|
+
find: `process.env.VXRN_REACT_19`,
|
|
83
|
+
replace: "false",
|
|
84
|
+
optional: true
|
|
85
|
+
}, {
|
|
86
|
+
find: `Object.assign(exports, eval("require('@vxrn/vendor/react-jsx-19')"));`,
|
|
87
|
+
optional: true,
|
|
88
|
+
replace: ``
|
|
89
|
+
}])}
|
|
88
90
|
}
|
|
89
91
|
const __mod__ = run()
|
|
90
|
-
${["jsx", "jsxs", "jsxDEV", "Fragment"].map(n => `export const ${n} = __mod__.${n} || __mod__.jsx || ${
|
|
91
|
-
|
|
92
|
+
${["jsx", "jsxs", "jsxDEV", "Fragment"].map(n => `export const ${n} = __mod__.${n} || __mod__.jsx || ${(() => {
|
|
93
|
+
if (n === "jsxs") {
|
|
94
|
+
return "function (type, props, key) { return __mod__.jsxDEV(type, props, key, true) }";
|
|
95
|
+
}
|
|
96
|
+
return "__mod__.jsxDEV";
|
|
97
|
+
})()}`).join("\n")}
|
|
92
98
|
`;
|
|
93
99
|
await import_fs_extra.default.writeFile(options.outfile, outCode);
|
|
94
100
|
});
|
|
95
101
|
}
|
|
96
102
|
async function buildReact(options = {}) {
|
|
97
|
-
const isProd = options.define?.__DEV__ === "false";
|
|
103
|
+
const isProd = options.define?.["__DEV__"] === "false";
|
|
98
104
|
return (0, import_esbuild.build)({
|
|
99
|
-
bundle:
|
|
105
|
+
bundle: true,
|
|
100
106
|
entryPoints: [requireResolve("react")],
|
|
101
107
|
format: "cjs",
|
|
102
108
|
target: "node16",
|
|
103
109
|
jsx: "transform",
|
|
104
110
|
jsxFactory: "react",
|
|
105
|
-
allowOverwrite:
|
|
111
|
+
allowOverwrite: true,
|
|
106
112
|
platform: "node",
|
|
107
113
|
define: {
|
|
108
114
|
__DEV__: "true",
|
|
109
|
-
"process.env.NODE_ENV":
|
|
115
|
+
"process.env.NODE_ENV": `"development"`
|
|
110
116
|
},
|
|
111
117
|
logLevel: "warning",
|
|
112
118
|
external,
|
|
113
119
|
...options
|
|
114
120
|
}).then(async () => {
|
|
115
|
-
const bundled = await (0, import_promises.readFile)(options.outfile, "utf-8")
|
|
116
|
-
|
|
121
|
+
const bundled = await (0, import_promises.readFile)(options.outfile, "utf-8");
|
|
122
|
+
const outCode = `
|
|
117
123
|
const run = () => {
|
|
118
124
|
${(0, import_utils.mustReplace)(bundled, [isProd ? {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
find: /module\.exports = require_react_production([a-z_]*)\(\);/,
|
|
126
|
+
replace: "return require_react_production$1();"
|
|
127
|
+
} : {
|
|
128
|
+
find: /module\.exports = require_react_development([a-z_]*)\(\);/,
|
|
129
|
+
replace: "return require_react_development$1();"
|
|
130
|
+
}, {
|
|
131
|
+
find: `process.env.VXRN_REACT_19`,
|
|
132
|
+
optional: true,
|
|
133
|
+
replace: "false"
|
|
134
|
+
}, {
|
|
135
|
+
find: `Object.assign(exports, eval("require('@vxrn/vendor/react-19')"));`,
|
|
136
|
+
optional: true,
|
|
137
|
+
replace: ``
|
|
138
|
+
}])}
|
|
133
139
|
}
|
|
134
140
|
const __mod__ = run()
|
|
135
|
-
${RExports.map(n => `export const ${n} = __mod__.${n}`).join(
|
|
136
|
-
`)}
|
|
141
|
+
${RExports.map(n => `export const ${n} = __mod__.${n}`).join("\n")}
|
|
137
142
|
export default __mod__
|
|
138
143
|
`;
|
|
139
144
|
await import_fs_extra.default.writeFile(options.outfile, outCode);
|
|
@@ -141,14 +146,14 @@ async function buildReact(options = {}) {
|
|
|
141
146
|
}
|
|
142
147
|
async function buildReactNative(options = {}, {
|
|
143
148
|
platform,
|
|
144
|
-
enableExperimentalReactNativeWithReact19Support =
|
|
149
|
+
enableExperimentalReactNativeWithReact19Support = false
|
|
145
150
|
}) {
|
|
146
151
|
return (0, import_esbuild.build)({
|
|
147
|
-
bundle:
|
|
152
|
+
bundle: true,
|
|
148
153
|
entryPoints: [requireResolve("react-native")],
|
|
149
154
|
format: "cjs",
|
|
150
155
|
target: "node20",
|
|
151
|
-
allowOverwrite:
|
|
156
|
+
allowOverwrite: true,
|
|
152
157
|
platform: "node",
|
|
153
158
|
external,
|
|
154
159
|
loader: {
|
|
@@ -159,7 +164,7 @@ async function buildReactNative(options = {}, {
|
|
|
159
164
|
},
|
|
160
165
|
define: {
|
|
161
166
|
__DEV__: "true",
|
|
162
|
-
"process.env.NODE_ENV":
|
|
167
|
+
"process.env.NODE_ENV": `"development"`
|
|
163
168
|
},
|
|
164
169
|
logLevel: "warning",
|
|
165
170
|
resolveExtensions: [`.${platform}.js`, ".native.js", ".js", ".jsx", ".json", ".mjs"],
|
|
@@ -170,17 +175,23 @@ async function buildReactNative(options = {}, {
|
|
|
170
175
|
build2.onResolve({
|
|
171
176
|
filter: /HMRClient/
|
|
172
177
|
}, async input => {
|
|
173
|
-
const path = requireResolve("@vxrn/vite-native-hmr")
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
const path = requireResolve("@vxrn/vite-native-hmr");
|
|
179
|
+
const possibleEsmPath = path.replace("/cjs/index.cjs", "/esm/index.native.js");
|
|
180
|
+
if (import_fs_extra.default.pathExistsSync(possibleEsmPath)) {
|
|
181
|
+
return {
|
|
182
|
+
path: possibleEsmPath
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
178
186
|
path
|
|
179
187
|
};
|
|
180
|
-
})
|
|
188
|
+
});
|
|
189
|
+
build2.onLoad({
|
|
181
190
|
filter: /.*\.js$/
|
|
182
191
|
}, async input => {
|
|
183
|
-
if (!input.path.includes("react-native") && !input.path.includes(
|
|
192
|
+
if (!input.path.includes("react-native") && !input.path.includes(`vite-native-hmr`)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
184
195
|
if (enableExperimentalReactNativeWithReact19Support) {
|
|
185
196
|
if (input.path.includes("Libraries/Renderer/implementations/ReactFabric")) {
|
|
186
197
|
const reactFabricRendererPath = requireResolve(`@vxrn/react-native-prebuilt/vendor/rn-react-19-support/ReactFabric-${input.path.endsWith("-dev.js") ? "dev" : "prod"}.js`);
|
|
@@ -199,15 +210,18 @@ async function buildReactNative(options = {}, {
|
|
|
199
210
|
}
|
|
200
211
|
const code = await (0, import_promises.readFile)(input.path, "utf-8");
|
|
201
212
|
let outagain = await (0, import_vite_flow.transformFlowBabel)(code, {
|
|
202
|
-
development:
|
|
213
|
+
development: true,
|
|
203
214
|
path: input.path
|
|
204
215
|
});
|
|
205
|
-
|
|
216
|
+
if (input.path.endsWith("react-native/index.js")) {
|
|
217
|
+
outagain = outagain.replace(/module\.exports *= *{/, `
|
|
206
218
|
module.exports = {
|
|
207
219
|
get _vxrnInternalReactNativeVersionDoNotUse() {
|
|
208
220
|
return require("./Libraries/Core/ReactNativeVersion").default;
|
|
209
221
|
},
|
|
210
|
-
`.trim())
|
|
222
|
+
`.trim());
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
211
225
|
contents: outagain,
|
|
212
226
|
loader: "jsx"
|
|
213
227
|
};
|
|
@@ -215,12 +229,12 @@ module.exports = {
|
|
|
215
229
|
}
|
|
216
230
|
}]
|
|
217
231
|
}).then(async () => {
|
|
218
|
-
const bundled = await (0, import_promises.readFile)(options.outfile, "utf-8")
|
|
219
|
-
|
|
232
|
+
const bundled = await (0, import_promises.readFile)(options.outfile, "utf-8");
|
|
233
|
+
const outCode = `
|
|
220
234
|
const run = () => {
|
|
221
235
|
${(0, import_utils.mustReplace)(bundled, [{
|
|
222
|
-
|
|
223
|
-
|
|
236
|
+
find: esbuildCommonJSFunction,
|
|
237
|
+
replace: `
|
|
224
238
|
// replaced commonjs function to allow importing internals
|
|
225
239
|
var __commonJS = function __commonJS(cb, mod) {
|
|
226
240
|
var path = __getOwnPropNames(cb)[0];
|
|
@@ -251,26 +265,25 @@ var __commonJS = function __commonJS(cb, mod) {
|
|
|
251
265
|
return __require;
|
|
252
266
|
};
|
|
253
267
|
`
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}])}
|
|
268
|
+
}, {
|
|
269
|
+
find: /module\.exports = require_(react_native|index)\(\);/,
|
|
270
|
+
replace: [`const rn = require_$1();`, `rn.AssetRegistry = require_registry();`, `require_ReactNative();`,
|
|
271
|
+
// This is react-native/Libraries/Renderer/shims/ReactNative.js, we call it here to ensure shims are initialized since we won't lazy load React Native components. See the NOTE below.
|
|
272
|
+
`if (typeof require_InitializeCore === 'function') { require_InitializeCore(); }`,
|
|
273
|
+
// Since we're accessing the RefreshRuntime directly via `__cachedModules` directly in the RN bundle, we need to ensure it's loaded in time. Note that calling `require_react_refresh_runtime_development()`, `require_setUpReactRefresh()` or `require_setUpDeveloperTools()` directly won't work.
|
|
274
|
+
`return rn;`].join("\n")
|
|
275
|
+
},
|
|
276
|
+
// improve error logs a lot including stack of original error
|
|
277
|
+
{
|
|
278
|
+
find: `originalMessage = e.message || "";`,
|
|
279
|
+
replace: `originalMessage = "" + (e.stack || "");`
|
|
280
|
+
}])}
|
|
268
281
|
}
|
|
269
282
|
const RN = run()
|
|
270
283
|
|
|
271
|
-
export const REACT_NATIVE_ESM_MANUAL_EXPORTS_START = 'REACT_NATIVE_ESM_MANUAL_EXPORTS_START'
|
|
272
|
-
|
|
273
|
-
`)}
|
|
284
|
+
export const REACT_NATIVE_ESM_MANUAL_EXPORTS_START = 'REACT_NATIVE_ESM_MANUAL_EXPORTS_START';${/* NOTE: The `REACT_NATIVE_ESM_MANUAL_EXPORTS_*` vars here are used by other tools to replace exports in this section with a CJS `module.export` which supports dynamic loaded lazy exports, if CJS can be used - such as in a React Native bundle. */
|
|
285
|
+
""}
|
|
286
|
+
${RNExportNames.map(n => `export const ${n} = RN.${n}`).join("\n")}
|
|
274
287
|
export const REACT_NATIVE_ESM_MANUAL_EXPORTS_END = 'REACT_NATIVE_ESM_MANUAL_EXPORTS_END';
|
|
275
288
|
`;
|
|
276
289
|
await import_fs_extra.default.writeFile(options.outfile, outCode);
|
|
@@ -278,14 +291,14 @@ var __commonJS = function __commonJS(cb, mod) {
|
|
|
278
291
|
}
|
|
279
292
|
const esbuildCommonJSFunction = `var __commonJS = (cb, mod) => function __require() {
|
|
280
293
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
294
|
+
};`;
|
|
295
|
+
const RNExportNames = ["registerCallableModule", "AccessibilityInfo", "ActivityIndicator", "Button", "DrawerLayoutAndroid", "FlatList", "Image", "ImageBackground", "InputAccessoryView", "KeyboardAvoidingView", "Modal", "Pressable", "RefreshControl", "SafeAreaView", "ScrollView", "SectionList", "StatusBar", "Switch", "Text", "TextInput", "Touchable", "TouchableHighlight", "TouchableNativeFeedback", "TouchableOpacity", "TouchableWithoutFeedback", "View", "VirtualizedList", "VirtualizedSectionList", "ActionSheetIOS", "Alert", "Animated", "Appearance", "AppRegistry", "AppState", "BackHandler", "DeviceInfo", "DevSettings", "Dimensions", "Easing", "findNodeHandle", "I18nManager", "InteractionManager", "Keyboard", "LayoutAnimation", "Linking", "LogBox", "NativeDialogManagerAndroid", "NativeEventEmitter", "Networking", "PanResponder", "PermissionsAndroid", "PixelRatio", "Settings", "Share", "StyleSheet", "Systrace", "ToastAndroid", "TurboModuleRegistry", "UIManager", "unstable_batchedUpdates", "useAnimatedValue", "useColorScheme", "useWindowDimensions", "UTFSequence", "Vibration", "DeviceEventEmitter", "DynamicColorIOS", "NativeAppEventEmitter", "NativeModules", "Platform", "PlatformColor", "processColor", "requireNativeComponent", "RootTagContext", "AssetRegistry"
|
|
296
|
+
// Normally not exported by React Native, but with a hack we make @react-native/assets-registry/registry available here.
|
|
297
|
+
];
|
|
298
|
+
const RExports = ["Children", "Component", "Fragment", "Profiler", "PureComponent", "StrictMode", "Suspense", "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED",
|
|
299
|
+
// For React 18
|
|
300
|
+
"__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE",
|
|
301
|
+
// For React 19
|
|
302
|
+
"cloneElement", "createContext", "createElement", "createFactory", "createRef", "forwardRef", "isValidElement", "lazy", "memo", "startTransition", "unstable_act", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition", "version",
|
|
303
|
+
// Added in React 19
|
|
304
|
+
"act", "cache", "unstable_useCacheRefresh", "use", "useActionState", "useOptimistic"];
|