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,497 +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
- import{b as Ht,c as Kt}from"./chunk-MXJ2UWRV.js";import{a as Jt,b as qt}from"./chunk-CCMZSHJB.js";import{a as ce}from"./chunk-RLCQLMFF.js";import{a as ne,b as ye,c as Bt,d as Ct,e as Dt,f as Lt,g as Wt}from"./chunk-V7RGRZOL.js";import{a as he,b as Fe}from"./chunk-YX52RJKO.js";import{j as jt}from"./chunk-EWPAI4MO.js";import{a as Z,b as D,c as C,d as Ie,e as oe,f as G,g as me,h as ge,i as At,j as Pt,k as Me,l as _t}from"./chunk-2BRBFLWA.js";import{C as Et,E as Ot,G as ue,H as Rt,N as We,a as Se,b as pt,c as ke,d as ft,e as gt,f as yt,g as ht,h as bt,i as wt,j as $t,k as xt,l as ve,m as Be,n as Ce,o as De,p as St,q as kt,r as fe,s as vt,t as Ne,u as Le,v as Nt,w as It,x as Mt,y as Ft,z as Tt}from"./chunk-5PZVYF42.js";import{a as X}from"./chunk-ZXFVBYJY.js";import{e as it,j as at,r as lt,t as ct,v as dt,w as ut,x as mt,y as le}from"./chunk-7NCPUZ52.js";import{a as ot}from"./chunk-4CEZZKRY.js";import{b as st,c as y}from"./chunk-T4ISWS5H.js";import{c as nt,d as je,f as rt}from"./chunk-XUBV77WH.js";import{a as de}from"./chunk-LMHBU5LZ.js";function Je(e){return`(async () => {
5
- const bridge = globalThis.SootSim && globalThis.SootSim.bridges && globalThis.SootSim.bridges.hotRemount
6
- if (!bridge || typeof bridge.reloadExternalApp !== 'function') return false
7
- await bridge.reloadExternalApp({ resetStorage: ${e?"true":"false"} })
8
- return true
9
- })()`}import{existsSync as Lo,mkdirSync as zt,readFileSync as Wo,rmSync as He,writeFileSync as Gt}from"fs";import{tmpdir as Jo}from"os";import{dirname as Yt,join as qo,resolve as Vt}from"path";import*as Te from"fs";function Do(e){let t={},r=e,l=m=>Array.isArray(m)?m:[],u=e.match(/^---\n([\s\S]*?)\n---\n?/);if(u){try{t=ce.parse(u[1])??{}}catch(b){console.warn(` warn: could not parse frontmatter: ${b.message}`)}r=e.slice(u[0].length);let m=ce.parse(r);return{frontmatter:t,steps:l(m)}}if(/\n---\s*\n/.test(e))try{let m=ce.parseAllDocuments(e);if(m.length>=2){let b=m[0].toJS(),$=m[m.length-1].toJS();return{frontmatter:b&&typeof b=="object"?b:{},steps:l($)}}}catch(m){console.warn(` warn: could not parse multi-doc flow: ${m.message}`)}let a=ce.parse(r);return{frontmatter:t,steps:l(a)}}var Ut=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function qe(e){let t=[];if(!Array.isArray(e)||e.length===0)return t.push("flow body must be a non-empty YAML array of steps"),t;let r=0;for(let l of e)l&&typeof l=="object"?Object.keys(l).some(a=>Ut.has(a))&&(r+=1):typeof l=="string"&&Ut.has(l)&&(r+=1);return r===0&&t.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),t}function Ts(e){if(!Te.existsSync(e))return[`file not found: ${e}`];let t;try{t=Te.readFileSync(e,"utf8")}catch(r){return[`cannot read file: ${r.message}`]}if(t.trim().length===0)return["file is empty"];try{let r=Do(t);return qe(r.steps)}catch(r){return[`yaml parse error: ${r.message}`]}}var Ke=1;function Ee(){return Vt(process.env.SOOTSIM_FLOW_SESSION_PATH||qo(Jo(),"sootsim-flow-session.json"))}function Ue(e){let t=Ee();zt(Yt(t),{recursive:!0}),Gt(t,JSON.stringify(e,null,2)+`
10
- `)}function ze(){let e=Ee();if(!Lo(e))return null;try{let t=JSON.parse(Wo(e,"utf8"));return t.version!==Ke||!Array.isArray(t.steps)||typeof t.startedAt!="string"||typeof t.updatedAt!="string"?(He(e,{force:!0}),null):{version:Ke,startedAt:t.startedAt,updatedAt:t.updatedAt,steps:t.steps,candidate:t.candidate??null}}catch{return He(e,{force:!0}),null}}function js(){let e=new Date().toISOString(),t={version:Ke,startedAt:e,updatedAt:e,steps:[],candidate:null};return Ue(t),{path:Ee(),state:t}}function Ho(){He(Ee(),{force:!0})}function Bs(){Ho()}function Oe(e){let t=ze();if(!t)return{active:!1};let r=t.candidate,l={...t,updatedAt:new Date().toISOString(),candidate:{step:e.step,summary:e.summary,source:e.source,recordedAt:new Date().toISOString()}};return Ue(l),{active:!0,candidate:l.candidate,replaced:r}}function Cs(){let e=ze();if(!e)return{active:!1,kept:!1,reason:"no-session"};if(!e.candidate)return{active:!0,kept:!1,reason:"no-candidate"};let t=e.candidate,r={...e,updatedAt:new Date().toISOString(),steps:[...e.steps,t.step],candidate:null};return Ue(r),{active:!0,kept:!0,candidate:t,stepCount:r.steps.length}}function Ko(e){return ce.stringify(e).trimEnd()+`
11
- `}function Ds(e){let t=ze();if(!t)return{active:!1};let r=Ko(t.steps),l=qe(t.steps);if(l.length>0)return{active:!0,valid:!1,issues:l,yaml:r,stepCount:t.steps.length,outputPath:null};let u=null;return e&&(u=Vt(e),zt(Yt(u),{recursive:!0}),Gt(u,r)),{active:!0,valid:!0,issues:[],yaml:r,stepCount:t.steps.length,outputPath:u}}import{existsSync as Uo,mkdirSync as zo,readFileSync as Go,rmSync as Xt,writeFileSync as Yo}from"fs";import{tmpdir as Vo}from"os";import{dirname as Xo,join as Qo,resolve as Zo}from"path";var be=1,es="SOOTSIM_INSPECT_NOTICE_PATH",ts=300*1e3,os=15e3;function Qt(){return Zo(process.env[es]||Qo(Vo(),"sootsim-inspect-notice-state.json"))}function ss(e,t){return Object.fromEntries(Object.entries(e).filter(([,r])=>typeof r?.signature=="string"&&Number.isFinite(r?.updatedAt)&&t-r.updatedAt<=ts))}function ns(e){let t=Qt();if(!Uo(t))return{version:be,entries:{}};try{let r=JSON.parse(Go(t,"utf8"));return r.version!==be||!r.entries||typeof r.entries!="object"?(Xt(t,{force:!0}),{version:be,entries:{}}):{version:be,entries:ss(r.entries,e)}}catch{return Xt(t,{force:!0}),{version:be,entries:{}}}}function rs(e){let t=Qt();zo(Xo(t),{recursive:!0}),Yo(t,JSON.stringify(e,null,2)+`
12
- `)}function is(e,t){let r=t.trim()||"default";return`${e}:${r}`}function Ge(e,t,r,l={}){let u=l.nowMs??Date.now(),a=l.cooldownMs??os,m=ns(u),b=is(e,t),$=m.entries[b];return $&&$.signature===r&&u-$.updatedAt<a?!1:(m.entries[b]={signature:r,updatedAt:u},rs(m),!0)}async function Zt(e,t={args:[]}){let r=await ke(e);if(D(t.args)){C(r);return}console.log(` nodes: ${r.nodes}`)}function Ye(e,t){let r=e.indexOf(t);return r>=0&&r+1<e.length?e[r+1]:null}async function eo(e){let{bridge:t,args:r,positional:l}=e,u=r.includes("--verbose")||r.includes("-v"),a=D(r),m=u&&!a,b=r.includes("--watch")||r.includes("-w"),$=1e3,M=r.includes("--compact"),w=r.includes("--no-xy"),h=Ye(r,"--testid-like"),T=Ye(r,"--only"),x=Ye(r,"--subtree"),P=l[1]&&!l[1].startsWith("-")?l[1]:void 0,O=P?/[*?]/.test(P):!1,c=!O&&!T?P:void 0,j=T??(O?P:void 0),A=async()=>{await me(t,{verbose:m});let H=await bt(t,{describe:!0,verbose:u,filter:c||"",testIdLike:h||void 0,onlyGlob:j||void 0,subtreeRoot:x||void 0,compact:M,hideXy:w,fullText:a}),W=H?.tree;if(a){C({tree:W??""});return}if(typeof W=="string"&&W.startsWith("__SUBTREE_NOT_FOUND__:")){let V=W.slice(22);console.log(` subtree root not found: ${V}`),X("subtree-root-not-found",V);return}if(!W){let V=H?.nodeCount??0;console.log(" no matching nodes found"),!(c||h||j||x)&&V<10&&X("app-still-loading",V);return}console.log(W);let F=c||h||j||x;(c||h||j)&&!b&&X("describe-filter-context"),!F&&!b&&W.split(`
13
- `).length>=80&&X("describe-use-filters")};if(b)for(console.log(` watching... (Ctrl+C to stop)
14
- `);;)console.clear(),await A(),await Z($);else await A()}async function to(e){let{bridge:t,args:r,effectiveArgs:l,positional:u,inspectUsage:a}=e,m=F=>{let _=l.indexOf(F);return _>=0&&_+1<l.length?l[_+1]:null},b=F=>l.includes(F),$=m("--testid")||m("--test-id"),M=m("--role"),w=m("--type"),h=m("--text"),T=b("--pressable"),x=b("--visible"),P=b("--interactive-targets")||b("--actions"),O=!$&&!M&&!w&&!h&&!T&&!x&&!P?u[1]:null,c=h??O,j=await ve(t,{testId:$,role:M,type:w,text:c,pressable:T,visible:x,interactive:P});j||(console.error(a("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),y(1));let{mode:A,result:B}=j,H=D(r),W=r.includes("--verbose")||r.includes("--dump");if(H)A==="interactive-targets"&&Array.isArray(B)?C(Be(B).map(F=>({...F,tap:Ce(F)}))):C(B??null);else if(Array.isArray(B))if(B.length===0){console.log(` no ${A} nodes found`);let{nodes:F}=await ke(t);F<10&&X("app-still-loading",F)}else if(A==="interactive-targets"){let F=Be(B);console.log(` found ${F.length} interactive target${F.length===1?"":"s"} (sorted by score):`);for(let _ of F.slice(0,20)){let V=_.absolutePosition?`@(${Math.round(_.absolutePosition.x)},${Math.round(_.absolutePosition.y)})`:"",se=_.layout?`${Math.round(_.layout.width)}x${Math.round(_.layout.height)}`:"?x?",re=_.text?` "${_.text.slice(0,30)}"`:"",ie=_.testID?` #${_.testID}`:"",ae=_.accessibilityLabel?` \u24D8"${String(_.accessibilityLabel).slice(0,24)}"`:"",_e=_.accessibilityRole?`[${_.accessibilityRole}]`:_.type,pe=Ce(_);console.log(` ${_e}${re}${ae}${ie} ${se} ${V}`),console.log(` \u2192 ${pe}`),W&&console.log(Ve(JSON.stringify(_,null,2)," "))}F.length>20&&console.log(` ... and ${F.length-20} more`)}else{console.log(` found ${B.length} node${B.length===1?"":"s"} (${A}):`);for(let F of B.slice(0,20)){let _=F.absolutePosition?`@(${Math.round(F.absolutePosition.x)},${Math.round(F.absolutePosition.y)})`:"",V=F.layout?`${Math.round(F.layout.width)}x${Math.round(F.layout.height)}`:"?x?",se=F.text?` "${F.text.slice(0,30)}"`:"",re=F.testID?` #${F.testID}`:"",ie=F.pressable?" (tap)":"",ae=F.accessibilityRole?`[${F.accessibilityRole}]`:F.type;console.log(` ${ae}${se}${re} ${V} ${_}${ie}`),W&&console.log(Ve(JSON.stringify(F,null,2)," "))}B.length>20&&console.log(` ... and ${B.length-20} more`)}else if(B==null)console.log(` not found: ${c||$||M||w||""||A}`),$&&X("wait-selector-for-missing-testid",$);else{let F=B;if(F.type&&F.absolutePosition){let _=`@(${Math.round(F.absolutePosition.x)},${Math.round(F.absolutePosition.y)})`,V=F.layout?`${Math.round(F.layout.width)}x${Math.round(F.layout.height)}`:"?x?",se=F.text?` "${F.text.slice(0,40)}"`:"",re=F.testID?` #${F.testID}`:"",ie=F.pressable?" (tap)":"",ae=F.accessibilityRole?`[${F.accessibilityRole}]`:F.type;console.log(` ${ae}${se}${re} ${V} ${_}${ie}`),W&&console.log(Ve(JSON.stringify(F,null,2)," "))}else console.log(JSON.stringify(B,null,2))}}function Ve(e,t){return e.split(`
15
- `).map(r=>t+r).join(`
16
- `)}async function oo(e){let{bridge:t,args:r}=e,l=D(r);await me(t,{verbose:!l});let u=r.includes("--styling"),a=r.indexOf("--filter"),m=a>=0?r[a+1]:void 0,b=await wt(t,{styling:u,filter:m}).catch($=>{throw u&&$ instanceof Error&&$.message==="unsupported RNX Cloud command type: evaluate"?new Error("get layout --styling is unavailable in RNX Cloud; rerun without --styling or use a local sim"):$});if(l){C({count:b.length,elements:b});return}console.log(` layout (${b.length} element${b.length===1?"":"s"}):
17
- `),console.log($t(b,{styling:u}))}async function so(e,t={}){let r=await Ot(e);if("error"in r&&(console.error(r.error),y(1)),t.json){console.log(JSON.stringify(r,null,2));return}let{visible:l,spec:u,mode:a,shifted:m,capsLock:b,accessoryBarId:$}=r,M=[];M.push(`keyboard: ${l?"visible":"hidden"}`),u?(M.push(` type: ${u.keyboardType}`),M.push(` returnKey: ${u.returnKeyType}`),M.push(` autoCap: ${u.autoCapitalize}`),M.push(` autoCorrect: ${u.autoCorrect?"on":"off"}`),M.push(` appearance: ${u.keyboardAppearance}`),u.secureTextEntry&&M.push(" secureTextEntry: true"),u.enablesReturnKeyAutomatically&&M.push(` return: ${u.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):M.push(" spec: <none> (shown via dev-tools with no TextInput)"),M.push(` mode: ${a}${m?" (shifted)":""}${b?" (caps)":""}`),$&&M.push(` accessoryBar: ${$}`),console.log(M.join(`
18
- `))}async function no(e){let t=await e.bridge.listSims(),r=e.args.includes("--all"),l=e.args.find((b,$)=>e.args[$-1]==="--bundle"),u=e.args.find((b,$)=>e.args[$-1]==="--app-port"),a=e.args.includes("--primary"),m=t.filter(b=>!(a&&!b.isPrimary||l&&!(b.url??"").includes(l)||u&&!(b.url??"").includes(`/rn/${u}`)||!r&&!l&&!u&&!a&&!(b.url&&(b.url.includes("bundle=")||b.url.includes("/index.bundle")))&&b.id!==e.simId));if(D(e.args)){C(m.map(b=>({...b,active:b.id===e.simId})));return}jt(m,e.simId),m.length<t.length&&!D(e.args)&&console.log(` (${t.length-m.length} more hidden \u2014 pass --all to show)`)}function te(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function as(e,t){return t<=0?"?":`${(e/t*100).toFixed(0)}%`}function ls(e){let t={},r=(l,u)=>{u&&(u.nodesRegistered!=null&&(t[`${l}.nodes`]=u.nodesRegistered),u.nodesDetached!=null&&(t[`${l}.detached`]=u.nodesDetached),u.objects&&(t[`${l}.paragraphs`]=u.objects.paragraphs,t[`${l}.yogaNodes`]=u.objects.yogaNodes,t[`${l}.pictures`]=u.objects.pictures,t[`${l}.rasterImages`]=u.objects.rasterImages),u.imageLoader&&(t[`${l}.imageCacheEntries`]=u.imageLoader.cacheEntries,t[`${l}.imagePixelBytes`]=u.imageLoader.cachePixelBytes),u.workerHeap&&(t[`${l}.heapBytes`]=u.workerHeap.usedJSHeapSize),u.wasmHeapBytes!=null&&(t[`${l}.wasmHeapBytes`]=u.wasmHeapBytes))};return r("tenant",e.tenant),r("shell",e.shell),r("compositor",e.compositor),e.hostHeap&&(t["host.heapBytes"]=e.hostHeap.usedJSHeapSize),t}function ro(e,t){return e.endsWith("Bytes")?te(t):String(t)}function Xe(e,t){if(!t){console.log(` ${e}: not available`);return}let r=t.objects;if(console.log(` ${e}`),t.nodesRegistered!=null&&console.log(` nodes registered: ${t.nodesRegistered}`),t.nodesDetached!=null){let l=Object.entries(t.detachedTypes??{}).map(([u,a])=>`${u}:${a}`).join(" ");console.log(` nodes detached: ${t.nodesDetached}${l?` (${l})`:""}`)}if(r&&(console.log(` paragraphs: ${r.paragraphs}`),console.log(` yoga nodes: ${r.yogaNodes}`),console.log(` pictures: ${r.pictures}`),console.log(` raster images: ${r.rasterImages}`)),t.activeNativeAnimations!=null&&console.log(` native anims: ${t.activeNativeAnimations}`),t.imageLoader){let l=t.imageLoader;console.log(` image cache: ${l.cacheEntries}/${l.cacheMaxEntries} entries, ${te(l.cachePixelBytes)}/${te(l.cachePixelBudget)} (${as(l.cachePixelBytes,l.cachePixelBudget)})`)}t.workerHeap&&console.log(` js heap: ${te(t.workerHeap.usedJSHeapSize)} used / ${te(t.workerHeap.totalJSHeapSize)} total`),t.wasmHeapBytes!=null&&console.log(` canvaskit wasm: ${te(t.wasmHeapBytes)}`)}function cs(e){console.log(" memory:"),Xe("tenant worker",e.tenant),Xe("shell worker",e.shell),Xe("compositor worker",e.compositor),e.hostHeap?(console.log(" host"),console.log(` js heap: ${te(e.hostHeap.usedJSHeapSize)} used / ${te(e.hostHeap.totalJSHeapSize)} total`)):console.log(" host js heap: not available (chrome only)")}function ds(e,t,r){let l=e.indexOf(t);if(l===-1)return r;let u=Number(e[l+1]);return Number.isFinite(u)&&u>0?u:r}async function io(e,t={args:[]}){let r=D(t.args),l=t.args.indexOf("--watch");if(l===-1){let O=await We(e);if(r){C(O);return}cs(O);return}let u=Number(t.args[l+1]),a=Number.isFinite(u)&&u>0?u:60,m=ds(t.args,"--interval",5),b=[],$=Date.now(),M=null;for(r||console.log(` sampling every ${m}s for ${a}s \u2014 deltas per tick:`);;){let O=await We(e),c=(Date.now()-$)/1e3,j=ls(O);if(b.push({tSec:c,counters:j}),!r){let A=[];for(let[B,H]of Object.entries(j)){let W=M&&B in M?H-M[B]:null;if(W===null||W===0)continue;let F=W>0?"+":"-",_=B.endsWith("Bytes")?`${F}${te(Math.abs(W))}`:`${F}${Math.abs(W)}`;A.push(`${B} ${ro(B,H)} (${_})`)}console.log(` t+${c.toFixed(0)}s ${A.length?A.join(" "):M?"no change":Object.entries(j).map(([B,H])=>`${B} ${ro(B,H)}`).join(" ")}`)}if(M=j,c>=a)break;await new Promise(A=>setTimeout(A,m*1e3))}let w=b[0],h=b[b.length-1],T=Math.max(h.tSec-w.tSec,.001),x={};for(let O of Object.keys(h.counters))O in w.counters&&(x[O]=(h.counters[O]-w.counters[O])/T);if(r){C({samples:b,perSecond:x,elapsedSec:T});return}console.log(`
19
- slope over ${T.toFixed(0)}s:`);let P=Object.entries(x).filter(([,O])=>O!==0).sort((O,c)=>Math.abs(c[1])-Math.abs(O[1]));if(P.length===0){console.log(" all counters flat");return}for(let[O,c]of P){let j=O.endsWith("Bytes")?`${te(Math.abs(c))}/s${c<0?" (shrinking)":""}`:`${c>0?"+":""}${c.toFixed(2)}/s`;console.log(` ${O.padEnd(28)}${j}`)}}var Q="<redacted secure text>";function we(e){let t=e?.layout?.spec??e?.spec??null;return!!t?.secureTextEntry&&t.keyboardType!=="visible-password"}function Qe(e,t){return we(t)?Q:e}function Ze(e){if(!e||!we(e))return e;let t=e.focusedInput;return!t||typeof t!="object"?e:{...e,focusedInput:{...t,secureTextEntry:!0,text:typeof t.text=="string"?Q:t.text}}}async function ao(e,t={}){let{nav:r,route:l,keyboard:u,shell:a}=await Rt(e);if(t.json){console.log(JSON.stringify({shell:a??null,nav:r,route:l,keyboard:u},null,2));return}let m=[];if(a){let b=a.activeApp??a.state??"<none>",$=a.showSwitcher?" (app switcher open)":"",M=typeof a.launchProgress=="number"&&a.launchProgress<.98?` launching (${Math.round(a.launchProgress*100)}%)`:"";m.push(`shell: ${b}${$}${M}`)}else m.push("shell: <unavailable>");if(r){let b=r.transitionPhase!=="idle"?` (${r.transitionPhase}, ${r.activeTransitionCount} active)`:"";if(m.push(`nav: phase=${r.transitionPhase}${b}`),r.screens.length===0)m.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let $ of r.screens){let M=$.isActive?"\u25B6":" ",w=$.routeName?` ${$.routeName}`:"",h=$.headerHeight>0?` header=${$.headerHeight}`:"",T=$.largeTitleState&&$.largeTitleState!=="expanded"?` large-title=${$.largeTitleState}`:"";m.push(` ${M} #${$.id}${w}${h}${T}`)}}else m.push("nav: <runtime not available>");if(m.push(`route: ${l?.currentPath??"<unavailable>"}`),l?.coveringPath&&m.push(`covered: a presented screen (${l.coveringPath}) is above this route`),u&&u.visible){let b=u.spec?.keyboardType??"default",$=u.spec?.returnKeyType??"default";m.push(`keyboard: visible (${b}, return=${$}, mode=${u.mode??"?"})`)}else m.push("keyboard: hidden");console.log(m.join(`
20
- `))}async function lo(e){let{bridge:t,args:r,positional:l}=e,u=l[1]?Number(l[1])*1e3:3e3,a=r.includes("--strict"),{elapsed:m,settled:b}=await ne({bridge:t,maxMs:u,strict:a});console.log(b?` settled in ${m}ms`:` timed out after ${m}ms (may still be animating)`)}async function co(e){let t=e.positional[1]?Number(e.positional[1]):.5;(!Number.isFinite(t)||t<0)&&(console.error(e.inspectUsage("sleep","[seconds]")),y(1)),await Z(t*1e3),console.log(` slept ${t}s`)}async function uo(e){let{bridge:t,args:r,positional:l}=e,u=r.includes("--boxes"),a=l[1]?Number(l[1]):u?50:5,{tree:m}=await ft(t,a);if(D(r)){C({depth:a,tree:m??null});return}console.log(yt(m)?ht(m):"")}async function mo(e,t={args:[]}){let r=await gt(e);if(D(t.args)){C(r);return}console.log(r.url)}async function po(e){let{wsPort:t,commandTimeoutMs:r,simId:l,simIdSource:u,positional:a}=e,m=a[1]?Number(a[1]):30,b=Math.max(1e3,(Number.isFinite(m)?m:30)*1e3),$=Math.max(1,Math.ceil(b/500));console.log(" waiting for sim reconnect...");let M=await At(t,r,l,{attempts:$,simIdSource:u});M||(console.error(" timed out waiting for sim reconnect"),y(1)),M.bridge.close(),Oe({source:"inspect wait",step:{wait:b},summary:`wait ${Math.round(b/1e3)}s`}),console.log(` ready: ${M.count} nodes`)}var fo=new Set(["app-launch","toast","keyboard","screen","flow-step","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function Re(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1]}function us(e,t){if(!t.filter&&!t.equals)return!0;let r=e.data,l=[];if(r&&typeof r=="object")for(let a of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let m=r[a];typeof m=="string"&&m.length>0&&l.push(m)}let u=l.join(" ");return t.equals?l.some(a=>a===t.equals):t.filter?u.toLowerCase().includes(t.filter.toLowerCase()):!0}async function go(e){let{bridge:t,args:r,positional:l,inspectUsage:u}=e,a=l[1];a||(console.error(u("event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),y(1)),fo.has(a)||console.error(` warning: '${a}' is not a known timeline kind \u2014 waiting anyway. known: ${[...fo].sort().join(", ")}`);let m=Re(r,"--max-ms"),b=m&&Number.isFinite(Number(m))?Math.max(100,Number(m)):5e3,$=Re(r,"--filter"),M=Re(r,"--equals"),w=Re(r,"--since")??"now",h=r.includes("--json"),T=Date.now(),x=T+b,P=200,O=T;for(;Date.now()<x;){let j={kinds:[a],since:w==="cursor"?void 0:O,limit:50},A=await t.send({type:"evaluate",code:`(async () => {
21
- const t = window.SootSim?.bridges?.timeline
22
- if (!t) return { ok: false, error: 'timeline bridge missing' }
23
- return { ok: true, result: await t.recent(${JSON.stringify(j)}) }
24
- })()`});(!A||!A.ok)&&(console.error(` could not query timeline: ${A&&"error"in A?A.error:"unknown"}`),y(1));let B=A.result.events??[];for(let H of B)if(us(H,{filter:$,equals:M})){let W=Date.now()-T;console.log(h?JSON.stringify({found:!0,elapsedMs:W,event:H}):` ${a} event after ${W}ms${$?` (filter: ${$})`:""}${M?` (equals: ${M})`:""}`);return}A.result.watermark&&A.result.watermark>O&&(O=A.result.watermark),await new Promise(H=>setTimeout(H,P))}let c=Date.now()-T;h?console.log(JSON.stringify({found:!1,elapsedMs:c,kind:a,filter:$,equals:M})):console.error(` \u26A0 wait event ${a} timed out after ${c}ms${$?` (filter: ${$})`:""}${M?` (equals: ${M})`:""}`),y(1)}async function yo(e){let{bridge:t,args:r}=e,l=r.includes("--strict"),u=Se(r,3e3),{elapsed:a,settled:m}=await ne({bridge:t,maxMs:u,strict:l});m?console.log(` idle in ${a}ms`):(console.error(` \u26A0 wait idle timed out after ${a}ms (may still be animating)`),y(1))}async function ho(e){let{bridge:t,args:r}=e,l=Se(r,2e4),{ready:u,elapsedMs:a,nodes:m,targets:b,liveFrameActive:$,liveFrameChannels:M,flag:w,loadingText:h,externalReady:T,externalError:x,suppressedEntryError:P,errors:O,bridgeError:c}=await St(t,l,{onProgress(A){console.error(` still waiting after ${A.elapsedMs}ms \u2014 ${De(A)} (nodes: ${A.nodes}, targets: ${A.targets}, live surfaces: ${A.liveFrameActive?A.liveFrameChannels:0}, errors: ${A.errors})`)}});if(u){let A=l-a,B=Math.max(100,Math.min(1e4,A)),H=await ne({bridge:t,maxMs:B,pollMs:32,stablePolls:2});H.settled||(console.error(` \u26A0 wait ready timed out after ${a+H.elapsed}ms \u2014 app mounted but did not settle (nodes: ${m}, targets: ${b})`),y(1)),console.log(` ready in ${a+H.elapsed}ms: ${m} nodes, ${b} targets${$?`, ${M} live surfaces`:""}`);return}let j=De({externalError:x,loadingText:h,externalReady:T,flag:w,targets:b,suppressedEntryError:P,bridgeError:c});console.error(` \u26A0 wait ready timed out after ${a}ms \u2014 ${j} (nodes: ${m}, targets: ${b}, live surfaces: ${$?M:0}, errors: ${O})`),y(1)}async function bo(e){let{bridge:t,args:r,positional:l,inspectUsage:u}=e,a=l[1];a||(console.error(u("selector","<testid> [--max-ms 5000] [--gone]")),y(1));let m=r.indexOf("--max-ms"),b=m>=0&&r[m+1]?Math.max(100,Number(r[m+1])):5e3,$=r.includes("--gone"),{found:M,node:w,elapsed:h}=await kt(t,a,b,{gone:$});if($){M?console.log(` #${a} gone after ${h}ms`):(console.error(` \u26A0 wait selector #${a} --gone timed out after ${h??b}ms (still present)`),y(1));return}if(M&&w){let T=`@(${Math.round(w.geometry.x)},${Math.round(w.geometry.y)})`,x=`${Math.round(w.geometry.width)}x${Math.round(w.geometry.height)}`;console.log(` found #${a} in ${h}ms ${x} ${T}`)}else console.error(` \u26A0 wait selector #${a} timed out after ${h??b}ms`),y(1)}function To(e){return e==null?"\u2014":e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}K`:`${(e/1024/1024).toFixed(1)}M`}function Eo(e){return e==null?" \u2026":e<1e3?`${e}ms`.padStart(5):`${(e/1e3).toFixed(2)}s`.padStart(5)}function wo(){process.stderr.write(` the sim is not responding. recover it with:
25
- rnx close --sim <id> # force-close the wedged sim
26
- rnx list # confirm it's gone
27
- `)}async function $e(e,t){let r=await e.send({type:"perform",steps:[t]}),l=r?.steps?.[0],u=l?.error??r?.error;return{ok:r?.ok===!0,value:l?.value,...u?{error:u}:{}}}async function ps(e){try{return await e.send({type:"evaluate",code:"1"},{timeoutMs:3e3}),!0}catch{return!1}}async function fs(e,t){try{let r=await e.send({type:"evaluate",code:`(async () => {
28
- const t = window.__sootsimTest
29
- if (!t || typeof t.queryAll !== 'function') return []
30
- try {
31
- // queryAll is async in render-worker mode (the canonical mode now)
32
- // because the call has to round-trip the worker \u2014 must await it.
33
- // a sync result is still handled fine since await on a non-Promise
34
- // is a no-op.
35
- const nodes = await t.queryAll({})
36
- if (!Array.isArray(nodes)) return []
37
- const out = new Set()
38
- for (const n of nodes) {
39
- const id = n && (n.testID || n.id)
40
- if (typeof id === 'string' && id) out.add(id)
41
- }
42
- return Array.from(out)
43
- } catch {
44
- return []
45
- }
46
- })()`});if(!Array.isArray(r)||r.length===0)return;let l=t.toLowerCase(),u=r.map(a=>({id:a,score:gs(l,a.toLowerCase())})).filter(a=>a.score<l.length+4).sort((a,m)=>a.score-m.score).slice(0,5);if(u.length===0)return;console.error(" similar testIDs:");for(let a of u)console.error(` ${a.id}`)}catch{}}function gs(e,t){if(t===e)return 0;if(t.includes(e))return 1;if(e.includes(t))return 2;let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r+=1;return ys(e,t)-r}function ys(e,t){if(e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let r=new Array(t.length+1),l=new Array(t.length+1);for(let u=0;u<=t.length;u++)r[u]=u;for(let u=1;u<=e.length;u++){l[0]=u;for(let m=1;m<=t.length;m++)l[m]=Math.min(r[m]+1,l[m-1]+1,r[m-1]+(e[u-1]===t[m-1]?0:1));let a=r;r=l,l=a}return r[t.length]}function hs(e){return e.error?"err":e.status==null?" \u2026 ":String(e.status)}function $o(e){return e.externalError?`guest app errored: ${e.externalError}`:e.loadingText?`still showing "${e.loadingText}"`:e.externalReady===!1?"guest app is still loading":e.flag!==!0?"guest app has not emitted sootsim:externalAppReady":e.targets<=0?"ready flag emitted but no visible app content is inspectable yet":"node tree is still changing"}function xo(e){let t=oe(e.startTs),r=hs(e).padEnd(3),l=e.method.padEnd(5),u=To(e.size).padStart(6),a=Eo(e.durationMs);console.log(` [${t}] ${r} ${l} ${u} ${a} ${e.displayUrl}`),e.error&&console.log(` error: ${e.error}`)}function bs(e){let t=[["id",e.id],["source",e.source],["kind",e.kind],["method",e.method],["status",e.error?`error: ${e.error}`:`${e.status??"\u2014"} ${e.statusText??""}`.trim()],["url",e.url],["started",oe(e.startTs)],["duration",Eo(e.durationMs).trim()],["size",To(e.size)],["content-type",e.type??"\u2014"]];for(let[r,l]of t)console.log(` ${r.padEnd(13)} ${l}`)}var ws={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},So="\x1B[0m",$s="\x1B[2m";function ko(e,t){let r=oe(e.ts),l=e.level.toUpperCase().padEnd(5),u=e.args.join(" ");if(t){let a=ws[e.level];console.log(` ${$s}[${r}]${So} ${a}${l}${So} ${u}`)}else console.log(` [${r}] ${l} ${u}`);if(e.stack&&e.level==="error"){let a=e.stack.split(`
47
- `).slice(0,5);for(let m of a)console.log(` ${m.trim()}`)}}var xs=120;async function vo(e,t){let r=e.find((T,x)=>e[x-1]==="--id"),l=e.find((T,x)=>e[x-1]==="--text");if(r||l){let T=await t.send({type:"evaluate",code:Jt({id:r,text:l})});if(!T)throw new Error(r?`no node with id "${r}"`:`no node matching text "${l}"`);let{x,y:P,w:O,h:c}=T;return{x,y:P,w:O,h:c}}let u=e.find((T,x)=>e[x-1]==="--area");if(u){let T=u.split(",").map(j=>Number(j.trim()));if(T.length!==4||T.some(j=>!Number.isFinite(j)))throw new Error(`--area expects x,y,w,h (got "${u}")`);let[x,P,O,c]=T;return{x,y:P,w:O,h:c}}let a=T=>{let x=e.find((O,c)=>e[c-1]===T);if(x==null)return null;let P=Number(x);return Number.isFinite(P)?P:null},m=a("--x"),b=a("--y"),$=a("--w"),M=a("--h");if(m!=null||b!=null||$!=null||M!=null)return{x:m??0,y:b??0,w:$??1,h:M??1};let h=e.filter((T,x)=>x>0&&!T.startsWith("-")&&e[x-1]!=="--output"&&e[x-1]!=="--area"&&e[x-1]!=="--id"&&e[x-1]!=="--text"&&e[x-1]!=="--x"&&e[x-1]!=="--y"&&e[x-1]!=="--w"&&e[x-1]!=="--h").map(Number).filter(T=>Number.isFinite(T));if(h.length>=2){let[T,x,P=1,O=1]=h;return{x:T,y:x,w:P,h:O}}return null}function No(e,t){if(!t||typeof t!="object")return;console.log(""),console.log(` render profile \u2014 ${e} (per painted frame):`),console.log(` node visits: ${t.nodeVisitsPerFrame}`),console.log(` boundaries: ${t.recordsPerFrame} records (${t.avgBoundaryRecordMs}ms) / ${t.replaysPerFrame} replays`);let r=[t.boundaryRecordsInvalidated?`invalidated ${t.boundaryRecordsInvalidated}`:"",t.boundaryRecordsOrigin?`moved ${t.boundaryRecordsOrigin}`:"",t.boundaryRecordsScheme?`first-record ${t.boundaryRecordsScheme}`:""].filter(Boolean).join(" \xB7 ");r&&console.log(` why recorded: ${r}`),t.prewarmRecords&&console.log(` pre-recorded: ${t.prewarmRecords} boundaries at idle (${Number(t.prewarmRecordMs).toFixed(1)}ms total)`),console.log(` raster tier: ${t.rasterPromotionsPerFrame} promotions / ${t.rasterBlitsPerFrame} blits`);let l=[t.rasterRejectRebuild?`rebuild ${t.rasterRejectRebuild}`:"",t.rasterRejectLinear?`linear ${t.rasterRejectLinear}`:"",t.rasterRejectAnimated?`animated ${t.rasterRejectAnimated}`:"",t.rasterRejectTransform?`transform ${t.rasterRejectTransform}`:"",t.rasterRejectOpacity?`opacity ${t.rasterRejectOpacity}`:"",t.rasterRejectCacheable?`cacheable ${t.rasterRejectCacheable}`:"",t.rasterRejectBounds?`bounds ${t.rasterRejectBounds}`:"",t.rasterRejectPixels?`pixels ${t.rasterRejectPixels}`:"",t.rasterRejectBudget?`budget ${t.rasterRejectBudget}`:"",t.rasterWarming?`warming ${t.rasterWarming}`:""].filter(Boolean).join(" \xB7 ");l&&(console.log(` raster skips: ${l} (total across run)`),t.rasterRejectAlsoBlocked&&console.log(` ${"".padEnd(12)} ${t.rasterRejectAlsoBlocked} of those also fail a later gate \u2014 widening the named gate cannot promote them`)),console.log(` blur: ${t.avgBlurMs}ms`),(t.glassDownsampleActive||t.glassBackdropCacheMisses)&&console.log(` glass: ${t.glassDownsampleFactor}x downsample (${t.glassDownsampledDraws} draws) \xB7 cache ${t.glassBackdropCacheHits} hits / ${t.glassBackdropCacheMisses} misses / ${t.glassBackdropCacheInvalidations} invalidations`),console.log(` draw calls: text ${t.textDrawsPerFrame} \xB7 image ${t.imageDrawsPerFrame} \xB7 path ${t.pathDrawsPerFrame} \xB7 saveLayer ${t.saveLayersPerFrame}`)}function Io(e){let t=e.avgMs>0?(1e3/e.avgMs).toFixed(1):"?",r=e.jank&&typeof e.jank=="object"?e.jank:null,l=e.compositorProduction&&typeof e.compositorProduction=="object"?e.compositorProduction:null,u=l?.budgetMs??8;if(console.log(` shell frame profile:
48
- `),r){let T=(Array.isArray(r.compositor)?r.compositor:[]).reduce((x,P)=>x+(P.jankPaints??0),0);console.log(` health: ${r.detected?"jank or cadence gaps observed":"no jank or cadence gaps observed"} \xB7 shell ${r.shell?.jankFrames??0} \xB7 compositor ${T} \xB7 host clock gaps ${r.hostGaps??0}`),console.log(" series: independent worker clocks, no per-frame pairing")}if(console.log(` painted frames: ${e.frames}${e.skippedFrames?` (+${e.skippedFrames} skipped idle ticks)`:""}`),console.log(` shell work avg: ${e.avgMs}ms (${t} fps) \xB7 worst observed ${e.maxMs}ms`),console.log(` shell p50/95/99:${e.p50} / ${e.p95} / ${e.p99} ms`),r){console.log(` shell jank: ${r.shell?.jankFrames??0}/${r.shell?.sampledFrames??0} (${r.shell?.jankPct??0}%) >${u}ms \xB7 max ${r.shell?.maxMs??0}ms`);for(let h of Array.isArray(r.compositor)?r.compositor:[])console.log(` ${String(h.surfaceId).padEnd(12)} ${h.jankPaints}/${h.sampledPaints} compositor paints (${h.jankPct}%) >${u}ms \xB7 max ${h.maxMs}ms`)}else console.log(` jank: ${e.jankFrames} frames (${e.jankPct}%) >${u}ms`);if(console.log(` avg per frame: overlay ${e.avgOverlayMs}ms \xB7 aux ${e.avgAuxMs}ms \xB7 layout ${e.avgLayoutMs}ms`),l){let h=l.frames??{};console.log(""),console.log(` compositor production (${u}ms budget):`),console.log(` frames: ${h.count??0} \xB7 avg ${Number(h.avg??0).toFixed(2)} / p95 ${Number(h.p95??0).toFixed(2)} / max ${Number(h.max??0).toFixed(2)} ms \xB7 ${l.overBudget??0} over budget (${l.overBudgetPct??0}%)`);let T=[["javascript","javascript"],["layout","layout"],["paint","paint"],["prewarm","prewarm"],["texture upload","textureUpload"],["gpu submit","gpuSubmit"],["composite","composite"],["capture/readback","capture"]];for(let[O,c]of T){let j=l.phases?.[c];!j?.count||!j.max&&!j.avg||console.log(` ${O.padEnd(16)} avg ${Number(j.avg??0).toFixed(2)} / p95 ${Number(j.p95??0).toFixed(2)} / max ${Number(j.max??0).toFixed(2)} ms`)}let x=l.captureBetweenFrames;x?.count&&x.max>0&&console.log(` capture between p95 ${Number(x.p95??0).toFixed(2)} / max ${Number(x.max??0).toFixed(2)} ms between compositor rAF callbacks`);let P=Array.isArray(l.worstFrames)?l.worstFrames.slice(0,5):[];if(P.length>0){console.log(" worst frames:");for(let O of P){let c=O.phases??{};console.log(` ${Number(O.productionMs??0).toFixed(2)}ms frame ${O.frameToken??"?"} \xB7 js ${Number(c.javascriptMs??0).toFixed(2)} \xB7 layout ${Number(c.layoutMs??0).toFixed(2)} \xB7 paint ${Number(c.paintMs??0).toFixed(2)} \xB7 prewarm ${Number(c.prewarmMs??0).toFixed(2)} \xB7 upload ${Number(c.textureUploadMs??0).toFixed(2)} \xB7 submit ${Number(c.gpuSubmitMs??0).toFixed(2)} \xB7 composite ${Number(c.compositeMs??0).toFixed(2)} \xB7 capture ${Number(c.captureMs??0).toFixed(2)}`)}}}let a=e.cadence;a&&typeof a=="object"&&(console.log(""),console.log(` cadence (frame delivery, ${a.vsyncTicks} vsync ticks):`),console.log(` display clock: ${a.displayHz}hz \xB7 host rAF interval p50 ${a.hostIntervalP50} / p95 ${a.hostIntervalP95} / max ${a.hostIntervalMax} ms${a.hostGaps?` \xB7 ${a.hostGaps} gaps >1.5x (host rAF starved)`:""}`),console.log(` delivery lag: p50 ${a.deliveryLagP50} / p95 ${a.deliveryLagP95} / max ${a.deliveryLagMax} ms (vsync postMessage \u2192 shell receipt)`),console.log(` paint interval: p50 ${a.paintIntervalP50} / p95 ${a.paintIntervalP95} / max ${a.paintIntervalMax} ms${a.idleBreaks?` \xB7 ${a.idleBreaks} idle breaks excluded`:""}`));let m=e.compositorCadence;if(m&&typeof m=="object"){console.log(` compositor rAF: p50 ${m.p50} / p95 ${m.p95} / max ${m.max} ms \xB7 ${m.gaps} gaps >1.5x`);let h=(T,x)=>{x?.count&&console.log(` ${T}: ${x.count} samples \xB7 p50 ${x.p50.toFixed(2)} / p95 ${x.p95.toFixed(2)} / max ${x.max.toFixed(2)} ms`)};h("engine-empty rAF",m.phases?.uninterruptedEngineEmpty),h("rAF with CanvasKit flush",m.phases?.withCanvaskitFlush),h("rAF after CanvasKit flush",m.phases?.afterCanvaskitFlush),h("CanvasKit submission",m.canvaskitSubmission)}let b=Array.isArray(e.auxSurfaces)?e.auxSurfaces:[],$=e.graphiteCaches,M=e.decodedImageCache;if($||M){let h=(T,x)=>{if(typeof x?.bytes!="number"||typeof x.limitBytes!="number")return;let P=typeof x.purgeableBytes=="number"?` \xB7 ${(x.purgeableBytes/1024/1024).toFixed(1)}MB purgeable`:"";console.log(` ${T.padEnd(29)} ${(x.bytes/1024/1024).toFixed(1)}MB/${(x.limitBytes/1024/1024).toFixed(1)}MB${P}`)};console.log(""),console.log(" device-wide caches:"),h("Graphite context resources",$?.contextResources??null),h("Graphite recorder resources",$?.recorderResources??null),h("Graphite image provider",$?.imageProvider??null),h("decoded image pixels",M??null),$?.imageProvider&&console.log(` ${"".padEnd(29)} ${$.imageProvider.entries} entries \xB7 ${$.imageProvider.uploads} uploads \xB7 ${$.imageProvider.evictions} evictions`),M&&console.log(` ${"".padEnd(29)} ${M.entries} entries/${M.maxEntries} max`)}if(b.length>0){console.log(""),console.log(" surfaces (last 100 frames):");for(let h of b)console.log(` ${String(h.surfaceId).padEnd(10)} ${String(h.frames).padStart(4)} paints avg ${h.avgMs}ms (layout ${h.avgLayoutMs}, render ${h.avgRenderMs}, flush ${h.avgFlushMs}) max ${h.maxMs}ms`)}No("shell worker",e.renderProfile),No("compositor worker",e.compositorRenderProfile);let w=Array.isArray(e.worstFrames)?e.worstFrames:[];if(w.length>0){console.log(""),console.log(" worst observations (shell and compositor series are unpaired):");for(let h of w){if(h.source==="compositor"){console.log(` ${String(h.totalMs).padStart(7)}ms compositor ${h.surfaceId} paint ${h.paint} \xB7 layout ${h.layoutMs} \xB7 render ${h.renderMs} \xB7 flush ${h.flushMs}`);continue}let T=(h.auxSurfaces??[]).map(x=>`${x.surfaceId} ${x.totalMs}ms (layout ${x.layoutMs}, render ${x.renderMs})`).join(" \xB7 ");console.log(` ${String(h.totalMs).padStart(7)}ms overlay ${h.overlayMs} \xB7 aux ${h.auxMs} \xB7 layout ${h.layoutMs}${T?` [${T}]`:""}`)}}}async function Ae(e,t,r){let l=Date.now()+t,u=await ue(e,t);for(;;){if(r(u))return{settled:!0,state:u};if(Date.now()>=l)return{settled:!1,state:u};await Z(16),u=await ue(e)}}async function tt(e){return e.send({type:"evaluate",code:`(async () => {
49
- const kb = window.__sootsimKeyboard
50
- const test = window.__sootsimTest
51
- if (!kb) return { error: 'keyboard bridge not available' }
52
- const layout = typeof kb.getLayout === 'function' ? kb.getLayout() : null
53
- const secureTextEntry =
54
- !!layout?.spec?.secureTextEntry && layout?.spec?.keyboardType !== 'visible-password'
55
- const visible = kb.isVisible()
56
- const mode = kb.getMode()
57
- let focused = null
58
- if (test && typeof test.getFocusedNode === 'function') {
59
- try {
60
- focused = await test.getFocusedNode()
61
- } catch {}
62
- }
63
- let runtimeSnapshot = null
64
- if (test && typeof test.getFocusKeyboardSnapshot === 'function') {
65
- try {
66
- runtimeSnapshot = await test.getFocusKeyboardSnapshot()
67
- } catch {}
68
- }
69
- return {
70
- visible,
71
- mode,
72
- layout,
73
- hostedEditorFocused:
74
- typeof kb.hasHostedEditorFocus === 'function' && kb.hasHostedEditorFocus(),
75
- focusedInput: focused ? {
76
- nodeId: focused.nodeId ?? null,
77
- testID: focused.testID || null,
78
- id: focused.id || null,
79
- placeholder: focused.placeholder || null,
80
- secureTextEntry,
81
- text: secureTextEntry ? ${JSON.stringify(Q)} : (focused.text || null),
82
- } : null,
83
- phase: runtimeSnapshot?.keyboard?.phase ?? null,
84
- frame: runtimeSnapshot?.keyboard?.frame ?? null,
85
- focusedRect: runtimeSnapshot?.focused?.rect ?? null,
86
- }
87
- })()`}).then(t=>Ze(t))}function Ss(e,t,r){if(!e.visible)return!1;let l=e.focusedInput;return!(t&&l&&!(l.testID===t||l.id===t)||r!==null&&we(e)!==r)}async function ks(e,t=600,r={}){let l=Date.now()+t;for(;Date.now()<=l;){let u=await tt(e);if(Ss(u,r.targetId??null,r.secureTextEntry??null))return u;await Z(30)}return tt(e)}async function Pe(e,t){let r=await tt(e);if(r.visible&&(r.focusedInput||r.hostedEditorFocused))return r;r.visible&&(console.error(` ${t} requires a focused editable control. the iOS keyboard is visible, but no input owns focus.`),y(1)),console.error(` ${t} requires the iOS keyboard to be visible. focus an input first with rnx do tap-id/tap-text or rnx do type-into.`),y(1)}async function Mo(e,t,r){return t==="appearance"?e.send({type:"evaluate",code:`(async () => {
88
- const requested = ${JSON.stringify(r??"toggle")}
89
- // the engine owns toggle + auto resolution (settingsStore is the single
90
- // source of truth). never infer the current scheme client-side \u2014 the old
91
- // documentElement '#333333' sniff is never set in embedded / shell-chrome
92
- // contexts, so 'toggle' read 'light' forever and stuck on the boot scheme.
93
- window.postMessage({ type: 'contrast-action', action: 'set-appearance', value: requested }, '*')
94
- // let the engine's message handler apply + publish window.__sootsimColorScheme
95
- await new Promise((r) => setTimeout(r, 60))
96
- const applied = window.__sootsimColorScheme?.resolved
97
- ?? (window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light')
98
- const setting = window.__sootsimColorScheme?.setting ?? requested
99
- return { ok: true, requested, setting, applied }
100
- })()`}):t==="lock"?e.send({type:"evaluate",code:`(async () => {
101
- const toggleLock = window.SootSim?.bridges?.mainShell?.toggleLock
102
- if (typeof toggleLock !== 'function') {
103
- throw new Error('rnx mainShell.toggleLock bridge unavailable')
104
- }
105
- await toggleLock()
106
- return { ok: true, action: 'lock' }
107
- })()`}):e.send({type:"evaluate",code:`(async () => {
108
- window.dispatchEvent(new CustomEvent('sootsim:shake'))
109
- return { ok: true, action: 'shake' }
110
- })()`})}function vs(e){let t={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(t[e])return t[e];let r=e.match(/^Digit([0-9])$/);if(r)return r[1];let l=e.match(/^Key([A-Z])$/);return l?l[1].toLowerCase():null}function Ns(e){if(typeof e!="string")return null;let t=e.replace(/\s+/g," ").trim();return t?t.slice(0,80):null}function Oo(...e){for(let t of e){if(typeof t!="string")continue;let r=t.trim();if(r)return r}return null}function Is(e){let t=e.indexOf("--node-id");if(t<0)return null;let r=e[t+1];if(!r)return null;let l=Number(r);return Number.isInteger(l)&&l>0?l:null}async function q(e,t,r){let l=Oe({source:e,step:t,summary:r});l.active&&(l.replaced?console.error(` draft: replaced unkept action "${l.replaced.summary}" \u2014 \`maestro keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `rnx maestro keep` to commit"))}function Fo(e,t,r){if(!r||r.hit===!1)return null;let l=Oo(r.responderTestID,r.testID);if(l)return{step:{tapOn:{id:l}},summary:`tap #${l}`};let u=Ns(r.text);return u?{step:{tapOn:u},summary:`tap "${u}"`}:{step:{tapAtCoords:{x:e,y:t}},summary:`tap @${Math.round(e)},${Math.round(t)}`}}function et(e,t,r){let l=Oo(t?.testID,t?.id);return l?{step:{tapOn:{id:l}},summary:`tap #${l}`}:r==="id"?{step:{tapOn:{id:e}},summary:`tap #${e}`}:{step:{tapOn:e},summary:`tap "${e}"`}}async function Br(e,t){let r=e[0]==="get"||e[0]==="do"||e[0]==="debug"||e[0]==="wait"?e[0]:null,l=r?e.slice(1):e,u=ct(l,{port:t.port,commandTimeoutMs:t.timeoutMs,stripBooleanFlags:["--verbose","-v","--help","-h","--clear-state","--json","--all","--watch","-w","--strict","--no-wait","--dump","--failed","--slow","--tail","-f","--interactive-targets","--actions","--internal","--compact","--no-xy"],stripValueFlags:["--output","--nth","--index","--testid","--test-id","--text","--node-id","--max-ms","--filter","--limit","--level","--threshold","--equals","--since","--testid-like","--only","--subtree"]}),a=u.positional,m=a[0],b=r,$=typeof l[0]=="string"&&ot.has(l[0]),M=$?l[0]:null,w=S=>{if(t.internalPerfCommand&&S==="perf")return`rnx perf ${t.internalPerfCommand}`;if($&&S===l[0])return`rnx ${S}`;let o=b??nt(S)?.group;return o?`rnx ${o} ${S}`:`rnx ${S}`},h=(S,o)=>` usage: ${w(S)}${o?` ${o}`:""}`;if(!m||e.includes("--help")||e.includes("-h")){let S={bridgePort:7668,defaultShellUrl:at};if(b==="do"||b==="get"||b==="debug"||b==="wait"){let s=je(b,S);s&&(console.log(`${s}
111
- `),y(0))}if(M==="shell"){let s=rt("shell",S);s&&(console.log(`${s}
112
- `),y(0))}let o=["do","get","debug","wait"].map(s=>je(s,S)).filter(s=>s!=null).join(`
113
-
114
- `);console.log(`${o}
115
- `),y(0)}let T=u.wsPort,x=u.simId,P=u.simIdSource,O=u.commandTimeoutMs;if(b==="get"&&m==="diagnosis"){let S=l.indexOf("diagnosis"),o=S>=0?[...l.slice(0,S),...l.slice(S+1)]:l,{runDiagnose:s}=await import("./diagnose-PJMPXKJY.js"),n=await s(["recent",...o],t);process.exitCode=n;return}if(b==="do"&&m==="scan"){let{runCamera:S}=await import("./camera-J3V62PP7.js");process.exitCode=await S(l,{port:t.port});return}if(m==="list"&&l.some(S=>S==="--drivers"||S==="-D")){let{buildDriverListRows:S}=await import("./drivers-ZFNX3T5Z.js"),o=S();console.log(` available drivers (${o.length}):
116
- `);let s=Math.max(...o.map(i=>i.id.length),6),n=Math.max(...o.map(i=>i.kind.length),4);for(let i of o){let d=i.available?"\u2713":"\u2717",p=i.id.padEnd(s),f=i.kind.padEnd(n);console.log(` ${d} ${p} ${f} ${i.description}`),i.available&&i.detail?console.log(` ${i.detail}`):!i.available&&i.reason&&console.log(` unavailable: ${i.reason}`)}return}let c=dt(u),j=x||"default",A=new Set(["errors","warnings","requests","js","reload","globals","perf","storage-clear","list","wait","sleep"]),B=200;function H(S){let o=S.replace(/\s+/g," ").trim();if(!o)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(o)){let n=/<title[^>]*>([^<]+)<\/title>/i.exec(S)?.[1]?.trim(),i=/<body[^>]*>([\s\S]*?)<\//i.exec(S)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),d=n||i||"html error page";return`<html ${S.length}B> "${d}" (body elided \u2014 add --json for the full payload)`}return o.length<=B?o:`${o.slice(0,B)}\u2026 (+${o.length-B} more bytes)`}function W(S){let o=S.displayUrl||S.url;return S.status!=null?`${S.method} ${o} -> ${S.status}${S.statusText?` ${S.statusText}`:""}`:S.error?`${S.method} ${o} -> ${S.error}`:`${S.method} ${o}`}async function F(S){let o=de()?400:200;try{let{settled:s,elapsed:n}=await ne({bridge:S,maxMs:o,pollMs:32,stablePolls:2});s||process.stderr.write(` \u26A0 auto-wait timed out after ${n??o}ms \u2014 next command may see mid-animation state. use \`rnx do settle\` for a longer wait.
117
- `)}catch{}}function _(S,o){if(o.result?.reason==="offscreen"){let{x:s,y:n,screen:i}=o.result;console.error(` tap failed: ${S} resolved to (${Math.round(s)},${Math.round(n)}), outside the ${i?.width}x${i?.height} screen`),console.error(" the node exists but is scrolled out of view \u2014 scroll it on-screen first (rnx do scroll / swipe), then tap.");return}console.error(` tap failed: ${S} stayed visible but did not receive a hittable press after ${o.attempts} attempt${o.attempts===1?"":"s"}`),o.result&&console.error(` last result: ${JSON.stringify(o.result)}`)}async function V(){try{return await c.send({type:"evaluate",code:`(() => ({
118
- console: ${Ne},
119
- requests: window.__sootsimTest?.getRequestCounts?.() || null,
120
- }))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function se(S={}){let o=S.counts!==void 0?S.counts:await G(c,"getRequestCounts");if(!o||typeof o!="object")return;let s=Math.max(0,Number(o.failed)||0);if(s===0||!S.includeTail&&!Ge("requests",j,String(s))||(console.log(`
121
- network: ${s} failed request${s===1?"":"s"}`),console.log(` inspect: ${w("requests")} 5`),!S.includeTail))return;let n=await G(c,"getFailedRequests",5);if(!(!Array.isArray(n)||n.length===0)){console.log(`
122
- recent failed requests:
123
- `);for(let i of n){let d=oe(i.timestamp);console.log(` [${d}] ${W(i)}`),i.responseBody?console.log(` ${H(i.responseBody)}`):i.error&&console.log(` ${i.error}`)}}}function re(S){for(let o of S){let s=o.title?` (\u201C${o.title}\u201D)`:"";console.error(`
124
- note: ${o.label} is open${s} \u2014 taps/drags hit it, not the app`)}}async function ie(S={}){let o=S.counts!==void 0?S.counts:await c.send({type:"evaluate",code:Ne});if(!o||typeof o!="object")return;let s=o,n=Math.max(0,Number(s.errors)||0),i=Math.max(0,Number(s.warnings)||0);if(n===0&&i===0||!S.includeTail&&!Ge("console",j,`${n}:${i}`))return;let d=[];if(n>0&&d.push(`${n} console error${n===1?"":"s"}`),i>0&&d.push(`${i} console warning${i===1?"":"s"}`),console.error(`
125
- console: ${d.join(", ")}`),console.error(` inspect: ${w("errors")} 5`),i>0&&console.error(` inspect: ${w("warnings")} 5`),!S.includeTail||n===0)return;let p=await fe(c,5);if(!(!Array.isArray(p)||p.length===0)){console.error(`
126
- recent console errors:
127
- `);for(let f of p){let v=oe(f.timestamp),g=Array.isArray(f.args)?f.args.map(N=>typeof N=="object"?JSON.stringify(N):String(N)).join(" "):String(f);console.error(` [${v}] ${g}`)}}}let ae=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function _e(S){let o=it(),s=null;try{s=await mt(S,`(() => {
128
- const tl = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.timeline
129
- if (!tl || typeof tl.summary !== 'function') return null
130
- const cursorKey = ${JSON.stringify(o)}
131
- const summary = tl.summary({ sinceCursor: cursorKey })
132
- let consoleSplit = null
133
- if (summary && summary.byKind && summary.byKind.console) {
134
- const events = tl.recent({ sinceCursor: cursorKey, kinds: 'console', limit: 100000 }).events
135
- consoleSplit = { error: 0, warn: 0 }
136
- for (const ev of events) {
137
- const lvl = ev && ev.data && ev.data.level
138
- if (lvl === 'error') consoleSplit.error++
139
- else if (lvl === 'warn') consoleSplit.warn++
140
- }
141
- }
142
- return summary ? { summary, consoleSplit } : null
143
- })()`)}catch{return}if(!s||!s.summary||!s.summary.total)return;let n=s.summary.byKind??{},i=[],d=new Set;for(let p of ae){let f=n[p];if(f)if(d.add(p),p==="console"&&s.consoleSplit){let{error:v,warn:g}=s.consoleSplit;v>0&&i.push(`${v} error${v===1?"":"s"}`),g>0&&i.push(`${g} warning${g===1?"":"s"}`)}else i.push(`${f} ${p}${f===1?"":"s"}`)}for(let[p,f]of Object.entries(n))!d.has(p)&&f&&i.push(`${f} ${p}${f===1?"":"s"}`);if(i.length!==0&&(console.error(`
144
- since last: ${i.join(" \xB7 ")} \u2014 rnx what-happened`),s.summary.lastAt))try{await le(S,"SootSim.bridges.timeline.cursorAdvance",o,s.summary.lastAt)}catch{}}let pe=new Set(["tap","double-tap","tap-text","tap-id","type","type-into","key","key-sequence","keycode","drag","swipe","long-press","touch","gesture","pinch","scroll","shell","storage-clear"]),Ro=new Set(["a11y","capture","count","double-tap","drag","find","gesture","layout","long-press","node","pinch","sample-color","scroll","screenshot","swipe","tap","tap-id","tap-text","touch","tree","type-into"]),Ao=(e.includes("--verbose")||e.includes("-v"))&&!e.includes("--json");b==="do"&&m==="shell"&&(console.error(" `rnx do shell` was removed. use `rnx shell ...` instead."),y(1)),pe.has(m)&&await ut(c),Ro.has(m)&&await me(c,{verbose:Ao});try{let S=pe.has(m)?await Et(c):[];switch(m){case"list":{lt(u.wsPort),await no({bridge:c,simId:x,args:l});break}case"tree":{await uo({bridge:c,args:l,positional:a});break}case"a11y":{let o=await xt(c);if(!Array.isArray(o)||o.length===0){console.log(" no accessible nodes found");break}if(e.includes("--json"))console.log(JSON.stringify(o,null,2));else{console.log(` accessibility tree (${o.length} nodes):
145
- `);for(let s of o){let n=[];if(n.push(`[${s.role}]`),s.label){let i=s.label.length>50?s.label.slice(0,47)+"...":s.label;n.push(`"${i}"`)}if(s.hint&&n.push(`(hint: "${s.hint}")`),s.testID&&n.push(`#${s.testID}`),s.state){let i=[];s.state.disabled&&i.push("disabled"),s.state.selected&&i.push("selected"),s.state.checked===!0&&i.push("checked"),s.state.checked==="mixed"&&i.push("mixed"),s.state.busy&&i.push("busy"),s.state.expanded===!0&&i.push("expanded"),s.state.expanded===!1&&i.push("collapsed"),i.length&&n.push(`{${i.join(", ")}}`)}s.position&&n.push(`@(${s.position.x},${s.position.y})`),s.size&&n.push(`${s.size.w}x${s.size.h}`),console.log(" "+n.join(" "))}}break}case"find":{await to({bridge:c,args:e,effectiveArgs:l,positional:a,inspectUsage:h});break}case"count":{await Zt(c,{args:l});break}case"keyboard":{await so(c,{json:e.includes("--json")});break}case"screens":{await ao(c,{json:e.includes("--json")});break}case"memory":{await io(c,{args:l});break}case"wait":{await po({wsPort:T,commandTimeoutMs:O,simId:x,simIdSource:P,positional:a});break}case"sleep":{await co({positional:a,inspectUsage:h});break}case"settle":{await lo({bridge:c,args:e,positional:a});break}case"ready":{await ho({bridge:c,args:e});break}case"idle":{await yo({bridge:c,args:e,positional:a});break}case"selector":{await bo({bridge:c,args:e,positional:a,inspectUsage:h});break}case"event":{await go({bridge:c,args:e,positional:a,inspectUsage:h});break}case"layout":{let o=a[1];if(!o){await oo({bridge:c,args:l});break}let n=(await ve(c,{testId:o}))?.result;if(n===null||typeof n!="object"||Array.isArray(n)){console.log("null");break}let i=Reflect.get(n,"absolutePosition"),d=Reflect.get(n,"layout");console.log(JSON.stringify(i&&d?{x:Reflect.get(i,"x"),y:Reflect.get(i,"y"),width:Reflect.get(d,"width"),height:Reflect.get(d,"height")}:null,null,2));break}case"capture":case"screenshot":{let s=e.find((v,g)=>e[g-1]==="--output")||"/tmp/sootsim-inspect.png",n=await vo(e,c),i={type:"screenshot"};n&&(i.crop=n);let p=(await c.send(i)).replace(/^data:image\/png;base64,/,"");n&&console.log(` area: x=${n.x} y=${n.y} w=${n.w} h=${n.h}`),(await import("fs")).writeFileSync(s,Buffer.from(p,"base64")),console.log(` saved: ${s}`);break}case"sample-color":{let o=await vo(e,c);o||(console.error(h("sample-color","<x> <y> [w] [h] | --id <testID> | --text <text>")),console.error(" samples an averaged color from the canvas. coords are logical rnx units."),y(1));let s=await c.send({type:"evaluate",code:qt(o)});if(e.includes("--json"))console.log(JSON.stringify(s,null,2));else{let{r:n,g:i,b:d,a:p,hex:f,samples:v}=s,g=o.w===1&&o.h===1?`@(${o.x},${o.y})`:`@(${o.x},${o.y}) ${o.w}x${o.h}`;console.log(` ${f} rgba(${n}, ${i}, ${d}, ${p}) ${g} ${v} samples`)}break}case"node":{let o=a[1];o||(console.error(h("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),y(1));let s=await c.send({type:"evaluate",code:`(async () => {
146
- const t = window.__sootsimTest
147
- const q = ${JSON.stringify(o)}
148
- let node = null
149
- let via = null
150
- if (t.findByTestId) { node = await t.findByTestId(q); if (node) via = 'testID' }
151
- if (!node && t.findById) { node = await t.findById(q); if (node) via = 'id' }
152
- if (!node && t.findByText) { node = await t.findByText(q); if (node) via = 'text' }
153
- if (!node) return { matcher: q, found: false }
154
-
155
- // read the resolved transform (if any) off the style \u2014 useful
156
- // because canvas nodes often animate via transform and describe
157
- // output strips that.
158
- const transform =
159
- node.style && Array.isArray(node.style.transform)
160
- ? node.style.transform
161
- : node.style && node.style.transform
162
- ? node.style.transform
163
- : null
164
-
165
- // parent chain \u2014 walk up from the node so the JSON dump is
166
- // self-describing.
167
- const parentChain = []
168
- const root = window.__sootsimRoot
169
- if (root && node.id != null) {
170
- const findPath = (n, targetId, path) => {
171
- if (!n) return null
172
- if (n.id === targetId) return path
173
- if (n.children) {
174
- for (const child of n.children) {
175
- const nextPath = [
176
- ...path,
177
- {
178
- type: n.type || 'view',
179
- testID: n.props?.testID || null,
180
- text: n.text || null,
181
- },
182
- ]
183
- const found = findPath(child, targetId, nextPath)
184
- if (found) return found
185
- }
186
- }
187
- return null
188
- }
189
- const chain = findPath(root, node.id, [])
190
- if (chain) parentChain.push(...chain)
191
- }
192
-
193
- return {
194
- matcher: q,
195
- found: true,
196
- resolvedVia: via,
197
- node,
198
- transform,
199
- parentChain,
200
- }
201
- })()`});console.log(JSON.stringify(s,null,2));break}case"tap":{let o=Number(a[1]),s=Number(a[2]),n=he(e,a);if(n){let p=await Bt(c,{agent:de(),textFallback:n.mode==="text"?n.value:void 0,resolve:async()=>{let g=await Fe(c,n);return g?{cx:g.x,cy:g.y,match:{testID:n.mode==="testid"?n.value:g.testID??null,text:n.mode==="text"?n.value:g.text??null,type:g.type??null},target:{testID:g.testID??null,text:g.text??null,type:g.type??null}}:null}}),f=p.payload;(!f||typeof f.cx!="number")&&(console.error(` not found: ${n.value}`),n.mode==="testid"&&X("wait-selector-for-missing-testid",n.value),y(1)),ye(p.result)||(_(`${n.mode} "${n.value}"`,p),y(1));let v=Fo(f.cx,f.cy,p.result);v&&await q("inspect tap",v.step,v.summary),console.log(JSON.stringify({...p.attempts>1?{attempts:p.attempts}:{},...p.result},null,2));break}(!Number.isFinite(o)||!Number.isFinite(s))&&(console.error(h("tap","<testid> | <x> <y> | --testid <id> | --text <t>")),y(1));let i=await Ct(c,o,s),d=Fo(o,s,i);d&&await q("inspect tap",d.step,d.summary),console.log(JSON.stringify(i,null,2));break}case"drag":case"swipe":{let o=Number(a[1]),s=Number(a[2]),n=Number(a[3]),i=Number(a[4]),d=m==="swipe"?10:12,p=m==="swipe"?8:16,f=a[5]?Number(a[5]):d,v=a[6]?Number(a[6]):p;(!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(f)||!Number.isFinite(v))&&(console.error(h(m,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),y(1));let g=await $e(c,{type:"drag",fromX:o,fromY:s,toX:n,toY:i,steps:Math.max(1,Math.round(f)),stepMs:Math.max(0,Math.round(v))});if(g?.ok){let N=Math.max(1,Math.round(Math.max(1,f)*Math.max(0,v)));await q(`inspect ${m}`,{swipe:{start:`${o}, ${s}`,end:`${n}, ${i}`,duration:N}},`${m} ${o},${s} -> ${n},${i}`)}console.log(JSON.stringify(g,null,2));break}case"pinch":{let o=Number(a[1]),s=Number(a[2]),n=Number(a[3]),i=Number(a[4]),d=Number(a[5]),p=Number(a[6]),f=Number(a[7]),v=Number(a[8]),g=a[9]?Number(a[9]):12,N=a[10]?Number(a[10]):16;(!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(d)||!Number.isFinite(p)||!Number.isFinite(f)||!Number.isFinite(v)||!Number.isFinite(g)||!Number.isFinite(N))&&(console.error(h("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),y(1));let J=await $e(c,{type:"pinch",fromX1:o,fromY1:s,fromX2:n,fromY2:i,toX1:d,toY1:p,toX2:f,toY2:v,steps:Math.max(1,Math.round(g)),stepMs:Math.max(0,Math.round(N))});J?.ok&&await q("inspect pinch",{pinch:{from:[o,s,n,i],to:[d,p,f,v],steps:Math.max(1,Math.round(g)),stepMs:Math.max(0,Math.round(N))}},`pinch (${o},${s}) (${n},${i}) -> (${d},${p}) (${f},${v})`),console.log(JSON.stringify(J,null,2));break}case"tap-text":{let o=a[1];o||(console.error(h("tap-text","<text>")),y(1));let s=z=>{let L=e.indexOf(z);return L>=0&&L+1<e.length?e[L+1]:null},n=z=>e.includes(z),i=s("--nth")??s("--index"),d=i!==null?Number(i):null;d!==null&&!Number.isFinite(d)&&(console.error(` --nth/--index requires an integer, got: ${i}`),y(1));let p=s("--within"),f=s("--role"),v=n("--exact"),g=n("--first"),N=s("--min-y"),J=s("--max-y"),Y=s("--min-x"),K=s("--max-x");for(let[z,L]of[["--min-y",N],["--max-y",J],["--min-x",Y],["--max-x",K]])L!==null&&!Number.isFinite(Number(L))&&(console.error(` ${z} requires a number, got: ${L}`),y(1));let U=e.indexOf("--near"),R=null;if(U>=0){let z=Number(e[U+1]),L=Number(e[U+2]);(!Number.isFinite(z)||!Number.isFinite(L))&&(console.error(" --near requires two numbers: --near <x> <y>"),y(1)),R={x:z,y:L}}let k={exact:v,role:f,within:p,minX:Y!==null?Number(Y):null,maxX:K!==null?Number(K):null,minY:N!==null?Number(N):null,maxY:J!==null?Number(J):null,near:R,nth:d,first:g},I=await Lt(c,o,k,{agent:de()}),E=I.payload;if(E?.error==="bridge-not-ready"&&(console.error(" rnx test bridge not ready"),y(1)),E?.ambiguous){let z=E.candidates;console.error(` ambiguous: ${E.total} matches for "${o}"`);for(let L of z){let xe=L.abs?`@(${Math.round(L.abs.x)},${Math.round(L.abs.y)})`:"",Po=L.layout?` ${L.layout.width}x${L.layout.height}`:"",_o=L.testID?` #${L.testID}`:"",jo=L.text?` "${L.text}"`:"",Bo=L.ancestorTestIDs.length>0?` within ${L.ancestorTestIDs.slice(0,3).map(Co=>`#${Co}`).join(" > ")}`:"";console.error(` [${L.idx}] <${L.type}>${jo}${_o} ${xe}${Po}${Bo}`)}E.total>z.length&&console.error(` ... and ${E.total-z.length} more`),console.error(" pick one:"),console.error(" --nth <index> pick the nth match (top-to-bottom, left-to-right; negatives from end)"),console.error(" --within <testID> narrow to descendants of a node"),console.error(" --min-y / --max-y geometric filter (pixels, absolute)"),console.error(" --min-x / --max-x geometric filter (pixels, absolute)"),console.error(" --near <x> <y> pick the closest match to a point"),console.error(" --exact exact text match (default is substring)"),console.error(" --role <role> narrow to accessibilityRole"),console.error(" --first keep the old pick-first-silently behavior"),y(2)}E?.nthOutOfRange&&(console.error(` not found: nth ${E.nth} of ${E.total} match${E.total===1?"":"es"} for "${o}"`),y(1)),(!E||typeof E.cx!="number")&&(console.error(` not found: ${o}`),y(1)),ye(I.result)||(_(`text "${o}"`,I),y(1));let ee=et(o,{id:E.target?.id??null,testID:E.target?.testID??null,type:E.target?.type??null,cx:E.cx,cy:E.cy},"text");await q("inspect tap-text",ee.step,ee.summary),console.log(JSON.stringify({matched:E.match,tapped:{nodeId:E.target?.nodeId??null,id:E.target?.id??null,testID:E.target?.testID??null,type:E.target?.type??null,cx:E.cx,cy:E.cy},...E.strategy&&E.strategy!=="matched-node"?{strategy:E.strategy}:{},...E.total>1||d!==null?{nth:{index:E.idx,total:E.total}}:{},...I.attempts>1?{attempts:I.attempts}:{},result:I.result},null,2));break}case"tap-best":{let o=a[1];o||(console.error(h("tap-best","<query>")),y(1));let s=await Wt(c,o,{agent:de()}),n=s.payload;n||(console.error(` tap-best: no testID or visible text matched "${o}". try \`rnx find --interactive-targets\` to list candidates.`),y(1)),"error"in n&&(console.error(` ${n.error}`),y(1)),n.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${o}". try \`rnx find --interactive-targets\` to list candidates.`),y(1));let i=n.node;ye(s.result)||(_(`best "${o}"`,s),y(1));let d=et(o,{id:i.id,testID:i.testID,type:i.type,cx:n.cx,cy:n.cy},n.strategy==="testid"?"id":"text");await q("inspect tap-best",d.step,d.summary),console.log(JSON.stringify({matched:{strategy:n.strategy,nodeId:i.nodeId,id:i.id,testID:i.testID,type:i.type,text:i.text},tapped:{cx:n.cx,cy:n.cy},...s.attempts>1?{attempts:s.attempts}:{},result:s.result},null,2));break}case"tap-id":{let o=a[1];o||(console.error(h("tap-id","<id>")),y(1));let s=await Dt(c,o,{agent:de()}),n=s.payload;(!n||typeof n.cx!="number")&&(console.error(` not found: ${o}`),await fs(c,o),y(1)),ye(s.result)||(_(`id "${o}"`,s),y(1));let i=et(o,{id:n.target?.id??null,testID:n.target?.testID??null,type:n.target?.type??null,cx:n.cx,cy:n.cy},"id");await q("inspect tap-id",i.step,i.summary),console.log(JSON.stringify({matched:n.match,tapped:{nodeId:n.target?.nodeId??null,id:n.target?.id??null,testID:n.target?.testID??null,type:n.target?.type??null,cx:n.cx,cy:n.cy},...n.strategy&&n.strategy!=="matched-node"?{strategy:n.strategy}:{},...s.attempts>1?{attempts:s.attempts}:{},result:s.result},null,2));break}case"type-into":{let o=a[1],s=a.slice(2).join(" ");(!o||!s)&&(console.error(h("type-into","<id> <text>")),y(1));let n=JSON.stringify(o),i=await c.send({type:"evaluate",code:`(async () => {
202
- const t = window.__sootsimTest
203
- if (!t) return null
204
- const n = await (t.findByTestId(${n}) || t.findById(${n}))
205
- if (!n || !n.absolutePosition || !n.layout) return null
206
- return {
207
- cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
208
- cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
209
- id: n.id,
210
- testID: n.testID,
211
- type: n.type,
212
- isTextInput: !!n.isTextInput,
213
- secureTextEntry: !!n.secureTextEntry,
214
- placeholder: n.placeholder || null,
215
- }
216
- })()`});(!i||typeof i.cx!="number")&&(console.error(` not found: ${o}`),y(1)),i.isTextInput||console.error(` warning: ${o} is not a text input (isTextInput: false)`);let d=await c.send({type:"tap",x:i.cx,y:i.cy,target:{id:i.id??o,testID:i.testID??o,text:null,type:i.type??null}}),p=i.secureTextEntry===!0,f=await ks(c,1e3,{targetId:o,secureTextEntry:p});f.visible||(console.error(` keyboard did not open after tapping ${o}`),y(1));let v=f.focusedInput;v&&(v.testID===o||v.id===o||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(o)} but focus is on ${JSON.stringify(v.testID??v.id??null)}. did the tap land on an outer Pressable wrapper?`),y(1))),await c.send({type:"keyboard",action:"type",text:s});let g=p||we(f),N=g?Q:Qe(s,f),J=g&&f.focusedInput?{...f.focusedInput,secureTextEntry:!0,text:typeof f.focusedInput.text=="string"?Q:f.focusedInput.text}:f.focusedInput??null;await q("inspect type-into",{tapOn:{id:o},inputText:N},N===Q?`type-into #${o} ${Q}`:`type-into #${o} ${JSON.stringify(s)}`),console.log(JSON.stringify({target:o,isTextInput:i.isTextInput,secureTextEntry:g,keyboardOpened:f.visible??d?.keyboardOpened??!1,focusedInput:J,typed:N},null,2));break}case"type":{let o=a.slice(1).join(" ");o||(console.error(h("type","<text>")),y(1));let s=await Pe(c,"type");await c.send({type:"keyboard",action:"type",text:o});let n=Qe(o,s);await q("inspect type",{inputText:n},n===Q?`type ${Q}`:`type ${JSON.stringify(o)}`),console.log(n===Q?` typed: ${Q}`:` typed: ${JSON.stringify(o)}`);break}case"key":{let o=a[1];o||(console.error(h("key","<name>")),y(1)),await Pe(c,"key"),await c.send({type:"keyboard",action:"press",text:o}),await q("inspect key",{pressKey:o},`key ${o}`),console.log(` pressed: ${o}`);break}case"key-sequence":{let o=a.slice(1);o.length===0&&(console.error(h("key-sequence","<key> [<key> ...]")),y(1)),await Pe(c,"key-sequence");for(let s of o)await c.send({type:"keyboard",action:"press",text:s});await q("inspect key-sequence",{pressKey:o.join(" ")},`key-sequence ${o.join(" ")}`),console.log(` pressed: ${o.join(", ")}`);break}case"keycode":{let o=a.slice(1);o.length===0&&(console.error(h("keycode","<code> [<code> ...]")),y(1));let s=o.map(i=>({code:i,key:vs(i)})),n=s.filter(i=>!i.key);n.length>0&&(console.error(` unsupported keycode(s): ${n.map(i=>i.code).join(", ")}`),y(1)),await Pe(c,"keycode");for(let i of s)await c.send({type:"keyboard",action:"press",text:i.key});await q("inspect keycode",{pressKey:s.map(i=>i.key).join(" ")},`keycode ${o.join(" ")}`),console.log(` pressed: ${o.join(", ")}`);break}case"dispatch":{let o=a[1];o||(console.error(h("dispatch","<char>")),y(1)),await c.send({type:"keyboard",action:"dispatchKey",text:o}),await q("inspect dispatch",{dispatchKey:o},`dispatch ${JSON.stringify(o)}`),console.log(` dispatched: ${o}`);break}case"dismiss":{await c.send({type:"keyboard",action:"dismiss"}),await q("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let o=Number(a[1]),s=Number(a[2]),n=he(e,a);if(n){let v=await Fe(c,n);v||(console.error(` not found: ${n.value}`),n.mode==="testid"&&X("wait-selector-for-missing-testid",n.value),y(1)),o=v.x,s=v.y}let i=a[3]?Number(a[3]):80;(!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(i))&&(console.error(h("double-tap","<testid> | <x> <y> [gapMs] | --testid <id>")),y(1));let d=Math.max(0,Math.round(i)),f={...await $e(c,{type:"doubleTap",x:o,y:s,gapMs:d}),gapMs:d};f?.ok&&await q("inspect double-tap",{doubleTapAtCoords:{x:o,y:s,gapMs:d}},`double-tap @${o},${s}`),console.log(JSON.stringify(f,null,2));break}case"long-press":{let o=Number(a[1]),s=Number(a[2]),n=he(e,a),i=null;if(n){let g=await Fe(c,n);g||(console.error(` not found: ${n.value}`),n.mode==="testid"&&X("wait-selector-for-missing-testid",n.value),y(1)),o=g.x,s=g.y,i={testID:g.testID??null,text:g.text??null,type:g.type??null}}let d=n?a[1]:a[3],p=d?Number(d):600;(!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(p))&&(console.error(h("long-press","<testid> | <x> <y> [durationMs] | --testid <id>")),y(1));let f=Math.max(0,Math.round(p)),v=await c.send({type:"longPress",x:o,y:s,durationMs:f,target:i});v?.ok&&await q("inspect long-press",{tapAtCoords:{x:o,y:s}},`long-press @${o},${s}`),console.log(JSON.stringify(v,null,2));break}case"touch":{let o=a[1],s=Number(a[2]),n=Number(a[3]),i=a[4]?Number(a[4]):999,d=o==="down"?"touchDown":o==="move"?"touchMove":o==="up"?"touchUp":o==="cancel"?"touchCancel":null;d||(console.error(h("touch","<down|move|up|cancel> <x> <y> [pointerId]")),y(1)),o!=="cancel"&&(!Number.isFinite(s)||!Number.isFinite(n))&&(console.error(h("touch","<down|move|up|cancel> <x> <y> [pointerId]")),y(1));let p=Math.max(1,Math.round(i)),f=await $e(c,d==="touchCancel"?{type:d,pointerId:p}:{type:d,x:s,y:n,pointerId:p});f?.ok&&o!=="cancel"&&await q("inspect touch",{tapAtCoords:{x:s,y:n}},`touch ${o} @${s},${n}`),console.log(JSON.stringify(f,null,2));break}case"gesture":{let o=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],s=a[1],n=a[2]?Number(a[2]):220;(!s||!Number.isFinite(n))&&(console.error(h("gesture","<preset> [durationMs]")),console.error(` presets: ${o.join(", ")}`),y(1)),o.includes(s)||(console.error(` unknown gesture preset: ${s}`),console.error(` presets: ${o.join(", ")}`),y(1));let i=await c.send({type:"evaluate",code:`(async () => {
217
- const spec = globalThis.__sootsimDeviceSpec || {}
218
- return {
219
- width: spec.width || window.innerWidth || 393,
220
- height: spec.height || window.innerHeight || 852,
221
- statusBarHeight: spec.statusBarHeight || 0,
222
- homeIndicatorHeight: spec.homeIndicatorHeight || 0,
223
- }
224
- })()`}),d=Number(i?.width)||393,p=Number(i?.height)||852,f=Number(i?.statusBarHeight)||0,v=Number(i?.homeIndicatorHeight)||0,g=Math.round(d/2),N=Math.round(p/2),J=Math.max(24,f+18),Y=Math.max(24,v+18),K=18,U=Math.min(220,Math.round(p*.24)),R=Math.min(180,Math.round(d*.32)),k=g,I=N,E=g,ee=N;switch(s){case"scroll-up":I=N+Math.round(U/2),ee=N-Math.round(U/2);break;case"scroll-down":I=N-Math.round(U/2),ee=N+Math.round(U/2);break;case"scroll-left":k=g+Math.round(R/2),E=g-Math.round(R/2);break;case"scroll-right":k=g-Math.round(R/2),E=g+Math.round(R/2);break;case"swipe-from-left-edge":k=K,I=N,E=Math.min(d-K,K+R);break;case"swipe-from-right-edge":k=d-K,I=N,E=Math.max(K,d-K-R);break;case"swipe-from-top-edge":k=g,I=J,ee=Math.min(p-Y,J+U);break;case"swipe-from-bottom-edge":k=g,I=p-Y,ee=Math.max(J,p-Y-U);break}let z=Math.max(8,Math.round(n/16)),L=Math.max(1,Math.round(n/z)),xe=await $e(c,{type:"drag",fromX:k,fromY:I,toX:E,toY:ee,steps:z,stepMs:L});xe?.ok&&await q("inspect gesture",{swipe:{start:`${k}, ${I}`,end:`${E}, ${ee}`,duration:Math.max(1,Math.round(n))}},`gesture ${s}`),console.log(JSON.stringify({preset:s,from:{x:k,y:I},to:{x:E,y:ee},result:xe},null,2));break}case"scroll":{let o=he(e),s=Is(e),n=o?.mode==="testid"?o.value:s==null?a[1]:null,i=o||s!=null?1:2,d=Number(a[i]),p=Number(a[i+1]);(!n&&s==null||!Number.isFinite(d)||!Number.isFinite(p))&&(console.error(h("scroll","<id> <x> <y> | --testid <id> <x> <y> | --node-id <nodeId> <x> <y>")),y(1));let f=await c.send({type:"evaluate",code:`(async () => {
225
- const t = window.__sootsimTest
226
- if (!t) return null
227
- const n = ${s!=null?`await t.inspectByNodeId(${JSON.stringify(s)})`:`await t.findByTestId(${JSON.stringify(n)})
228
- || await t.findById(${JSON.stringify(n)})`}
229
- if (!n || !n.absolutePosition || !n.layout) return null
230
- return {
231
- cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
232
- cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
233
- }
234
- })()`}),v=await G(c,"scrollTo",s!=null?{nodeId:s}:n,d,p,!1);if(v?.ok){let g=s!=null?`node ${s}`:`#${n}`;await q("inspect scroll",{scrollTo:{...s!=null?{nodeId:s}:{id:n},x:d,y:p}},`scroll ${g} -> ${d},${p}`)}console.log(JSON.stringify({...v,...f?{at:{x:f.cx,y:f.cy}}:{}},null,2));break}case"state":{let o=a[1];if(r==="get"&&!o){let n=await G(c,"getRuntimeState"),i=await c.send({type:"evaluate",code:Ne});if(n&&typeof n=="object"&&n.diagnostics&&(n.diagnostics.errors=i?.errors??0,n.diagnostics.warnings=i?.warnings??0),n&&typeof n=="object"&&n.shell==null)try{let d=await ue(c);d&&(n.shell=d)}catch{}console.log(JSON.stringify(n,null,2));break}if(!o||o==="--help"||o==="-h"){console.log(`
235
- ${w("state")} \u2014 dump raw runtime state
236
-
237
- subcommands:
238
- shell dump shell transition/layout state
239
- worker dump render-worker host/animation state
240
- keyboard dump keyboard visibility, mode, and focused input
241
- ownership dump surface ownership + pointerOnSurface delivery stats
242
- worklets dump tenant + shell worklet-runtime slot/handler counts
243
- scroll-input dump shell-owned scroll gesture and momentum state
244
- scroll-mirror dump shell scroll registry entries and offsets
245
- node <id> dump raw node info by id or testID
246
- scroll <id> dump scroll metrics and runtime state
247
- scroll-hit <x> <y> dump the nearest scroll ancestor at coordinates
248
- hit <x> <y> dump the hit-test ancestry at coordinates
249
- gesture <x> <y> dump gesture routing/debug info at coordinates
250
- gesture-seam dump shell-hosted gesture recognizer state/events
251
-
252
- examples:
253
- ${w("state")} shell
254
- ${w("state")} worker
255
- ${w("state")} keyboard
256
- ${w("state")} ownership
257
- ${w("state")} worklets
258
- ${w("state")} scroll-input
259
- ${w("state")} scroll-mirror
260
- ${w("state")} node photos
261
- ${w("state")} scroll feed
262
- ${w("state")} scroll-hit 360 420
263
- ${w("state")} hit 200 720
264
- `);break}let s;switch(o){case"shell":s=await ue(c,500);break;case"worker":s=await le(c,"__sootsimRenderHost.queryStats");break;case"ownership":s=await c.send({type:"evaluate",code:`(() => {
265
- const h = window.__sootsimRenderHost
266
- if (!h || typeof h.getOwnershipSnapshot !== 'function') {
267
- return { error: 'getOwnershipSnapshot not available' }
268
- }
269
- return h.getOwnershipSnapshot()
270
- })()`});break;case"keyboard":s=await c.send({type:"evaluate",code:`(async () => {
271
- const kb = window.__sootsimKeyboard
272
- const test = window.__sootsimTest
273
- if (!kb) return { error: 'keyboard bridge not available' }
274
- const layout = typeof kb.getLayout === 'function' ? kb.getLayout() : null
275
- const secureTextEntry =
276
- !!layout?.spec?.secureTextEntry && layout?.spec?.keyboardType !== 'visible-password'
277
- const visible = kb.isVisible()
278
- const mode = kb.getMode()
279
- let focused = null
280
- if (test && typeof test.getFocusedNode === 'function') {
281
- try {
282
- focused = await test.getFocusedNode()
283
- } catch {}
284
- }
285
- return {
286
- visible,
287
- mode,
288
- layout,
289
- focusedInput: focused ? {
290
- nodeId: focused.nodeId ?? null,
291
- testID: focused.testID || null,
292
- id: focused.id || null,
293
- placeholder: focused.placeholder || null,
294
- secureTextEntry,
295
- text: secureTextEntry ? ${JSON.stringify(Q)} : (focused.text || null),
296
- } : null,
297
- }
298
- })()`}),s=Ze(s);break;case"node":{let n=a[2];n||(console.error(` usage: ${w("state")} node <id>`),y(1)),s=await G(c,"findByTestId",n)||await G(c,"findById",n);break}case"scroll":{let n=a[2];n||(console.error(` usage: ${w("state")} scroll <id>`),y(1)),s=await G(c,"getScrollState",n);break}case"scroll-hit":{let n=Number(a[2]),i=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(i))&&(console.error(` usage: ${w("state")} scroll-hit <x> <y>`),y(1)),s=await G(c,"getScrollStateAt",n,i);break}case"hit":{let n=Number(a[2]),i=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(i))&&(console.error(` usage: ${w("state")} hit <x> <y>`),y(1)),s=await G(c,"debugHitAt",n,i);break}case"gesture":{let n=Number(a[2]),i=Number(a[3]);(!Number.isFinite(n)||!Number.isFinite(i))&&(console.error(` usage: ${w("state")} gesture <x> <y>`),y(1)),s=await G(c,"debugGestureAt",n,i);break}case"gesture-seam":s=await le(c,"SootSim.bridges.mainShell.callTestBridge","getShellGestureSeamDebug");break;case"worklets":{let[n,i]=await Promise.all([G(c,"getWorkletSlotStats"),le(c,"SootSim.bridges.mainShell.callTestBridge","getWorkletSlotStats")]);s={tenant:n,shell:i};break}case"scroll-input":s=await le(c,"SootSim.bridges.mainShell.callTestBridge","getShellScrollInputDebug");break;case"scroll-mirror":s=await le(c,"SootSim.bridges.mainShell.callTestBridge","getScrollMirrorDebug");break;default:console.error(` unknown state subcommand: ${o}`),y(1)}console.log(JSON.stringify(s,null,2));break}case"shell":{let o=a[1];if(!o||o==="--help"||o==="-h"){console.log(`
299
- ${w("shell")} \u2014 run built-in shell commands
300
-
301
- subcommands:
302
- launch <appId> [waitMs] [--clear-state]
303
- launch app and wait for settled shell state
304
- home [waitMs] go home and wait for settled shell state
305
- switcher [waitMs] open switcher and wait for settled shell state
306
- open-card <appId> [waitMs]
307
- open a specific switcher card and wait for app settle
308
- appearance <light|dark|auto|toggle>
309
- update simulator appearance
310
- lock toggle device lock state
311
- shake trigger the simulator shake gesture
312
-
313
- examples:
314
- ${w("shell")} launch photos
315
- ${w("shell")} launch rn --clear-state
316
- ${w("shell")} launch photos 1500
317
- ${w("shell")} home 500
318
- ${w("shell")} switcher 800
319
- ${w("shell")} open-card clock 800
320
- ${w("shell")} appearance dark
321
- ${w("shell")} lock
322
- `);break}let s=o==="launch"||o==="open-card"||o==="home"||o==="switcher",n=o==="launch"||o==="open-card"?a[3]:a[2],i=n?Number(n):350;s&&(!Number.isFinite(i)||i<0)&&(console.error(h("shell",o==="launch"||o==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),y(1));let d=!1,p=!1,f=null,v=e.includes("--clear-state");if(o==="launch"){let g=a[2];g||(console.error(h("shell","launch <appId> [settleMs] [--clear-state]")),y(1)),v&&await c.send({type:"evaluate",code:Je(!0)}),d=!!await ge(c,"launchApp",i,g),{settled:p,state:f}=await Ae(c,Math.round(i),N=>!!N&&N.state==="app"&&N.activeApp===g&&N.showSwitcher===!1&&N.switcherPhase==="idle"&&typeof N.launchProgress=="number"&&N.launchProgress>=.98),d&&await q("inspect shell launch",v?{launchApp:{clearState:!0}}:{launchApp:{}},v?"launch app (clear state)":"launch app")}else if(o==="home")d=!!await ge(c,"goHome",i),{settled:p,state:f}=await Ae(c,Math.round(i),g=>!!g&&g.state==="home"&&g.activeApp==null&&g.showSwitcher===!1&&g.switcherPhase==="idle"&&typeof g.launchProgress=="number"&&g.launchProgress>=.98);else if(o==="switcher")d=!!await ge(c,"openSwitcher",i),{settled:p,state:f}=await Ae(c,Math.round(i),g=>!!g&&g.state==="app"&&g.showSwitcher===!0&&g.switcherPhase==="idle"&&typeof g.zoomLevel=="number"&&Math.abs(g.zoomLevel)<=.02&&typeof g.horizontalZoom=="number"&&Math.abs(g.horizontalZoom)<=.02),p&&(await Z(xs),f=await ue(c));else if(o==="open-card"){let g=a[2];g||(console.error(h("shell","open-card <appId> [settleMs]")),y(1)),d=!!await ge(c,"openSwitcherCard",i,g),{settled:p,state:f}=await Ae(c,Math.round(i),N=>!!N&&N.state==="app"&&N.activeApp===g&&N.showSwitcher===!1&&N.switcherPhase==="idle"&&typeof N.zoomLevel=="number"&&N.zoomLevel>=.98&&typeof N.horizontalZoom=="number"&&N.horizontalZoom>=.98),d&&await q("inspect shell open-card",{openSwitcherCard:{appId:g}},`open switcher card ${g}`)}else if(o==="appearance"){let g=a[2];(!g||!["light","dark","auto","toggle"].includes(g))&&(console.error(h("shell","appearance <light|dark|auto|toggle>")),y(1));let N=await Mo(c,"appearance",g);if(d=!!N?.ok,f={appearance:N},d){let J=N?.applied??g;console.log(` appearance: ${J}`)}}else if(o==="lock"||o==="shake"){let g=await Mo(c,o);d=!!g?.ok,f={[o]:g}}else console.error(` unknown shell subcommand: ${o}`),y(1);console.log(JSON.stringify({ok:d,settled:p,state:f},null,2));break}case"url":{await mo(c,{args:l});break}case"reload":{let s=!1,n=!1;try{await c.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let p=await c.send({type:"evaluate",code:`;(async () => {
323
- // in-place guest reload is only valid while the page still runs
324
- // the engine build the server would serve NOW. the shell dev
325
- // server has no HMR client, so a long-lived sim tab otherwise
326
- // keeps a stale engine forever while builds churn underneath it.
327
- // compare the inlined engine manifest against a fresh fetch of
328
- // this page's html; any drift means the whole page must reload.
329
- let engineStale = false
330
- try {
331
- const loaded = document.getElementById('__sootsim-engine-manifest')?.textContent
332
- if (loaded) {
333
- const res = await fetch(location.href, { cache: 'no-store' })
334
- const html = await res.text()
335
- const m = html.match(/<script[^>]*id="__sootsim-engine-manifest"[^>]*>([^<]*)<\\/script>/)
336
- if (m && m[1] !== loaded) engineStale = true
337
- }
338
- } catch {}
339
- const reloadExternalApp = window.SootSim?.bridges?.hotRemount?.reloadExternalApp
340
- if (!engineStale && typeof reloadExternalApp === 'function') {
341
- reloadExternalApp()
342
- return { kind: 'external-app' }
343
- }
344
- window.location.reload()
345
- return { kind: 'page', engineStale }
346
- })()`});n=!!p&&p.kind==="external-app",s=!0,p&&p.engineStale&&console.log(" engine build changed since page load \u2014 full page reload")}catch{}console.log(" reloading...");let i=c,d=null;if(n)d=await Me(c,{timeoutMs:1e4});else{s&&await Z(300);let f=await Pt(T,O,x,{timeoutMs:3e4,simIdSource:P});f?(i=f,d=await Me(f,{timeoutMs:3e4})):(console.log(" \u26A0 reload: bridge never reconnected within 30000ms"),i=null)}if(d)if(d.ready){let p=d.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${d.elapsedMs}ms: ${d.nodes} nodes${p}`)}else if(d.source==="error-bail")console.log(` \u26A0 reload bailed after ${d.elapsedMs}ms: ${d.errors} console error(s), ready signal never fired`);else{let p=$o(d);console.log(` \u26A0 reload timed out after ${d.elapsedMs}ms \u2014 ${p} (nodes: ${d.nodes}, targets: ${d.targets}, errors: ${d.errors})`)}if(i)try{let p=await fe(i,10);if(i!==c&&i.close(),Array.isArray(p)&&p.length>0){console.log(`
347
- \u26A0 ${p.length} error(s) during mount:
348
- `);for(let f of p){let v=f.args.map(g=>typeof g=="object"?JSON.stringify(g):g).join(" ");if(console.log(` ${v}`),f.stack){let g=f.stack.split(`
349
- `).slice(0,2);for(let N of g)console.log(` ${N.trim()}`)}}}}catch{}d&&!d.ready&&(process.exitCode=1);break}case"storage-clear":{if(await Le(c),await c.send({type:"evaluate",code:Je(!0)})!==!0){D(l)?C({cleared:!1,ready:!1,error:"external app reload bridge is unavailable"}):console.error(" storage clear failed: external app reload bridge is unavailable"),process.exitCode=1;break}let n=await Me(c,{timeoutMs:1e4});if(D(l)){C({cleared:!0,ready:n.ready,reload:n}),n.ready||(process.exitCode=1);break}if(n.ready){let i=n.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` cleared tenant storage; ready in ${n.elapsedMs}ms: ${n.nodes} nodes${i}`)}else if(n.source==="error-bail")console.log(` \u26A0 storage clear reloaded but bailed after ${n.elapsedMs}ms: ${n.errors} console error(s), ready signal never fired`);else{let i=$o(n);console.log(` \u26A0 storage clear reloaded but timed out after ${n.elapsedMs}ms \u2014 ${i} (nodes: ${n.nodes}, targets: ${n.targets}, errors: ${n.errors})`)}try{let i=await fe(c,10);if(Array.isArray(i)&&i.length>0){console.log(`
350
- \u26A0 ${i.length} error(s) during mount:
351
- `);for(let d of i){let p=d.args.map(f=>typeof f=="object"?JSON.stringify(f):f).join(" ");if(console.log(` ${p}`),d.stack){let f=d.stack.split(`
352
- `).slice(0,2);for(let v of f)console.log(` ${v.trim()}`)}}}}catch{}n.ready||(process.exitCode=1);break}case"js":{let o=a.slice(1).join(" ");if(o||(console.error(h("js","<javascript>")),console.error(""),console.error(" runs the snippet in the engine realm. SootSim is the"),console.error(" canonical state surface \u2014 reach into it directly."),console.error(""),console.error(" examples:"),console.error(` ${w("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${w("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${w("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${w("js")} SootSim.state.root.children.length`),y(1)),e.includes("--tenant")){let p=a.slice(1).filter(v=>v!=="--tenant").join(" "),f=await c.send({type:"evaluate",code:`(async () => SootSim.bridges.test.evalInTenant(${JSON.stringify(p)}))()`});console.log(JSON.stringify(f,null,2));break}let s=o;s.startsWith("(async")||(s=`(async () => ${s})()`);let n=await c.send({type:"evaluate",code:s});console.log(JSON.stringify(n,null,2));let i=o.toLowerCase(),d=[];(i.includes("sootsim:gohome")||i.includes("gohome"))&&d.push("rnx shell home"),(i.includes("sootsim:appswitcher")||i.includes("appswitcher"))&&d.push("rnx shell switcher"),(i.includes("keyboard.isvisible")||i.includes("keyboard.getmode"))&&d.push("rnx debug state keyboard"),i.includes("interact.tap")&&d.push("rnx do tap <x> <y>"),i.includes("keyboard.type")&&d.push("rnx do type <text>"),(i.includes("keyboard.press")||i.includes("keyboard.dispatchkey"))&&d.push("rnx do key <name>"),i.includes("keyboard.dismiss")&&d.push("rnx do dismiss"),i.includes("dumptree")&&d.push("rnx get tree"),i.includes("dumpaccessibilitytree")&&d.push("rnx get a11y"),i.includes("getnodecount")&&d.push("rnx get count"),i.includes("findbytext")&&d.push("rnx find <text>"),(i.includes("findbytestid")||i.includes("findbyid"))&&d.push("rnx find --testid <id>"),i.includes("document.hidden")&&d.push("rnx debug state keyboard (includes tab health)"),d.length>0&&X("prefer-cli-over-eval",d);break}case"globals":{let o=await c.send({type:"evaluate",code:`(async () => {
353
- const globals = {}
354
-
355
- // test bridge (proxy in worker mode)
356
- const testMethods = [
357
- 'findById', 'findByTestId', 'findByText', 'findByLabel', 'findByRole',
358
- 'findAllByRole', 'findByA11yState', 'findAllByA11yState', 'findByHint',
359
- 'findPressable', 'getStyle', 'getLayout', 'getAbsolutePosition', 'isVisible',
360
- 'queryAll', 'dumpTree', 'dumpAccessibilityTree', 'getNodeCount', 'getShellState',
361
- 'getScrollState', 'getScrollStateAt', 'scrollTo', 'waitForTree',
362
- 'waitForScreenTransitions', 'debugByText', 'debugByTestId', 'debugHitAt',
363
- 'debugGestureAt'
364
- ]
365
- globals['test (\u2192 __sootsimTest)'] = testMethods
366
-
367
- // debug
368
- if (window.__sootsimDebug) {
369
- globals['debug (\u2192 __sootsimDebug)'] = Object.keys(window.__sootsimDebug)
370
- }
371
-
372
- // interact
373
- if (window.__sootsimInteract) {
374
- globals['interact (\u2192 __sootsimInteract)'] = Object.keys(window.__sootsimInteract)
375
- }
376
-
377
- // keyboard
378
- if (window.__sootsimKeyboard) {
379
- globals['keyboard (\u2192 __sootsimKeyboard)'] = Object.keys(window.__sootsimKeyboard)
380
- }
381
-
382
- // other globals
383
- globals['other'] = [
384
- 'root (\u2192 __sootsimRoot) - live node tree',
385
- 'render() (\u2192 __sootsimForceRender) - force re-render'
386
- ]
387
-
388
- return globals
389
- })()`});console.log(` rnx JS API:
390
- `);for(let[s,n]of Object.entries(o)){console.log(` ${s}:`);for(let i of n)console.log(` .${i}`);console.log("")}console.log(` use: ${w("js")} <expression>`),console.log(` example: ${w("js")} test.findByText("Sign in")`);break}case"describe":{await eo({bridge:c,args:e,positional:a});break}case"perf":{b==="debug"&&!t.internalPerfCommand&&(console.error(" `rnx debug perf` was removed. use `rnx perf shell ...`."),y(1));let o=a[1];if(t.internalPerfCommand==="scroll"){if(!o||o==="--help"||o==="-h"){console.log(`
391
- ${w("perf")} <start|stop> [options]
392
-
393
- records per-frame scroll offsets from the tenant worker, shell worker,
394
- and compositor worker. timestamps use the shared wall clock, while frame
395
- sequences remain separate because the workers do not share a frame id.
396
-
397
- options:
398
- --limit <n> maximum samples retained per layer (default 6000)
399
- --json emit every per-frame sample on stop
400
-
401
- examples:
402
- ${w("perf")} start
403
- # ... perform consecutive swipes ...
404
- ${w("perf")} stop
405
- ${w("perf")} stop --json
406
- `);break}if(o==="start"){let s=l.find((d,p)=>l[p-1]==="--limit"),n=s===void 0?6e3:Number(s);(!Number.isFinite(n)||n<120)&&(console.error(" error: --limit must be a number of at least 120"),y(1));let i=await c.send({type:"evaluate",code:`(async () => {
407
- const perf = window.SootSim?.bridges?.scrollPerf
408
- if (!perf) return { error: 'scroll performance profile unavailable' }
409
- await perf.start(${Math.floor(n)})
410
- return { started: true }
411
- })()`});i?.error&&(console.error(` error: ${i.error}`),y(1)),console.log(` scroll profiling started: perform consecutive swipes, then run '${w("perf")} stop'`);break}if(o==="stop"){let s=await c.send({type:"evaluate",code:`(async () => {
412
- const perf = window.SootSim?.bridges?.scrollPerf
413
- if (!perf) return { error: 'scroll performance profile unavailable' }
414
- return await perf.stop()
415
- })()`});s?.error&&(console.error(` error: ${s.error}`),y(1));let n=s;if(D(l)){C(n);break}console.log(` scroll performance trace:
416
- `),console.log(` duration: ${n.stoppedAt-n.startedAt}ms (worker series are timestamp-aligned, not frame-paired)`),console.log(` samples: tenant ${n.layers.tenant.length} \xB7 shell ${n.layers.shell.length} \xB7 compositor ${n.layers.compositor.length}`),console.log(""),console.log(" offset and phase changes (--json includes every per-frame sample):"),console.log(" t(ms) layer surface node offsetY slotY phase paint");let i=[];for(let d of Object.values(n.layers)){let p=new Map;for(let f of d){let v=`${f.surfaceId}:${f.nodeId}`,g=`${f.offsetY}:${f.slotY??""}:${f.phase??""}`;p.get(v)!==g&&(p.set(v,g),i.push(f))}}i.sort((d,p)=>d.t-p.t||d.seq-p.seq);for(let d of i)console.log(` ${String(d.t-n.startedAt).padStart(5)} ${d.layer.padEnd(10)} ${d.surfaceId.padEnd(8)} ${String(d.nodeId).padStart(5)} ${d.offsetY.toFixed(2).padStart(8)} ${d.slotY===void 0?" -":d.slotY.toFixed(2).padStart(8)} ${(d.phase??"-").padEnd(8)} ${d.paint===void 0?"-":d.paint}`);break}console.error(` unknown scroll perf command: ${o}`),y(1)}if(!o||o==="--help"||o==="-h"){console.log(`
417
- ${w("perf")} \u2014 shell frame profiling (the worker that paints)
418
-
419
- records per-painted-frame timing in the shell worker \u2014 the surface that
420
- actually draws the app's pixels \u2014 merged with render-profile counters
421
- (node visits, boundary records/replays, raster tier, blur ms, draw calls).
422
-
423
- subcommands:
424
- start begin recording (clears prior frames + counters)
425
- stop stop recording and report results
426
- transition <e> profile a shell transition (goHome, appSwitcher, lockScreen)
427
-
428
- stop and transition accept --json for the full machine-readable payload.
429
-
430
- examples:
431
- ${w("perf")} start
432
- # ... interact with the app ...
433
- ${w("perf")} stop
434
- ${w("perf")} stop --json
435
- ${w("perf")} transition goHome
436
- `);break}switch(o){case"start":{let s=await c.send({type:"evaluate",code:`(() => {
437
- if (!window.__sootsimShellPerf) {
438
- return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
439
- }
440
- window.__sootsimShellPerf.start()
441
- return { started: true }
442
- })()`});s?.error&&(console.error(` error: ${s.error}`),y(1)),console.log(` shell profiling started \u2014 interact with the app, then run '${w("perf")} stop'`);break}case"stop":{let s=await c.send({type:"evaluate",code:`(async () => {
443
- if (!window.__sootsimShellPerf) {
444
- return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
445
- }
446
- return await window.__sootsimShellPerf.stop()
447
- })()`});if(s?.error&&(console.error(` error: ${s.error}`),s.error==="timeout"&&console.error(" (shell worker did not answer within 5s \u2014 is a sim loaded?)"),y(1)),D(l)){C(s);break}Io(s);break}case"transition":{let s=a[2];if(!s||!["goHome","appSwitcher","lockScreen"].includes(s)){console.log(`
448
- ${w("perf")} transition <event> \u2014 profile a shell transition
449
-
450
- events:
451
- goHome swipe-to-home animation
452
- appSwitcher app switcher card animation
453
- lockScreen lock screen transition
454
-
455
- note: uses 600ms capture window \u2014 may need --timeout 10000 flag
456
-
457
- examples:
458
- ${w("perf")} transition goHome --timeout 10000
459
- ${w("perf")} transition appSwitcher
460
- `);break}let i=`sootsim:${s}`;Ie(` profiling ${s} transition...`),Ie(" (use --timeout 10000 if this times out)");let d=await c.send({type:"evaluate",code:`(async () => {
461
- if (!window.__sootsimShellPerf) {
462
- return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
463
- }
464
- window.__sootsimShellPerf.start()
465
- // give a frame for profiling to engage before the event
466
- await new Promise(r => requestAnimationFrame(() => r(undefined)))
467
- window.dispatchEvent(new Event('${i}'))
468
- // shell animations are ~300-500ms; fixed timing avoids complex
469
- // animation-end detection
470
- await new Promise(r => setTimeout(r, 600))
471
- return await window.__sootsimShellPerf.stop()
472
- })()`});if(d?.error&&(console.error(` error: ${d.error}`),y(1)),D(l)){C(d);break}Ie(` ${s} transition profiled:`),Io(d);break}default:console.error(` unknown perf subcommand: ${o}`),console.error(" valid: start, stop, transition"),/^--?reset$/.test(o)&&console.error(" note: 'perf start' already clears prior frames \u2014 no reset needed"),(o==="stats"||o==="frames"||o==="worst")&&(console.error(" note: the tenant sampler (stats/frames/worst) was removed \u2014 it hardcoded"),console.error(" layout/render/copy to zero because the shell worker owns every real paint."),console.error(" use 'perf start' / 'perf stop' (worst frames are in the stop report).")),y(1)}break}case"errors":{let o=a[1];if(o==="clear"){await Le(c),D(l)?C({cleared:!0}):console.log(" error buffer cleared");break}let s=o?Number(o):20,n=await fe(c,s);if(D(l)){C(n);break}if(n.length===0){console.log(" no errors captured");break}console.log(` ${n.length} error(s):
473
- `);for(let i of n){let d=oe(i.timestamp),p=i.args.map(f=>typeof f=="object"?JSON.stringify(f):f).join(" ");if(console.log(` [${d}] ${p}`),i.stack){let f=i.stack.split(`
474
- `).slice(0,3);for(let v of f)console.log(` ${v.trim()}`)}}break}case"warnings":{let o=a[1]?Number(a[1]):20,s=await vt(c,o);if(D(l)){C(s);break}if(s.length===0){console.log(" no warnings captured");break}console.log(` ${s.length} warning(s):
475
- `);for(let n of s){let i=oe(n.timestamp),d=n.args.map(p=>typeof p=="object"?JSON.stringify(p):p).join(" ");console.log(` [${i}] ${d}`)}break}case"animations":{let o=await G(c,"listAnimations")??[];if(e.includes("--json")){console.log(JSON.stringify(o,null,2));break}if(o.length===0){console.log(" no active animations");break}console.log(` ${o.length} active animation(s):
476
- `);for(let s of o){let n=String(s.realm??"tenant").padEnd(6),i=String(s.kind).padEnd(10),d=typeof s.from=="number"&&typeof s.to=="number"?`${s.from.toFixed(2)}\u2192${s.to.toFixed(2)}`:"\u2014",p=Number(s.current??0).toFixed(2),f=typeof s.progress=="number"?`${Math.round(s.progress*100)}%`:"\u2014",v=`${Math.round(s.elapsedMs??0)}ms`,g=[s.loop?"loop":null,s.layoutBound?"layout":null,s.remoteDriven?"remote-driven":s.graphBacked?"graph":null,s.visible===!1?"offscreen":null].filter(Boolean),N=g.length>0?` [${g.join(" ")}]`:"";console.log(` #${s.id} ${n} ${i} ${d.padEnd(14)} cur=${p.padEnd(7)} ${f.padStart(4)} ${v}${N}`)}break}case"animation":{let o=a[1];(!o||o==="--help"||o==="-h")&&(console.error(` usage: ${w("animation")} <id>`),y(1));let s=Number(o);Number.isFinite(s)||(console.error(` invalid id: ${o}`),y(1));let n=await G(c,"getAnimation",s);console.log(JSON.stringify(n,null,2));break}case"stop-animation":{let o=a[1];(!o||o==="--help"||o==="-h")&&(console.error(` usage: ${w("stop-animation")} <id|all>`),y(1));let s=o==="all"?"all":Number(o);s!=="all"&&!Number.isFinite(s)&&(console.error(` invalid id: ${o}`),y(1));let n=await G(c,"stopAnimation",s);console.log(` stopped ${n??0} animation(s)`);break}case"requests":{let o=a[1];if(o==="clear"){await It(c),D(l)?C({cleared:!0}):console.log(" request buffer cleared");break}let s=o==="all",n=s?a[2]:o,i=n?Number(n):20,d=await Nt(c,{failed:!s,limit:i});if(D(l)){C(d);break}if(d.length===0){console.log(s?" no requests captured":" no failed requests captured");break}console.log(` ${d.length} ${s?"request(s)":"failed request(s)"}:
477
- `);for(let p of d){let f=oe(p.timestamp);console.log(` [${f}] ${W(p)}`),p.responseBody?console.log(` ${p.responseBody}`):p.error&&console.log(` ${p.error}`)}break}case"network":{let o=a[1],s=null,n=null,i=!1,d=!1,p=1e3,f=!1,v=!1;for(let R=0;R<l.length;R++){let k=l[R];if(k==="--filter")s=l[R+1]??null,R++;else if(k==="--limit"){let I=Number(l[R+1]);Number.isFinite(I)&&(n=I),R++}else if(k==="--threshold"){let I=Number(l[R+1]);Number.isFinite(I)&&I>0&&(p=I),R++}else k==="--failed"?i=!0:k==="--slow"?d=!0:k==="--tail"||k==="-f"?f=!0:k==="--json"&&(v=!0)}if(o==="clear"){await c.send({type:"evaluate",code:'window.__sootsimObservability?.network.clear(); "cleared"'}),console.log(" network buffer cleared");break}if(o==="get"){let R=a[2];R||(console.error(" usage: rnx network get <id>"),y(1));let k=await c.send({type:"evaluate",code:`(() => {
478
- const obs = window.__sootsimObservability;
479
- if (!obs) return null;
480
- return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(R)}) || null;
481
- })()`});k||(console.error(` no entry with id ${R}`),y(1)),v?console.log(JSON.stringify(k,null,2)):bs(k);break}let g=n??(f?200:o?Number(o):20);Number.isFinite(g)||(console.error(` invalid limit: ${o} \u2014 \`network\` takes a numeric count (e.g. ${w("network")} 100).
482
- to target a specific sim, use \`--sim ${o}\` instead.`),y(1));let N=async()=>{let R=await c.send({type:"evaluate",code:`(() => {
483
- const obs = window.__sootsimObservability;
484
- if (!obs) return { ok: false };
485
- return { ok: true, entries: obs.network.getSnapshot() };
486
- })()`});if(!R||!R.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return R.entries??[]},J=R=>{let k=R;if(i&&(k=k.filter(I=>!!I.error||I.status!=null&&I.status>=400)),d&&(k=k.filter(I=>I.durationMs!=null&&I.durationMs>=p)),s){let I=s.toLowerCase();k=k.filter(E=>(E.displayUrl||E.url).toLowerCase().includes(I))}return d&&!f&&(k=[...k].sort((I,E)=>(E.durationMs??0)-(I.durationMs??0))),k};if(!f){let R=await N(),k=J(R).slice(-g);if(v){console.log(JSON.stringify(k,null,2));break}if(k.length===0){R.length===0?console.log(" no network requests captured"):console.log(d?` no requests slower than ${p}ms (${R.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(d?` ${k.length} request(s) slower than ${p}ms (sorted by duration desc):
487
- `:` ${k.length} request(s):
488
- `);for(let I of k)xo(I);break}console.log(` tailing network (ctrl-c to stop)...
489
- `);let Y=new Set,K=!0,U=()=>{K=!1};process.on("SIGINT",U);try{for(;K;){let R=await N(),k=J(R);for(let I of k)I.durationMs!=null&&(Y.has(I.id)||(Y.add(I.id),v?console.log(JSON.stringify(I)):xo(I)));await Z(250)}}finally{process.off("SIGINT",U)}break}case"logs":{let o=a[1],s=null,n=null,i=null,d=!1,p=!1,f=!1;for(let k=0;k<l.length;k++){let I=l[k];if(I==="--filter")s=l[k+1]??null,k++;else if(I==="--limit"){let E=Number(l[k+1]);Number.isFinite(E)&&(n=E),k++}else I==="--level"?(i=l[k+1]??null,k++):I==="--tail"||I==="-f"?d=!0:I==="--json"?p=!0:(I==="--internal"||I==="--all")&&(f=!0)}let v=i?new Set(i.split(",").map(k=>k.trim()).filter(k=>k==="log"||k==="info"||k==="warn"||k==="error"||k==="debug")):null;if(o==="clear"){await Ft(c),console.log(" log buffer cleared");break}let g=!p&&process.stdout.isTTY===!0,N=n??(d?500:o?Number(o):50);Number.isFinite(N)||(console.error(` invalid limit: ${o} \u2014 \`logs\` takes a numeric count (e.g. ${w("logs")} 100).
490
- to target a specific sim, use \`--sim ${o}\` instead.`),y(1));let J=()=>Mt(c),Y=k=>Tt(k,{level:v,filter:s,showInternal:f});if(!d){let k=await J(),I=Y(k).slice(-N);if(p){console.log(JSON.stringify(I,null,2));break}if(I.length===0){console.log(k.length===0?" no logs captured":" no matching logs");break}console.log(` ${I.length} log(s):
491
- `);for(let E of I)ko(E,g);break}console.log(` tailing logs (ctrl-c to stop)...
492
- `);let K=new Set,U=!0,R=()=>{U=!1};process.on("SIGINT",R);try{for(;U;){let k=await J(),I=Y(k);for(let E of I)K.has(E.id)||(K.add(E.id),p?console.log(JSON.stringify(E)):ko(E,g));await Z(250)}}finally{process.off("SIGINT",R)}break}default:console.error(` unknown subcommand: ${m}`),y(1)}if(pe.has(m)&&!e.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&!await pt(c,m)&&await F(c),S.length>0&&re(S),!A.has(m))try{await _e(c)}catch{}}catch(S){st(S);let o=S instanceof Error?S.message:String(S);console.error(` ${m??"rnx"} failed: ${o}`);let s=/^no sim connected with id ([^;]+)(?:; connected sims: .+)?$/.exec(o),n=/^command timed out after (\d+)s$/.exec(o),i=o.startsWith("sim disconnected:")||o.startsWith("bridge never reconnected")||o.startsWith("could not connect to ws://");if(s)await Kt(c,T,s[1]);else if(/^no sim connected$/.test(o))Ht(T);else if(n)if(await ps(c)){let p=m??"describe";process.stderr.write(` the sim is still responsive \u2014 '${p}' just exceeded the ${n[1]}s command budget.
493
- the screen's node tree is large; narrow the query or raise the budget:
494
- rnx ${p} --testid <id> # scope to one subtree
495
- rnx find --testid <id> # targeted single-node lookup
496
- rnx ${p} --timeout 60000 # raise per-command budget (ms)
497
- `)}else wo();else if(i)wo();else{try{await _t(c)}catch{}try{await ie({includeTail:!0})}catch{}try{await se({includeTail:!0})}catch{}}y(1)}finally{c.close()}}export{Do as a,Ts as b,js as c,Bs as d,Cs as e,Ds as f,Io as g,Br as h};