peachsim 0.1.2241 → 0.1.2243

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/bridge-flow-runner.ts +10 -9
  2. package/cli/commands/flow.ts +4 -0
  3. package/cli/commands/inspect/settling.ts +496 -515
  4. package/cli/commands/platform.ts +2 -0
  5. package/dist-lib/agent-daemon-client.cjs +1 -1
  6. package/dist-lib/agent-events.cjs +1 -1
  7. package/dist-lib/attached-projects.cjs +1 -1
  8. package/dist-lib/auth/shared-session.cjs +1 -1
  9. package/dist-lib/backend-origin.cjs +1 -1
  10. package/dist-lib/beta.cjs +1 -1
  11. package/dist-lib/beta.mjs +1 -1
  12. package/dist-lib/bridge-constants.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.mjs +1 -1
  15. package/dist-lib/bridge-contract.cjs +1 -1
  16. package/dist-lib/bridge-contract.mjs +1 -1
  17. package/dist-lib/bundle-channel.cjs +115 -28
  18. package/dist-lib/capture-contract.cjs +1 -1
  19. package/dist-lib/capture-contract.mjs +1 -1
  20. package/dist-lib/cloud-contract.cjs +1 -1
  21. package/dist-lib/cloud-contract.mjs +1 -1
  22. package/dist-lib/cloud-test-args.cjs +1 -1
  23. package/dist-lib/cloud-test-args.mjs +1 -1
  24. package/dist-lib/cloud.cjs +1 -1
  25. package/dist-lib/cloud.mjs +1 -1
  26. package/dist-lib/config.cjs +1 -1
  27. package/dist-lib/config.mjs +1 -1
  28. package/dist-lib/detox/index.cjs +498 -518
  29. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  30. package/dist-lib/expo-swift-bundle.cjs +114 -27
  31. package/dist-lib/expo-swift-metadata.cjs +1 -1
  32. package/dist-lib/expo-swift-metadata.mjs +1 -1
  33. package/dist-lib/home-paths.cjs +1 -1
  34. package/dist-lib/host/bridge-host.cjs +122 -40
  35. package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
  36. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  37. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  38. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  39. package/dist-lib/host/websocket-proxy.cjs +1 -1
  40. package/dist-lib/index.cjs +496 -516
  41. package/dist-lib/jump-to-source-babel.cjs +1 -1
  42. package/dist-lib/jump-to-source-native.cjs +1 -1
  43. package/dist-lib/kotlin-host.cjs +1 -1
  44. package/dist-lib/menu.cjs +1 -1
  45. package/dist-lib/menu.mjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  48. package/dist-lib/metro-production-bundle.cjs +1 -1
  49. package/dist-lib/metro-production-bundle.mjs +1 -1
  50. package/dist-lib/metro.cjs +3 -3
  51. package/dist-lib/native-app-identity-project.cjs +2 -2
  52. package/dist-lib/native-app-identity-project.mjs +2 -2
  53. package/dist-lib/native-app-identity.cjs +1 -1
  54. package/dist-lib/native-app-identity.mjs +1 -1
  55. package/dist-lib/native-firebase-metadata.cjs +1 -1
  56. package/dist-lib/native-firebase-metadata.mjs +1 -1
  57. package/dist-lib/pdfium-raster.cjs +1 -1
  58. package/dist-lib/pdfium-raster.mjs +1 -1
  59. package/dist-lib/plist.cjs +1 -1
  60. package/dist-lib/plist.mjs +1 -1
  61. package/dist-lib/profiles.cjs +1 -1
  62. package/dist-lib/public-brand.cjs +1 -1
  63. package/dist-lib/public-origins-lib-esm.json +24 -24
  64. package/dist-lib/public-origins-lib.json +53 -53
  65. package/dist-lib/react-native-host-modules.cjs +1 -1
  66. package/dist-lib/react-native-host-modules.mjs +1 -1
  67. package/dist-lib/reap-browser.cjs +1 -1
  68. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  69. package/dist-lib/sdk.cjs +492 -512
  70. package/dist-lib/sdk.mjs +492 -512
  71. package/dist-lib/skills.cjs +632 -569
  72. package/dist-lib/swift-compile.cjs +13 -4
  73. package/dist-lib/swift-compile.mjs +13 -4
  74. package/dist-lib/swift-package.cjs +1 -1
  75. package/dist-lib/swift-package.mjs +1 -1
  76. package/dist-lib/swift-submit.cjs +2 -2
  77. package/dist-lib/swift-submit.mjs +2 -2
  78. package/dist-lib/swift-toolchain.cjs +1 -1
  79. package/dist-lib/swift.cjs +1 -1
  80. package/dist-lib/vite-swift.cjs +507 -419
  81. package/dist-lib/vite.cjs +3 -3
  82. package/dist-lib/worklet-executable.cjs +1 -1
  83. package/dist-lib/worklet-executable.mjs +1 -1
  84. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +3 -0
  85. package/kotlin/sdk.tar.gz +0 -0
  86. package/package.json +1 -1
  87. package/src/host/bridge-host.ts +12 -13
  88. package/src/native-static-libraries.ts +98 -17
  89. package/src/swift-shared-sdk.ts +6 -1
  90. package/src/swift-standins.ts +11 -4
  91. package/src/swift-submit.ts +3 -1
  92. package/src/swift-wasm-prune.ts +28 -0
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2241 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2243 | (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;
@@ -11498,7 +11498,7 @@ async function waitForSootsimIdle({
11498
11498
  pollMs = 50,
11499
11499
  stablePolls = 3,
11500
11500
  strict = false,
11501
- paintStill = false,
11501
+ screenStill = false,
11502
11502
  maestro = false,
11503
11503
  motionOnly = false,
11504
11504
  readyPlayback = false,
@@ -11536,7 +11536,7 @@ async function waitForSootsimIdle({
11536
11536
  let deadline = start + budgetMs
11537
11537
  const pollMs = ${Math.max(1, Math.round(pollMs))}
11538
11538
  const strict = ${strict ? "true" : "false"}
11539
- const paintStill = ${paintStill ? "true" : "false"}
11539
+ const screenStill = ${screenStill ? "true" : "false"}
11540
11540
  const maestro = ${maestro ? "true" : "false"}
11541
11541
  const accessibilityBounds = ${accessibilityBounds.toString()}
11542
11542
  const sameNativeAccessibilityShape = ${sameNativeAccessibilityShape.toString()}
@@ -11546,550 +11546,530 @@ async function waitForSootsimIdle({
11546
11546
  // tight budgets (auto-wait) settle on worker stillness plus root
11547
11547
  // membership, generous ones confirm the geometry too.
11548
11548
  const fullGeometry = ${!maestro && maxMs >= 1e3 ? "true" : "false"}
11549
- const requiredStillMs = paintStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
11550
- const minimumStablePolls = paintStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
11551
- const composite = paintStill ? globalThis.SootSim?.bridges?.liveComposite : null
11552
- if (paintStill && !composite) {
11553
- return { settled: false, elapsed: clockNow() - start, blockedBy: 'screen pixels unavailable' }
11554
- }
11555
- // subscribe to presented frames; authoritative screenshots force a
11556
- // worker render, which changes the very counter we used to inspect.
11557
- // pixels only decide stillness once motion and layout work drain, so the
11558
- // subscription holds only then: a headless host otherwise reads back
11559
- // every motion frame for a comparison that cannot pass.
11560
- let unsubscribe = null
11549
+ const requiredStillMs = screenStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
11550
+ const minimumStablePolls = screenStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
11561
11551
  let transitionEndedAt = null
11562
- let pixelFrameToken = -1
11563
- let screenPixels = null
11564
11552
  // the hierarchy read last taken and the geometry revision it answered.
11565
11553
  // it outlives this wait: a revision still current when a later wait
11566
11554
  // polls names the same geometry, so a step that follows a settled one
11567
11555
  // proves an unchanged screen without walking the tree again.
11568
11556
  const geometry = (globalThis.__peachSettleGeometry ??= { revision: null, hierarchy: null })
11569
- try {
11570
-
11571
- // discover transitions while observing layout. when motion starts,
11572
- // observations from before its completion cannot prove the new screen;
11573
- // those that began after it drained still can. a loaded host runs a
11574
- // push past a tap's budget, so the transition gets its own timeout and
11575
- // the budget restarts once it drains.
11576
- let transitionWait = (async () => {
11577
- try {
11578
- const wfst = globalThis.__sootsimTest?.waitForScreenTransitions
11579
- if (typeof wfst === 'function' && budgetMs > 120) {
11580
- const transition = await wfst({
11581
- timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
11582
- settleMs: 64,
11583
- startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
11584
- })
11585
- if (transition?.started !== true) return false
11586
- // a loaded worker replies long after the motion stopped; it
11587
- // reports how long ago, so polls begun since still count. a
11588
- // runtime without the field ends the transition at the reply.
11589
- const rested = typeof transition.restedMs === 'number' ? Math.max(0, transition.restedMs) : 0
11590
- transitionEndedAt = clockNow() - rested
11591
- deadline = Math.max(deadline, transitionEndedAt + budgetMs)
11592
- return true
11593
- }
11594
- } catch {}
11595
- return false
11596
- })()
11597
-
11598
- // a worker that cannot answer within the remaining budget is busy, not
11599
- // idle: its poll reads as unsettled. bounding each read by the budget
11600
- // keeps a busy worker from holding a poll past the deadline.
11601
- const BUSY = { busy: true }
11602
- const answer = (read) =>
11603
- Promise.race([
11604
- Promise.resolve().then(read),
11605
- new Promise((resolve) =>
11606
- setTimeout(() => resolve(BUSY), Math.max(deadline - clockNow(), 100)),
11607
- ),
11608
- ])
11557
+ // discover transitions while observing layout. when motion starts,
11558
+ // observations from before its completion cannot prove the new screen;
11559
+ // those that began after it drained still can. a loaded host runs a
11560
+ // push past a tap's budget, so the transition gets its own timeout and
11561
+ // the budget restarts once it drains.
11562
+ let transitionWait = (async () => {
11563
+ try {
11564
+ const wfst = globalThis.__sootsimTest?.waitForScreenTransitions
11565
+ if (typeof wfst === 'function' && budgetMs > 120) {
11566
+ const transition = await wfst({
11567
+ timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
11568
+ settleMs: 64,
11569
+ startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
11570
+ })
11571
+ if (transition?.started !== true) return false
11572
+ // a loaded worker replies long after the motion stopped; it
11573
+ // reports how long ago, so polls begun since still count. a
11574
+ // runtime without the field ends the transition at the reply.
11575
+ const rested = typeof transition.restedMs === 'number' ? Math.max(0, transition.restedMs) : 0
11576
+ transitionEndedAt = clockNow() - rested
11577
+ deadline = Math.max(deadline, transitionEndedAt + budgetMs)
11578
+ return true
11579
+ }
11580
+ } catch {}
11581
+ return false
11582
+ })()
11583
+
11584
+ // a worker that cannot answer within the remaining budget is busy, not
11585
+ // idle: its poll reads as unsettled. bounding each read by the budget
11586
+ // keeps a busy worker from holding a poll past the deadline.
11587
+ const BUSY = { busy: true }
11588
+ const answer = (read) =>
11589
+ Promise.race([
11590
+ Promise.resolve().then(read),
11591
+ new Promise((resolve) =>
11592
+ setTimeout(() => resolve(BUSY), Math.max(deadline - clockNow(), 100)),
11593
+ ),
11594
+ ])
11609
11595
 
11610
- const readSnapshot = async () => {
11611
- let animating = false
11612
- let animatingBy = ''
11613
- let layoutDirty = false
11614
- let pendingFetches = 0
11615
- let workerBusy = false
11616
- let requestTotal = 0
11617
- let requestInFlight = 0
11618
- let appCommits = null
11619
- let nodeCount = null
11620
- let renderStatsAvailable = false
11621
- let shellAnimating = false
11622
- let shellBlockers = ''
11623
- let webViewStarting = false
11624
- let webViewBlocker = ''
11625
- // the reads are independent, so they run concurrently: a loaded sim
11626
- // answers each one late, and a poll that waits for them in turn
11627
- // costs their sum, which fits too few polls in the budget to settle.
11628
- // the window node count is the exception: it launches after the
11629
- // motion read, so a poll motion already fails skips that walk.
11630
- // strict reads also wait out shell motion. pixel reads inspect finite
11631
- // animations in both realms: a worklet can move the app while the
11632
- // tenant's basic animation flag and last presented pixels read still.
11633
- const accessibilityRead = maestro
11634
- ? answer(() => globalThis.__sootsimTest.captureAccessibilityTree()).catch(() => null)
11635
- : null
11636
- const motionRead = strict || paintStill
11637
- ? answer(() => globalThis.__sootsimTest?.listAnimations?.()).catch(() => null)
11596
+ const readSnapshot = async () => {
11597
+ let animating = false
11598
+ let animatingBy = ''
11599
+ let layoutDirty = false
11600
+ let pendingFetches = 0
11601
+ let workerBusy = false
11602
+ let requestTotal = 0
11603
+ let requestInFlight = 0
11604
+ let appCommits = null
11605
+ let nodeCount = null
11606
+ let renderStatsAvailable = false
11607
+ let shellAnimating = false
11608
+ let shellBlockers = ''
11609
+ let webViewStarting = false
11610
+ let webViewBlocker = ''
11611
+ let visibleMotion = false
11612
+ let visibleMotionBy = ''
11613
+ let motionUnavailable = false
11614
+ // the reads are independent, so they run concurrently: a loaded sim
11615
+ // answers each one late, and a poll that waits for them in turn
11616
+ // costs their sum, which fits too few polls in the budget to settle.
11617
+ // the window node count is the exception: it launches after the
11618
+ // motion read, so a poll motion already fails skips that walk.
11619
+ // strict reads also wait out shell motion. pixel reads inspect finite
11620
+ // animations in both realms: a worklet can move the app while the
11621
+ // tenant's basic animation flag and last presented pixels read still.
11622
+ const accessibilityRead = maestro
11623
+ ? answer(() => globalThis.__sootsimTest.captureAccessibilityTree()).catch(() => null)
11624
+ : null
11625
+ const motionRead = strict || screenStill
11626
+ ? answer(() => globalThis.__sootsimTest?.listAnimations?.()).catch(() => null)
11627
+ : null
11628
+ const statsRead = answer(() => globalThis.__sootsimRenderHost?.queryStats?.()).catch(() => null)
11629
+ // image preparation ends in the tenant before the compositor decodes
11630
+ // and realizes its pixels. both owners must finish before settling.
11631
+ // the compositor rejects a stats request it is too busy to answer.
11632
+ const compositorRead = answer(() => globalThis.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
11633
+ const countsRead = answer(() => globalThis.__sootsimTest?.getRequestCounts?.()).catch(() => null)
11634
+ // the mounted hierarchy in render-worker mode comes from the test
11635
+ // bridge: globalThis.__sootsimRoot is an empty placeholder there, so a
11636
+ // walk over it hashes every screen to the same empty string while
11637
+ // it moves. listInspectable is the worker-backed read describe
11638
+ // uses; a worker too busy to answer it reads as unsettled. tight
11639
+ // budgets skip this read and settle on the cheaper signals above.
11640
+ // it walks every node, so a poll whose geometry revision matches the
11641
+ // last read, in this wait or an earlier one, reuses that read.
11642
+ const hierarchyRead =
11643
+ fullGeometry && typeof globalThis.__sootsimTest?.listInspectable === 'function'
11644
+ ? answer(() => globalThis.__sootsimTest.getGeometryRevision?.())
11645
+ .catch(() => null)
11646
+ .then((revision) => {
11647
+ if (revision === BUSY) return BUSY
11648
+ if (typeof revision === 'string' && geometry.revision === revision) return geometry.hierarchy
11649
+ return answer(() => globalThis.__sootsimTest.listInspectable({}))
11650
+ .catch(() => null)
11651
+ .then((hierarchy) => {
11652
+ const kept = typeof revision === 'string' && Array.isArray(hierarchy)
11653
+ geometry.revision = kept ? revision : null
11654
+ geometry.hierarchy = kept ? hierarchy : null
11655
+ return hierarchy
11656
+ })
11657
+ })
11638
11658
  : null
11639
- const statsRead = answer(() => globalThis.__sootsimRenderHost?.queryStats?.()).catch(() => null)
11640
- // image preparation ends in the tenant before the compositor decodes
11641
- // and realizes its pixels. both owners must finish before settling.
11642
- // the compositor rejects a stats request it is too busy to answer.
11643
- const compositorRead = answer(() => globalThis.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
11644
- const countsRead = answer(() => globalThis.__sootsimTest?.getRequestCounts?.()).catch(() => null)
11645
- // the mounted hierarchy in render-worker mode comes from the test
11646
- // bridge: globalThis.__sootsimRoot is an empty placeholder there, so a
11647
- // walk over it hashes every screen to the same empty string while
11648
- // it moves. listInspectable is the worker-backed read describe
11649
- // uses; a worker too busy to answer it reads as unsettled. tight
11650
- // budgets skip this read and settle on the cheaper signals above.
11651
- // it walks every node, so a poll whose geometry revision matches the
11652
- // last read, in this wait or an earlier one, reuses that read.
11653
- const hierarchyRead =
11654
- fullGeometry && typeof globalThis.__sootsimTest?.listInspectable === 'function'
11655
- ? answer(() => globalThis.__sootsimTest.getGeometryRevision?.())
11656
- .catch(() => null)
11657
- .then((revision) => {
11658
- if (revision === BUSY) return BUSY
11659
- if (typeof revision === 'string' && geometry.revision === revision) return geometry.hierarchy
11660
- return answer(() => globalThis.__sootsimTest.listInspectable({}))
11661
- .catch(() => null)
11662
- .then((hierarchy) => {
11663
- const kept = typeof revision === 'string' && Array.isArray(hierarchy)
11664
- geometry.revision = kept ? revision : null
11665
- geometry.hierarchy = kept ? hierarchy : null
11666
- return hierarchy
11667
- })
11668
- })
11669
- : null
11670
- if (motionRead) {
11671
- const motion = await motionRead
11672
- if (motion === BUSY) workerBusy = true
11673
- else if (Array.isArray(motion)) {
11674
- const blocking = motion.filter((anim) =>
11675
- (anim.realm === 'shell' || paintStill) &&
11676
- anim.priority !== 'low' && anim.visible !== false &&
11677
- (!paintStill || anim.loop !== true))
11678
- shellAnimating = blocking.length > 0
11679
- // name what holds the settle so a timeout points at its owner.
11680
- shellBlockers = blocking
11681
- .slice(0, 4)
11682
- .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + ' at ' + anim.current + (anim.loop ? ' loop' : ''))
11683
- .join(', ')
11684
- }
11685
- }
11686
- const stats = await statsRead
11687
- if (stats === BUSY) {
11688
- workerBusy = true
11689
- } else if (!stats && readyPlayback) {
11659
+ if (motionRead) {
11660
+ const motion = await motionRead
11661
+ if (motion === BUSY) workerBusy = true
11662
+ else if (Array.isArray(motion)) {
11663
+ const blocking = motion.filter((anim) =>
11664
+ (anim.realm === 'shell' || screenStill) &&
11665
+ anim.priority !== 'low' && anim.visible !== false &&
11666
+ (!screenStill || anim.loop !== true))
11667
+ shellAnimating = blocking.length > 0
11668
+ // what blocking leaves out still moves the screen while visible;
11669
+ // it ends a screen-still wait only at maestro's hierarchy check
11670
+ // or the deadline, as a screen that never holds still does on ios.
11671
+ const moving = screenStill
11672
+ ? motion.filter((anim) => anim.visible !== false && !blocking.includes(anim))
11673
+ : []
11674
+ visibleMotion = moving.length > 0
11675
+ visibleMotionBy = moving
11676
+ .slice(0, 4)
11677
+ .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + (anim.loop ? ' loop' : '') + (anim.priority === 'low' ? ' low' : ''))
11678
+ .join(', ')
11679
+ // name what holds the settle so a timeout points at its owner.
11680
+ shellBlockers = blocking
11681
+ .slice(0, 4)
11682
+ .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + ' at ' + anim.current + (anim.loop ? ' loop' : ''))
11683
+ .join(', ')
11684
+ } else if (screenStill) {
11685
+ motionUnavailable = true
11690
11686
  workerBusy = true
11691
- } else if (stats) {
11692
- renderStatsAvailable = true
11693
- const missingFields = ['hasActiveBlockingNativeAnimations', 'hasPendingBlockingAnimationFrames']
11694
- .filter((field) => typeof stats[field] !== 'boolean')
11695
- if (readyPlayback && typeof stats.hasPendingReadinessAnimationFrames !== 'boolean') missingFields.push('hasPendingReadinessAnimationFrames')
11696
- if ((strict || readyPlayback) && missingFields.length > 0) {
11697
- return {
11698
- runtimeUnsupported: {
11699
- error: 'runtime_readiness_unsupported',
11700
- runtimeVersion: globalThis.__sootsimRuntimeVersion || 'unknown',
11701
- missingFields,
11702
- },
11703
- }
11704
- }
11705
- // positive checks only: an older runtime without the blocking
11706
- // fields reads as still, and strict rejects that runtime above
11707
- // instead of ever settling on unknown motion.
11708
- animating =
11709
- stats.hasActiveAnims === true ||
11710
- stats.hasActiveBlockingNativeAnimations === true ||
11711
- (!paintStill && (readyPlayback ? stats.hasPendingReadinessAnimationFrames : stats.hasPendingBlockingAnimationFrames) === true)
11712
- if (animating)
11713
- animatingBy = [
11714
- stats.hasActiveAnims === true && 'activeAnims',
11715
- stats.hasActiveBlockingNativeAnimations === true && 'blockingNative',
11716
- !paintStill && stats.hasPendingBlockingAnimationFrames === true && 'pendingFrames',
11717
- !paintStill && stats.hasPendingReadinessAnimationFrames === true && 'pendingReadinessFrames',
11718
- ].filter(Boolean).join('+')
11719
- // the runtime reports only layout work that can reach the window:
11720
- // a covered screen or inactive tab committing does not hold it.
11721
- layoutDirty =
11722
- stats.layoutDirty === true && stats.renderRequested === true
11723
- // a freshly-pushed screen showing a skeleton is layout-stable
11724
- // but not actually settled \u2014 its data/images are still in
11725
- // flight. treat bounded image-loader fetches as not-idle so
11726
- // settle waits for real content, capped by the budget.
11727
- const pf = stats.memory && stats.memory.imageLoader
11728
- ? stats.memory.imageLoader.pendingFetches
11729
- : 0
11730
- pendingFetches = typeof pf === 'number' ? pf : 0
11731
- // tenant layout commits: a screen that keeps committing is still
11732
- // mounting or remounting, even with no animation flag raised.
11733
- appCommits = typeof stats.appCommitCount === 'number' ? stats.appCommitCount : null
11734
11687
  }
11735
- // mounted-root membership: the count of nodes that can reach the
11736
- // window moves while the screen mounts, unmounts or recycles, in
11737
- // either render mode. a screen a pushed one covers or an inactive
11738
- // tab stays mounted out of the window, so what it mounts is not
11739
- // screen motion. the worker rebuilds the membership set while the
11740
- // wire moves on every animated frame, so a poll the motion read
11741
- // already fails skips it: the motion flags alone prove this poll
11742
- // unsettled, and the carried count hands the first still poll the
11743
- // pre-motion baseline to compare against.
11744
- const motionStill = !workerBusy && !animating && !layoutDirty && !shellAnimating
11745
- const nodeCountRead = motionStill
11746
- ? answer(() => globalThis.__sootsimTest?.getWindowNodeCount?.()).catch(() => null)
11747
- : null
11748
- const compositor = await compositorRead
11749
- if (compositor === BUSY) {
11750
- workerBusy = true
11751
- } else {
11752
- pendingFetches += compositor.images.pendingFetches
11753
- pendingFetches += compositor.imageRealization.pending
11754
- if (compositor.webViewCaptureSettled === false) {
11755
- webViewStarting = true
11756
- webViewBlocker = 'compositor webView capture not settled'
11688
+ }
11689
+ const stats = await statsRead
11690
+ if (stats === BUSY) {
11691
+ workerBusy = true
11692
+ } else if (!stats && readyPlayback) {
11693
+ workerBusy = true
11694
+ } else if (stats) {
11695
+ renderStatsAvailable = true
11696
+ const missingFields = ['hasActiveBlockingNativeAnimations', 'hasPendingBlockingAnimationFrames']
11697
+ .filter((field) => typeof stats[field] !== 'boolean')
11698
+ if (readyPlayback && typeof stats.hasPendingReadinessAnimationFrames !== 'boolean') missingFields.push('hasPendingReadinessAnimationFrames')
11699
+ if ((strict || readyPlayback) && missingFields.length > 0) {
11700
+ return {
11701
+ runtimeUnsupported: {
11702
+ error: 'runtime_readiness_unsupported',
11703
+ runtimeVersion: globalThis.__sootsimRuntimeVersion || 'unknown',
11704
+ missingFields,
11705
+ },
11757
11706
  }
11758
11707
  }
11759
- const counts = await countsRead
11760
- if (counts === BUSY) workerBusy = true
11761
- // <Image> loads are left to the image loader, which counts only those
11762
- // that can reach the window. a runtime older than the CLI reports none.
11763
- const imageLoads = counts?.imageLoads ?? { total: 0, inFlight: 0 }
11764
- requestTotal = typeof counts?.total === 'number' ? counts.total - imageLoads.total : 0
11765
- requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight - imageLoads.inFlight : 0
11766
- // a skipped read carries the last count: mounts during motion still
11767
- // break the first still poll after it, instead of a blank baseline
11768
- // reading them as stable.
11769
- const total = nodeCountRead ? await nodeCountRead : lastNodeCount
11770
- if (total === BUSY) workerBusy = true
11771
- nodeCount = typeof total === 'number' ? total : null
11772
- const accessibility = accessibilityRead ? await accessibilityRead : null
11773
- const nativeHierarchy = Array.isArray(accessibility) && accessibility.length > 0
11774
- ? accessibility
11775
- : null
11776
- if (accessibility === BUSY) workerBusy = true
11777
- let hierarchy = hierarchyRead ? await hierarchyRead : null
11778
- if (hierarchy === BUSY) {
11779
- workerBusy = true
11780
- hierarchy = null
11781
- } else if (!Array.isArray(hierarchy)) {
11782
- hierarchy = null
11708
+ // positive checks only: an older runtime without the blocking
11709
+ // fields reads as still, and strict rejects that runtime above
11710
+ // instead of ever settling on unknown motion.
11711
+ animating =
11712
+ stats.hasActiveAnims === true ||
11713
+ stats.hasActiveBlockingNativeAnimations === true ||
11714
+ (!screenStill && (readyPlayback ? stats.hasPendingReadinessAnimationFrames : stats.hasPendingBlockingAnimationFrames) === true)
11715
+ if (animating)
11716
+ animatingBy = [
11717
+ stats.hasActiveAnims === true && 'activeAnims',
11718
+ stats.hasActiveBlockingNativeAnimations === true && 'blockingNative',
11719
+ !screenStill && stats.hasPendingBlockingAnimationFrames === true && 'pendingFrames',
11720
+ !screenStill && stats.hasPendingReadinessAnimationFrames === true && 'pendingReadinessFrames',
11721
+ ].filter(Boolean).join('+')
11722
+ // the runtime reports only layout work that can reach the window:
11723
+ // a covered screen or inactive tab committing does not hold it.
11724
+ layoutDirty =
11725
+ stats.layoutDirty === true && stats.renderRequested === true
11726
+ // a freshly-pushed screen showing a skeleton is layout-stable
11727
+ // but not actually settled \u2014 its data/images are still in
11728
+ // flight. treat bounded image-loader fetches as not-idle so
11729
+ // settle waits for real content, capped by the budget.
11730
+ const pf = stats.memory && stats.memory.imageLoader
11731
+ ? stats.memory.imageLoader.pendingFetches
11732
+ : 0
11733
+ pendingFetches = typeof pf === 'number' ? pf : 0
11734
+ // tenant layout commits: a screen that keeps committing is still
11735
+ // mounting or remounting, even with no animation flag raised.
11736
+ appCommits = typeof stats.appCommitCount === 'number' ? stats.appCommitCount : null
11737
+ }
11738
+ // mounted-root membership: the count of nodes that can reach the
11739
+ // window moves while the screen mounts, unmounts or recycles, in
11740
+ // either render mode. a screen a pushed one covers or an inactive
11741
+ // tab stays mounted out of the window, so what it mounts is not
11742
+ // screen motion. the worker rebuilds the membership set while the
11743
+ // wire moves on every animated frame, so a poll the motion read
11744
+ // already fails skips it: the motion flags alone prove this poll
11745
+ // unsettled, and the carried count hands the first still poll the
11746
+ // pre-motion baseline to compare against.
11747
+ const motionStill = !workerBusy && !animating && !layoutDirty && !shellAnimating
11748
+ const nodeCountRead = motionStill
11749
+ ? answer(() => globalThis.__sootsimTest?.getWindowNodeCount?.()).catch(() => null)
11750
+ : null
11751
+ const compositor = await compositorRead
11752
+ if (compositor === BUSY) {
11753
+ workerBusy = true
11754
+ } else {
11755
+ pendingFetches += compositor.images.pendingFetches
11756
+ pendingFetches += compositor.imageRealization.pending
11757
+ if (compositor.webViewCaptureSettled === false) {
11758
+ webViewStarting = true
11759
+ webViewBlocker = 'compositor webView capture not settled'
11783
11760
  }
11784
- const nodes = []
11785
- // identity beside each geometry entry, from the rows already read,
11786
- // so a changed layout can name the nodes that moved.
11787
- const nodeRows = []
11788
- const LOADING_TEXT_REGEX = /^(creating webview|loading html|fetching bundle|waiting for first render|starting preview|loading simulator|fetching app code|waiting for native preview|starting design|loading canvas|fetching screens|painting the canvas|waiting for webview|waiting for preview|waiting for canvas|preview stalled)/i
11789
- const noteLoading = (state, text) => {
11790
- if (state?.busy === true) {
11791
- webViewStarting = true
11792
- if (!webViewBlocker) webViewBlocker = 'accessibility busy state active'
11793
- }
11794
- if (typeof text === 'string' && LOADING_TEXT_REGEX.test(text.trim())) {
11795
- webViewStarting = true
11796
- if (!webViewBlocker) webViewBlocker = 'webView startup in progress ("' + text.trim() + '")'
11761
+ }
11762
+ const counts = await countsRead
11763
+ if (counts === BUSY) workerBusy = true
11764
+ // <Image> loads are left to the image loader, which counts only those
11765
+ // that can reach the window. a runtime older than the CLI reports none.
11766
+ const imageLoads = counts?.imageLoads ?? { total: 0, inFlight: 0 }
11767
+ requestTotal = typeof counts?.total === 'number' ? counts.total - imageLoads.total : 0
11768
+ requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight - imageLoads.inFlight : 0
11769
+ // a skipped read carries the last count: mounts during motion still
11770
+ // break the first still poll after it, instead of a blank baseline
11771
+ // reading them as stable.
11772
+ const total = nodeCountRead ? await nodeCountRead : lastNodeCount
11773
+ if (total === BUSY) workerBusy = true
11774
+ nodeCount = typeof total === 'number' ? total : null
11775
+ const accessibility = accessibilityRead ? await accessibilityRead : null
11776
+ const nativeHierarchy = Array.isArray(accessibility) && accessibility.length > 0
11777
+ ? accessibility
11778
+ : null
11779
+ if (accessibility === BUSY) workerBusy = true
11780
+ let hierarchy = hierarchyRead ? await hierarchyRead : null
11781
+ if (hierarchy === BUSY) {
11782
+ workerBusy = true
11783
+ hierarchy = null
11784
+ } else if (!Array.isArray(hierarchy)) {
11785
+ hierarchy = null
11786
+ }
11787
+ const nodes = []
11788
+ // identity beside each geometry entry, from the rows already read,
11789
+ // so a changed layout can name the nodes that moved.
11790
+ const nodeRows = []
11791
+ const LOADING_TEXT_REGEX = /^(creating webview|loading html|fetching bundle|waiting for first render|starting preview|loading simulator|fetching app code|waiting for native preview|starting design|loading canvas|fetching screens|painting the canvas|waiting for webview|waiting for preview|waiting for canvas|preview stalled)/i
11792
+ const noteLoading = (state, text) => {
11793
+ if (state?.busy === true) {
11794
+ webViewStarting = true
11795
+ if (!webViewBlocker) webViewBlocker = 'accessibility busy state active'
11796
+ }
11797
+ if (typeof text === 'string' && LOADING_TEXT_REGEX.test(text.trim())) {
11798
+ webViewStarting = true
11799
+ if (!webViewBlocker) webViewBlocker = 'webView startup in progress ("' + text.trim() + '")'
11800
+ }
11801
+ }
11802
+ if (hierarchy) {
11803
+ for (const n of hierarchy) {
11804
+ const layout = n && n.layout
11805
+ if (layout && layout.width > 0) {
11806
+ // painted bounds catch a scroll fling. background playback
11807
+ // keeps a view's painted bounds moving forever, so it and its
11808
+ // subtree count by their own layout; the rest of the screen
11809
+ // still catches the fling.
11810
+ const abs = n.backgroundPlayback ? layout : n.absolute || n.absolutePosition || layout
11811
+ const geometry = Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width)
11812
+ nodes.push(geometry)
11813
+ nodeRows.push([String(n.nodeId ?? nodes.length - 1), (n.type || '?') + (n.testId ? '#' + n.testId : ''), geometry])
11797
11814
  }
11815
+ noteLoading(
11816
+ n.accessibilityState,
11817
+ typeof n.text === 'string' ? n.text : '',
11818
+ )
11798
11819
  }
11799
- if (hierarchy) {
11800
- for (const n of hierarchy) {
11801
- const layout = n && n.layout
11802
- if (layout && layout.width > 0) {
11803
- // painted bounds catch a scroll fling. background playback
11804
- // keeps a view's painted bounds moving forever, so it and its
11805
- // subtree count by their own layout; the rest of the screen
11806
- // still catches the fling.
11807
- const abs = n.backgroundPlayback ? layout : n.absolute || n.absolutePosition || layout
11808
- const geometry = Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width)
11820
+ } else {
11821
+ const root = globalThis.__sootsimRoot
11822
+ if (root) {
11823
+ const walk = (n) => {
11824
+ if (n.layout && n.layout.width > 0) {
11825
+ const geometry = Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width)
11809
11826
  nodes.push(geometry)
11810
- nodeRows.push([String(n.nodeId ?? nodes.length - 1), (n.type || '?') + (n.testId ? '#' + n.testId : ''), geometry])
11827
+ nodeRows.push([String(n.id ?? nodes.length - 1), (n.type || '?') + (n.props?.testID ? '#' + n.props.testID : ''), geometry])
11811
11828
  }
11812
11829
  noteLoading(
11813
- n.accessibilityState,
11814
- typeof n.text === 'string' ? n.text : '',
11830
+ n.props?.accessibilityState,
11831
+ n.textContent || (typeof n.props?.children === 'string' ? n.props.children : ''),
11815
11832
  )
11833
+ for (const c of n.children || []) walk(c)
11816
11834
  }
11817
- } else {
11818
- const root = globalThis.__sootsimRoot
11819
- if (root) {
11820
- const walk = (n) => {
11821
- if (n.layout && n.layout.width > 0) {
11822
- const geometry = Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width)
11823
- nodes.push(geometry)
11824
- nodeRows.push([String(n.id ?? nodes.length - 1), (n.type || '?') + (n.props?.testID ? '#' + n.props.testID : ''), geometry])
11825
- }
11826
- noteLoading(
11827
- n.props?.accessibilityState,
11828
- n.textContent || (typeof n.props?.children === 'string' ? n.props.children : ''),
11829
- )
11830
- for (const c of n.children || []) walk(c)
11831
- }
11832
- walk(root)
11833
- }
11835
+ walk(root)
11834
11836
  }
11835
- if (!webViewStarting && typeof document !== 'undefined') {
11836
- const busyEl = [...document.querySelectorAll('[aria-busy="true"]')].find((element) => {
11837
- const bounds = element.getBoundingClientRect()
11838
- return element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&
11839
- bounds.width > 0 && bounds.height > 0 && bounds.right > 0 && bounds.bottom > 0 &&
11840
- bounds.left < globalThis.innerWidth && bounds.top < globalThis.innerHeight
11837
+ }
11838
+ if (!webViewStarting && typeof document !== 'undefined') {
11839
+ const busyEl = [...document.querySelectorAll('[aria-busy="true"]')].find((element) => {
11840
+ const bounds = element.getBoundingClientRect()
11841
+ return element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&
11842
+ bounds.width > 0 && bounds.height > 0 && bounds.right > 0 && bounds.bottom > 0 &&
11843
+ bounds.left < globalThis.innerWidth && bounds.top < globalThis.innerHeight
11844
+ })
11845
+ if (busyEl) {
11846
+ webViewStarting = true
11847
+ webViewBlocker = 'accessibility busy element displayed'
11848
+ } else {
11849
+ // a loading document with no area (an app's hidden worker or
11850
+ // executor frame) paints nothing, and a screenshot on device
11851
+ // does not wait for it.
11852
+ const unreadyWebView = [...document.querySelectorAll(
11853
+ '[data-sootsim-webview-loading="true"], [data-sootsim-webview-mode="placeholder"]'
11854
+ )].find((view) => {
11855
+ const frame = view.querySelector('iframe')
11856
+ return !frame || frame.clientWidth > 0 || frame.clientHeight > 0
11841
11857
  })
11842
- if (busyEl) {
11858
+ if (unreadyWebView) {
11843
11859
  webViewStarting = true
11844
- webViewBlocker = 'accessibility busy element displayed'
11845
- } else {
11846
- // a loading document with no area (an app's hidden worker or
11847
- // executor frame) paints nothing, and a screenshot on device
11848
- // does not wait for it.
11849
- const unreadyWebView = [...document.querySelectorAll(
11850
- '[data-sootsim-webview-loading="true"], [data-sootsim-webview-mode="placeholder"]'
11851
- )].find((view) => {
11852
- const frame = view.querySelector('iframe')
11853
- return !frame || frame.clientWidth > 0 || frame.clientHeight > 0
11854
- })
11855
- if (unreadyWebView) {
11856
- webViewStarting = true
11857
- webViewBlocker = 'webView document still loading'
11858
- }
11860
+ webViewBlocker = 'webView document still loading'
11859
11861
  }
11860
11862
  }
11861
- const pixelsDecide = !workerBusy && !animating && !shellAnimating && !layoutDirty && pendingFetches === 0 && !webViewStarting
11862
- if (paintStill && !pixelsDecide && unsubscribe) {
11863
- unsubscribe()
11864
- unsubscribe = null
11865
- }
11866
- if (paintStill && pixelsDecide && !unsubscribe) unsubscribe = composite.subscribe(() => {})
11867
- if (paintStill && pixelsDecide) {
11868
- const canvas = composite.getCanvas()
11869
- const token = composite.getFrameToken()
11870
- if (!canvas || canvas.width <= 1 || canvas.height <= 1) {
11871
- screenPixels = null
11872
- } else if (token !== pixelFrameToken || canvas.width !== screenPixels?.width || canvas.height !== screenPixels?.height) {
11873
- const context = canvas.getContext('2d')
11874
- const image = context?.getImageData(0, 0, canvas.width, canvas.height)
11875
- screenPixels = image ? { width: image.width, height: image.height, data: new Uint32Array(image.data.buffer) } : null
11876
- pixelFrameToken = token
11877
- }
11878
- }
11879
- return { layout: nodes.join(';'), nodeRows, nativeHierarchy, screenPixels, animating, animatingBy, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
11880
11863
  }
11881
-
11882
- // how long generic background network is allowed to keep us waiting AFTER
11883
- // the screen is otherwise visually settled. apps with continuous traffic
11884
- // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
11885
- // requestInFlight===0 / a stable requestTotal, so requiring full network
11886
- // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
11887
- // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
11888
- // layout-stability + the image-loader already prove visible content
11889
- // loaded (a data load changes layout; an image load shows in the loader),
11890
- // so the generic request counters are a courtesy, not a gate: honor them
11891
- // only within this grace once the screen is visually still.
11892
- const networkQuietGraceMs = 1200
11893
- let lastNativeHierarchy = null
11894
- let lastLayout = ''
11895
- let lastNodeRows = []
11896
- // what moved between the last two differing polls, bounded; names the
11897
- // nodes behind "layout changed" without keeping any poll history.
11898
- let lastLayoutChange = null
11899
- const describeLayoutChange = (before, after) => {
11900
- const previous = new Map(before.map(([key, label, geometry]) => [key, [label, geometry]]))
11901
- const moved = []
11902
- const added = []
11903
- const short = (label, key) => String(label).slice(0, 48) + ' [' + String(key).slice(0, 24) + ']'
11904
- for (const [key, label, geometry] of after) {
11905
- const was = previous.get(key)
11906
- previous.delete(key)
11907
- if (!was) added.push(short(label, key) + ' ' + geometry)
11908
- else if (was[1] !== geometry) moved.push(short(label, key) + ' ' + was[1] + '->' + geometry)
11909
- }
11910
- const removed = [...previous].map(([key, [label, geometry]]) => short(label, key) + ' ' + geometry)
11911
- return {
11912
- moved: moved.length, added: added.length, removed: removed.length,
11913
- movedSample: moved.slice(0, 3), addedSample: added.slice(0, 3), removedSample: removed.slice(0, 3),
11914
- }
11864
+ return { layout: nodes.join(';'), nodeRows, nativeHierarchy, visibleMotion, visibleMotionBy, animating, animatingBy, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, motionUnavailable, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
11865
+ }
11866
+
11867
+ // how long generic background network is allowed to keep us waiting AFTER
11868
+ // the screen is otherwise visually settled. apps with continuous traffic
11869
+ // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
11870
+ // requestInFlight===0 / a stable requestTotal, so requiring full network
11871
+ // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
11872
+ // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
11873
+ // layout-stability + the image-loader already prove visible content
11874
+ // loaded (a data load changes layout; an image load shows in the loader),
11875
+ // so the generic request counters are a courtesy, not a gate: honor them
11876
+ // only within this grace once the screen is visually still.
11877
+ const networkQuietGraceMs = 1200
11878
+ let lastNativeHierarchy = null
11879
+ let lastLayout = ''
11880
+ let lastNodeRows = []
11881
+ // what moved between the last two differing polls, bounded; names the
11882
+ // nodes behind "layout changed" without keeping any poll history.
11883
+ let lastLayoutChange = null
11884
+ const describeLayoutChange = (before, after) => {
11885
+ const previous = new Map(before.map(([key, label, geometry]) => [key, [label, geometry]]))
11886
+ const moved = []
11887
+ const added = []
11888
+ const short = (label, key) => String(label).slice(0, 48) + ' [' + String(key).slice(0, 24) + ']'
11889
+ for (const [key, label, geometry] of after) {
11890
+ const was = previous.get(key)
11891
+ previous.delete(key)
11892
+ if (!was) added.push(short(label, key) + ' ' + geometry)
11893
+ else if (was[1] !== geometry) moved.push(short(label, key) + ' ' + was[1] + '->' + geometry)
11915
11894
  }
11916
- let lastScreenPixels = null
11917
- let screenChangedPolls = 0
11918
- let lastRequestTotal = -1
11919
- let lastAppCommits = null
11920
- let lastNodeCount = null
11921
- // the last completed poll and the values it was compared against.
11922
- let report = null
11923
- // the still polls of the current run, when each began and answered
11924
- let stillPolls = []
11925
- let lastIdlePoll = null
11926
- let visuallyStillSince = 0
11927
- // counts across the whole budget: a flag that is true on every poll is a
11928
- // different bug from one that is true intermittently, and the two need
11929
- // opposite fixes (engine vs budget).
11930
- let polls = 0
11931
- let dirtyPolls = 0
11932
- let animatingPolls = 0
11933
- let layoutChangedPolls = 0
11934
- let webViewStartingPolls = 0
11935
- const screenUnchanged = (pixels, previous) => {
11936
- if (!pixels || !previous || pixels.width !== previous.width || pixels.height !== previous.height) return false
11937
- if (pixels === previous) return true
11938
- for (let i = 0; i < pixels.data.length; i++) {
11939
- if (pixels.data[i] !== previous.data[i]) return false
11940
- }
11941
- return true
11895
+ const removed = [...previous].map(([key, [label, geometry]]) => short(label, key) + ' ' + geometry)
11896
+ return {
11897
+ moved: moved.length, added: added.length, removed: removed.length,
11898
+ movedSample: moved.slice(0, 3), addedSample: added.slice(0, 3), removedSample: removed.slice(0, 3),
11942
11899
  }
11943
- const hierarchyUnchanged = (current, previous) =>
11944
- current !== null && previous !== null && current.length === previous.length &&
11945
- current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
11946
- while (true) {
11947
- if (clockNow() >= deadline) {
11948
- if (!transitionWait) break
11949
- await transitionWait
11950
- transitionWait = null
11951
- // nothing polled while parked on the transition, and a loaded
11952
- // worker's late reply would spend the restarted budget unobserved.
11953
- if (transitionEndedAt !== null) deadline = Math.max(deadline, clockNow() + budgetMs)
11954
- if (clockNow() >= deadline) break
11955
- }
11956
- const pollStarted = clockNow()
11957
- const snapshot = await readSnapshot()
11958
- if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
11959
- // a read the deadline cut short observed nothing: the last full poll
11960
- // names what held the settle, not a worker that ran out of budget.
11961
- // the loop head drains a transition still in flight before it ends.
11962
- if (snapshot.workerBusy && clockNow() >= deadline && report) continue
11963
- polls++
11964
- report = { snapshot, nativeHierarchy: lastNativeHierarchy, layout: lastLayout, screenPixels: lastScreenPixels, requestTotal: lastRequestTotal, appCommits: lastAppCommits, nodeCount: lastNodeCount }
11965
- if (snapshot.layoutDirty) dirtyPolls++
11966
- if (snapshot.animating || snapshot.shellAnimating) animatingPolls++
11967
- if (snapshot.webViewStarting) webViewStartingPolls++
11968
- if (polls > 1 && snapshot.layout !== lastLayout) {
11969
- layoutChangedPolls++
11970
- lastLayoutChange = describeLayoutChange(lastNodeRows, snapshot.nodeRows)
11971
- }
11972
- const screenChanged = paintStill && !screenUnchanged(snapshot.screenPixels, lastScreenPixels)
11973
- if (polls > 1 && screenChanged) screenChangedPolls++
11974
- const strictOk =
11975
- !strict ||
11976
- (snapshot.renderStatsAvailable &&
11977
- !snapshot.animating &&
11978
- !snapshot.shellAnimating &&
11979
- !snapshot.layoutDirty)
11980
- // visually settled: no worker motion or layout work, no new layout
11981
- // commits, a stable mounted node count, no image content loading
11982
- // (unless motion alone is asked), no webview startup in progress,
11983
- // layout unchanged since the last poll. both modes wait out finite
11984
- // worker motion now; strict additionally implies the flags through
11985
- // strictOk and adds shell motion plus the blocking-stats floor. a
11986
- // null count or commit reading means the runtime does not report
11987
- // it, which reads as stable the way a missing stats block does.
11988
- // equal presented pixels can precede pending worker motion or layout.
11989
- // after that work drains, iOS's 3 s pixel phase may accept two equal
11990
- // native TreeNodes while paint-only playback continues. overlap
11991
- // hierarchy reads so neither the gesture nor screenshot deadline grows.
11992
- const maestroStill = snapshot.screenPixels !== null && !snapshot.workerBusy && snapshot.pendingFetches === 0 && snapshot.requestInFlight === 0 && !snapshot.webViewStarting &&
11993
- !snapshot.animating && !snapshot.shellAnimating && !snapshot.layoutDirty && (
11994
- !screenChanged || (clockNow() - start >= 3000 &&
11995
- hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
11996
- )
11997
- const idleSnapshot =
11998
- strictOk &&
11900
+ }
11901
+ let screenChangedPolls = 0
11902
+ let lastRequestTotal = -1
11903
+ let lastAppCommits = null
11904
+ let lastNodeCount = null
11905
+ // the last completed poll and the values it was compared against.
11906
+ let report = null
11907
+ // the still polls of the current run, when each began and answered
11908
+ let stillPolls = []
11909
+ let lastIdlePoll = null
11910
+ let visuallyStillSince = 0
11911
+ // counts across the whole budget: a flag that is true on every poll is a
11912
+ // different bug from one that is true intermittently, and the two need
11913
+ // opposite fixes (engine vs budget).
11914
+ let polls = 0
11915
+ let dirtyPolls = 0
11916
+ let animatingPolls = 0
11917
+ let layoutChangedPolls = 0
11918
+ let webViewStartingPolls = 0
11919
+ const hierarchyUnchanged = (current, previous) =>
11920
+ current !== null && previous !== null && current.length === previous.length &&
11921
+ current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
11922
+ while (true) {
11923
+ if (clockNow() >= deadline) {
11924
+ if (!transitionWait) break
11925
+ await transitionWait
11926
+ transitionWait = null
11927
+ // nothing polled while parked on the transition, and a loaded
11928
+ // worker's late reply would spend the restarted budget unobserved.
11929
+ if (transitionEndedAt !== null) deadline = Math.max(deadline, clockNow() + budgetMs)
11930
+ if (clockNow() >= deadline) break
11931
+ }
11932
+ const pollStarted = clockNow()
11933
+ const snapshot = await readSnapshot()
11934
+ if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
11935
+ // a read the deadline cut short observed nothing: the last full poll
11936
+ // names what held the settle, not a worker that ran out of budget.
11937
+ // the loop head drains a transition still in flight before it ends.
11938
+ if (snapshot.workerBusy && clockNow() >= deadline && report) continue
11939
+ polls++
11940
+ report = { snapshot, nativeHierarchy: lastNativeHierarchy, layout: lastLayout, requestTotal: lastRequestTotal, appCommits: lastAppCommits, nodeCount: lastNodeCount }
11941
+ if (snapshot.layoutDirty) dirtyPolls++
11942
+ if (snapshot.animating || snapshot.shellAnimating) animatingPolls++
11943
+ if (snapshot.webViewStarting) webViewStartingPolls++
11944
+ if (polls > 1 && snapshot.layout !== lastLayout) {
11945
+ layoutChangedPolls++
11946
+ lastLayoutChange = describeLayoutChange(lastNodeRows, snapshot.nodeRows)
11947
+ }
11948
+ // the first poll has nothing to compare, so it cannot prove a still screen
11949
+ const screenChanged = screenStill && (
11950
+ polls === 1 ||
11951
+ snapshot.visibleMotion ||
11952
+ (snapshot.appCommits !== null && lastAppCommits !== null && snapshot.appCommits !== lastAppCommits) ||
11953
+ (snapshot.nodeCount !== null && lastNodeCount !== null && snapshot.nodeCount !== lastNodeCount) ||
11954
+ snapshot.layout !== lastLayout ||
11955
+ (maestro && !hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
11956
+ )
11957
+ if (polls > 1 && screenChanged) screenChangedPolls++
11958
+ const strictOk =
11959
+ !strict ||
11960
+ (snapshot.renderStatsAvailable &&
11999
11961
  !snapshot.animating &&
12000
11962
  !snapshot.shellAnimating &&
12001
- !snapshot.layoutDirty &&
12002
- snapshot.pendingFetches === 0 &&
12003
- !snapshot.workerBusy &&
12004
- !snapshot.webViewStarting
12005
- const visuallyStill = maestro ? maestroStill :
12006
- idleSnapshot &&
12007
- (snapshot.appCommits === null || lastAppCommits === null || snapshot.appCommits === lastAppCommits) &&
12008
- (snapshot.nodeCount === null || lastNodeCount === null || snapshot.nodeCount === lastNodeCount) &&
12009
- !screenChanged &&
12010
- snapshot.layout === lastLayout
12011
- // generic network quiet: nothing in flight and no new requests issued.
12012
- const networkQuiet =
12013
- snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
12014
- if (visuallyStill) {
12015
- if (visuallyStillSince === 0) visuallyStillSince = clockNow()
12016
- // two equal idle observations prove the interval between them.
12017
- // discarding the first requires a third worker round trip, which
12018
- // can exhaust the budget after a late image on a loaded host.
12019
- if (!maestro && !paintStill && stillPolls.length === 0 && lastIdlePoll) {
12020
- stillPolls.push(lastIdlePoll)
12021
- }
12022
- stillPolls.push({ started: pollStarted, answered: clockNow() })
12023
- // still long enough, counting only polls that began after a started
12024
- // transition drained.
12025
- const stillProven = () => {
12026
- const proving = stillPolls.filter((poll) => transitionEndedAt === null || poll.started >= transitionEndedAt)
12027
- return proving.length >= minimumStablePolls && clockNow() - proving[0].answered >= requiredStillMs
12028
- }
12029
- // settle once the screen has held still long enough AND either the
12030
- // network is genuinely quiet OR it has refused to quiet within the
12031
- // grace (continuous background traffic must not block forever).
12032
- if (
12033
- stillProven() &&
12034
- (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
12035
- ) {
12036
- if (transitionWait) {
12037
- await transitionWait
12038
- transitionWait = null
12039
- }
12040
- if (stillProven()) return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
11963
+ !snapshot.layoutDirty)
11964
+ // visually settled: no worker motion or layout work, no new layout
11965
+ // commits, a stable mounted node count, no image content loading
11966
+ // (unless motion alone is asked), no webview startup in progress,
11967
+ // layout unchanged since the last poll. both modes wait out finite
11968
+ // worker motion now; strict additionally implies the flags through
11969
+ // strictOk and adds shell motion plus the blocking-stats floor. a
11970
+ // null count or commit reading means the runtime does not report
11971
+ // it, which reads as stable the way a missing stats block does.
11972
+ // equal presented pixels can precede pending worker motion or layout.
11973
+ // after that work drains, iOS's 3 s pixel phase may accept two equal
11974
+ // native TreeNodes while paint-only playback continues. overlap
11975
+ // hierarchy reads so neither the gesture nor screenshot deadline grows.
11976
+ const maestroStill = !snapshot.workerBusy && snapshot.pendingFetches === 0 && snapshot.requestInFlight === 0 && !snapshot.webViewStarting &&
11977
+ !snapshot.animating && !snapshot.shellAnimating && !snapshot.layoutDirty && (
11978
+ !screenChanged || (clockNow() - start >= 3000 &&
11979
+ hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
11980
+ )
11981
+ const idleSnapshot =
11982
+ strictOk &&
11983
+ !snapshot.animating &&
11984
+ !snapshot.shellAnimating &&
11985
+ !snapshot.layoutDirty &&
11986
+ snapshot.pendingFetches === 0 &&
11987
+ !snapshot.workerBusy &&
11988
+ !snapshot.webViewStarting
11989
+ const visuallyStill = maestro ? maestroStill :
11990
+ idleSnapshot &&
11991
+ (snapshot.appCommits === null || lastAppCommits === null || snapshot.appCommits === lastAppCommits) &&
11992
+ (snapshot.nodeCount === null || lastNodeCount === null || snapshot.nodeCount === lastNodeCount) &&
11993
+ !screenChanged &&
11994
+ snapshot.layout === lastLayout
11995
+ // generic network quiet: nothing in flight and no new requests issued.
11996
+ const networkQuiet =
11997
+ snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
11998
+ if (visuallyStill) {
11999
+ if (visuallyStillSince === 0) visuallyStillSince = clockNow()
12000
+ // two equal idle observations prove the interval between them.
12001
+ // discarding the first requires a third worker round trip, which
12002
+ // can exhaust the budget after a late image on a loaded host.
12003
+ if (!maestro && !screenStill && stillPolls.length === 0 && lastIdlePoll) {
12004
+ stillPolls.push(lastIdlePoll)
12005
+ }
12006
+ stillPolls.push({ started: pollStarted, answered: clockNow() })
12007
+ // still long enough, counting only polls that began after a started
12008
+ // transition drained.
12009
+ const stillProven = () => {
12010
+ const proving = stillPolls.filter((poll) => transitionEndedAt === null || poll.started >= transitionEndedAt)
12011
+ return proving.length >= minimumStablePolls && clockNow() - proving[0].answered >= requiredStillMs
12012
+ }
12013
+ // settle once the screen has held still long enough AND either the
12014
+ // network is genuinely quiet OR it has refused to quiet within the
12015
+ // grace (continuous background traffic must not block forever).
12016
+ if (
12017
+ stillProven() &&
12018
+ (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
12019
+ ) {
12020
+ if (transitionWait) {
12021
+ await transitionWait
12022
+ transitionWait = null
12041
12023
  }
12042
- } else {
12043
- stillPolls = []
12044
- visuallyStillSince = 0
12024
+ if (stillProven()) return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
12045
12025
  }
12046
- lastIdlePoll = idleSnapshot ? { started: pollStarted, answered: clockNow() } : null
12047
- lastNativeHierarchy = snapshot.nativeHierarchy
12048
- lastLayout = snapshot.layout
12049
- lastNodeRows = snapshot.nodeRows
12050
- lastScreenPixels = snapshot.screenPixels
12051
- lastRequestTotal = snapshot.requestTotal
12052
- lastAppCommits = snapshot.appCommits
12053
- lastNodeCount = snapshot.nodeCount
12054
- // reply latency belongs inside the poll interval; the stillness window
12055
- // above remains measured from completed observations.
12056
- const remainingPollMs = pollMs - (clockNow() - pollStarted)
12057
- if (remainingPollMs > 0) await clockSleep(remainingPollMs)
12058
- }
12059
- if (!report) {
12060
- return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
12061
- }
12062
- const last = report.snapshot
12063
- const blockers = []
12064
- if (!maestro && strict && !last.renderStatsAvailable) blockers.push('render stats unavailable')
12065
- if (!maestro && last.animating) blockers.push('animations still running' + (last.animatingBy ? ' (' + last.animatingBy + ')' : ''))
12066
- if (last.shellAnimating) blockers.push('animations still running (' + last.shellBlockers + ')')
12067
- if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
12068
- if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
12069
- if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
12070
- if (last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
12071
- if (last.workerBusy) blockers.push('a render worker too busy to report')
12072
- if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
12073
- if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
12074
- if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
12075
- if (paintStill && !last.screenPixels) blockers.push('screen pixels unavailable')
12076
- else if (paintStill && !screenUnchanged(last.screenPixels, report.screenPixels)) blockers.push('screen pixels still changing')
12077
- if (last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
12078
- else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
12079
- if (polls < 2) blockers.push('sim too busy to poll twice')
12080
- // the last read is still: motion ended too near the deadline for the
12081
- // stillness window to hold before it.
12082
- if (!blockers.length) blockers.push('motion ended before stillness was proven')
12083
- return {
12084
- settled: false,
12085
- elapsed: clockNow() - start,
12086
- blockedBy:
12087
- blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
12088
- 'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
12089
- (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
12026
+ } else {
12027
+ stillPolls = []
12028
+ visuallyStillSince = 0
12090
12029
  }
12091
- } finally {
12092
- unsubscribe?.()
12030
+ lastIdlePoll = idleSnapshot ? { started: pollStarted, answered: clockNow() } : null
12031
+ lastNativeHierarchy = snapshot.nativeHierarchy
12032
+ lastLayout = snapshot.layout
12033
+ lastNodeRows = snapshot.nodeRows
12034
+ lastRequestTotal = snapshot.requestTotal
12035
+ lastAppCommits = snapshot.appCommits
12036
+ lastNodeCount = snapshot.nodeCount
12037
+ // reply latency belongs inside the poll interval; the stillness window
12038
+ // above remains measured from completed observations.
12039
+ const remainingPollMs = pollMs - (clockNow() - pollStarted)
12040
+ if (remainingPollMs > 0) await clockSleep(remainingPollMs)
12041
+ }
12042
+ if (!report) {
12043
+ return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
12044
+ }
12045
+ const last = report.snapshot
12046
+ const blockers = []
12047
+ if (!maestro && strict && !last.renderStatsAvailable) blockers.push('render stats unavailable')
12048
+ if (!maestro && last.animating) blockers.push('animations still running' + (last.animatingBy ? ' (' + last.animatingBy + ')' : ''))
12049
+ if (last.shellAnimating) blockers.push('animations still running (' + last.shellBlockers + ')')
12050
+ if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
12051
+ if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
12052
+ if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
12053
+ if (last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
12054
+ if (last.motionUnavailable) blockers.push('animation reporting unavailable')
12055
+ if (last.workerBusy && !last.motionUnavailable) blockers.push('a render worker too busy to report')
12056
+ if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
12057
+ if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
12058
+ if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
12059
+ if (screenStill && last.visibleMotion) blockers.push('visible motion continues (' + last.visibleMotionBy + ')')
12060
+ if (last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
12061
+ else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
12062
+ if (polls < 2) blockers.push('sim too busy to poll twice')
12063
+ // the last read is still: motion ended too near the deadline for the
12064
+ // stillness window to hold before it.
12065
+ if (!blockers.length) blockers.push('motion ended before stillness was proven')
12066
+ return {
12067
+ settled: false,
12068
+ elapsed: clockNow() - start,
12069
+ blockedBy:
12070
+ blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
12071
+ 'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
12072
+ (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
12093
12073
  }
12094
12074
  })()`
12095
12075
  },
@@ -13528,7 +13508,7 @@ function readIosSdkTree(root) {
13528
13508
 
13529
13509
  // src/swift-standin-digest.ts
13530
13510
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
13531
- var STANDIN_SOURCE_DIGEST = true ? "a337dfa692c4f84cc4b30522d000cdd1c7c4c140d002f00e11c12179ed99631e" : standinSourceDigest();
13511
+ var STANDIN_SOURCE_DIGEST = true ? "9d24428078636d005cc1401363f5f50704e049f52802b0493da7eea674470942" : standinSourceDigest();
13532
13512
 
13533
13513
  // src/expo-native-workspace.ts
13534
13514
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
@@ -16067,7 +16047,7 @@ var FOUNDATION_IMPLICIT_MODULES = [
16067
16047
  var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
16068
16048
  (module2) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module2}"`
16069
16049
  ).join("");
16070
- var compilerSourceDigest = true ? "3bbc36e39985b08e87a73a633978d40d8856f485ad28dbc7caf18e13cba6bf81" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
16050
+ var compilerSourceDigest = true ? "b60df189803fef5c8b8fd902ae0a694ffbefe056af8f5fc06f707750dc97f09b" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
16071
16051
  var CORE_FOUNDATION_HANDLE_IMPORTS = [
16072
16052
  "CFAllocator",
16073
16053
  "CFArray",