peachsim 0.1.2270 → 0.1.2271

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 (100) hide show
  1. package/cli/app-catalog.ts +13 -5
  2. package/cli/bridge-flow-runner.ts +1 -1
  3. package/cli/commands/control.ts +10 -1
  4. package/cli/commands/flow.ts +117 -23
  5. package/cli/commands/shell-url.ts +10 -2
  6. package/cli/commands/upload.ts +49 -39
  7. package/dist-lib/agent-daemon-client.cjs +1 -1
  8. package/dist-lib/agent-events.cjs +1 -1
  9. package/dist-lib/attached-projects.cjs +1 -1
  10. package/dist-lib/auth/shared-session.cjs +1 -1
  11. package/dist-lib/backend-origin.cjs +1 -1
  12. package/dist-lib/beta.cjs +1 -1
  13. package/dist-lib/beta.mjs +1 -1
  14. package/dist-lib/bridge-constants.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.mjs +1 -1
  17. package/dist-lib/bridge-contract.cjs +1 -1
  18. package/dist-lib/bridge-contract.mjs +1 -1
  19. package/dist-lib/bundle-channel.cjs +43 -57
  20. package/dist-lib/capture-contract.cjs +1 -1
  21. package/dist-lib/capture-contract.mjs +1 -1
  22. package/dist-lib/cloud-contract.cjs +1 -1
  23. package/dist-lib/cloud-contract.mjs +1 -1
  24. package/dist-lib/cloud-test-args.cjs +1 -1
  25. package/dist-lib/cloud-test-args.mjs +1 -1
  26. package/dist-lib/cloud.cjs +1 -1
  27. package/dist-lib/cloud.mjs +1 -1
  28. package/dist-lib/config.cjs +1 -1
  29. package/dist-lib/config.mjs +1 -1
  30. package/dist-lib/detox/index.cjs +2 -2
  31. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  32. package/dist-lib/expo-swift-bundle.cjs +32 -49
  33. package/dist-lib/expo-swift-metadata.cjs +1 -1
  34. package/dist-lib/expo-swift-metadata.mjs +1 -1
  35. package/dist-lib/home-paths.cjs +1 -1
  36. package/dist-lib/host/bridge-host.cjs +38 -55
  37. package/dist-lib/host/fetch-proxy-handler.cjs +6 -6
  38. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  39. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  40. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  41. package/dist-lib/host/websocket-proxy.cjs +1 -1
  42. package/dist-lib/index.cjs +6 -6
  43. package/dist-lib/jump-to-source-babel.cjs +1 -1
  44. package/dist-lib/jump-to-source-native.cjs +1 -1
  45. package/dist-lib/kotlin-host.cjs +1 -1
  46. package/dist-lib/menu.cjs +1 -1
  47. package/dist-lib/menu.mjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  50. package/dist-lib/metro-production-bundle.cjs +1 -1
  51. package/dist-lib/metro-production-bundle.mjs +1 -1
  52. package/dist-lib/metro.cjs +6 -6
  53. package/dist-lib/native-app-identity-project.cjs +3 -3
  54. package/dist-lib/native-app-identity-project.mjs +3 -3
  55. package/dist-lib/native-app-identity.cjs +1 -1
  56. package/dist-lib/native-app-identity.mjs +1 -1
  57. package/dist-lib/native-firebase-metadata.cjs +1 -1
  58. package/dist-lib/native-firebase-metadata.mjs +1 -1
  59. package/dist-lib/pdfium-raster.cjs +1 -1
  60. package/dist-lib/pdfium-raster.mjs +1 -1
  61. package/dist-lib/plist.cjs +1 -1
  62. package/dist-lib/plist.mjs +1 -1
  63. package/dist-lib/profiles.cjs +1 -1
  64. package/dist-lib/public-brand.cjs +1 -1
  65. package/dist-lib/public-origins-lib-esm.json +24 -24
  66. package/dist-lib/public-origins-lib.json +53 -53
  67. package/dist-lib/react-native-host-modules.cjs +1 -1
  68. package/dist-lib/react-native-host-modules.mjs +1 -1
  69. package/dist-lib/reap-browser.cjs +1 -1
  70. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  71. package/dist-lib/sdk.cjs +1 -1
  72. package/dist-lib/sdk.mjs +1 -1
  73. package/dist-lib/skills.cjs +51 -62
  74. package/dist-lib/swift-compile.cjs +23 -12
  75. package/dist-lib/swift-compile.mjs +23 -12
  76. package/dist-lib/swift-package.cjs +1 -1
  77. package/dist-lib/swift-package.mjs +1 -1
  78. package/dist-lib/swift-submit.cjs +1 -1
  79. package/dist-lib/swift-submit.mjs +1 -1
  80. package/dist-lib/swift-toolchain.cjs +22 -11
  81. package/dist-lib/swift.cjs +1 -1
  82. package/dist-lib/vite-swift.cjs +25 -14
  83. package/dist-lib/vite.cjs +6 -6
  84. package/dist-lib/worklet-executable.cjs +1 -1
  85. package/dist-lib/worklet-executable.mjs +1 -1
  86. package/dist-types/packages/peach-engine/src/engine/layout-engine.d.ts +1 -1
  87. package/dist-types/packages/peach-engine/src/engine/yoga-layout.d.ts +1 -0
  88. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  89. package/dist-types/packages/peach-globals/src/recordingBridgeContract.d.ts +12 -0
  90. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  91. package/dist-types/packages/peach-kit/src/ui/hosting-safe-area.d.ts +1 -0
  92. package/dist-types/packages/peach-kit/src/ui/popover-placement.d.ts +1 -0
  93. package/package.json +1 -1
  94. package/runtime-companion.json +1 -1
  95. package/src/nitro-adapter.lock.json +279 -279
  96. package/src/nitro-superset.lock.json +4 -4
  97. package/src/swift-distribution.lock.json +12 -11
  98. package/src/swift-toolchain.ts +24 -10
  99. package/src/turbo-runtime.lock.json +22 -22
  100. package/src/turbo-source.ts +4 -32
