rnxsim 0.1.317 → 0.1.319

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 (183) hide show
  1. package/cli/bin.ts +1 -8
  2. package/cli/commands/debug.ts +1 -8
  3. package/cli/commands/detox.ts +16 -4
  4. package/cli/commands/flow.ts +1 -2
  5. package/cli/commands/inspect/wait-event.ts +1 -1
  6. package/cli/commands/inspect/wait-selector.ts +1 -1
  7. package/cli/commands/inspect.ts +56 -33
  8. package/cli/commands/maestro.ts +1 -1
  9. package/cli/commands/profile.ts +4 -6
  10. package/cli/commands/runtime.ts +0 -4
  11. package/cli/commands/storage.ts +1 -1
  12. package/cli/commands/telemetry.ts +0 -2
  13. package/cli/commands/timeline.ts +2 -4
  14. package/cli/parse-args.ts +0 -3
  15. package/detox/index.ts +155 -15
  16. package/detox/jest-preset.cjs +0 -1
  17. package/dist-cli/bin.js +5 -5
  18. package/dist-cli/chunks/{agent-EKGLRJEN.js → agent-Q4VAKGOL.js} +2 -2
  19. package/dist-cli/chunks/{agent-wrapper-FONNWB7J.js → agent-wrapper-Q2O4TR7H.js} +2 -2
  20. package/dist-cli/chunks/{app-fonts-XPM54HRY.js → app-fonts-B7UP3XTI.js} +2 -2
  21. package/dist-cli/chunks/{assert-PILHTZRZ.js → assert-NAFO4KMH.js} +2 -2
  22. package/dist-cli/chunks/{auth-Q2VUD5NQ.js → auth-CNUGYLCX.js} +2 -2
  23. package/dist-cli/chunks/{beta-P4XLZ3KL.js → beta-GN5BSED6.js} +2 -2
  24. package/dist-cli/chunks/{camera-O4PEVPI4.js → camera-EJRFUEXV.js} +2 -2
  25. package/dist-cli/chunks/{chunk-R6DDJVBB.js → chunk-2TNUPISH.js} +2 -2
  26. package/dist-cli/chunks/{chunk-BJ5CYKA7.js → chunk-3DEQXXSF.js} +4 -4
  27. package/dist-cli/chunks/{chunk-VB2ZZ4JI.js → chunk-3F3R7BM4.js} +2 -2
  28. package/dist-cli/chunks/{chunk-CUILVYWI.js → chunk-4UY4JSQ4.js} +1 -1
  29. package/dist-cli/chunks/chunk-522E7BRF.js +937 -0
  30. package/dist-cli/chunks/{chunk-NF63TOPI.js → chunk-5ABSWU6L.js} +2 -2
  31. package/dist-cli/chunks/{chunk-NA4AMR2E.js → chunk-5KXQT465.js} +1 -1
  32. package/dist-cli/chunks/{chunk-6WG4RQKM.js → chunk-6BGXKWGF.js} +2 -2
  33. package/dist-cli/chunks/{chunk-67ZR7PU7.js → chunk-72VB52IV.js} +1 -1
  34. package/dist-cli/chunks/{chunk-JQ4Y2XVT.js → chunk-76EVUPAL.js} +1 -1
  35. package/dist-cli/chunks/{chunk-OWADERTW.js → chunk-7DABL656.js} +2 -2
  36. package/dist-cli/chunks/{chunk-WWW5DC3G.js → chunk-7IW3PBRN.js} +2 -2
  37. package/dist-cli/chunks/{chunk-S23KHLTR.js → chunk-AX7PASOS.js} +2 -2
  38. package/dist-cli/chunks/{chunk-SZIPYT3D.js → chunk-AZ6S36CJ.js} +2 -2
  39. package/dist-cli/chunks/{chunk-T6W3B2KA.js → chunk-B27W3QWS.js} +1 -1
  40. package/dist-cli/chunks/{chunk-GQ3D2D4O.js → chunk-BQEWRZON.js} +1 -1
  41. package/dist-cli/chunks/{chunk-ADAIY3DX.js → chunk-BSCOA6LL.js} +2 -2
  42. package/dist-cli/chunks/{chunk-NUSBQSRQ.js → chunk-BVVUWEDG.js} +2 -2
  43. package/dist-cli/chunks/chunk-DD6F2WOA.js +4 -0
  44. package/dist-cli/chunks/{chunk-J4MCKLWE.js → chunk-DIADYUIH.js} +4 -4
  45. package/dist-cli/chunks/{chunk-KO7UG262.js → chunk-GHHVBATM.js} +2 -2
  46. package/dist-cli/chunks/{chunk-QCQQ2VDW.js → chunk-HCM7K4AU.js} +2 -2
  47. package/dist-cli/chunks/chunk-HPO2HNJX.js +124 -0
  48. package/dist-cli/chunks/{chunk-67OCUGZD.js → chunk-IHBAZ6ZJ.js} +2 -2
  49. package/dist-cli/chunks/{chunk-QGPNBTHT.js → chunk-IJYWC6QT.js} +2 -2
  50. package/dist-cli/chunks/{chunk-JZXCQEKO.js → chunk-JWAF5GXK.js} +2 -2
  51. package/dist-cli/chunks/{chunk-LSC2HFAB.js → chunk-JZIFPU64.js} +1 -1
  52. package/dist-cli/chunks/{chunk-RCPPPW7B.js → chunk-KMOLZN54.js} +1 -1
  53. package/dist-cli/chunks/{chunk-GMWPCQ63.js → chunk-L5JZXGYY.js} +1 -1
  54. package/dist-cli/chunks/{chunk-YRVJHPCU.js → chunk-LKO7E4VO.js} +2 -2
  55. package/dist-cli/chunks/{chunk-WJVNVBAI.js → chunk-M52VGRRN.js} +1 -1
  56. package/dist-cli/chunks/{chunk-7Q7IQ2SS.js → chunk-PFRV3TNY.js} +2 -2
  57. package/dist-cli/chunks/{chunk-3G7I72XV.js → chunk-PYDVLJOW.js} +2 -2
  58. package/dist-cli/chunks/{chunk-ATOUAYJP.js → chunk-QNNCKWZF.js} +1 -1
  59. package/dist-cli/chunks/{chunk-ODHQKXLB.js → chunk-R4JD7RQ5.js} +2 -2
  60. package/dist-cli/chunks/chunk-RIRZMX6H.js +4 -0
  61. package/dist-cli/chunks/{chunk-FIPCJ5OS.js → chunk-RVKU4F4H.js} +1 -1
  62. package/dist-cli/chunks/{chunk-A3GVXVSG.js → chunk-S5XIMHEZ.js} +2 -2
  63. package/dist-cli/chunks/{chunk-HJKQ6NEU.js → chunk-SPHYBQAZ.js} +2 -2
  64. package/dist-cli/chunks/chunk-TJSU45JD.js +4 -0
  65. package/dist-cli/chunks/{chunk-R6MEMDNB.js → chunk-UGYANOZR.js} +2 -2
  66. package/dist-cli/chunks/{chunk-W4YHMJOO.js → chunk-VB6FBQBW.js} +2 -2
  67. package/dist-cli/chunks/{chunk-5XVHBFAT.js → chunk-VLT3KCQT.js} +3 -3
  68. package/dist-cli/chunks/{chunk-OO5D7IJE.js → chunk-VQJMFDUN.js} +1 -1
  69. package/dist-cli/chunks/{chunk-EL23MRFL.js → chunk-WUZNWEBT.js} +1 -1
  70. package/dist-cli/chunks/{chunk-5BYFLVSZ.js → chunk-X2AHIPGY.js} +1 -1
  71. package/dist-cli/chunks/{chunk-OXSCF4UD.js → chunk-XJHAGKJD.js} +2 -2
  72. package/dist-cli/chunks/{chunk-RG3CME4Y.js → chunk-YPDFFAE7.js} +2 -2
  73. package/dist-cli/chunks/{chunk-HF4NZ5SD.js → chunk-YS6EWKGV.js} +2 -2
  74. package/dist-cli/chunks/{chunk-2SAOKV6V.js → chunk-YT6RDBLT.js} +1 -1
  75. package/dist-cli/chunks/{chunk-KZS5VM6Y.js → chunk-Z4LSUN4M.js} +1 -1
  76. package/dist-cli/chunks/{chunk-TUFL7CQK.js → chunk-Z72QDFQG.js} +2 -2
  77. package/dist-cli/chunks/{chunk-ARICQ4CG.js → chunk-ZH5X2H73.js} +2 -2
  78. package/dist-cli/chunks/{cleanup-O6IWLGDY.js → cleanup-GBLORG7C.js} +2 -2
  79. package/dist-cli/chunks/cli-version-6C4ZR7I7.js +4 -0
  80. package/dist-cli/chunks/{compat-562BT6JM.js → compat-OIWTQTTQ.js} +2 -2
  81. package/dist-cli/chunks/{config-7RO6O45J.js → config-DZCL6YFH.js} +2 -2
  82. package/dist-cli/chunks/{control-XYKZG442.js → control-MY5IZSCI.js} +2 -2
  83. package/dist-cli/chunks/daemon-42K3PILG.js +4 -0
  84. package/dist-cli/chunks/{debug-3VCEOVRM.js → debug-6UQUAZKP.js} +4 -4
  85. package/dist-cli/chunks/{desktop-K3PPS6VL.js → desktop-DFBFLSQ3.js} +3 -3
  86. package/dist-cli/chunks/detox-CIHUJOCI.js +52 -0
  87. package/dist-cli/chunks/{device-NZCR7JIN.js → device-7SOHSSJO.js} +2 -2
  88. package/dist-cli/chunks/{diagnose-VVJY6RF2.js → diagnose-P2FMX5HU.js} +2 -2
  89. package/dist-cli/chunks/{disk-cleanup-2VJMHUIY.js → disk-cleanup-6PP5CQVO.js} +2 -2
  90. package/dist-cli/chunks/drivers-CFJGYQFX.js +4 -0
  91. package/dist-cli/chunks/{film-CEMBA2DA.js → film-2WWHMPGU.js} +3 -3
  92. package/dist-cli/chunks/flow-KL7ZTVKL.js +4 -0
  93. package/dist-cli/chunks/help-T2OCMQPI.js +4 -0
  94. package/dist-cli/chunks/hidden-runtime-alias-ZZMC3E6R.js +4 -0
  95. package/dist-cli/chunks/{home-paths-TKPTU62O.js → home-paths-Y6X4LFSU.js} +2 -2
  96. package/dist-cli/chunks/inspect-PVMJQHMF.js +4 -0
  97. package/dist-cli/chunks/install-desktop-NHQZI4EH.js +4 -0
  98. package/dist-cli/chunks/{login-CIQT627K.js → login-BARKKDRL.js} +4 -4
  99. package/dist-cli/chunks/{logout-V2DJVY3U.js → logout-YVUMTGMP.js} +2 -2
  100. package/dist-cli/chunks/{maestro-YSZ6ZC5C.js → maestro-UPVELJ7G.js} +7 -7
  101. package/dist-cli/chunks/{maestro-generate-6JUELIXK.js → maestro-generate-EP76F4GB.js} +3 -3
  102. package/dist-cli/chunks/{mode-D4HQ6YN3.js → mode-ULOBJKDO.js} +2 -2
  103. package/dist-cli/chunks/{optional-demo-registry-AC6YJKT4.js → optional-demo-registry-O6RANNU3.js} +2 -2
  104. package/dist-cli/chunks/{perf-5GRZ4G5X.js → perf-ANPUHMRS.js} +2 -2
  105. package/dist-cli/chunks/{permissions-4V6UVWGK.js → permissions-NGMRAUGD.js} +2 -2
  106. package/dist-cli/chunks/{record-IDNLOQLR.js → record-CBO3QGRB.js} +3 -3
  107. package/dist-cli/chunks/{report-issue-TF6R77TT.js → report-issue-K7XKNJ2D.js} +2 -2
  108. package/dist-cli/chunks/reset-FXAX2W5A.js +4 -0
  109. package/dist-cli/chunks/runtime-GNCU66RR.js +4 -0
  110. package/dist-cli/chunks/{screenshot-command-CHJN7WUT.js → screenshot-command-KZZSYRX5.js} +3 -3
  111. package/dist-cli/chunks/{screenshot-layers-MSDCGYNE.js → screenshot-layers-Z3KSMJ3R.js} +2 -2
  112. package/dist-cli/chunks/{screenshots-capture-OGP3OQYR.js → screenshots-capture-QTB5GQNA.js} +2 -2
  113. package/dist-cli/chunks/{serve-GPBLCMXX.js → serve-JKTMCDG2.js} +2 -2
  114. package/dist-cli/chunks/{setup-S2KYWZZO.js → setup-GCAPEHZH.js} +2 -2
  115. package/dist-cli/chunks/{skills-AUS5DTUE.js → skills-Y4YDYEKA.js} +2 -2
  116. package/dist-cli/chunks/{state-QLYTMIKF.js → state-3HTG2CZU.js} +2 -2
  117. package/dist-cli/chunks/storage-XQE2XZJM.js +37 -0
  118. package/dist-cli/chunks/store-22QXHYUS.js +4 -0
  119. package/dist-cli/chunks/telemetry-VYGOHQWW.js +4 -0
  120. package/dist-cli/chunks/{timeline-EUHPXPFP.js → timeline-XYACO63Y.js} +3 -3
  121. package/dist-cli/chunks/{upgrade-JMMBM3ZN.js → upgrade-EVQTCUSG.js} +2 -2
  122. package/dist-cli/chunks/upload-XH3RQR4U.js +4 -0
  123. package/dist-cli/chunks/{version-QCF7RCA2.js → version-NLGYSRXS.js} +2 -2
  124. package/dist-cli/chunks/{web-WPYHMOVH.js → web-25OBFWDS.js} +2 -2
  125. package/dist-cli/chunks/{what-happened-3RNZP4MB.js → what-happened-MRN6CH5W.js} +2 -2
  126. package/dist-lib/agent-daemon-client.cjs +1 -1
  127. package/dist-lib/agent-events.cjs +1 -1
  128. package/dist-lib/agent-identity.cjs +1 -1
  129. package/dist-lib/agent-sessions.cjs +1 -1
  130. package/dist-lib/attached-projects.cjs +1 -1
  131. package/dist-lib/auth/shared-session.cjs +1 -1
  132. package/dist-lib/backend-origin.cjs +1 -1
  133. package/dist-lib/beta.cjs +1 -1
  134. package/dist-lib/beta.mjs +1 -1
  135. package/dist-lib/bridge-constants.cjs +1 -1
  136. package/dist-lib/bridge-contract.cjs +1 -1
  137. package/dist-lib/cli-constants.cjs +1 -1
  138. package/dist-lib/config.cjs +1 -1
  139. package/dist-lib/detox/index.cjs +93 -11
  140. package/dist-lib/detox/jest-preset.cjs +0 -1
  141. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  142. package/dist-lib/home-paths.cjs +1 -1
  143. package/dist-lib/host/bridge-host.cjs +1 -1
  144. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  145. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  146. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  147. package/dist-lib/host/websocket-proxy.cjs +1 -1
  148. package/dist-lib/index.cjs +1 -1
  149. package/dist-lib/jump-to-source-babel.cjs +1 -1
  150. package/dist-lib/menu.cjs +1 -1
  151. package/dist-lib/menu.mjs +1 -1
  152. package/dist-lib/metro.cjs +1 -1
  153. package/dist-lib/profiles.cjs +1 -1
  154. package/dist-lib/public-brand.cjs +1 -1
  155. package/dist-lib/render-mode.cjs +1 -1
  156. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  157. package/dist-lib/sdk.cjs +1 -1
  158. package/dist-lib/sdk.mjs +1 -1
  159. package/dist-lib/skills.cjs +62 -28
  160. package/dist-lib/vite.cjs +1 -1
  161. package/package.json +1 -1
  162. package/skills/contrast/SKILL.md +0 -1
  163. package/skills/rnx-perf/SKILL.md +17 -0
  164. package/src/vite-plugin.ts +74 -43
  165. package/dist-cli/chunks/chunk-744422UA.js +0 -4
  166. package/dist-cli/chunks/chunk-CHKTOWRH.js +0 -939
  167. package/dist-cli/chunks/chunk-O6OIXJ54.js +0 -4
  168. package/dist-cli/chunks/chunk-VUKB6JW3.js +0 -125
  169. package/dist-cli/chunks/cli-version-F2R7SUY7.js +0 -4
  170. package/dist-cli/chunks/daemon-WE37QLQC.js +0 -4
  171. package/dist-cli/chunks/detox-6ODNKASO.js +0 -52
  172. package/dist-cli/chunks/drivers-44ZJZ37B.js +0 -4
  173. package/dist-cli/chunks/flow-ORGIXYVS.js +0 -4
  174. package/dist-cli/chunks/help-UW52M7FZ.js +0 -4
  175. package/dist-cli/chunks/hidden-runtime-alias-R2QQLZZA.js +0 -4
  176. package/dist-cli/chunks/inspect-TNFI6C6G.js +0 -4
  177. package/dist-cli/chunks/install-desktop-NEJEPL4L.js +0 -4
  178. package/dist-cli/chunks/reset-D7WAFOZO.js +0 -4
  179. package/dist-cli/chunks/runtime-O5TNQBYH.js +0 -4
  180. package/dist-cli/chunks/storage-2MNS4TYO.js +0 -37
  181. package/dist-cli/chunks/store-UT52X7AA.js +0 -4
  182. package/dist-cli/chunks/telemetry-CAQVTTHY.js +0 -4
  183. package/dist-cli/chunks/upload-CEX4UBJL.js +0 -4
