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,702 @@
|
|
|
1
|
+
import { writeFileSync } from "fs";
|
|
2
|
+
import { basename, dirname, extname, join, relative } from "path";
|
|
3
|
+
import { DEFAULT_ASSET_EXTS } from "../constants/defaults.native.js";
|
|
4
|
+
import { getNativePrelude } from "../runtime/native-prelude.native.js";
|
|
5
|
+
function _instanceof(left, right) {
|
|
6
|
+
return right != null && typeof Symbol < "u" && right[Symbol.hasInstance] ? !!right[Symbol.hasInstance](left) : left instanceof right;
|
|
7
|
+
}
|
|
8
|
+
var FLOW_FILE_PATTERN = /node_modules[\\/](?:react-native|@react-native)[\\/].*\.js$/;
|
|
9
|
+
function getResolveExtensions(platform) {
|
|
10
|
+
var platformExts = platform === "ios" ? [".ios.tsx", ".ios.ts", ".ios.jsx", ".ios.js"] : [".android.tsx", ".android.ts", ".android.jsx", ".android.js"],
|
|
11
|
+
nativeExts = [".native.tsx", ".native.ts", ".native.jsx", ".native.js"],
|
|
12
|
+
defaultExts = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs", ".json"];
|
|
13
|
+
return [...platformExts, ...nativeExts, ...defaultExts];
|
|
14
|
+
}
|
|
15
|
+
function getNativeResolveConfig(platform) {
|
|
16
|
+
return {
|
|
17
|
+
extensions: getResolveExtensions(platform),
|
|
18
|
+
conditionNames: ["react-native", "import", "require", "default"],
|
|
19
|
+
mainFields: ["react-native", "module", "main"]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function getNativeTransformConfig(dev) {
|
|
23
|
+
return {
|
|
24
|
+
jsx: {
|
|
25
|
+
// use 'classic' mode (babel plugin-transform-react-jsx)
|
|
26
|
+
// 'automatic' has files where jsxDEV import fails to resolve
|
|
27
|
+
runtime: "classic"
|
|
28
|
+
},
|
|
29
|
+
define: {
|
|
30
|
+
"process.env.NODE_ENV": dev ? '"development"' : '"production"',
|
|
31
|
+
"process.env.VXRN_REACT_19": "false",
|
|
32
|
+
__DEV__: dev ? "true" : "false"
|
|
33
|
+
},
|
|
34
|
+
// auto-inject React import for classic JSX (React.createElement)
|
|
35
|
+
inject: {
|
|
36
|
+
React: "react"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function getNativePlugins(root, platform, viteImportGlobPlugin, dev) {
|
|
41
|
+
return [
|
|
42
|
+
// stub CSS imports — native doesn't support CSS and rolldown removed CSS bundling
|
|
43
|
+
cssStubPlugin(),
|
|
44
|
+
// handle import.meta.glob (used by One's route system)
|
|
45
|
+
viteImportGlobPlugin({
|
|
46
|
+
root
|
|
47
|
+
}),
|
|
48
|
+
// strip Flow types from react-native and @react-native packages
|
|
49
|
+
flowStripPlugin(),
|
|
50
|
+
// handle asset imports (.png, .jpg, .ttf, etc.)
|
|
51
|
+
assetPlugin({
|
|
52
|
+
root,
|
|
53
|
+
platform
|
|
54
|
+
}),
|
|
55
|
+
// @vxrn/compiler babel transforms: reanimated worklets, async generators,
|
|
56
|
+
// react-native codegen, react compiler — same pipeline as metro
|
|
57
|
+
vxrnCompilerPlugin(platform, dev),
|
|
58
|
+
// hermes compat: transform class properties and private fields
|
|
59
|
+
hermesCompatSWCPlugin(dev),
|
|
60
|
+
// downgrade polyfill "not configurable" errors to warnings (hermes v1)
|
|
61
|
+
polyfillErrorDowngradePlugin(),
|
|
62
|
+
// strip DevSettings in prod (dev-only native module)
|
|
63
|
+
stripDevSettingsPlugin(dev)];
|
|
64
|
+
}
|
|
65
|
+
function getNativeOutputOptions(prelude) {
|
|
66
|
+
return {
|
|
67
|
+
format: "esm",
|
|
68
|
+
sourcemap: !0,
|
|
69
|
+
intro: prelude,
|
|
70
|
+
codeSplitting: !1,
|
|
71
|
+
strictExecutionOrder: !0
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function postProcessNativeBundle(code) {
|
|
75
|
+
return code = code.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm, ""), code = code.replace(/^if \(import\.meta\.hot\).*$/gm, ""), code;
|
|
76
|
+
}
|
|
77
|
+
async function downlevelClassFieldsInBundle(code) {
|
|
78
|
+
var startMarker = "//#region \\0rolldown/runtime.js",
|
|
79
|
+
endMarker = "//#endregion",
|
|
80
|
+
startIdx = code.indexOf(startMarker);
|
|
81
|
+
if (startIdx === -1) return code;
|
|
82
|
+
var endIdx = code.indexOf(endMarker, startIdx);
|
|
83
|
+
if (endIdx === -1) return code;
|
|
84
|
+
var runtimeEnd = endIdx + endMarker.length,
|
|
85
|
+
runtimeSection = code.slice(startIdx, runtimeEnd);
|
|
86
|
+
try {
|
|
87
|
+
var swc = await import("@swc/core"),
|
|
88
|
+
result = await swc.transform(runtimeSection, {
|
|
89
|
+
filename: "rolldown-runtime.js",
|
|
90
|
+
configFile: !1,
|
|
91
|
+
swcrc: !1,
|
|
92
|
+
sourceMaps: !1,
|
|
93
|
+
inputSourceMap: !1,
|
|
94
|
+
isModule: !1,
|
|
95
|
+
env: {
|
|
96
|
+
targets: {
|
|
97
|
+
node: 9999
|
|
98
|
+
},
|
|
99
|
+
include: ["transform-class-properties", "transform-class-static-block", "transform-private-methods", "transform-private-property-in-object"]
|
|
100
|
+
},
|
|
101
|
+
jsc: {
|
|
102
|
+
parser: {
|
|
103
|
+
syntax: "ecmascript"
|
|
104
|
+
},
|
|
105
|
+
transform: {
|
|
106
|
+
react: {
|
|
107
|
+
runtime: "preserve"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
externalHelpers: !1,
|
|
111
|
+
assumptions: {
|
|
112
|
+
setPublicClassFields: !0,
|
|
113
|
+
privateFieldsAsProperties: !0
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return code.slice(0, startIdx) + result.code + code.slice(runtimeEnd);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
return console.warn("[vxrn] downlevelClassFieldsInBundle failed, returning original:", err), code;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function createNativeDevEngine(options) {
|
|
123
|
+
var {
|
|
124
|
+
root,
|
|
125
|
+
port,
|
|
126
|
+
host = "localhost",
|
|
127
|
+
platform,
|
|
128
|
+
serverUrl,
|
|
129
|
+
plugins: userPlugins = [],
|
|
130
|
+
onHmrUpdate
|
|
131
|
+
} = options,
|
|
132
|
+
{
|
|
133
|
+
dev,
|
|
134
|
+
viteImportGlobPlugin
|
|
135
|
+
} = await import("rolldown/experimental"),
|
|
136
|
+
hmrRuntimeSource = getHmrRuntimeSource(),
|
|
137
|
+
prelude = getNativePrelude({
|
|
138
|
+
dev: !0,
|
|
139
|
+
platform,
|
|
140
|
+
serverUrl: serverUrl || `http://${host}:${port}`
|
|
141
|
+
}),
|
|
142
|
+
entryFile = generateNativeEntry(root),
|
|
143
|
+
currentBundle = null,
|
|
144
|
+
bundleResolve = null,
|
|
145
|
+
bundlePromise = null,
|
|
146
|
+
resolvedHost = host === "0.0.0.0" ? "localhost" : host,
|
|
147
|
+
inputOptions = {
|
|
148
|
+
input: entryFile,
|
|
149
|
+
cwd: root,
|
|
150
|
+
platform: "neutral",
|
|
151
|
+
resolve: getNativeResolveConfig(platform),
|
|
152
|
+
transform: getNativeTransformConfig(!0),
|
|
153
|
+
experimental: {
|
|
154
|
+
devMode: {
|
|
155
|
+
implement: hmrRuntimeSource,
|
|
156
|
+
host,
|
|
157
|
+
port
|
|
158
|
+
},
|
|
159
|
+
incrementalBuild: !0
|
|
160
|
+
},
|
|
161
|
+
treeshake: !1,
|
|
162
|
+
// some react-native ecosystem packages import symbols that don't exist in
|
|
163
|
+
// the declared entry (e.g. @react-navigation/elements imports NavigationProvider
|
|
164
|
+
// from @react-navigation/native which doesn't export it). metro silently shims
|
|
165
|
+
// these — rolldown needs an explicit opt-in.
|
|
166
|
+
shimMissingExports: !0,
|
|
167
|
+
moduleTypes: {
|
|
168
|
+
".js": "jsx"
|
|
169
|
+
},
|
|
170
|
+
plugins: [...getNativePlugins(root, platform, viteImportGlobPlugin, !0),
|
|
171
|
+
// add import.meta.hot.accept() to user files for HMR boundaries
|
|
172
|
+
// rolldown compiles import.meta.hot -> createModuleHotContext at build time
|
|
173
|
+
nativeReactRefreshPlugin(), ...userPlugins]
|
|
174
|
+
},
|
|
175
|
+
outputOptions = {
|
|
176
|
+
...getNativeOutputOptions(prelude),
|
|
177
|
+
// connect HMR WebSocket using RN's WebSocket module (not the global)
|
|
178
|
+
outro: `
|
|
179
|
+
try {
|
|
180
|
+
var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
|
|
181
|
+
var __hmrUrl = 'ws://${resolvedHost}:${port}/hot';
|
|
182
|
+
var __hmrWS = new __WS(__hmrUrl);
|
|
183
|
+
__hmrWS.onmessage = function(event) {
|
|
184
|
+
try {
|
|
185
|
+
var msg = JSON.parse(event.data);
|
|
186
|
+
var g = typeof global !== 'undefined' ? global : globalThis;
|
|
187
|
+
if (msg.type === 'hmr:update' && msg.code) {
|
|
188
|
+
if (g.globalEvalWithSourceUrl) g.globalEvalWithSourceUrl(msg.code);
|
|
189
|
+
else (0, eval)(msg.code);
|
|
190
|
+
setTimeout(function() {
|
|
191
|
+
try { if (g.__ReactRefresh) g.__ReactRefresh.performReactRefresh(); } catch(e) {}
|
|
192
|
+
}, 50);
|
|
193
|
+
} else if (msg.type === 'hmr:reload') {
|
|
194
|
+
var ds = g.__turboModuleProxy ? g.__turboModuleProxy('DevSettings') : null;
|
|
195
|
+
if (ds && ds.reload) ds.reload();
|
|
196
|
+
}
|
|
197
|
+
} catch(e) { console.error('[vxrn] HMR eval error:', e); }
|
|
198
|
+
};
|
|
199
|
+
__hmrWS.onopen = function() {
|
|
200
|
+
if (typeof __rolldown_runtime__ !== 'undefined' && __rolldown_runtime__.setup) {
|
|
201
|
+
__rolldown_runtime__.setup(__hmrWS, __hmrUrl.replace('ws://', 'http://'));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
__hmrWS.onerror = function(e) { console.warn('[vxrn] HMR connection error:', e.message || e); };
|
|
205
|
+
} catch(e) {}
|
|
206
|
+
`
|
|
207
|
+
},
|
|
208
|
+
engine = await dev(inputOptions, outputOptions, {
|
|
209
|
+
onOutput: async function (result) {
|
|
210
|
+
if (_instanceof(result, Error)) {
|
|
211
|
+
console.error("[vxrn] native bundle error:", result.message);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
var output = result,
|
|
215
|
+
chunk = output.output.find(function (o) {
|
|
216
|
+
return o.type === "chunk" && o.isEntry;
|
|
217
|
+
});
|
|
218
|
+
if (chunk && "code" in chunk) {
|
|
219
|
+
var _chunk_map,
|
|
220
|
+
code = postProcessNativeBundle(chunk.code);
|
|
221
|
+
code = await downlevelClassFieldsInBundle(code);
|
|
222
|
+
var hmrClientStub = 'registerCallableModule("HMRClient",{setup:function(){},enable:function(){},disable:function(){},registerBundle:function(){},log:function(){}})';
|
|
223
|
+
code = code.replace(/registerCallableModule\s*\(\s*["']AppRegistry["']/, function (match) {
|
|
224
|
+
return hmrClientStub + "," + match;
|
|
225
|
+
}), currentBundle = {
|
|
226
|
+
code,
|
|
227
|
+
map: (_chunk_map = chunk.map) === null || _chunk_map === void 0 ? void 0 : _chunk_map.toString()
|
|
228
|
+
}, console.info(`[vxrn] native bundle ready (${Math.round(chunk.code.length / 1024)}KB)`), bundleResolve && (bundleResolve(currentBundle), bundleResolve = null, bundlePromise = null);
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
onHmrUpdates: async function (result) {
|
|
232
|
+
if (_instanceof(result, Error)) {
|
|
233
|
+
console.error("[vxrn] HMR error:", result.message), onHmrUpdate?.({
|
|
234
|
+
type: "hmr:error"
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
var updates = result.updates || [],
|
|
239
|
+
_iteratorNormalCompletion = !0,
|
|
240
|
+
_didIteratorError = !1,
|
|
241
|
+
_iteratorError = void 0;
|
|
242
|
+
try {
|
|
243
|
+
for (var _iterator = updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
244
|
+
var item = _step.value,
|
|
245
|
+
update = item.update || item;
|
|
246
|
+
update.type === "Patch" && update.code ? onHmrUpdate?.({
|
|
247
|
+
type: "hmr:update",
|
|
248
|
+
code: update.code
|
|
249
|
+
}) : update.type === "FullReload" && onHmrUpdate?.({
|
|
250
|
+
type: "hmr:reload"
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
} catch (err) {
|
|
254
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
255
|
+
} finally {
|
|
256
|
+
try {
|
|
257
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
258
|
+
} finally {
|
|
259
|
+
if (_didIteratorError) throw _iteratorError;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
updates.length === 0 && onHmrUpdate?.({
|
|
263
|
+
type: "hmr:reload"
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
rebuildStrategy: "auto",
|
|
267
|
+
watch: {}
|
|
268
|
+
});
|
|
269
|
+
return await engine.run(), {
|
|
270
|
+
engine,
|
|
271
|
+
async getBundle() {
|
|
272
|
+
if (currentBundle) return currentBundle;
|
|
273
|
+
if (!bundlePromise) {
|
|
274
|
+
var timeoutId;
|
|
275
|
+
bundlePromise = new Promise(function (resolve, reject) {
|
|
276
|
+
bundleResolve = function (value) {
|
|
277
|
+
clearTimeout(timeoutId), resolve(value);
|
|
278
|
+
}, timeoutId = setTimeout(function () {
|
|
279
|
+
return reject(new Error("[vxrn] bundle build timed out after 120s"));
|
|
280
|
+
}, 12e4);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return await engine.ensureLatestBuildOutput(), currentBundle || bundlePromise;
|
|
284
|
+
},
|
|
285
|
+
async close() {
|
|
286
|
+
await engine.close();
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
async function buildNativeBundle(options) {
|
|
291
|
+
var _chunk_map,
|
|
292
|
+
{
|
|
293
|
+
root,
|
|
294
|
+
platform,
|
|
295
|
+
dev = !1,
|
|
296
|
+
serverUrl,
|
|
297
|
+
plugins: userPlugins = []
|
|
298
|
+
} = options,
|
|
299
|
+
{
|
|
300
|
+
build
|
|
301
|
+
} = await import("rolldown"),
|
|
302
|
+
{
|
|
303
|
+
viteImportGlobPlugin
|
|
304
|
+
} = await import("rolldown/experimental"),
|
|
305
|
+
prelude = getNativePrelude({
|
|
306
|
+
dev,
|
|
307
|
+
platform,
|
|
308
|
+
serverUrl
|
|
309
|
+
}),
|
|
310
|
+
entryFile = generateNativeEntry(root, {
|
|
311
|
+
dev
|
|
312
|
+
}),
|
|
313
|
+
result = await build({
|
|
314
|
+
input: entryFile,
|
|
315
|
+
cwd: root,
|
|
316
|
+
platform: "neutral",
|
|
317
|
+
resolve: getNativeResolveConfig(platform),
|
|
318
|
+
transform: getNativeTransformConfig(dev),
|
|
319
|
+
treeshake: !dev,
|
|
320
|
+
shimMissingExports: !0,
|
|
321
|
+
moduleTypes: {
|
|
322
|
+
".js": "jsx"
|
|
323
|
+
},
|
|
324
|
+
plugins: [...getNativePlugins(root, platform, viteImportGlobPlugin, dev), ...userPlugins],
|
|
325
|
+
output: getNativeOutputOptions(prelude)
|
|
326
|
+
}),
|
|
327
|
+
chunk = result.output.find(function (o) {
|
|
328
|
+
return o.type === "chunk" && o.isEntry;
|
|
329
|
+
});
|
|
330
|
+
if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
|
|
331
|
+
var code = postProcessNativeBundle(chunk.code);
|
|
332
|
+
return code = await downlevelClassFieldsInBundle(code), {
|
|
333
|
+
code,
|
|
334
|
+
map: (_chunk_map = chunk.map) === null || _chunk_map === void 0 ? void 0 : _chunk_map.toString()
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function generateNativeEntry(root, opts) {
|
|
338
|
+
var isDev = opts?.dev !== !1,
|
|
339
|
+
entryPath = join(root, ".vxrn-entry-native.tsx"),
|
|
340
|
+
refreshSetup = isDev ? `
|
|
341
|
+
// react-refresh/runtime MUST initialize before React loads
|
|
342
|
+
import RefreshRuntime from 'react-refresh/runtime';
|
|
343
|
+
RefreshRuntime.injectIntoGlobalHook(globalThis);
|
|
344
|
+
globalThis.__ReactRefresh = RefreshRuntime;
|
|
345
|
+
globalThis.$RefreshReg$ = function(type, id) {
|
|
346
|
+
RefreshRuntime.register(type, id);
|
|
347
|
+
};
|
|
348
|
+
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
349
|
+
` : "",
|
|
350
|
+
entryCode = `
|
|
351
|
+
// auto-generated native entry for rolldown
|
|
352
|
+
${refreshSetup}
|
|
353
|
+
import { createApp } from 'one';
|
|
354
|
+
|
|
355
|
+
var _routes = import.meta.glob(['./app/**/*.tsx', './app/**/*.ts', '!./app/**/*+api.*', '!./app/**/*.test.*', '!./app/**/*.d.ts'], { exhaustive: true });
|
|
356
|
+
// fix route keys: One expects '/app/...' prefix but import.meta.glob returns './app/...'
|
|
357
|
+
var routes = {};
|
|
358
|
+
Object.keys(_routes).forEach(function(key) {
|
|
359
|
+
routes[key.replace(/^\\./, '')] = _routes[key];
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
createApp({
|
|
363
|
+
routes: routes,
|
|
364
|
+
routerRoot: 'app',
|
|
365
|
+
flags: {},
|
|
366
|
+
});
|
|
367
|
+
`;
|
|
368
|
+
return writeFileSync(entryPath, entryCode), entryPath;
|
|
369
|
+
}
|
|
370
|
+
function cssStubPlugin() {
|
|
371
|
+
return {
|
|
372
|
+
name: "vxrn:css-stub",
|
|
373
|
+
load: {
|
|
374
|
+
handler(id) {
|
|
375
|
+
if (/\.css$/.test(id)) return {
|
|
376
|
+
code: "",
|
|
377
|
+
moduleType: "js"
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function vxrnCompilerPlugin(platform, dev) {
|
|
384
|
+
var compiler = null;
|
|
385
|
+
return {
|
|
386
|
+
name: "vxrn:compiler",
|
|
387
|
+
async transform(code, id) {
|
|
388
|
+
if (/\.[cm]?[jt]sx?$/.test(id) && !(id.includes("\0") || id.includes("virtual:"))) try {
|
|
389
|
+
compiler || (compiler = await import("@vxrn/compiler"));
|
|
390
|
+
var props = {
|
|
391
|
+
id,
|
|
392
|
+
code,
|
|
393
|
+
development: dev,
|
|
394
|
+
environment: platform,
|
|
395
|
+
reactForRNVersion: "19"
|
|
396
|
+
},
|
|
397
|
+
babelOptions = compiler.getBabelOptions(props);
|
|
398
|
+
if (!babelOptions) return;
|
|
399
|
+
var result = await compiler.transformBabel(id, code, babelOptions);
|
|
400
|
+
if (result?.code) return {
|
|
401
|
+
code: result.code
|
|
402
|
+
};
|
|
403
|
+
} catch (err) {
|
|
404
|
+
dev && console.warn(`[vxrn:compiler] ${id}: ${err.message || err}`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function flowStripPlugin() {
|
|
410
|
+
return {
|
|
411
|
+
name: "vxrn:flow-strip",
|
|
412
|
+
transform: {
|
|
413
|
+
async handler(code, id) {
|
|
414
|
+
if (FLOW_FILE_PATTERN.test(id)) try {
|
|
415
|
+
var fft = await import("fast-flow-transform"),
|
|
416
|
+
result = await fft.default({
|
|
417
|
+
filename: id,
|
|
418
|
+
source: code,
|
|
419
|
+
sourcemap: !0,
|
|
420
|
+
dialect: "flow",
|
|
421
|
+
format: "pretty"
|
|
422
|
+
});
|
|
423
|
+
return {
|
|
424
|
+
code: result.code,
|
|
425
|
+
map: result.map
|
|
426
|
+
};
|
|
427
|
+
} catch (err) {
|
|
428
|
+
console.warn(`[vxrn:flow-strip] ${id}: ${err.message}`);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
function assetPlugin(opts) {
|
|
435
|
+
var assetRegex = new RegExp(`\\.(?:${DEFAULT_ASSET_EXTS.join("|")})$`);
|
|
436
|
+
return {
|
|
437
|
+
name: "vxrn:asset",
|
|
438
|
+
load: {
|
|
439
|
+
async handler(id) {
|
|
440
|
+
if (assetRegex.test(id)) {
|
|
441
|
+
var ext = extname(id).slice(1),
|
|
442
|
+
name = basename(id, `.${ext}`),
|
|
443
|
+
dir = dirname(id),
|
|
444
|
+
relativePath = relative(opts.root, id),
|
|
445
|
+
httpLocation = "/assets/" + dirname(relativePath),
|
|
446
|
+
assetData = {
|
|
447
|
+
__packager_asset: !0,
|
|
448
|
+
name,
|
|
449
|
+
type: ext,
|
|
450
|
+
scales: [1],
|
|
451
|
+
httpServerLocation: httpLocation,
|
|
452
|
+
fileSystemLocation: dir,
|
|
453
|
+
hash: "",
|
|
454
|
+
width: void 0,
|
|
455
|
+
height: void 0
|
|
456
|
+
};
|
|
457
|
+
if (["png", "jpg", "jpeg", "gif", "webp", "bmp"].includes(ext)) try {
|
|
458
|
+
var {
|
|
459
|
+
imageSize
|
|
460
|
+
} = await import("image-size"),
|
|
461
|
+
dims = imageSize(id);
|
|
462
|
+
assetData.width = dims.width, assetData.height = dims.height;
|
|
463
|
+
} catch {}
|
|
464
|
+
var code = `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`;
|
|
465
|
+
return {
|
|
466
|
+
code,
|
|
467
|
+
moduleType: "js"
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function hermesCompatSWCPlugin(dev) {
|
|
475
|
+
var swc = null;
|
|
476
|
+
return {
|
|
477
|
+
name: "vxrn:hermes-compat",
|
|
478
|
+
async transform(code, id) {
|
|
479
|
+
if (/\.[cm]?[jt]sx?$/.test(id) && !(id.includes("\0") || id.includes("virtual:"))) {
|
|
480
|
+
var hasClass = code.includes("class ") || code.includes("class{"),
|
|
481
|
+
hasAsync = !dev && code.includes("async ");
|
|
482
|
+
if (!(!hasClass && !hasAsync) && !(code.length > 5e5)) try {
|
|
483
|
+
swc || (swc = await import("@swc/core"));
|
|
484
|
+
var envIncludes = ["transform-class-properties", "transform-class-static-block", "transform-private-methods", "transform-private-property-in-object", ...(dev ? [] : ["transform-classes", "transform-async-to-generator"])],
|
|
485
|
+
result = await swc.transform(code, {
|
|
486
|
+
filename: id,
|
|
487
|
+
configFile: !1,
|
|
488
|
+
swcrc: !1,
|
|
489
|
+
sourceMaps: !1,
|
|
490
|
+
inputSourceMap: !1,
|
|
491
|
+
env: {
|
|
492
|
+
targets: {
|
|
493
|
+
node: 9999
|
|
494
|
+
},
|
|
495
|
+
include: envIncludes
|
|
496
|
+
},
|
|
497
|
+
jsc: {
|
|
498
|
+
parser: {
|
|
499
|
+
syntax: "typescript",
|
|
500
|
+
tsx: !0
|
|
501
|
+
},
|
|
502
|
+
transform: {
|
|
503
|
+
react: {
|
|
504
|
+
runtime: "preserve"
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
externalHelpers: !1,
|
|
508
|
+
assumptions: {
|
|
509
|
+
setPublicClassFields: !0,
|
|
510
|
+
privateFieldsAsProperties: !0
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
isModule: !id.endsWith(".cjs")
|
|
514
|
+
});
|
|
515
|
+
return {
|
|
516
|
+
code: result.code
|
|
517
|
+
};
|
|
518
|
+
} catch {}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function polyfillErrorDowngradePlugin() {
|
|
524
|
+
return {
|
|
525
|
+
name: "vxrn:polyfill-error-downgrade",
|
|
526
|
+
transform(code, id) {
|
|
527
|
+
if (id.includes("node_modules") && code.includes('console.error("Failed to set polyfill.')) return {
|
|
528
|
+
code: code.replace(/console\.error\(\s*"Failed to set polyfill\.\s*"\s*\+/g, 'console.warn("Failed to set polyfill. " +')
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
function stripDevSettingsPlugin(dev) {
|
|
534
|
+
return {
|
|
535
|
+
name: "vxrn:strip-dev-settings",
|
|
536
|
+
transform(code, id) {
|
|
537
|
+
if (!dev && code.includes("DevSettings")) return {
|
|
538
|
+
code: code.replace(/getEnforcing\s*\(\s*["']DevSettings["']\s*\)/g, "patched_getEnforcing_DevSettings_will_not_work_in_production()")
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
function nativeReactRefreshPlugin() {
|
|
544
|
+
return {
|
|
545
|
+
name: "vxrn:react-refresh",
|
|
546
|
+
async transform(code, id) {
|
|
547
|
+
if (!id.includes("node_modules") && !id.includes(".vxrn-entry-native") && !id.startsWith("\0") && /\.[tj]sx?$/.test(id) && /[<]|function\s|=>\s*[{(]/.test(code)) try {
|
|
548
|
+
var babel = await import("@babel/core"),
|
|
549
|
+
parserPlugins = [];
|
|
550
|
+
id.endsWith(".tsx") ? parserPlugins.push(["@babel/plugin-syntax-typescript", {
|
|
551
|
+
isTSX: !0
|
|
552
|
+
}]) : id.endsWith(".ts") ? parserPlugins.push("@babel/plugin-syntax-typescript") : id.endsWith(".jsx") && parserPlugins.push("@babel/plugin-syntax-jsx");
|
|
553
|
+
var result = await babel.transformAsync(code, {
|
|
554
|
+
filename: id,
|
|
555
|
+
babelrc: !1,
|
|
556
|
+
configFile: !1,
|
|
557
|
+
compact: !1,
|
|
558
|
+
plugins: [...parserPlugins, "react-refresh/babel"],
|
|
559
|
+
sourceType: "unambiguous"
|
|
560
|
+
});
|
|
561
|
+
if (result?.code) {
|
|
562
|
+
var escapedId = id.replace(/\\/g, "\\\\").replace(/"/g, '\\"'),
|
|
563
|
+
wrappedCode = `
|
|
564
|
+
var __prevRefreshReg = globalThis.$RefreshReg$;
|
|
565
|
+
var __prevRefreshSig = globalThis.$RefreshSig$;
|
|
566
|
+
if (globalThis.__ReactRefresh) {
|
|
567
|
+
globalThis.$RefreshReg$ = function(type, id) {
|
|
568
|
+
globalThis.__ReactRefresh.register(type, "${escapedId}" + " " + id);
|
|
569
|
+
};
|
|
570
|
+
globalThis.$RefreshSig$ = globalThis.__ReactRefresh.createSignatureFunctionForTransform;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
${result.code}
|
|
574
|
+
|
|
575
|
+
globalThis.$RefreshReg$ = __prevRefreshReg;
|
|
576
|
+
globalThis.$RefreshSig$ = __prevRefreshSig;
|
|
577
|
+
if (import.meta.hot) {
|
|
578
|
+
import.meta.hot.accept(function() {
|
|
579
|
+
if (globalThis.__ReactRefresh) {
|
|
580
|
+
setTimeout(function() { globalThis.__ReactRefresh.performReactRefresh(); }, 30);
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
`;
|
|
585
|
+
return {
|
|
586
|
+
code: wrappedCode
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
} catch {
|
|
590
|
+
return {
|
|
591
|
+
code: code + `
|
|
592
|
+
if (import.meta.hot) { import.meta.hot.accept(); }
|
|
593
|
+
`
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function getHmrRuntimeSource() {
|
|
600
|
+
return `
|
|
601
|
+
// vxrn HMR runtime for rolldown devMode
|
|
602
|
+
var BaseDevRuntime = DevRuntime;
|
|
603
|
+
|
|
604
|
+
class ReactNativeDevRuntime extends BaseDevRuntime {
|
|
605
|
+
constructor() {
|
|
606
|
+
var _shared = { _socket: null, _queue: [] };
|
|
607
|
+
var clientId = 'rn-' + Date.now() + '-' + Math.random().toString(36).slice(2);
|
|
608
|
+
super({ send: function(msg) {
|
|
609
|
+
var s = JSON.stringify(msg);
|
|
610
|
+
if (_shared._socket && _shared._socket.readyState === 1) { _shared._socket.send(s); }
|
|
611
|
+
else { _shared._queue.push(s); }
|
|
612
|
+
}}, clientId);
|
|
613
|
+
this._shared = _shared;
|
|
614
|
+
this._socket = null;
|
|
615
|
+
this._queue = [];
|
|
616
|
+
this.moduleHotContexts = {};
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
createModuleHotContext(moduleId) {
|
|
620
|
+
var ctx = {
|
|
621
|
+
acceptCallbacks: [],
|
|
622
|
+
accept: function(cb) {
|
|
623
|
+
if (cb) ctx.acceptCallbacks.push({ deps: [moduleId], fn: cb });
|
|
624
|
+
},
|
|
625
|
+
invalidate: function() {},
|
|
626
|
+
on: function() {},
|
|
627
|
+
off: function() {},
|
|
628
|
+
send: function() {},
|
|
629
|
+
get refresh() { return globalThis.__ReactRefresh; },
|
|
630
|
+
get refreshUtils() {
|
|
631
|
+
return {
|
|
632
|
+
isReactRefreshBoundary: function(exports) {
|
|
633
|
+
if (!globalThis.__ReactRefresh) return false;
|
|
634
|
+
if (globalThis.__ReactRefresh.isLikelyComponentType(exports)) return true;
|
|
635
|
+
if (!exports || typeof exports !== 'object') return false;
|
|
636
|
+
var hasExports = false, allComponents = true;
|
|
637
|
+
for (var key in exports) {
|
|
638
|
+
hasExports = true;
|
|
639
|
+
if (key === '__esModule') continue;
|
|
640
|
+
if (!globalThis.__ReactRefresh.isLikelyComponentType(exports[key])) allComponents = false;
|
|
641
|
+
}
|
|
642
|
+
return hasExports && allComponents;
|
|
643
|
+
},
|
|
644
|
+
enqueueUpdate: function() {
|
|
645
|
+
if (globalThis.__ReactRefresh) {
|
|
646
|
+
setTimeout(function() { globalThis.__ReactRefresh.performReactRefresh(); }, 50);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
this.moduleHotContexts[moduleId] = ctx;
|
|
653
|
+
return ctx;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
applyUpdates(boundaries) {
|
|
657
|
+
for (var i = 0; i < boundaries.length; i++) {
|
|
658
|
+
var moduleId = boundaries[i][0];
|
|
659
|
+
var ctx = this.moduleHotContexts[moduleId];
|
|
660
|
+
if (ctx && ctx.acceptCallbacks) {
|
|
661
|
+
for (var j = 0; j < ctx.acceptCallbacks.length; j++) {
|
|
662
|
+
ctx.acceptCallbacks[j].fn(this.modules[moduleId].exports);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
setup(socket, origin) {
|
|
669
|
+
if (this._socket) return;
|
|
670
|
+
this._socket = socket;
|
|
671
|
+
// also set the shared messenger socket so queued messages can flush
|
|
672
|
+
if (this._shared) this._shared._socket = socket;
|
|
673
|
+
|
|
674
|
+
var flushQueues = function() {
|
|
675
|
+
// flush messenger queue
|
|
676
|
+
if (this._shared && this._shared._queue.length) {
|
|
677
|
+
for (var i = 0; i < this._shared._queue.length; i++) socket.send(this._shared._queue[i]);
|
|
678
|
+
this._shared._queue = [];
|
|
679
|
+
}
|
|
680
|
+
// flush instance queue
|
|
681
|
+
for (var i = 0; i < this._queue.length; i++) socket.send(this._queue[i]);
|
|
682
|
+
this._queue = [];
|
|
683
|
+
}.bind(this);
|
|
684
|
+
|
|
685
|
+
if (socket.readyState === 1) {
|
|
686
|
+
flushQueues();
|
|
687
|
+
} else {
|
|
688
|
+
socket.addEventListener('open', function() {
|
|
689
|
+
flushQueues();
|
|
690
|
+
}, { once: true });
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// HMR message handling is done by the outro WebSocket handler
|
|
694
|
+
// the runtime's setup() only needs to flush queued messages
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
globalThis.__rolldown_runtime__ = new ReactNativeDevRuntime();
|
|
699
|
+
`;
|
|
700
|
+
}
|
|
701
|
+
export { buildNativeBundle, createNativeDevEngine };
|
|
702
|
+
//# sourceMappingURL=createNativeDevEngine.native.js.map
|