peachsim 0.1.2241 → 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 (88) hide show
  1. package/cli/bridge-flow-runner.ts +10 -9
  2. package/cli/commands/inspect/settling.ts +491 -515
  3. package/cli/commands/platform.ts +2 -0
  4. package/dist-lib/agent-daemon-client.cjs +1 -1
  5. package/dist-lib/agent-events.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/bundle-channel.cjs +30 -22
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/config.mjs +1 -1
  27. package/dist-lib/detox/index.cjs +493 -518
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/expo-swift-bundle.cjs +29 -21
  30. package/dist-lib/expo-swift-metadata.cjs +1 -1
  31. package/dist-lib/expo-swift-metadata.mjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +30 -22
  34. package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +491 -516
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +3 -3
  50. package/dist-lib/native-app-identity-project.cjs +2 -2
  51. package/dist-lib/native-app-identity-project.mjs +2 -2
  52. package/dist-lib/native-app-identity.cjs +1 -1
  53. package/dist-lib/native-app-identity.mjs +1 -1
  54. package/dist-lib/native-firebase-metadata.cjs +1 -1
  55. package/dist-lib/native-firebase-metadata.mjs +1 -1
  56. package/dist-lib/pdfium-raster.cjs +1 -1
  57. package/dist-lib/pdfium-raster.mjs +1 -1
  58. package/dist-lib/plist.cjs +1 -1
  59. package/dist-lib/plist.mjs +1 -1
  60. package/dist-lib/profiles.cjs +1 -1
  61. package/dist-lib/public-brand.cjs +1 -1
  62. package/dist-lib/public-origins-lib-esm.json +24 -24
  63. package/dist-lib/public-origins-lib.json +53 -53
  64. package/dist-lib/react-native-host-modules.cjs +1 -1
  65. package/dist-lib/react-native-host-modules.mjs +1 -1
  66. package/dist-lib/reap-browser.cjs +1 -1
  67. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  68. package/dist-lib/sdk.cjs +487 -512
  69. package/dist-lib/sdk.mjs +487 -512
  70. package/dist-lib/skills.cjs +536 -552
  71. package/dist-lib/swift-compile.cjs +11 -3
  72. package/dist-lib/swift-compile.mjs +11 -3
  73. package/dist-lib/swift-package.cjs +1 -1
  74. package/dist-lib/swift-package.mjs +1 -1
  75. package/dist-lib/swift-submit.cjs +1 -1
  76. package/dist-lib/swift-submit.mjs +1 -1
  77. package/dist-lib/swift-toolchain.cjs +1 -1
  78. package/dist-lib/swift.cjs +1 -1
  79. package/dist-lib/vite-swift.cjs +28 -20
  80. package/dist-lib/vite.cjs +3 -3
  81. package/dist-lib/worklet-executable.cjs +1 -1
  82. package/dist-lib/worklet-executable.mjs +1 -1
  83. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +3 -0
  84. package/kotlin/sdk.tar.gz +0 -0
  85. package/package.json +1 -1
  86. package/src/native-static-libraries.ts +16 -16
  87. package/src/swift-shared-sdk.ts +6 -1
  88. package/src/swift-wasm-prune.ts +5 -0
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2241 | (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;
@@ -46543,7 +46543,7 @@ function weakenFoundationOverridesInArchive(arBuf) {
46543
46543
  } else if (name3.endsWith("/")) {
46544
46544
  name3 = name3.slice(0, -1);
46545
46545
  }
46546
- if (name3.endsWith("NSSortDescriptor.o")) {
46546
+ if (name3.endsWith("Bundle.o") || name3.endsWith("NSSortDescriptor.o")) {
46547
46547
  weakenFoundationSymbolsInWasmObj(arBuf.subarray(bodyStart, bodyEnd));
46548
46548
  }
46549
46549
  pos = bodyEnd + (size & 1);
@@ -46749,6 +46749,9 @@ var init_swift_shared_sdk = __esm({
46749
46749
  init_swift_toolchain();
46750
46750
  distributionHeaderRoots = /* @__PURE__ */ new Map();
46751
46751
  WEAKEN_FOUNDATION_SYMS = /* @__PURE__ */ new Set([
46752
+ "$s10Foundation6BundleC22preferredLocalizations4from14forPreferencesSaySSGAG_AGSgtFZ",
46753
+ "$s10Foundation6BundleC22preferredLocalizations4fromSaySSGAF_tFZ",
46754
+ "$s10Foundation6BundleC22preferredLocalizationsSaySSGvg",
46752
46755
  "$s10Foundation16NSSortDescriptorC3key9ascendingACSSSg_SbtcfC",
46753
46756
  "$s10Foundation16NSSortDescriptorC3key9ascendingACSSSg_Sbtcfc",
46754
46757
  "$s10Foundation16NSSortDescriptorC3keySSSgvg",
@@ -48702,6 +48705,11 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
48702
48705
  if (def) activateSymbolInObj(def.obj, def.symIdx);
48703
48706
  }
48704
48707
  const WEAKEN_SDK_FOUNDATION_SYMS = /* @__PURE__ */ new Set([
48708
+ "$s10Foundation6BundleC22preferredLocalizations4from14forPreferencesSaySSGAG_AGSgtFZ",
48709
+ "$s10Foundation6BundleC22preferredLocalizations4fromSaySSGAF_tFZ",
48710
+ "$s10Foundation6BundleC22preferredLocalizationsSaySSGvg",
48711
+ "$s10Foundation6BundleC22preferredLocalizations4from14forPreferencesSaySSGAG_AGSgtFZTf4nnd_n",
48712
+ "$s10Foundation6BundleC22preferredLocalizations4fromSaySSGAF_tFZTf4nd_n",
48705
48713
  "$s10Foundation16NSSortDescriptorC3key9ascendingACSSSg_SbtcfC",
48706
48714
  "$s10Foundation16NSSortDescriptorC3key9ascendingACSSSg_Sbtcfc",
48707
48715
  "$s10Foundation16NSSortDescriptorC3keySSSgvg",
@@ -59336,7 +59344,7 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
59336
59344
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
59337
59345
  MULTI_MANIFEST_VERSION = 68;
59338
59346
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
59339
- compilerSourceDigest = true ? "3bbc36e39985b08e87a73a633978d40d8856f485ad28dbc7caf18e13cba6bf81" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
59347
+ compilerSourceDigest = true ? "6ff3c88ff95ee93cffc6e832c96753820df284d9d2d9a99d405e2cb6be86ed65" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
59340
59348
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
59341
59349
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
59342
59350
  cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
@@ -65818,7 +65826,7 @@ var init_swift_standin_digest = __esm({
65818
65826
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
65819
65827
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
65820
65828
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
65821
- STANDIN_SOURCE_DIGEST = true ? "a337dfa692c4f84cc4b30522d000cdd1c7c4c140d002f00e11c12179ed99631e" : standinSourceDigest();
65829
+ STANDIN_SOURCE_DIGEST = true ? "ae85ffec56f52b5fc73fd9519b221f33abfd4b67aec6d9c5695044b4b6b6ab32" : standinSourceDigest();
65822
65830
  }
65823
65831
  });
65824
65832
 
@@ -66279,7 +66287,7 @@ var init_package_tree_digest = __esm({
66279
66287
 
66280
66288
  // src/expo-native-prebuilt.ts
66281
66289
  function expoNativeCompilerDigestValue() {
66282
- return true ? "0072d8f70d340dad805c0aff2b37027d400668b0c7b65ed167b47c6b3f1431d5" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
66290
+ return true ? "dc252d5a10409138e535f8caed0879e77c0415ec62aed534eba68347d7b4fbc5" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
66283
66291
  }
66284
66292
  function readSources(value) {
66285
66293
  const sources = isRecord(value) ? value.sources : null;
@@ -66732,112 +66740,112 @@ var init_native_static_libraries = __esm({
66732
66740
  name: "skia",
66733
66741
  nativeSha256: "5312f2b194b1f6b6721388028bf919e56400278245b039f47136aa98f0582333",
66734
66742
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66735
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66743
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66736
66744
  archive: "libskia.a"
66737
66745
  },
66738
66746
  {
66739
66747
  name: "skia_svg",
66740
66748
  nativeSha256: "77adc498cff85db7850fb713c306681c6337f9b4ec42991b3764c8f3eff9d8d0",
66741
66749
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66742
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66750
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66743
66751
  archive: "libsvg.a"
66744
66752
  },
66745
66753
  {
66746
66754
  name: "skia_skshaper",
66747
66755
  nativeSha256: "830bcf260bd24fd79ee5d323e26ec667638795e3a0e555f1093371b8342c345c",
66748
66756
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66749
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66757
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66750
66758
  archive: "libskshaper.a"
66751
66759
  },
66752
66760
  {
66753
66761
  name: "skia_skparagraph",
66754
66762
  nativeSha256: "26afd4e5b11d46b0820a2cd7fd9918eb5a041946e1a1c0d4b91a5d54877e9dda",
66755
66763
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66756
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66764
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66757
66765
  archive: "libskparagraph.a"
66758
66766
  },
66759
66767
  {
66760
66768
  name: "skia_skunicode_core",
66761
66769
  nativeSha256: "629f58c4e81157d42e353b2b255bebb2fd94d1f31d8f8157e982fa4367710526",
66762
66770
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66763
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66771
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66764
66772
  archive: "libskunicode_core.a"
66765
66773
  },
66766
66774
  {
66767
66775
  name: "skia_skunicode_libgrapheme",
66768
66776
  nativeSha256: "047bd82306ba688453a3ff9dc02e203cdf16f2084551cca54f5d2b099baf1895",
66769
66777
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66770
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66778
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66771
66779
  archive: "libskunicode_libgrapheme.a"
66772
66780
  },
66773
66781
  {
66774
66782
  name: "skia_skottie",
66775
66783
  nativeSha256: "75c0dfd82a256e761cddc45475b8109ed8c9a442767cf3a8bf8720eef0dd4af7",
66776
66784
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66777
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66785
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66778
66786
  archive: "libskottie.a"
66779
66787
  },
66780
66788
  {
66781
66789
  name: "skia_sksg",
66782
66790
  nativeSha256: "df9652a46505d3c5c74d55b52295ef39218d2b5856e074117461fa2348312c8d",
66783
66791
  upstream: "9f9e6beb751091ef69163d2b4fdcd1e711b594ac",
66784
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66792
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66785
66793
  archive: "libsksg.a"
66786
66794
  },
66787
66795
  {
66788
66796
  name: "skia",
66789
66797
  nativeSha256: "c9b007c4da16f66d84b2f108af719b424ef91ee0759e58df0b76930bc6f82e31",
66790
66798
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66791
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66799
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66792
66800
  archive: "libskia.a"
66793
66801
  },
66794
66802
  {
66795
66803
  name: "skia_svg",
66796
66804
  nativeSha256: "159705737769610b60216b114a28ba833840aa1df7833424df99edec4405b86f",
66797
66805
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66798
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66806
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66799
66807
  archive: "libsvg.a"
66800
66808
  },
66801
66809
  {
66802
66810
  name: "skia_skshaper",
66803
66811
  nativeSha256: "934f3dbf3f38bca87b463b664a17c1588840f86ec89cf6961fb2a89b6336b35b",
66804
66812
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66805
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66813
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66806
66814
  archive: "libskshaper.a"
66807
66815
  },
66808
66816
  {
66809
66817
  name: "skia_skparagraph",
66810
66818
  nativeSha256: "29a48349fc9b75c252b22fc6ca5ade90636900f82beec58780f03fd66ab345b3",
66811
66819
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66812
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66820
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66813
66821
  archive: "libskparagraph.a"
66814
66822
  },
66815
66823
  {
66816
66824
  name: "skia_skunicode_core",
66817
66825
  nativeSha256: "096e5139c4de528dbba5a9605895f4c725853e48225503bdfa9c1d70241e5f58",
66818
66826
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66819
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66827
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66820
66828
  archive: "libskunicode_core.a"
66821
66829
  },
66822
66830
  {
66823
66831
  name: "skia_skunicode_libgrapheme",
66824
66832
  nativeSha256: "d1ec3c2d5ad6889eb4fbf4a6bab74f39946739501d40de903f7d8cb2181ac37d",
66825
66833
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66826
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66834
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66827
66835
  archive: "libskunicode_libgrapheme.a"
66828
66836
  },
66829
66837
  {
66830
66838
  name: "skia_skottie",
66831
66839
  nativeSha256: "52ea2e046f45f51df6027d783e923864e8c4ef94a1fe4fc5971e436574d8ae57",
66832
66840
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66833
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66841
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66834
66842
  archive: "libskottie.a"
66835
66843
  },
66836
66844
  {
66837
66845
  name: "skia_sksg",
66838
66846
  nativeSha256: "541a74d8f83dc411efe8eeac377486a5054fab4c7710afe406a20a27efe8f627",
66839
66847
  upstream: "b94213a11b3a2edadfae89f0c57a7f4ab72772c9",
66840
- recipe: "91591e98be98542547d3ea972803b7929675c3569d98c7a3d92d266896f84545",
66848
+ recipe: "8675d17f45d09403bc82f0377f57a6258eb2e44e0a301278cb8e737517d9e6c5",
66841
66849
  archive: "libsksg.a"
66842
66850
  },
66843
66851
  {
@@ -87020,7 +87028,7 @@ var init_nitro_superset = __esm({
87020
87028
  init_nitroContract();
87021
87029
  init_swift_standin_digest();
87022
87030
  NITRO_SUPERSET_ENTRY_NAME = "superset";
87023
- NITRO_COMPILER_DIGEST = true ? "2654de7d6f4ee1bfbf3d26bee2e065bd0211eb9173f462cfd958195b8b799d23" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
87031
+ NITRO_COMPILER_DIGEST = true ? "79e76dd976a0ac6066a5ba0856e458310ebf221339008ce724a8535efc7c2488" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
87024
87032
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
87025
87033
  nitroSupersetKey = (inputs) => nativeEntryKey({ ...inputs, compiler: NITRO_COMPILER_DIGEST });
87026
87034
  published2 = /* @__PURE__ */ new Map();
@@ -133699,7 +133707,7 @@ async function waitForSootsimIdle({
133699
133707
  pollMs = 50,
133700
133708
  stablePolls = 3,
133701
133709
  strict = false,
133702
- paintStill = false,
133710
+ screenStill = false,
133703
133711
  maestro = false,
133704
133712
  motionOnly = false,
133705
133713
  readyPlayback = false,
@@ -133737,7 +133745,7 @@ async function waitForSootsimIdle({
133737
133745
  let deadline = start + budgetMs
133738
133746
  const pollMs = ${Math.max(1, Math.round(pollMs))}
133739
133747
  const strict = ${strict ? "true" : "false"}
133740
- const paintStill = ${paintStill ? "true" : "false"}
133748
+ const screenStill = ${screenStill ? "true" : "false"}
133741
133749
  const maestro = ${maestro ? "true" : "false"}
133742
133750
  const accessibilityBounds = ${accessibilityBounds.toString()}
133743
133751
  const sameNativeAccessibilityShape = ${sameNativeAccessibilityShape.toString()}
@@ -133747,550 +133755,525 @@ async function waitForSootsimIdle({
133747
133755
  // tight budgets (auto-wait) settle on worker stillness plus root
133748
133756
  // membership, generous ones confirm the geometry too.
133749
133757
  const fullGeometry = ${!maestro && maxMs >= 1e3 ? "true" : "false"}
133750
- const requiredStillMs = paintStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
133751
- const minimumStablePolls = paintStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
133752
- const composite = paintStill ? globalThis.SootSim?.bridges?.liveComposite : null
133753
- if (paintStill && !composite) {
133754
- return { settled: false, elapsed: clockNow() - start, blockedBy: 'screen pixels unavailable' }
133755
- }
133756
- // subscribe to presented frames; authoritative screenshots force a
133757
- // worker render, which changes the very counter we used to inspect.
133758
- // pixels only decide stillness once motion and layout work drain, so the
133759
- // subscription holds only then: a headless host otherwise reads back
133760
- // every motion frame for a comparison that cannot pass.
133761
- let unsubscribe = null
133758
+ const requiredStillMs = screenStill ? 0 : ${Math.max(1, Math.round(stablePolls)) * Math.max(1, Math.round(pollMs))}
133759
+ const minimumStablePolls = screenStill ? 1 : ${Math.min(2, Math.max(1, Math.round(stablePolls)))}
133762
133760
  let transitionEndedAt = null
133763
- let pixelFrameToken = -1
133764
- let screenPixels = null
133765
133761
  // the hierarchy read last taken and the geometry revision it answered.
133766
133762
  // it outlives this wait: a revision still current when a later wait
133767
133763
  // polls names the same geometry, so a step that follows a settled one
133768
133764
  // proves an unchanged screen without walking the tree again.
133769
133765
  const geometry = (globalThis.__peachSettleGeometry ??= { revision: null, hierarchy: null })
133770
- try {
133771
-
133772
- // discover transitions while observing layout. when motion starts,
133773
- // observations from before its completion cannot prove the new screen;
133774
- // those that began after it drained still can. a loaded host runs a
133775
- // push past a tap's budget, so the transition gets its own timeout and
133776
- // the budget restarts once it drains.
133777
- let transitionWait = (async () => {
133778
- try {
133779
- const wfst = globalThis.__sootsimTest?.waitForScreenTransitions
133780
- if (typeof wfst === 'function' && budgetMs > 120) {
133781
- const transition = await wfst({
133782
- timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
133783
- settleMs: 64,
133784
- startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
133785
- })
133786
- if (transition?.started !== true) return false
133787
- // a loaded worker replies long after the motion stopped; it
133788
- // reports how long ago, so polls begun since still count. a
133789
- // runtime without the field ends the transition at the reply.
133790
- const rested = typeof transition.restedMs === 'number' ? Math.max(0, transition.restedMs) : 0
133791
- transitionEndedAt = clockNow() - rested
133792
- deadline = Math.max(deadline, transitionEndedAt + budgetMs)
133793
- return true
133794
- }
133795
- } catch {}
133796
- return false
133797
- })()
133798
-
133799
- // a worker that cannot answer within the remaining budget is busy, not
133800
- // idle: its poll reads as unsettled. bounding each read by the budget
133801
- // keeps a busy worker from holding a poll past the deadline.
133802
- const BUSY = { busy: true }
133803
- const answer = (read) =>
133804
- Promise.race([
133805
- Promise.resolve().then(read),
133806
- new Promise((resolve) =>
133807
- setTimeout(() => resolve(BUSY), Math.max(deadline - clockNow(), 100)),
133808
- ),
133809
- ])
133766
+ // discover transitions while observing layout. when motion starts,
133767
+ // observations from before its completion cannot prove the new screen;
133768
+ // those that began after it drained still can. a loaded host runs a
133769
+ // push past a tap's budget, so the transition gets its own timeout and
133770
+ // the budget restarts once it drains.
133771
+ let transitionWait = (async () => {
133772
+ try {
133773
+ const wfst = globalThis.__sootsimTest?.waitForScreenTransitions
133774
+ if (typeof wfst === 'function' && budgetMs > 120) {
133775
+ const transition = await wfst({
133776
+ timeoutMs: ${Math.max(0, Math.round(transitionTimeoutMs))},
133777
+ settleMs: 64,
133778
+ startWindowMs: ${Math.max(0, Math.round(transitionStartWindowMs))},
133779
+ })
133780
+ if (transition?.started !== true) return false
133781
+ // a loaded worker replies long after the motion stopped; it
133782
+ // reports how long ago, so polls begun since still count. a
133783
+ // runtime without the field ends the transition at the reply.
133784
+ const rested = typeof transition.restedMs === 'number' ? Math.max(0, transition.restedMs) : 0
133785
+ transitionEndedAt = clockNow() - rested
133786
+ deadline = Math.max(deadline, transitionEndedAt + budgetMs)
133787
+ return true
133788
+ }
133789
+ } catch {}
133790
+ return false
133791
+ })()
133792
+
133793
+ // a worker that cannot answer within the remaining budget is busy, not
133794
+ // idle: its poll reads as unsettled. bounding each read by the budget
133795
+ // keeps a busy worker from holding a poll past the deadline.
133796
+ const BUSY = { busy: true }
133797
+ const answer = (read) =>
133798
+ Promise.race([
133799
+ Promise.resolve().then(read),
133800
+ new Promise((resolve) =>
133801
+ setTimeout(() => resolve(BUSY), Math.max(deadline - clockNow(), 100)),
133802
+ ),
133803
+ ])
133810
133804
 
133811
- const readSnapshot = async () => {
133812
- let animating = false
133813
- let animatingBy = ''
133814
- let layoutDirty = false
133815
- let pendingFetches = 0
133816
- let workerBusy = false
133817
- let requestTotal = 0
133818
- let requestInFlight = 0
133819
- let appCommits = null
133820
- let nodeCount = null
133821
- let renderStatsAvailable = false
133822
- let shellAnimating = false
133823
- let shellBlockers = ''
133824
- let webViewStarting = false
133825
- let webViewBlocker = ''
133826
- // the reads are independent, so they run concurrently: a loaded sim
133827
- // answers each one late, and a poll that waits for them in turn
133828
- // costs their sum, which fits too few polls in the budget to settle.
133829
- // the window node count is the exception: it launches after the
133830
- // motion read, so a poll motion already fails skips that walk.
133831
- // strict reads also wait out shell motion. pixel reads inspect finite
133832
- // animations in both realms: a worklet can move the app while the
133833
- // tenant's basic animation flag and last presented pixels read still.
133834
- const accessibilityRead = maestro
133835
- ? answer(() => globalThis.__sootsimTest.captureAccessibilityTree()).catch(() => null)
133836
- : null
133837
- const motionRead = strict || paintStill
133838
- ? answer(() => globalThis.__sootsimTest?.listAnimations?.()).catch(() => null)
133839
- : null
133840
- const statsRead = answer(() => globalThis.__sootsimRenderHost?.queryStats?.()).catch(() => null)
133841
- // image preparation ends in the tenant before the compositor decodes
133842
- // and realizes its pixels. both owners must finish before settling.
133843
- // the compositor rejects a stats request it is too busy to answer.
133844
- const compositorRead = answer(() => globalThis.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
133845
- const countsRead = answer(() => globalThis.__sootsimTest?.getRequestCounts?.()).catch(() => null)
133846
- // the mounted hierarchy in render-worker mode comes from the test
133847
- // bridge: globalThis.__sootsimRoot is an empty placeholder there, so a
133848
- // walk over it hashes every screen to the same empty string while
133849
- // it moves. listInspectable is the worker-backed read describe
133850
- // uses; a worker too busy to answer it reads as unsettled. tight
133851
- // budgets skip this read and settle on the cheaper signals above.
133852
- // it walks every node, so a poll whose geometry revision matches the
133853
- // last read, in this wait or an earlier one, reuses that read.
133854
- const hierarchyRead =
133855
- fullGeometry && typeof globalThis.__sootsimTest?.listInspectable === 'function'
133856
- ? answer(() => globalThis.__sootsimTest.getGeometryRevision?.())
133857
- .catch(() => null)
133858
- .then((revision) => {
133859
- if (revision === BUSY) return BUSY
133860
- if (typeof revision === 'string' && geometry.revision === revision) return geometry.hierarchy
133861
- return answer(() => globalThis.__sootsimTest.listInspectable({}))
133862
- .catch(() => null)
133863
- .then((hierarchy) => {
133864
- const kept = typeof revision === 'string' && Array.isArray(hierarchy)
133865
- geometry.revision = kept ? revision : null
133866
- geometry.hierarchy = kept ? hierarchy : null
133867
- return hierarchy
133868
- })
133869
- })
133870
- : null
133871
- if (motionRead) {
133872
- const motion = await motionRead
133873
- if (motion === BUSY) workerBusy = true
133874
- else if (Array.isArray(motion)) {
133875
- const blocking = motion.filter((anim) =>
133876
- (anim.realm === 'shell' || paintStill) &&
133877
- anim.priority !== 'low' && anim.visible !== false &&
133878
- (!paintStill || anim.loop !== true))
133879
- shellAnimating = blocking.length > 0
133880
- // name what holds the settle so a timeout points at its owner.
133881
- shellBlockers = blocking
133882
- .slice(0, 4)
133883
- .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + ' at ' + anim.current + (anim.loop ? ' loop' : ''))
133884
- .join(', ')
133885
- }
133886
- }
133887
- const stats = await statsRead
133888
- if (stats === BUSY) {
133889
- workerBusy = true
133890
- } else if (!stats && readyPlayback) {
133891
- workerBusy = true
133892
- } else if (stats) {
133893
- renderStatsAvailable = true
133894
- const missingFields = ['hasActiveBlockingNativeAnimations', 'hasPendingBlockingAnimationFrames']
133895
- .filter((field) => typeof stats[field] !== 'boolean')
133896
- if (readyPlayback && typeof stats.hasPendingReadinessAnimationFrames !== 'boolean') missingFields.push('hasPendingReadinessAnimationFrames')
133897
- if ((strict || readyPlayback) && missingFields.length > 0) {
133898
- return {
133899
- runtimeUnsupported: {
133900
- error: 'runtime_readiness_unsupported',
133901
- runtimeVersion: globalThis.__sootsimRuntimeVersion || 'unknown',
133902
- missingFields,
133903
- },
133904
- }
133905
- }
133906
- // positive checks only: an older runtime without the blocking
133907
- // fields reads as still, and strict rejects that runtime above
133908
- // instead of ever settling on unknown motion.
133909
- animating =
133910
- stats.hasActiveAnims === true ||
133911
- stats.hasActiveBlockingNativeAnimations === true ||
133912
- (!paintStill && (readyPlayback ? stats.hasPendingReadinessAnimationFrames : stats.hasPendingBlockingAnimationFrames) === true)
133913
- if (animating)
133914
- animatingBy = [
133915
- stats.hasActiveAnims === true && 'activeAnims',
133916
- stats.hasActiveBlockingNativeAnimations === true && 'blockingNative',
133917
- !paintStill && stats.hasPendingBlockingAnimationFrames === true && 'pendingFrames',
133918
- !paintStill && stats.hasPendingReadinessAnimationFrames === true && 'pendingReadinessFrames',
133919
- ].filter(Boolean).join('+')
133920
- // the runtime reports only layout work that can reach the window:
133921
- // a covered screen or inactive tab committing does not hold it.
133922
- layoutDirty =
133923
- stats.layoutDirty === true && stats.renderRequested === true
133924
- // a freshly-pushed screen showing a skeleton is layout-stable
133925
- // but not actually settled \u2014 its data/images are still in
133926
- // flight. treat bounded image-loader fetches as not-idle so
133927
- // settle waits for real content, capped by the budget.
133928
- const pf = stats.memory && stats.memory.imageLoader
133929
- ? stats.memory.imageLoader.pendingFetches
133930
- : 0
133931
- pendingFetches = typeof pf === 'number' ? pf : 0
133932
- // tenant layout commits: a screen that keeps committing is still
133933
- // mounting or remounting, even with no animation flag raised.
133934
- appCommits = typeof stats.appCommitCount === 'number' ? stats.appCommitCount : null
133935
- }
133936
- // mounted-root membership: the count of nodes that can reach the
133937
- // window moves while the screen mounts, unmounts or recycles, in
133938
- // either render mode. a screen a pushed one covers or an inactive
133939
- // tab stays mounted out of the window, so what it mounts is not
133940
- // screen motion. the worker rebuilds the membership set while the
133941
- // wire moves on every animated frame, so a poll the motion read
133942
- // already fails skips it: the motion flags alone prove this poll
133943
- // unsettled, and the carried count hands the first still poll the
133944
- // pre-motion baseline to compare against.
133945
- const motionStill = !workerBusy && !animating && !layoutDirty && !shellAnimating
133946
- const nodeCountRead = motionStill
133947
- ? answer(() => globalThis.__sootsimTest?.getWindowNodeCount?.()).catch(() => null)
133805
+ const readSnapshot = async () => {
133806
+ let animating = false
133807
+ let animatingBy = ''
133808
+ let layoutDirty = false
133809
+ let pendingFetches = 0
133810
+ let workerBusy = false
133811
+ let requestTotal = 0
133812
+ let requestInFlight = 0
133813
+ let appCommits = null
133814
+ let nodeCount = null
133815
+ let renderStatsAvailable = false
133816
+ let shellAnimating = false
133817
+ let shellBlockers = ''
133818
+ let webViewStarting = false
133819
+ let webViewBlocker = ''
133820
+ let visibleMotion = false
133821
+ let visibleMotionBy = ''
133822
+ // the reads are independent, so they run concurrently: a loaded sim
133823
+ // answers each one late, and a poll that waits for them in turn
133824
+ // costs their sum, which fits too few polls in the budget to settle.
133825
+ // the window node count is the exception: it launches after the
133826
+ // motion read, so a poll motion already fails skips that walk.
133827
+ // strict reads also wait out shell motion. pixel reads inspect finite
133828
+ // animations in both realms: a worklet can move the app while the
133829
+ // tenant's basic animation flag and last presented pixels read still.
133830
+ const accessibilityRead = maestro
133831
+ ? answer(() => globalThis.__sootsimTest.captureAccessibilityTree()).catch(() => null)
133832
+ : null
133833
+ const motionRead = strict || screenStill
133834
+ ? answer(() => globalThis.__sootsimTest?.listAnimations?.()).catch(() => null)
133835
+ : null
133836
+ const statsRead = answer(() => globalThis.__sootsimRenderHost?.queryStats?.()).catch(() => null)
133837
+ // image preparation ends in the tenant before the compositor decodes
133838
+ // and realizes its pixels. both owners must finish before settling.
133839
+ // the compositor rejects a stats request it is too busy to answer.
133840
+ const compositorRead = answer(() => globalThis.__sootsimCompositor.getStats({ detail: 'readiness' })).catch(() => BUSY)
133841
+ const countsRead = answer(() => globalThis.__sootsimTest?.getRequestCounts?.()).catch(() => null)
133842
+ // the mounted hierarchy in render-worker mode comes from the test
133843
+ // bridge: globalThis.__sootsimRoot is an empty placeholder there, so a
133844
+ // walk over it hashes every screen to the same empty string while
133845
+ // it moves. listInspectable is the worker-backed read describe
133846
+ // uses; a worker too busy to answer it reads as unsettled. tight
133847
+ // budgets skip this read and settle on the cheaper signals above.
133848
+ // it walks every node, so a poll whose geometry revision matches the
133849
+ // last read, in this wait or an earlier one, reuses that read.
133850
+ const hierarchyRead =
133851
+ fullGeometry && typeof globalThis.__sootsimTest?.listInspectable === 'function'
133852
+ ? answer(() => globalThis.__sootsimTest.getGeometryRevision?.())
133853
+ .catch(() => null)
133854
+ .then((revision) => {
133855
+ if (revision === BUSY) return BUSY
133856
+ if (typeof revision === 'string' && geometry.revision === revision) return geometry.hierarchy
133857
+ return answer(() => globalThis.__sootsimTest.listInspectable({}))
133858
+ .catch(() => null)
133859
+ .then((hierarchy) => {
133860
+ const kept = typeof revision === 'string' && Array.isArray(hierarchy)
133861
+ geometry.revision = kept ? revision : null
133862
+ geometry.hierarchy = kept ? hierarchy : null
133863
+ return hierarchy
133864
+ })
133865
+ })
133948
133866
  : null
133949
- const compositor = await compositorRead
133950
- if (compositor === BUSY) {
133951
- workerBusy = true
133952
- } else {
133953
- pendingFetches += compositor.images.pendingFetches
133954
- pendingFetches += compositor.imageRealization.pending
133955
- if (compositor.webViewCaptureSettled === false) {
133956
- webViewStarting = true
133957
- webViewBlocker = 'compositor webView capture not settled'
133867
+ if (motionRead) {
133868
+ const motion = await motionRead
133869
+ if (motion === BUSY) workerBusy = true
133870
+ else if (Array.isArray(motion)) {
133871
+ const blocking = motion.filter((anim) =>
133872
+ (anim.realm === 'shell' || screenStill) &&
133873
+ anim.priority !== 'low' && anim.visible !== false &&
133874
+ (!screenStill || anim.loop !== true))
133875
+ shellAnimating = blocking.length > 0
133876
+ // what blocking leaves out still moves the screen while visible;
133877
+ // it ends a screen-still wait only at maestro's hierarchy check
133878
+ // or the deadline, as a screen that never holds still does on ios.
133879
+ const moving = screenStill
133880
+ ? motion.filter((anim) => anim.visible !== false && !blocking.includes(anim))
133881
+ : []
133882
+ visibleMotion = moving.length > 0
133883
+ visibleMotionBy = moving
133884
+ .slice(0, 4)
133885
+ .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + (anim.loop ? ' loop' : '') + (anim.priority === 'low' ? ' low' : ''))
133886
+ .join(', ')
133887
+ // name what holds the settle so a timeout points at its owner.
133888
+ shellBlockers = blocking
133889
+ .slice(0, 4)
133890
+ .map((anim) => anim.source + '/' + anim.kind + '#' + anim.id + ' at ' + anim.current + (anim.loop ? ' loop' : ''))
133891
+ .join(', ')
133892
+ }
133893
+ }
133894
+ const stats = await statsRead
133895
+ if (stats === BUSY) {
133896
+ workerBusy = true
133897
+ } else if (!stats && readyPlayback) {
133898
+ workerBusy = true
133899
+ } else if (stats) {
133900
+ renderStatsAvailable = true
133901
+ const missingFields = ['hasActiveBlockingNativeAnimations', 'hasPendingBlockingAnimationFrames']
133902
+ .filter((field) => typeof stats[field] !== 'boolean')
133903
+ if (readyPlayback && typeof stats.hasPendingReadinessAnimationFrames !== 'boolean') missingFields.push('hasPendingReadinessAnimationFrames')
133904
+ if ((strict || readyPlayback) && missingFields.length > 0) {
133905
+ return {
133906
+ runtimeUnsupported: {
133907
+ error: 'runtime_readiness_unsupported',
133908
+ runtimeVersion: globalThis.__sootsimRuntimeVersion || 'unknown',
133909
+ missingFields,
133910
+ },
133958
133911
  }
133959
133912
  }
133960
- const counts = await countsRead
133961
- if (counts === BUSY) workerBusy = true
133962
- // <Image> loads are left to the image loader, which counts only those
133963
- // that can reach the window. a runtime older than the CLI reports none.
133964
- const imageLoads = counts?.imageLoads ?? { total: 0, inFlight: 0 }
133965
- requestTotal = typeof counts?.total === 'number' ? counts.total - imageLoads.total : 0
133966
- requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight - imageLoads.inFlight : 0
133967
- // a skipped read carries the last count: mounts during motion still
133968
- // break the first still poll after it, instead of a blank baseline
133969
- // reading them as stable.
133970
- const total = nodeCountRead ? await nodeCountRead : lastNodeCount
133971
- if (total === BUSY) workerBusy = true
133972
- nodeCount = typeof total === 'number' ? total : null
133973
- const accessibility = accessibilityRead ? await accessibilityRead : null
133974
- const nativeHierarchy = Array.isArray(accessibility) && accessibility.length > 0
133975
- ? accessibility
133976
- : null
133977
- if (accessibility === BUSY) workerBusy = true
133978
- let hierarchy = hierarchyRead ? await hierarchyRead : null
133979
- if (hierarchy === BUSY) {
133980
- workerBusy = true
133981
- hierarchy = null
133982
- } else if (!Array.isArray(hierarchy)) {
133983
- hierarchy = null
133984
- }
133985
- const nodes = []
133986
- // identity beside each geometry entry, from the rows already read,
133987
- // so a changed layout can name the nodes that moved.
133988
- const nodeRows = []
133989
- 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
133990
- const noteLoading = (state, text) => {
133991
- if (state?.busy === true) {
133992
- webViewStarting = true
133993
- if (!webViewBlocker) webViewBlocker = 'accessibility busy state active'
133994
- }
133995
- if (typeof text === 'string' && LOADING_TEXT_REGEX.test(text.trim())) {
133996
- webViewStarting = true
133997
- if (!webViewBlocker) webViewBlocker = 'webView startup in progress ("' + text.trim() + '")'
133913
+ // positive checks only: an older runtime without the blocking
133914
+ // fields reads as still, and strict rejects that runtime above
133915
+ // instead of ever settling on unknown motion.
133916
+ animating =
133917
+ stats.hasActiveAnims === true ||
133918
+ stats.hasActiveBlockingNativeAnimations === true ||
133919
+ (!screenStill && (readyPlayback ? stats.hasPendingReadinessAnimationFrames : stats.hasPendingBlockingAnimationFrames) === true)
133920
+ if (animating)
133921
+ animatingBy = [
133922
+ stats.hasActiveAnims === true && 'activeAnims',
133923
+ stats.hasActiveBlockingNativeAnimations === true && 'blockingNative',
133924
+ !screenStill && stats.hasPendingBlockingAnimationFrames === true && 'pendingFrames',
133925
+ !screenStill && stats.hasPendingReadinessAnimationFrames === true && 'pendingReadinessFrames',
133926
+ ].filter(Boolean).join('+')
133927
+ // the runtime reports only layout work that can reach the window:
133928
+ // a covered screen or inactive tab committing does not hold it.
133929
+ layoutDirty =
133930
+ stats.layoutDirty === true && stats.renderRequested === true
133931
+ // a freshly-pushed screen showing a skeleton is layout-stable
133932
+ // but not actually settled \u2014 its data/images are still in
133933
+ // flight. treat bounded image-loader fetches as not-idle so
133934
+ // settle waits for real content, capped by the budget.
133935
+ const pf = stats.memory && stats.memory.imageLoader
133936
+ ? stats.memory.imageLoader.pendingFetches
133937
+ : 0
133938
+ pendingFetches = typeof pf === 'number' ? pf : 0
133939
+ // tenant layout commits: a screen that keeps committing is still
133940
+ // mounting or remounting, even with no animation flag raised.
133941
+ appCommits = typeof stats.appCommitCount === 'number' ? stats.appCommitCount : null
133942
+ }
133943
+ // mounted-root membership: the count of nodes that can reach the
133944
+ // window moves while the screen mounts, unmounts or recycles, in
133945
+ // either render mode. a screen a pushed one covers or an inactive
133946
+ // tab stays mounted out of the window, so what it mounts is not
133947
+ // screen motion. the worker rebuilds the membership set while the
133948
+ // wire moves on every animated frame, so a poll the motion read
133949
+ // already fails skips it: the motion flags alone prove this poll
133950
+ // unsettled, and the carried count hands the first still poll the
133951
+ // pre-motion baseline to compare against.
133952
+ const motionStill = !workerBusy && !animating && !layoutDirty && !shellAnimating
133953
+ const nodeCountRead = motionStill
133954
+ ? answer(() => globalThis.__sootsimTest?.getWindowNodeCount?.()).catch(() => null)
133955
+ : null
133956
+ const compositor = await compositorRead
133957
+ if (compositor === BUSY) {
133958
+ workerBusy = true
133959
+ } else {
133960
+ pendingFetches += compositor.images.pendingFetches
133961
+ pendingFetches += compositor.imageRealization.pending
133962
+ if (compositor.webViewCaptureSettled === false) {
133963
+ webViewStarting = true
133964
+ webViewBlocker = 'compositor webView capture not settled'
133965
+ }
133966
+ }
133967
+ const counts = await countsRead
133968
+ if (counts === BUSY) workerBusy = true
133969
+ // <Image> loads are left to the image loader, which counts only those
133970
+ // that can reach the window. a runtime older than the CLI reports none.
133971
+ const imageLoads = counts?.imageLoads ?? { total: 0, inFlight: 0 }
133972
+ requestTotal = typeof counts?.total === 'number' ? counts.total - imageLoads.total : 0
133973
+ requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight - imageLoads.inFlight : 0
133974
+ // a skipped read carries the last count: mounts during motion still
133975
+ // break the first still poll after it, instead of a blank baseline
133976
+ // reading them as stable.
133977
+ const total = nodeCountRead ? await nodeCountRead : lastNodeCount
133978
+ if (total === BUSY) workerBusy = true
133979
+ nodeCount = typeof total === 'number' ? total : null
133980
+ const accessibility = accessibilityRead ? await accessibilityRead : null
133981
+ const nativeHierarchy = Array.isArray(accessibility) && accessibility.length > 0
133982
+ ? accessibility
133983
+ : null
133984
+ if (accessibility === BUSY) workerBusy = true
133985
+ let hierarchy = hierarchyRead ? await hierarchyRead : null
133986
+ if (hierarchy === BUSY) {
133987
+ workerBusy = true
133988
+ hierarchy = null
133989
+ } else if (!Array.isArray(hierarchy)) {
133990
+ hierarchy = null
133991
+ }
133992
+ const nodes = []
133993
+ // identity beside each geometry entry, from the rows already read,
133994
+ // so a changed layout can name the nodes that moved.
133995
+ const nodeRows = []
133996
+ 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
133997
+ const noteLoading = (state, text) => {
133998
+ if (state?.busy === true) {
133999
+ webViewStarting = true
134000
+ if (!webViewBlocker) webViewBlocker = 'accessibility busy state active'
134001
+ }
134002
+ if (typeof text === 'string' && LOADING_TEXT_REGEX.test(text.trim())) {
134003
+ webViewStarting = true
134004
+ if (!webViewBlocker) webViewBlocker = 'webView startup in progress ("' + text.trim() + '")'
134005
+ }
134006
+ }
134007
+ if (hierarchy) {
134008
+ for (const n of hierarchy) {
134009
+ const layout = n && n.layout
134010
+ if (layout && layout.width > 0) {
134011
+ // painted bounds catch a scroll fling. background playback
134012
+ // keeps a view's painted bounds moving forever, so it and its
134013
+ // subtree count by their own layout; the rest of the screen
134014
+ // still catches the fling.
134015
+ const abs = n.backgroundPlayback ? layout : n.absolute || n.absolutePosition || layout
134016
+ const geometry = Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width)
134017
+ nodes.push(geometry)
134018
+ nodeRows.push([String(n.nodeId ?? nodes.length - 1), (n.type || '?') + (n.testId ? '#' + n.testId : ''), geometry])
133998
134019
  }
134020
+ noteLoading(
134021
+ n.accessibilityState,
134022
+ typeof n.text === 'string' ? n.text : '',
134023
+ )
133999
134024
  }
134000
- if (hierarchy) {
134001
- for (const n of hierarchy) {
134002
- const layout = n && n.layout
134003
- if (layout && layout.width > 0) {
134004
- // painted bounds catch a scroll fling. background playback
134005
- // keeps a view's painted bounds moving forever, so it and its
134006
- // subtree count by their own layout; the rest of the screen
134007
- // still catches the fling.
134008
- const abs = n.backgroundPlayback ? layout : n.absolute || n.absolutePosition || layout
134009
- const geometry = Math.round(abs.x) + ',' + Math.round(abs.y) + ',' + Math.round(layout.width)
134025
+ } else {
134026
+ const root = globalThis.__sootsimRoot
134027
+ if (root) {
134028
+ const walk = (n) => {
134029
+ if (n.layout && n.layout.width > 0) {
134030
+ const geometry = Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width)
134010
134031
  nodes.push(geometry)
134011
- nodeRows.push([String(n.nodeId ?? nodes.length - 1), (n.type || '?') + (n.testId ? '#' + n.testId : ''), geometry])
134032
+ nodeRows.push([String(n.id ?? nodes.length - 1), (n.type || '?') + (n.props?.testID ? '#' + n.props.testID : ''), geometry])
134012
134033
  }
134013
134034
  noteLoading(
134014
- n.accessibilityState,
134015
- typeof n.text === 'string' ? n.text : '',
134035
+ n.props?.accessibilityState,
134036
+ n.textContent || (typeof n.props?.children === 'string' ? n.props.children : ''),
134016
134037
  )
134038
+ for (const c of n.children || []) walk(c)
134017
134039
  }
134018
- } else {
134019
- const root = globalThis.__sootsimRoot
134020
- if (root) {
134021
- const walk = (n) => {
134022
- if (n.layout && n.layout.width > 0) {
134023
- const geometry = Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width)
134024
- nodes.push(geometry)
134025
- nodeRows.push([String(n.id ?? nodes.length - 1), (n.type || '?') + (n.props?.testID ? '#' + n.props.testID : ''), geometry])
134026
- }
134027
- noteLoading(
134028
- n.props?.accessibilityState,
134029
- n.textContent || (typeof n.props?.children === 'string' ? n.props.children : ''),
134030
- )
134031
- for (const c of n.children || []) walk(c)
134032
- }
134033
- walk(root)
134034
- }
134040
+ walk(root)
134035
134041
  }
134036
- if (!webViewStarting && typeof document !== 'undefined') {
134037
- const busyEl = [...document.querySelectorAll('[aria-busy="true"]')].find((element) => {
134038
- const bounds = element.getBoundingClientRect()
134039
- return element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&
134040
- bounds.width > 0 && bounds.height > 0 && bounds.right > 0 && bounds.bottom > 0 &&
134041
- bounds.left < globalThis.innerWidth && bounds.top < globalThis.innerHeight
134042
+ }
134043
+ if (!webViewStarting && typeof document !== 'undefined') {
134044
+ const busyEl = [...document.querySelectorAll('[aria-busy="true"]')].find((element) => {
134045
+ const bounds = element.getBoundingClientRect()
134046
+ return element.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) &&
134047
+ bounds.width > 0 && bounds.height > 0 && bounds.right > 0 && bounds.bottom > 0 &&
134048
+ bounds.left < globalThis.innerWidth && bounds.top < globalThis.innerHeight
134049
+ })
134050
+ if (busyEl) {
134051
+ webViewStarting = true
134052
+ webViewBlocker = 'accessibility busy element displayed'
134053
+ } else {
134054
+ // a loading document with no area (an app's hidden worker or
134055
+ // executor frame) paints nothing, and a screenshot on device
134056
+ // does not wait for it.
134057
+ const unreadyWebView = [...document.querySelectorAll(
134058
+ '[data-sootsim-webview-loading="true"], [data-sootsim-webview-mode="placeholder"]'
134059
+ )].find((view) => {
134060
+ const frame = view.querySelector('iframe')
134061
+ return !frame || frame.clientWidth > 0 || frame.clientHeight > 0
134042
134062
  })
134043
- if (busyEl) {
134063
+ if (unreadyWebView) {
134044
134064
  webViewStarting = true
134045
- webViewBlocker = 'accessibility busy element displayed'
134046
- } else {
134047
- // a loading document with no area (an app's hidden worker or
134048
- // executor frame) paints nothing, and a screenshot on device
134049
- // does not wait for it.
134050
- const unreadyWebView = [...document.querySelectorAll(
134051
- '[data-sootsim-webview-loading="true"], [data-sootsim-webview-mode="placeholder"]'
134052
- )].find((view) => {
134053
- const frame = view.querySelector('iframe')
134054
- return !frame || frame.clientWidth > 0 || frame.clientHeight > 0
134055
- })
134056
- if (unreadyWebView) {
134057
- webViewStarting = true
134058
- webViewBlocker = 'webView document still loading'
134059
- }
134060
- }
134061
- }
134062
- const pixelsDecide = !workerBusy && !animating && !shellAnimating && !layoutDirty && pendingFetches === 0 && !webViewStarting
134063
- if (paintStill && !pixelsDecide && unsubscribe) {
134064
- unsubscribe()
134065
- unsubscribe = null
134066
- }
134067
- if (paintStill && pixelsDecide && !unsubscribe) unsubscribe = composite.subscribe(() => {})
134068
- if (paintStill && pixelsDecide) {
134069
- const canvas = composite.getCanvas()
134070
- const token = composite.getFrameToken()
134071
- if (!canvas || canvas.width <= 1 || canvas.height <= 1) {
134072
- screenPixels = null
134073
- } else if (token !== pixelFrameToken || canvas.width !== screenPixels?.width || canvas.height !== screenPixels?.height) {
134074
- const context = canvas.getContext('2d')
134075
- const image = context?.getImageData(0, 0, canvas.width, canvas.height)
134076
- screenPixels = image ? { width: image.width, height: image.height, data: new Uint32Array(image.data.buffer) } : null
134077
- pixelFrameToken = token
134065
+ webViewBlocker = 'webView document still loading'
134078
134066
  }
134079
134067
  }
134080
- return { layout: nodes.join(';'), nodeRows, nativeHierarchy, screenPixels, animating, animatingBy, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
134081
- }
134082
-
134083
- // how long generic background network is allowed to keep us waiting AFTER
134084
- // the screen is otherwise visually settled. apps with continuous traffic
134085
- // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
134086
- // requestInFlight===0 / a stable requestTotal, so requiring full network
134087
- // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
134088
- // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
134089
- // layout-stability + the image-loader already prove visible content
134090
- // loaded (a data load changes layout; an image load shows in the loader),
134091
- // so the generic request counters are a courtesy, not a gate: honor them
134092
- // only within this grace once the screen is visually still.
134093
- const networkQuietGraceMs = 1200
134094
- let lastNativeHierarchy = null
134095
- let lastLayout = ''
134096
- let lastNodeRows = []
134097
- // what moved between the last two differing polls, bounded; names the
134098
- // nodes behind "layout changed" without keeping any poll history.
134099
- let lastLayoutChange = null
134100
- const describeLayoutChange = (before, after) => {
134101
- const previous = new Map(before.map(([key, label, geometry]) => [key, [label, geometry]]))
134102
- const moved = []
134103
- const added = []
134104
- const short = (label, key) => String(label).slice(0, 48) + ' [' + String(key).slice(0, 24) + ']'
134105
- for (const [key, label, geometry] of after) {
134106
- const was = previous.get(key)
134107
- previous.delete(key)
134108
- if (!was) added.push(short(label, key) + ' ' + geometry)
134109
- else if (was[1] !== geometry) moved.push(short(label, key) + ' ' + was[1] + '->' + geometry)
134110
- }
134111
- const removed = [...previous].map(([key, [label, geometry]]) => short(label, key) + ' ' + geometry)
134112
- return {
134113
- moved: moved.length, added: added.length, removed: removed.length,
134114
- movedSample: moved.slice(0, 3), addedSample: added.slice(0, 3), removedSample: removed.slice(0, 3),
134115
- }
134116
- }
134117
- let lastScreenPixels = null
134118
- let screenChangedPolls = 0
134119
- let lastRequestTotal = -1
134120
- let lastAppCommits = null
134121
- let lastNodeCount = null
134122
- // the last completed poll and the values it was compared against.
134123
- let report = null
134124
- // the still polls of the current run, when each began and answered
134125
- let stillPolls = []
134126
- let lastIdlePoll = null
134127
- let visuallyStillSince = 0
134128
- // counts across the whole budget: a flag that is true on every poll is a
134129
- // different bug from one that is true intermittently, and the two need
134130
- // opposite fixes (engine vs budget).
134131
- let polls = 0
134132
- let dirtyPolls = 0
134133
- let animatingPolls = 0
134134
- let layoutChangedPolls = 0
134135
- let webViewStartingPolls = 0
134136
- const screenUnchanged = (pixels, previous) => {
134137
- if (!pixels || !previous || pixels.width !== previous.width || pixels.height !== previous.height) return false
134138
- if (pixels === previous) return true
134139
- for (let i = 0; i < pixels.data.length; i++) {
134140
- if (pixels.data[i] !== previous.data[i]) return false
134141
- }
134142
- return true
134143
- }
134144
- const hierarchyUnchanged = (current, previous) =>
134145
- current !== null && previous !== null && current.length === previous.length &&
134146
- current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
134147
- while (true) {
134148
- if (clockNow() >= deadline) {
134149
- if (!transitionWait) break
134150
- await transitionWait
134151
- transitionWait = null
134152
- // nothing polled while parked on the transition, and a loaded
134153
- // worker's late reply would spend the restarted budget unobserved.
134154
- if (transitionEndedAt !== null) deadline = Math.max(deadline, clockNow() + budgetMs)
134155
- if (clockNow() >= deadline) break
134156
- }
134157
- const pollStarted = clockNow()
134158
- const snapshot = await readSnapshot()
134159
- if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
134160
- // a read the deadline cut short observed nothing: the last full poll
134161
- // names what held the settle, not a worker that ran out of budget.
134162
- // the loop head drains a transition still in flight before it ends.
134163
- if (snapshot.workerBusy && clockNow() >= deadline && report) continue
134164
- polls++
134165
- report = { snapshot, nativeHierarchy: lastNativeHierarchy, layout: lastLayout, screenPixels: lastScreenPixels, requestTotal: lastRequestTotal, appCommits: lastAppCommits, nodeCount: lastNodeCount }
134166
- if (snapshot.layoutDirty) dirtyPolls++
134167
- if (snapshot.animating || snapshot.shellAnimating) animatingPolls++
134168
- if (snapshot.webViewStarting) webViewStartingPolls++
134169
- if (polls > 1 && snapshot.layout !== lastLayout) {
134170
- layoutChangedPolls++
134171
- lastLayoutChange = describeLayoutChange(lastNodeRows, snapshot.nodeRows)
134172
- }
134173
- const screenChanged = paintStill && !screenUnchanged(snapshot.screenPixels, lastScreenPixels)
134174
- if (polls > 1 && screenChanged) screenChangedPolls++
134175
- const strictOk =
134176
- !strict ||
134177
- (snapshot.renderStatsAvailable &&
134178
- !snapshot.animating &&
134179
- !snapshot.shellAnimating &&
134180
- !snapshot.layoutDirty)
134181
- // visually settled: no worker motion or layout work, no new layout
134182
- // commits, a stable mounted node count, no image content loading
134183
- // (unless motion alone is asked), no webview startup in progress,
134184
- // layout unchanged since the last poll. both modes wait out finite
134185
- // worker motion now; strict additionally implies the flags through
134186
- // strictOk and adds shell motion plus the blocking-stats floor. a
134187
- // null count or commit reading means the runtime does not report
134188
- // it, which reads as stable the way a missing stats block does.
134189
- // equal presented pixels can precede pending worker motion or layout.
134190
- // after that work drains, iOS's 3 s pixel phase may accept two equal
134191
- // native TreeNodes while paint-only playback continues. overlap
134192
- // hierarchy reads so neither the gesture nor screenshot deadline grows.
134193
- const maestroStill = snapshot.screenPixels !== null && !snapshot.workerBusy && snapshot.pendingFetches === 0 && snapshot.requestInFlight === 0 && !snapshot.webViewStarting &&
134194
- !snapshot.animating && !snapshot.shellAnimating && !snapshot.layoutDirty && (
134195
- !screenChanged || (clockNow() - start >= 3000 &&
134196
- hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
134197
- )
134198
- const idleSnapshot =
134199
- strictOk &&
134068
+ }
134069
+ return { layout: nodes.join(';'), nodeRows, nativeHierarchy, visibleMotion, visibleMotionBy, animating, animatingBy, shellAnimating, shellBlockers, layoutDirty, pendingFetches, workerBusy, webViewStarting, webViewBlocker, renderStatsAvailable, requestTotal, requestInFlight, appCommits, nodeCount }
134070
+ }
134071
+
134072
+ // how long generic background network is allowed to keep us waiting AFTER
134073
+ // the screen is otherwise visually settled. apps with continuous traffic
134074
+ // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
134075
+ // requestInFlight===0 / a stable requestTotal, so requiring full network
134076
+ // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
134077
+ // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
134078
+ // layout-stability + the image-loader already prove visible content
134079
+ // loaded (a data load changes layout; an image load shows in the loader),
134080
+ // so the generic request counters are a courtesy, not a gate: honor them
134081
+ // only within this grace once the screen is visually still.
134082
+ const networkQuietGraceMs = 1200
134083
+ let lastNativeHierarchy = null
134084
+ let lastLayout = ''
134085
+ let lastNodeRows = []
134086
+ // what moved between the last two differing polls, bounded; names the
134087
+ // nodes behind "layout changed" without keeping any poll history.
134088
+ let lastLayoutChange = null
134089
+ const describeLayoutChange = (before, after) => {
134090
+ const previous = new Map(before.map(([key, label, geometry]) => [key, [label, geometry]]))
134091
+ const moved = []
134092
+ const added = []
134093
+ const short = (label, key) => String(label).slice(0, 48) + ' [' + String(key).slice(0, 24) + ']'
134094
+ for (const [key, label, geometry] of after) {
134095
+ const was = previous.get(key)
134096
+ previous.delete(key)
134097
+ if (!was) added.push(short(label, key) + ' ' + geometry)
134098
+ else if (was[1] !== geometry) moved.push(short(label, key) + ' ' + was[1] + '->' + geometry)
134099
+ }
134100
+ const removed = [...previous].map(([key, [label, geometry]]) => short(label, key) + ' ' + geometry)
134101
+ return {
134102
+ moved: moved.length, added: added.length, removed: removed.length,
134103
+ movedSample: moved.slice(0, 3), addedSample: added.slice(0, 3), removedSample: removed.slice(0, 3),
134104
+ }
134105
+ }
134106
+ let screenChangedPolls = 0
134107
+ let lastRequestTotal = -1
134108
+ let lastAppCommits = null
134109
+ let lastNodeCount = null
134110
+ // the last completed poll and the values it was compared against.
134111
+ let report = null
134112
+ // the still polls of the current run, when each began and answered
134113
+ let stillPolls = []
134114
+ let lastIdlePoll = null
134115
+ let visuallyStillSince = 0
134116
+ // counts across the whole budget: a flag that is true on every poll is a
134117
+ // different bug from one that is true intermittently, and the two need
134118
+ // opposite fixes (engine vs budget).
134119
+ let polls = 0
134120
+ let dirtyPolls = 0
134121
+ let animatingPolls = 0
134122
+ let layoutChangedPolls = 0
134123
+ let webViewStartingPolls = 0
134124
+ const hierarchyUnchanged = (current, previous) =>
134125
+ current !== null && previous !== null && current.length === previous.length &&
134126
+ current.every((node, index) => sameNativeAccessibilityShape(node, previous[index], accessibilityBounds))
134127
+ while (true) {
134128
+ if (clockNow() >= deadline) {
134129
+ if (!transitionWait) break
134130
+ await transitionWait
134131
+ transitionWait = null
134132
+ // nothing polled while parked on the transition, and a loaded
134133
+ // worker's late reply would spend the restarted budget unobserved.
134134
+ if (transitionEndedAt !== null) deadline = Math.max(deadline, clockNow() + budgetMs)
134135
+ if (clockNow() >= deadline) break
134136
+ }
134137
+ const pollStarted = clockNow()
134138
+ const snapshot = await readSnapshot()
134139
+ if (snapshot.runtimeUnsupported) return snapshot.runtimeUnsupported
134140
+ // a read the deadline cut short observed nothing: the last full poll
134141
+ // names what held the settle, not a worker that ran out of budget.
134142
+ // the loop head drains a transition still in flight before it ends.
134143
+ if (snapshot.workerBusy && clockNow() >= deadline && report) continue
134144
+ polls++
134145
+ report = { snapshot, nativeHierarchy: lastNativeHierarchy, layout: lastLayout, requestTotal: lastRequestTotal, appCommits: lastAppCommits, nodeCount: lastNodeCount }
134146
+ if (snapshot.layoutDirty) dirtyPolls++
134147
+ if (snapshot.animating || snapshot.shellAnimating) animatingPolls++
134148
+ if (snapshot.webViewStarting) webViewStartingPolls++
134149
+ if (polls > 1 && snapshot.layout !== lastLayout) {
134150
+ layoutChangedPolls++
134151
+ lastLayoutChange = describeLayoutChange(lastNodeRows, snapshot.nodeRows)
134152
+ }
134153
+ // the first poll has nothing to compare, so it cannot prove a still screen
134154
+ const screenChanged = screenStill && (
134155
+ polls === 1 ||
134156
+ snapshot.visibleMotion ||
134157
+ (snapshot.appCommits !== null && lastAppCommits !== null && snapshot.appCommits !== lastAppCommits) ||
134158
+ (snapshot.nodeCount !== null && lastNodeCount !== null && snapshot.nodeCount !== lastNodeCount) ||
134159
+ snapshot.layout !== lastLayout ||
134160
+ (maestro && !hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
134161
+ )
134162
+ if (polls > 1 && screenChanged) screenChangedPolls++
134163
+ const strictOk =
134164
+ !strict ||
134165
+ (snapshot.renderStatsAvailable &&
134200
134166
  !snapshot.animating &&
134201
134167
  !snapshot.shellAnimating &&
134202
- !snapshot.layoutDirty &&
134203
- snapshot.pendingFetches === 0 &&
134204
- !snapshot.workerBusy &&
134205
- !snapshot.webViewStarting
134206
- const visuallyStill = maestro ? maestroStill :
134207
- idleSnapshot &&
134208
- (snapshot.appCommits === null || lastAppCommits === null || snapshot.appCommits === lastAppCommits) &&
134209
- (snapshot.nodeCount === null || lastNodeCount === null || snapshot.nodeCount === lastNodeCount) &&
134210
- !screenChanged &&
134211
- snapshot.layout === lastLayout
134212
- // generic network quiet: nothing in flight and no new requests issued.
134213
- const networkQuiet =
134214
- snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
134215
- if (visuallyStill) {
134216
- if (visuallyStillSince === 0) visuallyStillSince = clockNow()
134217
- // two equal idle observations prove the interval between them.
134218
- // discarding the first requires a third worker round trip, which
134219
- // can exhaust the budget after a late image on a loaded host.
134220
- if (!maestro && !paintStill && stillPolls.length === 0 && lastIdlePoll) {
134221
- stillPolls.push(lastIdlePoll)
134222
- }
134223
- stillPolls.push({ started: pollStarted, answered: clockNow() })
134224
- // still long enough, counting only polls that began after a started
134225
- // transition drained.
134226
- const stillProven = () => {
134227
- const proving = stillPolls.filter((poll) => transitionEndedAt === null || poll.started >= transitionEndedAt)
134228
- return proving.length >= minimumStablePolls && clockNow() - proving[0].answered >= requiredStillMs
134229
- }
134230
- // settle once the screen has held still long enough AND either the
134231
- // network is genuinely quiet OR it has refused to quiet within the
134232
- // grace (continuous background traffic must not block forever).
134233
- if (
134234
- stillProven() &&
134235
- (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
134236
- ) {
134237
- if (transitionWait) {
134238
- await transitionWait
134239
- transitionWait = null
134240
- }
134241
- if (stillProven()) return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
134168
+ !snapshot.layoutDirty)
134169
+ // visually settled: no worker motion or layout work, no new layout
134170
+ // commits, a stable mounted node count, no image content loading
134171
+ // (unless motion alone is asked), no webview startup in progress,
134172
+ // layout unchanged since the last poll. both modes wait out finite
134173
+ // worker motion now; strict additionally implies the flags through
134174
+ // strictOk and adds shell motion plus the blocking-stats floor. a
134175
+ // null count or commit reading means the runtime does not report
134176
+ // it, which reads as stable the way a missing stats block does.
134177
+ // equal presented pixels can precede pending worker motion or layout.
134178
+ // after that work drains, iOS's 3 s pixel phase may accept two equal
134179
+ // native TreeNodes while paint-only playback continues. overlap
134180
+ // hierarchy reads so neither the gesture nor screenshot deadline grows.
134181
+ const maestroStill = !snapshot.workerBusy && snapshot.pendingFetches === 0 && snapshot.requestInFlight === 0 && !snapshot.webViewStarting &&
134182
+ !snapshot.animating && !snapshot.shellAnimating && !snapshot.layoutDirty && (
134183
+ !screenChanged || (clockNow() - start >= 3000 &&
134184
+ hierarchyUnchanged(snapshot.nativeHierarchy, lastNativeHierarchy))
134185
+ )
134186
+ const idleSnapshot =
134187
+ strictOk &&
134188
+ !snapshot.animating &&
134189
+ !snapshot.shellAnimating &&
134190
+ !snapshot.layoutDirty &&
134191
+ snapshot.pendingFetches === 0 &&
134192
+ !snapshot.workerBusy &&
134193
+ !snapshot.webViewStarting
134194
+ const visuallyStill = maestro ? maestroStill :
134195
+ idleSnapshot &&
134196
+ (snapshot.appCommits === null || lastAppCommits === null || snapshot.appCommits === lastAppCommits) &&
134197
+ (snapshot.nodeCount === null || lastNodeCount === null || snapshot.nodeCount === lastNodeCount) &&
134198
+ !screenChanged &&
134199
+ snapshot.layout === lastLayout
134200
+ // generic network quiet: nothing in flight and no new requests issued.
134201
+ const networkQuiet =
134202
+ snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
134203
+ if (visuallyStill) {
134204
+ if (visuallyStillSince === 0) visuallyStillSince = clockNow()
134205
+ // two equal idle observations prove the interval between them.
134206
+ // discarding the first requires a third worker round trip, which
134207
+ // can exhaust the budget after a late image on a loaded host.
134208
+ if (!maestro && !screenStill && stillPolls.length === 0 && lastIdlePoll) {
134209
+ stillPolls.push(lastIdlePoll)
134210
+ }
134211
+ stillPolls.push({ started: pollStarted, answered: clockNow() })
134212
+ // still long enough, counting only polls that began after a started
134213
+ // transition drained.
134214
+ const stillProven = () => {
134215
+ const proving = stillPolls.filter((poll) => transitionEndedAt === null || poll.started >= transitionEndedAt)
134216
+ return proving.length >= minimumStablePolls && clockNow() - proving[0].answered >= requiredStillMs
134217
+ }
134218
+ // settle once the screen has held still long enough AND either the
134219
+ // network is genuinely quiet OR it has refused to quiet within the
134220
+ // grace (continuous background traffic must not block forever).
134221
+ if (
134222
+ stillProven() &&
134223
+ (maestro || networkQuiet || clockNow() - visuallyStillSince >= networkQuietGraceMs)
134224
+ ) {
134225
+ if (transitionWait) {
134226
+ await transitionWait
134227
+ transitionWait = null
134242
134228
  }
134243
- } else {
134244
- stillPolls = []
134245
- visuallyStillSince = 0
134246
- }
134247
- lastIdlePoll = idleSnapshot ? { started: pollStarted, answered: clockNow() } : null
134248
- lastNativeHierarchy = snapshot.nativeHierarchy
134249
- lastLayout = snapshot.layout
134250
- lastNodeRows = snapshot.nodeRows
134251
- lastScreenPixels = snapshot.screenPixels
134252
- lastRequestTotal = snapshot.requestTotal
134253
- lastAppCommits = snapshot.appCommits
134254
- lastNodeCount = snapshot.nodeCount
134255
- // reply latency belongs inside the poll interval; the stillness window
134256
- // above remains measured from completed observations.
134257
- const remainingPollMs = pollMs - (clockNow() - pollStarted)
134258
- if (remainingPollMs > 0) await clockSleep(remainingPollMs)
134259
- }
134260
- if (!report) {
134261
- return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
134262
- }
134263
- const last = report.snapshot
134264
- const blockers = []
134265
- if (!maestro && strict && !last.renderStatsAvailable) blockers.push('render stats unavailable')
134266
- if (!maestro && last.animating) blockers.push('animations still running' + (last.animatingBy ? ' (' + last.animatingBy + ')' : ''))
134267
- if (last.shellAnimating) blockers.push('animations still running (' + last.shellBlockers + ')')
134268
- if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
134269
- if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
134270
- if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
134271
- if (last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
134272
- if (last.workerBusy) blockers.push('a render worker too busy to report')
134273
- if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
134274
- if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
134275
- if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
134276
- if (paintStill && !last.screenPixels) blockers.push('screen pixels unavailable')
134277
- else if (paintStill && !screenUnchanged(last.screenPixels, report.screenPixels)) blockers.push('screen pixels still changing')
134278
- if (last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
134279
- else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
134280
- if (polls < 2) blockers.push('sim too busy to poll twice')
134281
- // the last read is still: motion ended too near the deadline for the
134282
- // stillness window to hold before it.
134283
- if (!blockers.length) blockers.push('motion ended before stillness was proven')
134284
- return {
134285
- settled: false,
134286
- elapsed: clockNow() - start,
134287
- blockedBy:
134288
- blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
134289
- 'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
134290
- (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
134291
- }
134292
- } finally {
134293
- unsubscribe?.()
134229
+ if (stillProven()) return { settled: true, elapsed: clockNow() - start, blockedBy: '' }
134230
+ }
134231
+ } else {
134232
+ stillPolls = []
134233
+ visuallyStillSince = 0
134234
+ }
134235
+ lastIdlePoll = idleSnapshot ? { started: pollStarted, answered: clockNow() } : null
134236
+ lastNativeHierarchy = snapshot.nativeHierarchy
134237
+ lastLayout = snapshot.layout
134238
+ lastNodeRows = snapshot.nodeRows
134239
+ lastRequestTotal = snapshot.requestTotal
134240
+ lastAppCommits = snapshot.appCommits
134241
+ lastNodeCount = snapshot.nodeCount
134242
+ // reply latency belongs inside the poll interval; the stillness window
134243
+ // above remains measured from completed observations.
134244
+ const remainingPollMs = pollMs - (clockNow() - pollStarted)
134245
+ if (remainingPollMs > 0) await clockSleep(remainingPollMs)
134246
+ }
134247
+ if (!report) {
134248
+ return { settled: false, elapsed: clockNow() - start, blockedBy: 'no poll fit the budget' }
134249
+ }
134250
+ const last = report.snapshot
134251
+ const blockers = []
134252
+ if (!maestro && strict && !last.renderStatsAvailable) blockers.push('render stats unavailable')
134253
+ if (!maestro && last.animating) blockers.push('animations still running' + (last.animatingBy ? ' (' + last.animatingBy + ')' : ''))
134254
+ if (last.shellAnimating) blockers.push('animations still running (' + last.shellBlockers + ')')
134255
+ if (!maestro && last.layoutDirty) blockers.push('layout still dirty')
134256
+ if (!maestro && last.appCommits !== null && report.appCommits !== null && last.appCommits !== report.appCommits) blockers.push('layout commits still landing')
134257
+ if (!maestro && last.nodeCount !== null && report.nodeCount !== null && last.nodeCount !== report.nodeCount) blockers.push('node count still changing')
134258
+ if (last.pendingFetches > 0) blockers.push(last.pendingFetches + ' image fetches pending')
134259
+ if (last.workerBusy) blockers.push('a render worker too busy to report')
134260
+ if (last.webViewStarting) blockers.push(last.webViewBlocker || 'webView still starting')
134261
+ if (!maestro && last.layout !== report.layout) blockers.push('layout still changing')
134262
+ if (maestro && !hierarchyUnchanged(last.nativeHierarchy, report.nativeHierarchy)) blockers.push(last.nativeHierarchy === null ? 'native accessibility hierarchy unavailable' : 'native accessibility hierarchy still changing')
134263
+ if (screenStill && last.visibleMotion) blockers.push('visible motion continues (' + last.visibleMotionBy + ')')
134264
+ if (last.requestInFlight > 0) blockers.push(last.requestInFlight + ' requests in flight')
134265
+ else if (!maestro && last.requestTotal !== report.requestTotal) blockers.push('new requests issued')
134266
+ if (polls < 2) blockers.push('sim too busy to poll twice')
134267
+ // the last read is still: motion ended too near the deadline for the
134268
+ // stillness window to hold before it.
134269
+ if (!blockers.length) blockers.push('motion ended before stillness was proven')
134270
+ return {
134271
+ settled: false,
134272
+ elapsed: clockNow() - start,
134273
+ blockedBy:
134274
+ blockers.join(', ') + ' over ' + polls + ' polls (layout changed ' + layoutChangedPolls +
134275
+ 'x, layoutDirty ' + dirtyPolls + 'x, animating ' + animatingPolls + 'x, webViewStarting ' + webViewStartingPolls + 'x, screen changed ' + screenChangedPolls + 'x)' +
134276
+ (lastLayoutChange ? '; last layout change ' + JSON.stringify(lastLayoutChange) : ''),
134294
134277
  }
134295
134278
  })()`
134296
134279
  },
@@ -136630,11 +136613,11 @@ var init_bridge_flow_runner = __esm({
136630
136613
  throw new Error(`assertTreeContains: "${value}" not in tree`);
136631
136614
  }
136632
136615
  }
136633
- // maestro's waitForAnimationToEnd compares screenshots until the screen holds
136634
- // still, so motion the screen does not show (an endless loop under a
136635
- // full-screen sheet) never holds it; visible shell motion changes the pixels.
136636
- // like maestro, a screen that never holds still (a looping illustration)
136637
- // ends the wait at the timeout and the flow continues
136616
+ // maestro's waitForAnimationToEnd waits until the screen holds still, so
136617
+ // motion the screen does not show (an endless loop under a full-screen
136618
+ // sheet) never holds it. the engine knows which motion is visible, so the
136619
+ // wait reads that instead of pixels. like maestro, a screen that never holds
136620
+ // still (a looping illustration) ends the wait at the timeout
136638
136621
  async waitForAnimationToEnd(timeoutMs = 2e3) {
136639
136622
  const maxMs = Math.max(0, Math.round(timeoutMs));
136640
136623
  if (maxMs <= 0) return;
@@ -136643,7 +136626,7 @@ var init_bridge_flow_runner = __esm({
136643
136626
  simId: this.opts.simId,
136644
136627
  maxMs,
136645
136628
  pollMs: 32,
136646
- paintStill: true
136629
+ screenStill: true
136647
136630
  });
136648
136631
  }
136649
136632
  // step peach's lockstep animation clock by one or more explicit millisecond
@@ -136939,7 +136922,8 @@ var init_bridge_flow_runner = __esm({
136939
136922
  });
136940
136923
  }
136941
136924
  }
136942
- // ios checks pixels for three seconds, then compares native hierarchies.
136925
+ // ios waits up to three seconds for a still screen, then compares native
136926
+ // hierarchies.
136943
136927
  // the observer overlaps those reads to keep this command's existing budget.
136944
136928
  async waitForAppToSettle() {
136945
136929
  try {
@@ -136949,7 +136933,7 @@ var init_bridge_flow_runner = __esm({
136949
136933
  maxMs: 3e3,
136950
136934
  pollMs: 32,
136951
136935
  maestro: true,
136952
- paintStill: true
136936
+ screenStill: true
136953
136937
  });
136954
136938
  if (!result.settled) {
136955
136939
  console.warn(
@@ -136972,7 +136956,7 @@ var init_bridge_flow_runner = __esm({
136972
136956
  pollMs: 32,
136973
136957
  stablePolls: 3,
136974
136958
  maestro: true,
136975
- paintStill: true
136959
+ screenStill: true
136976
136960
  });
136977
136961
  if (!result.settled) {
136978
136962
  throw new Error(