@@ -1,939 +0,0 @@
1
- /*! rnx v0.1.317 | (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 Ct,c as jt}from"./chunk-EL23MRFL.js";import{a as _t,b as Dt}from"./chunk-OO5D7IJE.js";import{a as de}from"./chunk-R6DDJVBB.js";import{k as Bt}from"./chunk-HJKQ6NEU.js";import{a as oe,b as B,c as D,d as Me,e as ae,f as X,g as pe,h as ye,i as Pt,j as Et,k as Ne,l as At}from"./chunk-HF4NZ5SD.js";import{A as Tt,B as Mt,C as Nt,F as Ft,H as Ot,J as ue,K as Rt,Q as Je,a as Ie,b as pt,c as mt,d as ft,e as gt,f as yt,g as ht,h as bt,i as wt,j as xt,k as je,l as qe,r as Le,s as $t,t as St,u as ge,v as vt,w as Te,x as We,y as kt,z as It}from"./chunk-KZS5VM6Y.js";import{a as nt}from"./chunk-O6OIXJ54.js";import{a as Q}from"./chunk-TUFL7CQK.js";import{e as rt,j as it,o as at,q as lt,s as ct,t as dt,u as ut,v as ce}from"./chunk-A3GVXVSG.js";import{c as Be,e as Ce}from"./chunk-VUKB6JW3.js";function He(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 Do,mkdirSync as Lt,readFileSync as Bo,rmSync as Ue,writeFileSync as Wt}from"fs";import{tmpdir as Co}from"os";import{dirname as Jt,join as jo,resolve as Ht}from"path";import*as Fe from"fs";function _o(e){let t={},s=e,a=p=>Array.isArray(p)?p:[],c=e.match(/^---\n([\s\S]*?)\n---\n?/);if(c){try{t=de.parse(c[1])??{}}catch(b){console.warn(` warn: could not parse frontmatter: ${b.message}`)}s=e.slice(c[0].length);let p=de.parse(s);return{frontmatter:t,steps:a(p)}}if(/\n---\s*\n/.test(e))try{let p=de.parseAllDocuments(e);if(p.length>=2){let b=p[0].toJS(),w=p[p.length-1].toJS();return{frontmatter:b&&typeof b=="object"?b:{},steps:a(w)}}}catch(p){console.warn(` warn: could not parse multi-doc flow: ${p.message}`)}let i=de.parse(s);return{frontmatter:t,steps:a(i)}}var qt=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function Ke(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 s=0;for(let a of e)a&&typeof a=="object"?Object.keys(a).some(i=>qt.has(i))&&(s+=1):typeof a=="string"&&qt.has(a)&&(s+=1);return s===0&&t.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),t}function Os(e){if(!Fe.existsSync(e))return[`file not found: ${e}`];let t;try{t=Fe.readFileSync(e,"utf8")}catch(s){return[`cannot read file: ${s.message}`]}if(t.trim().length===0)return["file is empty"];try{let s=_o(t);return Ke(s.steps)}catch(s){return[`yaml parse error: ${s.message}`]}}var Ge=1;function Oe(){return Ht(process.env.SOOTSIM_FLOW_SESSION_PATH||jo(Co(),"sootsim-flow-session.json"))}function Ye(e){let t=Oe();Lt(Jt(t),{recursive:!0}),Wt(t,JSON.stringify(e,null,2)+`
10
- `)}function ze(){let e=Oe();if(!Do(e))return null;try{let t=JSON.parse(Bo(e,"utf8"));return t.version!==Ge||!Array.isArray(t.steps)||typeof t.startedAt!="string"||typeof t.updatedAt!="string"?(Ue(e,{force:!0}),null):{version:Ge,startedAt:t.startedAt,updatedAt:t.updatedAt,steps:t.steps,candidate:t.candidate??null}}catch{return Ue(e,{force:!0}),null}}function Bs(){let e=new Date().toISOString(),t={version:Ge,startedAt:e,updatedAt:e,steps:[],candidate:null};return Ye(t),{path:Oe(),state:t}}function qo(){Ue(Oe(),{force:!0})}function Cs(){qo()}function Re(e){let t=ze();if(!t)return{active:!1};let s=t.candidate,a={...t,updatedAt:new Date().toISOString(),candidate:{step:e.step,summary:e.summary,source:e.source,recordedAt:new Date().toISOString()}};return Ye(a),{active:!0,candidate:a.candidate,replaced:s}}function js(){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,s={...e,updatedAt:new Date().toISOString(),steps:[...e.steps,t.step],candidate:null};return Ye(s),{active:!0,kept:!0,candidate:t,stepCount:s.steps.length}}function Lo(e){return de.stringify(e).trimEnd()+`
11
- `}function qs(e){let t=ze();if(!t)return{active:!1};let s=Lo(t.steps),a=Ke(t.steps);if(a.length>0)return{active:!0,valid:!1,issues:a,yaml:s,stepCount:t.steps.length,outputPath:null};let c=null;return e&&(c=Ht(e),Lt(Jt(c),{recursive:!0}),Wt(c,s)),{active:!0,valid:!0,issues:[],yaml:s,stepCount:t.steps.length,outputPath:c}}import{existsSync as Wo,mkdirSync as Jo,readFileSync as Ho,rmSync as Kt,writeFileSync as Ko}from"fs";import{tmpdir as Uo}from"os";import{dirname as Go,join as Yo,resolve as zo}from"path";var he=1,Xo="SOOTSIM_INSPECT_NOTICE_PATH",Vo=300*1e3,Qo=15e3;function Ut(){return zo(process.env[Xo]||Yo(Uo(),"sootsim-inspect-notice-state.json"))}function Zo(e,t){return Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s?.signature=="string"&&Number.isFinite(s?.updatedAt)&&t-s.updatedAt<=Vo))}function es(e){let t=Ut();if(!Wo(t))return{version:he,entries:{}};try{let s=JSON.parse(Ho(t,"utf8"));return s.version!==he||!s.entries||typeof s.entries!="object"?(Kt(t,{force:!0}),{version:he,entries:{}}):{version:he,entries:Zo(s.entries,e)}}catch{return Kt(t,{force:!0}),{version:he,entries:{}}}}function ts(e){let t=Ut();Jo(Go(t),{recursive:!0}),Ko(t,JSON.stringify(e,null,2)+`
12
- `)}function os(e,t){let s=t.trim()||"default";return`${e}:${s}`}function Xe(e,t,s,a={}){let c=a.nowMs??Date.now(),i=a.cooldownMs??Qo,p=es(c),b=os(e,t),w=p.entries[b];return w&&w.signature===s&&c-w.updatedAt<i?!1:(p.entries[b]={signature:s,updatedAt:c},ts(p),!0)}async function se({bridge:e,simId:t,maxMs:s,pollMs:a=50,stablePolls:c=3,strict:i=!1}){let p=await e.send({type:"evaluate",simId:t,code:`(async () => {
13
- const start = Date.now()
14
- const deadline = start + ${Math.max(0,Math.round(s))}
15
- const pollMs = ${Math.max(1,Math.round(a))}
16
- const requiredStablePolls = ${Math.max(1,Math.round(c))}
17
- const strict = ${i?"true":"false"}
18
- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
19
-
20
- // route-aware settle: a tap that pushes/pops a screen is async \u2014 the
21
- // old screen still renders for a moment, then the new one mounts and
22
- // its content loads. a pure layout-hash check reports "idle" on the
23
- // outgoing screen or on the incoming skeleton, so a driver re-taps
24
- // and stacks duplicate navigations. drain any in-flight screen
25
- // transition FIRST, bounded by the overall budget. when no
26
- // transition is happening this returns in ~80ms (startWindowMs), so
27
- // a plain button tap barely pays for it.
28
- try {
29
- const wfst = window.__sootsimTest?.waitForScreenTransitions
30
- if (typeof wfst === 'function') {
31
- const remaining = deadline - Date.now()
32
- if (remaining > 120) {
33
- await wfst({
34
- timeoutMs: Math.min(remaining - 80, 4000),
35
- settleMs: 64,
36
- startWindowMs: 80,
37
- })
38
- }
39
- }
40
- } catch {}
41
-
42
- const readSnapshot = async () => {
43
- let animating = false
44
- let pendingFetches = 0
45
- let requestTotal = 0
46
- let requestInFlight = 0
47
- try {
48
- const stats = await window.__sootsimRenderHost?.queryStats?.()
49
- if (stats) {
50
- animating =
51
- stats.hasActiveAnims === true ||
52
- stats.hasActiveNativeAnimations === true ||
53
- stats.hasPendingAnimationFrames === true
54
- // a freshly-pushed screen showing a skeleton is layout-stable
55
- // but not actually settled \u2014 its data/images are still in
56
- // flight. treat bounded image-loader fetches as not-idle so
57
- // settle waits for real content, capped by the budget.
58
- const pf = stats.memory && stats.memory.imageLoader
59
- ? stats.memory.imageLoader.pendingFetches
60
- : 0
61
- pendingFetches = typeof pf === 'number' ? pf : 0
62
- }
63
- } catch {}
64
- try {
65
- const counts = await window.__sootsimTest?.getRequestCounts?.()
66
- requestTotal = typeof counts?.total === 'number' ? counts.total : 0
67
- requestInFlight = typeof counts?.inFlight === 'number' ? counts.inFlight : 0
68
- } catch {}
69
- const root = window.__sootsimRoot
70
- const nodes = []
71
- if (root) {
72
- const walk = (n) => {
73
- if (n.layout && n.layout.width > 0) {
74
- nodes.push(Math.round(n.layout.x) + ',' + Math.round(n.layout.y) + ',' + Math.round(n.layout.width))
75
- }
76
- for (const c of n.children || []) walk(c)
77
- }
78
- walk(root)
79
- }
80
- return { layout: nodes.join(';'), animating, pendingFetches, requestTotal, requestInFlight }
81
- }
82
-
83
- // how long generic background network is allowed to keep us waiting AFTER
84
- // the screen is otherwise visually settled. apps with continuous traffic
85
- // (polling, realtime sockets, a tap that fires 20-50 fetches) never reach
86
- // requestInFlight===0 / a stable requestTotal, so requiring full network
87
- // quiet burns the ENTIRE budget on every command \u2014 the leading idle that
88
- // failed PR-preview recordings for network-heavy apps (3pc fight-pulse).
89
- // layout-stability + the image-loader already prove visible content
90
- // loaded (a data load changes layout; an image load shows in the loader),
91
- // so the generic request counters are a courtesy, not a gate: honor them
92
- // only within this grace once the screen is visually still.
93
- const networkQuietGraceMs = 1200
94
- let lastLayout = ''
95
- let lastRequestTotal = -1
96
- let stable = 0
97
- let visuallyStillSince = 0
98
- while (Date.now() < deadline) {
99
- const snapshot = await readSnapshot()
100
- const strictOk = !strict || !snapshot.animating
101
- // visually settled: no animations, no image content loading, layout
102
- // unchanged since the last poll.
103
- const visuallyStill =
104
- strictOk && snapshot.pendingFetches === 0 && snapshot.layout === lastLayout
105
- // generic network quiet: nothing in flight and no new requests issued.
106
- const networkQuiet =
107
- snapshot.requestInFlight === 0 && snapshot.requestTotal === lastRequestTotal
108
- if (visuallyStill) {
109
- stable++
110
- if (visuallyStillSince === 0) visuallyStillSince = Date.now()
111
- // settle once the screen has held still long enough AND either the
112
- // network is genuinely quiet OR it has refused to quiet within the
113
- // grace (continuous background traffic must not block forever).
114
- if (
115
- stable >= requiredStablePolls &&
116
- (networkQuiet || Date.now() - visuallyStillSince >= networkQuietGraceMs)
117
- ) {
118
- return { settled: true, elapsed: Date.now() - start }
119
- }
120
- } else {
121
- stable = 0
122
- visuallyStillSince = 0
123
- }
124
- lastLayout = snapshot.layout
125
- lastRequestTotal = snapshot.requestTotal
126
- await sleep(pollMs)
127
- }
128
- return { settled: false, elapsed: Date.now() - start }
129
- })()`},{timeoutMs:s+1e3}),{elapsed:b,settled:w}=p??{};return{elapsed:typeof b=="number"?b:s,settled:w===!0}}var Pe=`(() => {
130
- const spec = window.SootSim?.state?.engineSnapshot?.windowState?.deviceSpec
131
- return spec && spec.width > 0 && spec.height > 0
132
- ? { width: spec.width, height: spec.height }
133
- : null
134
- })()`,ss={initialWaitMs:3e3,deadlineMs:5e3,retryWaitMs:700},ns={initialWaitMs:1200,deadlineMs:2500,retryWaitMs:700};function rs(e,t={}){return{...e?ss:ns,...t}}function me(e){return!(!e||e.hit===!1||e.ok===!1||e.requestedTargetMatched===!1||e.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function is(e,t){return{nodeId:e.target?.nodeId??e.match?.nodeId??e.node?.nodeId??null,id:e.target?.id??e.match?.id??e.node?.id??null,testID:e.target?.testID??e.match?.testID??e.node?.testID??null,text:e.target?.text??e.target?.accessibilityLabel??e.match?.text??e.match?.accessibilityLabel??e.node?.text??t??null,type:e.target?.type??e.match?.type??e.node?.type??null}}async function be(e,t){let s=rs(!!t.agent,t.timing),a=0,c=null,i=null;try{await se({bridge:e,maxMs:s.initialWaitMs,pollMs:32,stablePolls:2})}catch{}let p=Date.now()+s.deadlineMs,b=null;for(;Date.now()<=p||a===0;){a++;let w=await t.resolve();if(c=w,w?.error==="bridge-not-ready"||w?.ambiguous||w?.nthOutOfRange)return{payload:w,result:null,attempts:a,failure:"special"};if(w&&typeof w.cx=="number"&&typeof w.cy=="number")if(w.offscreen){i={hit:!1,reason:"offscreen",x:w.cx,y:w.cy,screen:w.screen};let h=`${Math.round(w.cx)},${Math.round(w.cy)}`;if(b===h)return{payload:w,result:i,attempts:a,failure:"missed"};b=h}else{b=null;let h=is(w,t.textFallback),x=await e.send({type:"evaluate",code:`(async () => {
135
- const t = window.__sootsimTest
136
- if (
137
- !t ||
138
- typeof t.inspectAt !== 'function' ||
139
- typeof t.resolveTapTarget !== 'function'
140
- ) {
141
- return { error: 'tap-target-inspection-unavailable' }
142
- }
143
- const requestedTarget = ${JSON.stringify(h)}
144
- const inspected = await t.inspectAt(${w.cx}, ${w.cy})
145
- const resolved =
146
- inspected && typeof inspected.nodeId === 'number'
147
- ? await t.resolveTapTarget(inspected.nodeId)
148
- : null
149
- const node = (resolved && resolved.target) || inspected
150
- const coordinateTarget = node
151
- ? {
152
- nodeId: node.nodeId ?? null,
153
- id: node.id ?? null,
154
- testID: node.testID ?? null,
155
- text: node.text ?? node.accessibilityLabel ?? null,
156
- type: node.type ?? null,
157
- }
158
- : null
159
- const coordinateAncestors = Array.isArray(inspected?.ancestors)
160
- ? inspected.ancestors
161
- : []
162
- const ancestorMatchesRequested = coordinateAncestors.some(
163
- (ancestor) =>
164
- (typeof requestedTarget.nodeId === 'number' &&
165
- ancestor?.nodeId === requestedTarget.nodeId) ||
166
- (requestedTarget.testID &&
167
- ancestor?.testID === requestedTarget.testID) ||
168
- (requestedTarget.id && ancestor?.id === requestedTarget.id),
169
- )
170
- const requestedTargetMatched =
171
- coordinateTarget === null
172
- ? false
173
- : typeof requestedTarget.nodeId === 'number' &&
174
- typeof coordinateTarget.nodeId === 'number'
175
- ? requestedTarget.nodeId === coordinateTarget.nodeId ||
176
- ancestorMatchesRequested
177
- : requestedTarget.testID && coordinateTarget.testID
178
- ? requestedTarget.testID === coordinateTarget.testID
179
- || ancestorMatchesRequested
180
- : requestedTarget.id && coordinateTarget.id
181
- ? requestedTarget.id === coordinateTarget.id
182
- || ancestorMatchesRequested
183
- : ancestorMatchesRequested
184
- if (!requestedTargetMatched) {
185
- return {
186
- requestedTargetMatched,
187
- requestedTarget,
188
- coordinateTarget,
189
- }
190
- }
191
- if (typeof t.activatePressAt !== 'function') {
192
- return { error: 'tap-target-activation-unavailable' }
193
- }
194
- const activation = await t.activatePressAt(
195
- ${w.cx},
196
- ${w.cy},
197
- requestedTarget.nodeId,
198
- )
199
- if (activation?.ok) {
200
- window.dispatchEvent(
201
- new CustomEvent('sootsim:agentAction', {
202
- detail: {
203
- type: 'tap',
204
- x: ${w.cx},
205
- y: ${w.cy},
206
- target: requestedTarget,
207
- },
208
- }),
209
- )
210
- }
211
- return {
212
- activation,
213
- requestedTargetMatched,
214
- requestedTarget,
215
- coordinateTarget,
216
- }
217
- })()`});if(x?.error)return{payload:w,result:{hit:!1,reason:x.error,requestedTarget:h},attempts:a,failure:"special"};if(x?.requestedTargetMatched===!1)return{payload:w,result:{hit:!1,reason:"target-covered",...x},attempts:a,failure:"missed"};let F=x?.activation?.tap??x?.activation,M=F&&typeof F=="object"?{...F,...x?.activation,...x}:{hit:!!F,...x};if(i=M,me(M))return{payload:w,result:M,attempts:a}}let y=p-Date.now();if(y<=0)break;try{await se({bridge:e,maxMs:Math.min(y,s.retryWaitMs),pollMs:32,stablePolls:2})}catch{await new Promise(h=>setTimeout(h,Math.min(120,y)))}}return{payload:c,result:i,attempts:a,failure:c&&typeof c.cx=="number"?"missed":"not-found"}}async function Gt(e,t,s,a){return e.send({type:"tap",x:t,y:s,...a?{target:a}:{}})}async function Yt(e,t,s={}){let a=JSON.stringify(t);return be(e,{agent:s.agent,timing:s.timing,resolve:()=>e.send({type:"evaluate",code:`(async () => {
218
- const t = window.__sootsimTest
219
- if (!t) return null
220
- const n = (await t.findByTestId(${a})) || (await t.findById(${a}))
221
- if (!n || !n.absolutePosition || !n.layout) return { cx: null }
222
- const resolved =
223
- typeof n.nodeId === 'number' && typeof t.resolveTapTarget === 'function'
224
- ? await t.resolveTapTarget(n.nodeId)
225
- : null
226
- const target = (resolved && resolved.target) || n
227
- const cx =
228
- resolved && typeof resolved.cx === 'number'
229
- ? resolved.cx
230
- : n.absolutePosition.x + (n.layout.width || 0) / 2
231
- const cy =
232
- resolved && typeof resolved.cy === 'number'
233
- ? resolved.cy
234
- : n.absolutePosition.y + (n.layout.height || 0) / 2
235
- const scr = ${Pe}
236
- const offscreen =
237
- !!scr && (cx < 0 || cy < 0 || cx > scr.width || cy > scr.height)
238
- return {
239
- cx,
240
- cy,
241
- ...(offscreen ? { offscreen: true, screen: scr } : {}),
242
- match: {
243
- nodeId: n.nodeId ?? null,
244
- id: n.id,
245
- testID: n.testID,
246
- text: n.text ?? n.accessibilityLabel ?? null,
247
- type: n.type,
248
- },
249
- target: {
250
- nodeId: target.nodeId ?? null,
251
- id: target.id,
252
- testID: target.testID,
253
- text:
254
- target.text ??
255
- target.accessibilityLabel ??
256
- n.text ??
257
- n.accessibilityLabel ??
258
- null,
259
- type: target.type,
260
- },
261
- strategy: (resolved && resolved.strategy) || 'matched-node',
262
- }
263
- })()`})})}async function zt(e,t,s={},a={}){let c=JSON.stringify({query:t,exact:!!s.exact,role:s.role??null,within:s.within??null,minX:s.minX??null,maxX:s.maxX??null,minY:s.minY??null,maxY:s.maxY??null,near:s.near??null,nth:s.nth??null,first:!!s.first});return be(e,{agent:a.agent,timing:a.timing,textFallback:t,resolve:()=>e.send({type:"evaluate",code:`(async () => {
264
- const t = window.__sootsimTest
265
- if (!t) return { error: 'bridge-not-ready' }
266
- const F = ${c}
267
-
268
- const res = await t.queryTextCandidates({
269
- query: F.query,
270
- exact: !!F.exact,
271
- ...(F.role ? { role: F.role } : {}),
272
- })
273
-
274
- let candidates = res.candidates || []
275
-
276
- candidates = candidates.filter((c) => {
277
- const ax = c.info.absolutePosition && c.info.absolutePosition.x
278
- const ay = c.info.absolutePosition && c.info.absolutePosition.y
279
- if (F.minX !== null && !(ax >= F.minX)) return false
280
- if (F.maxX !== null && !(ax <= F.maxX)) return false
281
- if (F.minY !== null && !(ay >= F.minY)) return false
282
- if (F.maxY !== null && !(ay <= F.maxY)) return false
283
- if (F.within && !c.ancestorTestIDs.includes(F.within)) return false
284
- return true
285
- })
286
-
287
- if (F.near) {
288
- candidates.sort((a, b) => {
289
- const ax = (a.info.absolutePosition && a.info.absolutePosition.x) || 0
290
- const ay = (a.info.absolutePosition && a.info.absolutePosition.y) || 0
291
- const bx = (b.info.absolutePosition && b.info.absolutePosition.x) || 0
292
- const by = (b.info.absolutePosition && b.info.absolutePosition.y) || 0
293
- return (
294
- Math.hypot(ax - F.near.x, ay - F.near.y) -
295
- Math.hypot(bx - F.near.x, by - F.near.y)
296
- )
297
- })
298
- } else {
299
- candidates.sort((a, b) => {
300
- const ay = (a.info.absolutePosition && a.info.absolutePosition.y) || 0
301
- const by = (b.info.absolutePosition && b.info.absolutePosition.y) || 0
302
- if (Math.abs(ay - by) > 2) return ay - by
303
- const ax = (a.info.absolutePosition && a.info.absolutePosition.x) || 0
304
- const bx = (b.info.absolutePosition && b.info.absolutePosition.x) || 0
305
- return ax - bx
306
- })
307
- }
308
-
309
- const total = candidates.length
310
- if (total === 0) return { matched: 0, total: 0 }
311
-
312
- let idx = 0
313
- if (F.nth !== null) {
314
- idx = F.nth < 0 ? total + F.nth : F.nth
315
- if (idx < 0 || idx >= total) {
316
- return { matched: 0, total, nthOutOfRange: true, nth: F.nth }
317
- }
318
- } else if (total > 1 && !F.first && !F.near) {
319
- return {
320
- ambiguous: true,
321
- total,
322
- candidates: candidates.slice(0, 10).map((c, i) => ({
323
- idx: i,
324
- nodeId: c.info.nodeId,
325
- type: c.info.type,
326
- testID: c.info.testID,
327
- text: (c.info.text || '').slice(0, 60),
328
- abs: c.info.absolutePosition,
329
- layout: c.info.layout
330
- ? {
331
- width: Math.round(c.info.layout.width || 0),
332
- height: Math.round(c.info.layout.height || 0),
333
- }
334
- : null,
335
- ancestorTestIDs: (c.ancestorTestIDs || []).slice(0, 5),
336
- })),
337
- }
338
- }
339
-
340
- const picked = candidates[idx]
341
- const n = picked.info
342
- if (!n.absolutePosition || !n.layout) return { matched: 0, total }
343
-
344
- const resolved =
345
- typeof n.nodeId === 'number' &&
346
- typeof t.resolveTapTarget === 'function'
347
- ? await t.resolveTapTarget(n.nodeId)
348
- : null
349
- const target = (resolved && resolved.target) || n
350
- const cx =
351
- resolved && typeof resolved.cx === 'number'
352
- ? resolved.cx
353
- : n.absolutePosition.x + (n.layout.width || 0) / 2
354
- const cy =
355
- resolved && typeof resolved.cy === 'number'
356
- ? resolved.cy
357
- : n.absolutePosition.y + (n.layout.height || 0) / 2
358
- const scr = ${Pe}
359
- const offscreen =
360
- !!scr && (cx < 0 || cy < 0 || cx > scr.width || cy > scr.height)
361
- return {
362
- cx,
363
- cy,
364
- ...(offscreen ? { offscreen: true, screen: scr } : {}),
365
- match: {
366
- nodeId: n.nodeId ?? null,
367
- id: n.id,
368
- testID: n.testID,
369
- type: n.type,
370
- },
371
- target: {
372
- nodeId: target.nodeId ?? null,
373
- id: target.id,
374
- testID: target.testID,
375
- text:
376
- target.text ??
377
- target.accessibilityLabel ??
378
- n.text ??
379
- n.accessibilityLabel ??
380
- null,
381
- type: target.type,
382
- },
383
- strategy: (resolved && resolved.strategy) || 'matched-node',
384
- total,
385
- idx,
386
- }
387
- })()`})})}async function Xt(e,t,s={}){let a=JSON.stringify(t);return be(e,{agent:s.agent,timing:s.timing,textFallback:t,resolve:async()=>{let c=await e.send({type:"evaluate",code:`(async () => {
388
- const t = window.__sootsimTest
389
- if (!t) return { error: 'bridge-not-ready' }
390
- const byTestId =
391
- (await t.findByTestId(${a})) || (await t.findById(${a}))
392
- if (byTestId && byTestId.absolutePosition && byTestId.layout) {
393
- return {
394
- strategy: 'testid',
395
- node: {
396
- nodeId: byTestId.nodeId ?? null,
397
- id: byTestId.id,
398
- testID: byTestId.testID,
399
- type: byTestId.type,
400
- text: byTestId.text,
401
- absolutePosition: byTestId.absolutePosition,
402
- layout: byTestId.layout,
403
- },
404
- screen: ${Pe},
405
- }
406
- }
407
- const byText = await t.findByText(${a})
408
- if (byText && byText.absolutePosition && byText.layout) {
409
- return {
410
- strategy: 'text',
411
- node: {
412
- nodeId: byText.nodeId ?? null,
413
- id: byText.id,
414
- testID: byText.testID,
415
- type: byText.type,
416
- text: byText.text,
417
- absolutePosition: byText.absolutePosition,
418
- layout: byText.layout,
419
- },
420
- screen: ${Pe},
421
- }
422
- }
423
- return { strategy: 'none' }
424
- })()`});if(!c||!("node"in c))return c;let i=c.node,p=i.absolutePosition.x+i.layout.width/2,b=i.absolutePosition.y+i.layout.height/2,w=c.screen??null,y=!!w&&(p<0||b<0||p>w.width||b>w.height);return{...c,cx:p,cy:b,...y?{offscreen:!0,screen:w}:{},target:{id:i.id,testID:i.testID,text:c.strategy==="text"?t:i.text,type:i.type}}}})}async function Vt(e,t={args:[]}){let s=await mt(e);if(B(t.args)){D(s);return}console.log(` nodes: ${s.nodes}`)}function Ve(e,t){let s=e.indexOf(t);return s>=0&&s+1<e.length?e[s+1]:null}async function Qt(e){let{bridge:t,args:s,positional:a}=e,c=s.includes("--verbose")||s.includes("-v"),i=B(s),p=c&&!i,b=s.includes("--watch")||s.includes("-w"),w=1e3,y=s.includes("--compact"),h=s.includes("--no-xy"),x=s.includes("--no-clipped"),F=s.includes("--include-occluded"),M=Ve(s,"--testid-like"),_=Ve(s,"--only"),O=Ve(s,"--subtree"),d=a[1]&&!a[1].startsWith("-")?a[1]:void 0,q=d?/[*?]/.test(d):!1,P=!q&&!_?d:void 0,A=_??(q?d:void 0),J=async()=>{await pe(t,{verbose:p});let I=await yt(t,{describe:!0,verbose:c,filter:P||"",testIdLike:M||void 0,onlyGlob:A||void 0,subtreeRoot:O||void 0,compact:y,hideXy:h,includeOccluded:F,fullText:i}),R=I?.tree,H=I?.shell,K=I?.keyboard;if(i){D({shell:H,tree:R??"",keyboard:K});return}if(H&&typeof H=="object"){let j=[H.state?`state=${H.state}`:null,H.activeApp?`app=${H.activeApp}`:null,H.showSwitcher?"switcher":null,H.switcherPhase&&H.switcherPhase!=="idle"?`phase=${H.switcherPhase}`:null].filter(Boolean);j.length>0&&console.log(` shell: ${j.join(" ")}`)}if(typeof R=="string"&&R.startsWith("__SUBTREE_NOT_FOUND__:")){let j=R.slice(22);console.log(` subtree root not found: ${j}`),Q("subtree-root-not-found",j);return}if(!R){let j=I?.nodeCount??0;console.log(" no matching nodes found"),!(P||M||A||O)&&j<10&&Q("app-still-loading",j);return}let ee=R,te=0;if(x&&typeof ee=="string"){let j=ee.split(`
425
- `),le=[];for(let ve of j){if(ve.includes("(clipped:")){te+=1;continue}le.push(ve)}ee=le.join(`
426
- `)}console.log(ee),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let ie=P||M||A||O;if((P||M||A)&&!b&&Q("describe-filter-context"),!ie&&!b&&R.split(`
427
- `).length>=80&&Q("describe-use-filters"),K&&K.visible){let j=K.spec,le=[j?.keyboardType?`type=${j.keyboardType}`:null,j?.returnKeyType&&j.returnKeyType!=="default"?`return=${j.returnKeyType}`:null,K.mode!=="letters"?`mode=${K.mode}`:null,K.shifted?"shift":null,K.capsLock?"caps":null,j?.autoCapitalize&&j.autoCapitalize!=="sentences"?`autoCap=${j.autoCapitalize}`:null,K.accessoryBarId?`accessory=${K.accessoryBarId}`:null].filter(Boolean);console.log(`
428
- keyboard: ${le.join(" ")||"visible"}`)}};if(b)for(console.log(` watching... (Ctrl+C to stop)
429
- `);;)console.clear(),await J(),await oe(w);else await J()}var as=["SOOTSIM_AGENT","TM_SESSION","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function fe(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let e of as){let t=process.env[e];if(t&&t.trim()&&t!=="0")return!0}return!1}async function Zt(e){let{bridge:t,args:s,effectiveArgs:a,positional:c,inspectUsage:i}=e,p=I=>{let R=a.indexOf(I);return R>=0&&R+1<a.length?a[R+1]:null},b=I=>a.includes(I),w=p("--testid")||p("--test-id"),y=p("--role"),h=p("--type"),x=p("--text"),F=b("--pressable"),M=b("--visible"),_=b("--interactive-targets")||b("--actions"),O=!w&&!y&&!h&&!x&&!F&&!M&&!_?c[1]:null,d=x??O,q=await xt(t,{testId:w,role:y,type:h,text:d,pressable:F,visible:M,interactive:_});q||(console.error(i("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:P,result:A}=q,J=B(s),U=s.includes("--verbose")||s.includes("--dump");if(J)P==="interactive-targets"&&Array.isArray(A)?D(je(A).map(I=>({...I,tap:qe(I)}))):D(A??null);else if(Array.isArray(A))if(A.length===0){console.log(` no ${P} nodes found`);let I=await t.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof I=="number"&&I<10&&Q("app-still-loading",I)}else if(P==="interactive-targets"){let I=je(A);console.log(` found ${I.length} interactive target${I.length===1?"":"s"} (sorted by score):`);for(let R of I.slice(0,20)){let H=R.absolutePosition?`@(${Math.round(R.absolutePosition.x)},${Math.round(R.absolutePosition.y)})`:"",K=R.layout?`${Math.round(R.layout.width)}x${Math.round(R.layout.height)}`:"?x?",ee=R.text?` "${R.text.slice(0,30)}"`:"",te=R.testID?` #${R.testID}`:"",ie=R.accessibilityLabel?` \u24D8"${String(R.accessibilityLabel).slice(0,24)}"`:"",Se=R.accessibilityRole?`[${R.accessibilityRole}]`:R.type,j=qe(R);console.log(` ${Se}${ee}${ie}${te} ${K} ${H}`),console.log(` \u2192 ${j}`),U&&console.log(Qe(JSON.stringify(R,null,2)," "))}I.length>20&&console.log(` ... and ${I.length-20} more`)}else{console.log(` found ${A.length} node${A.length===1?"":"s"} (${P}):`);for(let I of A.slice(0,20)){let R=I.absolutePosition?`@(${Math.round(I.absolutePosition.x)},${Math.round(I.absolutePosition.y)})`:"",H=I.layout?`${Math.round(I.layout.width)}x${Math.round(I.layout.height)}`:"?x?",K=I.text?` "${I.text.slice(0,30)}"`:"",ee=I.testID?` #${I.testID}`:"",te=I.pressable?" (tap)":"",ie=I.accessibilityRole?`[${I.accessibilityRole}]`:I.type;console.log(` ${ie}${K}${ee} ${H} ${R}${te}`),U&&console.log(Qe(JSON.stringify(I,null,2)," "))}A.length>20&&console.log(` ... and ${A.length-20} more`)}else if(A==null)console.log(` not found: ${d||w||y||h||""||P}`),w&&Q("wait-selector-for-missing-testid",w);else{let I=A;if(I.type&&I.absolutePosition){let R=`@(${Math.round(I.absolutePosition.x)},${Math.round(I.absolutePosition.y)})`,H=I.layout?`${Math.round(I.layout.width)}x${Math.round(I.layout.height)}`:"?x?",K=I.text?` "${I.text.slice(0,40)}"`:"",ee=I.testID?` #${I.testID}`:"",te=I.pressable?" (tap)":"",ie=I.accessibilityRole?`[${I.accessibilityRole}]`:I.type;console.log(` ${ie}${K}${ee} ${H} ${R}${te}`),U&&console.log(Qe(JSON.stringify(I,null,2)," "))}else console.log(JSON.stringify(A,null,2))}}function Qe(e,t){return e.split(`
430
- `).map(s=>t+s).join(`
431
- `)}async function eo(e){let{bridge:t,args:s}=e,a=B(s);await pe(t,{verbose:!a});let c=s.includes("--styling"),i=s.indexOf("--filter"),p=i>=0?s[i+1]:void 0,b=await ht(t,{styling:c,filter:p});if(a){D({count:b.length,elements:b});return}console.log(` layout (${b.length} element${b.length===1?"":"s"}):
432
- `),console.log(bt(b,{styling:c}))}async function to(e,t={}){let s=await Ot(e);if("error"in s&&(console.error(s.error),process.exit(1)),t.json){console.log(JSON.stringify(s,null,2));return}let{visible:a,spec:c,mode:i,shifted:p,capsLock:b,accessoryBarId:w}=s,y=[];y.push(`keyboard: ${a?"visible":"hidden"}`),c?(y.push(` type: ${c.keyboardType}`),y.push(` returnKey: ${c.returnKeyType}`),y.push(` autoCap: ${c.autoCapitalize}`),y.push(` autoCorrect: ${c.autoCorrect?"on":"off"}`),y.push(` appearance: ${c.keyboardAppearance}`),c.secureTextEntry&&y.push(" secureTextEntry: true"),c.enablesReturnKeyAutomatically&&y.push(` return: ${c.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):y.push(" spec: <none> (shown via dev-tools with no TextInput)"),y.push(` mode: ${i}${p?" (shifted)":""}${b?" (caps)":""}`),w&&y.push(` accessoryBar: ${w}`),console.log(y.join(`
433
- `))}async function oo(e){let t=await e.bridge.listSims(),s=e.args.includes("--all"),a=e.args.find((b,w)=>e.args[w-1]==="--bundle"),c=e.args.find((b,w)=>e.args[w-1]==="--app-port"),i=e.args.includes("--primary"),p=t.filter(b=>!(i&&!b.isPrimary||a&&!(b.url??"").includes(a)||c&&!(b.url??"").includes(`/rn/${c}`)||!s&&!a&&!c&&!i&&!(b.url&&(b.url.includes("bundle=")||b.url.includes("/index.bundle")))&&b.id!==e.simId));if(B(e.args)){D(p.map(b=>({...b,active:b.id===e.simId})));return}Bt(p,e.simId),p.length<t.length&&!B(e.args)&&console.log(` (${t.length-p.length} more hidden \u2014 pass --all to show)`)}function re(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function ls(e,t){return t<=0?"?":`${(e/t*100).toFixed(0)}%`}function cs(e){let t={},s=(a,c)=>{c&&(c.nodesRegistered!=null&&(t[`${a}.nodes`]=c.nodesRegistered),c.nodesDetached!=null&&(t[`${a}.detached`]=c.nodesDetached),c.objects&&(t[`${a}.paragraphs`]=c.objects.paragraphs,t[`${a}.yogaNodes`]=c.objects.yogaNodes,t[`${a}.pictures`]=c.objects.pictures,t[`${a}.rasterImages`]=c.objects.rasterImages),c.imageLoader&&(t[`${a}.imageCacheEntries`]=c.imageLoader.cacheEntries,t[`${a}.imagePixelBytes`]=c.imageLoader.cachePixelBytes),c.workerHeap&&(t[`${a}.heapBytes`]=c.workerHeap.usedJSHeapSize),c.wasmHeapBytes!=null&&(t[`${a}.wasmHeapBytes`]=c.wasmHeapBytes))};return s("tenant",e.tenant),s("shell",e.shell),s("compositor",e.compositor),e.hostHeap&&(t["host.heapBytes"]=e.hostHeap.usedJSHeapSize),t}function so(e,t){return e.endsWith("Bytes")?re(t):String(t)}function Ze(e,t){if(!t){console.log(` ${e}: not available`);return}let s=t.objects;if(console.log(` ${e}`),t.nodesRegistered!=null&&console.log(` nodes registered: ${t.nodesRegistered}`),t.nodesDetached!=null){let a=Object.entries(t.detachedTypes??{}).map(([c,i])=>`${c}:${i}`).join(" ");console.log(` nodes detached: ${t.nodesDetached}${a?` (${a})`:""}`)}if(s&&(console.log(` paragraphs: ${s.paragraphs}`),console.log(` yoga nodes: ${s.yogaNodes}`),console.log(` pictures: ${s.pictures}`),console.log(` raster images: ${s.rasterImages}`)),t.activeNativeAnimations!=null&&console.log(` native anims: ${t.activeNativeAnimations}`),t.imageLoader){let a=t.imageLoader;console.log(` image cache: ${a.cacheEntries}/${a.cacheMaxEntries} entries, ${re(a.cachePixelBytes)}/${re(a.cachePixelBudget)} (${ls(a.cachePixelBytes,a.cachePixelBudget)})`)}t.workerHeap&&console.log(` js heap: ${re(t.workerHeap.usedJSHeapSize)} used / ${re(t.workerHeap.totalJSHeapSize)} total`),t.wasmHeapBytes!=null&&console.log(` canvaskit wasm: ${re(t.wasmHeapBytes)}`)}function ds(e){console.log(" memory:"),Ze("tenant worker",e.tenant),Ze("shell worker",e.shell),Ze("compositor worker",e.compositor),e.hostHeap?(console.log(" host"),console.log(` js heap: ${re(e.hostHeap.usedJSHeapSize)} used / ${re(e.hostHeap.totalJSHeapSize)} total`)):console.log(" host js heap: not available (chrome only)")}function us(e,t,s){let a=e.indexOf(t);if(a===-1)return s;let c=Number(e[a+1]);return Number.isFinite(c)&&c>0?c:s}async function no(e,t={args:[]}){let s=B(t.args),a=t.args.indexOf("--watch");if(a===-1){let O=await Je(e);if(s){D(O);return}ds(O);return}let c=Number(t.args[a+1]),i=Number.isFinite(c)&&c>0?c:60,p=us(t.args,"--interval",5),b=[],w=Date.now(),y=null;for(s||console.log(` sampling every ${p}s for ${i}s \u2014 deltas per tick:`);;){let O=await Je(e),d=(Date.now()-w)/1e3,q=cs(O);if(b.push({tSec:d,counters:q}),!s){let P=[];for(let[A,J]of Object.entries(q)){let U=y&&A in y?J-y[A]:null;if(U===null||U===0)continue;let I=U>0?"+":"-",R=A.endsWith("Bytes")?`${I}${re(Math.abs(U))}`:`${I}${Math.abs(U)}`;P.push(`${A} ${so(A,J)} (${R})`)}console.log(` t+${d.toFixed(0)}s ${P.length?P.join(" "):y?"no change":Object.entries(q).map(([A,J])=>`${A} ${so(A,J)}`).join(" ")}`)}if(y=q,d>=i)break;await new Promise(P=>setTimeout(P,p*1e3))}let h=b[0],x=b[b.length-1],F=Math.max(x.tSec-h.tSec,.001),M={};for(let O of Object.keys(x.counters))O in h.counters&&(M[O]=(x.counters[O]-h.counters[O])/F);if(s){D({samples:b,perSecond:M,elapsedSec:F});return}console.log(`
434
- slope over ${F.toFixed(0)}s:`);let _=Object.entries(M).filter(([,O])=>O!==0).sort((O,d)=>Math.abs(d[1])-Math.abs(O[1]));if(_.length===0){console.log(" all counters flat");return}for(let[O,d]of _){let q=O.endsWith("Bytes")?`${re(Math.abs(d))}/s${d<0?" (shrinking)":""}`:`${d>0?"+":""}${d.toFixed(2)}/s`;console.log(` ${O.padEnd(28)}${q}`)}}var Z="<redacted secure text>";function we(e){let t=e?.layout?.spec??e?.spec??null;return!!t?.secureTextEntry&&t.keyboardType!=="visible-password"}function et(e,t){return we(t)?Z:e}function tt(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"?Z:t.text}}}function xe(e,t){let s=e.indexOf("--testid");if(s>=0&&e[s+1])return{mode:"testid",value:e[s+1]};let a=e.indexOf("--test-id");if(a>=0&&e[a+1])return{mode:"testid",value:e[a+1]};let c=e.indexOf("--text");if(c>=0&&e[c+1])return{mode:"text",value:e[c+1]};let i=t?.[1];return i&&!i.startsWith("-")&&!Number.isFinite(Number(i))?{mode:"testid",value:i}:null}async function Ee(e,t){let s=JSON.stringify(t.value),a=t.mode==="testid"?`(await t.findByTestId(${s})) || (await t.findById(${s}))`:`await t.findByText(${s})`;return await e.send({type:"evaluate",code:`(async () => {
435
- const t = window.__sootsimTest
436
- if (!t) return null
437
- const n = ${a}
438
- if (!n || !n.absolutePosition || !n.layout) return null
439
- const resolved =
440
- typeof n.nodeId === 'number' && typeof t.resolveTapTarget === 'function'
441
- ? await t.resolveTapTarget(n.nodeId)
442
- : null
443
- const cx =
444
- typeof resolved?.cx === 'number'
445
- ? resolved.cx
446
- : n.absolutePosition.x + (n.layout.width || 0) / 2
447
- const cy =
448
- typeof resolved?.cy === 'number'
449
- ? resolved.cy
450
- : n.absolutePosition.y + (n.layout.height || 0) / 2
451
- return {
452
- x: cx,
453
- y: cy,
454
- id: n.id ?? null,
455
- testID: n.testID ?? null,
456
- text: ${JSON.stringify(t.mode==="text")} ? ${s} : (n.text ?? n.accessibilityLabel ?? null),
457
- type: n.type ?? null,
458
- }
459
- })()`})??null}async function ro(e,t={}){let{nav:s,route:a,keyboard:c,shell:i}=await Rt(e);if(t.json){console.log(JSON.stringify({shell:i??null,nav:s,route:a,keyboard:c},null,2));return}let p=[];if(i){let b=i.activeApp??i.state??"<none>",w=i.showSwitcher?" (app switcher open)":"",y=typeof i.launchProgress=="number"&&i.launchProgress<.98?` launching (${Math.round(i.launchProgress*100)}%)`:"";p.push(`shell: ${b}${w}${y}`)}else p.push("shell: <unavailable>");if(s){let b=s.transitionPhase!=="idle"?` (${s.transitionPhase}, ${s.activeTransitionCount} active)`:"";if(p.push(`nav: phase=${s.transitionPhase}${b}`),s.screens.length===0)p.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let w of s.screens){let y=w.isActive?"\u25B6":" ",h=w.routeName?` ${w.routeName}`:"",x=w.headerHeight>0?` header=${w.headerHeight}`:"",F=w.largeTitleState&&w.largeTitleState!=="expanded"?` large-title=${w.largeTitleState}`:"";p.push(` ${y} #${w.id}${h}${x}${F}`)}}else p.push("nav: <runtime not available>");if(p.push(`route: ${a?.currentPath??"<unavailable>"}`),a?.coveringPath&&p.push(`covered: a presented screen (${a.coveringPath}) is above this route`),c&&c.visible){let b=c.spec?.keyboardType??"default",w=c.spec?.returnKeyType??"default";p.push(`keyboard: visible (${b}, return=${w}, mode=${c.mode??"?"})`)}else p.push("keyboard: hidden");console.log(p.join(`
460
- `))}async function io(e){let{bridge:t,args:s,positional:a}=e,c=a[1]?Number(a[1])*1e3:3e3,i=s.includes("--strict"),{elapsed:p,settled:b}=await se({bridge:t,maxMs:c,strict:i});console.log(b?` settled in ${p}ms`:` timed out after ${p}ms (may still be animating)`)}async function ao(e){let t=e.positional[1]?Number(e.positional[1]):.5;(!Number.isFinite(t)||t<0)&&(console.error(e.inspectUsage("sleep","[seconds]")),process.exit(1)),await oe(t*1e3),console.log(` slept ${t}s`)}async function lo(e){let{bridge:t,args:s,positional:a}=e,c=s.includes("--boxes"),i=a[1]?Number(a[1]):c?50:5,{tree:p}=await ft(t,i,c?{format:"boxes"}:void 0);if(B(s)){D({depth:i,tree:p??null});return}console.log(typeof p=="string"?p:JSON.stringify(p,null,2))}async function co(e,t={args:[]}){let s=await gt(e);if(B(t.args)){D(s);return}console.log(s.url)}async function uo(e){let{wsPort:t,commandTimeoutMs:s,simId:a,simIdSource:c,positional:i}=e,p=i[1]?Number(i[1]):30,b=Math.max(1e3,(Number.isFinite(p)?p:30)*1e3),w=Math.max(1,Math.ceil(b/500));console.log(" waiting for sim reconnect...");let y=await Pt(t,s,a,{attempts:w,simIdSource:c});y||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),y.bridge.close(),Re({source:"inspect wait",step:{wait:b},summary:`wait ${Math.round(b/1e3)}s`}),console.log(` ready: ${y.count} nodes`)}var po=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 Ae(e,t){let s=e.indexOf(t);if(s>=0&&s+1<e.length)return e[s+1]}function ps(e,t){if(!t.filter&&!t.equals)return!0;let s=e.data,a=[];if(s&&typeof s=="object")for(let i of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let p=s[i];typeof p=="string"&&p.length>0&&a.push(p)}let c=a.join(" ");return t.equals?a.some(i=>i===t.equals):t.filter?c.toLowerCase().includes(t.filter.toLowerCase()):!0}async function mo(e){let{bridge:t,args:s,positional:a,inspectUsage:c}=e,i=a[1];i||(console.error(c("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),po.has(i)||console.error(` warning: '${i}' is not a known timeline kind \u2014 waiting anyway. known: ${[...po].sort().join(", ")}`);let p=Ae(s,"--max-ms"),b=p&&Number.isFinite(Number(p))?Math.max(100,Number(p)):5e3,w=Ae(s,"--filter"),y=Ae(s,"--equals"),h=Ae(s,"--since")??"now",x=s.includes("--json"),F=Date.now(),M=F+b,_=200,O=F;for(;Date.now()<M;){let q={kinds:[i],since:h==="cursor"?void 0:O,limit:50},P=await t.send({type:"evaluate",code:`(async () => {
461
- const t = window.SootSim?.bridges?.timeline
462
- if (!t) return { ok: false, error: 'timeline bridge missing' }
463
- return { ok: true, result: await t.recent(${JSON.stringify(q)}) }
464
- })()`});(!P||!P.ok)&&(console.error(` could not query timeline: ${P&&"error"in P?P.error:"unknown"}`),process.exit(1));let A=P.result.events??[];for(let J of A)if(ps(J,{filter:w,equals:y})){let U=Date.now()-F;console.log(x?JSON.stringify({found:!0,elapsedMs:U,event:J}):` ${i} event after ${U}ms${w?` (filter: ${w})`:""}${y?` (equals: ${y})`:""}`);return}P.result.watermark&&P.result.watermark>O&&(O=P.result.watermark),await new Promise(J=>setTimeout(J,_))}let d=Date.now()-F;x?console.log(JSON.stringify({found:!1,elapsedMs:d,kind:i,filter:w,equals:y})):console.error(` \u26A0 wait event ${i} timed out after ${d}ms${w?` (filter: ${w})`:""}${y?` (equals: ${y})`:""}`),process.exit(1)}async function fo(e){let{bridge:t,args:s}=e,a=s.includes("--strict"),c=Ie(s,3e3),{elapsed:i,settled:p}=await se({bridge:t,maxMs:c,strict:a});p?console.log(` idle in ${i}ms`):(console.error(` \u26A0 wait idle timed out after ${i}ms (may still be animating)`),process.exit(1))}async function go(e){let{bridge:t,args:s}=e,a=Ie(s,2e4),{ready:c,elapsedMs:i,nodes:p,targets:b,liveFrameActive:w,liveFrameChannels:y,flag:h,loadingText:x,externalReady:F,externalError:M,suppressedEntryError:_,errors:O,bridgeError:d}=await $t(t,a,{onProgress(P){console.error(` still waiting after ${P.elapsedMs}ms \u2014 ${Le(P)} (nodes: ${P.nodes}, targets: ${P.targets}, live surfaces: ${P.liveFrameActive?P.liveFrameChannels:0}, errors: ${P.errors})`)}});if(c){let P=a-i,A=Math.max(100,Math.min(1e4,P)),J=await se({bridge:t,maxMs:A,pollMs:32,stablePolls:2});J.settled||(console.error(` \u26A0 wait ready timed out after ${i+J.elapsed}ms \u2014 app mounted but did not settle (nodes: ${p}, targets: ${b})`),process.exit(1)),console.log(` ready in ${i+J.elapsed}ms: ${p} nodes, ${b} targets${w?`, ${y} live surfaces`:""}`);return}let q=Le({externalError:M,loadingText:x,externalReady:F,flag:h,targets:b,suppressedEntryError:_,bridgeError:d});console.error(` \u26A0 wait ready timed out after ${i}ms \u2014 ${q} (nodes: ${p}, targets: ${b}, live surfaces: ${w?y:0}, errors: ${O})`),process.exit(1)}async function yo(e){let{bridge:t,args:s,positional:a,inspectUsage:c}=e,i=a[1];i||(console.error(c("wait selector","<testid> [--max-ms 5000] [--gone]")),process.exit(1));let p=s.indexOf("--max-ms"),b=p>=0&&s[p+1]?Math.max(100,Number(s[p+1])):5e3,w=s.includes("--gone"),{found:y,node:h,elapsed:x}=await St(t,i,b,{gone:w});if(w){y?console.log(` #${i} gone after ${x}ms`):(console.error(` \u26A0 wait selector #${i} --gone timed out after ${x??b}ms (still present)`),process.exit(1));return}if(y&&h){let F=h.absolutePosition?`@(${Math.round(h.absolutePosition.x)},${Math.round(h.absolutePosition.y)})`:"",M=h.layout?`${Math.round(h.layout.width)}x${Math.round(h.layout.height)}`:"?x?";console.log(` found #${i} in ${x}ms ${M} ${F}`)}else console.error(` \u26A0 wait selector #${i} timed out after ${x??b}ms`),process.exit(1)}function Mo(e){return e==null?"\u2014":e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}K`:`${(e/1024/1024).toFixed(1)}M`}function No(e){return e==null?" \u2026":e<1e3?`${e}ms`.padStart(5):`${(e/1e3).toFixed(2)}s`.padStart(5)}function ho(){process.stderr.write(` the sim is not responding. recover it with:
465
- rnxsim close --sim <id> # force-close the wedged sim
466
- rnxsim list # confirm it's gone
467
- `)}async function $e(e,t){let s=await e.send({type:"perform",steps:[t]}),a=s?.steps?.[0],c=a?.error??s?.error;return{ok:s?.ok===!0,value:a?.value,...c?{error:c}:{}}}async function fs(e){try{return await e.send({type:"evaluate",code:"1"},{timeoutMs:3e3}),!0}catch{return!1}}async function gs(e,t){try{let s=await e.send({type:"evaluate",code:`(async () => {
468
- const t = window.__sootsimTest
469
- if (!t || typeof t.queryAll !== 'function') return []
470
- try {
471
- // queryAll is async in render-worker mode (the canonical mode now)
472
- // because the call has to round-trip the worker \u2014 must await it.
473
- // a sync result is still handled fine since await on a non-Promise
474
- // is a no-op.
475
- const nodes = await t.queryAll({})
476
- if (!Array.isArray(nodes)) return []
477
- const out = new Set()
478
- for (const n of nodes) {
479
- const id = n && (n.testID || n.id)
480
- if (typeof id === 'string' && id) out.add(id)
481
- }
482
- return Array.from(out)
483
- } catch {
484
- return []
485
- }
486
- })()`});if(!Array.isArray(s)||s.length===0)return;let a=t.toLowerCase(),c=s.map(i=>({id:i,score:ys(a,i.toLowerCase())})).filter(i=>i.score<a.length+4).sort((i,p)=>i.score-p.score).slice(0,5);if(c.length===0)return;console.error(" similar testIDs:");for(let i of c)console.error(` ${i.id}`)}catch{}}function ys(e,t){if(t===e)return 0;if(t.includes(e))return 1;if(e.includes(t))return 2;let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s+=1;return hs(e,t)-s}function hs(e,t){if(e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let s=new Array(t.length+1),a=new Array(t.length+1);for(let c=0;c<=t.length;c++)s[c]=c;for(let c=1;c<=e.length;c++){a[0]=c;for(let p=1;p<=t.length;p++)a[p]=Math.min(s[p]+1,a[p-1]+1,s[p-1]+(e[c-1]===t[p-1]?0:1));let i=s;s=a,a=i}return s[t.length]}function bs(e){return e.error?"err":e.status==null?" \u2026 ":String(e.status)}function bo(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 wo(e){let t=ae(e.startTs),s=bs(e).padEnd(3),a=e.method.padEnd(5),c=Mo(e.size).padStart(6),i=No(e.durationMs);console.log(` [${t}] ${s} ${a} ${c} ${i} ${e.displayUrl}`),e.error&&console.log(` error: ${e.error}`)}function ws(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",ae(e.startTs)],["duration",No(e.durationMs).trim()],["size",Mo(e.size)],["content-type",e.type??"\u2014"]];for(let[s,a]of t)console.log(` ${s.padEnd(13)} ${a}`)}var xs={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},xo="\x1B[0m",$s="\x1B[2m";function $o(e,t){let s=ae(e.ts),a=e.level.toUpperCase().padEnd(5),c=e.args.join(" ");if(t){let i=xs[e.level];console.log(` ${$s}[${s}]${xo} ${i}${a}${xo} ${c}`)}else console.log(` [${s}] ${a} ${c}`);if(e.stack&&e.level==="error"){let i=e.stack.split(`
487
- `).slice(0,5);for(let p of i)console.log(` ${p.trim()}`)}}var Ss=120;async function So(e,t){let s=e.find((F,M)=>e[M-1]==="--id"),a=e.find((F,M)=>e[M-1]==="--text");if(s||a){let F=await t.send({type:"evaluate",code:_t({id:s,text:a})});if(!F)throw new Error(s?`no node with id "${s}"`:`no node matching text "${a}"`);let{x:M,y:_,w:O,h:d}=F;return{x:M,y:_,w:O,h:d}}let c=e.find((F,M)=>e[M-1]==="--area");if(c){let F=c.split(",").map(q=>Number(q.trim()));if(F.length!==4||F.some(q=>!Number.isFinite(q)))throw new Error(`--area expects x,y,w,h (got "${c}")`);let[M,_,O,d]=F;return{x:M,y:_,w:O,h:d}}let i=F=>{let M=e.find((O,d)=>e[d-1]===F);if(M==null)return null;let _=Number(M);return Number.isFinite(_)?_:null},p=i("--x"),b=i("--y"),w=i("--w"),y=i("--h");if(p!=null||b!=null||w!=null||y!=null)return{x:p??0,y:b??0,w:w??1,h:y??1};let x=e.filter((F,M)=>M>0&&!F.startsWith("-")&&e[M-1]!=="--output"&&e[M-1]!=="--area"&&e[M-1]!=="--id"&&e[M-1]!=="--text"&&e[M-1]!=="--x"&&e[M-1]!=="--y"&&e[M-1]!=="--w"&&e[M-1]!=="--h").map(Number).filter(F=>Number.isFinite(F));if(x.length>=2){let[F,M,_=1,O=1]=x;return{x:F,y:M,w:_,h:O}}return null}function vo(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 s=[t.boundaryRecordsInvalidated?`invalidated ${t.boundaryRecordsInvalidated}`:"",t.boundaryRecordsOrigin?`moved ${t.boundaryRecordsOrigin}`:"",t.boundaryRecordsScheme?`first-record ${t.boundaryRecordsScheme}`:""].filter(Boolean).join(" \xB7 ");s&&console.log(` why recorded: ${s}`),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 a=[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 ");a&&(console.log(` raster skips: ${a} (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 ko(e){let t=e.avgMs>0?(1e3/e.avgMs).toFixed(1):"?",s=e.jank&&typeof e.jank=="object"?e.jank:null,a=e.compositorProduction&&typeof e.compositorProduction=="object"?e.compositorProduction:null,c=a?.budgetMs??8;if(console.log(` shell frame profile:
488
- `),s){let h=(Array.isArray(s.compositor)?s.compositor:[]).reduce((x,F)=>x+(F.jankPaints??0),0);console.log(` health: ${s.detected?"jank or cadence gaps observed":"no jank or cadence gaps observed"} \xB7 shell ${s.shell?.jankFrames??0} \xB7 compositor ${h} \xB7 host clock gaps ${s.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`),s){console.log(` shell jank: ${s.shell?.jankFrames??0}/${s.shell?.sampledFrames??0} (${s.shell?.jankPct??0}%) >${c}ms \xB7 max ${s.shell?.maxMs??0}ms`);for(let y of Array.isArray(s.compositor)?s.compositor:[])console.log(` ${String(y.surfaceId).padEnd(12)} ${y.jankPaints}/${y.sampledPaints} compositor paints (${y.jankPct}%) >${c}ms \xB7 max ${y.maxMs}ms`)}else console.log(` jank: ${e.jankFrames} frames (${e.jankPct}%) >${c}ms`);if(console.log(` avg per frame: overlay ${e.avgOverlayMs}ms \xB7 aux ${e.avgAuxMs}ms \xB7 layout ${e.avgLayoutMs}ms`),a){let y=a.frames??{};console.log(""),console.log(` compositor production (${c}ms budget):`),console.log(` frames: ${y.count??0} \xB7 avg ${Number(y.avg??0).toFixed(2)} / p95 ${Number(y.p95??0).toFixed(2)} / max ${Number(y.max??0).toFixed(2)} ms \xB7 ${a.overBudget??0} over budget (${a.overBudgetPct??0}%)`);let h=[["javascript","javascript"],["layout","layout"],["paint","paint"],["prewarm","prewarm"],["texture upload","textureUpload"],["gpu submit","gpuSubmit"],["composite","composite"],["capture/readback","capture"]];for(let[M,_]of h){let O=a.phases?.[_];!O?.count||!O.max&&!O.avg||console.log(` ${M.padEnd(16)} avg ${Number(O.avg??0).toFixed(2)} / p95 ${Number(O.p95??0).toFixed(2)} / max ${Number(O.max??0).toFixed(2)} ms`)}let x=a.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 F=Array.isArray(a.worstFrames)?a.worstFrames.slice(0,5):[];if(F.length>0){console.log(" worst frames:");for(let M of F){let _=M.phases??{};console.log(` ${Number(M.productionMs??0).toFixed(2)}ms frame ${M.frameToken??"?"} \xB7 js ${Number(_.javascriptMs??0).toFixed(2)} \xB7 layout ${Number(_.layoutMs??0).toFixed(2)} \xB7 paint ${Number(_.paintMs??0).toFixed(2)} \xB7 prewarm ${Number(_.prewarmMs??0).toFixed(2)} \xB7 upload ${Number(_.textureUploadMs??0).toFixed(2)} \xB7 submit ${Number(_.gpuSubmitMs??0).toFixed(2)} \xB7 composite ${Number(_.compositeMs??0).toFixed(2)} \xB7 capture ${Number(_.captureMs??0).toFixed(2)}`)}}}let i=e.cadence;i&&typeof i=="object"&&(console.log(""),console.log(` cadence (frame delivery, ${i.vsyncTicks} vsync ticks):`),console.log(` display clock: ${i.displayHz}hz \xB7 host rAF interval p50 ${i.hostIntervalP50} / p95 ${i.hostIntervalP95} / max ${i.hostIntervalMax} ms${i.hostGaps?` \xB7 ${i.hostGaps} gaps >1.5x (host rAF starved)`:""}`),console.log(` delivery lag: p50 ${i.deliveryLagP50} / p95 ${i.deliveryLagP95} / max ${i.deliveryLagMax} ms (vsync postMessage \u2192 shell receipt)`),console.log(` paint interval: p50 ${i.paintIntervalP50} / p95 ${i.paintIntervalP95} / max ${i.paintIntervalMax} ms${i.idleBreaks?` \xB7 ${i.idleBreaks} idle breaks excluded`:""}`));let p=e.compositorCadence;if(p&&typeof p=="object"){console.log(` compositor rAF: p50 ${p.p50} / p95 ${p.p95} / max ${p.max} ms \xB7 ${p.gaps} gaps >1.5x`);let y=(h,x)=>{x?.count&&console.log(` ${h}: ${x.count} samples \xB7 p50 ${x.p50.toFixed(2)} / p95 ${x.p95.toFixed(2)} / max ${x.max.toFixed(2)} ms`)};y("engine-empty rAF",p.phases?.uninterruptedEngineEmpty),y("rAF with CanvasKit flush",p.phases?.withCanvaskitFlush),y("rAF after CanvasKit flush",p.phases?.afterCanvaskitFlush),y("CanvasKit submission",p.canvaskitSubmission)}let b=Array.isArray(e.auxSurfaces)?e.auxSurfaces:[];if(b.length>0){console.log(""),console.log(" surfaces (last 100 frames):");for(let y of b)console.log(` ${String(y.surfaceId).padEnd(10)} ${String(y.frames).padStart(4)} paints avg ${y.avgMs}ms (layout ${y.avgLayoutMs}, render ${y.avgRenderMs}, flush ${y.avgFlushMs}) max ${y.maxMs}ms`),typeof y.gpuCacheBytes=="number"&&typeof y.gpuCacheLimitBytes=="number"&&console.log(` ${"".padEnd(10)} gpu cache ${(y.gpuCacheBytes/1024/1024).toFixed(1)}MB/${(y.gpuCacheLimitBytes/1024/1024).toFixed(1)}MB`)}vo("shell worker",e.renderProfile),vo("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 y of w){if(y.source==="compositor"){console.log(` ${String(y.totalMs).padStart(7)}ms compositor ${y.surfaceId} paint ${y.paint} \xB7 layout ${y.layoutMs} \xB7 render ${y.renderMs} \xB7 flush ${y.flushMs}`);continue}let h=(y.auxSurfaces??[]).map(x=>`${x.surfaceId} ${x.totalMs}ms (layout ${x.layoutMs}, render ${x.renderMs})`).join(" \xB7 ");console.log(` ${String(y.totalMs).padStart(7)}ms overlay ${y.overlayMs} \xB7 aux ${y.auxMs} \xB7 layout ${y.layoutMs}${h?` [${h}]`:""}`)}}}async function _e(e,t,s){let a=Date.now()+t,c=await ue(e,t);for(;;){if(s(c))return{settled:!0,state:c};if(Date.now()>=a)return{settled:!1,state:c};await oe(16),c=await ue(e)}}async function st(e){return e.send({type:"evaluate",code:`(async () => {
489
- const kb = window.__sootsimKeyboard
490
- const test = window.__sootsimTest
491
- if (!kb) return { error: 'keyboard bridge not available' }
492
- const layout = typeof kb.getLayout === 'function' ? kb.getLayout() : null
493
- const secureTextEntry =
494
- !!layout?.spec?.secureTextEntry && layout?.spec?.keyboardType !== 'visible-password'
495
- const visible = kb.isVisible()
496
- const mode = kb.getMode()
497
- let focused = null
498
- if (test && typeof test.getFocusedNode === 'function') {
499
- try {
500
- focused = await test.getFocusedNode()
501
- } catch {}
502
- }
503
- let runtimeSnapshot = null
504
- if (test && typeof test.getFocusKeyboardSnapshot === 'function') {
505
- try {
506
- runtimeSnapshot = await test.getFocusKeyboardSnapshot()
507
- } catch {}
508
- }
509
- return {
510
- visible,
511
- mode,
512
- layout,
513
- hostedEditorFocused:
514
- typeof kb.hasHostedEditorFocus === 'function' && kb.hasHostedEditorFocus(),
515
- focusedInput: focused ? {
516
- nodeId: focused.nodeId ?? null,
517
- testID: focused.testID || null,
518
- id: focused.id || null,
519
- placeholder: focused.placeholder || null,
520
- secureTextEntry,
521
- text: secureTextEntry ? ${JSON.stringify(Z)} : (focused.text || null),
522
- } : null,
523
- phase: runtimeSnapshot?.keyboard?.phase ?? null,
524
- frame: runtimeSnapshot?.keyboard?.frame ?? null,
525
- focusedRect: runtimeSnapshot?.focused?.rect ?? null,
526
- }
527
- })()`}).then(t=>tt(t))}function vs(e,t,s){if(!e.visible)return!1;let a=e.focusedInput;return!(t&&a&&!(a.testID===t||a.id===t)||s!==null&&we(e)!==s)}async function ks(e,t=600,s={}){let a=Date.now()+t;for(;Date.now()<=a;){let c=await st(e);if(vs(c,s.targetId??null,s.secureTextEntry??null))return c;await oe(30)}return st(e)}async function De(e,t){let s=await st(e);if(s.visible&&(s.focusedInput||s.hostedEditorFocused))return s;s.visible&&(console.error(` ${t} requires a focused editable control. the iOS keyboard is visible, but no input owns focus.`),process.exit(1)),console.error(` ${t} requires the iOS keyboard to be visible. focus an input first with rnxsim do tap-id/tap-text or rnxsim do type-into.`),process.exit(1)}async function Io(e,t,s){return t==="appearance"?e.send({type:"evaluate",code:`(async () => {
528
- const requested = ${JSON.stringify(s??"toggle")}
529
- // the engine owns toggle + auto resolution (settingsStore is the single
530
- // source of truth). never infer the current scheme client-side \u2014 the old
531
- // documentElement '#333333' sniff is never set in embedded / shell-chrome
532
- // contexts, so 'toggle' read 'light' forever and stuck on the boot scheme.
533
- window.postMessage({ type: 'contrast-action', action: 'set-appearance', value: requested }, '*')
534
- // let the engine's message handler apply + publish window.__sootsimColorScheme
535
- await new Promise((r) => setTimeout(r, 60))
536
- const applied = window.__sootsimColorScheme?.resolved
537
- ?? (window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light')
538
- const setting = window.__sootsimColorScheme?.setting ?? requested
539
- return { ok: true, requested, setting, applied }
540
- })()`}):t==="lock"?e.send({type:"evaluate",code:`(async () => {
541
- const toggleLock = window.SootSim?.bridges?.mainShell?.toggleLock
542
- if (typeof toggleLock !== 'function') {
543
- throw new Error('rnx mainShell.toggleLock bridge unavailable')
544
- }
545
- await toggleLock()
546
- return { ok: true, action: 'lock' }
547
- })()`}):e.send({type:"evaluate",code:`(async () => {
548
- window.dispatchEvent(new CustomEvent('sootsim:shake'))
549
- return { ok: true, action: 'shake' }
550
- })()`})}function Is(e){let t={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(t[e])return t[e];let s=e.match(/^Digit([0-9])$/);if(s)return s[1];let a=e.match(/^Key([A-Z])$/);return a?a[1].toLowerCase():null}function Ts(e){if(typeof e!="string")return null;let t=e.replace(/\s+/g," ").trim();return t?t.slice(0,80):null}function Fo(...e){for(let t of e){if(typeof t!="string")continue;let s=t.trim();if(s)return s}return null}function Ms(e){let t=e.indexOf("--node-id");if(t<0)return null;let s=e[t+1];if(!s)return null;let a=Number(s);return Number.isInteger(a)&&a>0?a:null}async function W(e,t,s){let a=Re({source:e,step:t,summary:s});a.active&&(a.replaced?console.error(` draft: replaced unkept action "${a.replaced.summary}" \u2014 \`maestro keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `rnxsim maestro keep` to commit"))}function To(e,t,s){if(!s||s.hit===!1)return null;let a=Fo(s.responderTestID,s.testID);if(a)return{step:{tapOn:{id:a}},summary:`tap #${a}`};let c=Ts(s.text);return c?{step:{tapOn:c},summary:`tap "${c}"`}:{step:{tapAtCoords:{x:e,y:t}},summary:`tap @${Math.round(e)},${Math.round(t)}`}}function ot(e,t,s){let a=Fo(t?.testID,t?.id);return a?{step:{tapOn:{id:a}},summary:`tap #${a}`}:s==="id"?{step:{tapOn:{id:e}},summary:`tap #${e}`}:{step:{tapOn:e},summary:`tap "${e}"`}}async function Er(e,t){let s=e[0]==="get"||e[0]==="do"||e[0]==="debug"||e[0]==="wait"?e[0]:null,a=s?e.slice(1):e,c=lt(a,{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","--no-clipped","--include-occluded"],stripValueFlags:["--output","--nth","--index","--testid","--test-id","--text","--node-id","--max-ms","--filter","--limit","--level","--threshold","--equals","--since","--testid-like","--only","--subtree"]}),i=c.positional,p=i[0],b=s==="get"||s==="do"||s==="debug"||s==="wait"?s:"inspect",w=typeof a[0]=="string"&&nt.has(a[0]),y=w?a[0]:null,h=S=>t.internalPerfCommand&&S==="perf"?`rnxsim perf ${t.internalPerfCommand}`:w&&S===a[0]?`rnxsim ${S}`:`rnxsim ${b} ${S}`,x=(S,o)=>` usage: ${h(S)}${o?` ${o}`:""}`;if(!p||e.includes("--help")||e.includes("-h")){let S={bridgePort:7668,defaultShellUrl:it};if(b==="do"||b==="get"||b==="debug"||b==="wait"){let r=Be(b,S);r&&(console.log(`${r}
551
- `),process.exit(0))}if(y==="shell"){let r=Ce("shell",S);r&&(console.log(`${r}
552
- `),process.exit(0))}let o=Ce("inspect",S),n=["do","get","debug","wait"].map(r=>Be(r,S)).filter(r=>r!=null).join(`
553
-
554
- `);console.log(`${o??""}
555
-
556
- ${n}
557
- `),process.exit(0)}let F=c.wsPort,M=c.simId,_=c.simIdSource,O=c.commandTimeoutMs;if(b==="get"&&p==="diagnosis"){let S=a.indexOf("diagnosis"),o=S>=0?[...a.slice(0,S),...a.slice(S+1)]:a,{runDiagnose:n}=await import("./diagnose-VVJY6RF2.js"),r=await n(["recent",...o],t);process.exitCode=r;return}if(b==="do"&&p==="scan"){let{runCamera:S}=await import("./camera-O4PEVPI4.js");process.exitCode=await S(a,{port:t.port});return}if(p==="list"&&a.some(S=>S==="--drivers"||S==="-D")){let{buildDriverListRows:S}=await import("./drivers-44ZJZ37B.js"),o=S();console.log(` available drivers (${o.length}):
558
- `);let n=Math.max(...o.map(l=>l.id.length),6),r=Math.max(...o.map(l=>l.kind.length),4);for(let l of o){let u=l.available?"\u2713":"\u2717",m=l.id.padEnd(n),f=l.kind.padEnd(r);console.log(` ${u} ${m} ${f} ${l.description}`),l.available&&l.detail?console.log(` ${l.detail}`):!l.available&&l.reason&&console.log(` unavailable: ${l.reason}`)}return}let d=ct(c),q=M||"default",P=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","storage-clear","list","wait","sleep"]),A=200;function J(S){let o=S.replace(/\s+/g," ").trim();if(!o)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(o)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec(S)?.[1]?.trim(),l=/<body[^>]*>([\s\S]*?)<\//i.exec(S)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),u=r||l||"html error page";return`<html ${S.length}B> "${u}" (body elided \u2014 add --json for the full payload)`}return o.length<=A?o:`${o.slice(0,A)}\u2026 (+${o.length-A} more bytes)`}function U(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 I(S){let o=fe()?400:200;try{let{settled:n,elapsed:r}=await se({bridge:S,maxMs:o,pollMs:32,stablePolls:2});n||process.stderr.write(` \u26A0 auto-wait timed out after ${r??o}ms \u2014 next command may see mid-animation state. use \`rnxsim do settle\` for a longer wait.
559
- `)}catch{}}function R(S,o){if(o.result?.reason==="offscreen"){let{x:n,y:r,screen:l}=o.result;console.error(` tap failed: ${S} resolved to (${Math.round(n)},${Math.round(r)}), outside the ${l?.width}x${l?.height} screen`),console.error(" the node exists but is scrolled out of view \u2014 scroll it on-screen first (rnxsim 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 H(){try{return await d.send({type:"evaluate",code:`(() => ({
560
- console: ${Te},
561
- requests: window.__sootsimTest?.getRequestCounts?.() || null,
562
- }))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function K(S={}){let o=S.counts!==void 0?S.counts:await X(d,"getRequestCounts");if(!o||typeof o!="object")return;let n=Math.max(0,Number(o.failed)||0);if(n===0||!S.includeTail&&!Xe("requests",q,String(n))||(console.log(`
563
- network: ${n} failed request${n===1?"":"s"}`),console.log(` inspect: ${h("requests")} 5`),!S.includeTail))return;let r=await X(d,"getFailedRequests",5);if(!(!Array.isArray(r)||r.length===0)){console.log(`
564
- recent failed requests:
565
- `);for(let l of r){let u=ae(l.timestamp);console.log(` [${u}] ${U(l)}`),l.responseBody?console.log(` ${J(l.responseBody)}`):l.error&&console.log(` ${l.error}`)}}}function ee(S){for(let o of S){let n=o.title?` (\u201C${o.title}\u201D)`:"";console.error(`
566
- note: ${o.label} is open${n} \u2014 taps/drags hit it, not the app`)}}async function te(S={}){let o=S.counts!==void 0?S.counts:await d.send({type:"evaluate",code:Te});if(!o||typeof o!="object")return;let n=o,r=Math.max(0,Number(n.errors)||0),l=Math.max(0,Number(n.warnings)||0);if(r===0&&l===0||!S.includeTail&&!Xe("console",q,`${r}:${l}`))return;let u=[];if(r>0&&u.push(`${r} console error${r===1?"":"s"}`),l>0&&u.push(`${l} console warning${l===1?"":"s"}`),console.error(`
567
- console: ${u.join(", ")}`),console.error(` inspect: ${h("errors")} 5`),l>0&&console.error(` inspect: ${h("warnings")} 5`),!S.includeTail||r===0)return;let m=await ge(d,5);if(!(!Array.isArray(m)||m.length===0)){console.error(`
568
- recent console errors:
569
- `);for(let f of m){let $=ae(f.timestamp),g=Array.isArray(f.args)?f.args.map(k=>typeof k=="object"?JSON.stringify(k):String(k)).join(" "):String(f);console.error(` [${$}] ${g}`)}}}let ie=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function Se(S){let o=rt(),n=null;try{n=await ut(S,`(() => {
570
- const tl = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.timeline
571
- if (!tl || typeof tl.summary !== 'function') return null
572
- const cursorKey = ${JSON.stringify(o)}
573
- const summary = tl.summary({ sinceCursor: cursorKey })
574
- let consoleSplit = null
575
- if (summary && summary.byKind && summary.byKind.console) {
576
- const events = tl.recent({ sinceCursor: cursorKey, kinds: 'console', limit: 100000 }).events
577
- consoleSplit = { error: 0, warn: 0 }
578
- for (const ev of events) {
579
- const lvl = ev && ev.data && ev.data.level
580
- if (lvl === 'error') consoleSplit.error++
581
- else if (lvl === 'warn') consoleSplit.warn++
582
- }
583
- }
584
- return summary ? { summary, consoleSplit } : null
585
- })()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},l=[],u=new Set;for(let m of ie){let f=r[m];if(f)if(u.add(m),m==="console"&&n.consoleSplit){let{error:$,warn:g}=n.consoleSplit;$>0&&l.push(`${$} error${$===1?"":"s"}`),g>0&&l.push(`${g} warning${g===1?"":"s"}`)}else l.push(`${f} ${m}${f===1?"":"s"}`)}for(let[m,f]of Object.entries(r))!u.has(m)&&f&&l.push(`${f} ${m}${f===1?"":"s"}`);if(l.length!==0&&(console.error(`
586
- since last: ${l.join(" \xB7 ")} \u2014 rnxsim what-happened`),n.summary.lastAt))try{await ce(S,"SootSim.bridges.timeline.cursorAdvance",o,n.summary.lastAt)}catch{}}let j=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"]),le=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"]),ve=(e.includes("--verbose")||e.includes("-v"))&&!e.includes("--json");b==="do"&&p==="shell"&&(console.error(" `rnxsim do shell` was removed. use `rnxsim shell ...` instead."),process.exit(1)),j.has(p)&&await dt(d),le.has(p)&&await pe(d,{verbose:ve});try{let S=j.has(p)?await Ft(d):[];switch(p){case"list":{at(c.wsPort),await oo({bridge:d,simId:M,args:a});break}case"tree":{await lo({bridge:d,args:a,positional:i});break}case"a11y":{let o=await wt(d);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):
587
- `);for(let n of o){let r=[];if(r.push(`[${n.role}]`),n.label){let l=n.label.length>50?n.label.slice(0,47)+"...":n.label;r.push(`"${l}"`)}if(n.hint&&r.push(`(hint: "${n.hint}")`),n.testID&&r.push(`#${n.testID}`),n.state){let l=[];n.state.disabled&&l.push("disabled"),n.state.selected&&l.push("selected"),n.state.checked===!0&&l.push("checked"),n.state.checked==="mixed"&&l.push("mixed"),n.state.busy&&l.push("busy"),n.state.expanded===!0&&l.push("expanded"),n.state.expanded===!1&&l.push("collapsed"),l.length&&r.push(`{${l.join(", ")}}`)}n.position&&r.push(`@(${n.position.x},${n.position.y})`),n.size&&r.push(`${n.size.w}x${n.size.h}`),console.log(" "+r.join(" "))}}break}case"find":{await Zt({bridge:d,args:e,effectiveArgs:a,positional:i,inspectUsage:x});break}case"count":{await Vt(d,{args:a});break}case"keyboard":{await to(d,{json:e.includes("--json")});break}case"screens":{await ro(d,{json:e.includes("--json")});break}case"memory":{await no(d,{args:a});break}case"wait":{await uo({wsPort:F,commandTimeoutMs:O,simId:M,simIdSource:_,positional:i});break}case"sleep":{await ao({positional:i,inspectUsage:x});break}case"settle":{await io({bridge:d,args:e,positional:i});break}case"ready":{await go({bridge:d,args:e});break}case"idle":{await fo({bridge:d,args:e,positional:i});break}case"selector":{await yo({bridge:d,args:e,positional:i,inspectUsage:x});break}case"event":{await mo({bridge:d,args:e,positional:i,inspectUsage:x});break}case"layout":{let o=i[1];if(!o){await eo({bridge:d,args:a});break}let n=await d.send({type:"evaluate",code:`(async () => await window.__sootsimTest.getLayout(${JSON.stringify(o)}))()`});console.log(JSON.stringify(n,null,2));break}case"capture":case"screenshot":{let n=e.find(($,g)=>e[g-1]==="--output")||"/tmp/sootsim-inspect.png",r=await So(e,d),l={type:"screenshot"};r&&(l.crop=r);let m=(await d.send(l)).replace(/^data:image\/png;base64,/,"");r&&console.log(` area: x=${r.x} y=${r.y} w=${r.w} h=${r.h}`),(await import("fs")).writeFileSync(n,Buffer.from(m,"base64")),console.log(` saved: ${n}`);break}case"sample-color":{let o=await So(e,d);o||(console.error(x("sample-color","<x> <y> [w] [h] | --id <testID> | --text <text>")),console.error(" samples an averaged color from the canvas. coords are logical rnx units."),process.exit(1));let n=await d.send({type:"evaluate",code:Dt(o)});if(e.includes("--json"))console.log(JSON.stringify(n,null,2));else{let{r,g:l,b:u,a:m,hex:f,samples:$}=n,g=o.w===1&&o.h===1?`@(${o.x},${o.y})`:`@(${o.x},${o.y}) ${o.w}x${o.h}`;console.log(` ${f} rgba(${r}, ${l}, ${u}, ${m}) ${g} ${$} samples`)}break}case"node":{let o=i[1];o||(console.error(x("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let n=await d.send({type:"evaluate",code:`(async () => {
588
- const t = window.__sootsimTest
589
- const q = ${JSON.stringify(o)}
590
- let node = null
591
- let via = null
592
- if (t.findByTestId) { node = await t.findByTestId(q); if (node) via = 'testID' }
593
- if (!node && t.findById) { node = await t.findById(q); if (node) via = 'id' }
594
- if (!node && t.findByText) { node = await t.findByText(q); if (node) via = 'text' }
595
- if (!node) return { matcher: q, found: false }
596
-
597
- // read the resolved transform (if any) off the style \u2014 useful
598
- // because canvas nodes often animate via transform and describe
599
- // output strips that.
600
- const transform =
601
- node.style && Array.isArray(node.style.transform)
602
- ? node.style.transform
603
- : node.style && node.style.transform
604
- ? node.style.transform
605
- : null
606
-
607
- // parent chain \u2014 walk up from the node so the JSON dump is
608
- // self-describing.
609
- const parentChain = []
610
- const root = window.__sootsimRoot
611
- if (root && node.id != null) {
612
- const findPath = (n, targetId, path) => {
613
- if (!n) return null
614
- if (n.id === targetId) return path
615
- if (n.children) {
616
- for (const child of n.children) {
617
- const nextPath = [
618
- ...path,
619
- {
620
- type: n.type || 'view',
621
- testID: n.props?.testID || null,
622
- text: n.text || null,
623
- },
624
- ]
625
- const found = findPath(child, targetId, nextPath)
626
- if (found) return found
627
- }
628
- }
629
- return null
630
- }
631
- const chain = findPath(root, node.id, [])
632
- if (chain) parentChain.push(...chain)
633
- }
634
-
635
- return {
636
- matcher: q,
637
- found: true,
638
- resolvedVia: via,
639
- node,
640
- transform,
641
- parentChain,
642
- }
643
- })()`});console.log(JSON.stringify(n,null,2));break}case"tap":{let o=Number(i[1]),n=Number(i[2]),r=xe(e,i);if(r){let m=await be(d,{agent:fe(),textFallback:r.mode==="text"?r.value:void 0,resolve:async()=>{let g=await Ee(d,r);return g?{cx:g.x,cy:g.y,match:{id:r.mode==="testid"?r.value:g.id??null,testID:r.mode==="testid"?r.value:g.testID??null,text:r.mode==="text"?r.value:g.text??null,type:g.type??null},target:{id:g.id??null,testID:g.testID??null,text:g.text??null,type:g.type??null}}:null}}),f=m.payload;(!f||typeof f.cx!="number")&&(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),me(m.result)||(R(`${r.mode} "${r.value}"`,m),process.exit(1));let $=To(f.cx,f.cy,m.result);$&&await W("inspect tap",$.step,$.summary),console.log(JSON.stringify({...m.attempts>1?{attempts:m.attempts}:{},...m.result},null,2));break}(!Number.isFinite(o)||!Number.isFinite(n))&&(console.error(x("tap","<testid> | <x> <y> | --testid <id> | --text <t>")),process.exit(1));let l=await Gt(d,o,n),u=To(o,n,l);u&&await W("inspect tap",u.step,u.summary),console.log(JSON.stringify(l,null,2));break}case"drag":case"swipe":{let o=Number(i[1]),n=Number(i[2]),r=Number(i[3]),l=Number(i[4]),u=p==="swipe"?10:12,m=p==="swipe"?8:16,f=i[5]?Number(i[5]):u,$=i[6]?Number(i[6]):m;(!Number.isFinite(o)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(l)||!Number.isFinite(f)||!Number.isFinite($))&&(console.error(x(p,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let g=await $e(d,{type:"drag",fromX:o,fromY:n,toX:r,toY:l,steps:Math.max(1,Math.round(f)),stepMs:Math.max(0,Math.round($))});if(g?.ok){let k=Math.max(1,Math.round(Math.max(1,f)*Math.max(0,$)));await W(`inspect ${p}`,{swipe:{start:`${o}, ${n}`,end:`${r}, ${l}`,duration:k}},`${p} ${o},${n} -> ${r},${l}`)}console.log(JSON.stringify(g,null,2));break}case"pinch":{let o=Number(i[1]),n=Number(i[2]),r=Number(i[3]),l=Number(i[4]),u=Number(i[5]),m=Number(i[6]),f=Number(i[7]),$=Number(i[8]),g=i[9]?Number(i[9]):12,k=i[10]?Number(i[10]):16;(!Number.isFinite(o)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(l)||!Number.isFinite(u)||!Number.isFinite(m)||!Number.isFinite(f)||!Number.isFinite($)||!Number.isFinite(g)||!Number.isFinite(k))&&(console.error(x("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let L=await $e(d,{type:"pinch",fromX1:o,fromY1:n,fromX2:r,fromY2:l,toX1:u,toY1:m,toX2:f,toY2:$,steps:Math.max(1,Math.round(g)),stepMs:Math.max(0,Math.round(k))});L?.ok&&await W("inspect pinch",{pinch:{from:[o,n,r,l],to:[u,m,f,$],steps:Math.max(1,Math.round(g)),stepMs:Math.max(0,Math.round(k))}},`pinch (${o},${n}) (${r},${l}) -> (${u},${m}) (${f},${$})`),console.log(JSON.stringify(L,null,2));break}case"tap-text":{let o=i[1];o||(console.error(x("tap-text","<text>")),process.exit(1));let n=z=>{let C=e.indexOf(z);return C>=0&&C+1<e.length?e[C+1]:null},r=z=>e.includes(z),l=n("--nth")??n("--index"),u=l!==null?Number(l):null;u!==null&&!Number.isFinite(u)&&(console.error(` --nth/--index requires an integer, got: ${l}`),process.exit(1));let m=n("--within"),f=n("--role"),$=r("--exact"),g=r("--first"),k=n("--min-y"),L=n("--max-y"),V=n("--min-x"),G=n("--max-x");for(let[z,C]of[["--min-y",k],["--max-y",L],["--min-x",V],["--max-x",G]])C!==null&&!Number.isFinite(Number(C))&&(console.error(` ${z} requires a number, got: ${C}`),process.exit(1));let Y=e.indexOf("--near"),E=null;if(Y>=0){let z=Number(e[Y+1]),C=Number(e[Y+2]);(!Number.isFinite(z)||!Number.isFinite(C))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),E={x:z,y:C}}let v={exact:$,role:f,within:m,minX:V!==null?Number(V):null,maxX:G!==null?Number(G):null,minY:k!==null?Number(k):null,maxY:L!==null?Number(L):null,near:E,nth:u,first:g},T=await zt(d,o,v,{agent:fe()}),N=T.payload;if(N?.error==="bridge-not-ready"&&(console.error(" rnxsim test bridge not ready"),process.exit(1)),N?.ambiguous){let z=N.candidates;console.error(` ambiguous: ${N.total} matches for "${o}"`);for(let C of z){let ke=C.abs?`@(${Math.round(C.abs.x)},${Math.round(C.abs.y)})`:"",Oo=C.layout?` ${C.layout.width}x${C.layout.height}`:"",Ro=C.testID?` #${C.testID}`:"",Po=C.text?` "${C.text}"`:"",Eo=C.ancestorTestIDs.length>0?` within ${C.ancestorTestIDs.slice(0,3).map(Ao=>`#${Ao}`).join(" > ")}`:"";console.error(` [${C.idx}] <${C.type}>${Po}${Ro} ${ke}${Oo}${Eo}`)}N.total>z.length&&console.error(` ... and ${N.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"),process.exit(2)}N?.nthOutOfRange&&(console.error(` not found: nth ${N.nth} of ${N.total} match${N.total===1?"":"es"} for "${o}"`),process.exit(1)),(!N||typeof N.cx!="number")&&(console.error(` not found: ${o}`),process.exit(1)),me(T.result)||(R(`text "${o}"`,T),process.exit(1));let ne=ot(o,{id:N.target?.id??null,testID:N.target?.testID??null,type:N.target?.type??null,cx:N.cx,cy:N.cy},"text");await W("inspect tap-text",ne.step,ne.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}:{},...N.total>1||u!==null?{nth:{index:N.idx,total:N.total}}:{},...T.attempts>1?{attempts:T.attempts}:{},result:T.result},null,2));break}case"tap-best":{let o=i[1];o||(console.error(x("tap-best","<query>")),process.exit(1));let n=await Xt(d,o,{agent:fe()}),r=n.payload;r||(console.error(` tap-best: no testID or visible text matched "${o}". try \`rnxsim find --interactive-targets\` to list candidates.`),process.exit(1)),"error"in r&&(console.error(` ${r.error}`),process.exit(1)),r.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${o}". try \`rnxsim find --interactive-targets\` to list candidates.`),process.exit(1));let l=r.node;me(n.result)||(R(`best "${o}"`,n),process.exit(1));let u=ot(o,{id:l.id,testID:l.testID,type:l.type,cx:r.cx,cy:r.cy},r.strategy==="testid"?"id":"text");await W("inspect tap-best",u.step,u.summary),console.log(JSON.stringify({matched:{strategy:r.strategy,nodeId:l.nodeId,id:l.id,testID:l.testID,type:l.type,text:l.text},tapped:{cx:r.cx,cy:r.cy},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"tap-id":{let o=i[1];o||(console.error(x("tap-id","<id>")),process.exit(1));let n=await Yt(d,o,{agent:fe()}),r=n.payload;(!r||typeof r.cx!="number")&&(console.error(` not found: ${o}`),await gs(d,o),process.exit(1)),me(n.result)||(R(`id "${o}"`,n),process.exit(1));let l=ot(o,{id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},"id");await W("inspect tap-id",l.step,l.summary),console.log(JSON.stringify({matched:r.match,tapped:{nodeId:r.target?.nodeId??null,id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},...r.strategy&&r.strategy!=="matched-node"?{strategy:r.strategy}:{},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"type-into":{let o=i[1],n=i.slice(2).join(" ");(!o||!n)&&(console.error(x("type-into","<id> <text>")),process.exit(1));let r=JSON.stringify(o),l=await d.send({type:"evaluate",code:`(async () => {
644
- const t = window.__sootsimTest
645
- if (!t) return null
646
- const n = await (t.findByTestId(${r}) || t.findById(${r}))
647
- if (!n || !n.absolutePosition || !n.layout) return null
648
- return {
649
- cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
650
- cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
651
- id: n.id,
652
- testID: n.testID,
653
- type: n.type,
654
- isTextInput: !!n.isTextInput,
655
- secureTextEntry: !!n.secureTextEntry,
656
- placeholder: n.placeholder || null,
657
- }
658
- })()`});(!l||typeof l.cx!="number")&&(console.error(` not found: ${o}`),process.exit(1)),l.isTextInput||console.error(` warning: ${o} is not a text input (isTextInput: false)`);let u=await d.send({type:"tap",x:l.cx,y:l.cy,target:{id:l.id??o,testID:l.testID??o,text:null,type:l.type??null}}),m=l.secureTextEntry===!0,f=await ks(d,1e3,{targetId:o,secureTextEntry:m});f.visible||(console.error(` keyboard did not open after tapping ${o}`),process.exit(1));let $=f.focusedInput;$&&($.testID===o||$.id===o||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(o)} but focus is on ${JSON.stringify($.testID??$.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await d.send({type:"keyboard",action:"type",text:n});let g=m||we(f),k=g?Z:et(n,f),L=g&&f.focusedInput?{...f.focusedInput,secureTextEntry:!0,text:typeof f.focusedInput.text=="string"?Z:f.focusedInput.text}:f.focusedInput??null;await W("inspect type-into",{tapOn:{id:o},inputText:k},k===Z?`type-into #${o} ${Z}`:`type-into #${o} ${JSON.stringify(n)}`),console.log(JSON.stringify({target:o,isTextInput:l.isTextInput,secureTextEntry:g,keyboardOpened:f.visible??u?.keyboardOpened??!1,focusedInput:L,typed:k},null,2));break}case"type":{let o=i.slice(1).join(" ");o||(console.error(x("type","<text>")),process.exit(1));let n=await De(d,"type");await d.send({type:"keyboard",action:"type",text:o});let r=et(o,n);await W("inspect type",{inputText:r},r===Z?`type ${Z}`:`type ${JSON.stringify(o)}`),console.log(r===Z?` typed: ${Z}`:` typed: ${JSON.stringify(o)}`);break}case"key":{let o=i[1];o||(console.error(x("key","<name>")),process.exit(1)),await De(d,"key"),await d.send({type:"keyboard",action:"press",text:o}),await W("inspect key",{pressKey:o},`key ${o}`),console.log(` pressed: ${o}`);break}case"key-sequence":{let o=i.slice(1);o.length===0&&(console.error(x("key-sequence","<key> [<key> ...]")),process.exit(1)),await De(d,"key-sequence");for(let n of o)await d.send({type:"keyboard",action:"press",text:n});await W("inspect key-sequence",{pressKey:o.join(" ")},`key-sequence ${o.join(" ")}`),console.log(` pressed: ${o.join(", ")}`);break}case"keycode":{let o=i.slice(1);o.length===0&&(console.error(x("keycode","<code> [<code> ...]")),process.exit(1));let n=o.map(l=>({code:l,key:Is(l)})),r=n.filter(l=>!l.key);r.length>0&&(console.error(` unsupported keycode(s): ${r.map(l=>l.code).join(", ")}`),process.exit(1)),await De(d,"keycode");for(let l of n)await d.send({type:"keyboard",action:"press",text:l.key});await W("inspect keycode",{pressKey:n.map(l=>l.key).join(" ")},`keycode ${o.join(" ")}`),console.log(` pressed: ${o.join(", ")}`);break}case"dispatch":{let o=i[1];o||(console.error(x("dispatch","<char>")),process.exit(1)),await d.send({type:"keyboard",action:"dispatchKey",text:o}),await W("inspect dispatch",{dispatchKey:o},`dispatch ${JSON.stringify(o)}`),console.log(` dispatched: ${o}`);break}case"dismiss":{await d.send({type:"keyboard",action:"dismiss"}),await W("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let o=Number(i[1]),n=Number(i[2]),r=xe(e,i);if(r){let $=await Ee(d,r);$||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),o=$.x,n=$.y}let l=i[3]?Number(i[3]):80;(!Number.isFinite(o)||!Number.isFinite(n)||!Number.isFinite(l))&&(console.error(x("double-tap","<testid> | <x> <y> [gapMs] | --testid <id>")),process.exit(1));let u=Math.max(0,Math.round(l)),f={...await $e(d,{type:"doubleTap",x:o,y:n,gapMs:u}),gapMs:u};f?.ok&&await W("inspect double-tap",{doubleTapAtCoords:{x:o,y:n,gapMs:u}},`double-tap @${o},${n}`),console.log(JSON.stringify(f,null,2));break}case"long-press":{let o=Number(i[1]),n=Number(i[2]),r=xe(e,i),l=null;if(r){let g=await Ee(d,r);g||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),o=g.x,n=g.y,l={id:g.id??null,testID:g.testID??null,text:g.text??null,type:g.type??null}}let u=r?i[1]:i[3],m=u?Number(u):600;(!Number.isFinite(o)||!Number.isFinite(n)||!Number.isFinite(m))&&(console.error(x("long-press","<testid> | <x> <y> [durationMs] | --testid <id>")),process.exit(1));let f=Math.max(0,Math.round(m)),$=await d.send({type:"longPress",x:o,y:n,durationMs:f,target:l});$?.ok&&await W("inspect long-press",{tapAtCoords:{x:o,y:n}},`long-press @${o},${n}`),console.log(JSON.stringify($,null,2));break}case"touch":{let o=i[1],n=Number(i[2]),r=Number(i[3]),l=i[4]?Number(i[4]):999,u=o==="down"?"touchDown":o==="move"?"touchMove":o==="up"?"touchUp":o==="cancel"?"touchCancel":null;u||(console.error(x("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),o!=="cancel"&&(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(x("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let m=Math.max(1,Math.round(l)),f=await $e(d,u==="touchCancel"?{type:u,pointerId:m}:{type:u,x:n,y:r,pointerId:m});f?.ok&&o!=="cancel"&&await W("inspect touch",{tapAtCoords:{x:n,y:r}},`touch ${o} @${n},${r}`),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"],n=i[1],r=i[2]?Number(i[2]):220;(!n||!Number.isFinite(r))&&(console.error(x("gesture","<preset> [durationMs]")),console.error(` presets: ${o.join(", ")}`),process.exit(1)),o.includes(n)||(console.error(` unknown gesture preset: ${n}`),console.error(` presets: ${o.join(", ")}`),process.exit(1));let l=await d.send({type:"evaluate",code:`(async () => {
659
- const spec = globalThis.__sootsimDeviceSpec || {}
660
- return {
661
- width: spec.width || window.innerWidth || 393,
662
- height: spec.height || window.innerHeight || 852,
663
- statusBarHeight: spec.statusBarHeight || 0,
664
- homeIndicatorHeight: spec.homeIndicatorHeight || 0,
665
- }
666
- })()`}),u=Number(l?.width)||393,m=Number(l?.height)||852,f=Number(l?.statusBarHeight)||0,$=Number(l?.homeIndicatorHeight)||0,g=Math.round(u/2),k=Math.round(m/2),L=Math.max(24,f+18),V=Math.max(24,$+18),G=18,Y=Math.min(220,Math.round(m*.24)),E=Math.min(180,Math.round(u*.32)),v=g,T=k,N=g,ne=k;switch(n){case"scroll-up":T=k+Math.round(Y/2),ne=k-Math.round(Y/2);break;case"scroll-down":T=k-Math.round(Y/2),ne=k+Math.round(Y/2);break;case"scroll-left":v=g+Math.round(E/2),N=g-Math.round(E/2);break;case"scroll-right":v=g-Math.round(E/2),N=g+Math.round(E/2);break;case"swipe-from-left-edge":v=G,T=k,N=Math.min(u-G,G+E);break;case"swipe-from-right-edge":v=u-G,T=k,N=Math.max(G,u-G-E);break;case"swipe-from-top-edge":v=g,T=L,ne=Math.min(m-V,L+Y);break;case"swipe-from-bottom-edge":v=g,T=m-V,ne=Math.max(L,m-V-Y);break}let z=Math.max(8,Math.round(r/16)),C=Math.max(1,Math.round(r/z)),ke=await $e(d,{type:"drag",fromX:v,fromY:T,toX:N,toY:ne,steps:z,stepMs:C});ke?.ok&&await W("inspect gesture",{swipe:{start:`${v}, ${T}`,end:`${N}, ${ne}`,duration:Math.max(1,Math.round(r))}},`gesture ${n}`),console.log(JSON.stringify({preset:n,from:{x:v,y:T},to:{x:N,y:ne},result:ke},null,2));break}case"scroll":{let o=xe(e),n=Ms(e),r=o?.mode==="testid"?o.value:n==null?i[1]:null,l=o||n!=null?1:2,u=Number(i[l]),m=Number(i[l+1]);(!r&&n==null||!Number.isFinite(u)||!Number.isFinite(m))&&(console.error(x("scroll","<id> <x> <y> | --testid <id> <x> <y> | --node-id <nodeId> <x> <y>")),process.exit(1));let f=await d.send({type:"evaluate",code:`(async () => {
667
- const t = window.__sootsimTest
668
- if (!t) return null
669
- const n = ${n!=null?`await t.inspectByNodeId(${JSON.stringify(n)})`:`await t.findByTestId(${JSON.stringify(r)})
670
- || await t.findById(${JSON.stringify(r)})`}
671
- if (!n || !n.absolutePosition || !n.layout) return null
672
- return {
673
- cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
674
- cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
675
- }
676
- })()`}),$=await X(d,"scrollTo",n!=null?{nodeId:n}:r,u,m,!1);if($?.ok){let g=n!=null?`node ${n}`:`#${r}`;await W("inspect scroll",{scrollTo:{...n!=null?{nodeId:n}:{id:r},x:u,y:m}},`scroll ${g} -> ${u},${m}`)}console.log(JSON.stringify({...$,...f?{at:{x:f.cx,y:f.cy}}:{}},null,2));break}case"state":{let o=i[1];if(s==="get"&&!o){let r=await X(d,"getRuntimeState"),l=await d.send({type:"evaluate",code:Te});if(r&&typeof r=="object"&&r.diagnostics&&(r.diagnostics.errors=l?.errors??0,r.diagnostics.warnings=l?.warnings??0),r&&typeof r=="object"&&r.shell==null)try{let u=await ue(d);u&&(r.shell=u)}catch{}console.log(JSON.stringify(r,null,2));break}if(!o||o==="--help"||o==="-h"){console.log(`
677
- ${h("state")} \u2014 dump raw runtime state
678
-
679
- subcommands:
680
- shell dump shell transition/layout state
681
- worker dump render-worker host/animation state
682
- keyboard dump keyboard visibility, mode, and focused input
683
- ownership dump surface ownership + pointerOnSurface delivery stats
684
- worklets dump tenant + shell worklet-runtime slot/handler counts
685
- scroll-input dump shell-owned scroll gesture and momentum state
686
- scroll-mirror dump shell scroll registry entries and offsets
687
- node <id> dump raw node info by id or testID
688
- scroll <id> dump scroll metrics and runtime state
689
- scroll-hit <x> <y> dump the nearest scroll ancestor at coordinates
690
- hit <x> <y> dump the hit-test ancestry at coordinates
691
- gesture <x> <y> dump gesture routing/debug info at coordinates
692
- gesture-seam dump shell-hosted gesture recognizer state/events
693
-
694
- examples:
695
- ${h("state")} shell
696
- ${h("state")} worker
697
- ${h("state")} keyboard
698
- ${h("state")} ownership
699
- ${h("state")} worklets
700
- ${h("state")} scroll-input
701
- ${h("state")} scroll-mirror
702
- ${h("state")} node photos
703
- ${h("state")} scroll feed
704
- ${h("state")} scroll-hit 360 420
705
- ${h("state")} hit 200 720
706
- `);break}let n;switch(o){case"shell":n=await ue(d,500);break;case"worker":n=await ce(d,"__sootsimRenderHost.queryStats");break;case"ownership":n=await d.send({type:"evaluate",code:`(() => {
707
- const h = window.__sootsimRenderHost
708
- if (!h || typeof h.getOwnershipSnapshot !== 'function') {
709
- return { error: 'getOwnershipSnapshot not available' }
710
- }
711
- return h.getOwnershipSnapshot()
712
- })()`});break;case"keyboard":n=await d.send({type:"evaluate",code:`(async () => {
713
- const kb = window.__sootsimKeyboard
714
- const test = window.__sootsimTest
715
- if (!kb) return { error: 'keyboard bridge not available' }
716
- const layout = typeof kb.getLayout === 'function' ? kb.getLayout() : null
717
- const secureTextEntry =
718
- !!layout?.spec?.secureTextEntry && layout?.spec?.keyboardType !== 'visible-password'
719
- const visible = kb.isVisible()
720
- const mode = kb.getMode()
721
- let focused = null
722
- if (test && typeof test.getFocusedNode === 'function') {
723
- try {
724
- focused = await test.getFocusedNode()
725
- } catch {}
726
- }
727
- return {
728
- visible,
729
- mode,
730
- layout,
731
- focusedInput: focused ? {
732
- nodeId: focused.nodeId ?? null,
733
- testID: focused.testID || null,
734
- id: focused.id || null,
735
- placeholder: focused.placeholder || null,
736
- secureTextEntry,
737
- text: secureTextEntry ? ${JSON.stringify(Z)} : (focused.text || null),
738
- } : null,
739
- }
740
- })()`}),n=tt(n);break;case"node":{let r=i[2];r||(console.error(` usage: ${h("state")} node <id>`),process.exit(1)),n=await X(d,"findByTestId",r)||await X(d,"findById",r);break}case"scroll":{let r=i[2];r||(console.error(` usage: ${h("state")} scroll <id>`),process.exit(1)),n=await X(d,"getScrollState",r);break}case"scroll-hit":{let r=Number(i[2]),l=Number(i[3]);(!Number.isFinite(r)||!Number.isFinite(l))&&(console.error(` usage: ${h("state")} scroll-hit <x> <y>`),process.exit(1)),n=await X(d,"getScrollStateAt",r,l);break}case"hit":{let r=Number(i[2]),l=Number(i[3]);(!Number.isFinite(r)||!Number.isFinite(l))&&(console.error(` usage: ${h("state")} hit <x> <y>`),process.exit(1)),n=await X(d,"debugHitAt",r,l);break}case"gesture":{let r=Number(i[2]),l=Number(i[3]);(!Number.isFinite(r)||!Number.isFinite(l))&&(console.error(` usage: ${h("state")} gesture <x> <y>`),process.exit(1)),n=await X(d,"debugGestureAt",r,l);break}case"gesture-seam":n=await ce(d,"SootSim.bridges.mainShell.callTestBridge","getShellGestureSeamDebug");break;case"worklets":{let[r,l]=await Promise.all([X(d,"getWorkletSlotStats"),ce(d,"SootSim.bridges.mainShell.callTestBridge","getWorkletSlotStats")]);n={tenant:r,shell:l};break}case"scroll-input":n=await ce(d,"SootSim.bridges.mainShell.callTestBridge","getShellScrollInputDebug");break;case"scroll-mirror":n=await ce(d,"SootSim.bridges.mainShell.callTestBridge","getScrollMirrorDebug");break;default:console.error(` unknown state subcommand: ${o}`),process.exit(1)}console.log(JSON.stringify(n,null,2));break}case"shell":{let o=i[1];if(!o||o==="--help"||o==="-h"){console.log(`
741
- ${h("shell")} \u2014 run built-in shell commands
742
-
743
- subcommands:
744
- launch <appId> [waitMs] [--clear-state]
745
- launch app and wait for settled shell state
746
- home [waitMs] go home and wait for settled shell state
747
- switcher [waitMs] open switcher and wait for settled shell state
748
- open-card <appId> [waitMs]
749
- open a specific switcher card and wait for app settle
750
- appearance <light|dark|auto|toggle>
751
- update simulator appearance
752
- lock toggle device lock state
753
- shake trigger the simulator shake gesture
754
-
755
- examples:
756
- ${h("shell")} launch photos
757
- ${h("shell")} launch rn --clear-state
758
- ${h("shell")} launch photos 1500
759
- ${h("shell")} home 500
760
- ${h("shell")} switcher 800
761
- ${h("shell")} open-card clock 800
762
- ${h("shell")} appearance dark
763
- ${h("shell")} lock
764
- `);break}let n=o==="launch"||o==="open-card"||o==="home"||o==="switcher",r=o==="launch"||o==="open-card"?i[3]:i[2],l=r?Number(r):350;n&&(!Number.isFinite(l)||l<0)&&(console.error(x("shell",o==="launch"||o==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let u=!1,m=!1,f=null,$=e.includes("--clear-state");if(o==="launch"){let g=i[2];g||(console.error(x("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),$&&await d.send({type:"evaluate",code:He(!0)}),u=!!await ye(d,"launchApp",l,g),{settled:m,state:f}=await _e(d,Math.round(l),k=>!!k&&k.state==="app"&&k.activeApp===g&&k.showSwitcher===!1&&k.switcherPhase==="idle"&&typeof k.launchProgress=="number"&&k.launchProgress>=.98),u&&await W("inspect shell launch",$?{launchApp:{clearState:!0}}:{launchApp:{}},$?"launch app (clear state)":"launch app")}else if(o==="home")u=!!await ye(d,"goHome",l),{settled:m,state:f}=await _e(d,Math.round(l),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")u=!!await ye(d,"openSwitcher",l),{settled:m,state:f}=await _e(d,Math.round(l),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),m&&(await oe(Ss),f=await ue(d));else if(o==="open-card"){let g=i[2];g||(console.error(x("shell","open-card <appId> [settleMs]")),process.exit(1)),u=!!await ye(d,"openSwitcherCard",l,g),{settled:m,state:f}=await _e(d,Math.round(l),k=>!!k&&k.state==="app"&&k.activeApp===g&&k.showSwitcher===!1&&k.switcherPhase==="idle"&&typeof k.zoomLevel=="number"&&k.zoomLevel>=.98&&typeof k.horizontalZoom=="number"&&k.horizontalZoom>=.98),u&&await W("inspect shell open-card",{openSwitcherCard:{appId:g}},`open switcher card ${g}`)}else if(o==="appearance"){let g=i[2];(!g||!["light","dark","auto","toggle"].includes(g))&&(console.error(x("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let k=await Io(d,"appearance",g);if(u=!!k?.ok,f={appearance:k},u){let L=k?.applied??g;console.log(` appearance: ${L}`)}}else if(o==="lock"||o==="shake"){let g=await Io(d,o);u=!!g?.ok,f={[o]:g}}else console.error(` unknown shell subcommand: ${o}`),process.exit(1);console.log(JSON.stringify({ok:u,settled:m,state:f},null,2));break}case"url":{await co(d,{args:a});break}case"reload":{let r=!1,l=!1;try{await d.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let f=await d.send({type:"evaluate",code:`;(async () => {
765
- // in-place guest reload is only valid while the page still runs
766
- // the engine build the server would serve NOW. the shell dev
767
- // server has no HMR client, so a long-lived sim tab otherwise
768
- // keeps a stale engine forever while builds churn underneath it.
769
- // compare the inlined engine manifest against a fresh fetch of
770
- // this page's html; any drift means the whole page must reload.
771
- let engineStale = false
772
- try {
773
- const loaded = document.getElementById('__sootsim-engine-manifest')?.textContent
774
- if (loaded) {
775
- const res = await fetch(location.href, { cache: 'no-store' })
776
- const html = await res.text()
777
- const m = html.match(/<script[^>]*id="__sootsim-engine-manifest"[^>]*>([^<]*)<\\/script>/)
778
- if (m && m[1] !== loaded) engineStale = true
779
- }
780
- } catch {}
781
- const reloadExternalApp = window.SootSim?.bridges?.hotRemount?.reloadExternalApp
782
- if (!engineStale && typeof reloadExternalApp === 'function') {
783
- reloadExternalApp()
784
- return { kind: 'external-app' }
785
- }
786
- window.location.reload()
787
- return { kind: 'page', engineStale }
788
- })()`});l=!!f&&f.kind==="external-app",r=!0,f&&f.engineStale&&console.log(" engine build changed since page load \u2014 full page reload")}catch{}console.log(" reloading...");let u=d,m=null;if(l)m=await Ne(d,{timeoutMs:1e4,errorGraceMs:3e3});else{r&&await oe(300);let $=await Et(F,O,M,{timeoutMs:3e4,simIdSource:_});$?(u=$,m=await Ne($,{timeoutMs:3e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 30000ms"),u=null)}if(m)if(m.ready){let f=m.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${m.elapsedMs}ms: ${m.nodes} nodes${f}`)}else if(m.source==="error-bail")console.log(` \u26A0 reload bailed after ${m.elapsedMs}ms: ${m.errors} console error(s), ready signal never fired`);else{let f=bo(m);console.log(` \u26A0 reload timed out after ${m.elapsedMs}ms \u2014 ${f} (nodes: ${m.nodes}, targets: ${m.targets}, errors: ${m.errors})`)}if(u)try{let f=await ge(u,10);if(u!==d&&u.close(),Array.isArray(f)&&f.length>0){console.log(`
789
- \u26A0 ${f.length} error(s) during mount:
790
- `);for(let $ of f){let g=$.args.map(k=>typeof k=="object"?JSON.stringify(k):k).join(" ");if(console.log(` ${g}`),$.stack){let k=$.stack.split(`
791
- `).slice(0,2);for(let L of k)console.log(` ${L.trim()}`)}}}}catch{}m&&!m.ready&&(process.exitCode=1);break}case"storage-clear":{if(await We(d),await d.send({type:"evaluate",code:He(!0)})!==!0){B(a)?D({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 l=await Ne(d,{timeoutMs:1e4,errorGraceMs:3e3});if(B(a)){D({cleared:!0,ready:l.ready,reload:l}),l.ready||(process.exitCode=1);break}if(l.ready){let u=l.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` cleared tenant storage; ready in ${l.elapsedMs}ms: ${l.nodes} nodes${u}`)}else if(l.source==="error-bail")console.log(` \u26A0 storage clear reloaded but bailed after ${l.elapsedMs}ms: ${l.errors} console error(s), ready signal never fired`);else{let u=bo(l);console.log(` \u26A0 storage clear reloaded but timed out after ${l.elapsedMs}ms \u2014 ${u} (nodes: ${l.nodes}, targets: ${l.targets}, errors: ${l.errors})`)}try{let u=await ge(d,10);if(Array.isArray(u)&&u.length>0){console.log(`
792
- \u26A0 ${u.length} error(s) during mount:
793
- `);for(let m of u){let f=m.args.map($=>typeof $=="object"?JSON.stringify($):$).join(" ");if(console.log(` ${f}`),m.stack){let $=m.stack.split(`
794
- `).slice(0,2);for(let g of $)console.log(` ${g.trim()}`)}}}}catch{}l.ready||(process.exitCode=1);break}case"eval":case"js":{let o=i.slice(1).join(" ");if(o||(console.error(x("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(` ${h("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${h("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${h("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${h("js")} SootSim.state.root.children.length`),process.exit(1)),e.includes("--tenant")){let m=i.slice(1).filter($=>$!=="--tenant").join(" "),f=await d.send({type:"evaluate",code:`(async () => SootSim.bridges.test.evalInTenant(${JSON.stringify(m)}))()`});console.log(JSON.stringify(f,null,2));break}let n=o;n.startsWith("(async")||(n=`(async () => ${n})()`);let r=await d.send({type:"evaluate",code:n});console.log(JSON.stringify(r,null,2));let l=o.toLowerCase(),u=[];(l.includes("sootsim:gohome")||l.includes("gohome"))&&u.push("rnxsim shell home"),(l.includes("sootsim:appswitcher")||l.includes("appswitcher"))&&u.push("rnxsim shell switcher"),(l.includes("keyboard.isvisible")||l.includes("keyboard.getmode"))&&u.push("rnxsim debug state keyboard"),l.includes("interact.tap")&&u.push("rnxsim do tap <x> <y>"),l.includes("keyboard.type")&&u.push("rnxsim do type <text>"),(l.includes("keyboard.press")||l.includes("keyboard.dispatchkey"))&&u.push("rnxsim do key <name>"),l.includes("keyboard.dismiss")&&u.push("rnxsim do dismiss"),l.includes("dumptree")&&u.push("rnxsim get tree"),l.includes("dumpaccessibilitytree")&&u.push("rnxsim get a11y"),l.includes("getnodecount")&&u.push("rnxsim get count"),l.includes("findbytext")&&u.push("rnxsim find <text>"),(l.includes("findbytestid")||l.includes("findbyid"))&&u.push("rnxsim find --testid <id>"),l.includes("document.hidden")&&u.push("rnxsim debug state keyboard (includes tab health)"),u.length>0&&Q("prefer-cli-over-eval",u);break}case"globals":{let o=await d.send({type:"evaluate",code:`(async () => {
795
- const globals = {}
796
-
797
- // test bridge (proxy in worker mode)
798
- const testMethods = [
799
- 'findById', 'findByTestId', 'findByText', 'findByLabel', 'findByRole',
800
- 'findAllByRole', 'findByA11yState', 'findAllByA11yState', 'findByHint',
801
- 'findPressable', 'getStyle', 'getLayout', 'getAbsolutePosition', 'isVisible',
802
- 'queryAll', 'dumpTree', 'dumpAccessibilityTree', 'getNodeCount', 'getShellState',
803
- 'getScrollState', 'getScrollStateAt', 'scrollTo', 'waitForTree',
804
- 'waitForScreenTransitions', 'debugByText', 'debugByTestId', 'debugHitAt',
805
- 'debugGestureAt'
806
- ]
807
- globals['test (\u2192 __sootsimTest)'] = testMethods
808
-
809
- // debug
810
- if (window.__sootsimDebug) {
811
- globals['debug (\u2192 __sootsimDebug)'] = Object.keys(window.__sootsimDebug)
812
- }
813
-
814
- // interact
815
- if (window.__sootsimInteract) {
816
- globals['interact (\u2192 __sootsimInteract)'] = Object.keys(window.__sootsimInteract)
817
- }
818
-
819
- // keyboard
820
- if (window.__sootsimKeyboard) {
821
- globals['keyboard (\u2192 __sootsimKeyboard)'] = Object.keys(window.__sootsimKeyboard)
822
- }
823
-
824
- // other globals
825
- globals['other'] = [
826
- 'root (\u2192 __sootsimRoot) - live node tree',
827
- 'render() (\u2192 __sootsimForceRender) - force re-render'
828
- ]
829
-
830
- return globals
831
- })()`});console.log(` rnx JS API:
832
- `);for(let[n,r]of Object.entries(o)){console.log(` ${n}:`);for(let l of r)console.log(` .${l}`);console.log("")}console.log(` use: ${h("js")} <expression>`),console.log(` example: ${h("js")} test.findByText("Sign in")`);break}case"describe":{await Qt({bridge:d,args:e,positional:i});break}case"perf":{b==="debug"&&!t.internalPerfCommand&&(console.error(" `rnxsim debug perf` was removed. use `rnxsim perf shell ...`."),process.exit(1));let o=i[1];if(t.internalPerfCommand==="scroll"){if(!o||o==="--help"||o==="-h"){console.log(`
833
- ${h("perf")} <start|stop> [options]
834
-
835
- records per-frame scroll offsets from the tenant worker, shell worker,
836
- and compositor worker. timestamps use the shared wall clock, while frame
837
- sequences remain separate because the workers do not share a frame id.
838
-
839
- options:
840
- --limit <n> maximum samples retained per layer (default 6000)
841
- --json emit every per-frame sample on stop
842
-
843
- examples:
844
- ${h("perf")} start
845
- # ... perform consecutive swipes ...
846
- ${h("perf")} stop
847
- ${h("perf")} stop --json
848
- `);break}if(o==="start"){let n=a.find((u,m)=>a[m-1]==="--limit"),r=n===void 0?6e3:Number(n);(!Number.isFinite(r)||r<120)&&(console.error(" error: --limit must be a number of at least 120"),process.exit(1));let l=await d.send({type:"evaluate",code:`(async () => {
849
- const perf = window.SootSim?.bridges?.scrollPerf
850
- if (!perf) return { error: 'scroll performance profile unavailable' }
851
- await perf.start(${Math.floor(r)})
852
- return { started: true }
853
- })()`});l?.error&&(console.error(` error: ${l.error}`),process.exit(1)),console.log(` scroll profiling started: perform consecutive swipes, then run '${h("perf")} stop'`);break}if(o==="stop"){let n=await d.send({type:"evaluate",code:`(async () => {
854
- const perf = window.SootSim?.bridges?.scrollPerf
855
- if (!perf) return { error: 'scroll performance profile unavailable' }
856
- return await perf.stop()
857
- })()`});n?.error&&(console.error(` error: ${n.error}`),process.exit(1));let r=n;if(B(a)){D(r);break}console.log(` scroll performance trace:
858
- `),console.log(` duration: ${r.stoppedAt-r.startedAt}ms (worker series are timestamp-aligned, not frame-paired)`),console.log(` samples: tenant ${r.layers.tenant.length} \xB7 shell ${r.layers.shell.length} \xB7 compositor ${r.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 l=[];for(let u of Object.values(r.layers)){let m=new Map;for(let f of u){let $=`${f.surfaceId}:${f.nodeId}`,g=`${f.offsetY}:${f.slotY??""}:${f.phase??""}`;m.get($)!==g&&(m.set($,g),l.push(f))}}l.sort((u,m)=>u.t-m.t||u.seq-m.seq);for(let u of l)console.log(` ${String(u.t-r.startedAt).padStart(5)} ${u.layer.padEnd(10)} ${u.surfaceId.padEnd(8)} ${String(u.nodeId).padStart(5)} ${u.offsetY.toFixed(2).padStart(8)} ${u.slotY===void 0?" -":u.slotY.toFixed(2).padStart(8)} ${(u.phase??"-").padEnd(8)} ${u.paint===void 0?"-":u.paint}`);break}console.error(` unknown scroll perf command: ${o}`),process.exit(1)}if(!o||o==="--help"||o==="-h"){console.log(`
859
- ${h("perf")} \u2014 shell frame profiling (the worker that paints)
860
-
861
- records per-painted-frame timing in the shell worker \u2014 the surface that
862
- actually draws the app's pixels \u2014 merged with render-profile counters
863
- (node visits, boundary records/replays, raster tier, blur ms, draw calls).
864
-
865
- subcommands:
866
- start begin recording (clears prior frames + counters)
867
- stop stop recording and report results
868
- transition <e> profile a shell transition (goHome, appSwitcher, lockScreen)
869
-
870
- stop and transition accept --json for the full machine-readable payload.
871
-
872
- examples:
873
- ${h("perf")} start
874
- # ... interact with the app ...
875
- ${h("perf")} stop
876
- ${h("perf")} stop --json
877
- ${h("perf")} transition goHome
878
- `);break}switch(o){case"start":{let n=await d.send({type:"evaluate",code:`(() => {
879
- if (!window.__sootsimShellPerf) {
880
- return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
881
- }
882
- window.__sootsimShellPerf.start()
883
- return { started: true }
884
- })()`});n?.error&&(console.error(` error: ${n.error}`),process.exit(1)),console.log(` shell profiling started \u2014 interact with the app, then run '${h("perf")} stop'`);break}case"stop":{let n=await d.send({type:"evaluate",code:`(async () => {
885
- if (!window.__sootsimShellPerf) {
886
- return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
887
- }
888
- return await window.__sootsimShellPerf.stop()
889
- })()`});if(n?.error&&(console.error(` error: ${n.error}`),n.error==="timeout"&&console.error(" (shell worker did not answer within 5s \u2014 is a sim loaded?)"),process.exit(1)),B(a)){D(n);break}ko(n);break}case"transition":{let n=i[2];if(!n||!["goHome","appSwitcher","lockScreen"].includes(n)){console.log(`
890
- ${h("perf")} transition <event> \u2014 profile a shell transition
891
-
892
- events:
893
- goHome swipe-to-home animation
894
- appSwitcher app switcher card animation
895
- lockScreen lock screen transition
896
-
897
- note: uses 600ms capture window \u2014 may need --timeout 10000 flag
898
-
899
- examples:
900
- ${h("perf")} transition goHome --timeout 10000
901
- ${h("perf")} transition appSwitcher
902
- `);break}let l=`sootsim:${n}`;Me(` profiling ${n} transition...`),Me(" (use --timeout 10000 if this times out)");let u=await d.send({type:"evaluate",code:`(async () => {
903
- if (!window.__sootsimShellPerf) {
904
- return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
905
- }
906
- window.__sootsimShellPerf.start()
907
- // give a frame for profiling to engage before the event
908
- await new Promise(r => requestAnimationFrame(() => r(undefined)))
909
- window.dispatchEvent(new Event('${l}'))
910
- // shell animations are ~300-500ms; fixed timing avoids complex
911
- // animation-end detection
912
- await new Promise(r => setTimeout(r, 600))
913
- return await window.__sootsimShellPerf.stop()
914
- })()`});if(u?.error&&(console.error(` error: ${u.error}`),process.exit(1)),B(a)){D(u);break}Me(` ${n} transition profiled:`),ko(u);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).")),process.exit(1)}break}case"errors":{let o=i[1];if(o==="clear"){await We(d),B(a)?D({cleared:!0}):console.log(" error buffer cleared");break}let n=o?Number(o):20,r=await ge(d,n);if(B(a)){D(r);break}if(r.length===0){console.log(" no errors captured");break}console.log(` ${r.length} error(s):
915
- `);for(let l of r){let u=ae(l.timestamp),m=l.args.map(f=>typeof f=="object"?JSON.stringify(f):f).join(" ");if(console.log(` [${u}] ${m}`),l.stack){let f=l.stack.split(`
916
- `).slice(0,3);for(let $ of f)console.log(` ${$.trim()}`)}}break}case"warnings":{let o=i[1]?Number(i[1]):20,n=await vt(d,o);if(B(a)){D(n);break}if(n.length===0){console.log(" no warnings captured");break}console.log(` ${n.length} warning(s):
917
- `);for(let r of n){let l=ae(r.timestamp),u=r.args.map(m=>typeof m=="object"?JSON.stringify(m):m).join(" ");console.log(` [${l}] ${u}`)}break}case"animations":{let o=await X(d,"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):
918
- `);for(let n of o){let r=String(n.realm??"tenant").padEnd(6),l=String(n.kind).padEnd(10),u=typeof n.from=="number"&&typeof n.to=="number"?`${n.from.toFixed(2)}\u2192${n.to.toFixed(2)}`:"\u2014",m=Number(n.current??0).toFixed(2),f=typeof n.progress=="number"?`${Math.round(n.progress*100)}%`:"\u2014",$=`${Math.round(n.elapsedMs??0)}ms`,g=[n.loop?"loop":null,n.layoutBound?"layout":null,n.remoteDriven?"remote-driven":n.graphBacked?"graph":null,n.visible===!1?"offscreen":null].filter(Boolean),k=g.length>0?` [${g.join(" ")}]`:"";console.log(` #${n.id} ${r} ${l} ${u.padEnd(14)} cur=${m.padEnd(7)} ${f.padStart(4)} ${$}${k}`)}break}case"animation":{let o=i[1];(!o||o==="--help"||o==="-h")&&(console.error(` usage: ${h("animation")} <id>`),process.exit(1));let n=Number(o);Number.isFinite(n)||(console.error(` invalid id: ${o}`),process.exit(1));let r=await X(d,"getAnimation",n);console.log(JSON.stringify(r,null,2));break}case"stop-animation":{let o=i[1];(!o||o==="--help"||o==="-h")&&(console.error(` usage: ${h("stop-animation")} <id|all>`),process.exit(1));let n=o==="all"?"all":Number(o);n!=="all"&&!Number.isFinite(n)&&(console.error(` invalid id: ${o}`),process.exit(1));let r=await X(d,"stopAnimation",n);console.log(` stopped ${r??0} animation(s)`);break}case"requests":{let o=i[1];if(o==="clear"){await It(d),B(a)?D({cleared:!0}):console.log(" request buffer cleared");break}let n=o==="all",r=n?i[2]:o,l=r?Number(r):20,u=await kt(d,{failed:!n,limit:l});if(B(a)){D(u);break}if(u.length===0){console.log(n?" no requests captured":" no failed requests captured");break}console.log(` ${u.length} ${n?"request(s)":"failed request(s)"}:
919
- `);for(let m of u){let f=ae(m.timestamp);console.log(` [${f}] ${U(m)}`),m.responseBody?console.log(` ${m.responseBody}`):m.error&&console.log(` ${m.error}`)}break}case"network":{let o=i[1],n=null,r=null,l=!1,u=!1,m=1e3,f=!1,$=!1;for(let E=0;E<a.length;E++){let v=a[E];if(v==="--filter")n=a[E+1]??null,E++;else if(v==="--limit"){let T=Number(a[E+1]);Number.isFinite(T)&&(r=T),E++}else if(v==="--threshold"){let T=Number(a[E+1]);Number.isFinite(T)&&T>0&&(m=T),E++}else v==="--failed"?l=!0:v==="--slow"?u=!0:v==="--tail"||v==="-f"?f=!0:v==="--json"&&($=!0)}if(o==="clear"){await d.send({type:"evaluate",code:'window.__sootsimObservability?.network.clear(); "cleared"'}),console.log(" network buffer cleared");break}if(o==="get"){let E=i[2];E||(console.error(" usage: rnxsim network get <id>"),process.exit(1));let v=await d.send({type:"evaluate",code:`(() => {
920
- const obs = window.__sootsimObservability;
921
- if (!obs) return null;
922
- return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(E)}) || null;
923
- })()`});v||(console.error(` no entry with id ${E}`),process.exit(1)),$?console.log(JSON.stringify(v,null,2)):ws(v);break}let g=r??(f?200:o?Number(o):20);Number.isFinite(g)||(console.error(` invalid limit: ${o} \u2014 \`network\` takes a numeric count (e.g. ${h("network")} 100).
924
- to target a specific sim, use \`--sim ${o}\` instead.`),process.exit(1));let k=async()=>{let E=await d.send({type:"evaluate",code:`(() => {
925
- const obs = window.__sootsimObservability;
926
- if (!obs) return { ok: false };
927
- return { ok: true, entries: obs.network.getSnapshot() };
928
- })()`});if(!E||!E.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return E.entries??[]},L=E=>{let v=E;if(l&&(v=v.filter(T=>!!T.error||T.status!=null&&T.status>=400)),u&&(v=v.filter(T=>T.durationMs!=null&&T.durationMs>=m)),n){let T=n.toLowerCase();v=v.filter(N=>(N.displayUrl||N.url).toLowerCase().includes(T))}return u&&!f&&(v=[...v].sort((T,N)=>(N.durationMs??0)-(T.durationMs??0))),v};if(!f){let E=await k(),v=L(E).slice(-g);if($){console.log(JSON.stringify(v,null,2));break}if(v.length===0){E.length===0?console.log(" no network requests captured"):console.log(u?` no requests slower than ${m}ms (${E.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(u?` ${v.length} request(s) slower than ${m}ms (sorted by duration desc):
929
- `:` ${v.length} request(s):
930
- `);for(let T of v)wo(T);break}console.log(` tailing network (ctrl-c to stop)...
931
- `);let V=new Set,G=!0,Y=()=>{G=!1};process.on("SIGINT",Y);try{for(;G;){let E=await k(),v=L(E);for(let T of v)T.durationMs!=null&&(V.has(T.id)||(V.add(T.id),$?console.log(JSON.stringify(T)):wo(T)));await oe(250)}}finally{process.off("SIGINT",Y)}break}case"logs":{let o=i[1],n=null,r=null,l=null,u=!1,m=!1,f=!1;for(let v=0;v<a.length;v++){let T=a[v];if(T==="--filter")n=a[v+1]??null,v++;else if(T==="--limit"){let N=Number(a[v+1]);Number.isFinite(N)&&(r=N),v++}else T==="--level"?(l=a[v+1]??null,v++):T==="--tail"||T==="-f"?u=!0:T==="--json"?m=!0:(T==="--internal"||T==="--all")&&(f=!0)}let $=l?new Set(l.split(",").map(v=>v.trim()).filter(v=>v==="log"||v==="info"||v==="warn"||v==="error"||v==="debug")):null;if(o==="clear"){await Mt(d),console.log(" log buffer cleared");break}let g=!m&&process.stdout.isTTY===!0,k=r??(u?500:o?Number(o):50);Number.isFinite(k)||(console.error(` invalid limit: ${o} \u2014 \`logs\` takes a numeric count (e.g. ${h("logs")} 100).
932
- to target a specific sim, use \`--sim ${o}\` instead.`),process.exit(1));let L=()=>Tt(d),V=v=>Nt(v,{level:$,filter:n,showInternal:f});if(!u){let v=await L(),T=V(v).slice(-k);if(m){console.log(JSON.stringify(T,null,2));break}if(T.length===0){console.log(v.length===0?" no logs captured":" no matching logs");break}console.log(` ${T.length} log(s):
933
- `);for(let N of T)$o(N,g);break}console.log(` tailing logs (ctrl-c to stop)...
934
- `);let G=new Set,Y=!0,E=()=>{Y=!1};process.on("SIGINT",E);try{for(;Y;){let v=await L(),T=V(v);for(let N of T)G.has(N.id)||(G.add(N.id),m?console.log(JSON.stringify(N)):$o(N,g));await oe(250)}}finally{process.off("SIGINT",E)}break}default:console.error(` unknown subcommand: ${p}`),process.exit(1)}if(j.has(p)&&!e.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&!await pt(d,p)&&await I(d),S.length>0&&ee(S),!P.has(p))try{await Se(d)}catch{}}catch(S){let o=S instanceof Error?S.message:String(S);console.error(` ${p??"inspect"} failed: ${o}`);let n=/^no sim connected with id ([^;]+)(?:; connected sims: .+)?$/.exec(o),r=/^command timed out after (\d+)s$/.exec(o),l=o.startsWith("sim disconnected:")||o.startsWith("bridge never reconnected")||o.startsWith("could not connect to ws://");if(n)await jt(d,F,n[1]);else if(/^no sim connected$/.test(o))Ct(F);else if(r)if(await fs(d)){let m=p??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
935
- the screen's node tree is large; narrow the query or raise the budget:
936
- rnxsim ${m} --testid <id> # scope to one subtree
937
- rnxsim find --testid <id> # targeted single-node lookup
938
- rnxsim ${m} --timeout 60000 # raise per-command budget (ms)
939
- `)}else ho();else if(l)ho();else{try{await At(d)}catch{}try{await te({includeTail:!0})}catch{}try{await K({includeTail:!0})}catch{}}process.exit(1)}finally{d.close()}}export{He as a,_o as b,Os as c,Bs as d,Cs as e,js as f,qs as g,se as h,ko as i,Er as j};