@@ -174,11 +174,12 @@ export function oneDeclaredAppCatalog(
174
174
  return catalog
175
175
  }
176
176
 
177
- // a running dev server reports the declaration from its evaluated config
178
- export async function discoverOneNativeAppCatalog(
177
+ // a running dev server reports the declaration from its evaluated config. a
178
+ // server busy with its first bundle build answers late, so `peach open` asks
179
+ // before it requests the bundle.
180
+ export async function fetchOneNativeAppCatalogDeclaration(
179
181
  metroOrigin: string,
180
- assetOrigin: string,
181
- ): Promise<AppCatalog | null> {
182
+ ): Promise<OneNativeAppCatalog | null> {
182
183
  const response = await fetch(`${metroOrigin}${ONE_NATIVE_APP_CATALOG_ROUTE}`, {
183
184
  signal: AbortSignal.timeout(1500),
184
185
  }).catch(() => null)
@@ -187,7 +188,14 @@ export async function discoverOneNativeAppCatalog(
187
188
  !(response.headers.get('content-type') ?? '').toLowerCase().includes('json')
188
189
  )
189
190
  return null
190
- const declared = parseOneNativeAppCatalog(await response.json().catch(() => null))
191
+ return parseOneNativeAppCatalog(await response.json().catch(() => null))
192
+ }
193
+
194
+ export async function discoverOneNativeAppCatalog(
195
+ metroOrigin: string,
196
+ assetOrigin: string,
197
+ ): Promise<AppCatalog | null> {
198
+ const declared = await fetchOneNativeAppCatalogDeclaration(metroOrigin)
191
199
  return declared ? oneDeclaredAppCatalog(declared, assetOrigin) : null
192
200
  }
193
201
 
@@ -1447,7 +1447,7 @@ export class SootSimBridgeFlowRunner {
1447
1447
  }
1448
1448
  const value = (step as Record<string, unknown>)[stepName]
1449
1449
  if (typeof value === 'string') return value.slice(0, 80)
1450
- if (typeof value === 'number' || typeof value === 'boolean') return String(value)
1450
+ if (typeof value === 'number') return String(value)
1451
1451
  if (Array.isArray(value)) return value.map(String).join(', ').slice(0, 80)
1452
1452
  if (!value || typeof value !== 'object') return undefined
1453
1453
  const record = value as Record<string, unknown>
@@ -13,7 +13,7 @@ import { buildPermissionSeedScript } from '../../detox/launch-permissions'
13
13
  import { ANDROID_ROOT_MODULE_QUERY_PARAM } from '../../src/androidRootModuleContract'
14
14
  import { loadRNXAppConfig } from '../../src/app-config'
15
15
  import { isAppDeepLinkTarget, openAppUrl } from '../../src/app-url'
16
- import { isLoopbackHost } from '../../src/backend-origin'
16
+ import { isLoopbackHost, loopbackOriginOf } from '../../src/backend-origin'
17
17
  import { ensureCliCompanion, getCliRuntime } from '../../src/cli-runtime.ts'
18
18
  import { getCliVersion } from '../../src/cli-version'
19
19
  import {
@@ -62,6 +62,7 @@ import {
62
62
  } from '../../src/runtime-assets'
63
63
  import { rnxRuntime } from '../../src/runtime-delivery'
64
64
  import { sleep } from '../../src/sleep'
65
+ import { fetchOneNativeAppCatalogDeclaration } from '../app-catalog'
65
66
  import { findExpoAppConfig } from '../app-project'
66
67
  import { discoverOneNativeAppSplash } from '../app-splash'
67
68
  import { extractAppBinaryBundle, isAppBinaryPath } from '../binary-sidecar'
@@ -1791,6 +1792,13 @@ async function openSim(
1791
1792
  resolvedBundle && project && !findExpoAppConfig(project.appDir)
1792
1793
  ? discoverOneNativeAppSplash(resolvedBundle.bundleUrl)
1793
1794
  : undefined
1795
+ const oneAppCatalogOrigin =
1796
+ resolvedBundle && project && !findExpoAppConfig(project.appDir)
1797
+ ? loopbackOriginOf(resolvedBundle.bundleUrl)
1798
+ : null
1799
+ const oneAppCatalog = oneAppCatalogOrigin
1800
+ ? fetchOneNativeAppCatalogDeclaration(oneAppCatalogOrigin)
1801
+ : undefined
1794
1802
  const explicitBaseUrl = args.find((_, i) => args[i - 1] === '--base-url')
1795
1803
  const baseUrlConfig = explicitBaseUrl
1796
1804
  ? readPeachConfigFromSearchParams(new URL(explicitBaseUrl).searchParams)
@@ -2077,6 +2085,7 @@ async function openSim(
2077
2085
  resolvedBundle,
2078
2086
  project,
2079
2087
  oneAppSplash,
2088
+ oneAppCatalog,
2080
2089
  proof: args.includes('--proof'),
2081
2090
  ephemeral: ephemeralProfile,
2082
2091
  env: envArgs.length ? envArgs : undefined,
@@ -38,6 +38,7 @@ import {
38
38
  parseBridgeCliArgs,
39
39
  resolveBridgePortForPin,
40
40
  worldForBridgePort,
41
+ type WsBridge,
41
42
  } from '../ws-bridge'
42
43
  import {
43
44
  closeSimsBulk,
@@ -50,6 +51,7 @@ import { getShellState } from './inspect/shared'
50
51
  import { resolveDefaultUploadOrigin } from './upload'
51
52
  import type { PeachConfig } from '../../src/config'
52
53
  import type { UploadResult } from './upload'
54
+ import type { SootSimRecordedPreviewSnapshot } from '@peach/globals'
53
55
  import type { ProfileFile } from '@peach/globals/profiler'
54
56
 
55
57
  export { parseFlowFile, validateFlowFile } from '../flow-file'
@@ -882,6 +884,8 @@ flow extension:
882
884
  let scenePath: string | null = null
883
885
  let previewRecordingStartedAtMs: number | null = null
884
886
  let previewScreenshotPath: string | null = null
887
+ let previewFinalCapturedAtMs: number | null = null
888
+ let recordedPreviewSnapshots: FlowSnapshotManifestEntry[] = []
885
889
  let failureBundleDir: string | null = null
886
890
  let exitCode = 0
887
891
  const dryRun = args.includes('--dry-run') || args.includes('--no-run')
@@ -996,12 +1000,18 @@ flow extension:
996
1000
  })()`,
997
1001
  })) as Array<Record<string, any>>
998
1002
  console.log(` captured ${capturedEvents.length} replay events`)
1003
+ recordedPreviewSnapshots = await drainRecorderSnapshots(
1004
+ bridge,
1005
+ driver.simId,
1006
+ screenshotDir,
1007
+ )
999
1008
  if (sceneRecording) {
1000
1009
  sceneRecording = false
1001
1010
  scenePath = await stopPreviewSceneRecording(bridge, driver.simId)
1002
1011
  }
1003
1012
  previewScreenshotPath = path.join(screenshotDir, 'preview-final.png')
1004
1013
  await driver.captureScreenshot(previewScreenshotPath)
1014
+ previewFinalCapturedAtMs = Date.now()
1005
1015
  console.log(` final screenshot: ${previewScreenshotPath}`)
1006
1016
  }
1007
1017
 
@@ -1051,6 +1061,11 @@ flow extension:
1051
1061
  })()`,
1052
1062
  })) as Array<Record<string, any>>
