peachsim 0.1.1874 → 0.1.1875

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 (92) hide show
  1. package/cli/commands/do-chain.ts +1 -1
  2. package/cli/commands/inspect/settling.ts +132 -92
  3. package/cli/outbound-endpoints.ts +4 -0
  4. package/dist-lib/agent-daemon-client.cjs +1 -1
  5. package/dist-lib/agent-events.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/bundle-channel.cjs +53 -21
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/config.mjs +1 -1
  27. package/dist-lib/detox/index.cjs +141 -102
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/expo-swift-bundle.cjs +32 -15
  30. package/dist-lib/expo-swift-metadata.cjs +1 -1
  31. package/dist-lib/expo-swift-metadata.mjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +49 -21
  34. package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +120 -94
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +2 -2
  50. package/dist-lib/native-app-identity-project.cjs +1 -1
  51. package/dist-lib/native-app-identity-project.mjs +1 -1
  52. package/dist-lib/native-app-identity.cjs +1 -1
  53. package/dist-lib/native-app-identity.mjs +1 -1
  54. package/dist-lib/native-firebase-metadata.cjs +1 -1
  55. package/dist-lib/native-firebase-metadata.mjs +1 -1
  56. package/dist-lib/pdfium-raster.cjs +1 -1
  57. package/dist-lib/pdfium-raster.mjs +1 -1
  58. package/dist-lib/plist.cjs +1 -1
  59. package/dist-lib/plist.mjs +1 -1
  60. package/dist-lib/profiles.cjs +1 -1
  61. package/dist-lib/public-brand.cjs +1 -1
  62. package/dist-lib/public-origins-lib-esm.json +24 -24
  63. package/dist-lib/public-origins-lib.json +53 -53
  64. package/dist-lib/react-native-host-modules.cjs +1 -1
  65. package/dist-lib/react-native-host-modules.mjs +1 -1
  66. package/dist-lib/reap-browser.cjs +1 -1
  67. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  68. package/dist-lib/sdk.cjs +119 -93
  69. package/dist-lib/sdk.mjs +119 -93
  70. package/dist-lib/skills.cjs +163 -111
  71. package/dist-lib/swift-compile.cjs +1 -1
  72. package/dist-lib/swift-compile.mjs +1 -1
  73. package/dist-lib/swift-package.cjs +1 -1
  74. package/dist-lib/swift-package.mjs +1 -1
  75. package/dist-lib/swift-submit.cjs +1 -1
  76. package/dist-lib/swift-submit.mjs +1 -1
  77. package/dist-lib/swift-toolchain.cjs +1 -1
  78. package/dist-lib/swift.cjs +1 -1
  79. package/dist-lib/vite-swift.cjs +1 -1
  80. package/dist-lib/vite.cjs +2 -2
  81. package/dist-lib/worklet-executable.cjs +1 -1
  82. package/dist-lib/worklet-executable.mjs +1 -1
  83. package/package.json +1 -1
  84. package/runtime-companion.json +1 -1
  85. package/skills/contrast/SKILL.md +3 -2
  86. package/src/expo-native-prebuilt.ts +4 -2
  87. package/src/native-bundles.ts +5 -1
  88. package/src/nitroContract.ts +43 -12
  89. package/src/sim-client.ts +4 -2
  90. package/src/swift-host.ts +5 -1
  91. package/src/turbo-bundle.ts +14 -1
  92. package/src/turbo-source.ts +4 -3
package/dist-lib/sdk.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1874 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1875 | (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;
@@ -1818,6 +1818,105 @@ var IdleObservationError = class extends Error {
1818
1818
  }
1819
1819
  code = "idle_observation_failed";
1820
1820
  };
