peachsim 0.1.1808 → 0.1.1811

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 (229) 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 +95 -53
  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 +60 -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 +70 -52
  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 +42783 -40717
  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 +15819 -15559
  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 +20857 -18756
  64. package/dist-lib/host/fetch-proxy-handler.cjs +10 -10
  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 +588 -544
  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 +25 -19
  80. package/dist-lib/native-app-identity-project.cjs +15 -6
  81. package/dist-lib/native-app-identity-project.mjs +23 -12
  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 +30496 -24309
  101. package/dist-lib/swift-compile.cjs +292 -213
  102. package/dist-lib/swift-compile.mjs +334 -254
  103. package/dist-lib/swift-package.cjs +8 -4
  104. package/dist-lib/swift-package.mjs +8 -4
  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 +32 -1
  108. package/dist-lib/swift.cjs +1 -1
  109. package/dist-lib/vite-swift.cjs +19172 -18941
  110. package/dist-lib/vite.cjs +11 -11
  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/usr/include/dispatch.modulemap +22 -0
  178. package/sdk/ios/usr/include/net/if.h +24 -0
  179. package/sdk/ios/usr/include/sys/time.h +1 -1
  180. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +265 -0
  181. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
  182. package/sdk/ios/wasm/include/fcntl.h +2 -0
  183. package/sdk/ios/wasm/include/pthread.h +3 -0
  184. package/sdk/ios/wasm/include/stdlib.h +2 -0
  185. package/sdk/ios/wasm/include/unistd.h +2 -2
  186. package/skills/contrast/SKILL.md +2 -2
  187. package/src/bundle-channel.mjs +9 -72
  188. package/src/capture-contract.ts +12 -9
  189. package/src/desktop-host-delivery.ts +16 -2
  190. package/src/dev-bundle-resolution.ts +12 -3
  191. package/src/expo-native-workspace.ts +57 -19
  192. package/src/expo-swift-host.ts +17 -12
  193. package/src/expo-swift-ready.ts +4 -1
  194. package/src/expoSwiftContract.ts +1 -0
  195. package/src/home-paths.ts +4 -48
  196. package/src/host/bridge-host.ts +1 -0
  197. package/src/installed-native-libraries.ts +2 -8
  198. package/src/metro-project-root.ts +2 -1
  199. package/src/native-bundles.ts +122 -0
  200. package/src/native-static-libraries.ts +65 -8
  201. package/src/nitro-adapter.lock.json +278 -278
  202. package/src/nitro-bundle.ts +2 -2
  203. package/src/nitro-compile.ts +68 -28
  204. package/src/nitro-source.ts +24 -6
  205. package/src/nitro-superset.lock.json +94 -34
  206. package/src/nitroContract.ts +2 -0
  207. package/src/podspec-sources.ts +1966 -0
  208. package/src/storageSnapshotContract.ts +40 -0
  209. package/src/swift-compile.ts +57 -20
  210. package/src/swift-design-time.ts +18 -1
  211. package/src/swift-distribution.lock.json +11 -11
  212. package/src/swift-distribution.ts +9 -6
  213. package/src/swift-host.ts +1 -2
  214. package/src/swift-objc-standin.ts +316 -112
  215. package/src/swift-package-manifest.ts +4 -3
  216. package/src/swift-package.ts +10 -3
  217. package/src/swift-root-lock.ts +11 -0
  218. package/src/swift-shared-sdk.ts +10 -9
  219. package/src/swift-source-pods.ts +2 -2
  220. package/src/swift-standins.ts +40 -143
  221. package/src/swift-toolchain.ts +42 -0
  222. package/src/swift-wasm-prune.ts +53 -21
  223. package/src/turbo-bundle.ts +2 -2
  224. package/src/turbo-codegen-intake.ts +111 -108
  225. package/src/turbo-compile.ts +63 -33
  226. package/src/turbo-runtime.lock.json +21 -21
  227. package/src/turbo-source.ts +171 -76
  228. package/src/wasm-optimize.ts +31 -2
  229. package/src/xcode-project.ts +36 -3
@@ -1,4 +1,7 @@
1
1
  import { createHash } from 'node:crypto'
2
+ import { mkdtempSync, rmSync, statSync } from 'node:fs'
3
+ import { tmpdir } from 'node:os'
4
+ import { join, resolve } from 'node:path'
2
5
  // `peach ios` and `peach android` — start a simulator on that platform.
