peachsim 0.1.2238 → 0.1.2242

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 (107) hide show
  1. package/cli/bridge-flow-runner.ts +10 -9
  2. package/cli/commands/inspect/settling.ts +491 -506
  3. package/cli/commands/platform.ts +2 -0
  4. package/cli/drivers/playwright-provisioning.ts +160 -37
  5. package/cli/internal-child.ts +5 -79
  6. package/dist-lib/agent-daemon-client.cjs +1 -1
  7. package/dist-lib/agent-events.cjs +1 -1
  8. package/dist-lib/attached-projects.cjs +1 -1
  9. package/dist-lib/auth/shared-session.cjs +1 -1
  10. package/dist-lib/backend-origin.cjs +1 -1
  11. package/dist-lib/beta.cjs +1 -1
  12. package/dist-lib/beta.mjs +1 -1
  13. package/dist-lib/bridge-constants.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.mjs +1 -1
  16. package/dist-lib/bridge-contract.cjs +1 -1
  17. package/dist-lib/bridge-contract.mjs +1 -1
  18. package/dist-lib/bundle-channel.cjs +115 -89
  19. package/dist-lib/capture-contract.cjs +1 -1
  20. package/dist-lib/capture-contract.mjs +1 -1
  21. package/dist-lib/cloud-contract.cjs +1 -1
  22. package/dist-lib/cloud-contract.mjs +1 -1
  23. package/dist-lib/cloud-test-args.cjs +1 -1
  24. package/dist-lib/cloud-test-args.mjs +1 -1
  25. package/dist-lib/cloud.cjs +1 -1
  26. package/dist-lib/cloud.mjs +1 -1
  27. package/dist-lib/config.cjs +1 -1
  28. package/dist-lib/config.mjs +1 -1
  29. package/dist-lib/detox/index.cjs +494 -510
  30. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  31. package/dist-lib/expo-swift-bundle.cjs +101 -75
  32. package/dist-lib/expo-swift-metadata.cjs +1 -1
  33. package/dist-lib/expo-swift-metadata.mjs +1 -1
  34. package/dist-lib/home-paths.cjs +1 -1
  35. package/dist-lib/host/bridge-host.cjs +119 -93
  36. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  37. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  38. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  39. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  40. package/dist-lib/host/websocket-proxy.cjs +1 -1
  41. package/dist-lib/index.cjs +492 -508
  42. package/dist-lib/jump-to-source-babel.cjs +1 -1
  43. package/dist-lib/jump-to-source-native.cjs +1 -1
  44. package/dist-lib/kotlin-host.cjs +1 -1
  45. package/dist-lib/menu.cjs +1 -1
  46. package/dist-lib/menu.mjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  49. package/dist-lib/metro-production-bundle.cjs +1 -1
  50. package/dist-lib/metro-production-bundle.mjs +1 -1
  51. package/dist-lib/metro.cjs +4 -4
  52. package/dist-lib/native-app-identity-project.cjs +2 -2
  53. package/dist-lib/native-app-identity-project.mjs +7 -8
  54. package/dist-lib/native-app-identity.cjs +1 -1
  55. package/dist-lib/native-app-identity.mjs +1 -1
  56. package/dist-lib/native-firebase-metadata.cjs +1 -1
  57. package/dist-lib/native-firebase-metadata.mjs +1 -1
  58. package/dist-lib/pdfium-raster.cjs +1 -1
  59. package/dist-lib/pdfium-raster.mjs +1 -1
  60. package/dist-lib/plist.cjs +1 -1
  61. package/dist-lib/plist.mjs +1 -1
  62. package/dist-lib/profiles.cjs +1 -1
  63. package/dist-lib/public-brand.cjs +1 -1
  64. package/dist-lib/public-origins-lib-esm.json +24 -24
  65. package/dist-lib/public-origins-lib.json +53 -53
  66. package/dist-lib/react-native-host-modules.cjs +1 -1
  67. package/dist-lib/react-native-host-modules.mjs +1 -1
  68. package/dist-lib/reap-browser.cjs +1 -1
  69. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  70. package/dist-lib/sdk.cjs +487 -503
  71. package/dist-lib/sdk.mjs +487 -503
  72. package/dist-lib/skills.cjs +1327 -1235
  73. package/dist-lib/swift-compile.cjs +46 -27
  74. package/dist-lib/swift-compile.mjs +42 -23
  75. package/dist-lib/swift-package.cjs +1 -1
  76. package/dist-lib/swift-package.mjs +1 -1
  77. package/dist-lib/swift-submit.cjs +2 -2
  78. package/dist-lib/swift-submit.mjs +2 -2
  79. package/dist-lib/swift-toolchain.cjs +1 -1
  80. package/dist-lib/swift.cjs +1 -1
  81. package/dist-lib/vite-swift.cjs +89 -64
  82. package/dist-lib/vite.cjs +4 -4
  83. package/dist-lib/worklet-executable.cjs +1 -1
  84. package/dist-lib/worklet-executable.mjs +1 -1
  85. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  86. package/dist-types/packages/peach-engine/src/engine/secureItemHostContract.d.ts +5 -1
  87. package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -0
  88. package/dist-types/packages/peach-engine/src/ios/chrome-metrics.d.ts +6 -0
  89. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +4 -1
  90. package/dist-types/packages/peach-engine/src/render-worker/webview-capture-protocol.d.ts +14 -0
  91. package/dist-types/packages/peach-globals/src/nativeSurfaceContract.d.ts +1 -0
  92. package/dist-types/packages/peach-globals/src/secure-item-store.d.ts +2 -0
  93. package/kotlin/sdk.tar.gz +0 -0
  94. package/package.json +1 -1
  95. package/runtime-companion.json +1 -1
  96. package/src/native-static-libraries.ts +20 -20
  97. package/src/native-swift-slices.ts +1 -0
  98. package/src/nitro-adapter.lock.json +253 -253
  99. package/src/nitro-superset.lock.json +4 -4
  100. package/src/swift-compile.ts +10 -3
  101. package/src/swift-distribution.lock.json +11 -11
  102. package/src/swift-host.ts +2 -1
  103. package/src/swift-shared-sdk.ts +10 -1
  104. package/src/swift-standins.ts +5 -2
  105. package/src/swift-submit.ts +3 -1
  106. package/src/swift-wasm-prune.ts +23 -14
  107. package/src/turbo-runtime.lock.json +22 -22
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2238 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2242 | (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;
@@ -1732,7 +1732,7 @@ async function waitForSootsimIdle({
1732
1732
  pollMs = 50,
1733
1733
  stablePolls = 3,
1734
1734
  strict = false,
1735
- paintStill = false,
1735
+ screenStill = false,
1736
1736
  maestro = false,
1737
1737
  motionOnly = false,
1738
1738
  readyPlayback = false,
@@ -1770,7 +1770,7 @@ async function waitForSootsimIdle({
1770
1770
  let deadline = start + budgetMs
1771
1771
  const pollMs = ${Math.max(1, Math.round(pollMs))}
1772
1772
  const strict = ${strict ? "true" : "false"}
1773
- const paintStill = ${paintStill ? "true" : "false"}
1773
+ const screenStill = ${screenStill ? "true" : "false"}
1774
1774
  const maestro = ${maestro ? "true" : "false"}
1775
1775
  const accessibilityBounds = ${accessibilityBounds.toString()}
1776
1776
  const sameNativeAccessibilityShape = ${sameNativeAccessibilityShape.toString()}
@@ -1780,541 +1780,525 @@ async function waitForSootsimIdle({
1780
1780
  // tight budgets (auto-wait) settle on worker stillness plus root
1781
1781
  // membership, generous ones confirm the geometry too.
1782
1782
  const fullGeometry = ${!maestro && maxMs >= 1e3 ? "true" : "false"}
1783
- const requiredStillMs = paintStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
1784
- const minimumStablePolls = paintStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
1785
- const composite = paintStill ? globalThis.SootSim?.bridges?.liveComposite : null
1786
- if (paintStill && !composite) {
1787
- return { settled: false, elapsed: clockNow() - start, blockedBy: 'screen pixels unavailable' }
1788
- }
1789
- // subscribe to presented frames; authoritative screenshots force a
1790
- // worker render, which changes the very counter we used to inspect.
1791
- const unsubscribe = composite?.subscribe(() => {})
1783
+ const requiredStillMs = screenStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
1784
+ const minimumStablePolls = screenStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
1792
1785
  let transitionEndedAt = null
1793
- let pixelFrameToken = -1
1794
- let screenPixels = null
1795
1786
  // the hierarchy read last taken and the geometry revision it answered.
1796
1787
  // it outlives this wait: a revision still current when a later wait
1797
1788
  // polls names the same geometry, so a step that follows a settled one
1798
1789
  // proves an unchanged screen without walking the tree again.
1799
1790
  const geometry = (globalThis.__peachSettleGeometry ??= { revision: null, hierarchy: null })
1800
- try {
1801
-
1802
- // discover transitions while observing layout. when motion starts,
1803
- // observations from before its completion cannot prove the new screen;
1804
- // those that began after it drained still can. a loaded host runs a
1805
- // push past a tap's budget, so the transition gets its own timeout and
1806
- // the budget restarts once it drains.
1807
- let transitionWait = (async () => {
1808
- try {
1809
- const wfst = globalThis.__sootsimTest?.waitForScreenTransitions
1810
- if (typeof wfst === 'function' && budgetMs > 120) {
1811
- const transition = await wfst({
1812
- timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
1813
- settleMs: 64,
1814
- startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
1815
- })
1816
- if (transition?.started !== true) return false
1817
- // a loaded worker replies long after the motion stopped; it
1818
- // reports how long ago, so polls begun since still count. a
1819
- // runtime without the field ends the transition at the reply.
1820
- const rested = typeof transition.restedMs === 'number' ? Math.max(0, transition.restedMs) : 0
1821
- transitionEndedAt = clockNow() - rested
1822
- deadline = Math.max(deadline, transitionEndedAt + budgetMs)
1823
- return true
1824
- }
1825
- } catch {}
1826
- return false
1827
- })()
1828
-
1829
- // a worker that cannot answer within the remaining budget is busy, not
1830
- // idle: its poll reads as unsettled. bounding each read by the budget
1831
- // keeps a busy worker from holding a poll past the deadline.
1832
- const BUSY = { busy: true }
1833
- const answer = (read) =>
1834
- Promise.race([
1835
- Promise.resolve().then(read),
1836
- new Promise((resolve) =>
1837
- setTimeout(() => resolve(BUSY), Math.max(deadline - clockNow(), 100)),
1838
- ),
1839
- ])
1840
-
1841
- const readSnapshot = async () => {
1842
- let animating = false
1843
- let animatingBy = ''
1844
- let layoutDirty = false
1845
- let pendingFetches = 0
1846
- let workerBusy = false
1847
- let requestTotal = 0
1848
- let requestInFlight = 0
1849
- let appCommits = null
1850
- let nodeCount = null
1851
- let renderStatsAvailable = false
1852
- let shellAnimating = false
1853
- let shellBlockers = ''
1854
- let webViewStarting = false
1855
- let webViewBlocker = ''
1856
- // the reads are independent, so they run concurrently: a loaded sim
1857
- // answers each one late, and a poll that waits for them in turn
1858
- // costs their sum, which fits too few polls in the budget to settle.
1859
- // the window node count is the exception: it launches after the
1860
- // motion read, so a poll motion already fails skips that walk.
1861
- // strict reads also wait out shell motion. pixel reads inspect finite
1862
- // animations in both realms: a worklet can move the app while the
1863
- // tenant's basic animation flag and last presented pixels read still.
1864
- const accessibilityRead = maestro
1865
- ? answer(() => globalThis.__sootsimTest.captureAccessibilityTree()).catch(() => null)
1866
- : null
1867
- const motionRead = strict || paintStill
1868
- ? answer(() => globalThis.__sootsimTest?.listAnimations?.()).catch(() => null)
1791
+ // discover transitions while observing layout. when motion starts,
1792
+ // observations from before its completion cannot prove the new screen;
1793
+ // those that began after it drained still can. a loaded host runs a
1794
+ // push past a tap's budget, so the transition gets its own timeout and
1795
+ // the budget restarts once it drains.
1796
+ let transitionWait = (async () => {
1797
+ try {
1798
+ const wfst = globalThis.__sootsimTest?.waitForScreenTransitions
1799
+ if (typeof wfst === 'function' && budgetMs > 120) {
1800
+ const transition = await wfst({
1801
+ timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
1802
+ settleMs: 64,
1803
+ startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
1804
+ })
1805
+ if (transition?.started !== true) return false
1806
+ // a loaded worker replies long after the motion stopped; it
1807
+ // reports how long ago, so polls begun since still count. a
1808
+ // runtime without the field ends the transition at the reply.
1809
+ const rested = typeof transition.restedMs === 'number' ? Math.max(0, transition.restedMs) : 0
1810
+ transitionEndedAt = clockNow() - rested
1811
+ deadline = Math.max(deadline, transitionEndedAt + budgetMs)
1812
+ return true
1813
+ }
1814
+ } catch {}
1815
+ return false
1816
+ })()
1817
+
1818
+ // a worker that cannot answer within the remaining budget is busy, not
1819
+ // idle: its poll reads as unsettled. bounding each read by the budget
1820
+ // keeps a busy worker from holding a poll past the deadline.
1821
+ const BUSY = { busy: true }
1822
+ const answer = (read) =>
1823
+ Promise.race([
1824
+ Promise.resolve().then(read),
1825
+ new Promise((resolve) =>
1826
+ setTimeout(() => resolve(BUSY), Math.max(deadline - clockNow(), 100)),
1827
+ ),
1828
+ ])
1829
+
1830
+ const readSnapshot = async () => {
1831
+ let animating = false
1832
+ let animatingBy = ''
1833
+ let layoutDirty = false
1834
+ let pendingFetches = 0
1835
+ let workerBusy = false
1836
+ let requestTotal = 0
1837
+ let requestInFlight = 0
1838
+ let appCommits = null
1839
+ let nodeCount = null
1840
+ let renderStatsAvailable = false
1841
+ let shellAnimating = false
1842
+ let shellBlockers = ''
1843
+ let webViewStarting = false
1844
+ let webViewBlocker = ''
1845
+ let visibleMotion = false
1846
+ let visibleMotionBy = ''
1847
+ // the reads are independent, so they run concurrently: a loaded sim
1848
+ // answers each one late, and a poll that waits for them in turn
1849
+ // costs their sum, which fits too few polls in the budget to settle.
1850
+ // the window node count is the exception: it launches after the
1851
+ // motion read, so a poll motion already fails skips that walk.
1852
+ // strict reads also wait out shell motion. pixel reads inspect finite
1853
+ // animations in both realms: a worklet can move the app while the
1854
+ // tenant's basic animation flag and last presented pixels read still.
1855
+ const accessibilityRead = maestro
1856
+ ? answer(() => globalThis.__sootsimTest.captureAccessibilityTree()).catch(() => null)
1857
+ : null
1858
+ const motionRead = strict || screenStill
1859
+ ? answer(() => globalThis.__sootsimTest?.listAnimations?.()).catch(() => null)
1860
+ : null
1861
+ const statsRead = answer(() => globalThis.__sootsimRenderHost?.queryStats?.()).catch(() => null)
1862
+ // image preparation ends in the tenant before the compositor decodes
1863
+ // and realizes its pixels. both owners must finish before settling.
1864
+ // the compositor rejects a stats request it is too busy to answer.
1865
+ const compositorRead = answer(() => globalThis.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
1866
+ const countsRead = answer(() => globalThis.__sootsimTest?.getRequestCounts?.()).catch(() => null)
1867
+ // the mounted hierarchy in render-worker mode comes from the test
1868
+ // bridge: globalThis.__sootsimRoot is an empty placeholder there, so a
1869
+ // walk over it hashes every screen to the same empty string while
1870
+ // it moves. listInspectable is the worker-backed read describe
1871
+ // uses; a worker too busy to answer it reads as unsettled. tight
1872
+ // budgets skip this read and settle on the cheaper signals above.
1873
+ // it walks every node, so a poll whose geometry revision matches the
1874
+ // last read, in this wait or an earlier one, reuses that read.
1875
+ const hierarchyRead =
1876
+ fullGeometry && typeof globalThis.__sootsimTest?.listInspectable === 'function'
1877
+ ? answer(() => globalThis.__sootsimTest.getGeometryRevision?.())
1878
+ .catch(() => null)
1879
+ .then((revision) => {
1880
+ if (revision === BUSY) return BUSY
1881
+ if (typeof revision === 'string' && geometry.revision === revision) return geometry.hierarchy
1882
+ return answer(() => globalThis.__sootsimTest.listInspectable({}))
1883
+ .catch(() => null)
1884
+ .then((hierarchy) => {
1885
+ const kept = typeof revision === 'string' && Array.isArray(hierarchy)
1886
+ geometry.revision = kept ? revision : null
1887
+ geometry.hierarchy = kept ? hierarchy : null
1888
+ return hierarchy
1889
+ })
1890
+ })
1869
1891
  : null
1870
- const statsRead = answer(() => globalThis.__sootsimRenderHost?.queryStats?.()).catch(() => null)
1871
- // image preparation ends in the tenant before the compositor decodes
1872
- // and realizes its pixels. both owners must finish before settling.
1873
- // the compositor rejects a stats request it is too busy to answer.
1874
- const compositorRead = answer(() => globalThis.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
1875
- const countsRead = answer(() => globalThis.__sootsimTest?.getRequestCounts?.()).catch(() => null)
1876
- // the mounted hierarchy in render-worker mode comes from the test
1877
- // bridge: globalThis.__sootsimRoot is an empty placeholder there, so a
1878
- // walk over it hashes every screen to the same empty string while
1879
- // it moves. listInspectable is the worker-backed read describe
1880
- // uses; a worker too busy to answer it reads as unsettled. tight
1881
- // budgets skip this read and settle on the cheaper signals above.
1882
- // it walks every node, so a poll whose geometry revision matches the
1883
- // last read, in this wait or an earlier one, reuses that read.
1884
- const hierarchyRead =
1885
- fullGeometry && typeof globalThis.__sootsimTest?.listInspectable === 'function'
1886
- ? answer(() => globalThis.__sootsimTest.getGeometryRevision?.())
1887
- .catch(() => null)
1888
- .then((revision) => {
1889
- if (revision === BUSY) return BUSY
1890
- if (typeof revision === 'string' && geometry.revision === revision) return geometry.hierarchy
1891
- return answer(() => globalThis.__sootsimTest.listInspectable({}))
1892
- .catch(() => null)
1893
- .then((hierarchy) => {
1894
- const kept = typeof revision === 'string' && Array.isArray(hierarchy)
1895
- geometry.revision = kept ? revision : null
1896
- geometry.hierarchy = kept ? hierarchy : null
1897
- return hierarchy
1898
- })
1899
- })
1900
- : null
1901
- if (motionRead) {
1902
- const motion = await motionRead
1903
- if (motion === BUSY) workerBusy = true
1904
- else if (Array.isArray(motion)) {
1905
- const blocking = motion.filter((anim) =>
1906
- (anim.realm === 'shell' || paintStill) &&
1907
- anim.priority !== 'low' && anim.visible !== false &&
1908
- (!paintStill || anim.loop !== true))
1909
- shellAnimating = blocking.length > 0
1910
- // name what holds the settle so a timeout points at its owner.
1911
- shellBlockers = blocking
1912
- .slice(0, 4)
1913
- .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + ' at ' + anim.current + (anim.loop ? ' loop' : ''))
1914
- .join(', ')
1915
- }
1892
+ if (motionRead) {
1893
+ const motion = await motionRead
1894
+ if (motion === BUSY) workerBusy = true
1895
+ else if (Array.isArray(motion)) {
1896
+ const blocking = motion.filter((anim) =>
1897
+ (anim.realm === 'shell' || screenStill) &&
1898
+ anim.priority !== 'low' && anim.visible !== false &&
1899
+ (!screenStill || anim.loop !== true))
1900
+ shellAnimating = blocking.length > 0
1901
+ // what blocking leaves out still moves the screen while visible;
1902
+ // it ends a screen-still wait only at maestro's hierarchy check
1903
+ // or the deadline, as a screen that never holds still does on ios.
1904
+ const moving = screenStill
1905
+ ? motion.filter((anim) => anim.visible !== false && !blocking.includes(anim))
1906
+ : []
1907
+ visibleMotion = moving.length > 0
1908
+ visibleMotionBy = moving
1909
+ .slice(0, 4)
1910
+ .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + (anim.loop ? ' loop' : '') + (anim.priority === 'low' ? ' low' : ''))
1911
+ .join(', ')
1912
+ // name what holds the settle so a timeout points at its owner.
1913
+ shellBlockers = blocking
1914
+ .slice(0, 4)
1915
+ .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + ' at ' + anim.current + (anim.loop ? ' loop' : ''))
1916
+ .join(', ')
1916
1917
  }
1917
- const stats = await statsRead
1918
- if (stats === BUSY) {
1919
- workerBusy = true
1920
- } else if (!stats && readyPlayback) {
1921
- workerBusy = true
1922
- } else if (stats) {
1923
- renderStatsAvailable = true
1924
- const missingFields = ['hasActiveBlockingNativeAnimations', 'hasPendingBlockingAnimationFrames']
1925
- .filter((field) => typeof stats[field] !== 'boolean')
1926
- if (readyPlayback && typeof stats.hasPendingReadinessAnimationFrames !== 'boolean') missingFields.push('hasPendingReadinessAnimationFrames')
1927
- if ((strict || readyPlayback) && missingFields.length > 0) {
1928
- return {
1929
- runtimeUnsupported: {
1930
- error: 'runtime_readiness_unsupported',
1931
- runtimeVersion: globalThis.__sootsimRuntimeVersion || 'unknown',
1932
- missingFields,
1933
- },
1934
- }
1918
+ }
1919
+ const stats = await statsRead
1920
+ if (stats === BUSY) {
1921
+ workerBusy = true
1922
+ } else if (!stats && readyPlayback) {
1923
+ workerBusy = true
1924
+ } else if (stats) {
1925
+ renderStatsAvailable = true
1926
+ const missingFields = ['hasActiveBlockingNativeAnimations', 'hasPendingBlockingAnimationFrames']
1927
+ .filter((field) => typeof stats[field] !== 'boolean')
1928
+ if (readyPlayback && typeof stats.hasPendingReadinessAnimationFrames !== 'boolean') missingFields.push('hasPendingReadinessAnimationFrames')
1929
+ if ((strict || readyPlayback) && missingFields.length > 0) {
1930
+ return {
1931
+ runtimeUnsupported: {
1932
+ error: 'runtime_readiness_unsupported',
1933
+ runtimeVersion: globalThis.__sootsimRuntimeVersion || 'unknown',
1934
+ missingFields,
1935
+ },
1935
1936
  }
1936
- // positive checks only: an older runtime without the blocking
1937
- // fields reads as still, and strict rejects that runtime above
1938
- // instead of ever settling on unknown motion.
1939
- animating =
1940
- stats.hasActiveAnims === true ||
1941
- stats.hasActiveBlockingNativeAnimations === true ||
1942
- (!paintStill && (readyPlayback ? stats.hasPendingReadinessAnimationFrames : stats.hasPendingBlockingAnimationFrames) === true)
1943
- if (animating)
1944
- animatingBy = [
1945
- stats.hasActiveAnims === true && 'activeAnims',
1946
- stats.hasActiveBlockingNativeAnimations === true && 'blockingNative',
1947
- !paintStill && stats.hasPendingBlockingAnimationFrames === true && 'pendingFrames',
1948
- !paintStill && stats.hasPendingReadinessAnimationFrames === true && 'pendingReadinessFrames',
1949
- ].filter(Boolean).join('+')
1950
- // the runtime reports only layout work that can reach the window:
1951
- // a covered screen or inactive tab committing does not hold it.
1952
- layoutDirty =
1953
- stats.layoutDirty === true && stats.renderRequested === true
1954
- // a freshly-pushed screen showing a skeleton is layout-stable
1955
- // but not actually settled \u2014 its data/images are still in
1956
- // flight. treat bounded image-loader fetches as not-idle so
1957
- // settle waits for real content, capped by the budget.
1958
- const pf = stats.memory && stats.memory.imageLoader
1959
- ? stats.memory.imageLoader.pendingFetches
1960
- : 0
1961
- pendingFetches = typeof pf === 'number' ? pf : 0
1962
- // tenant layout commits: a screen that keeps committing is still
1963
- // mounting or remounting, even with no animation flag raised.
1964
- appCommits = typeof stats.appCommitCount === 'number' ? stats.appCommitCount : null
1965
1937
  }
1966
- // mounted-root membership: the count of nodes that can reach the
1967
- // window moves while the screen mounts, unmounts or recycles, in
1968
- // either render mode. a screen a pushed one covers or an inactive
1969
- // tab stays mounted out of the window, so what it mounts is not
1970
- // screen motion. the worker rebuilds the membership set while the
1971
- // wire moves on every animated frame, so a poll the motion read
1972
- // already fails skips it: the motion flags alone prove this poll
1973
- // unsettled, and the carried count hands the first still poll the
1974
- // pre-motion baseline to compare against.
1975
- const motionStill = !workerBusy && !animating && !layoutDirty && !shellAnimating
1976
- const nodeCountRead = motionStill
1977
- ? answer(() => globalThis.__sootsimTest?.getWindowNodeCount?.()).catch(() => null)
1978
- : null
1979
- const compositor = await compositorRead
1980
- if (compositor === BUSY) {
1981
- workerBusy = true
1982
- } else {
1983
- pendingFetches += compositor.images.pendingFetches
1984
- pendingFetches += compositor.imageRealization.pending
1985
- if (compositor.webViewCaptureSettled === false) {
1986
- webViewStarting = true
1987
- webViewBlocker = 'compositor webView capture not settled'
1988
- }
1938
+ // positive checks only: an older runtime without the blocking
1939
+ // fields reads as still, and strict rejects that runtime above
1940
+ // instead of ever settling on unknown motion.
1941
+ animating =
1942
+ stats.hasActiveAnims === true ||
1943
+ stats.hasActiveBlockingNativeAnimations === true ||
1944
+ (!screenStill && (readyPlayback ? stats.hasPendingReadinessAnimationFrames : stats.hasPendingBlockingAnimationFrames) === true)
1945
+ if (animating)
1946
+ animatingBy = [
1947
+ stats.hasActiveAnims === true && 'activeAnims',
1948
+ stats.hasActiveBlockingNativeAnimations === true && 'blockingNative',
1949
+ !screenStill && stats.hasPendingBlockingAnimationFrames === true && 'pendingFrames',
1950
+ !screenStill && stats.hasPendingReadinessAnimationFrames === true && 'pendingReadinessFrames',
1951
+ ].filter(Boolean).join('+')
1952
+ // the runtime reports only layout work that can reach the window:
1953
+ // a covered screen or inactive tab committing does not hold it.
1954
+ layoutDirty =
1955
+ stats.layoutDirty === true && stats.renderRequested === true
1956
+ // a freshly-pushed screen showing a skeleton is layout-stable
1957
+ // but not actually settled \u2014 its data/images are still in
1958
+ // flight. treat bounded image-loader fetches as not-idle so
1959
+ // settle waits for real content, capped by the budget.
1960
+ const pf = stats.memory && stats.memory.imageLoader
1961
+ ? stats.memory.imageLoader.pendingFetches
1962
+ : 0
1963
+ pendingFetches = typeof pf === 'number' ? pf : 0
1964
+ // tenant layout commits: a screen that keeps committing is still
1965
+ // mounting or remounting, even with no animation flag raised.
1966
+ appCommits = typeof stats.appCommitCount === 'number' ? stats.appCommitCount : null
1967
+ }
1968
+ // mounted-root membership: the count of nodes that can reach the
1969
+ // window moves while the screen mounts, unmounts or recycles, in
1970
+ // either render mode. a screen a pushed one covers or an inactive
1971
+ // tab stays mounted out of the window, so what it mounts is not
1972
+ // screen motion. the worker rebuilds the membership set while the
1973
+ // wire moves on every animated frame, so a poll the motion read
1974
+ // already fails skips it: the motion flags alone prove this poll
1975
+ // unsettled, and the carried count hands the first still poll the
1976
+ // pre-motion baseline to compare against.
1977
+ const motionStill = !workerBusy && !animating && !layoutDirty && !shellAnimating
1978
+ const nodeCountRead = motionStill
1979
+ ? answer(() => globalThis.__sootsimTest?.getWindowNodeCount?.()).catch(() => null)
1980
+ : null
1981
+ const compositor = await compositorRead
1982
+ if (compositor === BUSY) {
1983
+ workerBusy = true
1984
+ } else {
1985
+ pendingFetches += compositor.images.pendingFetches
1986
+ pendingFetches += compositor.imageRealization.pending
1987
+ if (compositor.webViewCaptureSettled === false) {
1988
+ webViewStarting = true
1989
+ webViewBlocker = 'compositor webView capture not settled'
1989
1990
  }
1990
- const counts = await countsRead
1991
- if (counts === BUSY) workerBusy = true
1992
- // <Image> loads are left to the image loader, which counts only those
1993
- // that can reach the window. a runtime older than the CLI reports none.
1994
- const imageLoads = counts?.imageLoads ?? { total: 0, inFlight: 0 }
1995
- requestTotal = typeof counts?.total === 'number' ? counts.total - imageLoads.total : 0
1996
- requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight - imageLoads.inFlight : 0
1997
- // a skipped read carries the last count: mounts during motion still
1998
- // break the first still poll after it, instead of a blank baseline
1999
- // reading them as stable.
2000
- const total = nodeCountRead ? await nodeCountRead : lastNodeCount
2001
- if (total === BUSY) workerBusy = true
2002
- nodeCount = typeof total === 'number' ? total : null
2003
- const accessibility = accessibilityRead ? await accessibilityRead : null
2004
- const nativeHierarchy = Array.isArray(accessibility) && accessibility.length > 0
2005
- ? accessibility
2006
- : null
2007
- if (accessibility === BUSY) workerBusy = true
2008
- let hierarchy = hierarchyRead ? await hierarchyRead : null
2009
- if (hierarchy === BUSY) {
2010
- workerBusy = true
2011
- hierarchy = null
2012
- } else if (!Array.isArray(hierarchy)) {
2013
- hierarchy = null
1991
+ }
1992
+ const counts = await countsRead
1993
+ if (counts === BUSY) workerBusy = true
1994
+ // <Image> loads are left to the image loader, which counts only those
1995
+ // that can reach the window. a runtime older than the CLI reports none.
1996
+ const imageLoads = counts?.imageLoads ?? { total: 0, inFlight: 0 }
1997
+ requestTotal = typeof counts?.total === 'number' ? counts.total - imageLoads.total : 0
1998
+ requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight - imageLoads.inFlight : 0
1999
+ // a skipped read carries the last count: mounts during motion still
2000
+ // break the first still poll after it, instead of a blank baseline
2001
+ // reading them as stable.
2002
+ const total = nodeCountRead ? await nodeCountRead : lastNodeCount
2003
+ if (total === BUSY) workerBusy = true
2004
+ nodeCount = typeof total === 'number' ? total : null
2005
+ const accessibility = accessibilityRead ? await accessibilityRead : null
2006
+ const nativeHierarchy = Array.isArray(accessibility) && accessibility.length > 0
2007
+ ? accessibility
2008
+ : null
2009
+ if (accessibility === BUSY) workerBusy = true
2010
+ let hierarchy = hierarchyRead ? await hierarchyRead : null
2011
+ if (hierarchy === BUSY) {
2012
+ workerBusy = true
2013
+ hierarchy = null
2014
+ } else if (!Array.isArray(hierarchy)) {
2015
+ hierarchy = null
2016
+ }
2017
+ const nodes = []
2018
+ // identity beside each geometry entry, from the rows already read,
2019
+ // so a changed layout can name the nodes that moved.
2020
+ const nodeRows = []
2021
+ 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
2022
+ const noteLoading = (state, text) => {
2023
+ if (state?.busy === true) {
2024
+ webViewStarting = true
2025
+ if (!webViewBlocker) webViewBlocker = 'accessibility busy state active'
2014
2026
  }
2015
- const nodes = []
2016
- // identity beside each geometry entry, from the rows already read,
2017
- // so a changed layout can name the nodes that moved.
2018
- const nodeRows = []
2019
- 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
2020
- const noteLoading = (state, text) => {
2021
- if (state?.busy === true) {
2022
- webViewStarting = true
2023
- if (!webViewBlocker) webViewBlocker = 'accessibility busy state active'
2024
- }
2025
- if (typeof text === 'string' && LOADING_TEXT_REGEX.test(text.trim())) {
2026
- webViewStarting = true
2027
- if (!webViewBlocker) webViewBlocker = 'webView startup in progress ("' + text.trim() + '")'
2027
+ if (typeof text === 'string' && LOADING_TEXT_REGEX.test(text.trim())) {
2028
+ webViewStarting = true
2029
+ if (!webViewBlocker) webViewBlocker = 'webView startup in progress ("' + text.trim() + '")'
2030
+ }
2031
+ }
2032
+ if (hierarchy) {
2033
+ for (const n of hierarchy) {
2034
+ const layout = n && n.layout
2035
+ if (layout && layout.width > 0) {
2036
+ // painted bounds catch a scroll fling. background playback
2037
+ // keeps a view's painted bounds moving forever, so it and its
2038
+ // subtree count by their own layout; the rest of the screen
2039
+ // still catches the fling.
2040
+ const abs = n.backgroundPlayback ? layout : n.absolute || n.absolutePosition || layout
2041
+ const geometry = Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width)
2042
+ nodes.push(geometry)
2043
+ nodeRows.push([String(n.nodeId ?? nodes.length - 1), (n.type || '?') + (n.testId ? '#' + n.testId : ''), geometry])
2028
2044
  }
2045
+ noteLoading(
2046
+ n.accessibilityState,
2047
+ typeof n.text === 'string' ? n.text : '',
2048
+ )
2029
2049
  }
2030
- if (hierarchy) {
2031
- for (const n of hierarchy) {
2032
- const layout = n && n.layout
2033
- if (layout && layout.width > 0) {
2034
- // painted bounds catch a scroll fling. background playback
2035
- // keeps a view's painted bounds moving forever, so it and its
2036
- // subtree count by their own layout; the rest of the screen
2037
- // still catches the fling.
2038
- const abs = n.backgroundPlayback ? layout : n.absolute || n.absolutePosition || layout
2039
- const geometry = Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width)
2050
+ } else {
2051
+ const root = globalThis.__sootsimRoot
2052
+ if (root) {
2053
+ const walk = (n) => {
2054
+ if (n.layout && n.layout.width > 0) {
2055
+ const geometry = Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width)
2040
2056
  nodes.push(geometry)
2041
- nodeRows.push([String(n.nodeId ?? nodes.length - 1), (n.type || '?') + (n.testId ? '#' + n.testId : ''), geometry])
2057
+ nodeRows.push([String(n.id ?? nodes.length - 1), (n.type || '?') + (n.props?.testID ? '#' + n.props.testID : ''), geometry])
2042
2058
  }
2043
2059
  noteLoading(
2044
- n.accessibilityState,
2045
- typeof n.text === 'string' ? n.text : '',
2060
+ n.props?.accessibilityState,
2061
+ n.textContent || (typeof n.props?.children === 'string' ? n.props.children : ''),
2046
2062
  )
2063
+ for (const c of n.children || []) walk(c)
2047
2064
  }
2048
- } else {
2049
- const root = globalThis.__sootsimRoot
2050
- if (root) {
2051
- const walk = (n) => {
2052
- if (n.layout && n.layout.width > 0) {
2053
- const geometry = Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width)
2054
- nodes.push(geometry)
2055
- nodeRows.push([String(n.id ?? nodes.length - 1), (n.type || '?') + (n.props?.testID ? '#' + n.props.testID : ''), geometry])
2056
- }
2057
- noteLoading(
2058
- n.props?.accessibilityState,
2059
- n.textContent || (typeof n.props?.children === 'string' ? n.props.children : ''),
2060
- )
2061
- for (const c of n.children || []) walk(c)
2062
- }
2063
- walk(root)
2064
- }
2065
+ walk(root)
2065
2066
  }
2066
- if (!webViewStarting && typeof document !== 'undefined') {
2067
- const busyEl = [...document.querySelectorAll('[aria-busy="true"]')].find((element) => {
2068
- const bounds = element.getBoundingClientRect()
2069
- return element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&
2070
- bounds.width > 0 && bounds.height > 0 && bounds.right > 0 && bounds.bottom > 0 &&
2071
- bounds.left < globalThis.innerWidth && bounds.top < globalThis.innerHeight
2067
+ }
2068
+ if (!webViewStarting && typeof document !== 'undefined') {
2069
+ const busyEl = [...document.querySelectorAll('[aria-busy="true"]')].find((element) => {
2070
+ const bounds = element.getBoundingClientRect()
2071
+ return element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&
2072
+ bounds.width > 0 && bounds.height > 0 && bounds.right > 0 && bounds.bottom > 0 &&
2073
+ bounds.left < globalThis.innerWidth && bounds.top < globalThis.innerHeight
2074
+ })
2075
+ if (busyEl) {
2076
+ webViewStarting = true
2077
+ webViewBlocker = 'accessibility busy element displayed'
2078
+ } else {
2079
+ // a loading document with no area (an app's hidden worker or
2080
+ // executor frame) paints nothing, and a screenshot on device
2081
+ // does not wait for it.
2082
+ const unreadyWebView = [...document.querySelectorAll(
2083
+ '[data-sootsim-webview-loading="true"], [data-sootsim-webview-mode="placeholder"]'
2084
+ )].find((view) => {
2085
+ const frame = view.querySelector('iframe')
2086
+ return !frame || frame.clientWidth > 0 || frame.clientHeight > 0
2072
2087
  })
2073
- if (busyEl) {
2088
+ if (unreadyWebView) {
2074
2089
  webViewStarting = true
2075
- webViewBlocker = 'accessibility busy element displayed'
2076
- } else {
2077
- // a loading document with no area (an app's hidden worker or
2078
- // executor frame) paints nothing, and a screenshot on device
2079
- // does not wait for it.
2080
- const unreadyWebView = [...document.querySelectorAll(
2081
- '[data-sootsim-webview-loading="true"], [data-sootsim-webview-mode="placeholder"]'
2082
- )].find((view) => {
2083
- const frame = view.querySelector('iframe')
2084
- return !frame || frame.clientWidth > 0 || frame.clientHeight > 0
2085
- })
2086
- if (unreadyWebView) {
2087
- webViewStarting = true
2088
- webViewBlocker = 'webView document still loading'
2089
- }
2090
+ webViewBlocker = 'webView document still loading'
2090
2091
  }
2091
2092
  }
2092
- if (paintStill) {
2093
- const canvas = composite.getCanvas()
2094
- const token = composite.getFrameToken()
2095
- if (!canvas || canvas.width <= 1 || canvas.height <= 1) {
2096
- screenPixels = null
2097
- } else if (token !== pixelFrameToken || canvas.width !== screenPixels?.width || canvas.height !== screenPixels?.height) {
2098
- const context = canvas.getContext('2d')
2099
- const image = context?.getImageData(0, 0, canvas.width, canvas.height)
2100
- screenPixels = image ? { width: image.width, height: image.height, data: new Uint32Array(image.data.buffer) } : null
2101
- pixelFrameToken = token
2102
- }
2103
- }
2104
- return { layout: nodes.join(';'), nodeRows, nativeHierarchy, screenPixels, animating, animatingBy, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
2105
- }
2106
-
2107
- // how long generic background network is allowed to keep us waiting AFTER
2108
- // the screen is otherwise visually settled. apps with continuous traffic
2109
- // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
2110
- // requestInFlight===0 / a stable requestTotal, so requiring full network
2111
- // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
2112
- // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
2113
- // layout-stability + the image-loader already prove visible content
2114
- // loaded (a data load changes layout; an image load shows in the loader),
2115
- // so the generic request counters are a courtesy, not a gate: honor them
2116
- // only within this grace once the screen is visually still.
2117
- const networkQuietGraceMs = 1200
2118
- let lastNativeHierarchy = null
2119
- let lastLayout = ''
2120
- let lastNodeRows = []
2121
- // what moved between the last two differing polls, bounded; names the
2122
- // nodes behind "layout changed" without keeping any poll history.
2123
- let lastLayoutChange = null
2124
- const describeLayoutChange = (before, after) => {
2125
- const previous = new Map(before.map(([key, label, geometry]) => [key, [label, geometry]]))
2126
- const moved = []
2127
- const added = []
2128
- const short = (label, key) => String(label).slice(0, 48) + ' [' + String(key).slice(0, 24) + ']'
2129
- for (const [key, label, geometry] of after) {
2130
- const was = previous.get(key)
2131
- previous.delete(key)
2132
- if (!was) added.push(short(label, key) + ' ' + geometry)
2133
- else if (was[1] !== geometry) moved.push(short(label, key) + ' ' + was[1] + '->' + geometry)
2134
- }
2135
- const removed = [...previous].map(([key, [label, geometry]]) => short(label, key) + ' ' + geometry)
2136
- return {
2137
- moved: moved.length, added: added.length, removed: removed.length,
2138
- movedSample: moved.slice(0, 3), addedSample: added.slice(0, 3), removedSample: removed.slice(0, 3),
2139
- }
2140
2093
  }
2141
- let lastScreenPixels = null
2142
- let screenChangedPolls = 0
2143
- let lastRequestTotal = -1
2144
- let lastAppCommits = null
2145
- let lastNodeCount = null
2146
- // the last completed poll and the values it was compared against.
2147
- let report = null
2148
- // the still polls of the current run, when each began and answered
2149
- let stillPolls = []
2150
- let lastIdlePoll = null
2151
- let visuallyStillSince = 0
2152
- // counts across the whole budget: a flag that is true on every poll is a
2153
- // different bug from one that is true intermittently, and the two need
2154
- // opposite fixes (engine vs budget).
2155
- let polls = 0
2156
- let dirtyPolls = 0
2157
- let animatingPolls = 0
2158
- let layoutChangedPolls = 0
2159
- let webViewStartingPolls = 0
2160
- const screenUnchanged = (pixels, previous) => {
2161
- if (!pixels || !previous || pixels.width !== previous.width || pixels.height !== previous.height) return false
2162
- if (pixels === previous) return true
2163
- for (let i = 0; i < pixels.data.length; i++) {
2164
- if (pixels.data[i] !== previous.data[i]) return false
2165
- }
2166
- return true
2167
- }
2168
- const hierarchyUnchanged = (current, previous) =>
2169
- current !== null && previous !== null && current.length === previous.length &&
2170
- current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
2171
- while (true) {
2172
- if (clockNow() >= deadline) {
2173
- if (!transitionWait) break
2174
- await transitionWait
2175
- transitionWait = null
2176
- // nothing polled while parked on the transition, and a loaded
2177
- // worker's late reply would spend the restarted budget unobserved.
2178
- if (transitionEndedAt !== null) deadline = Math.max(deadline, clockNow() + budgetMs)
2179
- if (clockNow() >= deadline) break
2180
- }
2181
- const pollStarted = clockNow()
2182
- const snapshot = await readSnapshot()
2183
- if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
2184
- // a read the deadline cut short observed nothing: the last full poll
2185
- // names what held the settle, not a worker that ran out of budget.
2186
- // the loop head drains a transition still in flight before it ends.
2187
- if (snapshot.workerBusy && clockNow() >= deadline && report) continue
2188
- polls++
2189
- report = { snapshot, nativeHierarchy: lastNativeHierarchy, layout: lastLayout, screenPixels: lastScreenPixels, requestTotal: lastRequestTotal, appCommits: lastAppCommits, nodeCount: lastNodeCount }
2190
- if (snapshot.layoutDirty) dirtyPolls++
2191
- if (snapshot.animating || snapshot.shellAnimating) animatingPolls++
2192
- if (snapshot.webViewStarting) webViewStartingPolls++
2193
- if (polls > 1 && snapshot.layout !== lastLayout) {
2194
- layoutChangedPolls++
2195
- lastLayoutChange = describeLayoutChange(lastNodeRows, snapshot.nodeRows)
2196
- }
2197
- const screenChanged = paintStill && !screenUnchanged(snapshot.screenPixels, lastScreenPixels)
2198
- if (polls > 1 && screenChanged) screenChangedPolls++
2199
- const strictOk =
2200
- !strict ||
2201
- (snapshot.renderStatsAvailable &&
2202
- !snapshot.animating &&
2203
- !snapshot.shellAnimating &&
2204
- !snapshot.layoutDirty)
2205
- // visually settled: no worker motion or layout work, no new layout
2206
- // commits, a stable mounted node count, no image content loading
2207
- // (unless motion alone is asked), no webview startup in progress,
2208
- // layout unchanged since the last poll. both modes wait out finite
2209
- // worker motion now; strict additionally implies the flags through
2210
- // strictOk and adds shell motion plus the blocking-stats floor. a
2211
- // null count or commit reading means the runtime does not report
2212
- // it, which reads as stable the way a missing stats block does.
2213
- // equal presented pixels can precede pending worker motion or layout.
2214
- // after that work drains, iOS's 3 s pixel phase may accept two equal
2215
- // native TreeNodes while paint-only playback continues. overlap
2216
- // hierarchy reads so neither the gesture nor screenshot deadline grows.
2217
- const maestroStill = snapshot.screenPixels !== null && !snapshot.workerBusy && snapshot.pendingFetches === 0 && snapshot.requestInFlight === 0 && !snapshot.webViewStarting &&
2218
- !snapshot.animating && !snapshot.shellAnimating && !snapshot.layoutDirty && (
2219
- !screenChanged || (clockNow() - start >= 3000 &&
2220
- hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
2221
- )
2222
- const idleSnapshot =
2223
- strictOk &&
2094
+ return { layout: nodes.join(';'), nodeRows, nativeHierarchy, visibleMotion, visibleMotionBy, animating, animatingBy, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
2095
+ }
2096
+
2097
+ // how long generic background network is allowed to keep us waiting AFTER
2098
+ // the screen is otherwise visually settled. apps with continuous traffic
2099
+ // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
2100
+ // requestInFlight===0 / a stable requestTotal, so requiring full network
2101
+ // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
2102
+ // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
2103
+ // layout-stability + the image-loader already prove visible content
2104
+ // loaded (a data load changes layout; an image load shows in the loader),
2105
+ // so the generic request counters are a courtesy, not a gate: honor them
2106
+ // only within this grace once the screen is visually still.
2107
+ const networkQuietGraceMs = 1200
2108
+ let lastNativeHierarchy = null
2109
+ let lastLayout = ''
2110
+ let lastNodeRows = []
2111
+ // what moved between the last two differing polls, bounded; names the
2112
+ // nodes behind "layout changed" without keeping any poll history.
2113
+ let lastLayoutChange = null
2114
+ const describeLayoutChange = (before, after) => {
2115
+ const previous = new Map(before.map(([key, label, geometry]) => [key, [label, geometry]]))
2116
+ const moved = []
2117
+ const added = []
2118
+ const short = (label, key) => String(label).slice(0, 48) + ' [' + String(key).slice(0, 24) + ']'
2119
+ for (const [key, label, geometry] of after) {
2120
+ const was = previous.get(key)
2121
+ previous.delete(key)
2122
+ if (!was) added.push(short(label, key) + ' ' + geometry)
2123
+ else if (was[1] !== geometry) moved.push(short(label, key) + ' ' + was[1] + '->' + geometry)
2124
+ }
2125
+ const removed = [...previous].map(([key, [label, geometry]]) => short(label, key) + ' ' + geometry)
2126
+ return {
2127
+ moved: moved.length, added: added.length, removed: removed.length,
2128
+ movedSample: moved.slice(0, 3), addedSample: added.slice(0, 3), removedSample: removed.slice(0, 3),
2129
+ }
2130
+ }
2131
+ let screenChangedPolls = 0
2132
+ let lastRequestTotal = -1
2133
+ let lastAppCommits = null
2134
+ let lastNodeCount = null
2135
+ // the last completed poll and the values it was compared against.
2136
+ let report = null
2137
+ // the still polls of the current run, when each began and answered
2138
+ let stillPolls = []
2139
+ let lastIdlePoll = null
2140
+ let visuallyStillSince = 0
2141
+ // counts across the whole budget: a flag that is true on every poll is a
2142
+ // different bug from one that is true intermittently, and the two need
2143
+ // opposite fixes (engine vs budget).
2144
+ let polls = 0
2145
+ let dirtyPolls = 0
2146
+ let animatingPolls = 0
2147
+ let layoutChangedPolls = 0
2148
+ let webViewStartingPolls = 0
2149
+ const hierarchyUnchanged = (current, previous) =>
2150
+ current !== null && previous !== null && current.length === previous.length &&
2151
+ current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
2152
+ while (true) {
2153
+ if (clockNow() >= deadline) {
2154
+ if (!transitionWait) break
2155
+ await transitionWait
2156
+ transitionWait = null
2157
+ // nothing polled while parked on the transition, and a loaded
2158
+ // worker's late reply would spend the restarted budget unobserved.
2159
+ if (transitionEndedAt !== null) deadline = Math.max(deadline, clockNow() + budgetMs)
2160
+ if (clockNow() >= deadline) break
2161
+ }
2162
+ const pollStarted = clockNow()
2163
+ const snapshot = await readSnapshot()
2164
+ if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
2165
+ // a read the deadline cut short observed nothing: the last full poll
2166
+ // names what held the settle, not a worker that ran out of budget.
2167
+ // the loop head drains a transition still in flight before it ends.
2168
+ if (snapshot.workerBusy && clockNow() >= deadline && report) continue
2169
+ polls++
2170
+ report = { snapshot, nativeHierarchy: lastNativeHierarchy, layout: lastLayout, requestTotal: lastRequestTotal, appCommits: lastAppCommits, nodeCount: lastNodeCount }
2171
+ if (snapshot.layoutDirty) dirtyPolls++
2172
+ if (snapshot.animating || snapshot.shellAnimating) animatingPolls++
2173
+ if (snapshot.webViewStarting) webViewStartingPolls++
2174
+ if (polls > 1 && snapshot.layout !== lastLayout) {
2175
+ layoutChangedPolls++
2176
+ lastLayoutChange = describeLayoutChange(lastNodeRows, snapshot.nodeRows)
2177
+ }
2178
+ // the first poll has nothing to compare, so it cannot prove a still screen
2179
+ const screenChanged = screenStill && (
2180
+ polls === 1 ||
2181
+ snapshot.visibleMotion ||
2182
+ (snapshot.appCommits !== null && lastAppCommits !== null && snapshot.appCommits !== lastAppCommits) ||
2183
+ (snapshot.nodeCount !== null && lastNodeCount !== null && snapshot.nodeCount !== lastNodeCount) ||
2184
+ snapshot.layout !== lastLayout ||
2185
+ (maestro && !hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
2186
+ )
2187
+ if (polls > 1 && screenChanged) screenChangedPolls++
2188
+ const strictOk =
2189
+ !strict ||
2190
+ (snapshot.renderStatsAvailable &&
2224
2191
  !snapshot.animating &&
2225
2192
  !snapshot.shellAnimating &&
2226
- !snapshot.layoutDirty &&
2227
- snapshot.pendingFetches === 0 &&
2228
- !snapshot.workerBusy &&
2229
- !snapshot.webViewStarting
2230
- const visuallyStill = maestro ? maestroStill :
2231
- idleSnapshot &&
2232
- (snapshot.appCommits === null || lastAppCommits === null || snapshot.appCommits === lastAppCommits) &&
2233
- (snapshot.nodeCount === null || lastNodeCount === null || snapshot.nodeCount === lastNodeCount) &&
2234
- !screenChanged &&
2235
- snapshot.layout === lastLayout
2236
- // generic network quiet: nothing in flight and no new requests issued.
2237
- const networkQuiet =
2238
- snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
2239
- if (visuallyStill) {
2240
- if (visuallyStillSince === 0) visuallyStillSince = clockNow()
2241
- // two equal idle observations prove the interval between them.
2242
- // discarding the first requires a third worker round trip, which
2243
- // can exhaust the budget after a late image on a loaded host.
2244
- if (!maestro && !paintStill && stillPolls.length === 0 && lastIdlePoll) {
2245
- stillPolls.push(lastIdlePoll)
2246
- }
2247
- stillPolls.push({ started: pollStarted, answered: clockNow() })
2248
- // still long enough, counting only polls that began after a started
2249
- // transition drained.
2250
- const stillProven = () => {
2251
- const proving = stillPolls.filter((poll) => transitionEndedAt === null || poll.started >= transitionEndedAt)
2252
- return proving.length >= minimumStablePolls && clockNow() - proving[0].answered >= requiredStillMs
2253
- }
2254
- // settle once the screen has held still long enough AND either the
2255
- // network is genuinely quiet OR it has refused to quiet within the
2256
- // grace (continuous background traffic must not block forever).
2257
- if (
2258
- stillProven() &&
2259
- (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
2260
- ) {
2261
- if (transitionWait) {
2262
- await transitionWait
2263
- transitionWait = null
2264
- }
2265
- if (stillProven()) return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
2193
+ !snapshot.layoutDirty)
2194
+ // visually settled: no worker motion or layout work, no new layout
2195
+ // commits, a stable mounted node count, no image content loading
2196
+ // (unless motion alone is asked), no webview startup in progress,
2197
+ // layout unchanged since the last poll. both modes wait out finite
2198
+ // worker motion now; strict additionally implies the flags through
2199
+ // strictOk and adds shell motion plus the blocking-stats floor. a
2200
+ // null count or commit reading means the runtime does not report
2201
+ // it, which reads as stable the way a missing stats block does.
2202
+ // equal presented pixels can precede pending worker motion or layout.
2203
+ // after that work drains, iOS's 3 s pixel phase may accept two equal
2204
+ // native TreeNodes while paint-only playback continues. overlap
2205
+ // hierarchy reads so neither the gesture nor screenshot deadline grows.
2206
+ const maestroStill = !snapshot.workerBusy && snapshot.pendingFetches === 0 && snapshot.requestInFlight === 0 && !snapshot.webViewStarting &&
2207
+ !snapshot.animating && !snapshot.shellAnimating && !snapshot.layoutDirty && (
2208
+ !screenChanged || (clockNow() - start >= 3000 &&
2209
+ hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
2210
+ )
2211
+ const idleSnapshot =
2212
+ strictOk &&
2213
+ !snapshot.animating &&
2214
+ !snapshot.shellAnimating &&
2215
+ !snapshot.layoutDirty &&
2216
+ snapshot.pendingFetches === 0 &&
2217
+ !snapshot.workerBusy &&
2218
+ !snapshot.webViewStarting
2219
+ const visuallyStill = maestro ? maestroStill :
2220
+ idleSnapshot &&
2221
+ (snapshot.appCommits === null || lastAppCommits === null || snapshot.appCommits === lastAppCommits) &&
2222
+ (snapshot.nodeCount === null || lastNodeCount === null || snapshot.nodeCount === lastNodeCount) &&
2223
+ !screenChanged &&
2224
+ snapshot.layout === lastLayout
2225
+ // generic network quiet: nothing in flight and no new requests issued.
2226
+ const networkQuiet =
2227
+ snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
2228
+ if (visuallyStill) {
2229
+ if (visuallyStillSince === 0) visuallyStillSince = clockNow()
2230
+ // two equal idle observations prove the interval between them.
2231
+ // discarding the first requires a third worker round trip, which
2232
+ // can exhaust the budget after a late image on a loaded host.
2233
+ if (!maestro && !screenStill && stillPolls.length === 0 && lastIdlePoll) {
2234
+ stillPolls.push(lastIdlePoll)
2235
+ }
2236
+ stillPolls.push({ started: pollStarted, answered: clockNow() })
2237
+ // still long enough, counting only polls that began after a started
2238
+ // transition drained.
2239
+ const stillProven = () => {
2240
+ const proving = stillPolls.filter((poll) => transitionEndedAt === null || poll.started >= transitionEndedAt)
2241
+ return proving.length >= minimumStablePolls && clockNow() - proving[0].answered >= requiredStillMs
2242
+ }
2243
+ // settle once the screen has held still long enough AND either the
2244
+ // network is genuinely quiet OR it has refused to quiet within the
2245
+ // grace (continuous background traffic must not block forever).
2246
+ if (
2247
+ stillProven() &&
2248
+ (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
2249
+ ) {
2250
+ if (transitionWait) {
2251
+ await transitionWait
2252
+ transitionWait = null
2266
2253
  }
2267
- } else {
2268
- stillPolls = []
2269
- visuallyStillSince = 0
2254
+ if (stillProven()) return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
2270
2255
  }
2271
- lastIdlePoll = idleSnapshot ? { started: pollStarted, answered: clockNow() } : null
2272
- lastNativeHierarchy = snapshot.nativeHierarchy
2273
- lastLayout = snapshot.layout
2274
- lastNodeRows = snapshot.nodeRows
2275
- lastScreenPixels = snapshot.screenPixels
2276
- lastRequestTotal = snapshot.requestTotal
2277
- lastAppCommits = snapshot.appCommits
2278
- lastNodeCount = snapshot.nodeCount
2279
- // reply latency belongs inside the poll interval; the stillness window
2280
- // above remains measured from completed observations.
2281
- const remainingPollMs = pollMs - (clockNow() - pollStarted)
2282
- if (remainingPollMs > 0) await clockSleep(remainingPollMs)
2283
- }
2284
- if (!report) {
2285
- return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
2286
- }
2287
- const last = report.snapshot
2288
- const blockers = []
2289
- if (!maestro && strict && !last.renderStatsAvailable) blockers.push('render stats unavailable')
2290
- if (!maestro && last.animating) blockers.push('animations still running' + (last.animatingBy ? ' (' + last.animatingBy + ')' : ''))
2291
- if (last.shellAnimating) blockers.push('animations still running (' + last.shellBlockers + ')')
2292
- if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
2293
- if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
2294
- if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
2295
- if (last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
2296
- if (last.workerBusy) blockers.push('a render worker too busy to report')
2297
- if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
2298
- if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
2299
- if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
2300
- if (paintStill && !last.screenPixels) blockers.push('screen pixels unavailable')
2301
- else if (paintStill && !screenUnchanged(last.screenPixels, report.screenPixels)) blockers.push('screen pixels still changing')
2302
- if (last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
2303
- else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
2304
- if (polls < 2) blockers.push('sim too busy to poll twice')
2305
- // the last read is still: motion ended too near the deadline for the
2306
- // stillness window to hold before it.
2307
- if (!blockers.length) blockers.push('motion ended before stillness was proven')
2308
- return {
2309
- settled: false,
2310
- elapsed: clockNow() - start,
2311
- blockedBy:
2312
- blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
2313
- 'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
2314
- (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
2315
- }
2316
- } finally {
2317
- unsubscribe?.()
2256
+ } else {
2257
+ stillPolls = []
2258
+ visuallyStillSince = 0
2259
+ }
2260
+ lastIdlePoll = idleSnapshot ? { started: pollStarted, answered: clockNow() } : null
2261
+ lastNativeHierarchy = snapshot.nativeHierarchy
2262
+ lastLayout = snapshot.layout
2263
+ lastNodeRows = snapshot.nodeRows
2264
+ lastRequestTotal = snapshot.requestTotal
2265
+ lastAppCommits = snapshot.appCommits
2266
+ lastNodeCount = snapshot.nodeCount
2267
+ // reply latency belongs inside the poll interval; the stillness window
2268
+ // above remains measured from completed observations.
2269
+ const remainingPollMs = pollMs - (clockNow() - pollStarted)
2270
+ if (remainingPollMs > 0) await clockSleep(remainingPollMs)
2271
+ }
2272
+ if (!report) {
2273
+ return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
2274
+ }
2275
+ const last = report.snapshot
2276
+ const blockers = []
2277
+ if (!maestro && strict && !last.renderStatsAvailable) blockers.push('render stats unavailable')
2278
+ if (!maestro && last.animating) blockers.push('animations still running' + (last.animatingBy ? ' (' + last.animatingBy + ')' : ''))
2279
+ if (last.shellAnimating) blockers.push('animations still running (' + last.shellBlockers + ')')
2280
+ if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
2281
+ if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
2282
+ if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
2283
+ if (last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
2284
+ if (last.workerBusy) blockers.push('a render worker too busy to report')
2285
+ if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
2286
+ if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
2287
+ if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
2288
+ if (screenStill && last.visibleMotion) blockers.push('visible motion continues (' + last.visibleMotionBy + ')')
2289
+ if (last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
2290
+ else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
2291
+ if (polls < 2) blockers.push('sim too busy to poll twice')
2292
+ // the last read is still: motion ended too near the deadline for the
2293
+ // stillness window to hold before it.
2294
+ if (!blockers.length) blockers.push('motion ended before stillness was proven')
2295
+ return {
2296
+ settled: false,
2297
+ elapsed: clockNow() - start,
2298
+ blockedBy:
2299
+ blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
2300
+ 'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
2301
+ (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
2318
2302
  }
2319
2303
  })()`
2320
2304
  },
@@ -2515,7 +2499,7 @@ function isValidRuntimeVersion(value) {
2515
2499
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
2516
2500
 
2517
2501
  // runtime-companion.json
2518
- var runtime_companion_default = { abi: 1, sha256: "6dd2e5a5b979d46f53a8f7d8fcabf5b355446ecdf5fd09affbffc3e9a5f2599d", file: "node/cli-6dd2e5a5b979d46f53a8f7d8fcabf5b355446ecdf5fd09affbffc3e9a5f2599d.cjs" };
2502
+ var runtime_companion_default = { abi: 1, sha256: "e31bca40962475bce9d44f3218ea76c4537e744dfed9849160b028389774d5ba", file: "node/cli-e31bca40962475bce9d44f3218ea76c4537e744dfed9849160b028389774d5ba.cjs" };
2519
2503
 
2520
2504
  // src/answeredNativePackages.ts
2521
2505
  init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();