vxrn 1.26.0 → 1.26.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.
Files changed (42) hide show
  1. package/dist/plugins/reactNativeDevServer.mjs +123 -42
  2. package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
  3. package/dist/plugins/reactNativeDevServer.native.js +209 -44
  4. package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
  5. package/dist/rn-commands/bundle/buildBundle.mjs +29 -10
  6. package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
  7. package/dist/rn-commands/bundle/buildBundle.native.js +29 -10
  8. package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
  9. package/dist/utils/createNativeDevEngine.mjs +220 -83
  10. package/dist/utils/createNativeDevEngine.mjs.map +1 -1
  11. package/dist/utils/createNativeDevEngine.native.js +257 -84
  12. package/dist/utils/createNativeDevEngine.native.js.map +1 -1
  13. package/dist/utils/createNativeDevEngine.test.mjs +285 -23
  14. package/dist/utils/createNativeDevEngine.test.mjs.map +1 -1
  15. package/dist/utils/createNativeDevEngine.test.native.js +319 -23
  16. package/dist/utils/createNativeDevEngine.test.native.js.map +1 -1
  17. package/dist/utils/patches.test.mjs.map +1 -1
  18. package/dist/utils/patches.test.native.js.map +1 -1
  19. package/dist/utils/symbolicateNativeStack.mjs +66 -0
  20. package/dist/utils/symbolicateNativeStack.mjs.map +1 -0
  21. package/dist/utils/symbolicateNativeStack.native.js +70 -0
  22. package/dist/utils/symbolicateNativeStack.native.js.map +1 -0
  23. package/dist/utils/symbolicateNativeStack.test.mjs +96 -0
  24. package/dist/utils/symbolicateNativeStack.test.mjs.map +1 -0
  25. package/dist/utils/symbolicateNativeStack.test.native.js +96 -0
  26. package/dist/utils/symbolicateNativeStack.test.native.js.map +1 -0
  27. package/package.json +12 -11
  28. package/src/plugins/reactNativeDevServer.ts +162 -50
  29. package/src/rn-commands/bundle/buildBundle.ts +28 -9
  30. package/src/utils/createNativeDevEngine.test.ts +581 -193
  31. package/src/utils/createNativeDevEngine.ts +434 -115
  32. package/src/utils/patches.test.ts +1 -4
  33. package/src/utils/symbolicateNativeStack.test.ts +78 -0
  34. package/src/utils/symbolicateNativeStack.ts +129 -0
  35. package/types/plugins/reactNativeDevServer.d.ts.map +1 -1
  36. package/types/rn-commands/bundle/buildBundle.d.ts.map +1 -1
  37. package/types/utils/createNativeDevEngine.d.ts +23 -4
  38. package/types/utils/createNativeDevEngine.d.ts.map +1 -1
  39. package/types/utils/symbolicateNativeStack.d.ts +46 -0
  40. package/types/utils/symbolicateNativeStack.d.ts.map +1 -0
  41. package/types/utils/symbolicateNativeStack.test.d.ts +2 -0
  42. package/types/utils/symbolicateNativeStack.test.d.ts.map +1 -0
@@ -1,7 +1,8 @@
1
1
  import { createHash } from "crypto";
2
2
  import { basename, dirname, extname, join, relative, resolve } from "path";
3
- import { copyFileSync, mkdirSync, readFileSync, readdirSync, realpathSync } from "fs";
3
+ import { copyFileSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync } from "fs";
4
4
  import { pathToFileURL } from "url";
5
+ import micromatch from "micromatch";
5
6
  import { loadEnv, normalizePath } from "vite";
6
7
  import { shouldStripFlow, transformHermesAsync } from "@vxrn/compiler";
7
8
  import { DEFAULT_ASSET_EXTS } from "../constants/defaults.native.js";
@@ -145,7 +146,13 @@ function getNativeTransformConfig(platform, dev, root) {
145
146
  };
146
147
  }