3
6
  //
4
7
  // the platform picks the device; the command context picks where the sim runs
@@ -97,7 +100,7 @@ function remoteInputFromArgs(
97
100
  }
98
101
  if (positional.length !== 1 || !positional[0]) {
99
102
  throw new Error(
100
- `usage: peach remote ${platform} <local bundle.js|https://bundle-url> [--device <model>] [--url <link>] [--reuse|--new]`,
103
+ `usage: peach remote ${platform} <app-dir|local bundle.js|https://bundle-url> [--device <model>] [--url <link>] [--reuse|--new]`,
101
104
  )
102
105
  }
103
106
  const reuse = args.includes('--reuse')
@@ -297,9 +300,9 @@ async function runRemoteCreate(
297
300
  },
298
301
  {
299
302
  createCloudSession,
300
- publishCloudSessionToShell,
303
+ publishCloudSession,
301
304
  readCloudSession,
302
- requireCloudSessionShellUpdate,
305
+ cloudSessionShellUpdate,
303
306
  },
304
307
  { openInBrowser },
305
308
  ] = await Promise.all([
@@ -314,7 +317,7 @@ async function runRemoteCreate(
314
317
  input.assetsDirectory,
315
318
  )
316
319
  assertBundleBuiltFor(artifact.bytes, platform, `peach ${platform} --remote`)
317
- const descriptor = requireCloudSessionShellUpdate()
320
+ const descriptor = cloudSessionShellUpdate()
318
321
  const { auth, header } = authHeaderOrExit(
319
322
  `${platform} ${args.includes('--nano') ? '--nano' : '--remote'}`,
320
323
  )
@@ -343,7 +346,7 @@ async function runRemoteCreate(
343
346
  claimId: claimed.claim.id,
344
347
  ...(streamUrl ? { streamUrl } : {}),
345
348
  })
346
- publishCloudSessionToShell(session, descriptor)
349
+ publishCloudSession(session, descriptor)
347
350
  console.log(
348
351
  ` reconnected to remote simulator: ${existingSession.simId} (${platform})`,
349
352
  )
@@ -367,7 +370,7 @@ async function runRemoteCreate(
367
370
  assetsDirectory: input.assetsDirectory,
368
371
  })
369
372
  try {
370
- publishCloudSessionToShell(created.session, descriptor)
373
+ publishCloudSession(created.session, descriptor)
371
374
  } catch (error) {
372
375
  await closeCloudSession(created.session)
373
376
  throw error
@@ -431,26 +434,30 @@ async function runRemoteBox(
431
434
  BoxBootFailedError,
432
435
  closeCloudBox,
433
436
  closeCloudSession,
434
- produceCloudBoxArtifact,
435
437
  awaitBoxBoot,
436
438
  requestBoxWatchUrl,
439
+ shortWatchUrl,
437
440
  },
438
441
  box,
439
442
  { cloudBoxConnectUrl, ensureCloudBoxBrowser, readCloudBoxSession },
440
443
  { authHeaderOrExit, cloudAccountIdOrExit },
444
+ { buildRemoteProjectBundle },
441
445
  {
442
446
  createCloudBoxSession,
443
- publishCloudSessionToShell,
447
+ publishCloudSession,
444
448
  readCloudSession,
445
449
  serializeCloudSession,
446
450
  PEACH_CLOUD_SESSION_ENV,
447
451
  },
452
+ { produceCloudBoxArtifact },
448
453
  ] = await Promise.all([
449
454
  import('../cloud-client'),
450
455
  import('./box'),
451
456
  import('peach-cloud-box/client'),
452
457
  import('../auth'),
458
+ import('../remote-project-bundle'),
453
459
  import('../cloud-session'),
460
+ import('../cloud-box-artifact.ts'),
454
461
  ])
455
462
  const { openInBrowser } = box
456
463
  // an app that cannot boot never gets a simulator, so the box ends with the
@@ -465,17 +472,34 @@ async function runRemoteBox(
465
472
  } catch (error) {
466
473
  if (error instanceof BoxBootFailedError) {
467
474
  await closeCloudBox(session)
468
- try {
469
- publishCloudSessionToShell(null)
470
- } catch {
471
- // no shell update channel is required outside an interactive peach shell
472
- }
475
+ publishCloudSession(null)
473
476
  delete process.env[PEACH_CLOUD_SESSION_ENV]
474
477
  }
475
478
  throw error
476
479
  }
