rnxsim 0.1.375 → 0.1.377

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 (295) hide show
  1. package/README.md +28 -25
  2. package/cli/app-config.ts +9 -12
  3. package/cli/app-fonts.ts +3 -3
  4. package/cli/app-project.ts +8 -8
  5. package/cli/auth.ts +7 -9
  6. package/cli/bin.ts +16 -31
  7. package/cli/bridge-flow-runner.ts +3 -3
  8. package/cli/browser-backend.ts +44 -0
  9. package/cli/command-contract.ts +221 -0
  10. package/cli/command-registry.ts +291 -0
  11. package/cli/commands/agent-wrapper.ts +2 -2
  12. package/cli/commands/app-fonts.ts +2 -2
  13. package/cli/commands/assert.ts +3 -3
  14. package/cli/commands/auth.ts +1 -1
  15. package/cli/commands/box/cloud-box.ts +1 -1
  16. package/cli/commands/box/plane-share.ts +2 -2
  17. package/cli/commands/box.ts +4 -6
  18. package/cli/commands/compat.ts +1 -1
  19. package/cli/commands/config.ts +2 -2
  20. package/cli/commands/control.ts +42 -28
  21. package/cli/commands/cpu-profile.ts +7 -7
  22. package/cli/commands/daemon-mac-app.ts +7 -7
  23. package/cli/commands/daemon.ts +10 -10
  24. package/cli/commands/debug.ts +11 -11
  25. package/cli/commands/detox.ts +13 -13
  26. package/cli/commands/diagnose.ts +6 -6
  27. package/cli/commands/do-chain.ts +1 -2
  28. package/cli/commands/electron.ts +1 -3
  29. package/cli/commands/film.ts +3 -3
  30. package/cli/commands/flow.ts +43 -43
  31. package/cli/commands/inspect/count.ts +1 -1
  32. package/cli/commands/inspect/describe.ts +1 -1
  33. package/cli/commands/inspect/env.ts +2 -2
  34. package/cli/commands/inspect/get-layout.ts +1 -1
  35. package/cli/commands/inspect/keyboard.ts +1 -1
  36. package/cli/commands/inspect/list.ts +1 -1
  37. package/cli/commands/inspect/memory.ts +1 -1
  38. package/cli/commands/inspect/resolve-target.ts +1 -1
  39. package/cli/commands/inspect/screens.ts +1 -1
  40. package/cli/commands/inspect/tree.ts +1 -1
  41. package/cli/commands/inspect/url.ts +1 -1
  42. package/cli/commands/inspect/wait-event.ts +5 -5
  43. package/cli/commands/inspect.ts +34 -34
  44. package/cli/commands/install-desktop.ts +3 -3
  45. package/cli/commands/login.ts +6 -6
  46. package/cli/commands/maestro-generate.ts +5 -5
  47. package/cli/commands/maestro.ts +5 -5
  48. package/cli/commands/profile.ts +1 -1
  49. package/cli/commands/record.ts +9 -9
  50. package/cli/commands/runtime.ts +18 -18
  51. package/cli/commands/screenshot-command.ts +1 -1
  52. package/cli/commands/screenshot-layers.ts +5 -5
  53. package/cli/commands/screenshot-mode.ts +1 -1
  54. package/cli/commands/screenshot.ts +8 -8
  55. package/cli/commands/screenshots-capture.ts +5 -5
  56. package/cli/commands/serve.ts +3 -3
  57. package/cli/commands/setup.ts +20 -12
  58. package/cli/commands/skills.ts +5 -5
  59. package/cli/commands/slides.ts +1 -1
  60. package/cli/commands/telemetry.ts +1 -1
  61. package/cli/commands/three-mode.ts +1 -1
  62. package/cli/commands/timeline.ts +8 -8
  63. package/cli/commands/upgrade.ts +116 -131
  64. package/cli/commands/upload.ts +12 -12
  65. package/cli/commands/version.ts +7 -7
  66. package/cli/commands/what-happened.ts +9 -9
  67. package/cli/current-sim.ts +3 -3
  68. package/cli/desktop-companion.ts +1 -1
  69. package/cli/drivers/playwright.ts +9 -9
  70. package/cli/drivers/registry.ts +1 -1
  71. package/cli/drivers/types.ts +1 -1
  72. package/cli/flow-file.ts +2 -2
  73. package/cli/flow-session.ts +1 -1
  74. package/cli/help-core.ts +136 -0
  75. package/cli/help.ts +17 -53
  76. package/cli/hints.ts +5 -5
  77. package/cli/inspect-notice-state.ts +1 -1
  78. package/cli/maestro-js.ts +1 -1
  79. package/cli/outbound-endpoints.ts +23 -5
  80. package/cli/parse-args.ts +19 -66
  81. package/cli/recording-access.ts +1 -1
  82. package/cli/registry.ts +1 -0
  83. package/cli/run-registry.ts +1 -1
  84. package/cli/run-rnx-core.ts +148 -0
  85. package/cli/run-rnx.ts +6 -9
  86. package/cli/runtime-notes.ts +3 -3
  87. package/cli/standalone.ts +4 -0
  88. package/cli/ws-bridge.ts +8 -8
  89. package/detox/config-loader.ts +2 -2
  90. package/detox/index.ts +8 -8
  91. package/detox/jest-preset.cjs +1 -1
  92. package/detox/navigation.ts +2 -2
  93. package/dist-lib/agent-daemon-client.cjs +5 -5
  94. package/dist-lib/agent-events.cjs +1 -1
  95. package/dist-lib/agent-identity.cjs +2 -2
  96. package/dist-lib/agent-sessions.cjs +10 -10
  97. package/dist-lib/attached-projects.cjs +6 -6
  98. package/dist-lib/auth/shared-session.cjs +6 -6
  99. package/dist-lib/backend-origin.cjs +1 -1
  100. package/dist-lib/beta.cjs +1 -1
  101. package/dist-lib/beta.mjs +1 -1
  102. package/dist-lib/bridge-constants.cjs +1 -1
  103. package/dist-lib/bridge-contract-input.cjs +1 -1
  104. package/dist-lib/bridge-contract-input.mjs +1 -1
  105. package/dist-lib/bridge-contract.cjs +1 -1
  106. package/dist-lib/bridge-contract.mjs +1 -1
  107. package/dist-lib/cli-constants.cjs +1 -1
  108. package/dist-lib/config.cjs +25 -25
  109. package/dist-lib/detox/index.cjs +9 -9
  110. package/dist-lib/detox/jest-preset.cjs +1 -1
  111. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  112. package/dist-lib/home-paths.cjs +29 -29
  113. package/dist-lib/host/bridge-host.cjs +274 -181
  114. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  115. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  116. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  117. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  118. package/dist-lib/host/websocket-proxy.cjs +1 -1
  119. package/dist-lib/index.cjs +14 -14
  120. package/dist-lib/jump-to-source-babel.cjs +1 -1
  121. package/dist-lib/menu.cjs +1 -1
  122. package/dist-lib/menu.mjs +1 -1
  123. package/dist-lib/metro-production-bundle.cjs +1 -1
  124. package/dist-lib/metro-production-bundle.mjs +1 -1
  125. package/dist-lib/metro.cjs +8 -8
  126. package/dist-lib/profiles.cjs +12 -12
  127. package/dist-lib/public-brand.cjs +1 -1
  128. package/dist-lib/react-native-host-modules.cjs +1 -1
  129. package/dist-lib/react-native-host-modules.mjs +1 -1
  130. package/dist-lib/render-mode.cjs +1 -1
  131. package/dist-lib/scripts/dev-server-scanner.cjs +25 -11
  132. package/dist-lib/sdk.cjs +1 -1
  133. package/dist-lib/sdk.mjs +1 -1
  134. package/dist-lib/skills.cjs +470 -322
  135. package/dist-lib/vite.cjs +9 -9
  136. package/package.json +4 -11
  137. package/scripts/dev-server-scanner.ts +25 -7
  138. package/scripts/optional-demo-registry.ts +1 -1
  139. package/skills/contrast/SKILL.md +3 -3
  140. package/skills/rnx-debug/SKILL.md +1 -1
  141. package/skills/rnx-test/SKILL.md +2 -2
  142. package/src/agent-identity.ts +1 -1
  143. package/src/agent-sessions.ts +7 -5
  144. package/src/cli-version.ts +12 -4
  145. package/src/config.ts +26 -28
  146. package/src/disk-cleanup.ts +11 -11
  147. package/src/home-paths.ts +28 -28
  148. package/src/host/bridge-host.ts +16 -16
  149. package/src/metro-plugin.ts +2 -2
  150. package/src/profiles.ts +2 -2
  151. package/src/runtime-assets.ts +7 -7
  152. package/src/runtime-delivery.ts +13 -13
  153. package/src/screenshots/orchestrate.ts +1 -1
  154. package/src/screenshots/schema.ts +2 -2
  155. package/src/skills/builtin/a11y-review.ts +2 -2
  156. package/src/skills/builtin/compat-check.ts +2 -2
  157. package/src/skills/builtin/maestro-test.ts +2 -2
  158. package/src/skills/builtin/perf-profile.ts +2 -2
  159. package/src/skills/builtin/screenshot-all.ts +2 -2
  160. package/src/skills/builtin/visual-diff.ts +2 -2
  161. package/src/skills/registry.ts +8 -8
  162. package/src/skills/types.ts +1 -1
  163. package/src/vite-plugin-one.ts +3 -3
  164. package/src/vite-plugin.ts +15 -2
  165. package/dist-cli/bin.js +0 -15
  166. package/dist-cli/chunks/agent-JJN7U6FR.js +0 -48
  167. package/dist-cli/chunks/agent-wrapper-AVVUJ3WF.js +0 -17
  168. package/dist-cli/chunks/app-fonts-QJ22CNAZ.js +0 -4
  169. package/dist-cli/chunks/assert-PZZKIY3K.js +0 -49
  170. package/dist-cli/chunks/auth-5AVDJO33.js +0 -12
  171. package/dist-cli/chunks/beta-PFRGP266.js +0 -4
  172. package/dist-cli/chunks/box-ILC2O7ZO.js +0 -1730
  173. package/dist-cli/chunks/camera-J3V62PP7.js +0 -33
  174. package/dist-cli/chunks/chunk-25KRGDZT.js +0 -4
  175. package/dist-cli/chunks/chunk-2BRBFLWA.js +0 -38
  176. package/dist-cli/chunks/chunk-2GXNAZHB.js +0 -74
  177. package/dist-cli/chunks/chunk-2IUMRRYV.js +0 -7
  178. package/dist-cli/chunks/chunk-4ALPWIMP.js +0 -10
  179. package/dist-cli/chunks/chunk-4CEZZKRY.js +0 -4
  180. package/dist-cli/chunks/chunk-4EUKOIAV.js +0 -4
  181. package/dist-cli/chunks/chunk-4IKE4YUS.js +0 -32
  182. package/dist-cli/chunks/chunk-4ZXR2M3D.js +0 -4
  183. package/dist-cli/chunks/chunk-5CGJFU27.js +0 -7
  184. package/dist-cli/chunks/chunk-5HHWECGT.js +0 -4
  185. package/dist-cli/chunks/chunk-5PZVYF42.js +0 -312
  186. package/dist-cli/chunks/chunk-7NCPUZ52.js +0 -27
  187. package/dist-cli/chunks/chunk-7OSIJCBR.js +0 -107
  188. package/dist-cli/chunks/chunk-AQ5TMOAI.js +0 -4
  189. package/dist-cli/chunks/chunk-BQCEI37V.js +0 -5
  190. package/dist-cli/chunks/chunk-C6B5FOP3.js +0 -4
  191. package/dist-cli/chunks/chunk-CCMZSHJB.js +0 -71
  192. package/dist-cli/chunks/chunk-CX7VCKAT.js +0 -14
  193. package/dist-cli/chunks/chunk-DQUPSAHE.js +0 -4
  194. package/dist-cli/chunks/chunk-DSD2UBZI.js +0 -4
  195. package/dist-cli/chunks/chunk-EWPAI4MO.js +0 -7
  196. package/dist-cli/chunks/chunk-EZXV6U2N.js +0 -497
  197. package/dist-cli/chunks/chunk-F5F7FIPM.js +0 -6
  198. package/dist-cli/chunks/chunk-FUTYK55H.js +0 -30
  199. package/dist-cli/chunks/chunk-FW6AN7I2.js +0 -3
  200. package/dist-cli/chunks/chunk-FZDRA7Z4.js +0 -4
  201. package/dist-cli/chunks/chunk-GDLE4NIV.js +0 -4
  202. package/dist-cli/chunks/chunk-GEX7RVHY.js +0 -5
  203. package/dist-cli/chunks/chunk-H4MYYOYJ.js +0 -5
  204. package/dist-cli/chunks/chunk-HEV7BAPE.js +0 -11
  205. package/dist-cli/chunks/chunk-HNDWYCND.js +0 -506
  206. package/dist-cli/chunks/chunk-HNPHODBD.js +0 -4
  207. package/dist-cli/chunks/chunk-HWDVC6YA.js +0 -11
  208. package/dist-cli/chunks/chunk-JOHJZUGG.js +0 -4
  209. package/dist-cli/chunks/chunk-JWUDT4QK.js +0 -5
  210. package/dist-cli/chunks/chunk-K7QQWKGE.js +0 -4
  211. package/dist-cli/chunks/chunk-LAOKTKT4.js +0 -4
  212. package/dist-cli/chunks/chunk-LD7I266X.js +0 -24
  213. package/dist-cli/chunks/chunk-LMHBU5LZ.js +0 -4
  214. package/dist-cli/chunks/chunk-LSOGXSDV.js +0 -535
  215. package/dist-cli/chunks/chunk-MP2GPO4T.js +0 -4
  216. package/dist-cli/chunks/chunk-MXJ2UWRV.js +0 -4
  217. package/dist-cli/chunks/chunk-OJNKRIZF.js +0 -15
  218. package/dist-cli/chunks/chunk-PBOWUNXO.js +0 -4
  219. package/dist-cli/chunks/chunk-PNRJFHX4.js +0 -4
  220. package/dist-cli/chunks/chunk-QJQOK34O.js +0 -28
  221. package/dist-cli/chunks/chunk-RLCQLMFF.js +0 -142
  222. package/dist-cli/chunks/chunk-S65CK3RI.js +0 -9
  223. package/dist-cli/chunks/chunk-SWBUNMQS.js +0 -4
  224. package/dist-cli/chunks/chunk-SXBFGGAM.js +0 -4
  225. package/dist-cli/chunks/chunk-T4ISWS5H.js +0 -4
  226. package/dist-cli/chunks/chunk-TPPVAA7Z.js +0 -5
  227. package/dist-cli/chunks/chunk-USM3P74H.js +0 -4
  228. package/dist-cli/chunks/chunk-V4EJJHF5.js +0 -4
  229. package/dist-cli/chunks/chunk-V7RGRZOL.js +0 -423
  230. package/dist-cli/chunks/chunk-XUBV77WH.js +0 -130
  231. package/dist-cli/chunks/chunk-XYSDYGKC.js +0 -4
  232. package/dist-cli/chunks/chunk-YNHRSDVG.js +0 -5
  233. package/dist-cli/chunks/chunk-YX52RJKO.js +0 -4
  234. package/dist-cli/chunks/chunk-Z5O5H4O7.js +0 -99
  235. package/dist-cli/chunks/chunk-Z6LOIW46.js +0 -7
  236. package/dist-cli/chunks/chunk-ZXFVBYJY.js +0 -5
  237. package/dist-cli/chunks/cleanup-KPUW4SFK.js +0 -25
  238. package/dist-cli/chunks/cli-version-APGT6GAT.js +0 -4
  239. package/dist-cli/chunks/compat-XXRFD2TW.js +0 -23
  240. package/dist-cli/chunks/config-DDMFDQ7F.js +0 -13
  241. package/dist-cli/chunks/connect-IPG47YXM.js +0 -4
  242. package/dist-cli/chunks/control-O22Z3UJ5.js +0 -4
  243. package/dist-cli/chunks/daemon-PADUIMJV.js +0 -4
  244. package/dist-cli/chunks/debug-MYIP46TM.js +0 -200
  245. package/dist-cli/chunks/desktop-ENFFBQAA.js +0 -31
  246. package/dist-cli/chunks/detox-J5WVK6OH.js +0 -52
  247. package/dist-cli/chunks/device-RAVQVL75.js +0 -18
  248. package/dist-cli/chunks/diagnose-PJMPXKJY.js +0 -43
  249. package/dist-cli/chunks/disk-cleanup-YLAY445J.js +0 -4
  250. package/dist-cli/chunks/do-chain-UBE7GIOU.js +0 -5
  251. package/dist-cli/chunks/drivers-ZFNX3T5Z.js +0 -4
  252. package/dist-cli/chunks/env-Y5XJSNRD.js +0 -4
  253. package/dist-cli/chunks/film-W3V6VURB.js +0 -74
  254. package/dist-cli/chunks/flow-VMLI7BYM.js +0 -4
  255. package/dist-cli/chunks/help-PKZCWHJJ.js +0 -4
  256. package/dist-cli/chunks/hidden-runtime-alias-S5DJ7EDF.js +0 -4
  257. package/dist-cli/chunks/home-paths-5O4IZPYV.js +0 -4
  258. package/dist-cli/chunks/inspect-LT4MXK37.js +0 -4
  259. package/dist-cli/chunks/install-desktop-EXCFMXFS.js +0 -4
  260. package/dist-cli/chunks/login-V6TZ54ZH.js +0 -26
  261. package/dist-cli/chunks/logout-SPMLFWYA.js +0 -4
  262. package/dist-cli/chunks/maestro-5ISTBAZE.js +0 -108
  263. package/dist-cli/chunks/maestro-generate-WUI64NHR.js +0 -36
  264. package/dist-cli/chunks/mode-QPNBYXUF.js +0 -26
  265. package/dist-cli/chunks/optional-demo-registry-CBSYF4CG.js +0 -4
  266. package/dist-cli/chunks/perf-T6N5PVYV.js +0 -48
  267. package/dist-cli/chunks/permissions-YZ7RRSZJ.js +0 -13
  268. package/dist-cli/chunks/platform-XDQAA72X.js +0 -6
  269. package/dist-cli/chunks/privacy-54FIGXLT.js +0 -4
  270. package/dist-cli/chunks/record-QGYXRUKP.js +0 -72
  271. package/dist-cli/chunks/report-issue-VUUTGX7V.js +0 -29
  272. package/dist-cli/chunks/reset-CGO52KBW.js +0 -4
  273. package/dist-cli/chunks/resolve-target-NNQCALDM.js +0 -4
  274. package/dist-cli/chunks/runtime-4EP6YJVL.js +0 -4
  275. package/dist-cli/chunks/screenshot-command-NZCMSJ4P.js +0 -159
  276. package/dist-cli/chunks/screenshot-layers-VMTQ6XIU.js +0 -20
  277. package/dist-cli/chunks/screenshots-capture-K3MWIDBK.js +0 -42
  278. package/dist-cli/chunks/serve-QJRIB2BV.js +0 -56
  279. package/dist-cli/chunks/setup-6XXEJQVF.js +0 -4
  280. package/dist-cli/chunks/sim-client-5YUVL45C.js +0 -4
  281. package/dist-cli/chunks/skills-T3CS7CXK.js +0 -50
  282. package/dist-cli/chunks/state-AJC3VK3G.js +0 -14
  283. package/dist-cli/chunks/storage-KVGZKC3Y.js +0 -37
  284. package/dist-cli/chunks/store-AWUMOQUH.js +0 -4
  285. package/dist-cli/chunks/telemetry-W5ZDGWK6.js +0 -4
  286. package/dist-cli/chunks/timeline-DXDCAZUA.js +0 -24
  287. package/dist-cli/chunks/upgrade-SRPTJACU.js +0 -7
  288. package/dist-cli/chunks/upload-ZDV4BFED.js +0 -4
  289. package/dist-cli/chunks/version-SOLPSBMG.js +0 -6
  290. package/dist-cli/chunks/web-RT75LD7A.js +0 -4
  291. package/dist-cli/chunks/welcome-IJ55EC7U.js +0 -5
  292. package/dist-cli/chunks/what-happened-CEIWJIWK.js +0 -25
  293. package/dist-cli/chunks/ws-bridge-YK5R3HOI.js +0 -4
  294. package/scripts/postinstall.cjs +0 -3
  295. package/scripts/preuninstall.cjs +0 -118