147
148
  function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, onAsset) {
148
- var sourceMaps = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : false;
149
+ var sourceMaps = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : false,
150
+ userPlugins = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : [];
151
+ var context = {
152
+ root,
153
+ platform,
154
+ dev
155
+ };
149
156
  return [...(globalThis.__vxrnAddNativePlugins || []), serverFileExclusionPlugin(), environmentGuardPlugin(), hmrClientNoopPlugin(), cssStubPlugin(), viteImportGlobPlugin({
150
157
  root
151
158
  }), vxrnCompilerPlugin(platform, dev, root, sourceMaps), rnCodegenPlugin({
@@ -155,25 +162,47 @@ function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest,
155
162
  platform,
156
163
  assetsDest,
157
164
  onAsset
158
- }), hermesCompatSWCPlugin(dev, sourceMaps), hermesLoopsPlugin(sourceMaps)];
165
+ }), hermesCompatSWCPlugin(dev, sourceMaps), hermesLoopsPlugin(sourceMaps), ...userPlugins].map(function (plugin) {
166
+ var _plugin_api;
167
+ return ((_plugin_api = plugin.api) === null || _plugin_api === void 0 ? void 0 : _plugin_api.vxrnNative) ? plugin.api.vxrnNative(context) : plugin;
168
+ });
159
169
  }
