vxrn 1.17.11 → 1.18.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.
Files changed (54) hide show
  1. package/dist/plugins/reactNativeDevServer.mjs +5 -5
  2. package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
  3. package/dist/plugins/reactNativeDevServer.native.js +5 -5
  4. package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
  5. package/dist/rn-commands/bundle/buildBundle.mjs +2 -0
  6. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  7. package/dist/rn-commands/bundle/buildBundle.native.js +2 -0
  8. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  9. package/dist/runtime/native-prelude.mjs +1 -0
  10. package/dist/runtime/native-prelude.mjs.map +1 -1
  11. package/dist/runtime/native-prelude.native.js +1 -0
  12. package/dist/runtime/native-prelude.native.js.map +1 -1
  13. package/dist/user-interface/index.mjs +3 -2
  14. package/dist/user-interface/index.mjs.map +1 -1
  15. package/dist/user-interface/index.native.js +3 -2
  16. package/dist/user-interface/index.native.js.map +1 -1
  17. package/dist/utils/createNativeDevEngine.mjs +125 -179
  18. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  19. package/dist/utils/createNativeDevEngine.native.js +144 -217
  20. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  21. package/dist/utils/createNativeDevEngine.test.mjs +43 -0
  22. package/dist/utils/createNativeDevEngine.test.mjs.map +1 -0
  23. package/dist/utils/createNativeDevEngine.test.native.js +53 -0
  24. package/dist/utils/createNativeDevEngine.test.native.js.map +1 -0
  25. package/dist/utils/getBoundPort.mjs +9 -0
  26. package/dist/utils/getBoundPort.mjs.map +1 -0
  27. package/dist/utils/getBoundPort.native.js +16 -0
  28. package/dist/utils/getBoundPort.native.js.map +1 -0
  29. package/dist/utils/getBoundPort.test.mjs +71 -0
  30. package/dist/utils/getBoundPort.test.mjs.map +1 -0
  31. package/dist/utils/getBoundPort.test.native.js +82 -0
  32. package/dist/utils/getBoundPort.test.native.js.map +1 -0
  33. package/expo-plugin.cjs +34 -0
  34. package/package.json +12 -12
  35. package/src/plugins/reactNativeDevServer.ts +5 -4
  36. package/src/rn-commands/bundle/buildBundle.ts +3 -0
  37. package/src/runtime/native-prelude.ts +1 -0
  38. package/src/user-interface/index.ts +3 -2
  39. package/src/utils/createNativeDevEngine.test.ts +66 -0
  40. package/src/utils/createNativeDevEngine.ts +66 -3
  41. package/src/utils/getBoundPort.test.ts +59 -0
  42. package/src/utils/getBoundPort.ts +14 -0
  43. package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
  44. package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
  45. package/types/runtime/native-prelude.d.ts.map +1 -1
  46. package/types/user-interface/index.d.ts.map +1 -1
  47. package/types/utils/createNativeDevEngine.d.ts +35 -0
  48. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
  49. package/types/utils/createNativeDevEngine.test.d.ts +2 -0
  50. package/types/utils/createNativeDevEngine.test.d.ts.map +1 -0
  51. package/types/utils/getBoundPort.d.ts +3 -0
  52. package/types/utils/getBoundPort.d.ts.map +1 -0
  53. package/types/utils/getBoundPort.test.d.ts +2 -0
  54. package/types/utils/getBoundPort.test.d.ts.map +1 -0
@@ -5,11 +5,7 @@ import { normalizePath } from "vite";
5
5
  import { DEFAULT_ASSET_EXTS } from "../constants/defaults.native.js";
6
6
  import { getNativePrelude } from "../runtime/native-prelude.native.js";
7
7
  function _instanceof(left, right) {
8
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
9
- return !!right[Symbol.hasInstance](left);
10
- } else {
11
- return left instanceof right;
12
- }
8
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) return !!right[Symbol.hasInstance](left);else return left instanceof right;
13
9
  }
14
10
  var FLOW_FILE_PATTERN = /node_modules[\\/](?:react-native|@react-native)[\\/].*\.js$/;