477
480
  }
478
- const artifact = await produceCloudBoxArtifact(input.bundlePath, input.assetsDirectory)
481
+ // an app folder is built here, and its native modules and fonts come from it
482
+ const projectDir =
483
+ !/^https?:/.test(input.bundlePath) &&
484
+ statSync(input.bundlePath, { throwIfNoEntry: false })?.isDirectory()
485
+ ? resolve(input.bundlePath)
486
+ : null
487
+ if (projectDir && (input.assetsDirectory || input.nativeProjectDir))
488
+ throw new Error('--assets and --native-project apply to a prebuilt bundle')
489
+ const nativeProjectDir = projectDir ?? input.nativeProjectDir
490
+ const buildDir = projectDir && mkdtempSync(join(tmpdir(), 'peach-remote-'))
491
+ let artifact: Awaited<ReturnType<typeof produceCloudBoxArtifact>>
492
+ try {
493
+ artifact = await produceCloudBoxArtifact(
494
+ projectDir && buildDir
495
+ ? await buildRemoteProjectBundle(projectDir, platform, buildDir)
496
+ : input.bundlePath,
497
+ platform,
498
+ { assetsDirectory: buildDir || input.assetsDirectory, nativeProjectDir },
499
+ )
500
+ } finally {
501
+ if (buildDir) rmSync(buildDir, { recursive: true, force: true })
502
+ }
479
503
  assertBundleBuiltFor(artifact.bytes, platform, `peach ${command}`)
480
504
  // the session records which bundle a box already holds, so reattaching can
481
505
  // tell the same app from a rebuilt one. the box producer returns no digest