160
- function getNativeOutputOptions(prelude, sourcemap) {
170
+ function getNativeOutputOptions(prelude, sourcemap, minify) {
161
171
  return {
162
172
  format: "esm",
163
173
  sourcemap,
174
+ sourcemapPathTransform: function (relativeSourcePath, sourcemapPath) {
175
+ return normalizePath(resolve(dirname(sourcemapPath), relativeSourcePath));
176
+ },
164
177
  intro: prelude,
165
178
  codeSplitting: false,
166
- strictExecutionOrder: true
179
+ strictExecutionOrder: true,
180
+ minify: minify || "dce-only"
167
181
  };
168
182
  }
169
183
  function normalizeNativeCommonJSInterop(code) {
170
184
  return code.replace(/(\b__toESM(?:\$\d+)?\(\s*(?:require[\w$]*\(\)|__rolldown_runtime__\.loadExports\("(?:\\.|[^"\\])*"\))\s*),\s*1(\s*\))/g, "$1$2");
171
185
  }
186
+ function blankPreservingLines(match) {
187
+ var _ref;
188
+ var _match_match;
189
+ return "\n".repeat((_ref = (_match_match = match.match(/\n/g)) === null || _match_match === void 0 ? void 0 : _match_match.length) !== null && _ref !== void 0 ? _ref : 0);
190
+ }
191
+ function countLines(code) {
192
+ var _ref;
193
+ var _code_match;
194
+ return ((_ref = (_code_match = code.match(/\n/g)) === null || _code_match === void 0 ? void 0 : _code_match.length) !== null && _ref !== void 0 ? _ref : 0) + 1;
195
+ }
196
+ function assertBundleLinesPreserved(before, after, stage) {
197
+ var beforeLines = countLines(before);
198
+ var afterLines = countLines(after);
199
+ if (beforeLines !== afterLines) throw new Error(`[vxrn] native bundle post-processing (${stage}) changed the line count (${beforeLines} -> ${afterLines}), which invalidates the source map. Every pass after Rolldown emits the map must preserve lines.`);
200
+ }
172
201
  function postProcessNativeBundle(code) {
173
202
  code = normalizeNativeCommonJSInterop(code);
174
203
  code = code.replace(/\btypeof\s+import\.meta\b/g, "\"object\"");
175
- code = code.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm, "");
176
- code = code.replace(/^\s*export\s+default\s+([^;\n]+);?\s*$/gm, "$1;");
204
+ code = code.replace(/^[^\S\n]*export[^\S\n]*\{[^}]*\}[^\S\n]*;?[^\S\n]*$/gm, blankPreservingLines);
205
+ code = code.replace(/^([^\S\n]*)export[^\S\n]+default[^\S\n]+([^;\n]+);?[^\S\n]*$/gm, "$1$2;");
177
206
  code = code.replace(/^if \(import\.meta\.hot\).*$/gm, "");
178
207
  var idx = code.indexOf("NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;");
179
208
  if (idx !== -1) {
@@ -185,7 +214,8 @@ function postProcessNativeBundle(code) {
185
214
  var afterMarker = code.indexOf("})();", idx);
186
215
  if (afterMarker !== -1) {
187
216
  var end = afterMarker + 5;
188
- code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + code.slice(end);
217
+ var removed = code.slice(beforeMarker, end);
218
+ code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + blankPreservingLines(removed) + code.slice(end);
189
219
  }
190
220
  }
191
221
  }
@@ -195,7 +225,7 @@ function postProcessNativeBundle(code) {
195
225
  function wrapNativeBundleModuleScope(code) {
196
226
  var idx = code.indexOf("//#region \\0rolldown/runtime.js");
197
227
  if (idx === -1) return code;
198
- return code.slice(0, idx) + ";(function() {\n" + code.slice(idx) + "\n})();\n";
228
+ return code.slice(0, idx) + ";(function() {" + code.slice(idx) + "\n})();\n";
199
229
  }
200
230
  async function downlevelClassFieldsInBundle(code) {
201
231
  var _ref, _ref1;
@@ -229,6 +259,19 @@ ${transformedCode}`;
229
259
  var linePreservingRuntime = transformed + "\n".repeat(originalNewlines - transformedNewlines);
230
260
  return code.slice(0, startIdx) + linePreservingRuntime + code.slice(runtimeEnd);
231
261
  }
262
+ function nativeBundlePostProcessPlugin() {
263
+ return {
264
+ name: "vxrn:native-post-process",
265
+ async renderChunk(code) {
266
+ var processed = await downlevelClassFieldsInBundle(postProcessNativeBundle(code));
267
+ assertBundleLinesPreserved(code, processed, "production");
268
+ return {
269
+ code: processed,
270
+ map: null
271
+ };
272
+ }
273
+ };
274
+ }
232
275
  async function createNativeDevEngine(options) {
233
276
  var {
234
277
  root,
@@ -256,7 +299,16 @@ async function createNativeDevEngine(options) {
256
299
  var bundleReject = null;
257
300
  var bundlePromise = null;
258
301
  var resolvedHost = host === "0.0.0.0" ? "localhost" : host;
259
- var engine = await dev({
302
+ var virtualEntry = nativeVirtualEntryPlugin(root, {
303
+ dev: true
304
+ });
305
+ var engineWork = Promise.resolve();
306
+ var queueEngineWork = function (work) {
307
+ var result = engineWork.then(work, work);
308
+ engineWork = result.catch(function () {});
309
+ return result;
310
+ };
311
+ var inputOptions = {
260
312
  input: VIRTUAL_NATIVE_ENTRY,
261
313
  cwd: root,
262
314
  platform: "neutral",
@@ -276,74 +328,59 @@ async function createNativeDevEngine(options) {
276
328
  moduleTypes: {
277
329
  ".js": "jsx"
278
330
  },
279
- plugins: [nativeVirtualEntryPlugin(root, {
280
- dev: true
281
- }), ...getNativePlugins(root, platform, viteImportGlobPlugin, true, void 0, assetRegistry.register, false), ...userPlugins]
282
- }, {
283
- ...getNativeOutputOptions(prelude, false),
331
+ plugins: [virtualEntry.plugin, ...getNativePlugins(root, platform, viteImportGlobPlugin, true, void 0, assetRegistry.register, true, userPlugins)]
332
+ };
333
+ var outputOptions = {
334
+ ...getNativeOutputOptions(prelude, true, false),
284
335
  outro: `
285
336
  try {
286
337
  var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
287
338
  var __hmrUrl = 'ws://${resolvedHost}:${port}/hot?platform=${platform}&clientId=' + encodeURIComponent(__rolldown_runtime__.clientId);
288
- var __hmrWS = new __WS(__hmrUrl);
289
- __hmrWS.onmessage = function(event) {
290
- try {
291
- var msg = JSON.parse(event.data);
292
- var g = typeof global !== 'undefined' ? global : globalThis;
293
- if (msg.type === 'hmr:update' && msg.code) {
294
- var applied = __rolldown_runtime__.applyHmrUpdate(msg.code, msg.changedIds, msg.seq);
295
- if (!applied) {
296
- var updateSettings = g.__turboModuleProxy ? g.__turboModuleProxy('DevSettings') : null;
297
- if (updateSettings && updateSettings.reload) updateSettings.reload();
298
- }
299
- } else if (msg.type === 'hmr:reload') {
300
- var ds = g.__turboModuleProxy ? g.__turboModuleProxy('DevSettings') : null;
301
- if (ds && ds.reload) ds.reload();
302
- }
303
- } catch(e) { console.error('[vxrn] HMR eval error:', e); }
339
+ __rolldown_runtime__.setup(new __WS(__hmrUrl));
340
+ } catch(e) {
341
+ // a swallowed failure here leaves the app permanently without Fast Refresh and
342
+ // nothing on screen or in the terminal says so.
343
+ console.error('[vxrn] HMR client failed to start:', (e && e.message) || e);
344
+ }
345
+ `
304
346
  };
305
- __hmrWS.onopen = function() {
306
- if (typeof __rolldown_runtime__ !== 'undefined' && __rolldown_runtime__.setup) {
307
- __rolldown_runtime__.setup(__hmrWS);
308
- }
347
+ var outputProcessed = Promise.resolve();
348
+ var engine;
349
+ var rebuildIfNewRoute = async function (files) {
350
+ var {
351
+ routeRoot,
352
+ files: knownRoutes,
353
+ isRouteFile
354
+ } = virtualEntry.routes;
355
+ var routeRootPrefix = `${normalizePath(routeRoot)}/`;
356
+ if (!files.some(function (file) {
357
+ var _statSync;
358
+ var normalized = normalizePath(file);
359
+ if (isRouteFile(normalized)) return !knownRoutes.has(normalized);
360
+ return normalized.startsWith(routeRootPrefix) && ((_statSync = statSync(file, {
361
+ throwIfNoEntry: false
362
+ })) === null || _statSync === void 0 ? void 0 : _statSync.isDirectory()) === true;
363
+ })) return false;
364
+ await queueEngineWork(async function () {
365
+ engine.triggerFullBuild();
366
+ await engine.ensureLatestBuildOutput();
367
+ await outputProcessed;
368
+ });
369
+ onHmrUpdate === null || onHmrUpdate === void 0 || onHmrUpdate({
370
+ type: "hmr:reload"
371
+ });
372
+ return true;
309
373
  };
310
- __hmrWS.onerror = function(e) { console.warn('[vxrn] HMR connection error:', e.message || e); };
311
- } catch(e) {}
312
- `
313
- }, {
374
+ engine = await dev(inputOptions, outputOptions, {
314
375
  onOutput: async function (result) {
315
- if (_instanceof(result, Error)) {
316
- console.error("[vxrn] native bundle error:", result.message);
317
- if (!currentBundle) {
318
- firstBuildError || (firstBuildError = result);
319
- if (bundleReject) {
320
- var reject = bundleReject;
321
- bundleResolve = null;
322
- bundleReject = null;
323
- bundlePromise = null;
324
- reject(firstBuildError);
325
- }
326
- }
327
- return;
328
- }
329
- var chunk = result.output.find(function (o) {
330
- return o.type === "chunk" && o.isEntry;
376
+ var finishOutput = function () {};
377
+ outputProcessed = new Promise(function (resolve2) {
378
+ finishOutput = resolve2;
331
379
  });
332
- if (chunk && "code" in chunk) {
333
- firstBuildError = null;
334
- var code = postProcessNativeBundle(chunk.code);
335
- code = await downlevelClassFieldsInBundle(code);
336
- code = wrapNativeBundleModuleScope(code);
337
- currentBundle = {
338
- code
339
- };
340
- console.info(`[vxrn] native bundle ready (${Math.round(code.length / 1024)}KB)`);
341
- if (bundleResolve) {
342
- bundleResolve(currentBundle);
343
- bundleResolve = null;
344
- bundleReject = null;
345
- bundlePromise = null;
346
- }
380
+ try {
381
+ await handleOutput(result);
382
+ } finally {
383
+ finishOutput();
347
384
  }
348
385
  },
349
386
  onHmrUpdates: async function (result) {
@@ -354,6 +391,7 @@ try {
354
391
  });
355
392
  return;
356
393
  }
394
+ if (await rebuildIfNewRoute(result.changedFiles)) return;
357
395
  var _iteratorNormalCompletion = true,
358
396
  _didIteratorError = false,
359
397
  _iteratorError = void 0;
@@ -388,11 +426,53 @@ try {
388
426
  rebuildStrategy: "never",
389
427
  watch: {}
390
428
  });
429
+ async function handleOutput(result) {
430
+ if (_instanceof(result, Error)) {
431
+ console.error("[vxrn] native bundle error:", result.message);
432
+ if (/panic/i.test(result.message)) console.error("[vxrn] rolldown itself panicked. Fast Refresh will full-reload until you restart the dev server.");
433
+ if (!currentBundle) {
434
+ firstBuildError || (firstBuildError = result);
435
+ if (bundleReject) {
436
+ var reject = bundleReject;
437
+ bundleResolve = null;
438
+ bundleReject = null;
439
+ bundlePromise = null;
440
+ reject(firstBuildError);
441
+ }
442
+ }
443
+ return;
444
+ }
445
+ var chunk = result.output.find(function (o) {
446
+ return o.type === "chunk" && o.isEntry;
447
+ });
448
+ if (chunk && "code" in chunk) {
449
+ firstBuildError = null;
450
+ var code = postProcessNativeBundle(chunk.code);
451
+ code = await downlevelClassFieldsInBundle(code);
452
+ assertBundleLinesPreserved(chunk.code, code, "dev");
453
+ code = wrapNativeBundleModuleScope(code);
454
+ if (!chunk.map) throw new Error("[vxrn] rolldown produced no source map for the dev bundle, so /symbolicate cannot resolve a frame");
455
+ currentBundle = {
456
+ code,
457
+ map: chunk.map.toString()
458
+ };
459
+ console.info(`[vxrn] native bundle ready (${Math.round(code.length / 1024)}KB)`);
460
+ if (bundleResolve) {
461
+ bundleResolve(currentBundle);
462
+ bundleResolve = null;
463
+ bundleReject = null;
464
+ bundlePromise = null;
465
+ }
466
+ }
467
+ }
391
468
  await engine.run();
392
469
  return {
393
470
  engine,
394
471
  async getBundle() {
395
- await engine.ensureLatestBuildOutput();
472
+ await queueEngineWork(async function () {
473
+ await engine.ensureLatestBuildOutput();
474
+ await outputProcessed;
475
+ });
396
476
  if (currentBundle) return currentBundle;
397
477
  if (firstBuildError) throw firstBuildError;
398
478
  if (!bundlePromise) {
@@ -421,6 +501,9 @@ try {
421
501
  },
422
502
  async close() {
423
503
  await engine.close();
504
+ },
505
+ async handleAddedFile(file) {
506
+ await rebuildIfNewRoute([file]);
424
507
  }
425
508
  };
426
509
  }
@@ -434,7 +517,8 @@ async function buildNativeBundle(options) {
434
517
  entryFile,
435
518
  assetsDest,
436
519
  plugins: userPlugins = [],
437
- sourcemap = false
520
+ sourcemap = false,
521
+ minify = !dev
438
522
  } = options;
439
523
  var {
440
524
  build
@@ -463,16 +547,15 @@ async function buildNativeBundle(options) {
463
547
  },
464
548
  plugins: [...(entryFile ? [] : [nativeVirtualEntryPlugin(root, {
465
549
  dev
466
- })]), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap), ...userPlugins],
467
- output: getNativeOutputOptions(prelude, sourcemap)
550
+ }).plugin]), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap, userPlugins), nativeBundlePostProcessPlugin()],
551
+ output: getNativeOutputOptions(prelude, sourcemap, minify)
468
552
  })).output.find(function (o) {
469
553
  return o.type === "chunk" && o.isEntry;
470
554
  });
471
555
  if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
472
- var code = postProcessNativeBundle(chunk.code);
473
- code = await downlevelClassFieldsInBundle(code);
556
+ if (sourcemap && !chunk.map) throw new Error("[vxrn] a source map was requested but rolldown produced none for the production bundle");
474
557
  return {
475
- code,
558
+ code: chunk.code,
476
559
  map: sourcemap ? (_chunk_map = chunk.map) === null || _chunk_map === void 0 ? void 0 : _chunk_map.toString() : void 0
477
560
  };
478
561
  }
