peachsim 0.1.1812 → 0.1.1814

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 (127) hide show
  1. package/README.md +2 -1
  2. package/cli/cloud-box-artifact.ts +31 -9
  3. package/cli/cloud-client.ts +5 -4
  4. package/cli/cloud-session.ts +14 -1
  5. package/cli/commands/box/bundle-plane.ts +34 -5
  6. package/cli/commands/box.ts +12 -2
  7. package/cli/commands/compat.ts +12 -2
  8. package/cli/commands/control.ts +15 -1
  9. package/cli/commands/flow.ts +10 -5
  10. package/cli/commands/inspect/env.ts +3 -2
  11. package/cli/commands/inspect/wait-selector.ts +30 -9
  12. package/cli/commands/platform.ts +1 -0
  13. package/cli/commands/setup.ts +16 -3
  14. package/dist-lib/agent-daemon-client.cjs +1 -1
  15. package/dist-lib/agent-events.cjs +1 -1
  16. package/dist-lib/attached-projects.cjs +1 -1
  17. package/dist-lib/auth/shared-session.cjs +1 -1
  18. package/dist-lib/backend-origin.cjs +1 -1
  19. package/dist-lib/beta.cjs +1 -1
  20. package/dist-lib/beta.mjs +1 -1
  21. package/dist-lib/bridge-constants.cjs +1 -1
  22. package/dist-lib/bridge-contract-input.cjs +1 -1
  23. package/dist-lib/bridge-contract-input.mjs +1 -1
  24. package/dist-lib/bridge-contract.cjs +1 -1
  25. package/dist-lib/bridge-contract.mjs +1 -1
  26. package/dist-lib/bundle-channel.cjs +591 -449
  27. package/dist-lib/capture-contract.cjs +1 -1
  28. package/dist-lib/capture-contract.mjs +1 -1
  29. package/dist-lib/cloud-contract.cjs +1 -1
  30. package/dist-lib/cloud-contract.mjs +1 -1
  31. package/dist-lib/cloud-test-args.cjs +1 -1
  32. package/dist-lib/cloud-test-args.mjs +1 -1
  33. package/dist-lib/cloud.cjs +1 -1
  34. package/dist-lib/cloud.mjs +1 -1
  35. package/dist-lib/config.cjs +1 -1
  36. package/dist-lib/config.mjs +1 -1
  37. package/dist-lib/detox/index.cjs +2 -2
  38. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  39. package/dist-lib/expo-swift-bundle.cjs +119 -52
  40. package/dist-lib/expo-swift-metadata.cjs +1 -17
  41. package/dist-lib/expo-swift-metadata.mjs +1 -16
  42. package/dist-lib/home-paths.cjs +1 -1
  43. package/dist-lib/host/bridge-host.cjs +1970 -1891
  44. package/dist-lib/host/fetch-proxy-handler.cjs +2 -4
  45. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  46. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  47. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  48. package/dist-lib/host/websocket-proxy.cjs +1 -1
  49. package/dist-lib/index.cjs +7 -10
  50. package/dist-lib/jump-to-source-babel.cjs +1 -1
  51. package/dist-lib/jump-to-source-native.cjs +1 -1
  52. package/dist-lib/kotlin-host.cjs +1 -1
  53. package/dist-lib/menu.cjs +1 -1
  54. package/dist-lib/menu.mjs +1 -1
  55. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  56. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  57. package/dist-lib/metro-production-bundle.cjs +1 -1
  58. package/dist-lib/metro-production-bundle.mjs +1 -1
  59. package/dist-lib/metro.cjs +4 -6
  60. package/dist-lib/native-app-identity-project.cjs +3 -3
  61. package/dist-lib/native-app-identity-project.mjs +6 -6
  62. package/dist-lib/native-app-identity.cjs +1 -1
  63. package/dist-lib/native-app-identity.mjs +1 -1
  64. package/dist-lib/native-firebase-metadata.cjs +1 -1
  65. package/dist-lib/native-firebase-metadata.mjs +1 -1
  66. package/dist-lib/pdfium-raster.cjs +1 -1
  67. package/dist-lib/pdfium-raster.mjs +1 -1
  68. package/dist-lib/plist.cjs +1 -1
  69. package/dist-lib/plist.mjs +1 -1
  70. package/dist-lib/profiles.cjs +1 -1
  71. package/dist-lib/public-brand.cjs +1 -1
  72. package/dist-lib/public-origins-lib-esm.json +24 -24
  73. package/dist-lib/public-origins-lib.json +65 -68
  74. package/dist-lib/react-native-host-modules.cjs +1 -1
  75. package/dist-lib/react-native-host-modules.mjs +1 -1
  76. package/dist-lib/reap-browser.cjs +1 -1
  77. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  78. package/dist-lib/sdk.cjs +1 -1
  79. package/dist-lib/sdk.mjs +1 -1
  80. package/dist-lib/skills.cjs +713 -534
  81. package/dist-lib/swift-compile.cjs +27 -26
  82. package/dist-lib/swift-compile.mjs +34 -33
  83. package/dist-lib/swift-package.cjs +1 -1
  84. package/dist-lib/swift-package.mjs +1 -1
  85. package/dist-lib/swift-submit.cjs +2 -2
  86. package/dist-lib/swift-submit.mjs +2 -2
  87. package/dist-lib/swift-toolchain.cjs +5 -3
  88. package/dist-lib/swift.cjs +1 -1
  89. package/dist-lib/vite-swift.cjs +87 -41
  90. package/dist-lib/vite.cjs +2 -4
  91. package/dist-lib/worklet-executable.cjs +1 -1
  92. package/dist-lib/worklet-executable.mjs +1 -1
  93. package/dist-types/packages/peach-engine/src/react-native/host-services.d.ts +7 -0
  94. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +14 -2
  95. package/install.mjs +21 -8
  96. package/package.json +1 -1
  97. package/runtime-companion.json +1 -1
  98. package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h +17 -0
  99. package/sdk/ios/usr/lib/swift/Dispatch.swiftmodule/arm64-apple-ios-simulator.swiftinterface +5 -0
  100. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -0
  101. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +10 -1
  102. package/sdk/ios/usr/lib/swift/SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
  103. package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +11 -0
  104. package/sdk/ios/usr/lib/swift/UIKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +13 -0
  105. package/sdk/ios/wasm/include/string.h +1 -0
  106. package/src/expo-kotlin-host.ts +69 -35
  107. package/src/expo-native-workspace.ts +8 -0
  108. package/src/expo-swift-host.ts +45 -9
  109. package/src/expoSwiftContract.ts +2 -20
  110. package/src/nitro-adapter.lock.json +235 -235
  111. package/src/nitro-bundle.ts +2 -8
  112. package/src/nitro-superset.lock.json +14 -14
  113. package/src/nitro-superset.ts +2 -3
  114. package/src/nitroContract.ts +0 -29
  115. package/src/react-native-bridge-modules.ts +2 -9
  116. package/src/swift-compile.ts +2 -0
  117. package/src/swift-distribution.lock.json +8 -8
  118. package/src/swift-distribution.ts +1 -0
  119. package/src/swift-icu.ts +21 -27
  120. package/src/swift-project-user.ts +5 -0
  121. package/src/swift-shared-sdk.ts +4 -0
  122. package/src/swift-standins.ts +6 -1
  123. package/src/swift-submit.ts +2 -1
  124. package/src/swift-toolchain.ts +5 -2
  125. package/src/swift-wasm-prune.ts +10 -2
  126. package/src/turbo-runtime.lock.json +15 -15
  127. package/src/turbo-source.ts +160 -37