15
11
  function getResolveExtensions(platform) {
@@ -70,8 +66,7 @@ function getNativeTransformConfig(platform, dev, root) {
70
66
  _iteratorError2 = void 0;
71
67
  try {
72
68
  for (var _iterator2 = content.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
73
- var line = _step2.value;
74
- var match2 = line.match(/^\s*(VITE_\w+)\s*=\s*(.*)$/);
69
+ var match2 = _step2.value.match(/^\s*(VITE_\w+)\s*=\s*(.*)$/);
75
70
  if (match2) {
76
71
  var [, key2, rawVal] = match2;
77
72
  var val2 = rawVal.replace(/^['"]|['"]$/g, "").trim();
@@ -84,13 +79,9 @@ function getNativeTransformConfig(platform, dev, root) {
84
79
  _iteratorError2 = err;
85
80
  } finally {
86
81
  try {
87
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
88
- _iterator2.return();
89
- }
82
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) _iterator2.return();
90
83
  } finally {
91
- if (_didIteratorError2) {
92
- throw _iteratorError2;
93
- }
84
+ if (_didIteratorError2) throw _iteratorError2;
94
85
  }
95
86
  }
96
87
  }
@@ -105,7 +96,9 @@ function getNativeTransformConfig(platform, dev, root) {
105
96
  SSR: false,
106
97
  VITE_ENVIRONMENT: platform,
107
98
  VITE_NATIVE: "1",
108
- EXPO_OS: platform
99
+ EXPO_OS: platform,
100
+ TAMAGUI_TARGET: "native",
101
+ TAMAGUI_ENVIRONMENT: platform
109
102
  };
110
103
  var _iteratorNormalCompletion = true,
111
104
  _didIteratorError = false,
@@ -114,12 +107,10 @@ function getNativeTransformConfig(platform, dev, root) {
114
107
  for (var _iterator = Object.entries(envDefines)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
115
108
  var [key, val] = _step.value;
116
109
  var match = key.match(/^import\.meta\.env\.(.+)$/);
117
- if (match) {
118
- try {
119
- envObject[match[1]] = JSON.parse(val);
120
- } catch (unused) {
121
- envObject[match[1]] = val;
122
- }
110
+ if (match) try {
111
+ envObject[match[1]] = JSON.parse(val);
112
+ } catch (unused) {
113
+ envObject[match[1]] = val;
123
114
  }
124
115
  }
125
116
  } catch (err) {
@@ -127,77 +118,50 @@ function getNativeTransformConfig(platform, dev, root) {
127
118
  _iteratorError = err;
128
119
  } finally {
129
120
  try {
130
- if (!_iteratorNormalCompletion && _iterator.return != null) {
131
- _iterator.return();
132
- }
121
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
133
122
  } finally {
134
- if (_didIteratorError) {
135
- throw _iteratorError;
136
- }
123
+ if (_didIteratorError) throw _iteratorError;
137
124
  }
138
125
  }
139
126
  return {
140
127
  jsx: {
141
- // use 'classic' mode (babel plugin-transform-react-jsx)
142
- // 'automatic' has files where jsxDEV import fails to resolve
143
128
  runtime: "classic"
144
129
  },
145
130
  define: {
146
131
  "process.env.NODE_ENV": JSON.stringify(mode),
147
132
  "process.env.VXRN_REACT_19": "false",
148
133
  "process.env.VITE_ENVIRONMENT": JSON.stringify(platform),
149
- "process.env.VITE_NATIVE": '"1"',
134
+ "process.env.VITE_NATIVE": "\"1\"",
150
135
  "process.env.EXPO_OS": JSON.stringify(platform),
136
+ "process.env.TAMAGUI_TARGET": "\"native\"",
151
137
  "process.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
152
138
  __DEV__: dev ? "true" : "false",
153
- // import.meta.env as a whole object (for JSON.stringify(import.meta.env) etc.)
154
139
  "import.meta.env": JSON.stringify(envObject),
155
- // import.meta.env.* individual properties (for direct access)
156
140
  "import.meta.env.MODE": JSON.stringify(mode),
157
141
  "import.meta.env.DEV": dev ? "true" : "false",
158
142
  "import.meta.env.PROD": dev ? "false" : "true",
159
143
  "import.meta.env.SSR": "false",
160
144
  "import.meta.env.VITE_ENVIRONMENT": JSON.stringify(platform),
161
- "import.meta.env.VITE_NATIVE": '"1"',
145
+ "import.meta.env.VITE_NATIVE": "\"1\"",
162
146
  "import.meta.env.EXPO_OS": JSON.stringify(platform),
147
+ "import.meta.env.TAMAGUI_TARGET": "\"native\"",
148
+ "import.meta.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
163
149
  ...envDefines,
164
150
  ...setupFileDefines
165
151
  },
166
- // auto-inject React import for classic JSX (React.createElement)
167
152
  inject: {
168
153
  React: "react"
169
154
  }
170
155
  };
171
156
  }
172
157
  function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest) {
173
- return [
174
- // plugins provided by One (clientTreeShakePlugin for loader removal, etc.)
175
- ...(globalThis.__vxrnAddNativePlugins || []),
176
- // block .server.* and _middleware.* files from entering the native bundle
177
- serverFileExclusionPlugin(),
178
- // guard server-only / client-only / web-only / native-only imports
179
- environmentGuardPlugin(),
180
- // stub CSS imports — native doesn't support CSS and rolldown removed CSS bundling
181
- cssStubPlugin(),
182
- // handle import.meta.glob (used by One's route system)
183
- viteImportGlobPlugin({
158
+ return [...(globalThis.__vxrnAddNativePlugins || []), serverFileExclusionPlugin(), environmentGuardPlugin(), cssStubPlugin(), viteImportGlobPlugin({
184
159
  root
185
- }),
186
- // strip Flow types from react-native and @react-native packages
187
- flowStripPlugin(),
188
- // guard undefined native methods in NativeAnimatedHelper
189
- nativeAnimatedGuardPlugin(),
190
- // handle asset imports (.png, .jpg, .ttf, etc.)
191
- assetPlugin({
160
+ }), flowStripPlugin(), nativeAnimatedGuardPlugin(), assetPlugin({
192
161
  root,
193
162
  platform,
194
163
  assetsDest
195
- }),
196
- // @vxrn/compiler babel transforms: reanimated worklets, async generators,
197
- // react-native codegen, react compiler — same pipeline as metro
198
- vxrnCompilerPlugin(platform, dev),
199
- // hermes compat: transform class properties and private fields
200
- hermesCompatSWCPlugin(dev)];
164
+ }), vxrnCompilerPlugin(platform, dev), hermesCompatSWCPlugin(dev)];
201
165
  }
202
166
  function getNativeOutputOptions(prelude) {
203
167
  return {
@@ -210,27 +174,37 @@ function getNativeOutputOptions(prelude) {
210
174
  }
211
175
  function postProcessNativeBundle(code) {
212
176
  code = code.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm, "");
177
+ code = code.replace(/^\s*export\s+default\s+([^;\n]+);?\s*$/gm, "$1;");
213
178
  code = code.replace(/^if \(import\.meta\.hot\).*$/gm, "");
214
- {
215
- var marker = "NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;";
216
- var idx = code.indexOf(marker);
217
- if (idx !== -1) {
218
- var beforeMarker = code.lastIndexOf("NativeAnimatedModule = ", idx);
219
- if (beforeMarker !== -1) {
220
- var lineStart = code.lastIndexOf("\n", beforeMarker);
221
- var snippet = code.slice(lineStart + 1, beforeMarker + 50);
222
- if (snippet.includes("(function()") || snippet.includes("new Proxy")) {
223
- var afterMarker = code.indexOf("})();", idx);
224
- if (afterMarker !== -1) {
225
- var end = afterMarker + "})();".length;
226
- code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + code.slice(end);
227
- }
179
+ var idx = code.indexOf("NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;");
180
+ if (idx !== -1) {
181
+ var beforeMarker = code.lastIndexOf("NativeAnimatedModule = ", idx);
182
+ if (beforeMarker !== -1) {
183
+ var lineStart = code.lastIndexOf("\n", beforeMarker);
184
+ var snippet = code.slice(lineStart + 1, beforeMarker + 50);
185
+ if (snippet.includes("(function()") || snippet.includes("new Proxy")) {
186
+ var afterMarker = code.indexOf("})();", idx);
187
+ if (afterMarker !== -1) {
188
+ var end = afterMarker + 5;
189
+ code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + code.slice(end);
228
190
  }
229
191
  }
230
192
  }
231
193
  }
232
194
  return code;
233
195
  }
196
+ function wrapNativeBundleModuleScope(code) {
197
+ var idx = code.indexOf("//#region \\0rolldown/runtime.js");
198
+ if (idx === -1) return code;
199
+ var open = ";(function() {\n";
200
+ var close = "\n})();\n";
201
+ var sm = code.match(/\n\/\/# sourceMappingURL=[^\n]*\s*$/);
202
+ if (sm) {
203
+ var smIdx = code.lastIndexOf(sm[0]);
204
+ return code.slice(0, idx) + open + code.slice(idx, smIdx) + close + code.slice(smIdx);
205
+ }
206
+ return code.slice(0, idx) + open + code.slice(idx) + close;
207
+ }
234
208
  async function downlevelClassFieldsInBundle(code) {
235
209
  var startMarker = "//#region \\0rolldown/runtime.js";
236
210
  var endMarker = "//#endregion";
@@ -241,8 +215,7 @@ async function downlevelClassFieldsInBundle(code) {
241
215
  var runtimeEnd = endIdx + endMarker.length;
242
216
  var runtimeSection = code.slice(startIdx, runtimeEnd);
243
217
  try {
244
- var swc = await import("@swc/core");
245
- var result = await swc.transform(runtimeSection, {
218
+ var result = await (await import("@swc/core")).transform(runtimeSection, {
246
219
  filename: "rolldown-runtime.js",
247
220
  configFile: false,
248
221
  swcrc: false,
@@ -301,7 +274,7 @@ async function createNativeDevEngine(options) {
301
274
  var bundleResolve = null;
302
275
  var bundlePromise = null;
303
276
  var resolvedHost = host === "0.0.0.0" ? "localhost" : host;
304
- var inputOptions = {
277
+ var engine = await dev({
305
278
  input: VIRTUAL_NATIVE_ENTRY,
306
279
  cwd: root,
307
280
  platform: "neutral",
@@ -314,16 +287,9 @@ async function createNativeDevEngine(options) {
314
287
  port
315
288
  },
316
289
  incrementalBuild: true,
317
- // lazyBarrel defers barrel re-export initialization — needed in dev mode
318
- // to avoid breaking worklet closure serialization order.
319
- // removed from prod builds (buildNativeBundle) where it caused build errors.
320
290
  lazyBarrel: true
321
291
  },
322
292
  treeshake: false,
323
- // some react-native ecosystem packages import symbols that don't exist in
324
- // the declared entry (e.g. @react-navigation/elements imports NavigationProvider
325
- // from @react-navigation/native which doesn't export it). metro silently shims
326
- // these — rolldown needs an explicit opt-in.
327
293
  shimMissingExports: true,
328
294
  moduleTypes: {
329
295
  ".js": "jsx"
@@ -331,10 +297,8 @@ async function createNativeDevEngine(options) {
331
297
  plugins: [nativeVirtualEntryPlugin(root, {
332
298
  dev: true
333
299
  }), ...getNativePlugins(root, platform, viteImportGlobPlugin, true), ...userPlugins]
334
- };
335
- var outputOptions = {
300
+ }, {
336
301
  ...getNativeOutputOptions(prelude),
337
- // connect HMR WebSocket using RN's WebSocket module (not the global)
338
302
  outro: `
339
303
  try {
340
304
  var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
@@ -364,15 +328,13 @@ try {
364
328
  __hmrWS.onerror = function(e) { console.warn('[vxrn] HMR connection error:', e.message || e); };
365
329
  } catch(e) {}
366
330
  `
367
- };
368
- var engine = await dev(inputOptions, outputOptions, {
331
+ }, {
369
332
  onOutput: async function (result) {
370
333
  if (_instanceof(result, Error)) {
371
334
  console.error("[vxrn] native bundle error:", result.message);
372
335
  return;
373
336
  }
374
- var output = result;
375
- var chunk = output.output.find(function (o) {
337
+ var chunk = result.output.find(function (o) {
376
338
  return o.type === "chunk" && o.isEntry;
377
339
  });
378
340
  if (chunk && "code" in chunk) {
@@ -383,6 +345,7 @@ try {
383
345
  code = code.replace(/registerCallableModule\s*\(\s*["']AppRegistry["']/, function (match) {
384
346
  return hmrClientStub + "," + match;
385
347
  });
348
+ code = wrapNativeBundleModuleScope(code);
386
349
  currentBundle = {
387
350
  code,
388
351
  map: (_chunk_map = chunk.map) === null || _chunk_map === void 0 ? void 0 : _chunk_map.toString()
@@ -398,7 +361,7 @@ try {
398
361
  onHmrUpdates: async function (result) {
399
362
  if (_instanceof(result, Error)) {
400
363
  console.error("[vxrn] HMR error:", result.message);
401
- onHmrUpdate === null || onHmrUpdate === void 0 ? void 0 : onHmrUpdate({
364
+ onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({
402
365
  type: "hmr:error"
403
366
  });
404
367
  return;
@@ -411,36 +374,26 @@ try {
411
374
  for (var _iterator = updates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
412
375
  var item = _step.value;
413
376
  var update = item.update || item;
414
- if (update.type === "Patch" && update.code) {
415
- onHmrUpdate === null || onHmrUpdate === void 0 ? void 0 : onHmrUpdate({
416
- type: "hmr:update",
417
- code: update.code
418
- });
419
- } else if (update.type === "FullReload") {
420
- onHmrUpdate === null || onHmrUpdate === void 0 ? void 0 : onHmrUpdate({
421
- type: "hmr:reload"
422
- });
423
- }
377
+ if (update.type === "Patch" && update.code) onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({
378
+ type: "hmr:update",
379
+ code: update.code
380
+ });else if (update.type === "FullReload") onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({
381
+ type: "hmr:reload"
382
+ });
424
383
  }
425
384
  } catch (err) {
426
385
  _didIteratorError = true;
427
386
  _iteratorError = err;
428
387
  } finally {
429
388
  try {
430
- if (!_iteratorNormalCompletion && _iterator.return != null) {
431
- _iterator.return();
432
- }
389
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
433
390
  } finally {
434
- if (_didIteratorError) {
435
- throw _iteratorError;
436
- }
391
+ if (_didIteratorError) throw _iteratorError;
437
392
  }
438
393
  }
439
- if (updates.length === 0) {
440
- onHmrUpdate === null || onHmrUpdate === void 0 ? void 0 : onHmrUpdate({
441
- type: "hmr:reload"
442
- });
443
- }
394
+ if (updates.length === 0) onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({
395
+ type: "hmr:reload"
396
+ });
444
397
  },
445
398
  rebuildStrategy: "auto",
446
399
  watch: {}
@@ -458,7 +411,7 @@ try {
458
411
  resolve2(value);
459
412
  };
460
413
  timeoutId = setTimeout(function () {
461
- return reject(new Error("[vxrn] bundle build timed out after 120s"));
414
+ return reject(/* @__PURE__ */new Error("[vxrn] bundle build timed out after 120s"));
462
415
  }, 12e4);
463
416
  });
464
417
  }
@@ -478,6 +431,7 @@ async function buildNativeBundle(options) {
478
431
  platform,
479
432
  dev = false,
480
433
  serverUrl,
434
+ entryFile,
481
435
  assetsDest,
482
436
  plugins: userPlugins = []
483
437
  } = options;
@@ -492,8 +446,8 @@ async function buildNativeBundle(options) {
492
446
  platform,
493
447
  serverUrl
494
448
  });
495
- var result = await build({
496
- input: VIRTUAL_NATIVE_ENTRY,
449
+ var chunk = (await build({
450
+ input: entryFile ? normalizePath(resolve(root, entryFile)) : VIRTUAL_NATIVE_ENTRY,
497
451
  cwd: root,
498
452
  platform: "neutral",
499
453
  resolve: getNativeResolveConfig(platform),
@@ -503,17 +457,14 @@ async function buildNativeBundle(options) {
503
457
  moduleTypes: {
504
458
  ".js": "jsx"
505
459
  },
506
- plugins: [nativeVirtualEntryPlugin(root, {
460
+ plugins: [...(entryFile ? [] : [nativeVirtualEntryPlugin(root, {
507
461
  dev
508
- }), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest), ...userPlugins],
462
+ })]), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest), ...userPlugins],
509
463
  output: getNativeOutputOptions(prelude)
510
- });
511
- var chunk = result.output.find(function (o) {
464
+ })).output.find(function (o) {
512
465
  return o.type === "chunk" && o.isEntry;
513
466
  });
514
- if (!chunk || !("code" in chunk)) {
515
- throw new Error("[vxrn] production build produced no output");
516
- }
467
+ if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
517
468
  var code = postProcessNativeBundle(chunk.code);
518
469
  code = await downlevelClassFieldsInBundle(code);
519
470
  return {
@@ -537,12 +488,11 @@ function nativeVirtualEntryPlugin(root, opts) {
537
488
  var resolved = pathToFileURL(resolve(root, file)).href;
538
489
  return `import ${JSON.stringify(resolved)};`;
539
490
  }();
540
- var routeGlobs = [`./${routerRoot}/**/*.tsx`, `./${routerRoot}/**/*.ts`, `!./${routerRoot}/**/*+api.*`, `!./${routerRoot}/**/*.test.*`, `!./${routerRoot}/**/*.d.ts`, `!./${routerRoot}/**/*.server.*`, `!./${routerRoot}/**/_middleware.*`, `!./${routerRoot}/**/*.web.*`,
541
- // ignoredRouteFiles from One's router config
542
- ...(entryConfig.ignoredRouteFiles || []).map(function (pattern) {
491
+ var routeGlobs = [`./${routerRoot}/**/*.tsx`, `./${routerRoot}/**/*.ts`, `!./${routerRoot}/**/*+api.*`, `!./${routerRoot}/**/*.test.*`, `!./${routerRoot}/**/*.d.ts`, `!./${routerRoot}/**/*.server.*`, `!./${routerRoot}/**/_middleware.*`, `!./${routerRoot}/**/*.web.*`, ...(entryConfig.ignoredRouteFiles || []).map(function (pattern) {
543
492
  return `!./${routerRoot}/${pattern}`;
544
493
  })];
545
- var refreshSetup = isDev ? `
494
+ var entryCode = `
495
+ ${isDev ? `
546
496
  // react-refresh/runtime MUST initialize before React loads
547
497
  import RefreshRuntime from 'react-refresh/runtime';
548
498
  RefreshRuntime.injectIntoGlobalHook(globalThis);
@@ -551,12 +501,15 @@ globalThis.$RefreshReg$ = function(type, id) {
551
501
  RefreshRuntime.register(type, id);
552
502
  };
553
503
  globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
554
- ` : "";
555
- var entryCode = `
556
- ${refreshSetup}
504
+ ` : ""}
505
+ import * as ReactNativeInitializeCore from 'react-native/Libraries/Core/InitializeCore';
506
+ import NativeWebSocket from 'react-native/Libraries/WebSocket/WebSocket';
557
507
  ${setupFileImport}
558
508
  import { createApp } from 'one';
559
509
 
510
+ void ReactNativeInitializeCore;
511
+ globalThis.WebSocket = NativeWebSocket;
512
+
560
513
  var _routes = import.meta.glob(${JSON.stringify(routeGlobs)}, { exhaustive: true });
561
514
  // fix route keys: One expects '/${routerRoot}/...' prefix but import.meta.glob returns './${routerRoot}/...'
562
515
  var routes = {};
@@ -575,14 +528,10 @@ createApp({
575
528
  return {
576
529
  name: "vxrn:native-virtual-entry",
577
530
  resolveId(id) {
578
- if (id === VIRTUAL_NATIVE_ENTRY) {
579
- return resolvedId;
580
- }
531
+ if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
581
532
  },
582
533
  load(id) {
583
- if (id === resolvedId) {
584
- return entryCode;
585
- }
534
+ if (id === resolvedId) return entryCode;
586
535
  }
587
536
  };
588
537
  }
@@ -604,18 +553,14 @@ function serverFileExclusionPlugin() {
604
553
  return {
605
554
  name: "vxrn:server-file-exclusion",
606
555
  load(id) {
607
- if (/\.server\.\w+$/.test(id)) {
608
- return {
609
- code: "export default undefined;",
610
- moduleType: "js"
611
- };
612
- }
613
- if (/[\\/]_middleware\.\w+$/.test(id)) {
614
- return {
615
- code: "export default undefined;",
616
- moduleType: "js"
617
- };
618
- }
556
+ if (/\.server\.\w+$/.test(id)) return {
557
+ code: "export default undefined;",
558
+ moduleType: "js"
559
+ };
560
+ if (/[\\/]_middleware\.\w+$/.test(id)) return {
561
+ code: "export default undefined;",
562
+ moduleType: "js"
563
+ };
619
564
  }
620
565
  };
621
566
  }
@@ -635,13 +580,10 @@ function environmentGuardPlugin() {
635
580
  };
636
581
  },
637
582
  load(id) {
638
- if (id.startsWith("\0env-guard-throw:")) {
639
- var pkg = id.slice("\0env-guard-throw:".length);
640
- return {
641
- code: `throw new Error("Cannot import '${pkg}' in a native bundle.");`,
642
- moduleType: "js"
643
- };
644
- }
583
+ if (id.startsWith("\0env-guard-throw:")) return {
584
+ code: `throw new Error("Cannot import '${id.slice(17)}' in a native bundle.");`,
585
+ moduleType: "js"
586
+ };
645
587
  if (id.startsWith("\0env-guard-noop:")) return {
646
588
  code: "",
647
589
  moduleType: "js"
@@ -654,12 +596,10 @@ function cssStubPlugin() {
654
596
  name: "vxrn:css-stub",
655
597
  load: {
656
598
  handler(id) {
657
- if (id.endsWith(".css")) {
658
- return {
659
- code: "",
660
- moduleType: "js"
661
- };
662
- }
599
+ if (id.endsWith(".css")) return {
600
+ code: "",
601
+ moduleType: "js"
602
+ };
663
603
  }
664
604
  }
665
605
  };
@@ -696,14 +636,12 @@ function vxrnCompilerPlugin(platform, dev) {
696
636
  var result = await compiler.transformBabel(id, code, babelOptions);
697
637
  if (result === null || result === void 0 ? void 0 : result.code) {
698
638
  var out = result.code;
699
- if (needsRefresh) {
700
- var escapedId = id.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
701
- out = `
639
+ if (needsRefresh) out = `
702
640
  var __prevRefreshReg = globalThis.$RefreshReg$;
703
641
  var __prevRefreshSig = globalThis.$RefreshSig$;
704
642
  if (globalThis.__ReactRefresh) {
705
643
  globalThis.$RefreshReg$ = function(type, id) {
706
- globalThis.__ReactRefresh.register(type, "${escapedId}" + " " + id);
644
+ globalThis.__ReactRefresh.register(type, "${id.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}" + " " + id);
707
645
  };
708
646
  globalThis.$RefreshSig$ = globalThis.__ReactRefresh.createSignatureFunctionForTransform;
709
647
  }
@@ -720,22 +658,17 @@ if (import.meta.hot) {
720
658
  });
721
659
  }
722
660
  `;
723
- }
724
661
  return {
725
662
  code: out
726
663
  };
727
664
  }
728
665
  } catch (err) {
729
- if (dev) {
730
- console.warn(`[vxrn:compiler] ${id}: ${err.message || err}`);
731
- }
732
- if (needsRefresh) {
733
- return {
734
- code: code + `
666
+ if (dev) console.warn(`[vxrn:compiler] ${id}: ${err.message || err}`);
667
+ if (needsRefresh) return {
668
+ code: code + `
735
669
  if (import.meta.hot) { import.meta.hot.accept(); }
736
670
  `
737
- };
738
- }
671
+ };
739
672
  }
740
673
  }
741
674
  };
@@ -747,8 +680,7 @@ function flowStripPlugin() {
747
680
  async handler(code, id) {
748
681
  if (!FLOW_FILE_PATTERN.test(id)) return;
749
682
  try {
750
- var fft = await import("fast-flow-transform");
751
- var result = await fft.default({
683
+ var result = await (await import("fast-flow-transform")).default({
752
684
  filename: id,
753
685
  source: code,
754
686
  sourcemap: true,
@@ -777,28 +709,25 @@ function assetPlugin(opts) {
777
709
  var name = basename(id, `.${ext}`);
778
710
  var dir = dirname(id);
779
711
  var relativePath = relative(opts.root, id);
780
- var httpLocation = "/assets/" + dirname(relativePath).replace(/\\/g, "/");
781
712
  var assetData = {
782
713
  __packager_asset: true,
783
714
  name,
784
715
  type: ext,
785
716
  scales: [1],
786
- httpServerLocation: httpLocation,
717
+ httpServerLocation: "/assets/" + dirname(relativePath).replace(/\\/g, "/"),
787
718
  fileSystemLocation: dir,
788
719
  hash: "",
789
720
  width: void 0,
790
721
  height: void 0
791
722
  };
792
- if (["png", "jpg", "jpeg", "gif", "webp", "bmp"].includes(ext)) {
793
- try {
794
- var {
795
- imageSize
796
- } = await import("image-size");
797
- var dims = imageSize(id);
798
- assetData.width = dims.width;
799
- assetData.height = dims.height;
800
- } catch (unused) {}
801
- }
723
+ if (["png", "jpg", "jpeg", "gif", "webp", "bmp"].includes(ext)) try {
724
+ var {
725
+ imageSize
726
+ } = await import("image-size");
727
+ var dims = imageSize(id);
728
+ assetData.width = dims.width;
729
+ assetData.height = dims.height;
730
+ } catch (unused) {}
802
731
  if (opts.assetsDest) {
803
732
  var relativeAssetDir = dirname(relativePath).replace(/\\/g, "/");
804
733
  var assetDestDir = join(opts.assetsDest, "assets", relativeAssetDir);
@@ -807,9 +736,8 @@ function assetPlugin(opts) {
807
736
  });
808
737
  copyFileSync(id, join(assetDestDir, `${name}.${ext}`));
809
738
  }
810
- var code = `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`;
811
739
  return {
812
- code,
740
+ code: `module.exports = require('react-native/Libraries/Image/AssetRegistry').registerAsset(${JSON.stringify(assetData)});`,
813
741
  moduleType: "js"
814
742
  };
815
743
  }
@@ -830,38 +758,37 @@ function hermesCompatSWCPlugin(dev) {
830
758
  try {
831
759
  if (!swc) swc = await import("@swc/core");
832
760
  var envIncludes = ["transform-class-properties", "transform-class-static-block", "transform-private-methods", "transform-private-property-in-object", ...(!dev ? ["transform-classes", "transform-async-to-generator"] : [])];
833
- var result = await swc.transform(code, {
834
- filename: id,
835
- configFile: false,
836
- swcrc: false,
837
- sourceMaps: false,
838
- inputSourceMap: false,
839
- env: {
840
- targets: {
841
- node: 9999
842
- },
843
- include: envIncludes
844
- },
845
- jsc: {
846
- parser: {
847
- syntax: "typescript",
848
- tsx: true
761
+ return {
762
+ code: (await swc.transform(code, {
763
+ filename: id,
764
+ configFile: false,
765
+ swcrc: false,
766
+ sourceMaps: false,
767
+ inputSourceMap: false,
768
+ env: {
769
+ targets: {
770
+ node: 9999
771
+ },
772
+ include: envIncludes
849
773
  },
850
- transform: {
851
- react: {
852
- runtime: "preserve"
774
+ jsc: {
775
+ parser: {
776
+ syntax: "typescript",
777
+ tsx: true
778
+ },
779
+ transform: {
780
+ react: {
781
+ runtime: "preserve"
782
+ }
783
+ },
784
+ externalHelpers: false,
785
+ assumptions: {
786
+ setPublicClassFields: true,
787
+ privateFieldsAsProperties: true
853
788
  }
854
789
  },
855
- externalHelpers: false,
856
- assumptions: {
857
- setPublicClassFields: true,
858
- privateFieldsAsProperties: true
859
- }
860
- },
861
- isModule: !id.endsWith(".cjs")
862
- });
863
- return {
864
- code: result.code
790
+ isModule: !id.endsWith(".cjs")
791
+ })).code
865
792
  };
866
793
  } catch (err) {}
867
794
  }
@@ -969,5 +896,5 @@ class ReactNativeDevRuntime extends BaseDevRuntime {
969
896
  globalThis.__rolldown_runtime__ = new ReactNativeDevRuntime();
970
897
  `;
971
898
  }
972
- export { buildNativeBundle, createNativeDevEngine };
899
+ export { buildNativeBundle, createNativeDevEngine, getNativeTransformConfig, wrapNativeBundleModuleScope };
973
900
  //# sourceMappingURL=createNativeDevEngine.native.js.map