peachsim 0.1.1808 → 0.1.1812

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 (236) hide show
  1. package/README.md +4 -2
  2. package/cli/app-bundle-resources.ts +15 -2
  3. package/cli/cloud-box-artifact.ts +115 -0
  4. package/cli/cloud-client.ts +148 -76
  5. package/cli/cloud-dispatch.ts +4 -4
  6. package/cli/cloud-session.ts +60 -22
  7. package/cli/commands/box.ts +8 -2
  8. package/cli/commands/compat.ts +7 -4
  9. package/cli/commands/control.ts +69 -3
  10. package/cli/commands/coverage.ts +14 -4
  11. package/cli/commands/daemon.ts +41 -0
  12. package/cli/commands/no-bridge-hint.ts +9 -0
  13. package/cli/commands/package.ts +31 -56
  14. package/cli/commands/platform.ts +71 -60
  15. package/cli/commands/preview.ts +73 -24
  16. package/cli/commands/record.ts +10 -2
  17. package/cli/commands/screenshot.ts +17 -60
  18. package/cli/commands/setup.ts +3 -1
  19. package/cli/commands/three-mode.ts +22 -12
  20. package/cli/commands/upload.ts +2 -1
  21. package/cli/desktop-companion.ts +6 -1
  22. package/cli/drivers/desktop.ts +4 -1
  23. package/cli/main.ts +12 -2
  24. package/cli/metro-bundle-assets.ts +14 -4
  25. package/cli/outbound-endpoints.ts +7 -3
  26. package/cli/output-redaction.ts +38 -0
  27. package/cli/privacy.ts +2 -2
  28. package/cli/recording-access.ts +5 -0
  29. package/cli/remote-project-bundle.ts +83 -0
  30. package/cli/shell-init.ts +7 -11
  31. package/cli/telemetry.ts +41 -4
  32. package/cli/usage-error.ts +3 -0
  33. package/cli/ws-bridge.ts +42 -6
  34. package/dist-lib/agent-daemon-client.cjs +1 -1
  35. package/dist-lib/agent-events.cjs +1 -1
  36. package/dist-lib/attached-projects.cjs +1 -1
  37. package/dist-lib/auth/shared-session.cjs +1 -1
  38. package/dist-lib/backend-origin.cjs +1 -1
  39. package/dist-lib/beta.cjs +1 -1
  40. package/dist-lib/beta.mjs +1 -1
  41. package/dist-lib/bridge-constants.cjs +1 -1
  42. package/dist-lib/bridge-contract-input.cjs +1 -1
  43. package/dist-lib/bridge-contract-input.mjs +1 -1
  44. package/dist-lib/bridge-contract.cjs +1 -1
  45. package/dist-lib/bridge-contract.mjs +1 -1
  46. package/dist-lib/bundle-channel.cjs +42897 -40755
  47. package/dist-lib/capture-contract.cjs +7 -8
  48. package/dist-lib/capture-contract.mjs +7 -8
  49. package/dist-lib/cloud-contract.cjs +1 -1
  50. package/dist-lib/cloud-contract.mjs +1 -1
  51. package/dist-lib/cloud-test-args.cjs +1 -1
  52. package/dist-lib/cloud-test-args.mjs +1 -1
  53. package/dist-lib/cloud.cjs +1 -1
  54. package/dist-lib/cloud.mjs +1 -1
  55. package/dist-lib/config.cjs +1 -1
  56. package/dist-lib/config.mjs +1 -1
  57. package/dist-lib/detox/index.cjs +13 -7
  58. package/dist-lib/dev-bundle-resolution.cjs +10 -4
  59. package/dist-lib/expo-swift-bundle.cjs +15889 -15553
  60. package/dist-lib/expo-swift-metadata.cjs +2 -1
  61. package/dist-lib/expo-swift-metadata.mjs +2 -1
  62. package/dist-lib/home-paths.cjs +2 -33
  63. package/dist-lib/host/bridge-host.cjs +20891 -18714
  64. package/dist-lib/host/fetch-proxy-handler.cjs +10 -11
  65. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  66. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  67. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  68. package/dist-lib/host/websocket-proxy.cjs +1 -1
  69. package/dist-lib/index.cjs +620 -553
  70. package/dist-lib/jump-to-source-babel.cjs +1 -1
  71. package/dist-lib/jump-to-source-native.cjs +1 -1
  72. package/dist-lib/kotlin-host.cjs +1 -1
  73. package/dist-lib/menu.cjs +1 -1
  74. package/dist-lib/menu.mjs +1 -1
  75. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  76. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  77. package/dist-lib/metro-production-bundle.cjs +1 -1
  78. package/dist-lib/metro-production-bundle.mjs +1 -1
  79. package/dist-lib/metro.cjs +57 -28
  80. package/dist-lib/native-app-identity-project.cjs +47 -14
  81. package/dist-lib/native-app-identity-project.mjs +55 -20
  82. package/dist-lib/native-app-identity.cjs +1 -1
  83. package/dist-lib/native-app-identity.mjs +1 -1
  84. package/dist-lib/native-firebase-metadata.cjs +1 -1
  85. package/dist-lib/native-firebase-metadata.mjs +1 -1
  86. package/dist-lib/pdfium-raster.cjs +1 -1
  87. package/dist-lib/pdfium-raster.mjs +1 -1
  88. package/dist-lib/plist.cjs +1 -1
  89. package/dist-lib/plist.mjs +1 -1
  90. package/dist-lib/profiles.cjs +1 -1
  91. package/dist-lib/public-brand.cjs +1 -1
  92. package/dist-lib/public-origins-lib-esm.json +27 -26
  93. package/dist-lib/public-origins-lib.json +104 -81
  94. package/dist-lib/react-native-host-modules.cjs +1 -1
  95. package/dist-lib/react-native-host-modules.mjs +1 -1
  96. package/dist-lib/reap-browser.cjs +1 -1
  97. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  98. package/dist-lib/sdk.cjs +1 -1
  99. package/dist-lib/sdk.mjs +1 -1
  100. package/dist-lib/skills.cjs +30700 -24410
  101. package/dist-lib/swift-compile.cjs +336 -222
  102. package/dist-lib/swift-compile.mjs +378 -263
  103. package/dist-lib/swift-package.cjs +19 -7
  104. package/dist-lib/swift-package.mjs +16 -6
  105. package/dist-lib/swift-submit.cjs +1 -1
  106. package/dist-lib/swift-submit.mjs +1 -1
  107. package/dist-lib/swift-toolchain.cjs +49 -1
  108. package/dist-lib/swift.cjs +1 -1
  109. package/dist-lib/vite-swift.cjs +19213 -18937
  110. package/dist-lib/vite.cjs +11 -12
  111. package/dist-lib/worklet-executable.cjs +1 -1
  112. package/dist-lib/worklet-executable.mjs +1 -1
  113. package/dist-types/packages/peach-engine/src/engine/animated.d.ts +4 -0
  114. package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +1 -0
  115. package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +1 -0
  116. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -1
  117. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
  118. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +8 -1
  119. package/dist-types/packages/peach-globals/src/electronBridgeContract.d.ts +2 -1
  120. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  121. package/kotlin/sdk.tar.gz +0 -0
  122. package/package.json +1 -1
  123. package/runtime-companion.json +1 -1
  124. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCall.h +1 -1
  125. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCallCenter.h +1 -1
  126. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCarrier.h +1 -1
  127. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriber.h +1 -1
  128. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTSubscriberInfo.h +1 -1
  129. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h +1 -1
  130. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSDictionary.h +1 -1
  131. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSExtensionItem.h +1 -1
  132. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVFoundation+MPNowPlayingInfoLanguageOptionAdditions.h +39 -0
  133. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/AVPlayerItem+MediaPlayerAdditions.h +26 -0
  134. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPContentItem.h +67 -0
  135. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPError.h +33 -0
  136. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaEntity.h +53 -0
  137. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItem.h +346 -0
  138. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaItemCollection.h +42 -0
  139. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaLibrary.h +76 -0
  140. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPickerController.h +64 -0
  141. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlayback.h +47 -0
  142. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaPlaylist.h +82 -0
  143. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuery.h +120 -0
  144. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMediaQuerySection.h +26 -0
  145. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerController.h +444 -0
  146. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMoviePlayerViewController.h +43 -0
  147. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerApplicationController.h +47 -0
  148. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerController.h +147 -0
  149. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPMusicPlayerQueueDescriptor.h +75 -0
  150. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoCenter.h +197 -0
  151. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingInfoLanguageOption.h +107 -0
  152. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPNowPlayingSession.h +89 -0
  153. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDataSource.h +59 -0
  154. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentDelegate.h +64 -0
  155. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManager.h +46 -0
  156. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPPlayableContentManagerContext.h +32 -0
  157. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommand.h +143 -0
  158. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandCenter.h +66 -0
  159. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteCommandEvent.h +128 -0
  160. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPRemoteControlTypes.h +27 -0
  161. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeSettings.h +20 -0
  162. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MPVolumeView.h +82 -0
  163. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.apinotes +74 -0
  164. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayer.h +40 -0
  165. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/MediaPlayerDefines.h +84 -0
  166. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Headers/NSUserActivity+MediaPlayerAdditions.h +20 -0
  167. package/sdk/ios/System/Library/Frameworks/MediaPlayer.framework/Modules/module.modulemap +5 -0
  168. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityCustomRotor.h +2 -2
  169. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +1 -1
  170. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBackgroundConfiguration.h +1 -1
  171. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIButtonConfiguration.h +1 -1
  172. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuConfiguration.h +1 -1
  173. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIContextMenuInteraction.h +1 -1
  174. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDeferredMenuElement.h +1 -1
  175. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +1 -1
  176. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPointerStyle.h +5 -5
  177. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISlider.h +1 -1
  178. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewController.h +12 -50
  179. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewControllerLayoutEnvironment.h +2 -8
  180. package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +62 -0
  181. package/sdk/ios/usr/include/dispatch.modulemap +22 -0
  182. package/sdk/ios/usr/include/module.modulemap +8 -3
  183. package/sdk/ios/usr/include/net/if.h +24 -0
  184. package/sdk/ios/usr/include/sys/time.h +1 -1
  185. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
  186. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
  187. package/sdk/ios/wasm/include/fcntl.h +2 -0
  188. package/sdk/ios/wasm/include/pthread.h +3 -0
  189. package/sdk/ios/wasm/include/stdlib.h +2 -0
  190. package/sdk/ios/wasm/include/unistd.h +2 -2
  191. package/skills/contrast/SKILL.md +2 -2
  192. package/src/bundle-channel.mjs +9 -72
  193. package/src/capture-contract.ts +12 -9
  194. package/src/desktop-host-delivery.ts +16 -2
  195. package/src/dev-bundle-resolution.ts +12 -3
  196. package/src/expo-native-workspace.ts +113 -46
  197. package/src/expo-swift-host.ts +17 -12
  198. package/src/expo-swift-ready.ts +4 -1
  199. package/src/expoSwiftContract.ts +1 -0
  200. package/src/home-paths.ts +4 -48
  201. package/src/host/bridge-host.ts +1 -0
  202. package/src/installed-native-libraries.ts +2 -8
  203. package/src/metro-project-root.ts +2 -1
  204. package/src/native-bundles.ts +122 -0
  205. package/src/native-static-libraries.ts +65 -8
  206. package/src/nitro-adapter.lock.json +272 -272
  207. package/src/nitro-bundle.ts +2 -2
  208. package/src/nitro-compile.ts +68 -28
  209. package/src/nitro-source.ts +24 -6
  210. package/src/nitro-superset.lock.json +94 -34
  211. package/src/nitroContract.ts +3 -0
  212. package/src/podspec-sources.ts +1966 -0
  213. package/src/storageSnapshotContract.ts +40 -0
  214. package/src/swift-compile.ts +77 -26
  215. package/src/swift-design-time.ts +18 -1
  216. package/src/swift-distribution.lock.json +12 -12
  217. package/src/swift-distribution.ts +9 -6
  218. package/src/swift-host.ts +1 -2
  219. package/src/swift-link-roots.ts +13 -2
  220. package/src/swift-objc-compile.ts +12 -0
  221. package/src/swift-objc-standin.ts +321 -114
  222. package/src/swift-package-manifest.ts +4 -3
  223. package/src/swift-package.ts +31 -4
  224. package/src/swift-root-lock.ts +11 -0
  225. package/src/swift-shared-sdk.ts +10 -9
  226. package/src/swift-source-pods.ts +2 -2
  227. package/src/swift-standins.ts +40 -143
  228. package/src/swift-toolchain.ts +59 -0
  229. package/src/swift-wasm-prune.ts +53 -21
  230. package/src/turbo-bundle.ts +4 -5
  231. package/src/turbo-codegen-intake.ts +111 -108
  232. package/src/turbo-compile.ts +63 -33
  233. package/src/turbo-runtime.lock.json +22 -22
  234. package/src/turbo-source.ts +171 -76
  235. package/src/wasm-optimize.ts +31 -2
  236. package/src/xcode-project.ts +65 -15
