peachsim 0.1.792 → 0.1.794

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 (84) hide show
  1. package/cli/app-config.ts +3 -7
  2. package/cli/commands/compat.ts +0 -6
  3. package/cli/desktop-companion.ts +3 -0
  4. package/cli/ws-bridge.ts +103 -3
  5. package/dist-lib/agent-daemon-client.cjs +2 -2
  6. package/dist-lib/agent-events.cjs +2 -2
  7. package/dist-lib/agent-identity.cjs +2 -2
  8. package/dist-lib/agent-sessions.cjs +2 -2
  9. package/dist-lib/attached-projects.cjs +2 -2
  10. package/dist-lib/auth/shared-session.cjs +2 -2
  11. package/dist-lib/backend-origin.cjs +2 -2
  12. package/dist-lib/beta.cjs +2 -2
  13. package/dist-lib/beta.mjs +1 -1
  14. package/dist-lib/bridge-constants.cjs +2 -2
  15. package/dist-lib/bridge-contract-input.cjs +2 -2
  16. package/dist-lib/bridge-contract-input.mjs +1 -1
  17. package/dist-lib/bridge-contract.cjs +2 -2
  18. package/dist-lib/bridge-contract.mjs +1 -1
  19. package/dist-lib/bundle-channel.cjs +9071 -0
  20. package/dist-lib/capture-contract.cjs +2 -2
  21. package/dist-lib/capture-contract.mjs +1 -1
  22. package/dist-lib/cli-constants.cjs +2 -2
  23. package/dist-lib/cloud-contract.cjs +2 -2
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +2 -2
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +2 -2
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +2 -2
  30. package/dist-lib/detox/index.cjs +5 -3
  31. package/dist-lib/dev-bundle-resolution.cjs +2 -2
  32. package/dist-lib/expo-swift-bundle.cjs +8419 -0
  33. package/dist-lib/expo-swift-metadata.cjs +91 -0
  34. package/dist-lib/expo-swift-metadata.mjs +63 -0
  35. package/dist-lib/home-paths.cjs +2 -2
  36. package/dist-lib/host/bridge-host.cjs +238 -130
  37. package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
  38. package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
  39. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  40. package/dist-lib/host/replacement-module-handler.cjs +2 -2
  41. package/dist-lib/host/websocket-proxy.cjs +2 -2
  42. package/dist-lib/index.cjs +113 -13
  43. package/dist-lib/jump-to-source-babel.cjs +2 -2
  44. package/dist-lib/jump-to-source-native.cjs +2 -2
  45. package/dist-lib/kotlin-host.cjs +2 -2
  46. package/dist-lib/menu.cjs +2 -2
  47. package/dist-lib/menu.mjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.cjs +2 -2
  49. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  50. package/dist-lib/metro-production-bundle.cjs +2 -2
  51. package/dist-lib/metro-production-bundle.mjs +1 -1
  52. package/dist-lib/metro.cjs +110 -12
  53. package/dist-lib/native-app-identity.cjs +2 -2
  54. package/dist-lib/native-app-identity.mjs +1 -1
  55. package/dist-lib/native-firebase-metadata.cjs +2 -2
  56. package/dist-lib/native-firebase-metadata.mjs +1 -1
  57. package/dist-lib/plist.cjs +2 -2
  58. package/dist-lib/plist.mjs +1 -1
  59. package/dist-lib/profiles.cjs +2 -2
  60. package/dist-lib/public-brand.cjs +2 -2
  61. package/dist-lib/react-native-host-modules.cjs +2 -2
  62. package/dist-lib/react-native-host-modules.mjs +1 -1
  63. package/dist-lib/render-mode.cjs +2 -2
  64. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  65. package/dist-lib/sdk.cjs +2 -2
  66. package/dist-lib/sdk.mjs +1 -1
  67. package/dist-lib/skills.cjs +462 -170
  68. package/dist-lib/swift-compile.cjs +105 -5
  69. package/dist-lib/swift-compile.mjs +101 -2
  70. package/dist-lib/swift-package.cjs +2 -2
  71. package/dist-lib/swift-package.mjs +1 -1
  72. package/dist-lib/swift-submit.cjs +2 -2
  73. package/dist-lib/swift-submit.mjs +1 -1
  74. package/dist-lib/swift-toolchain.cjs +2 -2
  75. package/dist-lib/swift.cjs +2 -2
  76. package/dist-lib/vite-swift.cjs +64 -8
  77. package/dist-lib/vite.cjs +2 -2
  78. package/package.json +20 -2
  79. package/src/bundle-channel.mjs +251 -0
  80. package/src/expo-swift-bundle.ts +32 -0
  81. package/src/expo-swift-host.ts +152 -128
  82. package/src/expoSwiftContract.ts +88 -0
  83. package/src/swift-compile.ts +111 -1
  84. package/src/swift-host.ts +4 -1
