peachsim 0.1.1811 → 0.1.1813

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 (106) hide show
  1. package/cli/cloud-box-artifact.ts +31 -9
  2. package/cli/cloud-client.ts +53 -23
  3. package/cli/commands/box/bundle-plane.ts +34 -5
  4. package/cli/commands/box.ts +12 -2
  5. package/cli/commands/control.ts +19 -1
  6. package/cli/commands/platform.ts +12 -18
  7. package/cli/commands/setup.ts +16 -3
  8. package/dist-lib/agent-daemon-client.cjs +1 -1
  9. package/dist-lib/agent-events.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +1 -1
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +1 -1
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +1 -1
  20. package/dist-lib/bundle-channel.cjs +454 -371
  21. package/dist-lib/capture-contract.cjs +1 -1
  22. package/dist-lib/capture-contract.mjs +1 -1
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/config.mjs +1 -1
  31. package/dist-lib/detox/index.cjs +1 -1
  32. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  33. package/dist-lib/expo-swift-bundle.cjs +129 -46
  34. package/dist-lib/expo-swift-metadata.cjs +1 -1
  35. package/dist-lib/expo-swift-metadata.mjs +1 -1
  36. package/dist-lib/home-paths.cjs +1 -1
  37. package/dist-lib/host/bridge-host.cjs +445 -362
  38. package/dist-lib/host/fetch-proxy-handler.cjs +1 -2
  39. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  40. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  41. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  42. package/dist-lib/host/websocket-proxy.cjs +1 -1
  43. package/dist-lib/index.cjs +35 -12
  44. package/dist-lib/jump-to-source-babel.cjs +1 -1
  45. package/dist-lib/jump-to-source-native.cjs +1 -1
  46. package/dist-lib/kotlin-host.cjs +1 -1
  47. package/dist-lib/menu.cjs +1 -1
  48. package/dist-lib/menu.mjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  50. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  51. package/dist-lib/metro-production-bundle.cjs +1 -1
  52. package/dist-lib/metro-production-bundle.mjs +1 -1
  53. package/dist-lib/metro.cjs +35 -12
  54. package/dist-lib/native-app-identity-project.cjs +35 -11
  55. package/dist-lib/native-app-identity-project.mjs +35 -11
  56. package/dist-lib/native-app-identity.cjs +1 -1
  57. package/dist-lib/native-app-identity.mjs +1 -1
  58. package/dist-lib/native-firebase-metadata.cjs +1 -1
  59. package/dist-lib/native-firebase-metadata.mjs +1 -1
  60. package/dist-lib/pdfium-raster.cjs +1 -1
  61. package/dist-lib/pdfium-raster.mjs +1 -1
  62. package/dist-lib/plist.cjs +1 -1
  63. package/dist-lib/plist.mjs +1 -1
  64. package/dist-lib/profiles.cjs +1 -1
  65. package/dist-lib/public-brand.cjs +1 -1
  66. package/dist-lib/public-origins-lib-esm.json +24 -24
  67. package/dist-lib/public-origins-lib.json +54 -54
  68. package/dist-lib/react-native-host-modules.cjs +1 -1
  69. package/dist-lib/react-native-host-modules.mjs +1 -1
  70. package/dist-lib/reap-browser.cjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +1 -1
  73. package/dist-lib/sdk.mjs +1 -1
  74. package/dist-lib/skills.cjs +589 -456
  75. package/dist-lib/swift-compile.cjs +46 -11
  76. package/dist-lib/swift-compile.mjs +46 -11
  77. package/dist-lib/swift-package.cjs +12 -4
  78. package/dist-lib/swift-package.mjs +9 -3
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift-toolchain.cjs +18 -1
  82. package/dist-lib/swift.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +75 -30
  84. package/dist-lib/vite.cjs +1 -2
  85. package/dist-lib/worklet-executable.cjs +1 -1
  86. package/dist-lib/worklet-executable.mjs +1 -1
  87. package/package.json +1 -1
  88. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISlider.h +1 -1
  89. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewController.h +12 -50
  90. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISplitViewControllerLayoutEnvironment.h +2 -8
  91. package/sdk/ios/System/Library/Frameworks/UIKitTypes.framework/Headers/UIKitTypes.h +62 -0
  92. package/sdk/ios/usr/include/module.modulemap +8 -3
  93. package/src/expo-native-workspace.ts +64 -27
  94. package/src/nitro-adapter.lock.json +265 -265
  95. package/src/nitro-superset.lock.json +14 -14
  96. package/src/nitroContract.ts +1 -0
  97. package/src/swift-compile.ts +20 -6
  98. package/src/swift-distribution.lock.json +9 -9
  99. package/src/swift-link-roots.ts +13 -2
  100. package/src/swift-objc-compile.ts +12 -0
  101. package/src/swift-objc-standin.ts +5 -2
  102. package/src/swift-package.ts +21 -1
  103. package/src/swift-toolchain.ts +17 -0
  104. package/src/turbo-bundle.ts +3 -4
  105. package/src/turbo-runtime.lock.json +20 -20
  106. package/src/xcode-project.ts +29 -12