package/README.md CHANGED
@@ -9,7 +9,8 @@ The CLI and library are separate public artifacts. The recommended installer
9
9
  downloads one Bun-compiled `peach` executable that needs no Node.js, npm, or Bun
10
10
  installation. The `peachsim` npm package contains bundler plugins, testing
11
11
  drivers, and library exports; its only command, `npx peachsim`, runs that same
12
- installer from the copy of `install.sh` it ships.
12
+ installer from the copy of `install.sh` it ships, and `npx peachsim <command>`
13
+ installs peach if it is missing, then runs `peach <command>`.
13
14
 
14
15
  The executable updates itself with `peach upgrade`, which then restarts a running
15
16
  background daemon onto the new executable. A new runtime needs no restart: the
@@ -1,8 +1,10 @@
1
- // the prebuilt bundle a Box boots, with the app's Metro assets and compiled
2
- // native modules inside it. it compiles on the cli's machine, so it lives apart
3
- // from cloud-client, which the box worker itself bundles.
1
+ // the prebuilt bundle a Box boots, with the app's Metro assets inside it and
2
+ // its compiled native modules beside it. it compiles on the cli's machine, so
3
+ // it lives apart from cloud-client, which the box worker itself bundles.
4
+ import { createHash } from 'node:crypto'
4
5
  import { existsSync, readFileSync } from 'node:fs'
5
6
  import { dirname, join, resolve } from 'node:path'
7
+ import { prebuiltNativeAssetUrl } from '@peach/box/template'
6
8
  import { getCliRuntime } from '../src/cli-runtime.ts'
7
9
  import { isRecord } from '../src/is-record'
8
10
  import { detectBundleModeFromText } from '../src/metro-production-bundle.ts'
@@ -15,11 +17,19 @@ import { readPackageVersionsFooter } from '../src/packageVersionsContract'
15
17
  import { embedBundleAssets, isRemoteBundleInput } from './cloud-client.ts'