1821
+ function renderActivityIdleScript({
1822
+ maxMs,
1823
+ requiredStillMs,
1824
+ transitionStartWindowMs,
1825
+ transitionTimeoutMs
1826
+ }) {
1827
+ return `(async () => {
1828
+ const start = Date.now()
1829
+ const budgetMs = ${Math.max(0, Math.round(maxMs))}
1830
+ const requiredStillMs = ${Math.max(1, Math.round(requiredStillMs))}
1831
+ let deadline = start + budgetMs
1832
+ // with no tenant running, nothing an app draws can move.
1833
+ const host = window.__sootsimRenderHost ?? null
1834
+ const initial = host ? host.getRenderActivity() : null
1835
+ // a published frame proves the idle flag is an observed worker state, not
1836
+ // the host's pre-boot default, so its idle interval counts from now even
1837
+ // when the busy-to-idle edge preceded this wait.
1838
+ let busySeen = !initial || initial.busy || initial.frameToken > 0
1839
+ let idleSince = !initial || (!initial.busy && initial.frameToken > 0) ? start : null
1840
+ let wake = null
1841
+ const notify = () => {
1842
+ const resolve = wake
1843
+ wake = null
1844
+ resolve?.()
1845
+ }
1846
+ const unsubscribe = host?.subscribeRenderActivity(() => {
1847
+ if (host.getRenderActivity().busy) {
1848
+ busySeen = true
1849
+ idleSince = null
1850
+ } else if (busySeen && idleSince === null) {
1851
+ idleSince = Date.now()
1852
+ }
1853
+ notify()
1854
+ })
1855
+ // a started screen transition moves the deadline: it drains, then the
1856
+ // budget proves the new screen. a loaded host runs a push past a tap's
1857
+ // budget, so the transition carries its own timeout.
1858
+ let transitionEndedAt = null
1859
+ let transitionPending = budgetMs > 120 && typeof window.__sootsimTest?.waitForScreenTransitions === 'function'
1860
+ if (transitionPending) {
1861
+ Promise.resolve()
1862
+ .then(() => window.__sootsimTest.waitForScreenTransitions({
1863
+ timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
1864
+ settleMs: 64,
1865
+ startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
1866
+ }))
1867
+ .then((transition) => {
1868
+ if (transition?.started !== true) return
1869
+ // a loaded worker replies after the motion stopped and says how long ago.
1870
+ transitionEndedAt = Date.now() - Math.max(0, transition.restedMs ?? 0)
1871
+ deadline = Math.max(deadline, transitionEndedAt + budgetMs)
1872
+ }, () => {})
1873
+ .finally(() => {
1874
+ transitionPending = false
1875
+ notify()
1876
+ })
1877
+ }
1878
+ try {
1879
+ while (true) {
1880
+ const now = Date.now()
1881
+ const quietSince = idleSince === null ? null : Math.max(idleSince, transitionEndedAt ?? idleSince)
1882
+ if (!transitionPending && quietSince !== null && now - quietSince >= requiredStillMs) {
1883
+ return { settled: true, elapsed: now - start, blockedBy: '' }
1884
+ }
1885
+ if (!transitionPending && now >= deadline) break
1886
+ const until = !transitionPending && quietSince !== null
1887
+ ? Math.min(quietSince + requiredStillMs, deadline)
1888
+ : deadline
1889
+ let timer = null
1890
+ await new Promise((resolve) => {
1891
+ wake = resolve
1892
+ if (until > now) timer = setTimeout(notify, until - now)
1893
+ })
1894
+ clearTimeout(timer)
1895
+ }
1896
+ } finally {
1897
+ unsubscribe?.()
1898
+ }
1899
+ const blockers = []
1900
+ const stats = await Promise.race([
1901
+ Promise.resolve().then(() => host?.queryStats()).catch(() => null),
1902
+ new Promise((resolve) => setTimeout(() => resolve(null), 500)),
1903
+ ])
1904
+ if (stats) {
1905
+ if (stats.hasActiveAnims) blockers.push('animations still running')
1906
+ if (stats.hasActiveBlockingNativeAnimations) blockers.push('native animations still running')
1907
+ if (stats.hasPendingBlockingAnimationFrames) blockers.push('frame callbacks still pending')
1908
+ if (stats.layoutDirty && stats.renderRequested) blockers.push('layout still dirty')
1909
+ }
1910
+ if (!blockers.length) blockers.push(idleSince === null ? 'tenant render activity still busy' : 'motion ended before stillness was proven')
1911
+ return {
1912
+ settled: false,
1913
+ elapsed: Date.now() - start,
1914
+ blockedBy: blockers.join(', ') + '; tenant activity ' + JSON.stringify({
1915
+ initial, current: host?.getRenderActivity() ?? null, busySeen, idleSince, transitionEndedAt, startedAt: start,
1916
+ }),
1917
+ }
1918
+ })()`;
1919
+ }
1821
1920
  async function waitForSootsimIdle({
1822
1921
  bridge,
1823
1922
  simId,
@@ -1839,7 +1938,12 @@ async function waitForSootsimIdle({
1839
1938
  {
1840
1939
  type: "evaluate",
1841
1940
  simId,
1842
- code: `(async () => {
1941
+ code: motionOnly ? renderActivityIdleScript({
1942
+ maxMs,
1943
+ requiredStillMs: Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs)),
1944
+ transitionStartWindowMs,
1945
+ transitionTimeoutMs
1946
+ }) : `(async () => {
1843
1947
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
1844
1948
  // tests inject a virtual clock as window.__sootsimIdleClock ({ now, sleep })
1845
1949
  // so the stillness window is proven in virtual time: real-timer polls under
@@ -1862,13 +1966,12 @@ async function waitForSootsimIdle({
1862
1966
  const maestro = ${maestro ? "true" : "false"}
1863
1967
  const accessibilityBounds = ${accessibilityBounds.toString()}
1864
1968
  const sameNativeAccessibilityShape = ${sameNativeAccessibilityShape.toString()}
1865
- const motionOnly = ${motionOnly ? "true" : "false"}
1866
1969
  const readyPlayback = ${readyPlayback ? "true" : "false"}
1867
1970
  // full mounted-geometry observation needs at least two hierarchy reads
1868
1971
  // plus the stillness window, which a sub-second budget cannot afford:
1869
1972
  // tight budgets (auto-wait) settle on worker stillness plus root
1870
1973
  // membership, generous ones confirm the geometry too.
1871
- const fullGeometry = ${!maestro && !motionOnly && maxMs >= 1e3 ? "true" : "false"}
1974
+ const fullGeometry = ${!maestro && maxMs >= 1e3 ? "true" : "false"}
1872
1975
  const requiredStillMs = paintStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
1873
1976
  const minimumStablePolls = paintStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
1874
1977
  const composite = paintStill ? window.SootSim?.bridges?.liveComposite : null
@@ -1878,50 +1981,7 @@ async function waitForSootsimIdle({
1878
1981
  // subscribe to presented frames; authoritative screenshots force a
1879
1982
  // worker render, which changes the very counter we used to inspect.
1880
1983
  const unsubscribe = composite?.subscribe(() => {})
1881
- // the tenant pushes each busy change to the page on the port its stats
1882
- // replies use, so a wait on motion alone learns when the worker went
1883
- // idle without asking it. its busy flag covers render work, guest and
1884
- // blocking native animation, blocking frame callbacks and text waits,
1885
- // everything a motion-only poll reads from it, so once it has held idle
1886
- // for the still window that proves stillness without a poll: a worker
1887
- // too loaded to answer twice within a gesture's budget still settles
1888
- // once its motion ends.
1889
- const activityHost = motionOnly ? window.__sootsimRenderHost : null
1890
- const initialActivity = activityHost?.getRenderActivity?.()
1891
- // a published frame proves this is an observed worker state, rather than
1892
- // the host's pre-boot default. subscribe to its continuous idle interval
1893
- // even when the busy-to-idle edge preceded this command.
1894
- let busySeen = initialActivity?.busy === true || initialActivity?.frameToken > 0
1895
- let idleSince = initialActivity?.busy === false && initialActivity?.frameToken > 0
1896
- ? clockNow()
1897
- : null
1898
- let idleWaiters = []
1899
- const unsubscribeActivity = activityHost?.subscribeRenderActivity?.(() => {
1900
- if (activityHost.getRenderActivity().busy) {
1901
- busySeen = true
1902
- idleSince = null
1903
- } else if (busySeen && idleSince === null) {
1904
- idleSince = clockNow()
1905
- const waiters = idleWaiters
1906
- idleWaiters = []
1907
- for (const waiter of waiters) waiter()
1908
- }
1909
- })
1910
1984
  let transitionEndedAt = null
1911
- // resolves once both the tenant and any drained transition have held idle.
1912
- const idleHeld = () =>
1913
- new Promise((resolve) => {
1914
- const check = () => {
1915
- if (idleSince === null) idleWaiters.push(check)
1916
- else {
1917
- const quietSince = Math.max(idleSince, transitionEndedAt ?? idleSince)
1918
- const remaining = requiredStillMs - (clockNow() - quietSince)
1919
- if (remaining <= 0) resolve(true)
1920
- else setTimeout(check, Math.max(1, remaining))
1921
- }
1922
- }
1923
- check()
1924
- })
1925
1985
  let pixelFrameToken = -1
1926
1986
  let screenPixels = null
1927
1987
  // the hierarchy read last taken and the geometry revision it answered.
@@ -2003,7 +2063,7 @@ async function waitForSootsimIdle({
2003
2063
  // and realizes its pixels. both owners must finish before settling.
2004
2064
  // the compositor rejects a stats request it is too busy to answer.
2005
2065
  const compositorRead = answer(() => window.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
2006
- const countsRead = motionOnly ? null : answer(() => window.__sootsimTest?.getRequestCounts?.()).catch(() => null)
2066
+ const countsRead = answer(() => window.__sootsimTest?.getRequestCounts?.()).catch(() => null)
2007
2067
  // the mounted hierarchy in render-worker mode comes from the test
2008
2068
  // bridge: window.__sootsimRoot is an empty placeholder there, so a
2009
2069
  // walk over it hashes every screen to the same empty string while
@@ -2292,7 +2352,6 @@ async function waitForSootsimIdle({
2292
2352
  const hierarchyUnchanged = (current, previous) =>
2293
2353
  current !== null && previous !== null && current.length === previous.length &&
2294
2354
  current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
2295
- const IDLE_HELD = { idleHeld: true }
2296
2355
  while (true) {
2297
2356
  if (clockNow() >= deadline) {
2298
2357
  if (!transitionWait) break
@@ -2304,33 +2363,7 @@ async function waitForSootsimIdle({
2304
2363
  if (clockNow() >= deadline) break
2305
2364
  }
2306
2365
  const pollStarted = clockNow()
2307
- const read = readSnapshot()
2308
- let snapshot = activityHost
2309
- ? await Promise.race([read, idleHeld().then(() => IDLE_HELD)])
2310
- : await read
2311
- // a completed read can win the race before a delayed timer callback.
2312
- // the recorded idle interval remains evidence even on that turn.
2313
- const idleProven = () => {
2314
- const quietSince = Math.max(idleSince ?? Infinity, transitionEndedAt ?? 0)
2315
- return idleSince !== null && quietSince + requiredStillMs <= deadline && clockNow() - quietSince >= requiredStillMs
2316
- }
2317
- while (activityHost && (snapshot === IDLE_HELD || idleProven())) {
2318
- if (transitionWait) {
2319
- await transitionWait
2320
- transitionWait = null
2321
- }
2322
- if (idleProven()) {
2323
- return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
2324
- }
2325
- if (clockNow() >= deadline) {
2326
- snapshot = await read
2327
- break
2328
- }
2329
- // a transition can drain after the first idle interval. keep the
2330
- // pushed evidence armed while its remaining quiet interval holds;
2331
- // awaiting only the in-flight stats read would discard that proof.
2332
- snapshot = await Promise.race([read, idleHeld().then(() => IDLE_HELD)])
2333
- }
2366
+ const snapshot = await readSnapshot()
2334
2367
  if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
2335
2368
  // a read the deadline cut short observed nothing: the last full poll
2336
2369
  // names what held the settle, not a worker that ran out of budget.
@@ -2375,7 +2408,7 @@ async function waitForSootsimIdle({
2375
2408
  !snapshot.animating &&
2376
2409
  !snapshot.shellAnimating &&
2377
2410
  !snapshot.layoutDirty &&
2378
- (motionOnly || snapshot.pendingFetches === 0) &&
2411
+ snapshot.pendingFetches === 0 &&
2379
2412
  !snapshot.workerBusy &&
2380
2413
  !snapshot.webViewStarting
2381
2414
  const visuallyStill = maestro ? maestroStill :
@@ -2407,7 +2440,7 @@ async function waitForSootsimIdle({
2407
2440
  // grace (continuous background traffic must not block forever).
2408
2441
  if (
2409
2442
  stillProven() &&
2410
- (maestro || motionOnly || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
2443
+ (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
2411
2444
  ) {
2412
2445
  if (transitionWait) {
2413
2446
  await transitionWait
@@ -2432,13 +2465,6 @@ async function waitForSootsimIdle({
2432
2465
  const remainingPollMs = pollMs - (clockNow() - pollStarted)
2433
2466
  if (remainingPollMs > 0) await clockSleep(remainingPollMs)
2434
2467
  }
2435
- if (activityHost && idleSince !== null && idleSince + requiredStillMs <= deadline) {
2436
- if (transitionWait) await transitionWait
2437
- const quietSince = Math.max(idleSince ?? Infinity, transitionEndedAt ?? 0)
2438
- if (quietSince + requiredStillMs <= deadline && clockNow() - quietSince >= requiredStillMs) {
2439
- return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
2440
- }
2441
- }
2442
2468
  if (!report) {
2443
2469
  return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
2444
2470
  }
@@ -2450,15 +2476,15 @@ async function waitForSootsimIdle({
2450
2476
  if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
2451
2477
  if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
2452
2478
  if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
2453
- if (!maestro && !motionOnly && last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
2479
+ if (!maestro && last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
2454
2480
  if (last.workerBusy) blockers.push('a render worker too busy to report')
2455
2481
  if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
2456
2482
  if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
2457
2483
  if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
2458
2484
  if (paintStill && !last.screenPixels) blockers.push('screen pixels unavailable')
2459
2485
  else if (paintStill && !screenUnchanged(last.screenPixels, report.screenPixels)) blockers.push('screen pixels still changing')
2460
- if (!maestro && !motionOnly && last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
2461
- else if (!maestro && !motionOnly && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
2486
+ if (!maestro && last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
2487
+ else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
2462
2488
  if (polls < 2) blockers.push('sim too busy to poll twice')
2463
2489
  // the last read is still: motion ended too near the deadline for the
2464
2490
  // stillness window to hold before it.
@@ -2469,12 +2495,10 @@ async function waitForSootsimIdle({
2469
2495
  blockedBy:
2470
2496
  blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
2471
2497
  'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
2472
- (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : '') +
2473
- (activityHost ? '; tenant activity ' + JSON.stringify({ initial: initialActivity, current: activityHost.getRenderActivity?.(), busySeen, idleSince, transitionEndedAt, startedAt: start }) : ''),
2498
+ (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
2474
2499
  }
2475
2500
  } finally {
2476
2501
  unsubscribe?.()
2477
- unsubscribeActivity?.()
2478
2502
  }
2479
2503
  })()`
2480
2504
  },
@@ -3164,13 +3188,15 @@ var SimClient = class {
3164
3188
  * wait for layout/animation/transition settle after an interaction.
3165
3189
  * a still-busy guest returns settled false with its own elapsed time.
3166
3190
  * a failed idle read throws IdleObservationError with the host elapsed
3167
- * time and the original failure.
3191
+ * time and the original failure. motionOnly waits on pushed render activity
3192
+ * and screen transitions alone, the settle that follows a gesture.
3168
3193
  */
3169
3194
  settle(opts = {}) {
3170
3195
  return waitForSootsimIdle({
3171
3196
  bridge: this,
3172
3197
  maxMs: opts.maxMs ?? 3e3,
3173
- strict: opts.strict
3198
+ strict: opts.strict,
3199
+ ...opts.motionOnly ? { motionOnly: true, pollMs: 32, stablePolls: 2 } : {}
3174
3200
  });
3175
3201
  }
3176
3202
  // --- read verbs ---
package/dist-lib/sdk.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1874 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1875 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -1705,6 +1705,105 @@ var IdleObservationError = class extends Error {
1705
1705
  this.name = "IdleObservationError";
1706
1706
  }
1707
1707
  };
1708
+ function renderActivityIdleScript({
1709
+ maxMs,
1710
+ requiredStillMs,
1711
+ transitionStartWindowMs,
1712
+ transitionTimeoutMs
1713
+ }) {
1714
+ return `(async () => {
1715
+ const start = Date.now()
1716
+ const budgetMs = ${Math.max(0, Math.round(maxMs))}
1717
+ const requiredStillMs = ${Math.max(1, Math.round(requiredStillMs))}
1718
+ let deadline = start + budgetMs
1719
+ // with no tenant running, nothing an app draws can move.
1720
+ const host = window.__sootsimRenderHost ?? null
1721
+ const initial = host ? host.getRenderActivity() : null
1722
+ // a published frame proves the idle flag is an observed worker state, not
1723
+ // the host's pre-boot default, so its idle interval counts from now even
1724
+ // when the busy-to-idle edge preceded this wait.
1725
+ let busySeen = !initial || initial.busy || initial.frameToken > 0
1726
+ let idleSince = !initial || (!initial.busy && initial.frameToken > 0) ? start : null
1727
+ let wake = null
1728
+ const notify = () => {
1729
+ const resolve = wake
1730
+ wake = null
1731
+ resolve?.()
1732
+ }
1733
+ const unsubscribe = host?.subscribeRenderActivity(() => {
1734
+ if (host.getRenderActivity().busy) {
1735
+ busySeen = true
1736
+ idleSince = null
1737
+ } else if (busySeen && idleSince === null) {
1738
+ idleSince = Date.now()
1739
+ }
1740
+ notify()
1741
+ })
1742
+ // a started screen transition moves the deadline: it drains, then the
1743
+ // budget proves the new screen. a loaded host runs a push past a tap's
1744
+ // budget, so the transition carries its own timeout.
1745
+ let transitionEndedAt = null
1746
+ let transitionPending = budgetMs > 120 && typeof window.__sootsimTest?.waitForScreenTransitions === 'function'
1747
+ if (transitionPending) {
1748
+ Promise.resolve()
1749
+ .then(() => window.__sootsimTest.waitForScreenTransitions({
1750
+ timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
1751
+ settleMs: 64,
1752
+ startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
1753
+ }))
1754
+ .then((transition) => {
1755
+ if (transition?.started !== true) return
1756
+ // a loaded worker replies after the motion stopped and says how long ago.
1757
+ transitionEndedAt = Date.now() - Math.max(0, transition.restedMs ?? 0)
1758
+ deadline = Math.max(deadline, transitionEndedAt + budgetMs)
1759
+ }, () => {})
1760
+ .finally(() => {
1761
+ transitionPending = false
1762
+ notify()
1763
+ })
1764
+ }
1765
+ try {
1766
+ while (true) {
1767
+ const now = Date.now()
1768
+ const quietSince = idleSince === null ? null : Math.max(idleSince, transitionEndedAt ?? idleSince)
1769
+ if (!transitionPending && quietSince !== null && now - quietSince >= requiredStillMs) {
1770
+ return { settled: true, elapsed: now - start, blockedBy: '' }
1771
+ }
1772
+ if (!transitionPending && now >= deadline) break
1773
+ const until = !transitionPending && quietSince !== null
1774
+ ? Math.min(quietSince + requiredStillMs, deadline)
1775
+ : deadline
1776
+ let timer = null
1777
+ await new Promise((resolve) => {
1778
+ wake = resolve
1779
+ if (until > now) timer = setTimeout(notify, until - now)
1780
+ })
1781
+ clearTimeout(timer)
1782
+ }
1783
+ } finally {
1784
+ unsubscribe?.()
1785
+ }
1786
+ const blockers = []
1787
+ const stats = await Promise.race([
1788
+ Promise.resolve().then(() => host?.queryStats()).catch(() => null),
1789
+ new Promise((resolve) => setTimeout(() => resolve(null), 500)),
1790
+ ])
1791
+ if (stats) {
1792
+ if (stats.hasActiveAnims) blockers.push('animations still running')
1793
+ if (stats.hasActiveBlockingNativeAnimations) blockers.push('native animations still running')
1794
+ if (stats.hasPendingBlockingAnimationFrames) blockers.push('frame callbacks still pending')
1795
+ if (stats.layoutDirty && stats.renderRequested) blockers.push('layout still dirty')
1796
+ }
1797
+ if (!blockers.length) blockers.push(idleSince === null ? 'tenant render activity still busy' : 'motion ended before stillness was proven')
1798
+ return {
1799
+ settled: false,
1800
+ elapsed: Date.now() - start,
1801
+ blockedBy: blockers.join(', ') + '; tenant activity ' + JSON.stringify({
1802
+ initial, current: host?.getRenderActivity() ?? null, busySeen, idleSince, transitionEndedAt, startedAt: start,
1803
+ }),
1804
+ }
1805
+ })()`;
1806
+ }
1708
1807
  async function waitForSootsimIdle({
1709
1808
  bridge,
1710
1809
  simId,
@@ -1726,7 +1825,12 @@ async function waitForSootsimIdle({
1726
1825
  {
1727
1826
  type: "evaluate",
1728
1827
  simId,
1729
- code: `(async () => {
1828
+ code: motionOnly ? renderActivityIdleScript({
1829
+ maxMs,
1830
+ requiredStillMs: Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs)),
1831
+ transitionStartWindowMs,
1832
+ transitionTimeoutMs
1833
+ }) : `(async () => {
1730
1834
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
1731
1835
  // tests inject a virtual clock as window.__sootsimIdleClock ({ now, sleep })
1732
1836
  // so the stillness window is proven in virtual time: real-timer polls under
@@ -1749,13 +1853,12 @@ async function waitForSootsimIdle({
1749
1853
  const maestro = ${maestro ? "true" : "false"}
1750
1854
  const accessibilityBounds = ${accessibilityBounds.toString()}
1751
1855
  const sameNativeAccessibilityShape = ${sameNativeAccessibilityShape.toString()}
1752
- const motionOnly = ${motionOnly ? "true" : "false"}
1753
1856
  const readyPlayback = ${readyPlayback ? "true" : "false"}
1754
1857
  // full mounted-geometry observation needs at least two hierarchy reads
1755
1858
  // plus the stillness window, which a sub-second budget cannot afford:
1756
1859
  // tight budgets (auto-wait) settle on worker stillness plus root
1757
1860
  // membership, generous ones confirm the geometry too.
1758
- const fullGeometry = ${!maestro && !motionOnly && maxMs >= 1e3 ? "true" : "false"}
1861
+ const fullGeometry = ${!maestro && maxMs >= 1e3 ? "true" : "false"}
1759
1862
  const requiredStillMs = paintStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
1760
1863
  const minimumStablePolls = paintStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
1761
1864
  const composite = paintStill ? window.SootSim?.bridges?.liveComposite : null
@@ -1765,50 +1868,7 @@ async function waitForSootsimIdle({
1765
1868
  // subscribe to presented frames; authoritative screenshots force a
1766
1869
  // worker render, which changes the very counter we used to inspect.
1767
1870
  const unsubscribe = composite?.subscribe(() => {})
1768
- // the tenant pushes each busy change to the page on the port its stats
1769
- // replies use, so a wait on motion alone learns when the worker went
1770
- // idle without asking it. its busy flag covers render work, guest and
1771
- // blocking native animation, blocking frame callbacks and text waits,
1772
- // everything a motion-only poll reads from it, so once it has held idle
1773
- // for the still window that proves stillness without a poll: a worker
1774
- // too loaded to answer twice within a gesture's budget still settles
1775
- // once its motion ends.
1776
- const activityHost = motionOnly ? window.__sootsimRenderHost : null
1777
- const initialActivity = activityHost?.getRenderActivity?.()
1778
- // a published frame proves this is an observed worker state, rather than
1779
- // the host's pre-boot default. subscribe to its continuous idle interval
1780
- // even when the busy-to-idle edge preceded this command.
1781
- let busySeen = initialActivity?.busy === true || initialActivity?.frameToken > 0
1782
- let idleSince = initialActivity?.busy === false && initialActivity?.frameToken > 0
1783
- ? clockNow()
1784
- : null
1785
- let idleWaiters = []
1786
- const unsubscribeActivity = activityHost?.subscribeRenderActivity?.(() => {
1787
- if (activityHost.getRenderActivity().busy) {
1788
- busySeen = true
1789
- idleSince = null
1790
- } else if (busySeen && idleSince === null) {
1791
- idleSince = clockNow()
1792
- const waiters = idleWaiters
1793
- idleWaiters = []
1794
- for (const waiter of waiters) waiter()
1795
- }
1796
- })
1797
1871
  let transitionEndedAt = null
1798
- // resolves once both the tenant and any drained transition have held idle.
1799
- const idleHeld = () =>
1800
- new Promise((resolve) => {
1801
- const check = () => {
1802
- if (idleSince === null) idleWaiters.push(check)
1803
- else {
1804
- const quietSince = Math.max(idleSince, transitionEndedAt ?? idleSince)
1805
- const remaining = requiredStillMs - (clockNow() - quietSince)
1806
- if (remaining <= 0) resolve(true)
1807
- else setTimeout(check, Math.max(1, remaining))
1808
- }
1809
- }
1810
- check()
1811
- })
1812
1872
  let pixelFrameToken = -1
1813
1873
  let screenPixels = null
1814
1874
  // the hierarchy read last taken and the geometry revision it answered.
@@ -1890,7 +1950,7 @@ async function waitForSootsimIdle({
1890
1950
  // and realizes its pixels. both owners must finish before settling.
1891
1951
  // the compositor rejects a stats request it is too busy to answer.
1892
1952
  const compositorRead = answer(() => window.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
1893
- const countsRead = motionOnly ? null : answer(() => window.__sootsimTest?.getRequestCounts?.()).catch(() => null)
1953
+ const countsRead = answer(() => window.__sootsimTest?.getRequestCounts?.()).catch(() => null)
1894
1954
  // the mounted hierarchy in render-worker mode comes from the test
1895
1955
  // bridge: window.__sootsimRoot is an empty placeholder there, so a
1896
1956
  // walk over it hashes every screen to the same empty string while
@@ -2179,7 +2239,6 @@ async function waitForSootsimIdle({
2179
2239
  const hierarchyUnchanged = (current, previous) =>
2180
2240
  current !== null && previous !== null && current.length === previous.length &&
2181
2241
  current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
2182
- const IDLE_HELD = { idleHeld: true }
2183
2242
  while (true) {
2184
2243
  if (clockNow() >= deadline) {
2185
2244
  if (!transitionWait) break
@@ -2191,33 +2250,7 @@ async function waitForSootsimIdle({
2191
2250
  if (clockNow() >= deadline) break
2192
2251
  }
2193
2252
  const pollStarted = clockNow()
2194
- const read = readSnapshot()
2195
- let snapshot = activityHost
2196
- ? await Promise.race([read, idleHeld().then(() => IDLE_HELD)])
2197
- : await read
2198
- // a completed read can win the race before a delayed timer callback.
2199
- // the recorded idle interval remains evidence even on that turn.
2200
- const idleProven = () => {
2201
- const quietSince = Math.max(idleSince ?? Infinity, transitionEndedAt ?? 0)
2202
- return idleSince !== null && quietSince + requiredStillMs <= deadline && clockNow() - quietSince >= requiredStillMs
2203
- }
2204
- while (activityHost && (snapshot === IDLE_HELD || idleProven())) {
2205
- if (transitionWait) {
2206
- await transitionWait
2207
- transitionWait = null
2208
- }
2209
- if (idleProven()) {
2210
- return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
2211
- }
2212
- if (clockNow() >= deadline) {
2213
- snapshot = await read
2214
- break
2215
- }
2216
- // a transition can drain after the first idle interval. keep the
2217
- // pushed evidence armed while its remaining quiet interval holds;
2218
- // awaiting only the in-flight stats read would discard that proof.
2219
- snapshot = await Promise.race([read, idleHeld().then(() => IDLE_HELD)])
2220
- }
2253
+ const snapshot = await readSnapshot()
2221
2254
  if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
2222
2255
  // a read the deadline cut short observed nothing: the last full poll
2223
2256
  // names what held the settle, not a worker that ran out of budget.
@@ -2262,7 +2295,7 @@ async function waitForSootsimIdle({
2262
2295
  !snapshot.animating &&
2263
2296
  !snapshot.shellAnimating &&
2264
2297
  !snapshot.layoutDirty &&
2265
- (motionOnly || snapshot.pendingFetches === 0) &&
2298
+ snapshot.pendingFetches === 0 &&
2266
2299
  !snapshot.workerBusy &&
2267
2300
  !snapshot.webViewStarting
2268
2301
  const visuallyStill = maestro ? maestroStill :
@@ -2294,7 +2327,7 @@ async function waitForSootsimIdle({
2294
2327
  // grace (continuous background traffic must not block forever).
2295
2328
  if (
2296
2329
  stillProven() &&
2297
- (maestro || motionOnly || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
2330
+ (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
2298
2331
  ) {
2299
2332
  if (transitionWait) {
2300
2333
  await transitionWait
@@ -2319,13 +2352,6 @@ async function waitForSootsimIdle({
2319
2352
  const remainingPollMs = pollMs - (clockNow() - pollStarted)
2320
2353
  if (remainingPollMs > 0) await clockSleep(remainingPollMs)
2321
2354
  }
2322
- if (activityHost && idleSince !== null && idleSince + requiredStillMs <= deadline) {
2323
- if (transitionWait) await transitionWait
2324
- const quietSince = Math.max(idleSince ?? Infinity, transitionEndedAt ?? 0)
2325
- if (quietSince + requiredStillMs <= deadline && clockNow() - quietSince >= requiredStillMs) {
2326
- return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
2327
- }
2328
- }
2329
2355
  if (!report) {
2330
2356
  return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
2331
2357
  }
@@ -2337,15 +2363,15 @@ async function waitForSootsimIdle({
2337
2363
  if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
2338
2364
  if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
2339
2365
  if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
2340
- if (!maestro && !motionOnly && last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
2366
+ if (!maestro && last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
2341
2367
  if (last.workerBusy) blockers.push('a render worker too busy to report')
2342
2368
  if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
2343
2369
  if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
2344
2370
  if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
2345
2371
  if (paintStill && !last.screenPixels) blockers.push('screen pixels unavailable')
2346
2372
  else if (paintStill && !screenUnchanged(last.screenPixels, report.screenPixels)) blockers.push('screen pixels still changing')
2347
- if (!maestro && !motionOnly && last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
2348
- else if (!maestro && !motionOnly && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
2373
+ if (!maestro && last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
2374
+ else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
2349
2375
  if (polls < 2) blockers.push('sim too busy to poll twice')
2350
2376
  // the last read is still: motion ended too near the deadline for the
2351
2377
  // stillness window to hold before it.
@@ -2356,12 +2382,10 @@ async function waitForSootsimIdle({
2356
2382
  blockedBy:
2357
2383
  blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
2358
2384
  'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
2359
- (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : '') +
2360
- (activityHost ? '; tenant activity ' + JSON.stringify({ initial: initialActivity, current: activityHost.getRenderActivity?.(), busySeen, idleSince, transitionEndedAt, startedAt: start }) : ''),
2385
+ (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
2361
2386
  }
2362
2387
  } finally {
2363
2388
  unsubscribe?.()
2364
- unsubscribeActivity?.()
2365
2389
  }
2366
2390
  })()`
2367
2391
  },
@@ -3051,13 +3075,15 @@ var SimClient = class {
3051
3075
  * wait for layout/animation/transition settle after an interaction.
3052
3076
  * a still-busy guest returns settled false with its own elapsed time.
3053
3077
  * a failed idle read throws IdleObservationError with the host elapsed
3054
- * time and the original failure.
3078
+ * time and the original failure. motionOnly waits on pushed render activity
3079
+ * and screen transitions alone, the settle that follows a gesture.
3055
3080
  */
3056
3081
  settle(opts = {}) {
3057
3082
  return waitForSootsimIdle({
3058
3083
  bridge: this,
3059
3084
  maxMs: opts.maxMs ?? 3e3,
3060
- strict: opts.strict
3085
+ strict: opts.strict,
3086
+ ...opts.motionOnly ? { motionOnly: true, pollMs: 32, stablePolls: 2 } : {}
3061
3087
  });
3062
3088
  }
3063
3089
  // --- read verbs ---