@@ -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
  }
@@ -1741,6 +1741,44 @@ export class BoxBootFailedError extends Error {
1741
1741
  const BOX_DISPLAY_GRANT_WAIT_MS = 180_000
1742
1742
  const BOX_DISPLAY_GRANT_RETRY_MS = 2_000
1743
1743
 
1744
+ // a box's lifecycle as the page's runtime receipts and lost browser
1745
+ // generations record it.
1746
+ async function readBoxLifecycle(options: {
1747
+ apiOrigin: string
1748
+ boxId: string
1749
+ boxToken: string
1750
+ }): Promise<{ generation: unknown; receipts: unknown[]; lostGenerations: number }> {
1751
+ const response = await fetch(
1752
+ `${options.apiOrigin}/v1/boxes/${encodeURIComponent(options.boxId)}/lifecycle`,
1753
+ { headers: { authorization: `Bearer ${options.boxToken}` } },
1754
+ )
1755
+ const text = await response.text()
1756
+ if (!response.ok) throw responseError(response.status, text)
1757
+ const status: unknown = JSON.parse(text)
1758
+ if (!isRecord(status)) return { generation: null, receipts: [], lostGenerations: 0 }
1759
+ return {
1760
+ generation: isRecord(status.browser) ? status.browser.browserGeneration : null,
1761
+ receipts: Array.isArray(status.runtimeReceipts) ? status.runtimeReceipts : [],
1762
+ lostGenerations: Array.isArray(status.recoveries) ? status.recoveries.length : 0,
1763
+ }
1764
+ }
1765
+
1766
+ // the newest boot outcome among receipts that pass the filter, or null while
1767
+ // the app has reported neither loading nor failing.
1768
+ function bootOutcome(
1769
+ receipts: unknown[],
1770
+ include: (receipt: Record<string, unknown>) => boolean,
1771
+ ): { loaded: true } | { loaded: false; error: string } | null {
1772
+ for (const receipt of receipts.toReversed()) {
1773
+ if (!isRecord(receipt) || !include(receipt)) continue
1774
+ if (receipt.kind === 'boot-failed' && typeof receipt.error === 'string') {
1775
+ return { loaded: false, error: receipt.error }
1776
+ }
1777
+ if (receipt.kind === 'loaded' || receipt.kind === 'painted') return { loaded: true }
1778
+ }
1779
+ return null
1780
+ }
1781
+
1744
1782
  // waits for a fresh box's page to load its app or report that the app threw
1745
1783
  // while booting, reading the same runtime receipts the page records. a boot
1746
1784
  // error throws; a slow boot that reports neither within the wait is not an
@@ -1752,28 +1790,13 @@ export async function awaitBoxBoot(options: {
1752
1790
  }): Promise<void> {
1753
1791
  const started = Date.now()
1754
1792
  while (Date.now() - started < BOX_DISPLAY_GRANT_WAIT_MS) {
1755
- const response = await fetch(
1756
- `${options.apiOrigin}/v1/boxes/${encodeURIComponent(options.boxId)}/lifecycle`,
1757
- { headers: { authorization: `Bearer ${options.boxToken}` } },
1793
+ const { generation, receipts } = await readBoxLifecycle(options)
1794
+ const outcome = bootOutcome(
1795
+ receipts,
1796
+ (receipt) => receipt.browserGeneration === generation,
1758
1797
  )
1759
- const text = await response.text()
1760
- if (!response.ok) throw responseError(response.status, text)
1761
- const status: unknown = JSON.parse(text)
1762
- const generation =
1763
- isRecord(status) && isRecord(status.browser)
1764
- ? status.browser.browserGeneration
1765
- : null
1766
- const receipts =
1767
- isRecord(status) && Array.isArray(status.runtimeReceipts)
1768
- ? status.runtimeReceipts
1769
- : []
1770
- for (const receipt of receipts.toReversed()) {
1771
- if (!isRecord(receipt) || receipt.browserGeneration !== generation) continue
1772
- if (receipt.kind === 'boot-failed' && typeof receipt.error === 'string') {
1773
- throw new BoxBootFailedError(options.boxId, receipt.error)
1774
- }
1775
- if (receipt.kind === 'loaded' || receipt.kind === 'painted') return
1776
- }
1798
+ if (outcome?.loaded) return
1799
+ if (outcome) throw new BoxBootFailedError(options.boxId, outcome.error)
1777
1800
  await new Promise((resolve) => setTimeout(resolve, BOX_DISPLAY_GRANT_RETRY_MS))
1778
1801
  }
1779
1802
  }
@@ -1816,10 +1839,17 @@ export async function requestBoxWatchUrl(options: {
1816
1839
  failureSentence(text) === 'no simulator is hosting this box'
1817
1840
  ) {
1818
1841
  // the page has not attached its simulator yet. this is the normal state
1819
- // right after a create, so wait rather than refusing.
1842
+ // right after a create, so wait rather than refusing, unless a page of
1843
+ // any browser generation already reported that the app cannot boot.
1844
+ const lifecycle = await readBoxLifecycle(options)
1845
+ const outcome = bootOutcome(lifecycle.receipts, () => true)
1846
+ if (outcome && !outcome.loaded)
1847
+ throw new BoxBootFailedError(options.boxId, outcome.error)
1820
1848
  if (Date.now() - started >= BOX_DISPLAY_GRANT_WAIT_MS) {
1821
1849
  throw new Error(
1822
- `box ${options.boxId} has no simulator hosting it yet; try again once its page has booted`,
1850
+ lifecycle.lostGenerations > 0
1851
+ ? `box ${options.boxId} has no simulator hosting it: its page's browser was lost ${lifecycle.lostGenerations} time(s) before the app reported loading or failing`
1852
+ : `box ${options.boxId} has no simulator hosting it yet; try again once its page has booted`,
1823
1853
  )
1824
1854
  }
1825
1855
  await new Promise((resolve) => setTimeout(resolve, BOX_DISPLAY_GRANT_RETRY_MS))
@@ -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,
@@ -50,6 +50,7 @@ import { applyHotMode } from '../../src/native-dev-bundle-url'
50
50
  import { isProcessRunning } from '../../src/process-liveness'
51
51
  import { ensureProfile } from '../../src/profiles'
52
52
  import {
53
+ resolveDevCheckoutRuntimeAssetRoot,
53
54
  resolveDevCheckoutRuntimeRoot,
54
55
  runtimeVersionHostname,
55
56
  } from '../../src/runtime-assets'
@@ -78,6 +79,7 @@ import { diagnosticsAllowedForCurrentProcess, isCi } from '../privacy'
78
79
  import { rethrowIfExit, peachExit } from '../run-rnx'
79
80
  import { collectRuntimeDiagnostics } from '../runtime-diagnostics'
80
81
  import { rnxSelfInvocation } from '../self-invocation'
82
+ import { accent, muted, warning } from '../ui'
81
83
  import {
82
84
  BRIDGE_VALUE_FLAGS,
83
85
  BridgeSimLockedError,
@@ -93,7 +95,7 @@ import {
93
95
  type ParsedBridgeCliArgs,
94
96
  type WsBridge,
95
97
  } from '../ws-bridge'
96
- import { retireIdleBridge } from './daemon'
98
+ import { getDaemonServiceStatus, retireIdleBridge } from './daemon'
97
99
  import { inspectDescribe, inspectReadySnapshot, waitReadyReason } from './inspect/core'
98
100
  import { waitForSimReady } from './inspect/shared'
99
101
  import { runInstallDesktop } from './install-desktop'
@@ -388,6 +390,14 @@ async function connectBridgeForOpen(
388
390
  // starting a bridge needs ready local assets; an existing bridge gets
389
391
  // to finish its own install before the caller validates them.
390
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
+ }
391
401
  const { executable, prefixArgs } = rnxSelfInvocation()
392
402
  // the bridge outlives open, so it must not hold the command's captured stderr.
393
403
  const bridgeLogPath = path.join(
@@ -581,6 +591,14 @@ export async function ensureRuntimeForOpen() {
581
591
  // a dev checkout serves its own build; staging a published runtime into an
582
592
  // isolated home would make the daemon serve that instead.
583
593
  if (resolveDevCheckoutRuntimeRoot()) return
594
+ // a checkout with no engine build serves the installed runtime, whose engine
595
+ // predates this checkout's launch metadata and Swift output, so say so before
596
+ // its failures read like app bugs.
597
+ if (resolveDevCheckoutRuntimeAssetRoot()) {
598
+ console.error(
599
+ ` this checkout has no engine build, so the installed runtime serves it; run \`bun run build:peach\` to test this checkout's engine`,
600
+ )
601
+ }
584
602
  const active = readActiveRuntime()
585
603
  if (active && fs.existsSync(path.join(runtimeDir(active), 'index.html'))) return
586
604
  // a populated home without a ready active runtime may still be staging.
@@ -462,13 +462,12 @@ async function runRemoteBox(
462
462
  const { openInBrowser } = box
463
463
  // an app that cannot boot never gets a simulator, so the box ends with the
464
464
  // error instead of billing until someone finds it.
465
- const awaitBootOrCloseBox = async (session: CloudBoxSession) => {
465
+ const closeBoxOnBootFailure = async <T>(
466
+ session: CloudBoxSession,
467
+ work: () => Promise<T>,
468
+ ): Promise<T> => {
466
469
  try {
467
- await awaitBoxBoot({
468
- apiOrigin: session.apiOrigin,
469
- boxId: session.boxId,
470
- boxToken: session.boxToken,
471
- })
470
+ return await work()
472
471
  } catch (error) {
473
472
  if (error instanceof BoxBootFailedError) {
474
473
  await closeCloudBox(session)
@@ -534,18 +533,16 @@ async function runRemoteBox(
534
533
  })
535
534
  // a lapsed tab reboots the app, so a reconnect reads that boot's outcome
536
535
  // before waiting on a simulator a throwing app never attaches.
537
- await awaitBootOrCloseBox(existingSession)
536
+ await closeBoxOnBootFailure(existingSession, () => awaitBoxBoot(existingSession))
538
537
  // grants are short-lived, so a reconnect mints a fresh one rather than
539
538
  // reopening whatever url the create printed.
540
539
  const signedIn = authHeaderOrExit(command)
541
540
  const watchUrl = await shortWatchUrl({
542
541
  apiOrigin: box.cloudBoxApiOrigin(args, signedIn.auth),
543
542
  authHeader: signedIn.header,
544
- watchUrl: await requestBoxWatchUrl({
545
- apiOrigin: existingSession.apiOrigin,
546
- boxId: existingSession.boxId,
547
- boxToken: existingSession.boxToken,
548
- }),
543
+ watchUrl: await closeBoxOnBootFailure(existingSession, () =>
544
+ requestBoxWatchUrl(existingSession),
545
+ ),
549
546
  })
550
547
  console.log(
551
548
  ` reconnected to remote simulator: ${existingSession.boxId} (${platform})`,
@@ -570,6 +567,7 @@ async function runRemoteBox(
570
567
  const { box: created, appFontsWireSha256 } = await box.createPrebuiltBundleBox({
571
568
  bundle: new Uint8Array(artifact.bytes),
572
569
  nativeProjectDir,
570
+ nativeAssets: artifact.nativeAssets,
573
571
  device: selectedDevice,
574
572
  initialUrl: input.initialUrl,
575
573
  name: input.name ?? boxNameForBundle(projectDir ?? input.bundlePath),
@@ -623,13 +621,9 @@ async function runRemoteBox(
623
621
  const watchUrl = await shortWatchUrl({
624
622
  apiOrigin: box.cloudBoxApiOrigin(args, auth),
625
623
  authHeader: header,
626
- watchUrl: await requestBoxWatchUrl({
627
- apiOrigin: endpoint,
628
- boxId: created.id,
629
- boxToken: created.accessToken ?? '',
630
- }),
624
+ watchUrl: await closeBoxOnBootFailure(session, () => requestBoxWatchUrl(session)),
631
625
  })
632
- await awaitBootOrCloseBox(session)
626
+ await closeBoxOnBootFailure(session, () => awaitBoxBoot(session))
633
627
  console.log(` open ${watchUrl}`)
634
628
  return openInBrowser(watchUrl)
635
629
  }
@@ -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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (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.1811 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1813 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/bridge-contract.ts
4
4
  var REFUSED_PERFORM_STEP_TYPES = [