@@ -1,423 +0,0 @@
1
- /*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import { createRequire as __sootsimCreateRequire } from 'node:module'
3
- var require = __sootsimCreateRequire(import.meta.url)
4
- async function p({bridge:t,simId:a,maxMs:n,pollMs:s=50,stablePolls:o=3,strict:i=!1}){let c=await t.send({type:"evaluate",simId:a,code:`(async () => {
5
- const start = Date.now()
6
- const deadline = start + ${Math.max(0,Math.round(n))}
7
- const pollMs = ${Math.max(1,Math.round(s))}
8
- const requiredStablePolls = ${Math.max(1,Math.round(o))}
9
- const strict = ${i?"true":"false"}
10
- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
11
-
12
- // route-aware settle: a tap that pushes/pops a screen is async \u2014 the
13
- // old screen still renders for a moment, then the new one mounts and
14
- // its content loads. a pure layout-hash check reports "idle" on the
15
- // outgoing screen or on the incoming skeleton, so a driver re-taps
16
- // and stacks duplicate navigations. drain any in-flight screen
17
- // transition FIRST, bounded by the overall budget. when no
18
- // transition is happening this returns in ~80ms (startWindowMs), so
19
- // a plain button tap barely pays for it.
20
- try {
21
- const wfst = window.__sootsimTest?.waitForScreenTransitions
22
- if (typeof wfst === 'function') {
23
- const remaining = deadline - Date.now()
24
- if (remaining > 120) {
25
- await wfst({
26
- timeoutMs: Math.min(remaining - 80, 4000),
27
- settleMs: 64,
28
- startWindowMs: 80,
29
- })
30
- }
31
- }
32
- } catch {}
33
-
34
- const readSnapshot = async () => {
35
- let animating = false
36
- let layoutDirty = false
37
- let pendingFetches = 0
38
- let requestTotal = 0
39
- let requestInFlight = 0
40
- let renderStatsAvailable = false
41
- try {
42
- const stats = await window.__sootsimRenderHost?.queryStats?.()
43
- if (stats) {
44
- renderStatsAvailable = true
45
- animating =
46
- stats.hasActiveAnims === true ||
47
- stats.hasActiveNativeAnimations === true ||
48
- stats.hasPendingAnimationFrames === true
49
- layoutDirty =
50
- stats.layoutDirty === true && stats.renderRequested === true
51
- // a freshly-pushed screen showing a skeleton is layout-stable
52
- // but not actually settled \u2014 its data/images are still in
53
- // flight. treat bounded image-loader fetches as not-idle so
54
- // settle waits for real content, capped by the budget.
55
- const pf = stats.memory && stats.memory.imageLoader
56
- ? stats.memory.imageLoader.pendingFetches
57
- : 0
58
- pendingFetches = typeof pf === 'number' ? pf : 0
59
- }
60
- } catch {}
61
- try {
62
- const counts = await window.__sootsimTest?.getRequestCounts?.()
63
- requestTotal = typeof counts?.total === 'number' ? counts.total : 0
64
- requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight : 0
65
- } catch {}
66
- const root = window.__sootsimRoot
67
- const nodes = []
68
- if (root) {
69
- const walk = (n) => {
70
- if (n.layout && n.layout.width > 0) {
71
- nodes.push(Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width))
72
- }
73
- for (const c of n.children || []) walk(c)
74
- }
75
- walk(root)
76
- }
77
- return { layout: nodes.join(';'), animating, layoutDirty, pendingFetches, renderStatsAvailable, requestTotal, requestInFlight }
78
- }
79
-
80
- // how long generic background network is allowed to keep us waiting AFTER
81
- // the screen is otherwise visually settled. apps with continuous traffic
82
- // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
83
- // requestInFlight===0 / a stable requestTotal, so requiring full network
84
- // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
85
- // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
86
- // layout-stability + the image-loader already prove visible content
87
- // loaded (a data load changes layout; an image load shows in the loader),
88
- // so the generic request counters are a courtesy, not a gate: honor them
89
- // only within this grace once the screen is visually still.
90
- const networkQuietGraceMs = 1200
91
- let lastLayout = ''
92
- let lastRequestTotal = -1
93
- let stable = 0
94
- let visuallyStillSince = 0
95
- while (Date.now() < deadline) {
96
- const snapshot = await readSnapshot()
97
- const strictOk =
98
- !strict ||
99
- (snapshot.renderStatsAvailable && !snapshot.animating && !snapshot.layoutDirty)
100
- // visually settled: no animations, no image content loading, layout
101
- // unchanged since the last poll.
102
- const visuallyStill =
103
- strictOk && snapshot.pendingFetches === 0 && snapshot.layout === lastLayout
104
- // generic network quiet: nothing in flight and no new requests issued.
105
- const networkQuiet =
106
- snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
107
- if (visuallyStill) {
108
- stable++
109
- if (visuallyStillSince === 0) visuallyStillSince = Date.now()
110
- // settle once the screen has held still long enough AND either the
111
- // network is genuinely quiet OR it has refused to quiet within the
112
- // grace (continuous background traffic must not block forever).
113
- if (
114
- stable >= requiredStablePolls &&
115
- (networkQuiet || Date.now() - visuallyStillSince >= networkQuietGraceMs)
116
- ) {
117
- return { settled: true, elapsed: Date.now() - start }
118
- }
119
- } else {
120
- stable = 0
121
- visuallyStillSince = 0
122
- }
123
- lastLayout = snapshot.layout
124
- lastRequestTotal = snapshot.requestTotal
125
- await sleep(pollMs)
126
- }
127
- return { settled: false, elapsed: Date.now() - start }
128
- })()`},{timeoutMs:n+1e3}),{elapsed:r,settled:e}=c??{};return{elapsed:typeof r=="number"?r:n,settled:e===!0}}var g=`(() => {
129
- const spec = window.SootSim?.state?.engineSnapshot?.windowState?.deviceSpec
130
- return spec && spec.width > 0 && spec.height > 0
131
- ? { width: spec.width, height: spec.height }
132
- : null
133
- })()`,m={initialWaitMs:3e3,deadlineMs:5e3,retryWaitMs:700},b={initialWaitMs:1200,deadlineMs:2500,retryWaitMs:700};function T(t,a={}){return{...t?m:b,...a}}function x(t){return!(!t||t.hit===!1||t.ok===!1||t.requestedTargetMatched===!1||t.pointerTapHandled===!1&&!t.keyboardOpened&&!t.isTextInput)}function I(t,a){return{nodeId:t.target?.nodeId??t.match?.nodeId??t.node?.nodeId??null,id:t.target?.id??t.match?.id??t.node?.id??null,testID:t.target?.testID??t.match?.testID??t.node?.testID??null,text:t.target?.text??t.target?.accessibilityLabel??t.match?.text??t.match?.accessibilityLabel??t.node?.text??a??null,type:t.target?.type??t.match?.type??t.node?.type??null}}async function h(t,a){let n=T(!!a.agent,a.timing),s=0,o=null,i=null;try{await p({bridge:t,maxMs:n.initialWaitMs,pollMs:32,stablePolls:2})}catch{}let c=Date.now()+n.deadlineMs,r=null;for(;Date.now()<=c||s===0;){s++;let e=await a.resolve();if(o=e,e?.error==="bridge-not-ready"||e?.ambiguous||e?.nthOutOfRange)return{payload:e,result:null,attempts:s,failure:"special"};if(e&&typeof e.cx=="number"&&typeof e.cy=="number")if(e.offscreen){i={hit:!1,reason:"offscreen",x:e.cx,y:e.cy,screen:e.screen};let d=`${Math.round(e.cx)},${Math.round(e.cy)}`;if(r===d)return{payload:e,result:i,attempts:s,failure:"missed"};r=d}else{r=null;let d=I(e,a.textFallback),l=await t.send({type:"evaluate",code:`(async () => {
134
- const t = window.__sootsimTest
135
- if (
136
- !t ||
137
- typeof t.inspectAt !== 'function' ||
138
- typeof t.resolveTapTarget !== 'function'
139
- ) {
140
- return { error: 'tap-target-inspection-unavailable' }
141
- }
142
- const requestedTarget = ${JSON.stringify(d)}
143
- const inspected = await t.inspectAt(${e.cx}, ${e.cy})
144
- const resolved =
145
- inspected && typeof inspected.nodeId === 'number'
146
- ? await t.resolveTapTarget(inspected.nodeId)
147
- : null
148
- const node = (resolved && resolved.target) || inspected
149
- const coordinateTarget = node
150
- ? {
151
- nodeId: node.nodeId ?? null,
152
- id: node.id ?? null,
153
- testID: node.testID ?? null,
154
- text: node.text ?? node.accessibilityLabel ?? null,
155
- type: node.type ?? null,
156
- }
157
- : null
158
- const coordinateAncestors = Array.isArray(inspected?.ancestors)
159
- ? inspected.ancestors
160
- : []
161
- const ancestorMatchesRequested = coordinateAncestors.some(
162
- (ancestor) =>
163
- (typeof requestedTarget.nodeId === 'number' &&
164
- ancestor?.nodeId === requestedTarget.nodeId) ||
165
- (requestedTarget.testID &&
166
- ancestor?.testID === requestedTarget.testID) ||
167
- (requestedTarget.id && ancestor?.id === requestedTarget.id),
168
- )
169
- const requestedTargetMatched =
170
- coordinateTarget === null
171
- ? false
172
- : typeof requestedTarget.nodeId === 'number' &&
173
- typeof coordinateTarget.nodeId === 'number'
174
- ? requestedTarget.nodeId === coordinateTarget.nodeId ||
175
- ancestorMatchesRequested
176
- : requestedTarget.testID && coordinateTarget.testID
177
- ? requestedTarget.testID === coordinateTarget.testID
178
- || ancestorMatchesRequested
179
- : requestedTarget.id && coordinateTarget.id
180
- ? requestedTarget.id === coordinateTarget.id
181
- || ancestorMatchesRequested
182
- : ancestorMatchesRequested
183
- if (!requestedTargetMatched) {
184
- return {
185
- requestedTargetMatched,
186
- requestedTarget,
187
- coordinateTarget,
188
- }
189
- }
190
- if (typeof t.activatePressAt !== 'function') {
191
- return { error: 'tap-target-activation-unavailable' }
192
- }
193
- const activation = await t.activatePressAt(
194
- ${e.cx},
195
- ${e.cy},
196
- requestedTarget.nodeId,
197
- )
198
- if (activation?.ok) {
199
- window.dispatchEvent(
200
- new CustomEvent('sootsim:agentAction', {
201
- detail: {
202
- type: 'tap',
203
- x: ${e.cx},
204
- y: ${e.cy},
205
- target: requestedTarget,
206
- },
207
- }),
208
- )
209
- }
210
- return {
211
- activation,
212
- requestedTargetMatched,
213
- requestedTarget,
214
- coordinateTarget,
215
- }
216
- })()`});if(l?.error)return{payload:e,result:{hit:!1,reason:l.error,requestedTarget:d},attempts:s,failure:"special"};if(l?.requestedTargetMatched===!1)return{payload:e,result:{hit:!1,reason:"target-covered",...l},attempts:s,failure:"missed"};let y=l?.activation?.tap??l?.activation,f=y&&typeof y=="object"?{...y,...l?.activation,...l}:{hit:!!y,...l};if(i=f,x(f))return{payload:e,result:f,attempts:s}}let u=c-Date.now();if(u<=0)break;try{await p({bridge:t,maxMs:Math.min(u,n.retryWaitMs),pollMs:32,stablePolls:2})}catch{await new Promise(d=>setTimeout(d,Math.min(120,u)))}}return{payload:o,result:i,attempts:s,failure:o&&typeof o.cx=="number"?"missed":"not-found"}}async function F(t,a,n,s){return t.send({type:"tap",x:a,y:n,...s?{target:s}:{}})}async function q(t,a,n={}){let s=JSON.stringify(a);return h(t,{agent:n.agent,timing:n.timing,resolve:()=>t.send({type:"evaluate",code:`(async () => {
217
- const t = window.__sootsimTest
218
- if (!t) return null
219
- const n = (await t.findByTestId(${s})) || (await t.findById(${s}))
220
- if (!n || !n.absolutePosition || !n.layout) return { cx: null }
221
- const resolved =
222
- typeof n.nodeId === 'number' && typeof t.resolveTapTarget === 'function'
223
- ? await t.resolveTapTarget(n.nodeId)
224
- : null
225
- const target = (resolved && resolved.target) || n
226
- const cx =
227
- resolved && typeof resolved.cx === 'number'
228
- ? resolved.cx
229
- : n.absolutePosition.x + (n.layout.width || 0) / 2
230
- const cy =
231
- resolved && typeof resolved.cy === 'number'
232
- ? resolved.cy
233
- : n.absolutePosition.y + (n.layout.height || 0) / 2
234
- const scr = ${g}
235
- const offscreen =
236
- !!scr && (cx < 0 || cy < 0 || cx > scr.width || cy > scr.height)
237
- return {
238
- cx,
239
- cy,
240
- ...(offscreen ? { offscreen: true, screen: scr } : {}),
241
- match: {
242
- nodeId: n.nodeId ?? null,
243
- id: n.id,
244
- testID: n.testID,
245
- text: n.text ?? n.accessibilityLabel ?? null,
246
- type: n.type,
247
- },
248
- target: {
249
- nodeId: target.nodeId ?? null,
250
- id: target.id,
251
- testID: target.testID,
252
- text:
253
- target.text ??
254
- target.accessibilityLabel ??
255
- n.text ??
256
- n.accessibilityLabel ??
257
- null,
258
- type: target.type,
259
- },
260
- strategy: (resolved && resolved.strategy) || 'matched-node',
261
- }
262
- })()`})})}async function M(t,a,n={},s={}){let o=JSON.stringify({query:a,exact:!!n.exact,role:n.role??null,within:n.within??null,minX:n.minX??null,maxX:n.maxX??null,minY:n.minY??null,maxY:n.maxY??null,near:n.near??null,nth:n.nth??null,first:!!n.first});return h(t,{agent:s.agent,timing:s.timing,textFallback:a,resolve:()=>t.send({type:"evaluate",code:`(async () => {
263
- const t = window.__sootsimTest
264
- if (!t) return { error: 'bridge-not-ready' }
265
- const F = ${o}
266
-
267
- const res = await t.queryTextCandidates({
268
- query: F.query,
269
- exact: !!F.exact,
270
- ...(F.role ? { role: F.role } : {}),
271
- })
272
-
273
- let candidates = res.candidates || []
274
-
275
- candidates = candidates.filter((c) => {
276
- const ax = c.info.absolutePosition && c.info.absolutePosition.x
277
- const ay = c.info.absolutePosition && c.info.absolutePosition.y
278
- if (F.minX !== null && !(ax >= F.minX)) return false
279
- if (F.maxX !== null && !(ax <= F.maxX)) return false
280
- if (F.minY !== null && !(ay >= F.minY)) return false
281
- if (F.maxY !== null && !(ay <= F.maxY)) return false
282
- if (F.within && !c.ancestorTestIDs.includes(F.within)) return false
283
- return true
284
- })
285
-
286
- if (F.near) {
287
- candidates.sort((a, b) => {
288
- const ax = (a.info.absolutePosition && a.info.absolutePosition.x) || 0
289
- const ay = (a.info.absolutePosition && a.info.absolutePosition.y) || 0
290
- const bx = (b.info.absolutePosition && b.info.absolutePosition.x) || 0
291
- const by = (b.info.absolutePosition && b.info.absolutePosition.y) || 0
292
- return (
293
- Math.hypot(ax - F.near.x, ay - F.near.y) -
294
- Math.hypot(bx - F.near.x, by - F.near.y)
295
- )
296
- })
297
- } else {
298
- candidates.sort((a, b) => {
299
- const ay = (a.info.absolutePosition && a.info.absolutePosition.y) || 0
300
- const by = (b.info.absolutePosition && b.info.absolutePosition.y) || 0
301
- if (Math.abs(ay - by) > 2) return ay - by
302
- const ax = (a.info.absolutePosition && a.info.absolutePosition.x) || 0
303
- const bx = (b.info.absolutePosition && b.info.absolutePosition.x) || 0
304
- return ax - bx
305
- })
306
- }
307
-
308
- const total = candidates.length
309
- if (total === 0) return { matched: 0, total: 0 }
310
-
311
- let idx = 0
312
- if (F.nth !== null) {
313
- idx = F.nth < 0 ? total + F.nth : F.nth
314
- if (idx < 0 || idx >= total) {
315
- return { matched: 0, total, nthOutOfRange: true, nth: F.nth }
316
- }
317
- } else if (total > 1 && !F.first && !F.near) {
318
- return {
319
- ambiguous: true,
320
- total,
321
- candidates: candidates.slice(0, 10).map((c, i) => ({
322
- idx: i,
323
- nodeId: c.info.nodeId,
324
- type: c.info.type,
325
- testID: c.info.testID,
326
- text: (c.info.text || '').slice(0, 60),
327
- abs: c.info.absolutePosition,
328
- layout: c.info.layout
329
- ? {
330
- width: Math.round(c.info.layout.width || 0),
331
- height: Math.round(c.info.layout.height || 0),
332
- }
333
- : null,
334
- ancestorTestIDs: (c.ancestorTestIDs || []).slice(0, 5),
335
- })),
336
- }
337
- }
338
-
339
- const picked = candidates[idx]
340
- const n = picked.info
341
- if (!n.absolutePosition || !n.layout) return { matched: 0, total }
342
-
343
- const resolved =
344
- typeof n.nodeId === 'number' &&
345
- typeof t.resolveTapTarget === 'function'
346
- ? await t.resolveTapTarget(n.nodeId)
347
- : null
348
- const target = (resolved && resolved.target) || n
349
- const cx =
350
- resolved && typeof resolved.cx === 'number'
351
- ? resolved.cx
352
- : n.absolutePosition.x + (n.layout.width || 0) / 2
353
- const cy =
354
- resolved && typeof resolved.cy === 'number'
355
- ? resolved.cy
356
- : n.absolutePosition.y + (n.layout.height || 0) / 2
357
- const scr = ${g}
358
- const offscreen =
359
- !!scr && (cx < 0 || cy < 0 || cx > scr.width || cy > scr.height)
360
- return {
361
- cx,
362
- cy,
363
- ...(offscreen ? { offscreen: true, screen: scr } : {}),
364
- match: {
365
- nodeId: n.nodeId ?? null,
366
- id: n.id,
367
- testID: n.testID,
368
- type: n.type,
369
- },
370
- target: {
371
- nodeId: target.nodeId ?? null,
372
- id: target.id,
373
- testID: target.testID,
374
- text:
375
- target.text ??
376
- target.accessibilityLabel ??
377
- n.text ??
378
- n.accessibilityLabel ??
379
- null,
380
- type: target.type,
381
- },
382
- strategy: (resolved && resolved.strategy) || 'matched-node',
383
- total,
384
- idx,
385
- }
386
- })()`})})}async function P(t,a,n={}){let s=JSON.stringify(a);return h(t,{agent:n.agent,timing:n.timing,textFallback:a,resolve:async()=>{let o=await t.send({type:"evaluate",code:`(async () => {
387
- const t = window.__sootsimTest
388
- if (!t) return { error: 'bridge-not-ready' }
389
- const byTestId =
390
- (await t.findByTestId(${s})) || (await t.findById(${s}))
391
- if (byTestId && byTestId.absolutePosition && byTestId.layout) {
392
- return {
393
- strategy: 'testid',
394
- node: {
395
- nodeId: byTestId.nodeId ?? null,
396
- id: byTestId.id,
397
- testID: byTestId.testID,
398
- type: byTestId.type,
399
- text: byTestId.text,
400
- absolutePosition: byTestId.absolutePosition,
401
- layout: byTestId.layout,
402
- },
403
- screen: ${g},
404
- }
405
- }
406
- const byText = await t.findByText(${s})
407
- if (byText && byText.absolutePosition && byText.layout) {
408
- return {
409
- strategy: 'text',
410
- node: {
411
- nodeId: byText.nodeId ?? null,
412
- id: byText.id,
413
- testID: byText.testID,
414
- type: byText.type,
415
- text: byText.text,
416
- absolutePosition: byText.absolutePosition,
417
- layout: byText.layout,
418
- },
419
- screen: ${g},
420
- }
421
- }
422
- return { strategy: 'none' }
423
- })()`});if(!o||!("node"in o))return o;let i=o.node,c=i.absolutePosition.x+i.layout.width/2,r=i.absolutePosition.y+i.layout.height/2,e=o.screen??null,u=!!e&&(c<0||r<0||c>e.width||r>e.height);return{...o,cx:c,cy:r,...u?{offscreen:!0,screen:e}:{},target:{id:i.id,testID:i.testID,text:o.strategy==="text"?a:i.text,type:i.type}}}})}export{p as a,x as b,h as c,F as d,q as e,M as f,P as g};