@@ -487,7 +511,7 @@ async function runRemoteBox(
487
511
  // a launch link only means something to an app that is launching, so a box
488
512
  // already running this bundle is never reattached in its place.
489
513
  if (
490
- !input.nativeProjectDir &&
514
+ !nativeProjectDir &&
491
515
  !input.initialUrl &&
492
516
  existingSession?.service === 'box' &&
493
517
  !input.fresh &&
@@ -513,10 +537,15 @@ async function runRemoteBox(
513
537
  await awaitBootOrCloseBox(existingSession)
514
538
  // grants are short-lived, so a reconnect mints a fresh one rather than
515
539
  // reopening whatever url the create printed.
516
- const watchUrl = await requestBoxWatchUrl({
517
- apiOrigin: existingSession.apiOrigin,
518
- boxId: existingSession.boxId,
519
- boxToken: existingSession.boxToken,
540
+ const signedIn = authHeaderOrExit(command)
541
+ const watchUrl = await shortWatchUrl({
542
+ apiOrigin: box.cloudBoxApiOrigin(args, signedIn.auth),
543
+ authHeader: signedIn.header,
544
+ watchUrl: await requestBoxWatchUrl({
545
+ apiOrigin: existingSession.apiOrigin,
546
+ boxId: existingSession.boxId,
547
+ boxToken: existingSession.boxToken,
548
+ }),
520
549
  })
521
550
  console.log(
522
551
  ` reconnected to remote simulator: ${existingSession.boxId} (${platform})`,
@@ -532,20 +561,18 @@ async function runRemoteBox(
532
561
 
533
562
  if (existingSession?.service === 'box') {
534
563
  await closeCloudBox(existingSession)
535
- try {
536
- publishCloudSessionToShell(null)
537
- } catch {
538
- // no shell update channel is required outside an interactive peach shell
539
- }
564
+ // the shell takes exactly one update, the new box's below; until then
565
+ // only the folder forgets the closed one
566
+ publishCloudSession(null, null)
540
567
  } else if (existingSession) {
541
568
  await closeCloudSession(existingSession)
542
569
  }
543
570
  const { box: created, appFontsWireSha256 } = await box.createPrebuiltBundleBox({
544
571
  bundle: new Uint8Array(artifact.bytes),
545
- nativeProjectDir: input.nativeProjectDir,
572
+ nativeProjectDir,
546
573
  device: selectedDevice,
547
574
  initialUrl: input.initialUrl,
548
- name: input.name ?? boxNameForBundle(input.bundlePath),
575
+ name: input.name ?? boxNameForBundle(projectDir ?? input.bundlePath),
549
576
  fresh: input.name === null,
550
577
  endpoint,
551
578
  apiOrigin: box.cloudBoxApiOrigin(args, auth),
@@ -577,13 +604,7 @@ async function runRemoteBox(
577
604
  await closeCloudBox(session)
578
605
  throw error
579
606
  }
580
- let attachedToShell = true
581
- try {
582
- publishCloudSessionToShell(session)
583
- } catch {
584
- // shell update fd not configured
585
- attachedToShell = false
586
- }
607
+ publishCloudSession(session)
587
608
  process.env[PEACH_CLOUD_SESSION_ENV] = serializeCloudSession(session)
588
609
 
589
610
  console.log(` box: ${created.id} (${artifact.bytes.length} bytes)`)
@@ -592,22 +613,21 @@ async function runRemoteBox(
592
613
  console.log(` artifact: sha256:${artifactSha256}`)
593
614
  // the dest directory was chosen by resolving this bundle's descriptors
594
615
  // against it, so say which one won rather than leaving it invisible.
595
- if (artifact.assetsDirectory) console.log(` asset dest: ${artifact.assetsDirectory}`)
616
+ if (artifact.assetsDirectory && !projectDir)
617
+ console.log(` asset dest: ${artifact.assetsDirectory}`)
618
+ if (artifact.nativeProject) console.log(` native modules: ${artifact.nativeProject}`)
596
619
  for (const warning of artifact.warnings) console.warn(` warning: ${warning}`)
597
620
  console.log(REMOTE_COMMANDS_HELP)
598
- // without the shell integration no later command reaches this box, so
599
- // `peach remote close` cannot end it; name the command that does.
600
- if (!attachedToShell) {
601
- console.log(
602
- ` this shell has no Peach integration; the Box bills until: ${rnxPublicBrand.commandName} box delete ${created.id}`,
603
- )
604
- }
605
621
  // the session is published before the grant is minted, so a grant that never
606
622
  // arrives still leaves the box addressable: re-running this command mints it.
607
- const watchUrl = await requestBoxWatchUrl({
608
- apiOrigin: endpoint,
609
- boxId: created.id,
610
- boxToken: created.accessToken ?? '',
623
+ const watchUrl = await shortWatchUrl({
624
+ apiOrigin: box.cloudBoxApiOrigin(args, auth),
625
+ authHeader: header,
626
+ watchUrl: await requestBoxWatchUrl({
627
+ apiOrigin: endpoint,
628
+ boxId: created.id,
629
+ boxToken: created.accessToken ?? '',
630
+ }),
611
631
  })
612
632
  await awaitBootOrCloseBox(session)
613
633
  console.log(` open ${watchUrl}`)
@@ -687,7 +707,7 @@ export async function runRemoteStop(args: string[]): Promise<number> {
687
707
  { authHeaderOrExit, cloudAccountIdOrExit },
688
708
  { stopAccountRemoteSimulator },
689
709
  { cloudBoxApiOrigin },
690
- { publishCloudSessionToShell, readCloudSession, requireCloudSessionShellUpdate },
710
+ { publishCloudSession, readCloudSession, cloudSessionShellUpdate },
691
711
  ] = await Promise.all([
692
712
  import('../auth'),
693
713
  import('../remote-simulators'),
@@ -700,13 +720,11 @@ export async function runRemoteStop(args: string[]): Promise<number> {
700
720
  } catch {
701
721
  current = null
702
722
  }
703
- // stopping the shell's own simulator clears the shell with it, so the
704
- // update channel is required before anything is deleted.
705
- const descriptor =
723
+ // stopping the project's own simulator forgets it, and the shell's with it
724
+ const ownSession =
706
725
  (current?.service === 'sim' && current.simId === simId) ||
707
726
  (current?.service === 'box' && current.boxId === simId)
708
- ? requireCloudSessionShellUpdate()
709
- : null
727
+ const descriptor = ownSession ? cloudSessionShellUpdate() : null
710
728
  const { auth, header } = authHeaderOrExit('remote stop')
711
729
  const accountId = cloudAccountIdOrExit(auth)
712
730
  const deleted = await stopAccountRemoteSimulator(
@@ -723,7 +741,7 @@ export async function runRemoteStop(args: string[]): Promise<number> {
723
741
  )
724
742
  return 1
725
743
  }
726
- if (descriptor !== null) publishCloudSessionToShell(null, descriptor)
744
+ if (ownSession) publishCloudSession(null, descriptor)
727
745
  console.log(` stopped remote simulator: ${deleted.simId}`)
728
746
  return 0
729
747
  } catch (error) {
@@ -1,6 +1,14 @@
1
1
  import { spawn, type ChildProcess } from 'node:child_process'
2
2
  import { createHash } from 'node:crypto'
3
- import { closeSync, mkdtempSync, openSync, readFileSync, rmSync, statSync } from 'node:fs'
3
+ import {
4
+ closeSync,
5
+ existsSync,
6
+ mkdtempSync,
7
+ openSync,
8
+ readFileSync,
9
+ rmSync,
10
+ statSync,
11
+ } from 'node:fs'
4
12
  import { createRequire } from 'node:module'
5
13
  import { createServer } from 'node:net'
6
14
  import { tmpdir } from 'node:os'
@@ -17,6 +25,7 @@ import { authHeaderValue, cloudAccountIdOrExit, resolveCliAuth } from '../auth'
17
25
  import { producePreviewArtifact } from '../cloud-client'
18
26
  import { publishLiveDevStack, type PublishedLiveDevStack } from '../cloud-test-tunnel'
19
27
  import { openUrl } from '../open-url'
28
+ import { PRIVATE_PREVIEW_NOTE } from '../recording-access'
20
29
  import { detectProject } from './detect'
21
30
  import {
22
31
  parseServerMessage,
@@ -34,6 +43,43 @@ function takeValue(args: string[], flag: string): string | null {
34
43
  return value
35
44
  }
36
45
 
46
+ // an `npx expo export` output directory carries metadata.json naming one
47
+ // bundle per exported platform. returns that bundle for the requested platform,
48
+ // or null when the directory is not an expo export at all.
49
+ function resolveExpoExportBundle(
50
+ exportDir: string,
51
+ platform: 'ios' | 'android',
52
+ ): string | null {
53
+ const metadataPath = join(exportDir, 'metadata.json')
54
+ if (!existsSync(metadataPath)) return null
55
+ let metadata: unknown
56
+ try {
57
+ metadata = JSON.parse(readFileSync(metadataPath, 'utf8'))
58
+ } catch {
59
+ return null
60
+ }
61
+ if (!isRecord(metadata) || !isRecord(metadata.fileMetadata)) return null
62
+ const entry = metadata.fileMetadata[platform]
63
+ if (!isRecord(entry) || typeof entry.bundle !== 'string' || !entry.bundle) {
64
+ const exported = Object.keys(metadata.fileMetadata).join(', ') || 'none'
65
+ throw new Error(
66
+ `peach preview found an Expo export in ${exportDir} with no ${platform} bundle (exported: ${exported}). Export with \`npx expo export --platform ${platform} --no-bytecode\`.`,
67
+ )
68
+ }
69
+ if (entry.bundle.endsWith('.hbc')) {
70
+ throw new Error(
71
+ `peach preview cannot preview Hermes bytecode (${entry.bundle}). Export plain JavaScript with \`npx expo export --platform ${platform} --no-bytecode\` and preview the dist directory again.`,
72
+ )
73
+ }
74
+ const bundlePath = join(exportDir, entry.bundle)
75
+ if (!existsSync(bundlePath)) {
76
+ throw new Error(
77
+ `peach preview found an Expo export in ${exportDir} but its ${platform} bundle is missing: ${entry.bundle}. Export again with \`npx expo export --platform ${platform} --no-bytecode\`.`,
78
+ )
79
+ }
80
+ return bundlePath
81
+ }
82
+
37
83
  export async function runPreview(args: string[]): Promise<number> {
38
84
  try {
39
85
  const input = [...args]
@@ -55,7 +101,7 @@ export async function runPreview(args: string[]): Promise<number> {
55
101
  throw new Error('--platform must be ios or android')
56
102
  }
57
103
  if (input.length !== 1 || input[0]?.startsWith('-')) {
58
- throw new Error('usage: peach preview <project-or-bundle>')
104
+ throw new Error('usage: peach preview <project|dist|bundle>')
59
105
  }
60
106
  const auth = resolveCliAuth()
61
107
  if (!auth) throw new Error('peach preview needs `peach login` or PEACH_API_KEY')
@@ -63,24 +109,29 @@ export async function runPreview(args: string[]): Promise<number> {
63
109
 
64
110
  const target = input[0]
65
111
  const projectPath = resolve(target)
112
+ let bundleTarget: string | null = null
66
113
  if (!/^https?:/.test(target) && statSync(projectPath).isDirectory()) {
67
- const receipt = await publishProjectPreview(
68
- projectPath,
69
- platform,
70
- origin,
71
- authHeaderValue(auth),
72
- accountId,
73
- )
74
- if (json) console.log(JSON.stringify(receipt))
75
- else {
76
- console.log(` preview: ${receipt.previewUrl}`)
77
- console.log(` job: ${receipt.jobId}`)
78
- console.log(` artifact: ${JSON.stringify(receipt.artifact)}`)
114
+ const expoBundle = resolveExpoExportBundle(projectPath, platform)
115
+ if (!expoBundle) {
116
+ const receipt = await publishProjectPreview(
117
+ projectPath,
118
+ platform,
119
+ origin,
120
+ authHeaderValue(auth),
121
+ accountId,
122
+ )
123
+ if (json) console.log(JSON.stringify(receipt))
124
+ else {
125
+ console.log(` preview: ${receipt.previewUrl}`)
126
+ console.log(` job: ${receipt.jobId}`)
127
+ console.log(` artifact: ${JSON.stringify(receipt.artifact)}`)
128
+ }
129
+ if (open) await openUrl(receipt.previewUrl)
130
+ return 0
79
131
  }
80
- if (open) await openUrl(receipt.previewUrl)
81
- return 0
132
+ bundleTarget = expoBundle
82
133
  }
83
- const artifact = await producePreviewArtifact(target)
134
+ const artifact = await producePreviewArtifact(bundleTarget ?? target)
84
135
  const bundle = getCliRuntime().preview_compress_node.brotliBundle(artifact.bytes)
85
136
  const initBody: InitRequestBody = {
86
137
  kind: 'build',
@@ -127,11 +178,7 @@ export async function runPreview(args: string[]): Promise<number> {
127
178
  )
128
179
  else {
129
180
  console.log(` preview: ${url}`)
130
- if (finalize.visibility === 'private') {
131
- console.log(
132
- " private: only signed-in members of your account can open it; turn on Public link in the page's share menu to share it",
133
- )
134
- }
181
+ if (finalize.visibility === 'private') console.log(PRIVATE_PREVIEW_NOTE)
135
182
  console.log(
136
183
  ` artifact: sha256:${artifact.sha256} (${artifact.bytes.byteLength} bytes)`,
137
184
  )
@@ -181,10 +228,12 @@ async function publishProjectPreview(
181
228
  throw new Error(
182
229
  `cloud previews are paid from your account balance (${parseServerMessage(await preflight.text()) ?? 'no credit available'}). add credit at ${origin}/billing and run it again.`,
183
230
  )
184
- if (!preflight.ok)
231
+ if (!preflight.ok) {
232
+ const text = await preflight.text()
185
233
  throw new Error(
186
- `hosted build preflight ${preflight.status}: ${await preflight.text()}`,
234
+ `hosted build refused (${preflight.status}): ${parseServerMessage(text) ?? text}`,
187
235
  )
236
+ }
188
237
  const expoRoot = dirname(
189
238
  createRequire(join(projectPath, 'package.json')).resolve('expo/package.json'),
190
239
  )
@@ -18,7 +18,7 @@ import { githubUploadIdentity, resolveCliAuth } from '../auth'
18
18
  import { getCliIdentityKey } from '../current-sim'
19
19
  import { openUrl } from '../open-url'
20
20
  import { previewCaptureKind } from '../preview-capture'
21
- import { ensureCliRecordingEntitlement } from '../recording-access'
21
+ import { ensureCliRecordingEntitlement, PRIVATE_PREVIEW_NOTE } from '../recording-access'
22
22
  import { resolveRunProvenance } from '../run-registry'
23
23
  import { peachExit } from '../run-rnx'
24
24
  import {
@@ -1724,9 +1724,11 @@ async function evalStoreStop(bridge: WsBridge): Promise<boolean | 'pending'> {
1724
1724
 
1725
1725
  interface StoreUploadResult {
1726
1726
  previewUrl?: string
1727
+ previewId?: string
1727
1728
  uploadError?: string
1728
1729
  eventCount?: number
1729
1730
  phases?: Array<{ label: string; ms: number }>
1731
+ visibility?: 'private' | 'public'
1730
1732
  }
1731
1733
 
1732
1734
  async function pollStoreUpload(bridge: WsBridge): Promise<StoreUploadResult> {
@@ -1735,9 +1737,11 @@ async function pollStoreUpload(bridge: WsBridge): Promise<StoreUploadResult> {
1735
1737
  const snap: {
1736
1738
  state: 'idle' | 'recording' | 'processing'
1737
1739
  lastUpload: {
1740
+ id?: string
1738
1741
  previewUrl?: string
1739
1742
  eventCount?: number
1740
1743
  phases?: Array<{ label: string; ms: number }>
1744
+ visibility?: 'private' | 'public'
1741
1745
  } | null
1742
1746
  uploadError: string | null
1743
1747
  uploadRemainingMs: number | null
@@ -1757,8 +1761,10 @@ async function pollStoreUpload(bridge: WsBridge): Promise<StoreUploadResult> {
1757
1761
  if (snap.lastUpload?.previewUrl) {
1758
1762
  return {
1759
1763
  previewUrl: snap.lastUpload.previewUrl,
1764
+ previewId: snap.lastUpload.id,
1760
1765
  eventCount: snap.lastUpload.eventCount,
1761
1766
  phases: snap.lastUpload.phases,
1767
+ visibility: snap.lastUpload.visibility,
1762
1768
  }
1763
1769
  }
1764
1770
  }
@@ -1781,6 +1787,8 @@ function handleStoreUploadResult(
1781
1787
  peachExit(1)
1782
1788
  }
1783
1789
  console.log(` preview: ${result.previewUrl}`)
1790
+ if (result.previewId) console.log(` preview id: ${result.previewId}`)
1791
+ if (result.visibility === 'private') console.log(PRIVATE_PREVIEW_NOTE)
1784
1792
  if (result.phases?.length) {
1785
1793
  console.log(
1786
1794
  ` upload phases: ${result.phases.map(({ label, ms }) => `${label} ${(ms / 1000).toFixed(1)}s`).join(', ')}`,
@@ -1794,7 +1802,7 @@ function handleStoreUploadResult(
1794
1802
  // warning (QA F19-4). say so once so the reuse is a known choice.
1795
1803
  console.log(
1796
1804
  ' note: this URL is content-addressed — re-recording the same bundle\n' +
1797
- ' replaces this capture at the same /preview/<id>.',
1805
+ ' replaces this capture at the same link.',
1798
1806
  )
1799
1807
  // surface how many interaction events were captured (F14-7). without this
1800
1808
  // the CLI gave no signal that an event-capture regression shipped a stale
@@ -2,29 +2,27 @@
2
2
  //
3
3
  // prefers the WS bridge when one is reachable so the screenshot comes from
4
4
  // the user's current sim (and can be cropped to a logical
5
- // rect via --area / --id / --text). falls back to a fresh headless
6
- // chromium when nothing is running, so CI / one-shot capture still works
7
- // without a daemon.
5
+ // rect via --area / --id / --text). with no sim connected it says so and
6
+ // shows how to open one.
8
7
 
9
- import { mkdirSync } from 'fs'
10
- import { dirname, resolve } from 'path'
11
- import { DEFAULT_SOOTSIM_BRIDGE_PORT } from '../../src/bridge-constants'
8
+ import { resolve } from 'path'
12
9
  import { devices, type DeviceModel } from '../../src/device-catalog.ts'
13
- import { launchReapedChrome } from '../../src/reap-browser'
14
10
  import { composeFramedScreenshot } from '../../src/screenshots/frame-compose'
15
11
  import { buildResolveRectEval, type SampleRect } from '../browser-evals'
16
12
  import { createCloudBridgeForParsed } from '../cloud-client'
17
13
  import { peachExit } from '../run-rnx'
18
14
  import { writeScreenshotOutput } from '../screenshot-output'
19
15
  import {
16
+ BridgeHandshakeTimeoutError,
20
17
  callInBridge,
21
18
  checkSimHealth,
22
19
  createBridge,
23
20
  createBridgeFromParsed,
24
- isLiveBridge,
25
21
  parseBridgeCliArgs,
22
+ probeBridge,
26
23
  } from '../ws-bridge'
27
24
  import { inspectCaptureReady, waitReadyReason } from './inspect/core'
25
+ import { printMissingSimHint } from './no-bridge-hint'
28
26
 
29
27
  interface ScreenshotOptions {
30
28
  port?: number
@@ -134,9 +132,9 @@ examples:
134
132
  return
135
133
  }
136
134
  const rect = await parseRect(args)
137
- const usingBridge = await isLiveBridge(parsed.wsPort)
135
+ const probe = await probeBridge(parsed.wsPort)
138
136
 
139
- if (usingBridge) {
137
+ if (probe.live) {
140
138
  // captureViaBridge throws plain Errors for expected conditions (unknown
141
139
  // --id / --text, missing device model). surface them as a one-line
142
140
  // failure instead of an uncaught internal stack trace.
@@ -159,21 +157,20 @@ examples:
159
157
  return
160
158
  }
161
159
 
162
- if (withFrame) {
163
- console.error(' --with-frame requires a running peach bridge')
164
- console.error(' open the app in a live sim first, then rerun the command')
165
- peachExit(1)
166
- }
167
-
168
- if (rect) {
169
- console.error(' --area / --id / --text require a running peach bridge')
160
+ // a port that accepts tcp but never completes the upgrade is a hung or
161
+ // overloaded bridge, not an empty one — the no-sim hint would send the user
162
+ // to open an app on a bridge that cannot answer.
163
+ if (probe.error instanceof BridgeHandshakeTimeoutError) {
164
+ console.error('')
165
+ console.error(` ${probe.error.message}`)
170
166
  console.error(
171
- ' start one with `peach serve`, `peach desktop`, or your project dev server',
167
+ ' the bridge may be hung or overloaded; retry, or restart serve if it persists.',
172
168
  )
173
169
  peachExit(1)
174
170
  }
175
171
 
176
- await runPlaywrightScreenshot(args, opts)
172
+ printMissingSimHint(parsed.wsPort)
173
+ peachExit(1)
177
174
  }
178
175
 
179
176
  async function parseRect(args: string[]): Promise<SampleRect | null> {
@@ -401,7 +398,6 @@ const SCREENSHOT_VALUE_FLAGS = new Set([
401
398
  '--area',
402
399
  '--id',
403
400
  '--text',
404
- '--url',
405
401
  '--port',
406
402
  '--timeout',
407
403
  '--sim',
@@ -483,42 +479,3 @@ function resolveOutputPath(args: string[]): string | undefined {
483
479
  }
484
480
  return undefined
485
481
  }
486
-
487
- // capture a page in headless chromium when no bridge is running.
488
- async function runPlaywrightScreenshot(args: string[], opts: ScreenshotOptions) {
489
- const output = resolveOutputPath(args) || 'peach-screenshot.png'
490
- const url =
491
- args.find((_, i) => args[i - 1] === '--url') ||
492
- `http://localhost:${opts.port || 5173}`
493
-
494
- const { chromium } = await import('playwright')
495
- const browser = await launchReapedChrome((options) => chromium.launch(options), {
496
- headless: true,
497
- })
498
-
499
- try {
500
- const page = await browser.newPage({
501
- viewport: { width: 500, height: 900 },
502
- // this fallback screenshots a page a person opens; state display density
503
- // so the PNG is retina rather than half of what the display shows.
504
- deviceScaleFactor: 2,
505
- })
506
- await page.goto(url, { waitUntil: 'networkidle' })
507
- await page.waitForTimeout(2000)
508
-
509
- const outputPath = resolve(process.cwd(), output)
510
- if (outputPath === '/dev/stdout') {
511
- await writeScreenshotOutput(outputPath, await page.screenshot({ type: 'png' }))
512
- } else {
513
- mkdirSync(dirname(outputPath), { recursive: true })
514
- await page.screenshot({ path: outputPath })
515
- }
516
- console.log(` saved: ${outputPath}`)
517
- await page.close()
518
- } catch (err: any) {
519
- console.error(` screenshot failed: ${err.message}`)
520
- process.exitCode = 1
521
- } finally {
522
- await browser.close()
523
- }
524
- }
@@ -102,7 +102,9 @@ export async function runSetup(
102
102
  console.log(` ${muted('Would enable')} ${accent('the background service')}`)
103
103
  }
104
104
  if (!service && !serviceStatus.installed && !options.json) {
105
- console.log(` ${muted('Enable it later with')} ${accent('peach daemon install')}`)
105
+ console.log(
106
+ ` ${muted('The background service is off; turn it on with')} ${accent('peach daemon install')}`,
107
+ )
106
108
  }
107
109
  const simulatorDriver = await decideSimulatorDriver(options)
108
110
  if (options.dryRun && !options.json) {