@@ -5,12 +5,14 @@ import https from 'node:https'
5
5
  import net from 'node:net'
6
6
  import os from 'node:os'
7
7
  import path from 'node:path'
8
+ import { compareSemver } from '@contrast/runtime-delivery'
8
9
  import { WebSocket } from 'ws'
9
10
  import { formatLockOwner } from '../../src/agent-identity'
10
11
  import { ANDROID_ROOT_MODULE_QUERY_PARAM } from '../../src/androidRootModuleContract'
11
12
  import { isAppDeepLinkTarget, openAppUrl } from '../../src/app-url'
12
13
  import { isLoopbackHost } from '../../src/backend-origin'
13
14
  import { getCliRuntime } from '../../src/cli-runtime.ts'
15
+ import { getCliVersion } from '../../src/cli-version'
14
16
  import {
15
17
  applyPeachConfigToUrl,
16
18
  mergePeachConfig,
@@ -30,6 +32,7 @@ import { flowTimeoutScale } from '../../src/flow-timeout-scale'
30
32
  import {
31
33
  isDaemonLockfileFresh,
32
34
  isDevBridgeLockfileFresh,
35
+ isSootsimDevCheckout,
33
36
  PEACH_HOME_ENV,
34
37
  readActiveRuntime,
35
38
  readDaemonLockfile,
@@ -47,6 +50,7 @@ import { applyHotMode } from '../../src/native-dev-bundle-url'
47
50
  import { isProcessRunning } from '../../src/process-liveness'
48
51
  import { ensureProfile } from '../../src/profiles'
49
52
  import {
53
+ resolveDevCheckoutRuntimeAssetRoot,
50
54
  resolveDevCheckoutRuntimeRoot,
51
55
  runtimeVersionHostname,
52
56
  } from '../../src/runtime-assets'
@@ -90,6 +94,7 @@ import {
90
94
  type ParsedBridgeCliArgs,
91
95
  type WsBridge,
92
96
  } from '../ws-bridge'
97
+ import { retireIdleBridge } from './daemon'
93
98
  import { inspectDescribe, inspectReadySnapshot, waitReadyReason } from './inspect/core'
94
99
  import { waitForSimReady } from './inspect/shared'
95
100
  import { runInstallDesktop } from './install-desktop'
@@ -352,6 +357,7 @@ async function connectBridgeForOpen(
352
357
  runtimeSource: 'bridge' | 'external',
353
358
  ): Promise<number> {
354
359
  isolateHomeForExplicitPort(preferredPort, explicitPort, readDaemonLockfile())
360
+ await retireOutdatedIdleBridge(readDaemonLockfile())
355
361
  const lock = readDaemonLockfile()
356
362
  const preferredWorld = worldForBridgePort(preferredPort)
357
363
  const handshakeTimeoutMs = LIVE_BRIDGE_HANDSHAKE_TIMEOUT_MS * flowTimeoutScale()
@@ -474,6 +480,35 @@ async function connectBridgeForOpen(
474
480
  )
475
481
  }
476
482
 
483
+ // a bridge started by an older cli lacks the routes this cli's sims need, and
484
+ // they sit reconnecting against it. replace it once nothing uses it: no live or
485
+ // retained sim, and not the Mac app's own bridge. a busy or unanswering bridge
486
+ // is left alone, so active sessions are never cut.
487
+ async function retireOutdatedIdleBridge(
488
+ lock: ReturnType<typeof readDaemonLockfile>,
489
+ ): Promise<void> {
490
+ if (!lock || !isDaemonLockfileFresh(lock) || lock.bootstrapping) return
491
+ const current = getCliVersion()
492
+ if (isSootsimDevCheckout() || lock.cliVersion === current) return
493
+ if (lock.cliVersion && compareSemver(current, lock.cliVersion) <= 0) return
494
+ const appRecord = path.join(rnxHomeDir(), 'app-runtime.json')
495
+ if (fs.existsSync(appRecord)) return
496
+ const bridge = createBridge(lock.bridgePort, { commandTimeoutMs: 2000 })
497
+ const simCount = await bridge.listSims({ includeRetained: true }).then(
498
+ (sims) => sims.length,
499
+ () => -1,
500
+ )
501
+ bridge.close()
502
+ if (simCount !== 0) return
503
+ console.error(
504
+ ` Replacing the idle peach bridge on port ${lock.bridgePort} (${lock.cliVersion ? `v${lock.cliVersion}` : 'older'}) with v${current}.`,
505
+ )
506
+ await retireIdleBridge(lock)
507
+ const deadline = Date.now() + 10_000
508
+ while (isDaemonLockfileFresh(readDaemonLockfile()) && Date.now() < deadline)
509
+ await sleep(100)
510
+ }
511
+
477
512
  // one bridge per peach home, so an explicit port the active daemon does not own
478
513
  // gets its own home: this command and the bridge it starts both run in it,
479
514
  // sharing the daemon's installed runtimes unless this CLI serves its own dev
@@ -547,6 +582,14 @@ export async function ensureRuntimeForOpen() {
547
582
  // a dev checkout serves its own build; staging a published runtime into an
548
583
  // isolated home would make the daemon serve that instead.
549
584
  if (resolveDevCheckoutRuntimeRoot()) return
585
+ // a checkout with no engine build serves the installed runtime, whose engine
586
+ // predates this checkout's launch metadata and Swift output, so say so before
587
+ // its failures read like app bugs.
588
+ if (resolveDevCheckoutRuntimeAssetRoot()) {
589
+ console.error(
590
+ ` this checkout has no engine build, so the installed runtime serves it; run \`bun run build:peach\` to test this checkout's engine`,
591
+ )
592
+ }
550
593
  const active = readActiveRuntime()
551
594
  if (active && fs.existsSync(path.join(runtimeDir(active), 'index.html'))) return
552
595
  // a populated home without a ready active runtime may still be staging.
@@ -562,7 +605,9 @@ export async function ensureRuntimeForOpen() {
562
605
  await runRuntime(['install'], {})
563
606
  }
564
607
 
565
- type BridgeHandshake = 'open' | 'refused' | 'timeout'
608
+ // 'foreign' is a server that accepts the websocket but whose /healthz does not
609
+ // identify a peach bridge: another tool holding the port, never adopted.
610
+ type BridgeHandshake = 'open' | 'refused' | 'timeout' | 'foreign'
566
611
 
567
612
  function bridgeHandshake(
568
613
  port: number,
@@ -585,7 +630,21 @@ function bridgeHandshake(
585
630
  const onAbort = () => finish('timeout')
586
631
  if (signal?.aborted) onAbort()
587
632
  else signal?.addEventListener('abort', onAbort)
588
- ws.once('open', () => finish('open'))
633
+ ws.once('open', () => {
634
+ fetch(`http://127.0.0.1:${port}/healthz`, {
635
+ signal: AbortSignal.timeout(timeoutMs),
636
+ })
637
+ .then((res) => res.json())
638
+ .then(
639
+ (health: unknown) =>
640
+ finish(
641
+ health && typeof health === 'object' && Reflect.get(health, 'ok') === true
642
+ ? 'open'
643
+ : 'foreign',
644
+ ),
645
+ () => finish('foreign'),
646
+ )
647
+ })
589
648
  ws.on('error', (err: NodeJS.ErrnoException) => {
590
649
  finish(
591
650
  err.code === 'ECONNREFUSED' || err.code === 'ENOTFOUND' ? 'refused' : 'timeout',
@@ -599,6 +658,9 @@ function unreachableBridgeMessage(
599
658
  handshake: BridgeHandshake,
600
659
  timeoutMs: number,
601
660
  ): string {
661
+ if (handshake === 'foreign') {
662
+ return `peach open: requested bridge port ${port} is held by another program, not a peach bridge. stop it or pass a free port with --port <port>.`
663
+ }
602
664
  if (handshake === 'timeout') {
603
665
  const cores = Math.max(1, os.cpus().length)
604
666
  const load = os.loadavg()[0]
@@ -1948,7 +2010,11 @@ async function openSim(
1948
2010
  windowSize,
1949
2011
  osVersion: osVersionArg,
1950
2012
  theme: themeArg,
1951
- iosTarget: args.find((_, i) => args[i - 1] === '--ios-target'),
2013
+ // --target selects the Xcode application target on native opens; honor it
2014
+ // on dev-server opens too, where the multi-target error sends strangers
2015
+ iosTarget:
2016
+ args.find((_, i) => args[i - 1] === '--ios-target') ??
2017
+ args.find((_, i) => args[i - 1] === '--target'),
1952
2018
  resolvedBundle,
1953
2019
  project,
1954
2020
  oneAppSplash,
@@ -805,13 +805,25 @@ export function isSwiftSourceApp(app: string, sources: readonly string[]): boole
805
805
  )
806
806
  }
807
807
 
808
- // printed under compat's Source heading; each feature line only with --verbose
808
+ // printed under compat's Source heading. by default it prints the scan size and
809
+ // what needs attention; --verbose adds the feature and reference breakdown.
809
810
  export function printCoverageReport(report: CoverageReport, verbose: boolean): void {
810
811
  const { summary } = report
811
812
  const say = (text: string) => console.log(` ${text}`)
812
813
  say(
813
814
  `Scanned ${report.input.files} source files: ${summary.references} package references (${summary.projectModuleReferences} imports of the app's own modules not counted).`,
814
815
  )
816
+ if (!verbose) {
817
+ for (const module of report.localNativeModules)
818
+ say(
819
+ ` app-owned native module ${module.module} (${module.path}): ${module.references} references, unknown`,
820
+ )
821
+ for (const issue of report.unknowns) say(` ${issue.path}: ${issue.reason}`)
822
+ say(
823
+ '--verbose adds what works in each package, every feature, every package reference and the scan limits.',
824
+ )
825
+ return
826
+ }
815
827
  say(
816
828
  ` mapped to a feature: ${summary.mappedReferences}; package ships no native code: ${summary.noNativeSurfaceReferences}; version unknown: ${summary.versionUnknownReferences}; other unknown or unmapped: ${Math.max(0, summary.unknownReferences - summary.versionUnknownReferences)}`,
817
829
  )
@@ -822,9 +834,7 @@ export function printCoverageReport(report: CoverageReport, verbose: boolean): v
822
834
  say(
823
835
  `Final graph (${report.graph.platform}): ${report.graph.projectModules} project modules, ${report.graph.packageModules} package modules; complete: ${report.graph.complete ?? 'unknown'}.`,
824
836
  )
825
- if (!verbose && report.features.length)
826
- say(` ${report.features.length} features; --verbose lists each`)
827
- for (const feature of verbose ? report.features : [])
837
+ for (const feature of report.features)
828
838
  say(
829
839
  ` ${feature.id}${feature.graphReach ? ` (${feature.graphReach})` : ''}: verification unknown; unknown axes: ${feature.unknownAxes.join(', ') || 'none'}`,
830
840
  )
@@ -37,6 +37,7 @@ import {
37
37
  readDaemonLockfile,
38
38
  shouldSkipPersistentDaemon,
39
39
  rnxHomeDir,
40
+ type DaemonLockfile,
40
41
  } from '../../src/home-paths'
41
42
  import { rnxPublicBrand } from '../../src/public-brand'
42
43
  import { printCommandHelp } from '../help'
@@ -828,6 +829,46 @@ async function daemonStatus() {
828
829
  peachExit(1)
829
830
  }
830
831
 
832
+ // hands off an idle bridge that an older cli left running, so the next start
833
+ // serves the current cli's routes. a service-managed bridge restarts through
834
+ // its service; a bare bridge gets SIGTERM only when its pid still owns the
835
+ // lockfile's listening port, since a lockfile alone cannot authorize a signal.
836
+ // its sims and files are untouched: the caller proves the bridge idle first.
837
+ export async function retireIdleBridge(lock: DaemonLockfile): Promise<void> {
838
+ if (process.platform === 'darwin') {
839
+ const service = existsSync(macPlistPath())
840
+ ? readMacDaemonState(macServiceTarget())
841
+ : null
842
+ if (service?.pid === lock.pid) return daemonRestart()
843
+ if (!macBridgeHasListener(lock.pid, lock.bridgePort)) return
844
+ process.kill(lock.pid, 'SIGTERM')
845
+ return waitForBridgeRelease(macBridgeHasListener, lock)
846
+ }
847
+ if (process.platform === 'linux') {
848
+ const mainPid = spawnSync(
849
+ 'systemctl',
850
+ ['--user', 'show', SERVICE_NAME_LINUX, '-p', 'MainPID', '--value'],
851
+ { encoding: 'utf8' },
852
+ ).stdout.trim()
853
+ if (mainPid === String(lock.pid)) return daemonRestart()
854
+ if (!linuxBridgeHasListener(lock.pid, lock.bridgePort)) return
855
+ process.kill(lock.pid, 'SIGTERM')
856
+ return waitForBridgeRelease(linuxBridgeHasListener, lock)
857
+ }
858
+ }
859
+
860
+ async function waitForBridgeRelease(
861
+ hasListener: (pid: number, port: number) => boolean,
862
+ lock: DaemonLockfile,
863
+ ): Promise<void> {
864
+ const deadline = Date.now() + 4000
865
+ while (Date.now() < deadline) {
866
+ if (!hasListener(lock.pid, lock.bridgePort)) return
867
+ await new Promise((resolve) => setTimeout(resolve, 100))
868
+ }
869
+ throw new Error(`bridge pid ${lock.pid} did not release port ${lock.bridgePort}`)
870
+ }
871
+
831
872
  async function daemonRestart() {
832
873
  if (process.platform === 'darwin') {
833
874
  const path = macPlistPath()
@@ -1,8 +1,17 @@
1
1
  // shared hint printed when the CLI has no bridge or no desktop companion.
2
2
 
3
+ import { desktopHostPlatform } from '../../src/desktop-host-delivery'
3
4
  import type { BridgeSimInfo } from '../ws-bridge'
4
5
 
5
6
  export function printMissingCompanionHint(native = false) {
7
+ if (process.platform === 'darwin' && !desktopHostPlatform()) {
8
+ console.error(' the Peach desktop app needs Apple silicon on macOS 26 or later.')
9
+ console.error('')
10
+ console.error(' open the simulator in a browser window instead:')
11
+ console.error(' peach open <target> --driver playwright --headed')
12
+ console.error('')
13
+ return
14
+ }
6
15
  console.error(
7
16
  native
8
17
  ? ' no native peach desktop host found.'
@@ -20,8 +20,7 @@ import {
20
20
  import { getCliRuntime, verifyCliCompanion } from '../../src/cli-runtime'
21
21
  import { produceConfiguredBundle } from '../../src/configured-bundle-producer'
22
22
  import { activeDesktopHostApp } from '../../src/desktop-host-delivery'
23
- import { insertExpoKotlinFooter } from '../../src/expoKotlinContract'
24
- import { insertExpoSwiftFooter, readExpoSwiftFooter } from '../../src/expoSwiftContract'
23
+ import { readExpoSwiftFooter } from '../../src/expoSwiftContract'
25
24
  import { readActiveRuntime } from '../../src/home-paths'
26
25
  import {
27
26
  captureStagedHostFiles,
@@ -32,8 +31,12 @@ import { readInstalledNativePackageVersionsAsync } from '../../src/installed-pac
32
31
  import { isRecord } from '../../src/is-record'
33
32
  import { detectBundleModeFromText } from '../../src/metro-production-bundle'
34
33
  import { readNativeAppIdentityFromProject } from '../../src/native-app-identity-project'
34
+ import {
35
+ buildNativeBundles,
36
+ insertNativeBundleFooters,
37
+ nativeBundleAssets,
38
+ } from '../../src/native-bundles'
35
39
  import { readExpoConfigAsync } from '../../src/native-firebase-config'
36
- import { insertNitroFooter, insertTurboFooter } from '../../src/nitroContract'
37
40
  import {
38
41
  insertPackageVersionsFooter,
39
42
  readPackageVersions,
@@ -52,6 +55,7 @@ import {
52
55
  import { prepareNativeInput, resolveNativeInput } from '../native-input'
53
56
  import { packagedAppLauncher } from '../packaged-app-launcher'
54
57
  import { IS_STANDALONE } from '../standalone'
58
+ import { CliUsageError } from '../usage-error'
55
59
  import {
56
60
  buildShellUrl,
57
61
  resolveAppProjectForBundleUrl,
@@ -76,7 +80,7 @@ async function projectIcon(
76
80
 
77
81
  export async function runPackage(args: string[]): Promise<void> {
78
82
  if (process.platform !== 'darwin')
79
- throw new Error('peach package currently builds macOS apps')
83
+ throw new CliUsageError('peach package currently builds macOS apps')
80
84
  const input = [...args]
81
85
  const values = new Map<string, string>()
82
86
  const settings: string[] = []
@@ -108,9 +112,10 @@ export async function runPackage(args: string[]): Promise<void> {
108
112
  '--notarize',
109
113
  ].includes(flag)
110
114
  )
111
- throw new Error(`unknown peach package option: ${flag}`)
115
+ throw new CliUsageError(`unknown peach package option: ${flag}`)
112
116
  const value = input[++i]
113
- if (!value || value.startsWith('--')) throw new Error(`${flag} requires a value`)
117
+ if (!value || value.startsWith('--'))
118
+ throw new CliUsageError(`${flag} requires a value`)
114
119
  if (flag === '--setting') settings.push(value)
115
120
  else if (flag === '--launch-env-file') {
116
121
  // KEY=PATH: the launching host reads PATH (~/ is the user's home) at each
@@ -122,13 +127,13 @@ export async function runPackage(args: string[]): Promise<void> {
122
127
  !/^[A-Za-z_][A-Za-z0-9_]*$/.test(value.slice(0, equals)) ||
123
128
  equals === value.length - 1
124
129
  )
125
- throw new Error(`--launch-env-file expects KEY=PATH, got ${value}`)
130
+ throw new CliUsageError(`--launch-env-file expects KEY=PATH, got ${value}`)
126
131
  launchEnvironmentFiles[value.slice(0, equals)] = value.slice(equals + 1)
127
132
  } else values.set(flag, value)
128
133
  }
129
134
  const target = positionals[0]
130
135
  if (!target || positionals.length !== 1)
131
- throw new Error(
136
+ throw new CliUsageError(
132
137
  'usage: peach package <target> --name <name> [--output <app|zip|dmg> --setting key=value --launch-env-file KEY=PATH --sign <identity> --notarize <profile>]',
133
138
  )
134
139
  const name = values.get('--name') ?? path.basename(target, path.extname(target))
@@ -140,18 +145,18 @@ export async function runPackage(args: string[]): Promise<void> {
140
145
  /[/\0]/.test(name) ||
141
146
  !/^[A-Za-z0-9]+(?:[.-][A-Za-z0-9-]+)+$/.test(identifier)
142
147
  )
143
- throw new Error('package name or bundle identifier is invalid')
148
+ throw new CliUsageError('package name or bundle identifier is invalid')
144
149
  const output = path.resolve(values.get('--output') ?? `${name}.app`)
145
150
  const archive = path.extname(output)
146
151
  if (!['.app', '.zip', '.dmg'].includes(archive) || fs.existsSync(output))
147
- throw new Error('--output must name a new .app, .zip or .dmg')
152
+ throw new CliUsageError('--output must name a new .app, .zip or .dmg')
148
153
  // a Developer ID identity signs with the hardened runtime; notarization reads
149
154
  // credentials saved by `xcrun notarytool store-credentials <profile>`
150
155
  const identity = values.get('--sign')
151
156
  const notaryProfile = values.get('--notarize')
152
157
  if (identity && !identity.startsWith('Developer ID Application: '))
153
- throw new Error('--sign needs a Developer ID Application identity')
154
- if (notaryProfile && !identity) throw new Error('--notarize needs --sign')
158
+ throw new CliUsageError('--sign needs a Developer ID Application identity')
159
+ if (notaryProfile && !identity) throw new CliUsageError('--notarize needs --sign')
155
160
  const defaults = packageSettingDefaults(settings)
156
161
  const versionsFile = values.get('--package-versions')
157
162
  const versions = versionsFile
@@ -182,7 +187,7 @@ export async function runPackage(args: string[]): Promise<void> {
182
187
  const runtime = resolveActiveRuntimeRoot()
183
188
  const runtimeVersion = readActiveRuntime()
184
189
  if (!host || !runtime || !runtimeVersion)
185
- throw new Error(
190
+ throw new CliUsageError(
186
191
  'install the Peach desktop app and an engine runtime before packaging',
187
192
  )
188
193
  verifyCliCompanion(runtime)
@@ -192,7 +197,9 @@ export async function runPackage(args: string[]): Promise<void> {
192
197
  ? process.execPath
193
198
  : path.resolve(import.meta.dirname, '../../dist-bin/peach-darwin-arm64'))
194
199
  if (!fs.existsSync(cli))
195
- throw new Error('source packaging needs a built CLI binary; pass --cli <binary>')
200
+ throw new CliUsageError(
201
+ 'source packaging needs a built CLI binary; pass --cli <binary>',
202
+ )
196
203
  // the app is assembled beside the output, so archives and the final move stay on its volume
197
204
  const staging = `${output}.${randomUUID()}`
198
205
  const temporary = path.join(staging, `${name}.app`)
@@ -242,47 +249,15 @@ export async function runPackage(args: string[]): Promise<void> {
242
249
  source = detachBundleGlobalFooter(source, '__peachExpoKotlin').source
243
250
  source = stripBundleMetadataFooter(source, 'nitro')
244
251
  source = stripBundleMetadataFooter(source, 'turbo')
245
- if (platform === 'android') {
246
- const native = await (
247
- await import('../../src/expo-kotlin-bundle')
248
- ).buildExpoKotlinBundle(root)
249
- if (native) {
250
- for (const asset of native.assets)
251
- route('/' + asset.path, asset.bytes, asset.contentType)
252
- source = insertExpoKotlinFooter(source, native.metadata)
253
- }
254
- } else {
255
- const native = await (
256
- await import('../../src/expo-swift-bundle')
257
- ).buildExpoSwiftBundle(root)
258
- if (native) {
259
- for (const asset of native.assets)
260
- route('/' + asset.path, asset.bytes, asset.contentType)
261
- source = insertExpoSwiftFooter(source, native.metadata)
262
- }
263
- // a production bundle runs on a Release build, any other on Debug
264
- const nitro = await (
265
- await import('../../src/nitro-bundle')
266
- ).buildNitroBundle(
267
- root,
268
- (await detectBundleModeFromText(source)) === 'production'
269
- ? 'Release'
270
- : 'Debug',
271
- )
272
- if (nitro) {
273
- for (const asset of nitro.assets)
274
- route('/' + asset.path, asset.bytes, asset.contentType)
275
- source = insertNitroFooter(source, nitro.metadata)
276
- }
277
- const turbo = await (
278
- await import('../../src/turbo-bundle')
279
- ).buildTurboBundle(root)
280
- if (turbo) {
281
- for (const asset of turbo.assets)
282
- route('/' + asset.path, asset.bytes, asset.contentType)
283
- source = insertTurboFooter(source, turbo.metadata)
284
- }
285
- }
252
+ // a production bundle runs on a Release build, any other on Debug
253
+ const natives = await buildNativeBundles(
254
+ root,
255
+ platform === 'android' ? 'android' : 'ios',
256
+ (await detectBundleModeFromText(source)) === 'production' ? 'Release' : 'Debug',
257
+ )
258
+ for (const asset of nativeBundleAssets(natives))
259
+ route('/' + asset.path, asset.bytes, asset.contentType)
260
+ source = insertNativeBundleFooters(source, natives, (file) => '/' + file).source
286
261
  return produceConfiguredBundle(
287
262
  source,
288
263
  config,
@@ -307,7 +282,7 @@ export async function runPackage(args: string[]): Promise<void> {
307
282
  ? resolveAppProject(values.get('--project-root')!)
308
283
  : project
309
284
  if (values.has('--project-root') && !configuredProject)
310
- throw new Error('--project-root must name an app project')
285
+ throw new CliUsageError('--project-root must name an app project')
311
286
  if (configuredProject)
312
287
  configuredVersions = await readInstalledNativePackageVersionsAsync(
313
288
  configuredProject.appDir,