1053
1063
  console.log(` captured ${capturedEvents.length} partial replay events`)
1064
+ recordedPreviewSnapshots = await drainRecorderSnapshots(
1065
+ bridge,
1066
+ driver.simId,
1067
+ screenshotDir,
1068
+ )
1054
1069
  } catch (eventErr: any) {
1055
1070
  console.warn(
1056
1071
  ` event recorder stop failed: ${eventErr?.message || String(eventErr)}`,
@@ -1134,9 +1149,6 @@ flow extension:
1134
1149
  // catches up.
1135
1150
  if (videoPath) uploadArgs.push('--video', videoPath)
1136
1151
  if (scenePath) uploadArgs.push('--scene', scenePath, '--live-bundle')
1137
- if (previewScreenshotPath) {
1138
- uploadArgs.push('--screenshot', previewScreenshotPath)
1139
- }
1140
1152
  if (videoPath && videoDurationMs && Number.isFinite(videoDurationMs)) {
1141
1153
  uploadArgs.push('--video-duration-ms', String(Math.round(videoDurationMs)))
1142
1154
  uploadArgs.push('--recorded-duration-ms', String(Math.round(videoDurationMs)))
@@ -1171,10 +1183,15 @@ flow extension:
1171
1183
  await prepareFlowStepTimelineFile(flowTraceSteps),
1172
1184
  )
1173
1185
  }
1174
- const snapshotManifest = await prepareFlowSnapshotManifest(
1175
- flowTraceSteps,
1186
+ const snapshotManifest = await prepareFlowSnapshotManifest({
1187
+ steps: flowTraceSteps,
1176
1188
  recordingStartedAtMs,
1177
- )
1189
+ recorded: recordedPreviewSnapshots,
1190
+ final:
1191
+ previewScreenshotPath && previewFinalCapturedAtMs
1192
+ ? { path: previewScreenshotPath, capturedAtMs: previewFinalCapturedAtMs }
1193
+ : null,
1194
+ })
1178
1195
  if (snapshotManifest) {
1179
1196
  uploadArgs.push('--snapshot-manifest', snapshotManifest)
1180
1197
  }
@@ -1415,24 +1432,101 @@ async function prepareFlowStepTimelineFile(
1415
1432
  return outPath
1416
1433
  }
1417
1434
 
1418
- async function prepareFlowSnapshotManifest(
1419
- steps: SootSimFlowTraceStep[],
1420
- recordingStartedAtMs: number | null,
1421
- ): Promise<string | null> {
1422
- if (!recordingStartedAtMs) return null
1423
- const snapshots = steps.flatMap((step) =>
1424
- step.screenshotPath
1425
- ? [
1426
- {
1427
- id: `flow-step-${step.stepIndex}`,
1428
- label: step.targetLabel ?? `Step ${step.stepIndex + 1}`,
1429
- kind: 'interaction',
1430
- t: Math.max(0, step.endedAtMs - recordingStartedAtMs),
1431
- path: step.screenshotPath,
1432
- },
1433
- ]
1434
- : [],
1435
+ type FlowSnapshotManifestEntry = {
1436
+ id: string
1437
+ label: string
1438
+ kind: SootSimRecordedPreviewSnapshot['kind']
1439
+ t?: number
1440
+ eventIndex?: number
1441
+ width?: number
1442
+ height?: number
1443
+ contentType: SootSimRecordedPreviewSnapshot['contentType']
1444
+ path: string
1445
+ }
1446
+
1447
+ function isRecordedPreviewSnapshot(
1448
+ value: unknown,
1449
+ ): value is SootSimRecordedPreviewSnapshot {
1450
+ if (value === null || typeof value !== 'object') return false
1451
+ const id = Reflect.get(value, 'id')
1452
+ const contentType = Reflect.get(value, 'contentType')
1453
+ return (
1454
+ typeof id === 'string' &&
1455
+ /^[\w-]+$/.test(id) &&
1456
+ typeof Reflect.get(value, 'base64') === 'string' &&
1457
+ (contentType === 'image/png' || contentType === 'image/webp')
1435
1458
  )
1459
+ }
1460
+
1461
+ // the page's event recorder holds the settled landing and per-interaction
1462
+ // frames; drain them to files so the upload carries them beside the runner's
1463
+ // own captures.
1464
+ async function drainRecorderSnapshots(
1465
+ bridge: WsBridge,
1466
+ simId: string | undefined,
1467
+ dir: string,
1468
+ ): Promise<FlowSnapshotManifestEntry[]> {
1469
+ const drained: unknown = await bridge.send({
1470
+ type: 'evaluate',
1471
+ simId,
1472
+ code: `(() => {
1473
+ const r = globalThis.SootSim?.bridges?.eventRecorder ?? globalThis.__sootsimEventRecorder
1474
+ return r?.drainSnapshots?.() ?? []
1475
+ })()`,
1476
+ })
1477
+ if (!Array.isArray(drained) || !drained.every(isRecordedPreviewSnapshot)) {
1478
+ throw new Error('event recorder returned an invalid snapshot list')
1479
+ }
1480
+ fs.mkdirSync(dir, { recursive: true })
1481
+ const entries = drained.map((snapshot) => {
1482
+ const extension = snapshot.contentType === 'image/webp' ? 'webp' : 'png'
1483
+ const filePath = path.join(dir, `preview-${snapshot.id}.${extension}`)
1484
+ fs.writeFileSync(filePath, Buffer.from(snapshot.base64, 'base64'))
1485
+ const { base64: _base64, ...meta } = snapshot
1486
+ return { ...meta, path: filePath }
1487
+ })
1488
+ console.log(` recorder snapshots: ${entries.length}`)
1489
+ return entries
1490
+ }
1491
+
1492
+ async function prepareFlowSnapshotManifest(input: {
1493
+ steps: SootSimFlowTraceStep[]
1494
+ recordingStartedAtMs: number | null
1495
+ recorded: FlowSnapshotManifestEntry[]
1496
+ final: { path: string; capturedAtMs: number } | null
1497
+ }): Promise<string | null> {
1498
+ const { recordingStartedAtMs } = input
1499
+ const runnerSnapshots: FlowSnapshotManifestEntry[] = recordingStartedAtMs
1500
+ ? input.steps.flatMap<FlowSnapshotManifestEntry>((step) =>
1501
+ step.screenshotPath
1502
+ ? [
1503
+ {
1504
+ id: `flow-step-${step.stepIndex}`,
1505
+ label: step.targetLabel ?? `Step ${step.stepIndex + 1}`,
1506
+ kind: 'interaction',
1507
+ t: Math.max(0, step.endedAtMs - recordingStartedAtMs),
1508
+ contentType: 'image/png',
1509
+ path: step.screenshotPath,
1510
+ },
1511
+ ]
1512
+ : [],
1513
+ )
1514
+ : []
1515
+ const finalSnapshot: FlowSnapshotManifestEntry[] = input.final
1516
+ ? [
1517
+ {
1518
+ id: 'final',
1519
+ label: 'Final frame',
1520
+ kind: 'final',
1521
+ ...(recordingStartedAtMs
1522
+ ? { t: Math.max(0, input.final.capturedAtMs - recordingStartedAtMs) }
1523
+ : {}),
1524
+ contentType: 'image/png',
1525
+ path: input.final.path,
1526
+ },
1527
+ ]
1528
+ : []
1529
+ const snapshots = [...input.recorded, ...runnerSnapshots, ...finalSnapshot]
1436
1530
  if (snapshots.length === 0) return null
1437
1531
  const outPath = path.join(tmpdir(), `peach-flow-snapshots-${Date.now()}.json`)
1438
1532
  fs.writeFileSync(outPath, JSON.stringify(snapshots))
@@ -55,7 +55,8 @@ import { sleep } from '../../src/sleep'
55
55
  import { stageAppBundleResources } from '../app-bundle-resources'
56
56
  import {
57
57
  discoverAppCatalog,
58
- discoverOneNativeAppCatalog,
58
+ fetchOneNativeAppCatalogDeclaration,
59
+ oneDeclaredAppCatalog,
59
60
  discoverProjectOneNativeAppCatalog,
60
61
  } from '../app-catalog'
61
62
  import { discoverNativeLinkedAppFonts } from '../app-fonts'
@@ -79,6 +80,7 @@ import {
79
80
  } from '../ws-bridge'
80
81
  import { readExpoNativeRenderer, readNativeProjectRenderer } from './detect'
81
82
  import type { NitroBuildConfiguration } from '../../src/nitroContract'
83
+ import type { OneNativeAppCatalog } from '../../src/one-native-app-catalog'
82
84
 
83
85
  // built-in shell apps use pathname-based routing, not ?bundle= params
84
86
  const SHELL_APPS: Record<string, string> = {
@@ -469,6 +471,7 @@ async function stampAppCatalog(
469
471
  urlStr: string,
470
472
  assetOrigin: string,
471
473
  project?: ResolvedAppProject | null,
474
+ oneAppCatalog?: Promise<OneNativeAppCatalog | null>,
472
475
  ): Promise<string> {
473
476
  const url = new URL(urlStr)
474
477
  const bundleUrl = url.searchParams.get('bundle') ?? ''
@@ -479,7 +482,9 @@ async function stampAppCatalog(
479
482
  const catalog =
480
483
  (await discoverAppCatalog(project.appDir, assetOrigin)) ??
481
484
  (metroOrigin && !isStagedHostFileRequest(new URL(bundleUrl).pathname)
482
- ? await discoverOneNativeAppCatalog(metroOrigin, assetOrigin)
485
+ ? await (oneAppCatalog ?? fetchOneNativeAppCatalogDeclaration(metroOrigin)).then(
486
+ (declared) => declared && oneDeclaredAppCatalog(declared, assetOrigin),
487
+ )
483
488
  : await discoverProjectOneNativeAppCatalog(project.appDir, assetOrigin))
484
489
  if (!catalog) return urlStr
485
490
  url.searchParams.set(
@@ -570,6 +575,8 @@ export interface BuildShellUrlOptions {
570
575
  // starts the read beside its early bundle request so the answer overlaps
571
576
  // bridge and host setup instead of preceding the launch.
572
577
  oneAppSplash?: Promise<DiscoveredAppSplashSpec | null>
578
+ // the same early read for the One app's asset catalog declaration
579
+ oneAppCatalog?: Promise<OneNativeAppCatalog | null>
573
580
  // deterministic-capture mode, stamped onto the engine URL as ?proof=1. the
574
581
  // shell worker, compositor worker and tenant worker each read it off the
575
582
  // host page URL at boot (syncProofModeFromInitUrl) and pin everything that
@@ -817,6 +824,7 @@ export async function buildShellUrl(
817
824
  ),
818
825
  nativeAssetOrigin,
819
826
  project,
827
+ opts.oneAppCatalog,
820
828
  )
821
829
  const expoStamped = new URL(stamped)
822
830
  expoStamped.searchParams.delete('nativeAppIdentity')
@@ -67,12 +67,26 @@ export function parseServerMessage(responseText?: string): string | null {
67
67
  }
68
68
  }
69
69
 
70
- type AttachedInteractionSnapshot = {
70
+ type AttachedSnapshot = {
71
71
  meta: NonNullable<InitRequestBody['snapshots']>[number] & { id: string }
72
72
  bytes: Uint8Array
73
73
  }
74
74
 
75
- function readSnapshotManifest(manifestPath: string): AttachedInteractionSnapshot[] {
75
+ const MANIFEST_SNAPSHOT_KINDS = ['landing', 'interaction', 'final', 'manual'] as const
76
+ type ManifestSnapshotKind = (typeof MANIFEST_SNAPSHOT_KINDS)[number]
77
+ function isManifestSnapshotKind(value: unknown): value is ManifestSnapshotKind {
78
+ return MANIFEST_SNAPSHOT_KINDS.some((kind) => kind === value)
79
+ }
80
+
81
+ function optionalFiniteNumber(value: unknown, name: string, index: number) {
82
+ if (value === undefined) return undefined
83
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {
84
+ throw new Error(`snapshot manifest entry ${index} has an invalid ${name}`)
85
+ }
86
+ return Math.round(value)
87
+ }
88
+
89
+ function readSnapshotManifest(manifestPath: string): AttachedSnapshot[] {
76
90
  const parsed: unknown = JSON.parse(readFileSync(manifestPath, 'utf8'))
77
91
  if (!Array.isArray(parsed)) throw new Error('snapshot manifest must be an array')
78
92
  const seen = new Set<string>()
@@ -82,26 +96,41 @@ function readSnapshotManifest(manifestPath: string): AttachedInteractionSnapshot
82
96
  }
83
97
  const id = Reflect.get(entry, 'id')
84
98
  const label = Reflect.get(entry, 'label')
99
+ const kind = Reflect.get(entry, 'kind')
85
100
  const filePath = Reflect.get(entry, 'path')
86
- const t = Reflect.get(entry, 't')
101
+ const contentType = Reflect.get(entry, 'contentType')
87
102
  if (typeof id !== 'string' || !id || seen.has(id)) {
88
103
  throw new Error(`snapshot manifest entry ${index} has an invalid or duplicate id`)
89
104
  }
105
+ if (!isManifestSnapshotKind(kind)) {
106
+ throw new Error(`snapshot manifest entry ${index} has an invalid kind`)
107
+ }
90
108
  if (typeof filePath !== 'string' || !filePath) {
91
- throw new Error(`snapshot manifest entry ${index} has no PNG path`)
109
+ throw new Error(`snapshot manifest entry ${index} has no image path`)
92
110
  }
93
- if (typeof t !== 'number' || !Number.isFinite(t) || t < 0) {
94
- throw new Error(`snapshot manifest entry ${index} has an invalid capture time`)
111
+ if (contentType !== 'image/png' && contentType !== 'image/webp') {
112
+ throw new Error(`snapshot manifest entry ${index} has an invalid content type`)
95
113
  }
96
114
  seen.add(id)
97
115
  const bytes = readFileSync(filePath)
116
+ const t = optionalFiniteNumber(Reflect.get(entry, 't'), 'capture time', index)
117
+ const eventIndex = optionalFiniteNumber(
118
+ Reflect.get(entry, 'eventIndex'),
119
+ 'event index',
120
+ index,
121
+ )
122
+ const width = optionalFiniteNumber(Reflect.get(entry, 'width'), 'width', index)
123
+ const height = optionalFiniteNumber(Reflect.get(entry, 'height'), 'height', index)
98
124
  return {
99
125
  meta: {
100
126
  id,
101
127
  label: typeof label === 'string' && label ? label : id,
102
- kind: 'interaction',
103
- t: Math.round(t),
104
- contentType: 'image/png',
128
+ kind,
129
+ ...(t === undefined ? {} : { t }),
130
+ ...(eventIndex === undefined ? {} : { eventIndex }),
131
+ ...(width === undefined ? {} : { width }),
132
+ ...(height === undefined ? {} : { height }),
133
+ contentType,
105
134
  sizeBytes: bytes.byteLength,
106
135
  },
107
136
  bytes,
@@ -155,7 +184,7 @@ function printHelp() {
155
184
  peach record upload — publish a recording as a /preview/<id> link
156
185
 
157
186
  usage:
158
- peach record upload [--origin <url>] [--public-origin <url>] (--events <path> | --video <path> | --scene <path>) [--live-bundle] [--screenshot <path>] [--owner <org> --repo <repo>] [--sim <sim>] [--open] [--assets-only]
187
+ peach record upload [--origin <url>] [--public-origin <url>] (--events <path> | --video <path> | --scene <path>) [--live-bundle] [--snapshot-manifest <path>] [--owner <org> --repo <repo>] [--sim <sim>] [--open] [--assets-only]
159
188
 
160
189
  options:
161
190
  --origin <url> upload target (default: ${REMOTE_DEFAULT_ORIGIN})
@@ -167,10 +196,11 @@ options:
167
196
  --events <path> path to a gzipped events .jsonl.gz file to attach
168
197
  required unless --video or --scene is present;
169
198
  previews must have replay or recording playback data
170
- --screenshot <path>
171
- path to a PNG thumbnail to attach to the share
172
199
  --snapshot-manifest <path>
173
- JSON manifest of existing interaction PNGs to attach
200
+ JSON array of snapshots to attach: id, label, kind
201
+ (landing, interaction, final, manual), path,
202
+ contentType (image/png or image/webp), optional t,
203
+ eventIndex, width and height
174
204
  --video <path> path to a mp4/gif flow recording. embedded inline
175
205
  in the pr sticky comment served at
176
206
  /api/preview/flow-video?id=<share-id>
@@ -413,7 +443,6 @@ export async function runUpload(
413
443
  extractStringFlag(mutableArgs, '--public-origin'),
414
444
  )
415
445
  const eventsPath = extractStringFlag(mutableArgs, '--events')
416
- const screenshotPath = extractStringFlag(mutableArgs, '--screenshot')
417
446
  const snapshotManifestPath = extractStringFlag(mutableArgs, '--snapshot-manifest')
418
447
  const videoPath = extractStringFlag(mutableArgs, '--video')
419
448
  const scenePath = extractStringFlag(mutableArgs, '--scene')
@@ -783,18 +812,11 @@ export async function runUpload(
783
812
  }`,
784
813
  )
785
814
 
786
- let screenshotBytes: Uint8Array | undefined
787
- if (screenshotPath) {
788
- screenshotBytes = readFileSync(screenshotPath)
789
- console.log(
790
- ` attaching screenshot: ${(screenshotBytes.byteLength / 1024).toFixed(1)} KiB`,
791
- )
792
- }
793
- const interactionSnapshots = snapshotManifestPath
815
+ const manifestSnapshots = snapshotManifestPath
794
816
  ? readSnapshotManifest(snapshotManifestPath)
795
817
  : []
796
- if (interactionSnapshots.length > 0) {
797
- console.log(` attaching ${interactionSnapshots.length} interaction snapshots`)
818
+ if (manifestSnapshots.length > 0) {
819
+ console.log(` attaching ${manifestSnapshots.length} snapshots`)
798
820
  }
799
821
 
800
822
  // the flow runner's per-failure debug bundle: text artifacts fold into one
@@ -1197,16 +1219,6 @@ export async function runUpload(
1197
1219
  : undefined,
1198
1220
  snapshots: (() => {
1199
1221
  const entries: NonNullable<InitRequestBody['snapshots']> = []
1200
- if (screenshotBytes) {
1201
- entries.push({
1202
- id: 'landing',
1203
- label: 'Landing',
1204
- kind: 'landing',
1205
- t: 0,
1206
- contentType: 'image/png',
1207
- sizeBytes: screenshotBytes.byteLength,
1208
- })
1209
- }
1210
1222
  if (failureScreenshotBytes) {
1211
1223
  entries.push({
1212
1224
  id: 'failure',
@@ -1216,7 +1228,7 @@ export async function runUpload(
1216
1228
  sizeBytes: failureScreenshotBytes.byteLength,
1217
1229
  })
1218
1230
  }
1219
- for (const snapshot of interactionSnapshots) entries.push(snapshot.meta)
1231
+ for (const snapshot of manifestSnapshots) entries.push(snapshot.meta)
1220
1232
  return entries.length > 0 ? entries : undefined
1221
1233
  })(),
1222
1234
  flowVideo:
@@ -1233,9 +1245,8 @@ export async function runUpload(
1233
1245
  const filesByHash = new Map<string, Uint8Array>()
1234
1246
  for (const f of prepared) filesByHash.set(f.urlhash, f.bytes)
1235
1247
  const snapshotBytes = new Map<string, Uint8Array>()
1236
- if (screenshotBytes) snapshotBytes.set('landing', screenshotBytes)
1237
1248
  if (failureScreenshotBytes) snapshotBytes.set('failure', failureScreenshotBytes)
1238
- for (const snapshot of interactionSnapshots) {
1249
+ for (const snapshot of manifestSnapshots) {
1239
1250
  snapshotBytes.set(snapshot.meta.id, snapshot.bytes)
1240
1251
  }
1241
1252
 
@@ -1245,9 +1256,8 @@ export async function runUpload(
1245
1256
  if (eventsGz) putBytes += eventsGz.byteLength
1246
1257
  putBytes += timelineGz.byteLength
1247
1258
  if (storageGz) putBytes += storageGz.byteLength
1248
- if (screenshotBytes) putBytes += screenshotBytes.byteLength
1249
1259
  if (failureScreenshotBytes) putBytes += failureScreenshotBytes.byteLength
1250
- for (const snapshot of interactionSnapshots) putBytes += snapshot.bytes.byteLength
1260
+ for (const snapshot of manifestSnapshots) putBytes += snapshot.bytes.byteLength
1251
1261
  if (failureBundleGz) putBytes += failureBundleGz.byteLength
1252
1262
  if (videoBytes) putBytes += videoBytes.byteLength
1253
1263
  if (sceneBytes) putBytes += sceneBytes.byteLength
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (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.2270 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2271 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/bridge-contract.ts
4
4
  var REFUSED_PERFORM_STEP_TYPES = [