@@ -529,13 +612,68 @@ createApp({
529
612
  linking: ${JSON.stringify(linking)},
530
613
  });
531
614
  `;
615
+ var routeRoot = resolve(root, routerRoot);
616
+ var stripDot = function (pattern) {
617
+ return pattern.replace(/^\.\//, "");
618
+ };
619
+ var includeGlobs = routeGlobs.filter(function (p) {
620
+ return !p.startsWith("!");
621
+ }).map(stripDot);
622
+ var excludeGlobs = routeGlobs.filter(function (p) {
623
+ return p.startsWith("!");
624
+ }).map(function (p) {
625
+ return stripDot(p.slice(1));
626
+ });
627
+ var isRouteFile = function (file) {
628
+ var relativeToRoot = normalizePath(relative(root, file));
629
+ return micromatch.isMatch(relativeToRoot, includeGlobs) && !micromatch.isMatch(relativeToRoot, excludeGlobs);
630
+ };
631
+ var routes = {
632
+ routeRoot,
633
+ files: /* @__PURE__ */new Set(),
634
+ isRouteFile
635
+ };
532
636
  return {
533
- name: "vxrn:native-virtual-entry",
534
- resolveId(id) {
535
- if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
536
- },
537
- load(id) {
538
- if (id === resolvedId) return entryCode;
637
+ routes,
638
+ plugin: {
639
+ name: "vxrn:native-virtual-entry",
640
+ resolveId(id) {
641
+ if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
642
+ },
643
+ load(id) {
644
+ var _this = this;
645
+ var _statSync;
646
+ if (id !== resolvedId) return;
647
+ routes.files.clear();
648
+ var walkRouteRoot = function (dir) {
649
+ _this.addWatchFile(dir);
650
+ var _iteratorNormalCompletion = true,
651
+ _didIteratorError = false,
652
+ _iteratorError = void 0;
653
+ try {
654
+ for (var _iterator = readdirSync(dir, {
655
+ withFileTypes: true
656
+ })[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
657
+ var entry = _step.value;
658
+ var child = resolve(dir, entry.name);
659
+ if (entry.isDirectory()) walkRouteRoot(child);else if (isRouteFile(child)) routes.files.add(normalizePath(child));
660
+ }
661
+ } catch (err) {
662
+ _didIteratorError = true;
663
+ _iteratorError = err;
664
+ } finally {
665
+ try {
666
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
667
+ } finally {
668
+ if (_didIteratorError) throw _iteratorError;
669
+ }
670
+ }
671
+ };
672
+ if ((_statSync = statSync(routeRoot, {
673
+ throwIfNoEntry: false
674
+ })) === null || _statSync === void 0 ? void 0 : _statSync.isDirectory()) walkRouteRoot(routeRoot);else this.addWatchFile(dirname(routeRoot));
675
+ return entryCode;
676
+ }
539
677
  }
540
678
  };
541
679
  }
@@ -1328,14 +1466,49 @@ class ReactNativeDevRuntime extends BaseDevRuntime {
1328
1466
  }
1329
1467
  }
1330
1468
 
1469
+ reload() {
1470
+ var proxy = globalThis.__turboModuleProxy
1471
+ ? globalThis.__turboModuleProxy('DevSettings')
1472
+ : globalThis.nativeModuleProxy && globalThis.nativeModuleProxy.DevSettings;
1473
+ if (proxy && proxy.reload) proxy.reload();
1474
+ }
1475
+
1331
1476
  setup(socket) {
1332
1477
  if (this._socket) return;
1333
1478
  this._socket = socket;
1479
+ var runtime = this;
1480
+ // addEventListener rather than socket.onmessage: the bundle's WebSocket is
1481
+ // whatever the host platform provides, and a host that does not honor on*
1482
+ // property assignment would otherwise leave the app permanently without
1483
+ // Fast Refresh and say nothing.
1484
+ socket.addEventListener('message', function(event) {
1485
+ var message;
1486
+ try {
1487
+ message = JSON.parse(event.data);
1488
+ } catch (error) {
1489
+ return;
1490
+ }
1491
+ try {
1492
+ if (message.type === 'hmr:update') {
1493
+ // a patch that cannot be applied in place is the reload signal
1494
+ if (!runtime.applyHmrUpdate(message.code, message.changedIds, message.seq)) {
1495
+ runtime.reload();
1496
+ }
1497
+ } else if (message.type === 'hmr:reload') {
1498
+ runtime.reload();
1499
+ }
1500
+ } catch (error) {
1501
+ console.error('[vxrn HMR]: failed to apply update', error);
1502
+ }
1503
+ });
1504
+ socket.addEventListener('error', function(event) {
1505
+ console.warn('[vxrn HMR]: connection error', (event && event.message) || event);
1506
+ });
1334
1507
  }
1335
1508
  }
1336
1509
 
1337
1510
  globalThis.__rolldown_runtime__ = new ReactNativeDevRuntime();
1338
1511
  `;
1339
1512
  }
1340
- export { buildNativeBundle, createNativeDevAssetRegistry, createNativeDevEngine, getHermesSWCIncludes, getHmrRuntimeSource, getNativeAssetData, getNativeTransformConfig, hermesCompatPlugin, hermesCompatSWCPlugin, hermesLoopsPlugin, hmrClientNoopPlugin, nativeAnimatedGuardPlugin, normalizeNativeCommonJSInterop, vxrnCompilerPlugin, wrapNativeBundleModuleScope };
1513
+ export { buildNativeBundle, createNativeDevAssetRegistry, createNativeDevEngine, getHermesSWCIncludes, getHmrRuntimeSource, getNativeAssetData, getNativeTransformConfig, hermesCompatPlugin, hermesCompatSWCPlugin, hermesLoopsPlugin, hmrClientNoopPlugin, nativeAnimatedGuardPlugin, normalizeNativeCommonJSInterop, postProcessNativeBundle, vxrnCompilerPlugin, wrapNativeBundleModuleScope };
1341
1514
  //# sourceMappingURL=createNativeDevEngine.native.js.map