16
18
  import type { RemotePlatform } from './cloud-session.ts'
17
19
 
20
+ export interface CloudBoxNativeAsset {
21
+ url: string
22
+ contentType: string
23
+ bytes: Uint8Array
24
+ }
25
+
18
26
  export interface CloudBoxArtifactProduction {
19
27
  bytes: Buffer
20
28
  assetsDirectory: string | null
21
29
  /** the app project whose compiled native modules the bundle carries. */
22
30
  nativeProject: string | null
31
+ /** the compiled native module files the bundle's footers name, by guest url. */
32
+ nativeAssets: CloudBoxNativeAsset[]
23
33
  warnings: string[]
24
34
  }
25
35
 
@@ -45,9 +55,10 @@ function bundleAppProject(bundlePath: string): string | null {
45
55
  }
46
56
 
47
57
  /**
48
- * prepares a prebuilt bundle for a Box: the Metro assets beside the bundle and
49
- * the app project's compiled native modules travel inside it, because the box
50
- * page boots these bytes with no server of the app's behind them.
58
+ * prepares a prebuilt bundle for a Box: the Metro assets beside the bundle
59
+ * travel inside it, because the box page boots these bytes with no server of
60
+ * the app's behind them. the app project's compiled native modules travel as
61
+ * files beside it, which the page hands the guest as project assets.
51
62
  */