@@ -1,5 +1,5 @@
1
- /*! rnx v0.1.792 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
1
+ /*! rnx v0.1.794 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
@@ -8791,8 +8791,8 @@ var init_registry = __esm({
8791
8791
  range: ">=0.1.0",
8792
8792
  coverage: 0.92,
8793
8793
  note: "real canvaskit-wasm backing via the engine instance (`globalThis.__sootsimCanvasKit`); declarative <Canvas> snapshots each commit through an offscreen SkSurface and mounts the encoded PNG as a host image. zero second canvaskit bundle.",
8794
- working: "<Canvas> with offscreen SkSurface paint\u2192PNG\u2192host <Image>, <Path>/<Rect>/<RoundedRect>/<Circle>/<Oval>/<Line>/<Fill>/<Image>/<Text>/<Paragraph>/<Picture>/<Group> primitives, shared-value group transforms, rect/rrect group clipping, <LinearGradient>/<RadialGradient>/<SweepGradient>/<ColorShader> paint shaders, <BlurMask>/<Blur>/<Mask>/<Shadow> mask + image filters, <BackdropFilter>/<BackdropBlur>, <DashPathEffect>/<DiscretePathEffect>/<CornerPathEffect>, Skia.Path/Paint/Color/Shader/MaskFilter/ImageFilter/ColorFilter/Font/Typeface/FontMgr/ParagraphBuilder factories, built paragraph layout/paint/metrics, Skia.MakeImageFromEncoded, Skia.XYWHRect/LTRBRect/RRectXY/Point/Matrix, vec/rect and 4x4 scale/translate/multiply helpers, useImage (fetches+decodes through canvaskit), useFont (loads typeface from ArrayBuffer / URL), useFonts (URL, module, and Metro asset-id sources with matchFamilyStyle), useCanvasRef + ref.makeImageSnapshot, useValue/useDerivedValue/useComputedValue/useValueEffect/useClockValue listener model, BlendMode/StrokeCap/StrokeJoin/FillType/PaintStyle/TileMode/BlurStyle/FontWeight/FontStyle/FontSlant/FontWidth/ClipOp/PathVerb/PathOp/TextAlign/TextDirection enums.",
8795
- missing: "<RuntimeShader> SkSL compilation+uniform-binding pipeline, <Points>/<TextPath>/<Glyphs>/<ImageSVG>/<Vertices>/<Patch>/<Atlas>/<FitBox>/<Box>/<BoxShadow> (each logs a one-time hint and renders null), path-shaped group clipping, <Paint> as a declarative component, useTouchHandler full gesture state machine (we forward a minimal touch handler shape; consumers should use Pressable wrappers for hit-testing), reanimated worklet-driven canvas redraws (`useSharedValueEffect` subscribes only to the local SkiaValue listener shape; Canvas display-list encoding and setTick/setDataUrl updates remain owned by React useLayoutEffect, so redraws still reconcile through React), advanced ParagraphBuilder run/style APIs beyond pushStyle/pop/addText/reset and built paragraph layout/paint/metrics, Skia.SVG.MakeFromString (canvaskit-wasm omits svg parsing in the size-tuned builds we ship), GPU SkSurface backing on offscreen paints (we use software MakeSurface so each Canvas paint runs on cpu; deferred until a real engine host element owns its own GrDirectContext for paint-only animation)."
8794
+ working: "<Canvas> with offscreen SkSurface paint\u2192PNG\u2192host <Image>, <Path>/<Rect>/<RoundedRect>/<Circle>/<Oval>/<Line>/<Fill>/<Image>/<Text>/<Paragraph>/<Picture>/<Group> primitives, transform/origin/matrix and rect/rrect/path clip props on groups and drawings, Circle c/cx/cy and rect-prop geometry with shared-value props, <LinearGradient>/<RadialGradient>/<SweepGradient>/<TwoPointConicalGradient> with local transforms, tile modes, flags and sweep angles, <ColorShader> paint shaders, <BlurMask>/<Blur>/<Mask>/<Shadow> mask + image filters, <BackdropFilter>/<BackdropBlur>, <DashPathEffect>/<DiscretePathEffect>/<CornerPathEffect>, Skia.Path/Paint/Color/Shader/MaskFilter/ImageFilter/ColorFilter/Font/Typeface/FontMgr/ParagraphBuilder factories, built paragraph layout/paint/metrics, Skia.MakeImageFromEncoded, Skia.XYWHRect/LTRBRect/RRectXY/Point/Matrix, vec/rect and 4x4 scale/translate/multiply helpers, useImage (fetches+decodes through canvaskit), useFont (loads typeface from ArrayBuffer / URL), useFonts (URL, module, and Metro asset-id sources with matchFamilyStyle), useCanvasRef + ref.makeImageSnapshot, useValue/useDerivedValue/useComputedValue/useValueEffect/useClockValue listener model, BlendMode/StrokeCap/StrokeJoin/FillType/PaintStyle/TileMode/BlurStyle/FontWeight/FontStyle/FontSlant/FontWidth/ClipOp/PathVerb/PathOp/TextAlign/TextDirection enums.",
8795
+ missing: "<RuntimeShader> SkSL compilation+uniform-binding pipeline, <Points>/<TextPath>/<Glyphs>/<ImageSVG>/<Vertices>/<Patch>/<Atlas>/<FitBox>/<Box>/<BoxShadow> (each logs a one-time hint and renders null), <Paint> as a declarative component, useTouchHandler full gesture state machine (we forward a minimal touch handler shape; consumers should use Pressable wrappers for hit-testing), reanimated worklet-driven canvas redraws (`useSharedValueEffect` subscribes only to the local SkiaValue listener shape; Canvas display-list encoding and setTick/setDataUrl updates remain owned by React useLayoutEffect, so redraws still reconcile through React), advanced ParagraphBuilder run/style APIs beyond pushStyle/pop/addText/reset and built paragraph layout/paint/metrics, Skia.SVG.MakeFromString (canvaskit-wasm omits svg parsing in the size-tuned builds we ship), GPU SkSurface backing on offscreen paints (we use software MakeSurface so each Canvas paint runs on cpu; deferred until a real engine host element owns its own GrDirectContext for paint-only animation)."
8796
8796
  }
8797
8797
  ]
8798
8798
  },
@@ -18897,6 +18897,13 @@ function formatDetailedScanLines(result) {
18897
18897
  for (const pkg of actionable) {
18898
18898
  lines.push(`${formatPackageStatus(pkg)}: ${pkg.name}@${pkg.version} \u2014 ${pkg.note}`);
18899
18899
  }
18900
+ const supported = result.packages.filter(
18901
+ (pkg) => pkg.status === "full" && pkg.rnx.coverageSource !== "measured"
18902
+ );
18903
+ if (supported.length > 0) {
18904
+ lines.push("Supported:");
18905
+ for (const pkg of supported) lines.push(` ${pkg.name}@${pkg.version}`);
18906
+ }
18900
18907
  const light = result.packages.filter((pkg) => pkg.status === "light");
18901
18908
  if (light.length > 0) {
18902
18909
  lines.push("Light:");
@@ -18916,6 +18923,11 @@ function formatDetailedScanLines(result) {
18916
18923
  "Peach may still work. The simulator will report a concrete runtime error if it finds a gap."
18917
18924
  );
18918
18925
  }
18926
+ const notRelevant = result.packages.filter((pkg) => pkg.status === "not-relevant");
18927
+ if (notRelevant.length > 0) {
18928
+ lines.push("Not relevant at runtime:");
18929
+ for (const pkg of notRelevant) lines.push(` ${pkg.name}@${pkg.version}`);
18930
+ }
18919
18931
  return lines;
18920
18932
  }
18921
18933
  var COMPAT_RESULT_CAVEAT;
@@ -26550,6 +26562,35 @@ var init_is_record = __esm({
26550
26562
  });
26551
26563
 
26552
26564
  // src/config.ts
26565
+ var config_exports = {};
26566
+ __export(config_exports, {
26567
+ PEACH_CONFIGURED_FILES_HOOK: () => PEACH_CONFIGURED_FILES_HOOK,
26568
+ PEACH_CONFIG_QUERY_PARAM: () => PEACH_CONFIG_QUERY_PARAM,
26569
+ applyPeachConfigToUrl: () => applyPeachConfigToUrl,
26570
+ collectConfiguredFileModules: () => collectConfiguredFileModules,
26571
+ createPeachBundleConfigFooter: () => createPeachBundleConfigFooter,
26572
+ defineConfig: () => defineConfig,
26573
+ detachPeachBundleConfigFooter: () => detachPeachBundleConfigFooter,
26574
+ hasPeachConfig: () => hasPeachConfig,
26575
+ isPeachConfig: () => isPeachConfig,
26576
+ mergePeachConfig: () => mergePeachConfig,
26577
+ readPeachBundleConfig: () => readPeachBundleConfig,
26578
+ readPeachBundleConfigFooter: () => readPeachBundleConfigFooter,
26579
+ readPeachConfigFromSearchParams: () => readPeachConfigFromSearchParams
26580
+ });
26581
+ function collectConfiguredFileModules(config) {
26582
+ return [
26583
+ ...new Set(
26584
+ ["modules", "turboModules", "nativeModules", "nativeViews"].flatMap((key2) => {
26585
+ const entries = config && Reflect.get(config, key2);
26586
+ if (!isRecord(entries)) return [];
26587
+ return Object.values(entries).flatMap(
26588
+ (entry) => isRecord(entry) && typeof entry.file === "string" ? [entry.file] : []
26589
+ );
26590
+ })
26591
+ )
26592
+ ];
26593
+ }
26553
26594
  function isPeachConfig(value) {
26554
26595
  if (!isRecord(value)) return false;
26555
26596
  return (value.runtimeVersion === void 0 || typeof value.runtimeVersion === "string" && value.runtimeVersion === value.runtimeVersion.trim() && isValidRuntimeVersion(value.runtimeVersion)) && [
@@ -26563,6 +26604,42 @@ function isPeachConfig(value) {
26563
26604
  "initialState"
26564
26605
  ].every((key2) => value[key2] === void 0 || isRecord(value[key2]));
26565
26606
  }
26607
+ function readPeachBundleConfig(value) {
26608
+ if (value === void 0 || value === null) return null;
26609
+ if (!isRecord(value) || !isPeachConfig(value.config) || !Array.isArray(value.runtimePackages) || !value.runtimePackages.every((name2) => typeof name2 === "string")) {
26610
+ throw new Error("configured bundle metadata is malformed");
26611
+ }
26612
+ return { config: value.config, runtimePackages: [...value.runtimePackages] };
26613
+ }
26614
+ function readPeachBundleConfigFooter(source) {
26615
+ const start = source.lastIndexOf("\n" + BUNDLE_CONFIG_PREFIX);
26616
+ if (start < 0) return null;
26617
+ const end = source.indexOf("\n", start + 1);
26618
+ const line = source.slice(start + 1, end < 0 ? void 0 : end);
26619
+ if (!line.endsWith(";")) throw new Error("configured bundle footer is truncated");
26620
+ const result = readPeachBundleConfig(
26621
+ JSON.parse(line.slice(BUNDLE_CONFIG_PREFIX.length, -1))
26622
+ );
26623
+ if (!result) throw new Error("configured bundle footer is empty");
26624
+ return result;
26625
+ }
26626
+ function createPeachBundleConfigFooter(config) {
26627
+ const json = JSON.stringify(config).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
26628
+ return "\n" + BUNDLE_CONFIG_PREFIX + json + ";";
26629
+ }
26630
+ function detachPeachBundleConfigFooter(source) {
26631
+ const configuredBundle = readPeachBundleConfigFooter(source);
26632
+ if (!configuredBundle) return { source, configuredBundle };
26633
+ const start = source.lastIndexOf("\n" + BUNDLE_CONFIG_PREFIX);
26634
+ const end = source.indexOf("\n", start + 1);
26635
+ return {
26636
+ source: source.slice(0, start) + source.slice(end < 0 ? source.length : end),
26637
+ configuredBundle
26638
+ };
26639
+ }
26640
+ function defineConfig(config) {
26641
+ return config;
26642
+ }
26566
26643
  function hasOwnKeys(value) {
26567
26644
  return !!value && Object.keys(value).length > 0;
26568
26645
  }
@@ -26594,6 +26671,18 @@ function mergePeachConfig(base, override) {
26594
26671
  initialState: { ...base.initialState || {}, ...override.initialState || {} }
26595
26672
  };
26596
26673
  }
26674
+ function readPeachConfigFromSearchParams(searchParams) {
26675
+ const raw2 = searchParams.get(PEACH_CONFIG_QUERY_PARAM);
26676
+ if (!raw2) return void 0;
26677
+ try {
26678
+ const parsed = JSON.parse(raw2);
26679
+ return hasPeachConfig(parsed) ? parsed : void 0;
26680
+ } catch (error) {
26681
+ const message = error instanceof Error ? error.message : String(error);
26682
+ console.warn(`[peach] invalid ${PEACH_CONFIG_QUERY_PARAM}: ${message}`);
26683
+ return void 0;
26684
+ }
26685
+ }
26597
26686
  function applyPeachConfigToUrl(url, config) {
26598
26687
  const parsed = new URL(url);
26599
26688
  if (hasPeachConfig(config)) {
@@ -26603,13 +26692,15 @@ function applyPeachConfigToUrl(url, config) {
26603
26692
  }
26604
26693
  return parsed.toString();
26605
26694
  }
26606
- var PEACH_CONFIG_QUERY_PARAM;
26695
+ var PEACH_CONFIG_QUERY_PARAM, BUNDLE_CONFIG_PREFIX, PEACH_CONFIGURED_FILES_HOOK;
26607
26696
  var init_config = __esm({
26608
26697
  "src/config.ts"() {
26609
26698
  "use strict";
26610
26699
  init_version();
26611
26700
  init_is_record();
26612
26701
  PEACH_CONFIG_QUERY_PARAM = "peachConfig";
26702
+ BUNDLE_CONFIG_PREFIX = "globalThis.__peachBundleConfig=";
26703
+ PEACH_CONFIGURED_FILES_HOOK = "__peachInstallConfiguredFiles";
26613
26704
  }
26614
26705
  });
26615
26706
 
@@ -29772,6 +29863,57 @@ function lowerNSValueTimeBox(source) {
29772
29863
  out = out.slice(0, at) + insert + out.slice(at + remove);
29773
29864
  return out;
29774
29865
  }
29866
+ function lowerNotificationDelegate(source) {
29867
+ const code = swiftCodeMask(source);
29868
+ const selectors = {
29869
+ willPresent: "userNotificationCenter:willPresentNotification:withCompletionHandler:",
29870
+ didReceive: "userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:",
29871
+ openSettingsFor: "userNotificationCenter:openSettingsForNotification:"
29872
+ };
29873
+ const edits = [];
29874
+ const selector = /#(?:selector|Selector)\(\s*UNUserNotificationCenterDelegate\.userNotificationCenter\(\s*_\s*:\s*(willPresent|didReceive|openSettingsFor)\s*:[^)]*\)\s*\)/g;
29875
+ for (const match of code.matchAll(selector)) {
29876
+ edits.push([
29877
+ match.index,
29878
+ match[0].length,
29879
+ `NSSelectorFromString(${JSON.stringify(selectors[match[1]])})`
29880
+ ]);
29881
+ }
29882
+ const receivers = /* @__PURE__ */ new Set();
29883
+ for (const match of code.matchAll(
29884
+ /\b(?:var|let)\s+(\w+)\s*:\s*(?:any\s+)?UNUserNotificationCenterDelegate\??/g
29885
+ ))
29886
+ receivers.add(match[1]);
29887
+ for (const match of code.matchAll(/\blet\s+(\w+)\s*=\s*(?:self\.)?(\w+)\b/g)) {
29888
+ if (receivers.has(match[2])) receivers.add(match[1]);
29889
+ }
29890
+ for (const match of code.matchAll(
29891
+ /\b(\w+)(?:[?!])?\.userNotificationCenter\s*\?(?=\s*\()/g
29892
+ )) {
29893
+ if (receivers.has(match[1]))
29894
+ edits.push([match.index + match[0].lastIndexOf("?"), 1, " "]);
29895
+ }
29896
+ const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
29897
+ for (const owner of code.matchAll(
29898
+ /\b(?:class|extension)\s+[A-Za-z_]\w*[^{}]*\bUNUserNotificationCenterDelegate\b[^{}]*\{/g
29899
+ )) {
29900
+ const open = owner.index + owner[0].length - 1;
29901
+ const close = closingBrace(code, braces, open);
29902
+ const body = code.slice(open + 1, close - 1);
29903
+ for (const method of body.matchAll(/\bfunc\s+userNotificationCenter\s*\(/g)) {
29904
+ const at = open + 1 + method.index;
29905
+ const signature2 = code.slice(at, code.indexOf("{", at));
29906
+ const label = Object.keys(selectors).find(
29907
+ (name2) => new RegExp(`\\b${name2}\\b`).test(signature2)
29908
+ );
29909
+ if (label) edits.push([at, 0, `@ObjC(${JSON.stringify(selectors[label])}) `]);
29910
+ }
29911
+ }
29912
+ let result = source;
29913
+ for (const [at, count, text3] of edits.sort((a, b) => b[0] - a[0]))
29914
+ result = result.slice(0, at) + text3 + result.slice(at + count);
29915
+ return result;
29916
+ }
29775
29917
  function swiftCodeMask(source) {
29776
29918
  const chars = source.split("");
29777
29919
  const blank = (from, to) => {
@@ -29876,7 +30018,10 @@ function swiftCodeMask(source) {
29876
30018
  return chars.join("");
29877
30019
  }
29878
30020
  function swiftSourceAsIOS(original, extraObjCExtensions) {
29879
- const source = liftExtensionOverrides(original, extraObjCExtensions);
30021
+ const source = liftExtensionOverrides(
30022
+ lowerNotificationDelegate(original),
30023
+ extraObjCExtensions
30024
+ );
29880
30025
  const { lineStarts, tokens } = swiftCodeScan(source);
29881
30026
  let offset = 0;
29882
30027
  const conditioned = source.split("\n").map((line) => {
@@ -29979,6 +30124,49 @@ function swiftSourceAsIOS(original, extraObjCExtensions) {
29979
30124
  lowerAVAssetURLCluster(lowerAnyObjectDoubleValue(out + conditioned.slice(copied)))
29980
30125
  );
29981
30126
  }
30127
+ function swiftSourceClosure(files2, roots) {
30128
+ const sources = /* @__PURE__ */ new Map();
30129
+ const owners = /* @__PURE__ */ new Map();
30130
+ const extensions = /* @__PURE__ */ new Map();
30131
+ for (const [file, source] of Object.entries(files2)) {
30132
+ if (!file.endsWith(".swift")) continue;
30133
+ const code = swiftCodeMask(source);
30134
+ const references = new Set(code.match(/[A-Za-z_]\w*/g) ?? []);
30135
+ const pattern = /[{}]|\b(class|struct|enum|protocol|actor|typealias|func|var|let|extension)\s+([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)/g;
30136
+ let depth = 0;
30137
+ for (const match of code.matchAll(pattern)) {
30138
+ if (match[0] === "{") {
30139
+ depth++;
30140
+ continue;
30141
+ }
30142
+ if (match[0] === "}") {
30143
+ depth--;
30144
+ continue;
30145
+ }
30146
+ if (depth !== 0 || !match[2]) continue;
30147
+ const name2 = match[2].split(".").pop();
30148
+ const index = match[1] === "extension" ? extensions : owners;
30149
+ const set2 = index.get(name2) ?? /* @__PURE__ */ new Set();
30150
+ set2.add(file);
30151
+ index.set(name2, set2);
30152
+ }
30153
+ sources.set(file, references);
30154
+ }
30155
+ const included = /* @__PURE__ */ new Set();
30156
+ const pending = [...roots];
30157
+ const seen = /* @__PURE__ */ new Set();
30158
+ while (pending.length) {
30159
+ const name2 = pending.pop();
30160
+ if (seen.has(name2)) continue;
30161
+ seen.add(name2);
30162
+ for (const file of [...owners.get(name2) ?? [], ...extensions.get(name2) ?? []]) {
30163
+ if (included.has(file)) continue;
30164
+ included.add(file);
30165
+ for (const reference of sources.get(file)) pending.push(reference);
30166
+ }
30167
+ }
30168
+ return Object.fromEntries(Object.entries(files2).filter(([file]) => included.has(file)));
30169
+ }
29982
30170
  function swiftCodeScan(source) {
29983
30171
  const starts = /* @__PURE__ */ new Set();
29984
30172
  const tokens = [];
@@ -30251,7 +30439,7 @@ function compileSwiftProjectUnit(input, options) {
30251
30439
  };
30252
30440
  const hash = swiftArtifactHash(input, options.release, moduleRoot);
30253
30441
  return serialize(root, async () => {
30254
- if (process.platform === "darwin" && process.env.TM_SESSION && process.env.CI !== "true" && process.env.CONTRAST_HEAVY_ADMITTED !== "1" && moduleRoot === import_node_path7.default.resolve(import_meta2.dirname, "../../sootsim-swift") && !swiftDistributionAt(moduleRoot)) {
30442
+ if (process.platform === "darwin" && process.env.TM_SESSION && process.env.CI !== "true" && process.env.CONTRAST_HEAVY_ADMITTED !== "1" && moduleRoot === import_node_path7.default.resolve(__sootsim_import_meta_dirname, "../../sootsim-swift") && !swiftDistributionAt(moduleRoot)) {
30255
30443
  const requestRoot = (0, import_node_fs7.mkdtempSync)(import_node_path7.default.join(root, ".builder-request-"));
30256
30444
  const output = import_node_path7.default.join(requestRoot, "output");
30257
30445
  const request = import_node_path7.default.join(requestRoot, "request.json");
@@ -30351,7 +30539,7 @@ function compileSwiftProjectUnit(input, options) {
30351
30539
  };
30352
30540
  });
30353
30541
  }
30354
- var import_node_child_process4, import_node_crypto3, import_node_fs7, import_node_os2, import_node_path7, import_node_util2, import_meta2, run2, WASM_TRIPLE, cores, BUILD_ENV, BUILD_JOBS, linkedModuleDigests, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, sdkPaths, availableModules, ONE_PRODUCT, SPRITEKIT_PRODUCT, importsSpriteKit, FOUNDATION_IMPLICIT_FLAGS, ONE_IMPLICIT_FLAGS, MULTI_MANIFEST_VERSION, DIRECTIVE, OS_IOS, OBJC_ATTRIBUTE, SELECTOR, TYPE_AFTER_ATTRIBUTE, DELEGATE_CLASS, REUSABLE_INIT, REUSABLE_VIEW_BASES, CLASS_BASE, FRAME_INIT, APPLE_CLASS, EXTENSION_DECL, CLASS_DECL, MODIFIERS, OVERRIDE_FUNC, OVERRIDE_VAR, compiledSource, ROOT_LOCKS, host, rootLocks;
30542
+ var import_node_child_process4, import_node_crypto3, import_node_fs7, import_node_os2, import_node_path7, import_node_util2, run2, WASM_TRIPLE, cores, BUILD_ENV, BUILD_JOBS, linkedModuleDigests, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, sdkPaths, availableModules, ONE_PRODUCT, SPRITEKIT_PRODUCT, importsSpriteKit, FOUNDATION_IMPLICIT_FLAGS, ONE_IMPLICIT_FLAGS, MULTI_MANIFEST_VERSION, DIRECTIVE, OS_IOS, OBJC_ATTRIBUTE, SELECTOR, TYPE_AFTER_ATTRIBUTE, DELEGATE_CLASS, REUSABLE_INIT, REUSABLE_VIEW_BASES, CLASS_BASE, FRAME_INIT, APPLE_CLASS, EXTENSION_DECL, CLASS_DECL, MODIFIERS, OVERRIDE_FUNC, OVERRIDE_VAR, compiledSource, ROOT_LOCKS, host, rootLocks;
30355
30543
  var init_swift_compile = __esm({
30356
30544
  "src/swift-compile.ts"() {
30357
30545
  "use strict";
@@ -30364,7 +30552,6 @@ var init_swift_compile = __esm({
30364
30552
  init_swift_distribution_contract();
30365
30553
  init_swift_icu();
30366
30554
  init_swift_package();
30367
- import_meta2 = {};
30368
30555
  run2 = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
30369
30556
  WASM_TRIPLE = "wasm32-unknown-wasip1";
30370
30557
  cores = import_node_os2.default.availableParallelism();
@@ -31060,7 +31247,7 @@ function swiftDistributionRoot() {
31060
31247
  return pending;
31061
31248
  }
31062
31249
  async function resolveSwiftModule() {
31063
- const checkout2 = import_node_path11.default.resolve(import_meta3.dirname, "../../sootsim-swift");
31250
+ const checkout2 = import_node_path11.default.resolve(__sootsim_import_meta_dirname, "../../sootsim-swift");
31064
31251
  if (import_node_fs11.default.existsSync(import_node_path11.default.join(checkout2, "toolchain.json"))) {
31065
31252
  try {
31066
31253
  return { root: checkout2, ...swiftModuleToolchain(checkout2) };
@@ -31078,7 +31265,7 @@ function swiftModuleToolchain(root) {
31078
31265
  toolchainBin: swiftToolchain(pin.release, swiftModuleSdk(root))
31079
31266
  };
31080
31267
  }
31081
- var import_node_fs11, import_node_path11, import_meta3, SWIFT_ENDPOINT_ENV, installs;
31268
+ var import_node_fs11, import_node_path11, SWIFT_ENDPOINT_ENV, installs;
31082
31269
  var init_swift_distribution = __esm({
31083
31270
  "src/swift-distribution.ts"() {
31084
31271
  "use strict";
@@ -31090,7 +31277,6 @@ var init_swift_distribution = __esm({
31090
31277
  init_swift_distribution_contract();
31091
31278
  init_swift_distribution_lock();
31092
31279
  init_swift_toolchain();
31093
- import_meta3 = {};
31094
31280
  SWIFT_ENDPOINT_ENV = "PEACH_SWIFT_ENDPOINT";
31095
31281
  installs = /* @__PURE__ */ new Map();
31096
31282
  }
@@ -36580,7 +36766,8 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
36580
36766
  ...targets.length > 0 ? targets : ["App"]
36581
36767
  ])
36582
36768
  );
36583
- if (missing.size > 0) throw new Error(await missingModulesMessage(packagePath, missing));
36769
+ if (missing.size > 0)
36770
+ throw new SwiftMissingModulesError(await missingModulesMessage(packagePath, missing));
36584
36771
  const artifact = await compileSwiftProjectUnit(input, {
36585
36772
  // the compile rewrites Sources/App in its root before swiftpm builds, and
36586
36773
  // its lock orders one process only: two vites on one root (a lane's dev
@@ -36846,7 +37033,7 @@ function serveSwiftPackageAsset(pathname, res) {
36846
37033
  res.end("swift artifact is stale");
36847
37034
  return true;
36848
37035
  }
36849
- var import_node_crypto8, import_node_fs18, import_node_os8, import_node_path19, ARTIFACT_PATH, RESOURCE_PATH, ICU_PATH, SKIP_SOURCE_DIRS, NATIVE_DESCRIPTOR, NATIVE_GLUE, projects, xcodeProjects, XCODE_APP_DIR, XCODE_FRAMEWORKS_DIR, XCODE_PACKAGES_DIR, XCODE_STANDINS_DIR, CHECKOUTS_PREFIX, HOSTED_LIMITS, LOCAL_LIMITS, inputLimits, RESOURCE_CONTENT_TYPES, API_GAP_PATTERNS, UNPROVIDED_PLATFORM_MODULES, IOS_SDK_FRAMEWORKS;
37036
+ var import_node_crypto8, import_node_fs18, import_node_os8, import_node_path19, ARTIFACT_PATH, RESOURCE_PATH, ICU_PATH, SKIP_SOURCE_DIRS, NATIVE_DESCRIPTOR, NATIVE_GLUE, SwiftMissingModulesError, projects, xcodeProjects, XCODE_APP_DIR, XCODE_FRAMEWORKS_DIR, XCODE_PACKAGES_DIR, XCODE_STANDINS_DIR, CHECKOUTS_PREFIX, HOSTED_LIMITS, LOCAL_LIMITS, inputLimits, RESOURCE_CONTENT_TYPES, API_GAP_PATTERNS, UNPROVIDED_PLATFORM_MODULES, IOS_SDK_FRAMEWORKS;
36850
37037
  var init_swift_host = __esm({
36851
37038
  "src/swift-host.ts"() {
36852
37039
  "use strict";
@@ -36879,6 +37066,8 @@ var init_swift_host = __esm({
36879
37066
  ]);
36880
37067
  NATIVE_DESCRIPTOR = ".one-native-source.json";
36881
37068
  NATIVE_GLUE = ".one-native-source.swift.txt";
37069
+ SwiftMissingModulesError = class extends Error {
37070
+ };
36882
37071
  projects = /* @__PURE__ */ new Map();
36883
37072
  xcodeProjects = /* @__PURE__ */ new Map();
36884
37073
  XCODE_APP_DIR = "__app__";
@@ -37006,9 +37195,10 @@ async function collectExpoSwiftSources(appRoot) {
37006
37195
  const name2 = module2 && typeof module2 === "object" ? Reflect.get(module2, "name") : null;
37007
37196
  if (typeof className !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(className) || name2 !== null && typeof name2 !== "string")
37008
37197
  throw new Error(`${sourceRoot}: invalid Expo Apple module descriptor`);
37009
- classes.push(
37010
- `(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
37011
- );
37198
+ classes.push({
37199
+ name: className.split(".").pop(),
37200
+ registration: `(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
37201
+ });
37012
37202
  }
37013
37203
  const ios = import_node_path20.default.join(canonical, "ios");
37014
37204
  if (import_node_fs19.default.lstatSync(ios).isSymbolicLink())
@@ -37033,21 +37223,33 @@ ${import_node_fs19.default.readFileSync(file, "utf8")}`;
37033
37223
  }
37034
37224
  };
37035
37225
  walk2(ios);
37036
- const unit = { namespace, classes, files: files2 };
37037
- files2[EXPO_SWIFT_ENTRY] = expoEntry([unit]);
37038
- units.push(unit);
37226
+ for (const module2 of classes) {
37227
+ const unit = {
37228
+ namespace,
37229
+ moduleId: `${namespace}.${module2.name}`,
37230
+ classes: [module2.registration],
37231
+ files: swiftSourceClosure(files2, [module2.name])
37232
+ };
37233
+ unit.files[EXPO_SWIFT_ENTRY] = expoEntry([unit]);
37234
+ units.push(unit);
37235
+ }
37039
37236
  }
37040
37237
  if (units.length === 0) return null;
37041
37238
  const allFiles = Object.assign(
37042
37239
  {},
37043
37240
  ...units.map((unit) => unit.files)
37044
37241
  );
37045
- const targets = units.map((unit) => ({
37046
- name: unit.namespace,
37047
- path: `Sources/${unit.namespace}`
37242
+ const targets = [...new Set(units.map((unit) => unit.namespace))].map((namespace) => ({
37243
+ name: namespace,
37244
+ path: `Sources/${namespace}`
37048
37245
  }));
37049
37246
  const dependencies = swiftTargetDependencies(allFiles, targets);
37050
- const byNamespace = new Map(units.map((unit) => [unit.namespace, unit]));
37247
+ const byNamespace = /* @__PURE__ */ new Map();
37248
+ for (const unit of units) {
37249
+ const entries = byNamespace.get(unit.namespace) ?? [];
37250
+ entries.push(unit);
37251
+ byNamespace.set(unit.namespace, entries);
37252
+ }
37051
37253
  for (const unit of units) {
37052
37254
  const included = /* @__PURE__ */ new Set([unit.namespace]);
37053
37255
  const visit3 = (namespace) => {
@@ -37076,7 +37278,7 @@ let package = Package(name: "PeachExpo", targets: [${[...included].map((name2) =
37076
37278
  function expoEntry(units) {
37077
37279
  return `import SwiftUI
37078
37280
  import ExpoModulesCore
37079
- ${units.map((unit) => `import ${unit.namespace}`).join("\n")}
37281
+ ${[...new Set(units.map((unit) => unit.namespace))].map((namespace) => `import ${namespace}`).join("\n")}
37080
37282
 
37081
37283
  @main struct PeachExpoApp: RNXPackage {
37082
37284
  init() { MainActor.assumeIsolated { PeachExpoRuntime.register([${units.flatMap((unit) => unit.classes).join(", ")}]) } }
@@ -37090,6 +37292,112 @@ ${units.map((unit) => `import ${unit.namespace}`).join("\n")}
37090
37292
  }
37091
37293
  `;
37092
37294
  }
37295
+ async function compileExpoSwiftModules(root, base, publishArtifact) {
37296
+ const units = await collectExpoSwiftSources(root);
37297
+ if (!units) return null;
37298
+ const module2 = await resolveSwiftModule();
37299
+ if (!module2 && publishArtifact)
37300
+ throw new Error("No local Swift toolchain or distribution is available");
37301
+ const result = {
37302
+ namespaces: units.map((unit) => unit.moduleId),
37303
+ modules: [],
37304
+ failures: []
37305
+ };
37306
+ const key2 = (0, import_node_crypto9.createHash)("sha256").update(import_node_fs19.default.realpathSync(root)).digest("hex");
37307
+ const linked = [];
37308
+ for (const unit of units) {
37309
+ if (!module2) {
37310
+ result.failures.push({
37311
+ namespace: unit.moduleId,
37312
+ diagnostic: "No local Swift toolchain or distribution is available"
37313
+ });
37314
+ continue;
37315
+ }
37316
+ try {
37317
+ const packagePath = import_node_path20.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, unit.moduleId);
37318
+ syncSwiftTree(
37319
+ packagePath,
37320
+ new Map(
37321
+ Object.entries(unit.files).map(([name2, source]) => [
37322
+ import_node_path20.default.join(packagePath, name2),
37323
+ source
37324
+ ])
37325
+ )
37326
+ );
37327
+ const stamp = sourceStamp(packagePath, module2.root);
37328
+ const failed = failedCompilations.get(packagePath);
37329
+ if (failed?.stamp === stamp) {
37330
+ result.failures.push({
37331
+ namespace: unit.moduleId,
37332
+ diagnostic: failed.diagnostic
37333
+ });
37334
+ continue;
37335
+ }
37336
+ failedCompilations.delete(packagePath);
37337
+ await artifactFor(projectFor(packagePath), EXPO_SWIFT_ENTRY, module2.root).catch(
37338
+ (error) => {
37339
+ const diagnostic = error instanceof Error ? error.message : String(error);
37340
+ if (/^.+:\d+(?::\d+)?: error:/m.test(diagnostic) && sourceStamp(packagePath, module2.root) === stamp)
37341
+ failedCompilations.set(packagePath, { stamp, diagnostic });
37342
+ throw error;
37343
+ }
37344
+ );
37345
+ linked.push(unit);
37346
+ } catch (error) {
37347
+ const diagnostic = error instanceof Error ? error.message : String(error);
37348
+ const sourceErrors = diagnostic.match(/^.+:\d+(?::\d+)?: error:.*$/gm);
37349
+ if (publishArtifact && !sourceErrors && !(error instanceof SwiftMissingModulesError))
37350
+ throw error;
37351
+ result.failures.push({
37352
+ namespace: unit.moduleId,
37353
+ diagnostic: sourceErrors ? sourceErrors.join("\n") : diagnostic
37354
+ });
37355
+ }
37356
+ }
37357
+ if (module2 && linked.length) {
37358
+ const files2 = Object.assign(
37359
+ {},
37360
+ ...linked.map((unit) => unit.files)
37361
+ );
37362
+ files2[EXPO_SWIFT_ENTRY] = expoEntry(linked);
37363
+ const targets = [
37364
+ ...new Set(
37365
+ Object.keys(files2).flatMap((name2) => {
37366
+ const match = /^Sources\/([^/]+)\//.exec(name2);
37367
+ return match && match[1] !== "PeachExpoApp" ? [match[1]] : [];
37368
+ })
37369
+ )
37370
+ ];
37371
+ files2["Package.swift"] = `// swift-tools-version: 6.0
37372
+ import PackageDescription
37373
+ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.target(name: ${JSON.stringify(name2)}, path: ${JSON.stringify(`Sources/${name2}`)})`).join(", ")}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])
37374
+ `;
37375
+ const packagePath = import_node_path20.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, "linked-app");
37376
+ syncSwiftTree(
37377
+ packagePath,
37378
+ new Map(
37379
+ Object.entries(files2).map(([name2, source]) => [
37380
+ import_node_path20.default.join(packagePath, name2),
37381
+ source
37382
+ ])
37383
+ )
37384
+ );
37385
+ const artifact = await artifactFor(
37386
+ projectFor(packagePath),
37387
+ EXPO_SWIFT_ENTRY,
37388
+ module2.root
37389
+ );
37390
+ await publishArtifact?.(artifact);
37391
+ result.modules.push({
37392
+ namespaces: linked.map((unit) => unit.moduleId),
37393
+ url: `${base}/__peach/swift/${artifact.hash}.wasm`,
37394
+ hash: artifact.hash,
37395
+ icuUrl: icuUrl(base, artifact),
37396
+ rootId: `${key2}/Expo`
37397
+ });
37398
+ }
37399
+ return result;
37400
+ }
37093
37401
  async function handleExpoSwiftRequest(req, res) {
37094
37402
  const url = new URL(req.url ?? "/", "http://localhost");
37095
37403
  if (!url.pathname.startsWith("/__peach/swift") && url.pathname !== EXPO_SWIFT_ROUTE)
@@ -37121,118 +37429,9 @@ async function handleExpoSwiftRequest(req, res) {
37121
37429
  let pending = compiling.get(root);
37122
37430
  if (!pending) {
37123
37431
  pending = (async () => {
37124
- const units = await collectExpoSwiftSources(root);
37125
- if (!units) return null;
37126
- const module2 = await resolveSwiftModule();
37127
- const result = {
37128
- namespaces: units.map((unit) => unit.namespace),
37129
- modules: [],
37130
- failures: []
37131
- };
37132
- const key2 = (0, import_node_crypto9.createHash)("sha256").update(import_node_fs19.default.realpathSync(root)).digest("hex");
37133
37432
  const host2 = req.headers.host;
37134
37433
  if (!host2) throw new Error("Expo Swift request has no host");
37135
- const base = `http://${host2}`;
37136
- const linked = [];
37137
- for (const unit of units) {
37138
- if (!module2) {
37139
- result.failures.push({
37140
- namespace: unit.namespace,
37141
- diagnostic: "No local Swift toolchain or distribution is available"
37142
- });
37143
- continue;
37144
- }
37145
- try {
37146
- const packagePath = import_node_path20.default.join(
37147
- import_node_os9.default.tmpdir(),
37148
- "peach-expo-swift",
37149
- key2,
37150
- unit.namespace
37151
- );
37152
- syncSwiftTree(
37153
- packagePath,
37154
- new Map(
37155
- Object.entries(unit.files).map(([name2, source]) => [
37156
- import_node_path20.default.join(packagePath, name2),
37157
- source
37158
- ])
37159
- )
37160
- );
37161
- const stamp = sourceStamp(packagePath, module2.root);
37162
- const failed = failedCompilations.get(packagePath);
37163
- if (failed?.stamp === stamp) {
37164
- result.failures.push({
37165
- namespace: unit.namespace,
37166
- diagnostic: failed.diagnostic
37167
- });
37168
- continue;
37169
- }
37170
- failedCompilations.delete(packagePath);
37171
- await artifactFor(
37172
- projectFor(packagePath),
37173
- EXPO_SWIFT_ENTRY,
37174
- module2.root
37175
- ).catch((error) => {
37176
- const diagnostic = error instanceof Error ? error.message : String(error);
37177
- if (/^.+:\d+(?::\d+)?: error:/m.test(diagnostic) && sourceStamp(packagePath, module2.root) === stamp)
37178
- failedCompilations.set(packagePath, { stamp, diagnostic });
37179
- throw error;
37180
- });
37181
- linked.push(unit);
37182
- } catch (error) {
37183
- result.failures.push({
37184
- namespace: unit.namespace,
37185
- diagnostic: error instanceof Error ? error.message : String(error)
37186
- });
37187
- }
37188
- }
37189
- if (module2 && linked.length) {
37190
- const files2 = Object.assign(
37191
- {},
37192
- ...linked.map((unit) => unit.files)
37193
- );
37194
- files2[EXPO_SWIFT_ENTRY] = expoEntry(linked);
37195
- const targets = [
37196
- ...new Set(
37197
- Object.keys(files2).flatMap((name2) => {
37198
- const match = /^Sources\/([^/]+)\//.exec(name2);
37199
- return match && match[1] !== "PeachExpoApp" ? [match[1]] : [];
37200
- })
37201
- )
37202
- ];
37203
- files2["Package.swift"] = `// swift-tools-version: 6.0
37204
- import PackageDescription
37205
- let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.target(name: ${JSON.stringify(name2)}, path: ${JSON.stringify(`Sources/${name2}`)})`).join(", ")}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])
37206
- `;
37207
- const packagePath = import_node_path20.default.join(
37208
- import_node_os9.default.tmpdir(),
37209
- "peach-expo-swift",
37210
- key2,
37211
- "linked-app"
37212
- );
37213
- syncSwiftTree(
37214
- packagePath,
37215
- new Map(
37216
- Object.entries(files2).map(([name2, source]) => [
37217
- import_node_path20.default.join(packagePath, name2),
37218
- source
37219
- ])
37220
- )
37221
- );
37222
- const artifact = await artifactFor(
37223
- projectFor(packagePath),
37224
- EXPO_SWIFT_ENTRY,
37225
- module2.root
37226
- );
37227
- result.modules.push({
37228
- namespaces: linked.map((unit) => unit.namespace),
37229
- url: `${base}/__peach/swift/${artifact.hash}.wasm`,
37230
- hash: artifact.hash,
37231
- icuUrl: icuUrl(base, artifact),
37232
- rootId: `${key2}/Expo`
37233
- });
37234
- }
37235
- return result;
37434
+ return compileExpoSwiftModules(root, `http://${host2}`);
37236
37435
  })();
37237
37436
  compiling.set(root, pending);
37238
37437
  }
@@ -42917,7 +43116,7 @@ async function loadMetroFingerprintRegistry(options = {}) {
42917
43116
  }
42918
43117
  try {
42919
43118
  const payloadUrl = new URL(pointer.payloadUrl, baseUrl).toString();
42920
- const response = await request(payloadUrl, { cache: "force-cache" });
43119
+ const response = await request(payloadUrl);
42921
43120
  if (!response.ok) {
42922
43121
  throw new Error(`RNX Metro fingerprint registry answered ${response.status}`);
42923
43122
  }
@@ -47600,7 +47799,9 @@ function createBridge(wsPort, opts = {}) {
47600
47799
  let nextId = 1;
47601
47800
  const commandTimeoutMs = opts.commandTimeoutMs ?? 15e3;
47602
47801
  const pending = /* @__PURE__ */ new Map();
47603
- const ws = new import_ws2.WebSocket(bridgeWsUrl(wsPort));
47802
+ const ws = new import_ws2.WebSocket(bridgeWsUrl(wsPort), {
47803
+ handshakeTimeout: opts.connectTimeoutMs
47804
+ });
47604
47805
  const identity = getCliIdentity();
47605
47806
  const ready = new Promise((resolve10, reject) => {
47606
47807
  ws.on("open", () => {
@@ -47835,11 +48036,104 @@ function createBridge(wsPort, opts = {}) {
47835
48036
  function createBridgeFromParsed(parsed) {
47836
48037
  const cloudBridge = createCloudBridgeForParsed(parsed);
47837
48038
  if (cloudBridge) return cloudBridge;
47838
- return createBridge(parsed.wsPort, {
48039
+ const options = {
47839
48040
  commandTimeoutMs: parsed.commandTimeoutMs,
47840
48041
  simId: parsed.simId,
47841
48042
  simIdSource: parsed.simIdSource
47842
- });
48043
+ };
48044
+ if (!parsed.simId || parsed.simIdSource !== "flag") {
48045
+ return createBridge(parsed.wsPort, options);
48046
+ }
48047
+ let selected;
48048
+ let closed = false;
48049
+ const getBridge = () => {
48050
+ selected ??= resolveBridgePortForSim(parsed).then((port) => {
48051
+ if (closed) throw new Error("bridge closed during sim world resolution");
48052
+ parsed.wsPort = port;
48053
+ printBridgeWorldNotice(port);
48054
+ return createBridge(port, options);
48055
+ });
48056
+ return selected;
48057
+ };
48058
+ return {
48059
+ plane: "local",
48060
+ async send(cmd, opts) {
48061
+ return (await getBridge()).send(cmd, opts);
48062
+ },
48063
+ async listSims() {
48064
+ return (await getBridge()).listSims();
48065
+ },
48066
+ async resolveReloadedSim(id) {
48067
+ return (await getBridge()).resolveReloadedSim(id);
48068
+ },
48069
+ async focusSim(id) {
48070
+ return (await getBridge()).focusSim(id);
48071
+ },
48072
+ async closeSim(id) {
48073
+ return (await getBridge()).closeSim(id);
48074
+ },
48075
+ async claim(id, opts) {
48076
+ return (await getBridge()).claim(id, opts);
48077
+ },
48078
+ close() {
48079
+ closed = true;
48080
+ void selected?.then(
48081
+ (bridge) => bridge.close(),
48082
+ () => {
48083
+ }
48084
+ );
48085
+ }
48086
+ };
48087
+ }
48088
+ async function resolveBridgePortForSim(parsed) {
48089
+ const worlds = liveDevBridgeLockfiles().map((lock) => ({
48090
+ port: lock.bridgePort,
48091
+ record: `dev-bridges/${lock.bridgePort}.json`
48092
+ }));
48093
+ const daemon = readDaemonLockfile();
48094
+ if (daemon && isDaemonLockfileFresh(daemon)) {
48095
+ worlds.push({ port: daemon.bridgePort, record: "daemon.json" });
48096
+ }
48097
+ const checked = await Promise.all(
48098
+ worlds.map(async (world) => {
48099
+ const probe2 = createBridge(world.port, {
48100
+ connectTimeoutMs: 2e3,
48101
+ commandTimeoutMs: 2e3
48102
+ });
48103
+ try {
48104
+ const sims = await probe2.listSims();
48105
+ return {
48106
+ ...world,
48107
+ ownsSim: sims.some(
48108
+ (sim) => sim.id === parsed.simId && sim.readyState === "open"
48109
+ )
48110
+ };
48111
+ } catch (error) {
48112
+ return {
48113
+ ...world,
48114
+ ownsSim: false,
48115
+ error: error instanceof Error ? error.message : String(error)
48116
+ };
48117
+ } finally {
48118
+ probe2.close();
48119
+ }
48120
+ })
48121
+ );
48122
+ const owner = checked.find((world) => world.ownsSim);
48123
+ if (!owner) {
48124
+ const names = checked.map(
48125
+ (world) => `${world.record} (bridge :${world.port}${"error" in world ? `, ${world.error}` : ""})`
48126
+ );
48127
+ throw new Error(
48128
+ `no live peach world holds sim ${parsed.simId}; worlds checked: ${names.join(", ") || "none (no fresh dev-bridge or daemon lockfiles)"}`
48129
+ );
48130
+ }
48131
+ if (parsed.explicitPort && parsed.wsPort !== owner.port) {
48132
+ throw new Error(
48133
+ `--sim ${parsed.simId} belongs to bridge port ${owner.port}, but --port ${parsed.wsPort} names another world`
48134
+ );
48135
+ }
48136
+ return owner.port;
47843
48137
  }
47844
48138
  function describeVisibleSimCandidate(sims, currentId) {
47845
48139
  const open = sims.filter((sim) => sim.readyState === "open" && sim.id !== currentId);
@@ -48340,8 +48634,8 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
48340
48634
  "app.config.mjs"
48341
48635
  ].some((name2) => import_node_fs32.default.existsSync(import_node_path33.default.join(projectRoot, name2)));
48342
48636
  if (staticExpo || dynamicExpo) {
48343
- const require5 = (0, import_node_module2.createRequire)(import_node_path33.default.join(projectRoot, "package.json"));
48344
- const configModule = require5("@expo/config");
48637
+ const require4 = (0, import_node_module2.createRequire)(import_node_path33.default.join(projectRoot, "package.json"));
48638
+ const configModule = require4("@expo/config");
48345
48639
  if (!isRecord(configModule) || typeof configModule.getConfig !== "function")
48346
48640
  throw new Error("Expo native configuration is unavailable.");
48347
48641
  const resolved = Reflect.apply(configModule.getConfig, configModule, [
@@ -48729,10 +49023,8 @@ async function loadRNXAppConfig(project) {
48729
49023
  // metro serializes repeatedly in one process; edits must reload the config.
48730
49024
  moduleCache: false,
48731
49025
  tryNative: false,
48732
- alias: {
48733
- [`${rnxPublicBrand.packageName}/config`]: require2.resolve(
48734
- `${rnxPublicBrand.packageName}/config`
48735
- )
49026
+ virtualModules: {
49027
+ [`${rnxPublicBrand.packageName}/config`]: config_exports
48736
49028
  }
48737
49029
  });
48738
49030
  const loaded2 = await jiti.import(project.configPath, { default: true });
@@ -48749,17 +49041,16 @@ async function resolveRNXAppConfig(startDir = process.cwd()) {
48749
49041
  const project = resolveAppProject(startDir);
48750
49042
  return { project, config: await loadRNXAppConfig(project) };
48751
49043
  }
48752
- var import_node_module3, import_node_path36, import_jiti, require2;
49044
+ var import_node_path36, import_jiti;
48753
49045
  var init_app_config = __esm({
48754
49046
  "cli/app-config.ts"() {
48755
49047
  "use strict";
48756
- import_node_module3 = require("node:module");
48757
49048
  import_node_path36 = __toESM(require("node:path"), 1);
48758
49049
  import_jiti = require("jiti");
48759
49050
  init_config();
49051
+ init_config();
48760
49052
  init_public_brand();
48761
49053
  init_app_project();
48762
- require2 = (0, import_node_module3.createRequire)(__sootsim_import_meta_url);
48763
49054
  }
48764
49055
  });
48765
49056
 
@@ -48774,10 +49065,10 @@ function discoverNativeLinkedAppFonts(opts) {
48774
49065
  let getConfig = null;
48775
49066
  if (project) {
48776
49067
  try {
48777
- const modulePath = require3.resolve("@expo/config", {
49068
+ const modulePath = require2.resolve("@expo/config", {
48778
49069
  paths: [selectedAppDir]
48779
49070
  });
48780
- const mod = require3(modulePath);
49071
+ const mod = require2(modulePath);
48781
49072
  if (typeof mod.getConfig === "function") {
48782
49073
  getConfig = mod.getConfig;
48783
49074
  }
@@ -48859,7 +49150,7 @@ function discoverNativeLinkedAppFonts(opts) {
48859
49150
  if (bundleDir && selectedAppDir.endsWith(import_node_path37.default.sep + appRelativeDir)) {
48860
49151
  metroRootCandidates.push(selectedAppDir.slice(0, -appRelativeDir.length - 1));
48861
49152
  }
48862
- const vectorIconRequire = (0, import_node_module4.createRequire)(import_node_path37.default.join(selectedAppDir, "package.json"));
49153
+ const vectorIconRequire = (0, import_node_module3.createRequire)(import_node_path37.default.join(selectedAppDir, "package.json"));
48863
49154
  for (const dependencyName of vectorIconDependencies) {
48864
49155
  try {
48865
49156
  const entryPath = vectorIconRequire.resolve(dependencyName);
@@ -48885,7 +49176,7 @@ function discoverNativeLinkedAppFonts(opts) {
48885
49176
  try {
48886
49177
  const configPath = import_node_path37.default.join(selectedAppDir, "react-native.config.js");
48887
49178
  if (import_node_fs35.default.statSync(configPath).isFile()) {
48888
- const appConfigRequire = (0, import_node_module4.createRequire)(import_node_path37.default.join(selectedAppDir, "package.json"));
49179
+ const appConfigRequire = (0, import_node_module3.createRequire)(import_node_path37.default.join(selectedAppDir, "package.json"));
48889
49180
  const rnConfig = appConfigRequire(configPath);
48890
49181
  const assets2 = rnConfig && typeof rnConfig === "object" ? Reflect.get(rnConfig, "assets") : null;
48891
49182
  if (Array.isArray(assets2)) {
@@ -48979,19 +49270,19 @@ async function resolveMetroProjectRoot(bundleUrl, opts) {
48979
49270
  function encodeAppFontsWire(specs) {
48980
49271
  return specs.map((spec) => `${encodeURIComponent(spec.url)}::${encodeURIComponent(spec.family)}`).join(",");
48981
49272
  }
48982
- var import_node_fs35, import_node_module4, import_node_path37, import_config_plugin_fonts, require3;
49273
+ var import_node_fs35, import_node_module3, import_node_path37, import_config_plugin_fonts, require2;
48983
49274
  var init_app_fonts = __esm({
48984
49275
  "cli/app-fonts.ts"() {
48985
49276
  "use strict";
48986
49277
  import_node_fs35 = __toESM(require("node:fs"), 1);
48987
- import_node_module4 = require("node:module");
49278
+ import_node_module3 = require("node:module");
48988
49279
  import_node_path37 = __toESM(require("node:path"), 1);
48989
49280
  import_config_plugin_fonts = require("peach-engine/engine/config-plugin-fonts");
48990
49281
  init_dev_server_scanner();
48991
49282
  init_backend_origin();
48992
49283
  init_plist();
48993
49284
  init_app_project();
48994
- require3 = (0, import_node_module4.createRequire)(__sootsim_import_meta_url);
49285
+ require2 = (0, import_node_module3.createRequire)(__sootsim_import_meta_url);
48995
49286
  }
48996
49287
  });
48997
49288
 
@@ -49029,10 +49320,10 @@ function discoverConfigPluginAppSplash(opts) {
49029
49320
  const platform = (opts.platform || process.env.CONTRAST_PLATFORM || "ios").toLowerCase();
49030
49321
  let getConfig = null;
49031
49322
  try {
49032
- const modulePath = require4.resolve("@expo/config", {
49323
+ const modulePath = require3.resolve("@expo/config", {
49033
49324
  paths: [selectedAppDir]
49034
49325
  });
49035
- const mod = require4(modulePath);
49326
+ const mod = require3(modulePath);
49036
49327
  if (typeof mod.getConfig === "function") {
49037
49328
  getConfig = mod.getConfig;
49038
49329
  }
@@ -49060,15 +49351,15 @@ function splashImageUrls(spec) {
49060
49351
  if (spec.dark?.backgroundImageUrl) urls.add(spec.dark.backgroundImageUrl);
49061
49352
  return [...urls];
49062
49353
  }
49063
- var import_node_module5, import_config_plugin_splash, require4;
49354
+ var import_node_module4, import_config_plugin_splash, require3;
49064
49355
  var init_app_splash = __esm({
49065
49356
  "cli/app-splash.ts"() {
49066
49357
  "use strict";
49067
- import_node_module5 = require("node:module");
49358
+ import_node_module4 = require("node:module");
49068
49359
  import_config_plugin_splash = require("peach-engine/engine/config-plugin-splash");
49069
49360
  init_backend_origin();
49070
49361
  init_app_project();
49071
- require4 = (0, import_node_module5.createRequire)(__sootsim_import_meta_url);
49362
+ require3 = (0, import_node_module4.createRequire)(__sootsim_import_meta_url);
49072
49363
  }
49073
49364
  });
49074
49365
 
@@ -49977,7 +50268,7 @@ function getSootsimRoot() {
49977
50268
  if (_sootsimRoot !== void 0) return _sootsimRoot;
49978
50269
  try {
49979
50270
  _sootsimRoot = (0, import_path5.dirname)(
49980
- (0, import_url2.fileURLToPath)(import_meta4.resolve("peach-engine/package.json"))
50271
+ (0, import_url2.fileURLToPath)(import_meta2.resolve("peach-engine/package.json"))
49981
50272
  );
49982
50273
  } catch {
49983
50274
  _sootsimRoot = null;
@@ -50189,6 +50480,7 @@ async function launchDesktopCompanion(url, install = findDesktopCompanion(), opt
50189
50480
  if (install.kind === "mac-app" || install.kind === "native-mac-app") {
50190
50481
  const nativeApp = install.kind === "native-mac-app";
50191
50482
  if (nativeApp) extraArgs.push("--no-personal-home");
50483
+ if (nativeApp) extraArgs.push("-ApplePersistenceIgnoreState", "YES");
50192
50484
  const openArgs = ["-g", "-a", install.path];
50193
50485
  if (url) openArgs.push(buildMacLaunchUrl(url, opts, nativeApp));
50194
50486
  else if (nativeApp && (opts.profileId || opts.ephemeralProfile || opts.ownerPid || opts.device))
@@ -50227,7 +50519,7 @@ function buildMacLaunchUrl(url, opts, nativeApp = false) {
50227
50519
  }
50228
50520
  return deepLink.toString();
50229
50521
  }
50230
- var import_child_process5, import_fs6, import_path5, import_url2, import_meta4, _sootsimRoot, PEACH_BUNDLE_ID;
50522
+ var import_child_process5, import_fs6, import_path5, import_url2, import_meta2, _sootsimRoot, PEACH_BUNDLE_ID;
50231
50523
  var init_desktop_companion = __esm({
50232
50524
  "cli/desktop-companion.ts"() {
50233
50525
  "use strict";
@@ -50236,7 +50528,7 @@ var init_desktop_companion = __esm({
50236
50528
  import_path5 = require("path");
50237
50529
  import_url2 = require("url");
50238
50530
  init_desktop_host_delivery();
50239
- import_meta4 = {};
50531
+ import_meta2 = {};
50240
50532
  PEACH_BUNDLE_ID = "dev.peachsim.simulator";
50241
50533
  }
50242
50534
  });
@@ -51575,14 +51867,14 @@ function resolvePlaywright() {
51575
51867
  roots.push(`${playwrightCoreDir(PINNED_PLAYWRIGHT_CORE.version)}/`);
51576
51868
  for (const root of roots) {
51577
51869
  try {
51578
- const requireFromRoot = (0, import_node_module6.createRequire)(root);
51870
+ const requireFromRoot = (0, import_node_module5.createRequire)(root);
51579
51871
  for (const spec of ["playwright", "playwright-chromium", "playwright-core"]) {
51580
51872
  try {
51581
51873
  const modulePath = requireFromRoot.resolve(spec);
51582
51874
  const packageJsonPath = requireFromRoot.resolve(`${spec}/package.json`);
51583
51875
  const parsed = JSON.parse((0, import_node_fs38.readFileSync)(packageJsonPath, "utf8"));
51584
51876
  if (!isRecord(parsed) || typeof parsed.version !== "string") continue;
51585
- const corePackagePath = (0, import_node_module6.createRequire)(modulePath).resolve(
51877
+ const corePackagePath = (0, import_node_module5.createRequire)(modulePath).resolve(
51586
51878
  "playwright-core/package.json"
51587
51879
  );
51588
51880
  const cliPath = (0, import_node_path40.join)((0, import_node_path40.dirname)(corePackagePath), "cli.js");
@@ -51725,13 +52017,13 @@ ${detail}` : ""}`
51725
52017
  libraryPath: libraries.libraryPath
51726
52018
  };
51727
52019
  }
51728
- var import_node_child_process15, import_node_fs38, import_node_module6, import_node_path40;
52020
+ var import_node_child_process15, import_node_fs38, import_node_module5, import_node_path40;
51729
52021
  var init_playwright_provisioning = __esm({
51730
52022
  "cli/drivers/playwright-provisioning.ts"() {
51731
52023
  "use strict";
51732
52024
  import_node_child_process15 = require("node:child_process");
51733
52025
  import_node_fs38 = require("node:fs");
51734
- import_node_module6 = require("node:module");
52026
+ import_node_module5 = require("node:module");
51735
52027
  import_node_path40 = require("node:path");
51736
52028
  init_src();
51737
52029
  init_home_paths();
@@ -52241,7 +52533,7 @@ function getSkillsDir() {
52241
52533
  }
52242
52534
  try {
52243
52535
  const pkgPath = (0, import_url3.fileURLToPath)(
52244
- import_meta5.resolve(`${rnxPublicBrand.packageName}/package.json`)
52536
+ import_meta3.resolve(`${rnxPublicBrand.packageName}/package.json`)
52245
52537
  );
52246
52538
  return primaryCheckoutPath(path33.join(path33.dirname(pkgPath), "skills"));
52247
52539
  } catch {
@@ -52347,7 +52639,7 @@ function listSkills() {
52347
52639
  }
52348
52640
  return skills.sort((a, b) => a.name.localeCompare(b.name));
52349
52641
  }
52350
- var import_child_process7, fs29, os9, path33, import_url3, import_meta5, skillsDirPath;
52642
+ var import_child_process7, fs29, os9, path33, import_url3, import_meta3, skillsDirPath;
52351
52643
  var init_skills = __esm({
52352
52644
  "cli/commands/skills.ts"() {
52353
52645
  "use strict";
@@ -52360,7 +52652,7 @@ var init_skills = __esm({
52360
52652
  init_home_paths();
52361
52653
  init_public_brand();
52362
52654
  init_run_rnx();
52363
- import_meta5 = {};
52655
+ import_meta3 = {};
52364
52656
  }
52365
52657
  });
52366
52658