vxrn 1.17.11 → 1.18.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.
- package/dist/plugins/reactNativeDevServer.mjs +5 -5
- package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
- package/dist/plugins/reactNativeDevServer.native.js +5 -5
- package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +2 -0
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +2 -0
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/runtime/native-prelude.mjs +1 -0
- package/dist/runtime/native-prelude.mjs.map +1 -1
- package/dist/runtime/native-prelude.native.js +1 -0
- package/dist/runtime/native-prelude.native.js.map +1 -1
- package/dist/user-interface/index.mjs +3 -2
- package/dist/user-interface/index.mjs.map +1 -1
- package/dist/user-interface/index.native.js +3 -2
- package/dist/user-interface/index.native.js.map +1 -1
- package/dist/utils/createNativeDevEngine.mjs +125 -179
- package/dist/utils/createNativeDevEngine.mjs.map +1 -1
- package/dist/utils/createNativeDevEngine.native.js +144 -217
- package/dist/utils/createNativeDevEngine.native.js.map +1 -1
- package/dist/utils/createNativeDevEngine.test.mjs +43 -0
- package/dist/utils/createNativeDevEngine.test.mjs.map +1 -0
- package/dist/utils/createNativeDevEngine.test.native.js +53 -0
- package/dist/utils/createNativeDevEngine.test.native.js.map +1 -0
- package/dist/utils/getBoundPort.mjs +9 -0
- package/dist/utils/getBoundPort.mjs.map +1 -0
- package/dist/utils/getBoundPort.native.js +16 -0
- package/dist/utils/getBoundPort.native.js.map +1 -0
- package/dist/utils/getBoundPort.test.mjs +71 -0
- package/dist/utils/getBoundPort.test.mjs.map +1 -0
- package/dist/utils/getBoundPort.test.native.js +82 -0
- package/dist/utils/getBoundPort.test.native.js.map +1 -0
- package/expo-plugin.cjs +34 -0
- package/package.json +12 -12
- package/src/plugins/reactNativeDevServer.ts +5 -4
- package/src/rn-commands/bundle/buildBundle.ts +3 -0
- package/src/runtime/native-prelude.ts +1 -0
- package/src/user-interface/index.ts +3 -2
- package/src/utils/createNativeDevEngine.test.ts +66 -0
- package/src/utils/createNativeDevEngine.ts +66 -3
- package/src/utils/getBoundPort.test.ts +59 -0
- package/src/utils/getBoundPort.ts +14 -0
- package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
- package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
- package/types/runtime/native-prelude.d.ts.map +1 -1
- package/types/user-interface/index.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.d.ts +35 -0
- package/types/utils/createNativeDevEngine.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.test.d.ts +2 -0
- package/types/utils/createNativeDevEngine.test.d.ts.map +1 -0
- package/types/utils/getBoundPort.d.ts +3 -0
- package/types/utils/getBoundPort.d.ts.map +1 -0
- package/types/utils/getBoundPort.test.d.ts +2 -0
- package/types/utils/getBoundPort.test.d.ts.map +1 -0
|
@@ -78,80 +78,57 @@ function getNativeTransformConfig(platform, dev, root) {
|
|
|
78
78
|
SSR: false,
|
|
79
79
|
VITE_ENVIRONMENT: platform,
|
|
80
80
|
VITE_NATIVE: "1",
|
|
81
|
-
EXPO_OS: platform
|
|
81
|
+
EXPO_OS: platform,
|
|
82
|
+
TAMAGUI_TARGET: "native",
|
|
83
|
+
TAMAGUI_ENVIRONMENT: platform
|
|
82
84
|
};
|
|
83
85
|
for (const [key, val] of Object.entries(envDefines)) {
|
|
84
86
|
const match = key.match(/^import\.meta\.env\.(.+)$/);
|
|
85
|
-
if (match) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
envObject[match[1]] = val;
|
|
90
|
-
}
|
|
87
|
+
if (match) try {
|
|
88
|
+
envObject[match[1]] = JSON.parse(val);
|
|
89
|
+
} catch {
|
|
90
|
+
envObject[match[1]] = val;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
return {
|
|
94
94
|
jsx: {
|
|
95
|
-
// use 'classic' mode (babel plugin-transform-react-jsx)
|
|
96
|
-
// 'automatic' has files where jsxDEV import fails to resolve
|
|
97
95
|
runtime: "classic"
|
|
98
96
|
},
|
|
99
97
|
define: {
|
|
100
98
|
"process.env.NODE_ENV": JSON.stringify(mode),
|
|
101
99
|
"process.env.VXRN_REACT_19": "false",
|
|
102
100
|
"process.env.VITE_ENVIRONMENT": JSON.stringify(platform),
|
|
103
|
-
"process.env.VITE_NATIVE":
|
|
101
|
+
"process.env.VITE_NATIVE": "\"1\"",
|
|
104
102
|
"process.env.EXPO_OS": JSON.stringify(platform),
|
|
103
|
+
"process.env.TAMAGUI_TARGET": "\"native\"",
|
|
105
104
|
"process.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
|
|
106
105
|
__DEV__: dev ? "true" : "false",
|
|
107
|
-
// import.meta.env as a whole object (for JSON.stringify(import.meta.env) etc.)
|
|
108
106
|
"import.meta.env": JSON.stringify(envObject),
|
|
109
|
-
// import.meta.env.* individual properties (for direct access)
|
|
110
107
|
"import.meta.env.MODE": JSON.stringify(mode),
|
|
111
108
|
"import.meta.env.DEV": dev ? "true" : "false",
|
|
112
109
|
"import.meta.env.PROD": dev ? "false" : "true",
|
|
113
110
|
"import.meta.env.SSR": "false",
|
|
114
111
|
"import.meta.env.VITE_ENVIRONMENT": JSON.stringify(platform),
|
|
115
|
-
"import.meta.env.VITE_NATIVE":
|
|
112
|
+
"import.meta.env.VITE_NATIVE": "\"1\"",
|
|
116
113
|
"import.meta.env.EXPO_OS": JSON.stringify(platform),
|
|
114
|
+
"import.meta.env.TAMAGUI_TARGET": "\"native\"",
|
|
115
|
+
"import.meta.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
|
|
117
116
|
...envDefines,
|
|
118
117
|
...setupFileDefines
|
|
119
118
|
},
|
|
120
|
-
// auto-inject React import for classic JSX (React.createElement)
|
|
121
119
|
inject: {
|
|
122
120
|
React: "react"
|
|
123
121
|
}
|
|
124
122
|
};
|
|
125
123
|
}
|
|
126
124
|
function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest) {
|
|
127
|
-
return [
|
|
128
|
-
// plugins provided by One (clientTreeShakePlugin for loader removal, etc.)
|
|
129
|
-
...(globalThis.__vxrnAddNativePlugins || []),
|
|
130
|
-
// block .server.* and _middleware.* files from entering the native bundle
|
|
131
|
-
serverFileExclusionPlugin(),
|
|
132
|
-
// guard server-only / client-only / web-only / native-only imports
|
|
133
|
-
environmentGuardPlugin(),
|
|
134
|
-
// stub CSS imports — native doesn't support CSS and rolldown removed CSS bundling
|
|
135
|
-
cssStubPlugin(),
|
|
136
|
-
// handle import.meta.glob (used by One's route system)
|
|
137
|
-
viteImportGlobPlugin({
|
|
125
|
+
return [...(globalThis.__vxrnAddNativePlugins || []), serverFileExclusionPlugin(), environmentGuardPlugin(), cssStubPlugin(), viteImportGlobPlugin({
|
|
138
126
|
root
|
|
139
|
-
}),
|
|
140
|
-
// strip Flow types from react-native and @react-native packages
|
|
141
|
-
flowStripPlugin(),
|
|
142
|
-
// guard undefined native methods in NativeAnimatedHelper
|
|
143
|
-
nativeAnimatedGuardPlugin(),
|
|
144
|
-
// handle asset imports (.png, .jpg, .ttf, etc.)
|
|
145
|
-
assetPlugin({
|
|
127
|
+
}), flowStripPlugin(), nativeAnimatedGuardPlugin(), assetPlugin({
|
|
146
128
|
root,
|
|
147
129
|
platform,
|
|
148
130
|
assetsDest
|
|
149
|
-
}),
|
|
150
|
-
// @vxrn/compiler babel transforms: reanimated worklets, async generators,
|
|
151
|
-
// react-native codegen, react compiler — same pipeline as metro
|
|
152
|
-
vxrnCompilerPlugin(platform, dev),
|
|
153
|
-
// hermes compat: transform class properties and private fields
|
|
154
|
-
hermesCompatSWCPlugin(dev)];
|
|
131
|
+
}), vxrnCompilerPlugin(platform, dev), hermesCompatSWCPlugin(dev)];
|
|
155
132
|
}
|
|
156
133
|
function getNativeOutputOptions(prelude) {
|
|
157
134
|
return {
|
|
@@ -164,10 +141,10 @@ function getNativeOutputOptions(prelude) {
|
|
|
164
141
|
}
|
|
165
142
|
function postProcessNativeBundle(code) {
|
|
166
143
|
code = code.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm, "");
|
|
144
|
+
code = code.replace(/^\s*export\s+default\s+([^;\n]+);?\s*$/gm, "$1;");
|
|
167
145
|
code = code.replace(/^if \(import\.meta\.hot\).*$/gm, "");
|
|
168
146
|
{
|
|
169
|
-
const
|
|
170
|
-
const idx = code.indexOf(marker);
|
|
147
|
+
const idx = code.indexOf("NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;");
|
|
171
148
|
if (idx !== -1) {
|
|
172
149
|
const beforeMarker = code.lastIndexOf("NativeAnimatedModule = ", idx);
|
|
173
150
|
if (beforeMarker !== -1) {
|
|
@@ -176,7 +153,7 @@ function postProcessNativeBundle(code) {
|
|
|
176
153
|
if (snippet.includes("(function()") || snippet.includes("new Proxy")) {
|
|
177
154
|
const afterMarker = code.indexOf("})();", idx);
|
|
178
155
|
if (afterMarker !== -1) {
|
|
179
|
-
const end = afterMarker +
|
|
156
|
+
const end = afterMarker + 5;
|
|
180
157
|
code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + code.slice(end);
|
|
181
158
|
}
|
|
182
159
|
}
|
|
@@ -185,6 +162,18 @@ function postProcessNativeBundle(code) {
|
|
|
185
162
|
}
|
|
186
163
|
return code;
|
|
187
164
|
}
|
|
165
|
+
function wrapNativeBundleModuleScope(code) {
|
|
166
|
+
const idx = code.indexOf("//#region \\0rolldown/runtime.js");
|
|
167
|
+
if (idx === -1) return code;
|
|
168
|
+
const open = ";(function() {\n";
|
|
169
|
+
const close = "\n})();\n";
|
|
170
|
+
const sm = code.match(/\n\/\/# sourceMappingURL=[^\n]*\s*$/);
|
|
171
|
+
if (sm) {
|
|
172
|
+
const smIdx = code.lastIndexOf(sm[0]);
|
|
173
|
+
return code.slice(0, idx) + open + code.slice(idx, smIdx) + close + code.slice(smIdx);
|
|
174
|
+
}
|
|
175
|
+
return code.slice(0, idx) + open + code.slice(idx) + close;
|
|
176
|
+
}
|
|
188
177
|
async function downlevelClassFieldsInBundle(code) {
|
|
189
178
|
const startMarker = "//#region \\0rolldown/runtime.js";
|
|
190
179
|
const endMarker = "//#endregion";
|
|
@@ -192,11 +181,10 @@ async function downlevelClassFieldsInBundle(code) {
|
|
|
192
181
|
if (startIdx === -1) return code;
|
|
193
182
|
const endIdx = code.indexOf(endMarker, startIdx);
|
|
194
183
|
if (endIdx === -1) return code;
|
|
195
|
-
const runtimeEnd = endIdx +
|
|
184
|
+
const runtimeEnd = endIdx + 12;
|
|
196
185
|
const runtimeSection = code.slice(startIdx, runtimeEnd);
|
|
197
186
|
try {
|
|
198
|
-
const
|
|
199
|
-
const result = await swc.transform(runtimeSection, {
|
|
187
|
+
const result = await (await import("@swc/core")).transform(runtimeSection, {
|
|
200
188
|
filename: "rolldown-runtime.js",
|
|
201
189
|
configFile: false,
|
|
202
190
|
swcrc: false,
|
|
@@ -255,7 +243,7 @@ async function createNativeDevEngine(options) {
|
|
|
255
243
|
let bundleResolve = null;
|
|
256
244
|
let bundlePromise = null;
|
|
257
245
|
const resolvedHost = host === "0.0.0.0" ? "localhost" : host;
|
|
258
|
-
const
|
|
246
|
+
const engine = await dev({
|
|
259
247
|
input: VIRTUAL_NATIVE_ENTRY,
|
|
260
248
|
cwd: root,
|
|
261
249
|
platform: "neutral",
|
|
@@ -268,16 +256,9 @@ async function createNativeDevEngine(options) {
|
|
|
268
256
|
port
|
|
269
257
|
},
|
|
270
258
|
incrementalBuild: true,
|
|
271
|
-
// lazyBarrel defers barrel re-export initialization — needed in dev mode
|
|
272
|
-
// to avoid breaking worklet closure serialization order.
|
|
273
|
-
// removed from prod builds (buildNativeBundle) where it caused build errors.
|
|
274
259
|
lazyBarrel: true
|
|
275
260
|
},
|
|
276
261
|
treeshake: false,
|
|
277
|
-
// some react-native ecosystem packages import symbols that don't exist in
|
|
278
|
-
// the declared entry (e.g. @react-navigation/elements imports NavigationProvider
|
|
279
|
-
// from @react-navigation/native which doesn't export it). metro silently shims
|
|
280
|
-
// these — rolldown needs an explicit opt-in.
|
|
281
262
|
shimMissingExports: true,
|
|
282
263
|
moduleTypes: {
|
|
283
264
|
".js": "jsx"
|
|
@@ -285,10 +266,8 @@ async function createNativeDevEngine(options) {
|
|
|
285
266
|
plugins: [nativeVirtualEntryPlugin(root, {
|
|
286
267
|
dev: true
|
|
287
268
|
}), ...getNativePlugins(root, platform, viteImportGlobPlugin, true), ...userPlugins]
|
|
288
|
-
}
|
|
289
|
-
const outputOptions = {
|
|
269
|
+
}, {
|
|
290
270
|
...getNativeOutputOptions(prelude),
|
|
291
|
-
// connect HMR WebSocket using RN's WebSocket module (not the global)
|
|
292
271
|
outro: `
|
|
293
272
|
try {
|
|
294
273
|
var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
|
|
@@ -318,20 +297,19 @@ try {
|
|
|
318
297
|
__hmrWS.onerror = function(e) { console.warn('[vxrn] HMR connection error:', e.message || e); };
|
|
319
298
|
} catch(e) {}
|
|
320
299
|
`
|
|
321
|
-
}
|
|
322
|
-
const engine = await dev(inputOptions, outputOptions, {
|
|
300
|
+
}, {
|
|
323
301
|
onOutput: async result => {
|
|
324
302
|
if (result instanceof Error) {
|
|
325
303
|
console.error("[vxrn] native bundle error:", result.message);
|
|
326
304
|
return;
|
|
327
305
|
}
|
|
328
|
-
const
|
|
329
|
-
const chunk = output.output.find(o => o.type === "chunk" && o.isEntry);
|
|
306
|
+
const chunk = result.output.find(o => o.type === "chunk" && o.isEntry);
|
|
330
307
|
if (chunk && "code" in chunk) {
|
|
331
308
|
let code = postProcessNativeBundle(chunk.code);
|
|
332
309
|
code = await downlevelClassFieldsInBundle(code);
|
|
333
310
|
const hmrClientStub = `registerCallableModule("HMRClient",{setup:function(){},enable:function(){},disable:function(){},registerBundle:function(){},log:function(){}})`;
|
|
334
311
|
code = code.replace(/registerCallableModule\s*\(\s*["']AppRegistry["']/, match => hmrClientStub + "," + match);
|
|
312
|
+
code = wrapNativeBundleModuleScope(code);
|
|
335
313
|
currentBundle = {
|
|
336
314
|
code,
|
|
337
315
|
map: chunk.map?.toString()
|
|
@@ -355,22 +333,16 @@ try {
|
|
|
355
333
|
const updates = result.updates || [];
|
|
356
334
|
for (const item of updates) {
|
|
357
335
|
const update = item.update || item;
|
|
358
|
-
if (update.type === "Patch" && update.code) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
});
|
|
363
|
-
} else if (update.type === "FullReload") {
|
|
364
|
-
onHmrUpdate?.({
|
|
365
|
-
type: "hmr:reload"
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
if (updates.length === 0) {
|
|
370
|
-
onHmrUpdate?.({
|
|
336
|
+
if (update.type === "Patch" && update.code) onHmrUpdate?.({
|
|
337
|
+
type: "hmr:update",
|
|
338
|
+
code: update.code
|
|
339
|
+
});else if (update.type === "FullReload") onHmrUpdate?.({
|
|
371
340
|
type: "hmr:reload"
|
|
372
341
|
});
|
|
373
342
|
}
|
|
343
|
+
if (updates.length === 0) onHmrUpdate?.({
|
|
344
|
+
type: "hmr:reload"
|
|
345
|
+
});
|
|
374
346
|
},
|
|
375
347
|
rebuildStrategy: "auto",
|
|
376
348
|
watch: {}
|
|
@@ -387,7 +359,7 @@ try {
|
|
|
387
359
|
clearTimeout(timeoutId);
|
|
388
360
|
resolve2(value);
|
|
389
361
|
};
|
|
390
|
-
timeoutId = setTimeout(() => reject(new Error("[vxrn] bundle build timed out after 120s")), 12e4);
|
|
362
|
+
timeoutId = setTimeout(() => reject(/* @__PURE__ */new Error("[vxrn] bundle build timed out after 120s")), 12e4);
|
|
391
363
|
});
|
|
392
364
|
}
|
|
393
365
|
await engine.ensureLatestBuildOutput();
|
|
@@ -405,6 +377,7 @@ async function buildNativeBundle(options) {
|
|
|
405
377
|
platform,
|
|
406
378
|
dev = false,
|
|
407
379
|
serverUrl,
|
|
380
|
+
entryFile,
|
|
408
381
|
assetsDest,
|
|
409
382
|
plugins: userPlugins = []
|
|
410
383
|
} = options;
|
|
@@ -419,8 +392,8 @@ async function buildNativeBundle(options) {
|
|
|
419
392
|
platform,
|
|
420
393
|
serverUrl
|
|
421
394
|
});
|
|
422
|
-
const
|
|
423
|
-
input: VIRTUAL_NATIVE_ENTRY,
|
|
395
|
+
const chunk = (await build({
|
|
396
|
+
input: entryFile ? normalizePath(resolve(root, entryFile)) : VIRTUAL_NATIVE_ENTRY,
|
|
424
397
|
cwd: root,
|
|
425
398
|
platform: "neutral",
|
|
426
399
|
resolve: getNativeResolveConfig(platform),
|
|
@@ -430,15 +403,12 @@ async function buildNativeBundle(options) {
|
|
|
430
403
|
moduleTypes: {
|
|
431
404
|
".js": "jsx"
|
|
432
405
|
},
|
|
433
|
-
plugins: [nativeVirtualEntryPlugin(root, {
|
|
406
|
+
plugins: [...(entryFile ? [] : [nativeVirtualEntryPlugin(root, {
|
|
434
407
|
dev
|
|
435
|
-
}), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest), ...userPlugins],
|
|
408
|
+
})]), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest), ...userPlugins],
|
|
436
409
|
output: getNativeOutputOptions(prelude)
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
if (!chunk || !("code" in chunk)) {
|
|
440
|
-
throw new Error("[vxrn] production build produced no output");
|
|
441
|
-
}
|
|
410
|
+
})).output.find(o => o.type === "chunk" && o.isEntry);
|
|
411
|
+
if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
|
|
442
412
|
let code = postProcessNativeBundle(chunk.code);
|
|
443
413
|
code = await downlevelClassFieldsInBundle(code);
|
|
444
414
|
return {
|
|
@@ -462,10 +432,9 @@ function nativeVirtualEntryPlugin(root, opts) {
|
|
|
462
432
|
const resolved = pathToFileURL(resolve(root, file)).href;
|
|
463
433
|
return `import ${JSON.stringify(resolved)};`;
|
|
464
434
|
})();
|
|
465
|
-
const routeGlobs = [`./${routerRoot}/**/*.tsx`, `./${routerRoot}/**/*.ts`, `!./${routerRoot}/**/*+api.*`, `!./${routerRoot}/**/*.test.*`, `!./${routerRoot}/**/*.d.ts`, `!./${routerRoot}/**/*.server.*`, `!./${routerRoot}/**/_middleware.*`, `!./${routerRoot}/**/*.web.*`,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const refreshSetup = isDev ? `
|
|
435
|
+
const routeGlobs = [`./${routerRoot}/**/*.tsx`, `./${routerRoot}/**/*.ts`, `!./${routerRoot}/**/*+api.*`, `!./${routerRoot}/**/*.test.*`, `!./${routerRoot}/**/*.d.ts`, `!./${routerRoot}/**/*.server.*`, `!./${routerRoot}/**/_middleware.*`, `!./${routerRoot}/**/*.web.*`, ...(entryConfig.ignoredRouteFiles || []).map(pattern => `!./${routerRoot}/${pattern}`)];
|
|
436
|
+
const entryCode = `
|
|
437
|
+
${isDev ? `
|
|
469
438
|
// react-refresh/runtime MUST initialize before React loads
|
|
470
439
|
import RefreshRuntime from 'react-refresh/runtime';
|
|
471
440
|
RefreshRuntime.injectIntoGlobalHook(globalThis);
|
|
@@ -474,12 +443,15 @@ globalThis.$RefreshReg$ = function(type, id) {
|
|
|
474
443
|
RefreshRuntime.register(type, id);
|
|
475
444
|
};
|
|
476
445
|
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
477
|
-
` : ""
|
|
478
|
-
|
|
479
|
-
|
|
446
|
+
` : ""}
|
|
447
|
+
import * as ReactNativeInitializeCore from 'react-native/Libraries/Core/InitializeCore';
|
|
448
|
+
import NativeWebSocket from 'react-native/Libraries/WebSocket/WebSocket';
|
|
480
449
|
${setupFileImport}
|
|
481
450
|
import { createApp } from 'one';
|
|
482
451
|
|
|
452
|
+
void ReactNativeInitializeCore;
|
|
453
|
+
globalThis.WebSocket = NativeWebSocket;
|
|
454
|
+
|
|
483
455
|
var _routes = import.meta.glob(${JSON.stringify(routeGlobs)}, { exhaustive: true });
|
|
484
456
|
// fix route keys: One expects '/${routerRoot}/...' prefix but import.meta.glob returns './${routerRoot}/...'
|
|
485
457
|
var routes = {};
|
|
@@ -498,14 +470,10 @@ createApp({
|
|
|
498
470
|
return {
|
|
499
471
|
name: "vxrn:native-virtual-entry",
|
|
500
472
|
resolveId(id) {
|
|
501
|
-
if (id === VIRTUAL_NATIVE_ENTRY)
|
|
502
|
-
return resolvedId;
|
|
503
|
-
}
|
|
473
|
+
if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
|
|
504
474
|
},
|
|
505
475
|
load(id) {
|
|
506
|
-
if (id === resolvedId)
|
|
507
|
-
return entryCode;
|
|
508
|
-
}
|
|
476
|
+
if (id === resolvedId) return entryCode;
|
|
509
477
|
}
|
|
510
478
|
};
|
|
511
479
|
}
|
|
@@ -527,18 +495,14 @@ function serverFileExclusionPlugin() {
|
|
|
527
495
|
return {
|
|
528
496
|
name: "vxrn:server-file-exclusion",
|
|
529
497
|
load(id) {
|
|
530
|
-
if (/\.server\.\w+$/.test(id)) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
code: "export default undefined;",
|
|
539
|
-
moduleType: "js"
|
|
540
|
-
};
|
|
541
|
-
}
|
|
498
|
+
if (/\.server\.\w+$/.test(id)) return {
|
|
499
|
+
code: "export default undefined;",
|
|
500
|
+
moduleType: "js"
|
|
501
|
+
};
|
|
502
|
+
if (/[\\/]_middleware\.\w+$/.test(id)) return {
|
|
503
|
+
code: "export default undefined;",
|
|
504
|
+
moduleType: "js"
|
|
505
|
+
};
|
|
542
506
|
}
|
|
543
507
|
};
|
|
544
508
|
}
|
|
@@ -558,13 +522,10 @@ function environmentGuardPlugin() {
|
|
|
558
522
|
};
|
|
559
523
|
},
|
|
560
524
|
load(id) {
|
|
561
|
-
if (id.startsWith("\0env-guard-throw:")) {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
moduleType: "js"
|
|
566
|
-
};
|
|
567
|
-
}
|
|
525
|
+
if (id.startsWith("\0env-guard-throw:")) return {
|
|
526
|
+
code: `throw new Error("Cannot import '${id.slice(17)}' in a native bundle.");`,
|
|
527
|
+
moduleType: "js"
|
|
528
|
+
};
|
|
568
529
|
if (id.startsWith("\0env-guard-noop:")) return {
|
|
569
530
|
code: "",
|
|
570
531
|
moduleType: "js"
|
|
@@ -577,12 +538,10 @@ function cssStubPlugin() {
|
|
|
577
538
|
name: "vxrn:css-stub",
|
|
578
539
|
load: {
|
|
579
540
|
handler(id) {
|
|
580
|
-
if (id.endsWith(".css")) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
};
|
|
585
|
-
}
|
|
541
|
+
if (id.endsWith(".css")) return {
|
|
542
|
+
code: "",
|
|
543
|
+
moduleType: "js"
|
|
544
|
+
};
|
|
586
545
|
}
|
|
587
546
|
}
|
|
588
547
|
};
|
|
@@ -617,14 +576,12 @@ function vxrnCompilerPlugin(platform, dev) {
|
|
|
617
576
|
const result = await compiler.transformBabel(id, code, babelOptions);
|
|
618
577
|
if (result?.code) {
|
|
619
578
|
let out = result.code;
|
|
620
|
-
if (needsRefresh)
|
|
621
|
-
const escapedId = id.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
622
|
-
out = `
|
|
579
|
+
if (needsRefresh) out = `
|
|
623
580
|
var __prevRefreshReg = globalThis.$RefreshReg$;
|
|
624
581
|
var __prevRefreshSig = globalThis.$RefreshSig$;
|
|
625
582
|
if (globalThis.__ReactRefresh) {
|
|
626
583
|
globalThis.$RefreshReg$ = function(type, id) {
|
|
627
|
-
globalThis.__ReactRefresh.register(type, "${
|
|
584
|
+
globalThis.__ReactRefresh.register(type, "${id.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}" + " " + id);
|
|
628
585
|
};
|
|
629
586
|
globalThis.$RefreshSig$ = globalThis.__ReactRefresh.createSignatureFunctionForTransform;
|
|
630
587
|
}
|
|
@@ -641,22 +598,17 @@ if (import.meta.hot) {
|
|
|
641
598
|
});
|
|
642
599
|
}
|
|
643
600
|
`;
|
|
644
|
-
}
|
|
645
601
|
return {
|
|
646
602
|
code: out
|
|
647
603
|
};
|
|
648
604
|
}
|
|
649
605
|
} catch (err) {
|
|
650
|
-
if (dev) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
if (needsRefresh) {
|
|
654
|
-
return {
|
|
655
|
-
code: code + `
|
|
606
|
+
if (dev) console.warn(`[vxrn:compiler] ${id}: ${err.message || err}`);
|
|
607
|
+
if (needsRefresh) return {
|
|
608
|
+
code: code + `
|
|
656
609
|
if (import.meta.hot) { import.meta.hot.accept(); }
|
|
657
610
|
`
|
|
658
|
-
|
|
659
|
-
}
|
|
611
|
+
};
|
|
660
612
|
}
|
|
661
613
|
}
|
|
662
614
|
};
|
|
@@ -668,8 +620,7 @@ function flowStripPlugin() {
|
|
|
668
620
|
async handler(code, id) {
|
|
669
621
|
if (!FLOW_FILE_PATTERN.test(id)) return;
|
|
670
622
|
try {
|
|
671
|
-
const
|
|
672
|
-
const result = await fft.default({
|
|
623
|
+
const result = await (await import("fast-flow-transform")).default({
|
|
673
624
|
filename: id,
|
|
674
625
|
source: code,
|
|
675
626
|
sourcemap: true,
|
|
@@ -698,28 +649,25 @@ function assetPlugin(opts) {
|
|
|
698
649
|
const name = basename(id, `.${ext}`);
|
|
699
650
|
const dir = dirname(id);
|
|
700
651
|
const relativePath = relative(opts.root, id);
|
|
701
|
-
const httpLocation = "/assets/" + dirname(relativePath).replace(/\\/g, "/");
|
|
702
652
|
const assetData = {
|
|
703
653
|
__packager_asset: true,
|
|
704
654
|
name,
|
|
705
655
|
type: ext,
|
|
706
656
|
scales: [1],
|
|
707
|
-
httpServerLocation:
|
|
657
|
+
httpServerLocation: "/assets/" + dirname(relativePath).replace(/\\/g, "/"),
|
|
708
658
|
fileSystemLocation: dir,
|
|
709
659
|
hash: "",
|
|
710
660
|
width: void 0,
|
|
711
661
|
height: void 0
|
|
712
662
|
};
|
|
713
|
-
if (["png", "jpg", "jpeg", "gif", "webp", "bmp"].includes(ext)) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
} catch {}
|
|
722
|
-
}
|
|
663
|
+
if (["png", "jpg", "jpeg", "gif", "webp", "bmp"].includes(ext)) try {
|
|
664
|
+
const {
|
|
665
|
+
imageSize
|
|
666
|
+
} = await import("image-size");
|
|
667
|
+
const dims = imageSize(id);
|
|
668
|
+
assetData.width = dims.width;
|
|
669
|
+
assetData.height = dims.height;
|
|
670
|
+
} catch {}
|
|
723
671
|
if (opts.assetsDest) {
|
|
724
672
|
const relativeAssetDir = dirname(relativePath).replace(/\\/g, "/");
|
|
725
673
|
const assetDestDir = join(opts.assetsDest, "assets", relativeAssetDir);
|
|
@@ -728,9 +676,8 @@ function assetPlugin(opts) {
|
|
|
728
676
|
});
|
|
729
677
|
copyFileSync(id, join(assetDestDir, `${name}.${ext}`));
|
|
730
678
|
}
|
|
731
|
-
const code = `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`;
|
|
732
679
|
return {
|
|
733
|
-
code
|
|
680
|
+
code: `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`,
|
|
734
681
|
moduleType: "js"
|
|
735
682
|
};
|
|
736
683
|
}
|
|
@@ -751,38 +698,37 @@ function hermesCompatSWCPlugin(dev) {
|
|
|
751
698
|
try {
|
|
752
699
|
if (!swc) swc = await import("@swc/core");
|
|
753
700
|
const envIncludes = ["transform-class-properties", "transform-class-static-block", "transform-private-methods", "transform-private-property-in-object", ...(!dev ? ["transform-classes", "transform-async-to-generator"] : [])];
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
jsc: {
|
|
767
|
-
parser: {
|
|
768
|
-
syntax: "typescript",
|
|
769
|
-
tsx: true
|
|
701
|
+
return {
|
|
702
|
+
code: (await swc.transform(code, {
|
|
703
|
+
filename: id,
|
|
704
|
+
configFile: false,
|
|
705
|
+
swcrc: false,
|
|
706
|
+
sourceMaps: false,
|
|
707
|
+
inputSourceMap: false,
|
|
708
|
+
env: {
|
|
709
|
+
targets: {
|
|
710
|
+
node: 9999
|
|
711
|
+
},
|
|
712
|
+
include: envIncludes
|
|
770
713
|
},
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
714
|
+
jsc: {
|
|
715
|
+
parser: {
|
|
716
|
+
syntax: "typescript",
|
|
717
|
+
tsx: true
|
|
718
|
+
},
|
|
719
|
+
transform: {
|
|
720
|
+
react: {
|
|
721
|
+
runtime: "preserve"
|
|
722
|
+
}
|
|
723
|
+
},
|
|
724
|
+
externalHelpers: false,
|
|
725
|
+
assumptions: {
|
|
726
|
+
setPublicClassFields: true,
|
|
727
|
+
privateFieldsAsProperties: true
|
|
774
728
|
}
|
|
775
729
|
},
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
setPublicClassFields: true,
|
|
779
|
-
privateFieldsAsProperties: true
|
|
780
|
-
}
|
|
781
|
-
},
|
|
782
|
-
isModule: !id.endsWith(".cjs")
|
|
783
|
-
});
|
|
784
|
-
return {
|
|
785
|
-
code: result.code
|
|
730
|
+
isModule: !id.endsWith(".cjs")
|
|
731
|
+
})).code
|
|
786
732
|
};
|
|
787
733
|
} catch (err) {}
|
|
788
734
|
}
|
|
@@ -890,5 +836,5 @@ class ReactNativeDevRuntime extends BaseDevRuntime {
|
|
|
890
836
|
globalThis.__rolldown_runtime__ = new ReactNativeDevRuntime();
|
|
891
837
|
`;
|
|
892
838
|
}
|
|
893
|
-
export { buildNativeBundle, createNativeDevEngine };
|
|
839
|
+
export { buildNativeBundle, createNativeDevEngine, getNativeTransformConfig, wrapNativeBundleModuleScope };
|
|
894
840
|
//# sourceMappingURL=createNativeDevEngine.mjs.map
|