52
63
  export async function produceCloudBoxArtifact(
53
64
  bundlePath: string,
@@ -81,6 +92,7 @@ export async function produceCloudBoxArtifact(
81
92
  ? resolve(options.nativeProjectDir)
82
93
  : bundleAppProject(bundlePath)
83
94
  let code = prepared.code
95
+ const nativeAssets: CloudBoxNativeAsset[] = []
84
96
  if (nativeProject) {
85
97
  const natives = await buildNativeBundles(
86
98
  nativeProject,
@@ -89,18 +101,27 @@ export async function produceCloudBoxArtifact(
89
101
  ? 'Release'
90
102
  : 'Debug',
91
103
  )
92
- // a Kotlin module imports its loader and wasm by relative url, which a
93
- // self-contained data url cannot answer.
104
+ // a Kotlin module imports its loader and wasm by relative url, which the
105
+ // box page does not serve.
94
106
  if (natives.expoKotlin?.metadata.module) {
95
107
  throw new Error(
96
108
  `${nativeProject} has Expo Kotlin modules, and remote Android simulators cannot load compiled Kotlin modules yet.`,
97
109
  )
98
110
  }
99
111
  const files = new Map(nativeBundleAssets(natives).map((asset) => [asset.path, asset]))
112
+ const urls = new Map<string, string>()
100
113
  code = insertNativeBundleFooters(code, natives, (path) => {
114
+ const known = urls.get(path)
115
+ if (known) return known
101
116
  const asset = files.get(path)
102
117
  if (!asset) throw new Error(`compiled native module file ${path} was not produced`)
103
- return `data:${asset.contentType};base64,${asset.bytes.toString('base64')}`
118
+ const url = prebuiltNativeAssetUrl(
119
+ createHash('sha256').update(asset.bytes).digest('hex'),
120
+ path,
121
+ )
122
+ urls.set(path, url)
123
+ nativeAssets.push({ url, contentType: asset.contentType, bytes: asset.bytes })
124
+ return url
104
125
  }).source
105
126
  }
106
127
  if (getCliRuntime().preview_bundle_layout.isRolldownBundle(code))
@@ -110,6 +131,7 @@ export async function produceCloudBoxArtifact(
110
131
  bytes: Buffer.from(code, 'utf8'),
111
132
  assetsDirectory: prepared.dest?.directory ?? null,
112
133
  nativeProject,
134
+ nativeAssets,
113
135
  warnings,
114
136
  }
115
137
  }
@@ -1490,6 +1490,9 @@ function cloudCommand(command: {
1490
1490
  return clean
1491
1491
  }
1492
1492
 
1493
+ const REMOTE_HAS_NO_LOCAL_SIMS =
1494
+ 'Peach commands here go to your remote simulator, which has no local simulators; run `peach close` to end it, or run this from another folder'
1495
+
1493
1496
  class CloudBridge implements WsBridge {
1494
1497
  readonly plane = 'cloud' as const
1495
1498
 
@@ -1549,9 +1552,7 @@ class CloudBridge implements WsBridge {
1549
1552
  }
1550
1553
 
1551
1554
  listSims(): Promise<BridgeSimInfo[]> {
1552
- return Promise.reject(
1553
- new Error('a remote simulator does not expose a local simulator list'),
1554
- )
1555
+ return Promise.reject(new Error(REMOTE_HAS_NO_LOCAL_SIMS))
1555
1556
  }
1556
1557
 
1557
1558
  focusSim(): Promise<never> {
@@ -1639,7 +1640,7 @@ class CloudBoxBridge implements WsBridge {
1639
1640
  }
1640
1641
 
1641
1642
  listSims(): Promise<BridgeSimInfo[]> {
1642
- return Promise.reject(new Error('a box does not expose a local simulator list'))
1643
+ return Promise.reject(new Error(REMOTE_HAS_NO_LOCAL_SIMS))
1643
1644
  }
1644
1645
 
1645
1646
  focusSim(): Promise<never> {
@@ -300,6 +300,19 @@ export function readCloudSession(): CloudSession | null {
300
300
  return parseCloudSession(saved.session)
301
301
  }
302
302
 
303
+ // a shell session takes precedence over the folder file, so forgetting it must
304
+ // leave a different session another process saved for the folder in place
305
+ function shellOverridesOtherSavedSession(file: string): boolean {
306
+ const encoded = process.env[PEACH_CLOUD_SESSION_ENV]?.trim()
307
+ if (!encoded || !existsSync(file)) return false
308
+ const saved: unknown = JSON.parse(readFileSync(file, 'utf8'))
309
+ if (!isRecord(saved) || typeof saved.session !== 'string') return false
310
+ return (
311
+ serializeCloudSession(parseCloudSession(saved.session)) !==
312
+ serializeCloudSession(parseCloudSession(encoded))
313
+ )
314
+ }
315
+
303
316
  // the update channel the shell integration opens around a lifecycle command,
304
317
  // or null outside it (agents, scripts, a shell without the integration)
305
318
  export function cloudSessionShellUpdate(): number | null {
@@ -325,7 +338,7 @@ export function publishCloudSession(
325
338
  ): void {
326
339
  const file = projectSessionFile()
327
340
  if (session) writeSecureJsonAtomic(file, { session: serializeCloudSession(session) })
328
- else rmSync(file, { force: true })
341
+ else if (!shellOverridesOtherSavedSession(file)) rmSync(file, { force: true })
329
342
  if (descriptor === null) return
330
343
  const update = session
331
344
  ? `${RNX_SHELL_UPDATE_SET_PREFIX}${serializeCloudSession(session)}`
@@ -11,12 +11,16 @@
11
11
  import {
12
12
  PREBUILT_BUNDLE_DEVICE_PATH,
13
13
  PREBUILT_BUNDLE_INITIAL_URL_PATH,
14
+ PREBUILT_BUNDLE_NATIVE_ASSETS_MANIFEST_PATH,
14
15
  PREBUILT_BUNDLE_NATIVE_RENDERER_PATH,
15
16
  prebuiltAppFontsPartPath,
17
+ prebuiltNativeAssetPartPath,
16
18
  PREBUILT_BUNDLE_PART_BYTES,
17
19
  prebuiltBundlePartPath,
20
+ type PrebuiltNativeAssetEntry,
18
21
  } from '@peach/box/template'
19
22
  import type { NativeRenderer } from '../../../src/config'
23
+ import type { CloudBoxNativeAsset } from '../../cloud-box-artifact.ts'
20
24
  import type { ProjectFileMeta, ProjectFilePlane } from '@peach/box/plane'
21
25
 
22
26
  export class BundleFilePlane implements ProjectFilePlane {
@@ -29,6 +33,7 @@ export class BundleFilePlane implements ProjectFilePlane {
29
33
  initialUrl: string | null,
30
34
  appFonts = '',
31
35
  nativeRenderer?: NativeRenderer,
36
+ nativeAssets: readonly CloudBoxNativeAsset[] = [],
32
37
  ) {
33
38
  if (bundle.byteLength === 0) throw new Error('a Box bundle cannot be empty')
34
39
  if (appFonts)
@@ -41,31 +46,55 @@ export class BundleFilePlane implements ProjectFilePlane {
41
46
  PREBUILT_BUNDLE_NATIVE_RENDERER_PATH,
42
47
  new TextEncoder().encode(nativeRenderer),
43
48
  )
49
+ if (nativeAssets.length) {
50
+ const manifest: PrebuiltNativeAssetEntry[] = nativeAssets.map((asset, index) => ({
51
+ url: asset.url,
52
+ contentType: asset.contentType,
53
+ parts: this.recordParts(
54
+ asset.bytes,
55
+ (part) => prebuiltNativeAssetPartPath(index, part),
56
+ true,
57
+ ),
58
+ }))
59
+ this.record(
60
+ PREBUILT_BUNDLE_NATIVE_ASSETS_MANIFEST_PATH,
61
+ new TextEncoder().encode(JSON.stringify(manifest)),
62
+ )
63
+ }
44
64
  this.recordParts(bundle, prebuiltBundlePartPath)
45
65
  }
46
66
 
47
- private recordParts(content: Uint8Array, partPath: (index: number) => string): void {
67
+ // returns how many parts it wrote
68
+ private recordParts(
69
+ content: Uint8Array,
70
+ partPath: (index: number) => string,
71
+ binary = false,
72
+ ): number {
73
+ let index = 0
48
74
  for (
49
- let offset = 0, index = 0;
75
+ let offset = 0;
50
76
  offset < content.byteLength;
51
77
  offset += PREBUILT_BUNDLE_PART_BYTES, index++
52
78
  ) {
53
79
  this.record(
54
80
  partPath(index),
55
81
  content.subarray(offset, offset + PREBUILT_BUNDLE_PART_BYTES),
82
+ binary,
56
83
  )
57
84
  }
85
+ return index
58
86
  }
59
87
 
60
- private record(path: string, content: Uint8Array): void {
88
+ private record(path: string, content: Uint8Array, binary = false): void {
61
89
  this.parts.set(path, content)
62
90
  this.entries.set(path, {
63
91
  size: content.byteLength,
64
92
  readOnly: false,
65
93
  // a Metro bundle is JavaScript. the flag is what decides whether a shell
66
94
  // may overwrite a file with text, and marking it binary would make the
67
- // bundle unwritable from inside the box for no reason.
68
- binary: false,
95
+ // bundle unwritable from inside the box for no reason. compiled native
96
+ // modules are binary.
97
+ binary,
69
98
  })
70
99
  }
71
100
 
@@ -38,6 +38,7 @@ import { authHeaderOrExit, cloudAccountIdOrExit, type CliAuth } from '../auth'
38
38
  import {
39
39
  produceCloudBoxArtifact,
40
40
  type CloudBoxArtifactProduction,
41
+ type CloudBoxNativeAsset,
41
42
  } from '../cloud-box-artifact.ts'
42
43
  import { openUrl } from '../open-url'
43
44
  import { findRepositoryPackageRoot } from '../setup-repository'
@@ -522,6 +523,8 @@ export async function createPrebuiltBundleBox(options: {
522
523
  fresh?: boolean
523
524
  bundle: Uint8Array
524
525
  nativeProjectDir?: string
526
+ // the compiled native module files the bundle's footers name
527
+ nativeAssets?: readonly CloudBoxNativeAsset[]
525
528
  // the simulator's device model, or null for the Box page's default
526
529
  device: string | null
527
530
  // the link the app launches with, as Linking.getInitialURL reports it
@@ -556,6 +559,7 @@ export async function createPrebuiltBundleBox(options: {
556
559
  options.initialUrl ?? null,
557
560
  appFonts,
558
561
  nativeRenderer,
562
+ options.nativeAssets,
559
563
  ),
560
564
  ...(options.secrets ? { secrets: options.secrets } : {}),
561
565
  })
@@ -627,7 +631,9 @@ async function runCloudBoxCreate(
627
631
 
628
632
  // a prebuilt box holds the bundle; a source box holds the checkout it is
629
633
  // built from. nothing holds both, so they are not two nullable variables.
630
- let source: { bundle: Uint8Array } | { checkout: CheckoutFilePlane }
634
+ let source:
635
+ | { bundle: Uint8Array; nativeAssets: readonly CloudBoxNativeAsset[] }
636
+ | { checkout: CheckoutFilePlane }
631
637
  let defaultName: string
632
638
  if (bundlePath) {
633
639
  // bundle preparation and device metadata need the runtime companion.
@@ -657,7 +663,10 @@ async function runCloudBoxCreate(
657
663
  return 1
658
664
  }
659
665
  for (const warning of artifact.warnings) console.error(` ${warning}`)
660
- source = { bundle: new Uint8Array(artifact.bytes) }
666
+ source = {
667
+ bundle: new Uint8Array(artifact.bytes),
668
+ nativeAssets: artifact.nativeAssets,
669
+ }
661
670
  defaultName = path.basename(resolved).replace(/\.[^.]+$/, '')
662
671
  } else {
663
672
  const root = findRepositoryPackageRoot(process.cwd())
@@ -719,6 +728,7 @@ async function runCloudBoxCreate(
719
728
  ? await createPrebuiltBundleBox({
720
729
  ...connection,
721
730
  bundle: source.bundle,
731
+ nativeAssets: source.nativeAssets,
722
732
  nativeProjectDir,
723
733
  device: null,
724
734
  name,
@@ -6,7 +6,7 @@
6
6
  // source scan alone.
7
7
 
8
8
  import { createHash } from 'node:crypto'
9
- import { relative, resolve } from 'node:path'
9
+ import { join, relative, resolve } from 'node:path'
10
10
  import { PURE_JS_PACKAGES } from '@peach/compat/pure-js-whitelist'
11
11
  import { resolveCompatVersionRange } from '@peach/compat/version-range'
12
12
  import {
@@ -19,6 +19,7 @@ import {
19
19
  import { getCliVersion } from '../../src/cli-version'
20
20
  import { readActiveRuntime } from '../../src/home-paths'
21
21
  import { rnxPublicBrand } from '../../src/public-brand'
22
+ import { findXcodeProject } from '../../src/xcode-project'
22
23
  import { resolveRNXAppConfig } from '../app-config'
23
24
  import {
24
25
  installedPackageDir,
@@ -94,7 +95,16 @@ export async function runCompat(args: string[]): Promise<number> {
94
95
  const { runSwiftCoverage } = await import('./coverage-swift')
95
96
  return runSwiftCoverage(appDir, sources, json, graph, xcodeTarget)
96
97
  }
97
- if (xcodeTarget) throw new Error('--target selects an Xcode application target')
98
+ if (xcodeTarget) {
99
+ // a React Native project keeps its Xcode project at the root or in ios/
100
+ const project = findXcodeProject(appDir) ?? findXcodeProject(join(appDir, 'ios'))
101
+ if (!project)
102
+ throw new Error(
103
+ `--target ${xcodeTarget} selects an Xcode application target, but ${appDir} holds no Xcode project (looked in . and ios/). Run peach compat from the project that holds it, or drop --target to scan the React Native source.`,
104
+ )
105
+ const { runSwiftCoverage } = await import('./coverage-swift')
106
+ return runSwiftCoverage(project, sources, json, graph, xcodeTarget)
107
+ }
98
108
  const pkg = readProjectManifest(appDir)
99
109
  const { config, stubs: resolvedStubs } = await resolveRNXAppConfig(appDir)
100
110
  const stubs = effectiveStubSources(resolvedStubs)
@@ -79,6 +79,7 @@ import { diagnosticsAllowedForCurrentProcess, isCi } from '../privacy'
79
79
  import { rethrowIfExit, peachExit } from '../run-rnx'
80
80
  import { collectRuntimeDiagnostics } from '../runtime-diagnostics'
81
81
  import { rnxSelfInvocation } from '../self-invocation'
82
+ import { accent, muted, warning } from '../ui'
82
83
  import {
83
84
  BRIDGE_VALUE_FLAGS,
84
85
  BridgeSimLockedError,
@@ -94,7 +95,7 @@ import {
94
95
  type ParsedBridgeCliArgs,
95
96
  type WsBridge,
96
97
  } from '../ws-bridge'
97
- import { retireIdleBridge } from './daemon'
98
+ import { getDaemonServiceStatus, retireIdleBridge } from './daemon'
98
99
  import { inspectDescribe, inspectReadySnapshot, waitReadyReason } from './inspect/core'
99
100
  import { waitForSimReady } from './inspect/shared'
100
101
  import { runInstallDesktop } from './install-desktop'
@@ -389,6 +390,14 @@ async function connectBridgeForOpen(
389
390
  // starting a bridge needs ready local assets; an existing bridge gets
390
391
  // to finish its own install before the caller validates them.
391
392
  if (runtimeSource === 'bridge') await ensureRuntimeForOpen()
393
+ // the background service keeps a bridge warm; without it every cold open
394
+ // starts one here, so say once why this open is slower.
395
+ const service = getDaemonServiceStatus()
396
+ if (service.supported && !service.installed && !isCi()) {
397
+ console.error(
398
+ ` ${warning('!')} ${muted('the background service is off, so Peach starts slower; turn it on with')} ${accent('peach daemon install')}`,
399
+ )
400
+ }
392
401
  const { executable, prefixArgs } = rnxSelfInvocation()
393
402
  // the bridge outlives open, so it must not hold the command's captured stderr.
394
403
  const bridgeLogPath = path.join(
@@ -1061,6 +1070,11 @@ export function printDriverDiagnosticLogTail(result: DriverLaunchResult) {
1061
1070
  const shown = detail.length > 4_000 ? `…\n${detail.slice(-4_000)}` : detail
1062
1071
  console.error(` ${path.basename(result.diagnosticLogPath)}:`)
1063
1072
  console.error(shown)
1073
+ if (/No usable sandbox/i.test(detail)) {
1074
+ console.error(
1075
+ ' this container blocks the user namespaces Chromium sandboxes with. on a locked-down CI runner set PEACH_CHROMIUM_SANDBOX=0 to launch it unsandboxed (the default stays sandboxed).',
1076
+ )
1077
+ }
1064
1078
  } catch (err) {
1065
1079
  const message = err instanceof Error ? err.message : String(err)
1066
1080
  console.error(
@@ -551,6 +551,7 @@ flow extension:
551
551
  let openTarget = url || targetApp || ''
552
552
  const driverFlag = getFlag('--driver') || ''
553
553
  let closeFlowOwnedSimAfterRun = false
554
+ let openedSimId: string | undefined
554
555
  const ownedSimIds = new Set<string>()
555
556
 
556
557
  // if we weren't told exactly where to go, and there's already a primary
@@ -633,6 +634,7 @@ flow extension:
633
634
  resources: openResources,
634
635
  runtimeConfig: targetAppResolution.runtimeConfig,
635
636
  })
637
+ openedSimId = opened?.simId
636
638
  // the steps must talk to the bridge open actually settled on, not the
637
639
  // pre-open default. without this a default 7668 held by an unrelated
638
640
  // server keeps the flow on 7668 while open serves from 7669.
@@ -652,15 +654,18 @@ flow extension:
652
654
  const pinnedSimId =
653
655
  resolvedBridgeArgs.simIdSource === 'flag'
654
656
  ? resolvedBridgeArgs.simId
655
- : readCurrentSimId() || resolvedBridgeArgs.simId
657
+ : openedSimId || readCurrentSimId() || resolvedBridgeArgs.simId
656
658
  // carry the source through so the target-sim notice reads `via --sim`
657
659
  // (not the misleading `primary fallback — no sim pinned`) when the flow
658
660
  // was actually pinned with --sim or a `peach use` selection.
659
661
  const pinnedSimIdSource: typeof resolvedBridgeArgs.simIdSource =
660
- resolvedBridgeArgs.simIdSource === 'flag' ? 'flag' : pinnedSimId ? 'saved' : 'none'
661
- // the re-parse only picks up the sim the open saved; the bridge stays the
662
- // world open settled on above (or the --base-url pin when no open ran),
663
- // or the steps talk to another shell.
662
+ resolvedBridgeArgs.simIdSource === 'flag' || openedSimId
663
+ ? 'flag'
664
+ : pinnedSimId
665
+ ? 'saved'
666
+ : 'none'
667
+ // retain the world open settled on above (or the --base-url pin when no
668
+ // open ran), or the steps talk to another shell.
664
669
  const bridge = createBridge(parsedBridgeArgs.wsPort, {
665
670
  commandTimeoutMs: resolvedBridgeArgs.commandTimeoutMs,
666
671
  simId: pinnedSimId,
@@ -29,9 +29,10 @@ export function isAgentEnv(
29
29
  // 250ms opacity timing) plus the stillness proof on a contended host, where a
30
30
  // poll costs 40-70ms; at 400ms every feedback tap there timed out. it also
31
31
  // holds the floating tab bar lens after a tab switch: its springs end on the
32
- // uikit epsilons about 1.1s after the tap, which an 800ms cap could not outlast.
32
+ // uikit epsilons about 1.1s after the tap on a fast host and roughly twice that on a
33
+ // headless software-rendered Linux one, which 800ms and 1500ms caps could not outlast.
33
34
  export function autoWaitBudgetMs(
34
35
  env: Readonly<Record<string, string | undefined>> = process.env,
35
36
  ): number {
36
- return isAgentEnv(env) ? 1500 : 200
37
+ return isAgentEnv(env) ? 3000 : 200
37
38
  }
@@ -24,14 +24,21 @@ export async function runWaitSelectorSubcommand(opts: {
24
24
  .slice(1)
25
25
  .find((value) => !value.startsWith('-'))
26
26
  ?.replace(/^#/, '')
27
- // exactly one of a positional testID or --text names the node
28
- const selector =
29
- text === undefined ? (testId ? { testID: testId } : null) : testId ? null : { text }
30
- if (!selector) {
27
+ // exactly one of a positional or --text names the node. a positional is a
28
+ // testID or the node's visible text, so either finds it.
29
+ const selectors =
30
+ text === undefined
31
+ ? testId
32
+ ? [{ testID: testId }, { text: testId }]
33
+ : null
34
+ : testId
35
+ ? null
36
+ : [{ text }]
37
+ if (!selectors) {
31
38
  console.error(
32
39
  inspectUsage(
33
40
  'selector',
34
- '<testid> | --text <text> [--max-ms 5000 | --timeout 5000] [--gone] [--structural]',
41
+ '<testid-or-text> | --text <text> [--max-ms 5000 | --timeout 5000] [--gone] [--structural]',
35
42
  ),
36
43
  )
37
44
  rnxExit(1)
@@ -41,14 +48,28 @@ export async function runWaitSelectorSubcommand(opts: {
41
48
  const gone = args.includes('--gone')
42
49
  const structural = args.includes('--structural')
43
50
 
51
+ const waits = selectors.map((selector) =>
52
+ inspectWaitSelector(bridge, selector, timeoutMs, { gone, structural }),
53
+ )
54
+ // present: the first selector to match answers. gone: every selector must be absent.
44
55
  const {
45
56
  found,
46
57
  node,
47
58
  elapsed: elapsedMs,
48
- } = await inspectWaitSelector(bridge, selector, timeoutMs, {
49
- gone,
50
- structural,
51
- })
59
+ } = gone
60
+ ? await Promise.all(waits).then((results) => ({
61
+ found: results.every((result) => result.found),
62
+ node: undefined,
63
+ elapsed: Math.max(...results.map((result) => result.elapsed)),
64
+ }))
65
+ : await new Promise<Awaited<(typeof waits)[number]>>((resolve, reject) => {
66
+ let pending = waits.length
67
+ for (const wait of waits)
68
+ wait.then((result) => {
69
+ pending--
70
+ if (result.found || pending === 0) resolve(result)
71
+ }, reject)
72
+ })
52
73
 
53
74
  const elapsed = Math.round(elapsedMs)
54
75
 
@@ -567,6 +567,7 @@ async function runRemoteBox(
567
567
  const { box: created, appFontsWireSha256 } = await box.createPrebuiltBundleBox({
568
568
  bundle: new Uint8Array(artifact.bytes),
569
569
  nativeProjectDir,
570
+ nativeAssets: artifact.nativeAssets,
570
571
  device: selectedDevice,
571
572
  initialUrl: input.initialUrl,
572
573
  name: input.name ?? boxNameForBundle(projectDir ?? input.bundlePath),
@@ -2,6 +2,7 @@
2
2
  // works without project setup; bare first-run onboarding launches ConnectRN
3
3
  // during this flow and leaves the repository choice until the end.
4
4
 
5
+ import { existsSync, readdirSync } from 'node:fs'
5
6
  import os from 'node:os'
6
7
  import path from 'node:path'
7
8
  import { DEFAULT_SOOTSIM_BRIDGE_PORT } from '../../src/bridge-constants'
@@ -52,6 +53,7 @@ import { runInstallDesktop } from './install-desktop'
52
53
  interface SetupOptions {
53
54
  appDir: string
54
55
  ci: boolean
56
+ agentDesktop: boolean
55
57
  dryRun: boolean
56
58
  json: boolean
57
59
  yes: boolean
@@ -287,9 +289,20 @@ function parseSetupOptions(args: string[]): SetupOptions {
287
289
  if (appIndex >= 0 && (!appArg || appArg.startsWith('-'))) {
288
290
  throw new Error('--app requires a directory')
289
291
  }
292
+ const ci = args.includes('--ci') || isCi()
290
293
  return {
291
294
  appDir: path.resolve(appArg ?? process.cwd()),
292
- ci: args.includes('--ci') || isCi() || isAgentEnv(),
295
+ ci: ci || isAgentEnv(),
296
+ // an agent on a machine with a GPU is on someone's desktop, where the
297
+ // background service helps it as much as a person; CI and GPU-less
298
+ // sandboxes skip it. every Mac has one; Linux exposes it as a render node.
299
+ agentDesktop:
300
+ !ci &&
301
+ isAgentEnv() &&
302
+ (process.platform === 'darwin' ||
303
+ (process.platform === 'linux' &&
304
+ existsSync('/dev/dri') &&
305
+ readdirSync('/dev/dri').some((node) => node.startsWith('renderD')))),
293
306
  dryRun: args.includes('--dry-run'),
294
307
  json: args.includes('--json'),
295
308
  yes: args.includes('--yes') || args.includes('-y'),
@@ -338,7 +351,7 @@ async function decideService(
338
351
  options: SetupOptions,
339
352
  status: ReturnType<typeof getDaemonServiceStatus>,
340
353
  ): Promise<boolean> {
341
- if (options.ci) {
354
+ if (options.ci && !options.agentDesktop) {
342
355
  if (options.service === true) throw new Error('--ci cannot install a machine service')
343
356
  return false
344
357
  }
@@ -356,7 +369,7 @@ async function decideService(
356
369
  return true
357
370
  }
358
371
  if (options.service !== undefined) return options.service
359
- if (options.yes || options.dryRun) return true
372
+ if (options.yes || options.dryRun || options.agentDesktop) return true
360
373
  requireInteractive(options, '--service or --no-service')
361
374
  printPromptBlock('Background service', [
362
375
  'Keeps the local bridge and runtime ready between commands.',
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
package/dist-lib/beta.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
package/dist-lib/beta.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/beta.ts
4
4
  var IS_BETA = true;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/bridge-contract.ts
4
4
  var SIM_LONG_PRESS_MAX_MS = 5e3;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1812 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1814 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/bridge-contract.ts
4
4
  var REFUSED_PERFORM_STEP_TYPES = [