vxrn 1.12.8 → 1.13.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.
- package/dist/config/getAdditionalViteConfig.mjs +1 -4
- package/dist/config/getAdditionalViteConfig.mjs.map +1 -1
- package/dist/config/getAdditionalViteConfig.native.js +1 -4
- package/dist/config/getAdditionalViteConfig.native.js.map +1 -1
- package/dist/config/getReactNativePlugins.mjs +1 -5
- package/dist/config/getReactNativePlugins.mjs.map +1 -1
- package/dist/config/getReactNativePlugins.native.js +1 -5
- package/dist/config/getReactNativePlugins.native.js.map +1 -1
- package/dist/exports/build.mjs +5 -0
- package/dist/exports/build.mjs.map +1 -1
- package/dist/exports/build.native.js +5 -0
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/createServer.mjs +30 -25
- package/dist/exports/createServer.mjs.map +1 -1
- package/dist/exports/createServer.native.js +6 -3
- package/dist/exports/createServer.native.js.map +1 -1
- package/dist/exports/prebuild.mjs +25 -1
- package/dist/exports/prebuild.mjs.map +1 -1
- package/dist/exports/prebuild.native.js +30 -1
- package/dist/exports/prebuild.native.js.map +1 -1
- package/dist/exports/serve.mjs +2 -2
- package/dist/exports/serve.mjs.map +1 -1
- package/dist/exports/serve.native.js +2 -2
- package/dist/exports/serve.native.js.map +1 -1
- package/dist/exports/serveStaticAssets.mjs +43 -11
- package/dist/exports/serveStaticAssets.mjs.map +1 -1
- package/dist/exports/serveStaticAssets.native.js +69 -6
- package/dist/exports/serveStaticAssets.native.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1 -2
- package/dist/index.native.js.map +1 -1
- package/dist/patches/builtInDepPatches.mjs +14 -0
- package/dist/patches/builtInDepPatches.mjs.map +1 -1
- package/dist/patches/builtInDepPatches.native.js +14 -0
- package/dist/patches/builtInDepPatches.native.js.map +1 -1
- package/dist/plugins/clientInjectPlugin.mjs +2 -62
- package/dist/plugins/clientInjectPlugin.mjs.map +1 -1
- package/dist/plugins/clientInjectPlugin.native.js +2 -75
- package/dist/plugins/clientInjectPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs +1 -3
- package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.native.js +1 -3
- package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevServer.mjs +55 -77
- package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
- package/dist/plugins/reactNativeDevServer.native.js +73 -84
- package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
- package/dist/plugins/serverExtensions.test.mjs +12 -6
- package/dist/plugins/serverExtensions.test.mjs.map +1 -1
- package/dist/plugins/serverExtensions.test.native.js +12 -6
- package/dist/plugins/serverExtensions.test.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +11 -35
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +9 -36
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/runtime/hmr-client.mjs +125 -0
- package/dist/runtime/hmr-client.mjs.map +1 -0
- package/dist/runtime/hmr-client.native.js +197 -0
- package/dist/runtime/hmr-client.native.js.map +1 -0
- package/dist/runtime/hmr-runtime.mjs +162 -0
- package/dist/runtime/hmr-runtime.mjs.map +1 -0
- package/dist/runtime/hmr-runtime.native.js +348 -0
- package/dist/runtime/hmr-runtime.native.js.map +1 -0
- package/dist/runtime/hmr-types.mjs +2 -0
- package/dist/runtime/hmr-types.mjs.map +1 -0
- package/dist/runtime/hmr-types.native.js +2 -0
- package/dist/runtime/hmr-types.native.js.map +1 -0
- package/dist/runtime/native-prelude.mjs +97 -0
- package/dist/runtime/native-prelude.mjs.map +1 -0
- package/dist/runtime/native-prelude.native.js +97 -0
- package/dist/runtime/native-prelude.native.js.map +1 -0
- package/dist/runtime/react-refresh-utils.mjs +19 -0
- package/dist/runtime/react-refresh-utils.mjs.map +1 -0
- package/dist/runtime/react-refresh-utils.native.js +24 -0
- package/dist/runtime/react-refresh-utils.native.js.map +1 -0
- package/dist/utils/createNativeDevEngine.mjs +661 -0
- package/dist/utils/createNativeDevEngine.mjs.map +1 -0
- package/dist/utils/createNativeDevEngine.native.js +702 -0
- package/dist/utils/createNativeDevEngine.native.js.map +1 -0
- package/dist/utils/patches.mjs +6 -2
- package/dist/utils/patches.mjs.map +1 -1
- package/dist/utils/patches.native.js +6 -2
- package/dist/utils/patches.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +4 -3
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +4 -3
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/expo-plugin.cjs +122 -0
- package/package.json +15 -19
- package/src/config/getAdditionalViteConfig.ts +1 -3
- package/src/config/getReactNativePlugins.ts +0 -6
- package/src/exports/build.ts +5 -0
- package/src/exports/createServer.ts +7 -2
- package/src/exports/prebuild.ts +45 -0
- package/src/exports/serve.ts +2 -1
- package/src/exports/serveStaticAssets.ts +67 -4
- package/src/index.ts +0 -2
- package/src/patches/builtInDepPatches.ts +29 -0
- package/src/plugins/clientInjectPlugin.ts +2 -109
- package/src/plugins/reactNativeDevAssetPlugin.ts +0 -21
- package/src/plugins/reactNativeDevServer.ts +57 -84
- package/src/plugins/serverExtensions.test.ts +6 -8
- package/src/rn-commands/bundle/buildBundle.ts +9 -62
- package/src/runtime/hmr-client.ts +215 -0
- package/src/runtime/hmr-runtime.ts +276 -0
- package/src/runtime/hmr-types.ts +84 -0
- package/src/runtime/native-prelude.ts +110 -0
- package/src/runtime/react-refresh-utils.ts +36 -0
- package/src/types.ts +22 -4
- package/src/utils/createNativeDevEngine.ts +942 -0
- package/src/utils/patches.ts +36 -18
- package/src/utils/scanDepsToOptimize.ts +2 -3
- package/types/config/getAdditionalViteConfig.d.ts.map +1 -1
- package/types/config/getOptionsFilled.d.ts +2 -18
- package/types/config/getOptionsFilled.d.ts.map +1 -1
- package/types/config/getReactNativePlugins.d.ts.map +1 -1
- package/types/exports/build.d.ts +1 -9
- package/types/exports/build.d.ts.map +1 -1
- package/types/exports/createServer.d.ts.map +1 -1
- package/types/exports/prebuild.d.ts.map +1 -1
- package/types/exports/serve.d.ts +2 -1
- package/types/exports/serve.d.ts.map +1 -1
- package/types/exports/serveStaticAssets.d.ts +12 -1
- package/types/exports/serveStaticAssets.d.ts.map +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/types/patches/builtInDepPatches.d.ts.map +1 -1
- package/types/plugins/clientInjectPlugin.d.ts +1 -7
- package/types/plugins/clientInjectPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeDevAssetPlugin.d.ts.map +1 -1
- package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/runtime/hmr-client.d.ts +40 -0
- package/types/runtime/hmr-client.d.ts.map +1 -0
- package/types/runtime/hmr-runtime.d.ts +69 -0
- package/types/runtime/hmr-runtime.d.ts.map +1 -0
- package/types/runtime/hmr-types.d.ts +76 -0
- package/types/runtime/hmr-types.d.ts.map +1 -0
- package/types/runtime/native-prelude.d.ts +11 -0
- package/types/runtime/native-prelude.d.ts.map +1 -0
- package/types/runtime/react-refresh-utils.d.ts +3 -0
- package/types/runtime/react-refresh-utils.d.ts.map +1 -0
- package/types/types.d.ts +15 -1
- package/types/types.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.d.ts +42 -0
- package/types/utils/createNativeDevEngine.d.ts.map +1 -0
- package/types/utils/patches.d.ts.map +1 -1
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
- package/dist/config/getReactNativeBuildConfig.mjs +0 -200
- package/dist/config/getReactNativeBuildConfig.mjs.map +0 -1
- package/dist/config/getReactNativeBuildConfig.native.js +0 -204
- package/dist/config/getReactNativeBuildConfig.native.js.map +0 -1
- package/dist/plugins/reactNativeHMRPlugin.mjs +0 -120
- package/dist/plugins/reactNativeHMRPlugin.mjs.map +0 -1
- package/dist/plugins/reactNativeHMRPlugin.native.js +0 -151
- package/dist/plugins/reactNativeHMRPlugin.native.js.map +0 -1
- package/dist/utils/filterPluginsForNative.mjs +0 -27
- package/dist/utils/filterPluginsForNative.mjs.map +0 -1
- package/dist/utils/filterPluginsForNative.native.js +0 -33
- package/dist/utils/filterPluginsForNative.native.js.map +0 -1
- package/dist/utils/getReactNativeBundle.mjs +0 -104
- package/dist/utils/getReactNativeBundle.mjs.map +0 -1
- package/dist/utils/getReactNativeBundle.native.js +0 -135
- package/dist/utils/getReactNativeBundle.native.js.map +0 -1
- package/dist/utils/hotUpdateCache.mjs +0 -3
- package/dist/utils/hotUpdateCache.mjs.map +0 -1
- package/dist/utils/hotUpdateCache.native.js +0 -3
- package/dist/utils/hotUpdateCache.native.js.map +0 -1
- package/dist/utils/isBuildingNativeBundle.mjs +0 -6
- package/dist/utils/isBuildingNativeBundle.mjs.map +0 -1
- package/dist/utils/isBuildingNativeBundle.native.js +0 -7
- package/dist/utils/isBuildingNativeBundle.native.js.map +0 -1
- package/dist/utils/swapPrebuiltReactModules.mjs +0 -168
- package/dist/utils/swapPrebuiltReactModules.mjs.map +0 -1
- package/dist/utils/swapPrebuiltReactModules.native.js +0 -181
- package/dist/utils/swapPrebuiltReactModules.native.js.map +0 -1
- package/dist/worker.mjs +0 -55
- package/dist/worker.mjs.map +0 -1
- package/dist/worker.native.js +0 -55
- package/dist/worker.native.js.map +0 -1
- package/react-native-template.js +0 -375
- package/src/config/getReactNativeBuildConfig.ts +0 -349
- package/src/plugins/reactNativeHMRPlugin.ts +0 -237
- package/src/utils/filterPluginsForNative.ts +0 -55
- package/src/utils/getReactNativeBundle.ts +0 -243
- package/src/utils/hotUpdateCache.ts +0 -1
- package/src/utils/isBuildingNativeBundle.ts +0 -7
- package/src/utils/swapPrebuiltReactModules.ts +0 -341
- package/src/worker.ts +0 -90
- package/types/config/getReactNativeBuildConfig.d.ts +0 -72
- package/types/config/getReactNativeBuildConfig.d.ts.map +0 -1
- package/types/plugins/reactNativeHMRPlugin.d.ts +0 -10
- package/types/plugins/reactNativeHMRPlugin.d.ts.map +0 -1
- package/types/utils/filterPluginsForNative.d.ts +0 -8
- package/types/utils/filterPluginsForNative.d.ts.map +0 -1
- package/types/utils/getReactNativeBundle.d.ts +0 -12
- package/types/utils/getReactNativeBundle.d.ts.map +0 -1
- package/types/utils/hotUpdateCache.d.ts +0 -2
- package/types/utils/hotUpdateCache.d.ts.map +0 -1
- package/types/utils/isBuildingNativeBundle.d.ts +0 -3
- package/types/utils/isBuildingNativeBundle.d.ts.map +0 -1
- package/types/utils/swapPrebuiltReactModules.d.ts +0 -9
- package/types/utils/swapPrebuiltReactModules.d.ts.map +0 -1
- package/types/worker.d.ts +0 -13
- package/types/worker.d.ts.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* native bundle prelude - minimal globals for React Native.
|
|
3
|
+
* injected via rolldown's `intro` output option.
|
|
4
|
+
* rolldown's devMode handles the module system.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// this is output as a raw string, not compiled as a module
|
|
8
|
+
export function getNativePrelude(options: {
|
|
9
|
+
dev: boolean
|
|
10
|
+
platform: string
|
|
11
|
+
serverUrl?: string
|
|
12
|
+
}): string {
|
|
13
|
+
return `
|
|
14
|
+
var __BUNDLE_START_TIME__ = globalThis.nativePerformanceNow ? nativePerformanceNow() : Date.now();
|
|
15
|
+
|
|
16
|
+
var global = typeof globalThis !== 'undefined' ? globalThis
|
|
17
|
+
: typeof global !== 'undefined' ? global
|
|
18
|
+
: typeof window !== 'undefined' ? window
|
|
19
|
+
: this;
|
|
20
|
+
|
|
21
|
+
globalThis.global = global;
|
|
22
|
+
globalThis.__DEV__ = ${options.dev};
|
|
23
|
+
|
|
24
|
+
// react native polyfills
|
|
25
|
+
global.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__ = false;
|
|
26
|
+
global.Event = global.Event || function() { return this; };
|
|
27
|
+
global.dispatchEvent = global.dispatchEvent || function() {};
|
|
28
|
+
global.window = global.window || global;
|
|
29
|
+
global.self = global.self || global;
|
|
30
|
+
global.navigator = global.navigator || { product: 'ReactNative', userAgent: '' };
|
|
31
|
+
global.performance = global.performance || { now: function() { return Date.now(); } };
|
|
32
|
+
|
|
33
|
+
// ErrorUtils - used by RN's error handling system
|
|
34
|
+
if (!global.ErrorUtils) {
|
|
35
|
+
var _handler = null;
|
|
36
|
+
global.ErrorUtils = {
|
|
37
|
+
setGlobalHandler: function(h) { _handler = h; },
|
|
38
|
+
getGlobalHandler: function() { return _handler; },
|
|
39
|
+
reportFatalError: function(e) { if (_handler) _handler(e, true); else throw e; },
|
|
40
|
+
reportError: function(e) { if (_handler) _handler(e, false); },
|
|
41
|
+
applyWithGuard: function(fn, ctx, args) { try { return fn.apply(ctx, args); } catch(e) { this.reportError(e); } },
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (typeof process === 'undefined') {
|
|
46
|
+
globalThis.process = { env: {} };
|
|
47
|
+
}
|
|
48
|
+
process.env.NODE_ENV = ${JSON.stringify(options.dev ? 'development' : 'production')};
|
|
49
|
+
process.env.EXPO_OS = ${JSON.stringify(options.platform)};
|
|
50
|
+
${options.serverUrl ? `process.env.ONE_SERVER_URL = ${JSON.stringify(options.serverUrl)};` : ''}
|
|
51
|
+
|
|
52
|
+
// polyfill setImmediate (used by react-native internals)
|
|
53
|
+
if (typeof globalThis.setImmediate === 'undefined') {
|
|
54
|
+
globalThis.setImmediate = function(fn) { return setTimeout(fn, 0); };
|
|
55
|
+
globalThis.clearImmediate = function(id) { clearTimeout(id); };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// polyfill URLSearchParams early (before whatwg-fetch checks for it)
|
|
59
|
+
// RN's polyfillGlobal sets this up later but some modules check at import time
|
|
60
|
+
if (typeof globalThis.URLSearchParams === 'undefined') {
|
|
61
|
+
// minimal URLSearchParams polyfill - will be overridden by RN's proper one
|
|
62
|
+
globalThis.URLSearchParams = function URLSearchParams(init) {
|
|
63
|
+
this._params = {};
|
|
64
|
+
if (typeof init === 'string') {
|
|
65
|
+
init.replace(/^\\?/, '').split('&').forEach(function(p) {
|
|
66
|
+
var kv = p.split('=');
|
|
67
|
+
if (kv[0]) this._params[decodeURIComponent(kv[0])] = decodeURIComponent(kv[1] || '');
|
|
68
|
+
}.bind(this));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
globalThis.URLSearchParams.prototype.get = function(k) { return this._params[k] || null; };
|
|
72
|
+
globalThis.URLSearchParams.prototype.toString = function() {
|
|
73
|
+
return Object.keys(this._params).map(function(k) { return encodeURIComponent(k) + '=' + encodeURIComponent(this._params[k]); }.bind(this)).join('&');
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// suppress HMRClient.setup() error from native side
|
|
78
|
+
// native calls HMRClient.setup() during bundle load but we don't use Metro HMR
|
|
79
|
+
// this intercept catches the error and prevents the red screen
|
|
80
|
+
var __origErrorHandler = globalThis.ErrorUtils && globalThis.ErrorUtils.getGlobalHandler && globalThis.ErrorUtils.getGlobalHandler();
|
|
81
|
+
if (globalThis.ErrorUtils && globalThis.ErrorUtils.setGlobalHandler) {
|
|
82
|
+
globalThis.ErrorUtils.setGlobalHandler(function(error, isFatal) {
|
|
83
|
+
if (error && error.message && error.message.indexOf('HMRClient') !== -1) {
|
|
84
|
+
// suppress HMRClient errors silently
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (__origErrorHandler) __origErrorHandler(error, isFatal);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// reanimated compat - these console methods must exist to avoid EXC_BAD_ACCESS crash
|
|
92
|
+
console.assert = console.assert || function() {};
|
|
93
|
+
console.clear = console.clear || function() {};
|
|
94
|
+
console.dir = console.dir || function() {};
|
|
95
|
+
console.dirxml = console.dirxml || function() {};
|
|
96
|
+
console.profile = console.profile || function() {};
|
|
97
|
+
console.profileEnd = console.profileEnd || function() {};
|
|
98
|
+
console.table = console.table || function() {};
|
|
99
|
+
|
|
100
|
+
// react refresh stubs (overridden by react-refresh plugin in dev)
|
|
101
|
+
${
|
|
102
|
+
options.dev
|
|
103
|
+
? `
|
|
104
|
+
var $RefreshReg$ = function() {};
|
|
105
|
+
var $RefreshSig$ = function() { return function(v) { return v; }; };
|
|
106
|
+
`
|
|
107
|
+
: ''
|
|
108
|
+
}
|
|
109
|
+
`.trim()
|
|
110
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function isReactRefreshBoundary(moduleExports: Record<string, unknown>) {
|
|
2
|
+
if (globalThis.__ReactRefresh.isLikelyComponentType(moduleExports)) {
|
|
3
|
+
return true
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (
|
|
7
|
+
moduleExports === undefined ||
|
|
8
|
+
moduleExports === null ||
|
|
9
|
+
typeof moduleExports !== 'object'
|
|
10
|
+
) {
|
|
11
|
+
return false
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var hasExports = false
|
|
15
|
+
var areAllExportsComponents = true
|
|
16
|
+
for (var key in moduleExports) {
|
|
17
|
+
hasExports = true
|
|
18
|
+
if (key === '__esModule') continue
|
|
19
|
+
var exportValue = moduleExports[key]
|
|
20
|
+
if (!globalThis.__ReactRefresh.isLikelyComponentType(exportValue)) {
|
|
21
|
+
areAllExportsComponents = false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return hasExports && areAllExportsComponents
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let timer: ReturnType<typeof setTimeout> | null = null
|
|
29
|
+
|
|
30
|
+
export function enqueueUpdate() {
|
|
31
|
+
if (timer) return
|
|
32
|
+
timer = setTimeout(() => {
|
|
33
|
+
globalThis.__ReactRefresh.performReactRefresh()
|
|
34
|
+
timer = null
|
|
35
|
+
}, 50)
|
|
36
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -112,6 +112,21 @@ export type VXRNOptions = {
|
|
|
112
112
|
* @default false
|
|
113
113
|
*/
|
|
114
114
|
loadEnv?: boolean
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Custom cache-control rules for static assets.
|
|
118
|
+
* Map of glob patterns to Cache-Control header values.
|
|
119
|
+
* Hashed assets (e.g. app-CB4EB78V.js) are always immutable.
|
|
120
|
+
* Unmatched assets default to must-revalidate.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* cacheControl: {
|
|
124
|
+
* '*.worker.js': 'public, max-age=86400, stale-while-revalidate=604800',
|
|
125
|
+
* '*.wasm': 'public, max-age=86400',
|
|
126
|
+
* '/deps-*\/**': 'public, max-age=86400',
|
|
127
|
+
* }
|
|
128
|
+
*/
|
|
129
|
+
cacheControl?: Record<string, string>
|
|
115
130
|
}
|
|
116
131
|
|
|
117
132
|
/**
|
|
@@ -135,10 +150,13 @@ export type HMRListener = (update: { file: string; contents: string }) => void
|
|
|
135
150
|
|
|
136
151
|
type VXRNServeOptionsBase = VXRNOptions['server']
|
|
137
152
|
|
|
138
|
-
export type VXRNServeOptionsFilled = Required<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
export type VXRNServeOptionsFilled = Required<
|
|
154
|
+
Omit<NonNullable<VXRNServeOptionsBase>, 'cacheControl'>
|
|
155
|
+
> &
|
|
156
|
+
Pick<NonNullable<VXRNServeOptionsBase>, 'cacheControl'> & {
|
|
157
|
+
url: string
|
|
158
|
+
protocol: string
|
|
159
|
+
}
|
|
142
160
|
|
|
143
161
|
export type VXRNServeOptions = VXRNServeOptionsBase & {
|
|
144
162
|
app?: Hono
|