sootsim 0.1.40 → 0.1.41
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.
- package/README.md +15 -15
- package/dist-cli/bin.js +3 -3
- package/dist-cli/chunks/{agent-3F5PO4NL.js → agent-7BJ2ZP22.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-LVUUZRWL.js → agent-wrapper-OXBYRJVT.js} +2 -2
- package/dist-cli/chunks/{assert-4WMVS3WU.js → assert-NZTYFTTT.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-4KQT4TCR.js +2 -0
- package/dist-cli/chunks/beta-3S56PNSS.js +2 -0
- package/dist-cli/chunks/{chunk-DSTHAISO.js → chunk-2T6UOHPO.js} +1 -1
- package/dist-cli/chunks/chunk-334L67M2.js +2 -0
- package/dist-cli/chunks/{chunk-Y5CFIRLN.js → chunk-33R6QMNO.js} +1 -1
- package/dist-cli/chunks/{chunk-WPS3TIOB.js → chunk-4UA6P3T2.js} +1 -1
- package/dist-cli/chunks/{chunk-WQXG4I5N.js → chunk-5JOYGXCS.js} +2 -2
- package/dist-cli/chunks/{chunk-PNGBWMQH.js → chunk-6PLNIOJP.js} +2 -2
- package/dist-cli/chunks/{chunk-WZE6T3GT.js → chunk-7YZJHZ7X.js} +1 -1
- package/dist-cli/chunks/{chunk-QUULF2II.js → chunk-ANDSHXLU.js} +2 -2
- package/dist-cli/chunks/chunk-AOYBIMKL.js +4 -0
- package/dist-cli/chunks/chunk-ASSV2FFC.js +1 -0
- package/dist-cli/chunks/chunk-BR6QRN7U.js +11 -0
- package/dist-cli/chunks/{chunk-EOWN4ZFJ.js → chunk-C4AMFYK3.js} +2 -2
- package/dist-cli/chunks/{chunk-BZED27B2.js → chunk-ECIRRKKE.js} +2 -2
- package/dist-cli/chunks/{chunk-LCES5ZJI.js → chunk-FZB4W23Y.js} +2 -2
- package/dist-cli/chunks/{chunk-PKB6IEGM.js → chunk-G2QUPNHI.js} +2 -2
- package/dist-cli/chunks/{chunk-FNIL6BYS.js → chunk-GB3G5LVB.js} +1 -1
- package/dist-cli/chunks/{chunk-KGVH3YAG.js → chunk-GI7FXE7J.js} +2 -2
- package/dist-cli/chunks/{chunk-6XI4VHIL.js → chunk-GOFKXREQ.js} +2 -2
- package/dist-cli/chunks/{chunk-YJMXGTP4.js → chunk-HAVQS3PI.js} +1 -1
- package/dist-cli/chunks/{chunk-6X5NQJT7.js → chunk-HZVPHAJX.js} +20 -20
- package/dist-cli/chunks/{chunk-5IAIIX7B.js → chunk-I5Y4IECP.js} +3 -3
- package/dist-cli/chunks/{chunk-MLCBIX7O.js → chunk-IF33CQL4.js} +2 -2
- package/dist-cli/chunks/chunk-IP2MARRU.js +27 -0
- package/dist-cli/chunks/{chunk-YKEBL6GE.js → chunk-J3JJRXIP.js} +1 -1
- package/dist-cli/chunks/{chunk-OV5TY7M3.js → chunk-LMNB7NYI.js} +2 -2
- package/dist-cli/chunks/{chunk-CCZHRBXJ.js → chunk-LX6KS6TL.js} +1 -1
- package/dist-cli/chunks/{chunk-KVOMVYG6.js → chunk-MBGNDWGV.js} +2 -2
- package/dist-cli/chunks/{chunk-DEBXVPIE.js → chunk-N7DDNZTO.js} +1 -1
- package/dist-cli/chunks/chunk-NZ5O2OEL.js +56 -0
- package/dist-cli/chunks/{chunk-4L45Q3YX.js → chunk-OJFHAMXD.js} +2 -2
- package/dist-cli/chunks/{chunk-W2XRHDQQ.js → chunk-OPDPXAYA.js} +2 -2
- package/dist-cli/chunks/{chunk-U3JD6X75.js → chunk-OXTFYLZJ.js} +2 -2
- package/dist-cli/chunks/{chunk-TK2IPNHL.js → chunk-Q6DGMQ2V.js} +2 -2
- package/dist-cli/chunks/{chunk-553OZX4H.js → chunk-S3SQITOO.js} +2 -2
- package/dist-cli/chunks/{chunk-QMBYRPRK.js → chunk-SHHUVGL2.js} +1 -1
- package/dist-cli/chunks/{chunk-Y66CDFAT.js → chunk-SWHWVYZS.js} +1 -1
- package/dist-cli/chunks/{chunk-5GK4YX7O.js → chunk-TBIGAH3T.js} +1 -1
- package/dist-cli/chunks/chunk-UNJTJDZZ.js +62 -0
- package/dist-cli/chunks/chunk-WN6YFWS5.js +117 -0
- package/dist-cli/chunks/{chunk-Z3I2I4IO.js → chunk-WZDE344I.js} +3 -3
- package/dist-cli/chunks/{chunk-LXR5EI74.js → chunk-Y2YNXUBT.js} +2 -2
- package/dist-cli/chunks/chunk-YFX2XIR4.js +1 -0
- package/dist-cli/chunks/chunk-YKFRPIVC.js +1 -0
- package/dist-cli/chunks/chunk-ZPURE62G.js +1 -0
- package/dist-cli/chunks/{compat-NBFWHK5S.js → compat-BA6HDW3Q.js} +5 -5
- package/dist-cli/chunks/{config-JEDQ3NHA.js → config-QQ63IS5P.js} +2 -2
- package/dist-cli/chunks/control-GNJNC524.js +2 -0
- package/dist-cli/chunks/cpu-profile-3DDV2SYN.js +2 -0
- package/dist-cli/chunks/{daemon-HOL7J3BI.js → daemon-RYSVONEV.js} +2 -2
- package/dist-cli/chunks/{debug-LNVMIWD6.js → debug-YXE4XZLP.js} +3 -3
- package/dist-cli/chunks/demo-app-registry-3VFEW4NV.js +2 -0
- package/dist-cli/chunks/{detox-EEZPH3DZ.js → detox-2UI3EAXA.js} +2 -2
- package/dist-cli/chunks/{device-GVLYQI7X.js → device-UGDJBZKD.js} +2 -2
- package/dist-cli/chunks/diagnose-IRDRYKYZ.js +41 -0
- package/dist-cli/chunks/drivers-EAONIWG3.js +2 -0
- package/dist-cli/chunks/{electron-UDV6K3IH.js → electron-ZCYWIZAE.js} +3 -3
- package/dist-cli/chunks/flow-ECSMFTKS.js +2 -0
- package/dist-cli/chunks/{hints-46PJLATZ.js → hints-OWOBCWJH.js} +2 -2
- package/dist-cli/chunks/{home-paths-XD7AOYU7.js → home-paths-5QMCFTBP.js} +2 -2
- package/dist-cli/chunks/{inspect-EDIKZ6O2.js → inspect-K4VXPM5J.js} +94 -92
- package/dist-cli/chunks/install-YFE7C2NU.js +2 -0
- package/dist-cli/chunks/{install-desktop-CX6ATQTR.js → install-desktop-U3723T63.js} +3 -3
- package/dist-cli/chunks/{keys-CXQIYEVW.js → keys-IFVXJ7C2.js} +2 -2
- package/dist-cli/chunks/{launch-DCFRKVD3.js → launch-NDGFTRZ5.js} +3 -3
- package/dist-cli/chunks/{login-HCIZL5GT.js → login-KEU6RAV3.js} +4 -4
- package/dist-cli/chunks/{logout-7X2YHJY3.js → logout-KNFLP5OQ.js} +2 -2
- package/dist-cli/chunks/{maestro-TY622MIW.js → maestro-GBUBLS6L.js} +2 -2
- package/dist-cli/chunks/{preview-DYI6ESOK.js → preview-7OKMPPMN.js} +2 -2
- package/dist-cli/chunks/{profile-7SXJEJTG.js → profile-CHKDPGJF.js} +2 -2
- package/dist-cli/chunks/{react-VGSDY766.js → react-GYI5VITJ.js} +2 -2
- package/dist-cli/chunks/record-DQR2TEIF.js +45 -0
- package/dist-cli/chunks/runtime-XXNKSGFE.js +2 -0
- package/dist-cli/chunks/{runtime-delivery-PWLODFCY.js → runtime-delivery-JCAY2QVQ.js} +2 -2
- package/dist-cli/chunks/{screenshot-PTKY4UU4.js → screenshot-3T6MNPH7.js} +2 -2
- package/dist-cli/chunks/{screenshot-mode-HSV7VY4G.js → screenshot-mode-BUGXY7SQ.js} +2 -2
- package/dist-cli/chunks/{screenshots-VY7VAGSV.js → screenshots-EMTXGI2Q.js} +2 -2
- package/dist-cli/chunks/server-46H2M4TF.js +35 -0
- package/dist-cli/chunks/setup-repo-P4LCPAF6.js +2 -0
- package/dist-cli/chunks/{skills-KEPQLCMR.js → skills-2RP2CFPD.js} +2 -2
- package/dist-cli/chunks/{start-5CJTBNRM.js → start-QFREXALP.js} +4 -4
- package/dist-cli/chunks/store-GH77HGEB.js +2 -0
- package/dist-cli/chunks/telemetry-WC5J4TE5.js +2 -0
- package/dist-cli/chunks/{test-REKHGKFE.js → test-LI4PGGTE.js} +3 -3
- package/dist-cli/chunks/{three-mode-FZYHB4ZQ.js → three-mode-PKINB46T.js} +2 -2
- package/dist-cli/chunks/{timeline-CWZAY52K.js → timeline-5AREJDL5.js} +2 -2
- package/dist-cli/chunks/{upgrade-AIUJEF5F.js → upgrade-W2AGIOSC.js} +2 -2
- package/dist-cli/chunks/upload-RLS6KTG6.js +2 -0
- package/dist-cli/chunks/web-JM6WDSZQ.js +2 -0
- package/dist-cli/chunks/{what-happened-JSQQVQGE.js → what-happened-SVCASJKT.js} +2 -2
- package/dist-cli/chunks/whoami-5NJ6IPLT.js +2 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +14 -8
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/vite-base.cjs +14 -8
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/dist-cli/chunks/auto-bootstrap-Q4A3PTF5.js +0 -2
- package/dist-cli/chunks/beta-CLLKUB5X.js +0 -2
- package/dist-cli/chunks/chunk-4IAKB3C4.js +0 -117
- package/dist-cli/chunks/chunk-CAJ247SC.js +0 -2
- package/dist-cli/chunks/chunk-D2ZMP7G4.js +0 -61
- package/dist-cli/chunks/chunk-D4Z7MWQY.js +0 -11
- package/dist-cli/chunks/chunk-DHJIXXWG.js +0 -27
- package/dist-cli/chunks/chunk-DPZDTJVQ.js +0 -1
- package/dist-cli/chunks/chunk-FFR7EA4U.js +0 -1
- package/dist-cli/chunks/chunk-I7KXFJDK.js +0 -1
- package/dist-cli/chunks/chunk-J6BPROH4.js +0 -4
- package/dist-cli/chunks/chunk-S4PJMUC7.js +0 -2
- package/dist-cli/chunks/chunk-XWXFUFB2.js +0 -1
- package/dist-cli/chunks/control-IMWZVYC3.js +0 -2
- package/dist-cli/chunks/cpu-profile-MQPUSRHG.js +0 -22
- package/dist-cli/chunks/demo-app-registry-4RFMJ4FM.js +0 -2
- package/dist-cli/chunks/diagnose-JQ7DPTSL.js +0 -41
- package/dist-cli/chunks/drivers-JUW6JBWH.js +0 -2
- package/dist-cli/chunks/flow-JOW23WNH.js +0 -2
- package/dist-cli/chunks/install-CCC3IF5S.js +0 -2
- package/dist-cli/chunks/record-7JX2SMVP.js +0 -37
- package/dist-cli/chunks/runtime-FTOQD7QK.js +0 -2
- package/dist-cli/chunks/server-EDB3EK4K.js +0 -35
- package/dist-cli/chunks/setup-repo-S2GFZR7F.js +0 -2
- package/dist-cli/chunks/store-SCRULNVS.js +0 -2
- package/dist-cli/chunks/telemetry-RC3OT67I.js +0 -2
- package/dist-cli/chunks/upload-UDA5ITTE.js +0 -2
- package/dist-cli/chunks/whoami-5WUUPIRN.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as G}from"./chunk-
|
|
3
|
-
`)}function
|
|
1
|
+
/*! sootsim v0.1.41 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as G}from"./chunk-IF33CQL4.js";import{a as Ce,b as De}from"./chunk-4UA6P3T2.js";import{a as X,b as C,c as D,d as z,e as ce,f as ne,g as ot,h as st,i as xe}from"./chunk-MBGNDWGV.js";import{D as tt,a as Be,b as je,c as Le,d as Je,e as qe,f as be,g as we,h as We,i as He,j as Ke,k as Ue,l as ze,m as Ye,n as Ge,o as Xe,p as Ve,q as Qe,u as Ze,w as se,x as et}from"./chunk-GB3G5LVB.js";import{a as Re,e as le}from"./chunk-GI7FXE7J.js";import{b as nt,c as rt,i as it}from"./chunk-BR6QRN7U.js";import"./chunk-LX6KS6TL.js";import{a as Ee}from"./chunk-SHHUVGL2.js";import"./chunk-NZ5O2OEL.js";import"./chunk-7YZJHZ7X.js";import"./chunk-Q6DGMQ2V.js";import"./chunk-YKFRPIVC.js";import"./chunk-C4AMFYK3.js";import{a as ge,c as ye,d as Ie}from"./chunk-WN6YFWS5.js";import{a as Ne}from"./chunk-334L67M2.js";import{c as Fe,e as Ae,f as Pe,g as Oe,h as he}from"./chunk-6PLNIOJP.js";import{b as _e}from"./chunk-SWHWVYZS.js";import"./chunk-ASSV2FFC.js";import"./chunk-J3JJRXIP.js";import"./chunk-N7DDNZTO.js";import{existsSync as Lt,mkdirSync as Jt,readFileSync as qt,rmSync as at,writeFileSync as Wt}from"fs";import{tmpdir as Ht}from"os";import{dirname as Kt,join as Ut,resolve as zt}from"path";var re=1,Yt="SOOTSIM_INSPECT_NOTICE_PATH",Gt=300*1e3,Xt=15e3;function lt(){return zt(process.env[Yt]||Ut(Ht(),"sootsim-inspect-notice-state.json"))}function Vt(s,d){return Object.fromEntries(Object.entries(s).filter(([,a])=>typeof a?.signature=="string"&&Number.isFinite(a?.updatedAt)&&d-a.updatedAt<=Gt))}function Qt(s){let d=lt();if(!Lt(d))return{version:re,entries:{}};try{let a=JSON.parse(qt(d,"utf8"));return a.version!==re||!a.entries||typeof a.entries!="object"?(at(d,{force:!0}),{version:re,entries:{}}):{version:re,entries:Vt(a.entries,s)}}catch{return at(d,{force:!0}),{version:re,entries:{}}}}function Zt(s){let d=lt();Jt(Kt(d),{recursive:!0}),Wt(d,JSON.stringify(s,null,2)+`
|
|
3
|
+
`)}function eo(s,d){let a=d.trim()||"default";return`${s}:${a}`}function $e(s,d,a,l={}){let f=l.nowMs??Date.now(),i=l.cooldownMs??Xt,h=Qt(f),S=eo(s,d),I=h.entries[S];return I&&I.signature===a&&f-I.updatedAt<i?!1:(h.entries[S]={signature:a,updatedAt:f},Zt(h),!0)}async function ct(s,d={args:[]}){let a=await Be(s);if(C(d.args)){D(a);return}console.log(` nodes: ${a.nodes}`)}function Se(s,d){let a=s.indexOf(d);return a>=0&&a+1<s.length?s[a+1]:null}async function dt(s){let{bridge:d,args:a,positional:l}=s,f=a.includes("--verbose")||a.includes("-v"),i=C(a),h=f&&!i,S=a.includes("--watch")||a.includes("-w"),I=1e3,T=a.includes("--compact"),w=a.includes("--no-xy"),v=Se(a,"--testid-like"),_=Se(a,"--only"),M=Se(a,"--subtree"),R=l[1],c=R?/[*?]/.test(R):!1,J=!c&&!_?R:void 0,U=_??(c?R:void 0),E=async()=>{await ce(d,{verbose:h});let Y=await Je(d,{describe:!0,verbose:f,filter:J||"",testIdLike:v||void 0,onlyGlob:U||void 0,subtreeRoot:M||void 0,compact:T,hideXy:w}),W=Y?.tree,x=Y?.shell,N=Y?.keyboard;if(i){D({shell:x,tree:W??"",keyboard:N});return}if(x&&typeof x=="object"){let F=[x.state?`state=${x.state}`:null,x.activeApp?`app=${x.activeApp}`:null,x.showSwitcher?"switcher":null,x.switcherPhase&&x.switcherPhase!=="idle"?`phase=${x.switcherPhase}`:null].filter(Boolean);F.length>0&&console.log(` shell: ${F.join(" ")}`)}if(typeof W=="string"&&W.startsWith("__SUBTREE_NOT_FOUND__:")){let F=W.slice(22);console.log(` subtree root not found: ${F}`),G("subtree-root-not-found",F);return}if(!W){let F=Y?.nodeCount??0;console.log(" no matching nodes found"),!(J||v||U||M)&&F<10&&G("app-still-loading",F);return}if(console.log(W),!(J||v||U||M)&&!S&&W.split(`
|
|
4
4
|
`).length>=80&&G("describe-use-filters"),N&&N.visible){let F=N.spec,V=[F?.keyboardType?`type=${F.keyboardType}`:null,F?.returnKeyType&&F.returnKeyType!=="default"?`return=${F.returnKeyType}`:null,N.mode!=="letters"?`mode=${N.mode}`:null,N.shifted?"shift":null,N.capsLock?"caps":null,F?.autoCapitalize&&F.autoCapitalize!=="sentences"?`autoCap=${F.autoCapitalize}`:null,N.accessoryBarId?`accessory=${N.accessoryBarId}`:null].filter(Boolean);console.log(`
|
|
5
5
|
keyboard: ${V.join(" ")||"visible"}`)}};if(S)for(console.log(` watching... (Ctrl+C to stop)
|
|
6
|
-
`);;)console.clear(),await E(),await X(I);else await E()}var
|
|
6
|
+
`);;)console.clear(),await E(),await X(I);else await E()}var to=["SOOTSIM_AGENT","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function ut(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let s of to){let d=process.env[s];if(d&&d.trim()&&d!=="0")return!0}return!1}async function mt(s){let{bridge:d,args:a,effectiveArgs:l,positional:f,inspectUsage:i}=s,h=x=>{let N=l.indexOf(x);return N>=0&&N+1<l.length?l[N+1]:null},S=x=>l.includes(x),I=h("--testid")||h("--test-id"),T=h("--role"),w=h("--type"),v=h("--text"),_=S("--pressable"),M=S("--visible"),R=S("--interactive-targets")||S("--actions"),c=!I&&!T&&!w&&!v&&!_&&!M&&!R?f[1]:null,J=v??c,U=await qe(d,{testId:I,role:T,type:w,text:J,pressable:_,visible:M,interactive:R});U||(console.error(i("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:E,result:L}=U,Y=C(a),W=a.includes("--verbose")||a.includes("--dump");if(Y)E==="interactive-targets"&&Array.isArray(L)?D(be(L).map(x=>({...x,tap:we(x)}))):D(L??null);else if(Array.isArray(L))if(L.length===0){console.log(` no ${E} nodes found`);let x=await d.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof x=="number"&&x<10&&G("app-still-loading",x)}else if(E==="interactive-targets"){let x=be(L);console.log(` found ${x.length} interactive target${x.length===1?"":"s"} (sorted by score):`);for(let N of x.slice(0,20)){let Z=N.absolutePosition?`@(${Math.round(N.absolutePosition.x)},${Math.round(N.absolutePosition.y)})`:"",F=N.layout?`${Math.round(N.layout.width)}x${Math.round(N.layout.height)}`:"?x?",V=N.text?` "${N.text.slice(0,30)}"`:"",te=N.testID?` #${N.testID}`:"",e=N.accessibilityLabel?` \u24D8"${String(N.accessibilityLabel).slice(0,24)}"`:"",t=N.accessibilityRole?`[${N.accessibilityRole}]`:N.type,o=we(N);console.log(` ${t}${V}${e}${te} ${F} ${Z}`),console.log(` \u2192 ${o}`),W&&console.log(ve(JSON.stringify(N,null,2)," "))}x.length>20&&console.log(` ... and ${x.length-20} more`)}else{console.log(` found ${L.length} node${L.length===1?"":"s"} (${E}):`);for(let x of L.slice(0,20)){let N=x.absolutePosition?`@(${Math.round(x.absolutePosition.x)},${Math.round(x.absolutePosition.y)})`:"",Z=x.layout?`${Math.round(x.layout.width)}x${Math.round(x.layout.height)}`:"?x?",F=x.text?` "${x.text.slice(0,30)}"`:"",V=x.testID?` #${x.testID}`:"",te=x.pressable?" (tap)":"",e=x.accessibilityRole?`[${x.accessibilityRole}]`:x.type;console.log(` ${e}${F}${V} ${Z} ${N}${te}`),W&&console.log(ve(JSON.stringify(x,null,2)," "))}L.length>20&&console.log(` ... and ${L.length-20} more`)}else if(L==null)console.log(` not found: ${J||I||T||w||""||E}`),I&&G("wait-selector-for-missing-testid",I);else{let x=L;if(x.type&&x.absolutePosition){let N=`@(${Math.round(x.absolutePosition.x)},${Math.round(x.absolutePosition.y)})`,Z=x.layout?`${Math.round(x.layout.width)}x${Math.round(x.layout.height)}`:"?x?",F=x.text?` "${x.text.slice(0,40)}"`:"",V=x.testID?` #${x.testID}`:"",te=x.pressable?" (tap)":"",e=x.accessibilityRole?`[${x.accessibilityRole}]`:x.type;console.log(` ${e}${F}${V} ${Z} ${N}${te}`),W&&console.log(ve(JSON.stringify(x,null,2)," "))}else console.log(JSON.stringify(L,null,2))}}function ve(s,d){return s.split(`
|
|
7
7
|
`).map(a=>d+a).join(`
|
|
8
|
-
`)}async function
|
|
9
|
-
`))}async function
|
|
8
|
+
`)}async function pt(s,d={}){let a=await Ze(s);if("error"in a&&(console.error(a.error),process.exit(1)),d.json){console.log(JSON.stringify(a,null,2));return}let{visible:l,spec:f,mode:i,shifted:h,capsLock:S,accessoryBarId:I}=a,T=[];T.push(`keyboard: ${l?"visible":"hidden"}`),f?(T.push(` type: ${f.keyboardType}`),T.push(` returnKey: ${f.returnKeyType}`),T.push(` autoCap: ${f.autoCapitalize}`),T.push(` autoCorrect: ${f.autoCorrect?"on":"off"}`),T.push(` appearance: ${f.keyboardAppearance}`),f.secureTextEntry&&T.push(" secureTextEntry: true"),f.enablesReturnKeyAutomatically&&T.push(` return: ${f.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):T.push(" spec: <none> (shown via dev-tools with no TextInput)"),T.push(` mode: ${i}${h?" (shifted)":""}${S?" (caps)":""}`),I&&T.push(` accessoryBar: ${I}`),console.log(T.join(`
|
|
9
|
+
`))}async function ft(s){let d=await s.bridge.listSims();if(C(s.args)){D(d.map(a=>({...a,active:a.id===s.simId})));return}it(d,s.simId)}function ee(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/1024/1024).toFixed(1)}MB`}function de(s,d){return d<=0?"?":`${(s/d*100).toFixed(0)}%`}async function gt(s,d={args:[]}){let a=await tt(s);if(C(d.args)){D(a);return}if(console.log(" memory:"),a.imageLoader){let l=a.imageLoader;console.log(" image-loader cache"),console.log(` entries: ${l.cacheEntries} / ${l.cacheMaxEntries} (${de(l.cacheEntries,l.cacheMaxEntries)})`),console.log(` pixel bytes: ${ee(l.cachePixelBytes)} / ${ee(l.cachePixelBudget)} (${de(l.cachePixelBytes,l.cachePixelBudget)})`),console.log(` pending: ${l.pendingFetches} fetches, ${l.pendingBytes} bytes`),console.log(` failed uris: ${l.failedUris}`),console.log(` snapshots: ${l.snapshots}`),console.log(` camera frames: ${l.cameraFrames}`)}else console.log(" image-loader cache: not available (engine pre-rebuild?)");if(a.workerHeap){let l=a.workerHeap;console.log(" worker heap (chrome only)"),console.log(` used: ${ee(l.usedJSHeapSize)} / ${ee(l.jsHeapSizeLimit)} (${de(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ee(l.totalJSHeapSize)}`)}if(a.hostHeap){let l=a.hostHeap;console.log(" host heap (chrome only)"),console.log(` used: ${ee(l.usedJSHeapSize)} / ${ee(l.jsHeapSizeLimit)} (${de(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${ee(l.totalJSHeapSize)}`)}}function ie(s){let d=s.indexOf("--testid");if(d>=0&&s[d+1])return{mode:"testid",value:s[d+1]};let a=s.indexOf("--test-id");if(a>=0&&s[a+1])return{mode:"testid",value:s[a+1]};let l=s.indexOf("--text");return l>=0&&s[l+1]?{mode:"text",value:s[l+1]}:null}async function ue(s,d){let a=JSON.stringify(d.value),l=d.mode==="testid"?`(await t.findByTestId(${a})) || (await t.findById(${a}))`:`await t.findByText(${a})`;return await s.send({type:"evaluate",code:`(async () => {
|
|
10
10
|
const t = window.__sootsimTest
|
|
11
11
|
if (!t) return null
|
|
12
12
|
const n = ${l}
|
|
@@ -24,8 +24,8 @@ import{a as G}from"./chunk-MLCBIX7O.js";import{a as Ce,b as De}from"./chunk-WPS3
|
|
|
24
24
|
? resolved.cy
|
|
25
25
|
: n.absolutePosition.y + (n.layout.height || 0) / 2
|
|
26
26
|
return { x: cx, y: cy, testID: n.testID, text: n.text }
|
|
27
|
-
})()`})??null}async function
|
|
28
|
-
`))}async function oe({bridge:
|
|
27
|
+
})()`})??null}async function yt(s,d={}){let{nav:a,keyboard:l,shell:f}=await et(s);if(d.json){console.log(JSON.stringify({shell:f??null,nav:a,keyboard:l},null,2));return}let i=[];if(f){let h=f.activeApp??f.state??"<none>",S=f.showSwitcher?" (app switcher open)":"",I=typeof f.launchProgress=="number"&&f.launchProgress<.98?` launching (${Math.round(f.launchProgress*100)}%)`:"";i.push(`shell: ${h}${S}${I}`)}else i.push("shell: <unavailable>");if(a){let h=a.transitionPhase!=="idle"?` (${a.transitionPhase}, ${a.activeTransitionCount} active)`:"";if(i.push(`nav: phase=${a.transitionPhase}${h}`),a.screens.length===0)i.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let S of a.screens){let I=S.isActive?"\u25B6":" ",T=S.routeName?` ${S.routeName}`:"",w=S.headerHeight>0?` header=${S.headerHeight}`:"",v=S.largeTitleState&&S.largeTitleState!=="expanded"?` large-title=${S.largeTitleState}`:"";i.push(` ${I} #${S.id}${T}${w}${v}`)}}else i.push("nav: <runtime not available>");if(l&&l.visible){let h=l.spec?.keyboardType??"default",S=l.spec?.returnKeyType??"default";i.push(`keyboard: visible (${h}, return=${S}, mode=${l.mode??"?"})`)}else i.push("keyboard: hidden");console.log(i.join(`
|
|
28
|
+
`))}async function oe({bridge:s,maxMs:d,pollMs:a=50,stablePolls:l=3,strict:f=!1}){let i=await s.send({type:"evaluate",code:`(async () => {
|
|
29
29
|
const start = Date.now()
|
|
30
30
|
const deadline = start + ${Math.max(0,Math.round(d))}
|
|
31
31
|
const pollMs = ${Math.max(1,Math.round(a))}
|
|
@@ -74,12 +74,12 @@ import{a as G}from"./chunk-MLCBIX7O.js";import{a as Ce,b as De}from"./chunk-WPS3
|
|
|
74
74
|
await sleep(pollMs)
|
|
75
75
|
}
|
|
76
76
|
return { settled: false, elapsed: Date.now() - start }
|
|
77
|
-
})()`}),{elapsed:h,settled:S}=i??{};return{elapsed:typeof h=="number"?h:d,settled:S===!0}}async function
|
|
77
|
+
})()`}),{elapsed:h,settled:S}=i??{};return{elapsed:typeof h=="number"?h:d,settled:S===!0}}async function ht(s){let{bridge:d,args:a,positional:l}=s,f=l[1]?Number(l[1])*1e3:3e3,i=a.includes("--strict"),{elapsed:h,settled:S}=await oe({bridge:d,maxMs:f,strict:i});console.log(S?` settled in ${h}ms`:` timed out after ${h}ms (may still be animating)`)}async function bt(s){let d=s.positional[1]?Number(s.positional[1]):.5;(!Number.isFinite(d)||d<0)&&(console.error(s.inspectUsage("sleep","[seconds]")),process.exit(1)),await X(d*1e3),console.log(` slept ${d}s`)}async function wt(s){let{bridge:d,args:a,positional:l}=s,f=l[1]?Number(l[1]):5,{tree:i}=await je(d,f);if(C(a)){D({depth:f,tree:i??null});return}console.log(typeof i=="string"?i:JSON.stringify(i,null,2))}async function xt(s,d={args:[]}){let a=await Le(s);if(C(d.args)){D(a);return}console.log(a.url)}async function $t(s){let{wsPort:d,commandTimeoutMs:a,simId:l,positional:f}=s,i=f[1]?Number(f[1]):30,h=Math.max(1e3,(Number.isFinite(i)?i:30)*1e3),S=Math.max(1,Math.ceil(h/500));console.log(" waiting for sim reconnect...");let I=await ot(d,a,l,{attempts:S});I||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),I.bridge.close(),le({source:"inspect wait",step:{wait:h},summary:`wait ${Math.round(h/1e3)}s`}),console.log(` ready: ${I.count} nodes`)}var St=new Set(["app-launch","toast","keyboard","screen","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function me(s,d){let a=s.indexOf(d);if(a>=0&&a+1<s.length)return s[a+1]}function oo(s,d){if(!d.filter&&!d.equals)return!0;let a=s.data,l=[];if(a&&typeof a=="object")for(let i of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let h=a[i];typeof h=="string"&&h.length>0&&l.push(h)}let f=l.join(" ");return d.equals?l.some(i=>i===d.equals):d.filter?f.toLowerCase().includes(d.filter.toLowerCase()):!0}async function vt(s){let{bridge:d,args:a,positional:l,inspectUsage:f}=s,i=l[1];i||(console.error(f("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),St.has(i)||console.error(` warning: '${i}' is not a known timeline kind \u2014 waiting anyway. known: ${[...St].sort().join(", ")}`);let h=me(a,"--max-ms"),S=h&&Number.isFinite(Number(h))?Math.max(100,Number(h)):5e3,I=me(a,"--filter"),T=me(a,"--equals"),w=me(a,"--since")??"now",v=a.includes("--json"),_=Date.now(),M=_+S,R=200,c=_;for(;Date.now()<M;){let U={kinds:[i],since:w==="cursor"?void 0:c,limit:50},E=await d.send({type:"evaluate",code:`(async () => {
|
|
78
78
|
const t = window.SootSim?.bridges?.timeline
|
|
79
79
|
if (!t) return { ok: false, error: 'timeline bridge missing' }
|
|
80
80
|
return { ok: true, result: await t.recent(${JSON.stringify(U)}) }
|
|
81
|
-
})()`});(!E||!E.ok)&&(console.error(` could not query timeline: ${E&&"error"in E?E.error:"unknown"}`),process.exit(1));let L=E.result.events??[];for(let Y of L)if(
|
|
82
|
-
`).slice(0,5);for(let h of i)console.log(` ${h.trim()}`)}}var Q="__sootsimCliPerf",
|
|
81
|
+
})()`});(!E||!E.ok)&&(console.error(` could not query timeline: ${E&&"error"in E?E.error:"unknown"}`),process.exit(1));let L=E.result.events??[];for(let Y of L)if(oo(Y,{filter:I,equals:T})){let W=Date.now()-_;console.log(v?JSON.stringify({found:!0,elapsedMs:W,event:Y}):` ${i} event after ${W}ms${I?` (filter: ${I})`:""}${T?` (equals: ${T})`:""}`);return}E.result.watermark&&E.result.watermark>c&&(c=E.result.watermark),await new Promise(Y=>setTimeout(Y,R))}let J=Date.now()-_;v?console.log(JSON.stringify({found:!1,elapsedMs:J,kind:i,filter:I,equals:T})):console.error(` \u26A0 wait event ${i} timed out after ${J}ms${I?` (filter: ${I})`:""}${T?` (equals: ${T})`:""}`),process.exit(1)}async function kt(s){let{bridge:d,args:a}=s,l=a.includes("--strict"),f=a.indexOf("--max-ms"),i=f>=0&&a[f+1]?Math.max(100,Number(a[f+1])):3e3,{elapsed:h,settled:S}=await oe({bridge:d,maxMs:i,strict:l});S?console.log(` idle in ${h}ms`):(console.error(` \u26A0 wait idle timed out after ${h}ms (may still be animating)`),process.exit(1))}async function Tt(s){let{bridge:d,args:a}=s,l=2e4,f=a.indexOf("--max-ms");f>=0&&a[f+1]&&(l=Math.max(100,Number(a[f+1])));let{ready:i,elapsedMs:h,nodes:S}=await We(d,l);if(i){console.log(` ready in ${h}ms: ${S} nodes (flag)`);return}console.error(` \u26A0 wait ready timed out after ${h}ms \u2014 guest app did not emit sootsim:externalAppReady (nodes: ${S})`),process.exit(1)}async function Mt(s){let{bridge:d,args:a,positional:l,inspectUsage:f}=s,i=l[1];i||(console.error(f("wait selector","<testid> [--max-ms 5000]")),process.exit(1));let h=a.indexOf("--max-ms"),S=h>=0&&a[h+1]?Math.max(100,Number(a[h+1])):5e3,{found:I,node:T,elapsed:w}=await He(d,i,S);if(I&&T){let v=T.absolutePosition?`@(${Math.round(T.absolutePosition.x)},${Math.round(T.absolutePosition.y)})`:"",_=T.layout?`${Math.round(T.layout.width)}x${Math.round(T.layout.height)}`:"?x?";console.log(` found #${i} in ${w}ms ${_} ${v}`)}else console.error(` \u26A0 wait selector #${i} timed out after ${w??S}ms`),process.exit(1)}function Pt(s){return s==null?"\u2014":s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}K`:`${(s/1024/1024).toFixed(1)}M`}function Ot(s){return s==null?" \u2026":s<1e3?`${s}ms`.padStart(5):`${(s/1e3).toFixed(2)}s`.padStart(5)}function no(s){return s.error?"err":s.status==null?" \u2026 ":String(s.status)}function Nt(s){let d=new Date(s.startTs).toLocaleTimeString(),a=no(s).padEnd(3),l=s.method.padEnd(5),f=Pt(s.size).padStart(6),i=Ot(s.durationMs);console.log(` [${d}] ${a} ${l} ${f} ${i} ${s.displayUrl}`),s.error&&console.log(` error: ${s.error}`)}function ro(s){let d=[["id",s.id],["source",s.source],["kind",s.kind],["method",s.method],["status",s.error?`error: ${s.error}`:`${s.status??"\u2014"} ${s.statusText??""}`.trim()],["url",s.url],["started",new Date(s.startTs).toLocaleTimeString()],["duration",Ot(s.durationMs).trim()],["size",Pt(s.size)],["content-type",s.type??"\u2014"]];for(let[a,l]of d)console.log(` ${a.padEnd(13)} ${l}`)}var io={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},It="\x1B[0m",ao="\x1B[2m";function _t(s,d){let a=new Date(s.ts).toLocaleTimeString(),l=s.level.toUpperCase().padEnd(5),f=s.args.join(" ");if(d){let i=io[s.level];console.log(` ${ao}[${a}]${It} ${i}${l}${It} ${f}`)}else console.log(` [${a}] ${l} ${f}`);if(s.stack&&s.level==="error"){let i=s.stack.split(`
|
|
82
|
+
`).slice(0,5);for(let h of i)console.log(` ${h.trim()}`)}}var Q="__sootsimCliPerf",lo=120;async function Ft(s,d){let a=s.find((_,M)=>s[M-1]==="--id"),l=s.find((_,M)=>s[M-1]==="--text");if(a||l){let _=await d.send({type:"evaluate",code:Ce({id:a,text:l})});if(!_)throw new Error(a?`no node with id "${a}"`:`no node matching text "${l}"`);let{x:M,y:R,w:c,h:J}=_;return{x:M,y:R,w:c,h:J}}let f=s.find((_,M)=>s[M-1]==="--area");if(f){let _=f.split(",").map(U=>Number(U.trim()));if(_.length!==4||_.some(U=>!Number.isFinite(U)))throw new Error(`--area expects x,y,w,h (got "${f}")`);let[M,R,c,J]=_;return{x:M,y:R,w:c,h:J}}let i=_=>{let M=s.find((c,J)=>s[J-1]===_);if(M==null)return null;let R=Number(M);return Number.isFinite(R)?R:null},h=i("--x"),S=i("--y"),I=i("--w"),T=i("--h");if(h!=null||S!=null||I!=null||T!=null)return{x:h??0,y:S??0,w:I??1,h:T??1};let v=s.filter((_,M)=>M>0&&!_.startsWith("-")&&s[M-1]!=="--output"&&s[M-1]!=="--area"&&s[M-1]!=="--id"&&s[M-1]!=="--text"&&s[M-1]!=="--x"&&s[M-1]!=="--y"&&s[M-1]!=="--w"&&s[M-1]!=="--h").map(Number).filter(_=>Number.isFinite(_));if(v.length>=2){let[_,M,R=1,c=1]=v;return{x:_,y:M,w:R,h:c}}return null}function ke(s){let d={"<8":0,"8-12":0,"12-16":0,"16-20":0,"20-33":0,">33":0};for(let a of s)a<8?d["<8"]++:a<12?d["8-12"]++:a<16?d["12-16"]++:a<20?d["16-20"]++:a<33?d["20-33"]++:d[">33"]++;console.log(" histogram:");for(let[a,l]of Object.entries(d)){let f="\u2588".repeat(Math.ceil(l/s.length*40));console.log(` ${a.padEnd(6)} ${f} ${l}`)}}async function pe(s,d,a){let l=Date.now()+d,f=await se(s,d);for(;;){if(a(f))return{settled:!0,state:f};if(Date.now()>=l)return{settled:!1,state:f};await X(16),f=await se(s)}}async function Me(s){return s.send({type:"evaluate",code:`(async () => {
|
|
83
83
|
const kb = window.__sootsimKeyboard
|
|
84
84
|
const test = window.__sootsimTest
|
|
85
85
|
if (!kb) return { error: 'keyboard bridge not available' }
|
|
@@ -111,7 +111,7 @@ import{a as G}from"./chunk-MLCBIX7O.js";import{a as Ce,b as De}from"./chunk-WPS3
|
|
|
111
111
|
frame: runtimeSnapshot?.keyboard?.frame ?? null,
|
|
112
112
|
focusedRect: runtimeSnapshot?.focused?.rect ?? null,
|
|
113
113
|
}
|
|
114
|
-
})()`})}async function
|
|
114
|
+
})()`})}async function co(s,d=600){let a=Date.now()+d;for(;Date.now()<=a;){let l=await Me(s);if(l.visible)return l;await X(30)}return Me(s)}async function fe(s,d){let a=await Me(s);if(a.visible)return a;console.error(` ${d} requires the iOS keyboard to be visible. focus an input first with sootsim do tap-id/tap-text or sootsim do type-into.`),process.exit(1)}async function At(s,d,a){return d==="appearance"?s.send({type:"evaluate",code:`(async () => {
|
|
115
115
|
const requested = ${JSON.stringify(a??"toggle")}
|
|
116
116
|
const rootBg = (document.documentElement?.style?.background || '').toLowerCase()
|
|
117
117
|
const inferredCurrent = rootBg.includes('33') ? 'dark' : 'light'
|
|
@@ -125,28 +125,28 @@ import{a as G}from"./chunk-MLCBIX7O.js";import{a as Ce,b as De}from"./chunk-WPS3
|
|
|
125
125
|
? (window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ? 'dark' : 'light')
|
|
126
126
|
: next
|
|
127
127
|
return { ok: true, requested, value: next, applied }
|
|
128
|
-
})()`}):
|
|
128
|
+
})()`}):s.send({type:"evaluate",code:`(async () => {
|
|
129
129
|
window.dispatchEvent(new CustomEvent(${JSON.stringify(d==="lock"?"sootsim:toggleLock":"sootsim:shake")}))
|
|
130
130
|
return { ok: true, action: ${JSON.stringify(d)} }
|
|
131
|
-
})()`})}function
|
|
131
|
+
})()`})}function uo(s){let d={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(d[s])return d[s];let a=s.match(/^Digit([0-9])$/);if(a)return a[1];let l=s.match(/^Key([A-Z])$/);return l?l[1].toLowerCase():null}function mo(s){if(typeof s!="string")return null;let d=s.replace(/\s+/g," ").trim();return d?d.slice(0,80):null}function Rt(...s){for(let d of s){if(typeof d!="string")continue;let a=d.trim();if(a)return a}return null}async function j(s,d,a){le({source:s,step:d,summary:a})}function po(s,d,a){if(!a||a.hit===!1)return null;let l=Rt(a.responderTestID,a.testID);if(l)return{step:{tapOn:{id:l}},summary:`tap #${l}`};let f=mo(a.text);return f?{step:{tapOn:f},summary:`tap "${f}"`}:{step:{tapAtCoords:{x:s,y:d}},summary:`tap @${Math.round(s)},${Math.round(d)}`}}function Te(s,d,a){let l=Rt(d?.testID,d?.id);return l?{step:{tapOn:{id:l}},summary:`tap #${l}`}:a==="id"?{step:{tapOn:{id:s}},summary:`tap #${s}`}:{step:{tapOn:s},summary:`tap "${s}"`}}async function zs(s,d){let a=s[0]==="get"||s[0]==="do"||s[0]==="debug"||s[0]==="wait"?s[0]:null,l=a?s.slice(1):s,f=Fe(l,{port:d.port,commandTimeoutMs:d.timeoutMs,stripBooleanFlags:["--verbose","-v","--help","-h","--clear-state","--json","--all","--watch","-w","--strict","--no-wait","--dump","--failed","--slow","--tail","-f","--interactive-targets","--actions","--internal"],stripValueFlags:["--output","--nth","--index","--testid","--test-id","--text","--max-ms","--filter","--limit","--level","--threshold","--equals","--since"]}),i=f.positional,h=i[0],S=a==="get"||a==="do"||a==="debug"||a==="wait"?a:"inspect",I=typeof l[0]=="string"&&Ie.has(l[0]),T=I?l[0]:null,w=e=>I&&e===l[0]?`sootsim ${e}`:`sootsim ${S} ${e}`,v=(e,t)=>` usage: ${w(e)}${t?` ${t}`:""}`;if(!h||s.includes("--help")||s.includes("-h")){let e={bridgePort:7668,defaultShellUrl:Ne};if(S==="do"||S==="get"||S==="debug"||S==="wait"){let r=ge(S,e);r&&(console.log(`${r}
|
|
132
132
|
`),process.exit(0))}if(T==="shell"){let r=ye("shell",e);r&&(console.log(`${r}
|
|
133
|
-
`),process.exit(0))}let t=ye("inspect",e),
|
|
133
|
+
`),process.exit(0))}let t=ye("inspect",e),o=["do","get","debug","wait"].map(r=>ge(r,e)).filter(r=>r!=null).join(`
|
|
134
134
|
|
|
135
135
|
`);console.log(`${t??""}
|
|
136
136
|
|
|
137
|
-
${
|
|
138
|
-
`),process.exit(0)}let _=f.wsPort,M=f.simId,R=f.commandTimeoutMs;if(h==="list"&&l.some(e=>e==="--drivers"||e==="-D")){let{buildDriverListRows:e}=await import("./drivers-
|
|
139
|
-
`);let
|
|
137
|
+
${o}
|
|
138
|
+
`),process.exit(0)}let _=f.wsPort,M=f.simId,R=f.commandTimeoutMs;if(h==="list"&&l.some(e=>e==="--drivers"||e==="-D")){let{buildDriverListRows:e}=await import("./drivers-EAONIWG3.js"),t=e();console.log(` available drivers (${t.length}):
|
|
139
|
+
`);let o=Math.max(...t.map(n=>n.id.length),6),r=Math.max(...t.map(n=>n.kind.length),4);for(let n of t){let u=n.available?"\u2713":"\u2717",m=n.id.padEnd(o),y=n.kind.padEnd(r);console.log(` ${u} ${m} ${y} ${n.description}`),n.available&&n.detail?console.log(` ${n.detail}`):!n.available&&n.reason&&console.log(` unavailable: ${n.reason}`)}return}let c=Ae(f),J=M||"default",U=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","list","wait","sleep"]);function E(e){let t=e.displayUrl||e.url;return e.status!=null?`${e.method} ${t} -> ${e.status}${e.statusText?` ${e.statusText}`:""}`:e.error?`${e.method} ${t} -> ${e.error}`:`${e.method} ${t}`}async function L(e){let t=ut()?1200:350;try{let{settled:o,elapsed:r}=await oe({bridge:e,maxMs:t,pollMs:32,stablePolls:2});o||process.stderr.write(` \u26A0 auto-wait timed out after ${r??t}ms \u2014 next command may see mid-animation state. use \`sootsim do settle\` for a longer wait.
|
|
140
140
|
`)}catch{}}async function Y(){try{return await c.send({type:"evaluate",code:`(() => ({
|
|
141
141
|
console: window.__sootsimConsole?.count?.() || null,
|
|
142
142
|
requests: window.__sootsimTest?.getRequestCounts?.() || null,
|
|
143
|
-
}))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function W(e={}){let t=e.counts!==void 0?e.counts:await z(c,"getRequestCounts");if(!t||typeof t!="object")return;let
|
|
144
|
-
network: ${
|
|
143
|
+
}))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function W(e={}){let t=e.counts!==void 0?e.counts:await z(c,"getRequestCounts");if(!t||typeof t!="object")return;let o=Math.max(0,Number(t.failed)||0);if(o===0||!e.includeTail&&!$e("requests",J,String(o))||(console.log(`
|
|
144
|
+
network: ${o} failed request${o===1?"":"s"}`),console.log(` inspect: ${w("requests")} 5`),!e.includeTail))return;let r=await z(c,"getFailedRequests",5);if(!(!Array.isArray(r)||r.length===0)){console.log(`
|
|
145
145
|
recent failed requests:
|
|
146
|
-
`);for(let n of r){let u=new Date(n.timestamp).toLocaleTimeString();console.log(` [${u}] ${E(n)}`),n.responseBody?console.log(` ${n.responseBody}`):n.error&&console.log(` ${n.error}`)}}}async function
|
|
147
|
-
console: ${u.join(", ")}`),console.log(` inspect: ${
|
|
146
|
+
`);for(let n of r){let u=new Date(n.timestamp).toLocaleTimeString();console.log(` [${u}] ${E(n)}`),n.responseBody?console.log(` ${n.responseBody}`):n.error&&console.log(` ${n.error}`)}}}async function x(e={}){let t=e.counts!==void 0?e.counts:await c.send({type:"evaluate",code:"window.__sootsimConsole?.count?.() || { errors: 0, warnings: 0, total: 0 }"});if(!t||typeof t!="object")return;let o=t,r=Math.max(0,Number(o.errors)||0),n=Math.max(0,Number(o.warnings)||0);if(r===0&&n===0||!e.includeTail&&!$e("console",J,`${r}:${n}`))return;let u=[];if(r>0&&u.push(`${r} console error${r===1?"":"s"}`),n>0&&u.push(`${n} console warning${n===1?"":"s"}`),console.log(`
|
|
147
|
+
console: ${u.join(", ")}`),console.log(` inspect: ${w("errors")} 5`),n>0&&console.log(` inspect: ${w("warnings")} 5`),!e.includeTail||r===0)return;let m=await c.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors?.(5) || []"});if(!(!Array.isArray(m)||m.length===0)){console.log(`
|
|
148
148
|
recent console errors:
|
|
149
|
-
`);for(let y of m){let g=new Date(y.timestamp).toLocaleTimeString(),$=Array.isArray(y.args)?y.args.map(A=>typeof A=="object"?JSON.stringify(A):String(A)).join(" "):String(y);console.log(` [${g}] ${$}`)}}}let N=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function Z(e){let t=_e(),
|
|
149
|
+
`);for(let y of m){let g=new Date(y.timestamp).toLocaleTimeString(),$=Array.isArray(y.args)?y.args.map(A=>typeof A=="object"?JSON.stringify(A):String(A)).join(" "):String(y);console.log(` [${g}] ${$}`)}}}let N=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function Z(e){let t=_e(),o=null;try{o=await Oe(e,`(() => {
|
|
150
150
|
const tl = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.timeline
|
|
151
151
|
if (!tl || typeof tl.summary !== 'function') return null
|
|
152
152
|
const cursorKey = ${JSON.stringify(t)}
|
|
@@ -162,8 +162,8 @@ ${s}
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
return summary ? { summary, consoleSplit } : null
|
|
165
|
-
})()`)}catch{return}if(!
|
|
166
|
-
since last: ${n.join(" \xB7 ")} \u2014 sootsim what-happened`),
|
|
165
|
+
})()`)}catch{return}if(!o||!o.summary||!o.summary.total)return;let r=o.summary.byKind??{},n=[],u=new Set;for(let m of N){let y=r[m];if(y)if(u.add(m),m==="console"&&o.consoleSplit){let{error:g,warn:$}=o.consoleSplit;g>0&&n.push(`${g} error${g===1?"":"s"}`),$>0&&n.push(`${$} warning${$===1?"":"s"}`)}else n.push(`${y} ${m}${y===1?"":"s"}`)}for(let[m,y]of Object.entries(r))!u.has(m)&&y&&n.push(`${y} ${m}${y===1?"":"s"}`);if(n.length!==0&&(console.log(`
|
|
166
|
+
since last: ${n.join(" \xB7 ")} \u2014 sootsim what-happened`),o.summary.lastAt))try{await he(e,"SootSim.bridges.timeline.cursorAdvance",t,o.summary.lastAt)}catch{}}let F=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"]),V=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"]),te=(s.includes("--verbose")||s.includes("-v"))&&!s.includes("--json");S==="do"&&h==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),F.has(h)&&await Pe(c),V.has(h)&&await ce(c,{verbose:te});try{switch(h){case"list":{await ft({bridge:c,simId:M,args:l});break}case"tree":{await wt({bridge:c,args:l,positional:i});break}case"a11y":{let e=i[1]?Number(i[1]):5,t=await c.send({type:"evaluate",code:`(async () => {
|
|
167
167
|
const t = window.__sootsimTest
|
|
168
168
|
if (!t) return []
|
|
169
169
|
const all = await t.queryAll({ pruneHidden: true })
|
|
@@ -191,8 +191,8 @@ ${s}
|
|
|
191
191
|
position: n.absolutePosition ? { x: Math.round(n.absolutePosition.x), y: Math.round(n.absolutePosition.y) } : null,
|
|
192
192
|
size: n.layout ? { w: Math.round(n.layout.width), h: Math.round(n.layout.height) } : null,
|
|
193
193
|
}))
|
|
194
|
-
})()`});if(!Array.isArray(t)||t.length===0){console.log(" no accessible nodes found");break}if(
|
|
195
|
-
`);for(let
|
|
194
|
+
})()`});if(!Array.isArray(t)||t.length===0){console.log(" no accessible nodes found");break}if(s.includes("--json"))console.log(JSON.stringify(t,null,2));else{console.log(` accessibility tree (${t.length} nodes):
|
|
195
|
+
`);for(let o of t){let r=[];if(r.push(`[${o.role}]`),o.label){let n=o.label.length>50?o.label.slice(0,47)+"...":o.label;r.push(`"${n}"`)}if(o.hint&&r.push(`(hint: "${o.hint}")`),o.testID&&r.push(`#${o.testID}`),o.state){let n=[];o.state.disabled&&n.push("disabled"),o.state.selected&&n.push("selected"),o.state.checked===!0&&n.push("checked"),o.state.checked==="mixed"&&n.push("mixed"),o.state.busy&&n.push("busy"),o.state.expanded===!0&&n.push("expanded"),o.state.expanded===!1&&n.push("collapsed"),n.length&&r.push(`{${n.join(", ")}}`)}o.position&&r.push(`@(${o.position.x},${o.position.y})`),o.size&&r.push(`${o.size.w}x${o.size.h}`),console.log(" "+r.join(" "))}}break}case"find":{await mt({bridge:c,args:s,effectiveArgs:l,positional:i,inspectUsage:v});break}case"count":{await ct(c,{args:l});break}case"keyboard":{await pt(c,{json:s.includes("--json")});break}case"screens":{await yt(c,{json:s.includes("--json")});break}case"memory":{await gt(c,{args:l});break}case"wait":{await $t({wsPort:_,commandTimeoutMs:R,simId:M,positional:i});break}case"sleep":{await bt({positional:i,inspectUsage:v});break}case"settle":{await ht({bridge:c,args:s,positional:i});break}case"ready":{await Tt({bridge:c,args:s});break}case"idle":{await kt({bridge:c,args:s,positional:i});break}case"selector":{await Mt({bridge:c,args:s,positional:i,inspectUsage:v});break}case"event":{await vt({bridge:c,args:s,positional:i,inspectUsage:v});break}case"layout":{let e=i[1];e||(console.error(v("layout","<id>")),process.exit(1));let t=await c.send({type:"evaluate",code:`(async () => await window.__sootsimTest.getLayout(${JSON.stringify(e)}))()`});console.log(JSON.stringify(t,null,2));break}case"capture":case"screenshot":{let t=s.find((y,g)=>s[g-1]==="--output")||"/tmp/sootsim-inspect.png",o=await Ft(s,c),r={type:"screenshot"};o&&(r.crop=o);let u=(await c.send(r)).replace(/^data:image\/png;base64,/,"");o&&console.log(` area: x=${o.x} y=${o.y} w=${o.w} h=${o.h}`),(await import("fs")).writeFileSync(t,Buffer.from(u,"base64")),console.log(` saved: ${t}`);break}case"sample-color":{let e=await Ft(s,c);e||(console.error(v("sample-color","<x> <y> [w] [h] | --id <testID> | --text <text>")),console.error(" samples an averaged color from the canvas. coords are logical sootsim units."),process.exit(1));let t=await c.send({type:"evaluate",code:De(e)});if(s.includes("--json"))console.log(JSON.stringify(t,null,2));else{let{r:o,g:r,b:n,a:u,hex:m,samples:y}=t,g=e.w===1&&e.h===1?`@(${e.x},${e.y})`:`@(${e.x},${e.y}) ${e.w}x${e.h}`;console.log(` ${m} rgba(${o}, ${r}, ${n}, ${u}) ${g} ${y} samples`)}break}case"node":{let e=i[1];e||(console.error(v("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let t=await c.send({type:"evaluate",code:`(async () => {
|
|
196
196
|
const t = window.__sootsimTest
|
|
197
197
|
const q = ${JSON.stringify(e)}
|
|
198
198
|
let node = null
|
|
@@ -248,17 +248,17 @@ ${s}
|
|
|
248
248
|
transform,
|
|
249
249
|
parentChain,
|
|
250
250
|
}
|
|
251
|
-
})()`});console.log(JSON.stringify(t,null,2));break}case"tap":{let e=Number(i[1]),t=Number(i[2]),
|
|
251
|
+
})()`});console.log(JSON.stringify(t,null,2));break}case"tap":{let e=Number(i[1]),t=Number(i[2]),o=ie(s);if(o){let u=await ue(c,o);u||(console.error(` not found: ${o.value}`),o.mode==="testid"&&G("wait-selector-for-missing-testid",o.value),process.exit(1)),e=u.x,t=u.y}(!Number.isFinite(e)||!Number.isFinite(t))&&(console.error(v("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let r=await c.send({type:"tap",x:e,y:t}),n=po(e,t,r);n&&await j("inspect tap",n.step,n.summary),console.log(JSON.stringify(r,null,2));break}case"drag":case"swipe":{let e=Number(i[1]),t=Number(i[2]),o=Number(i[3]),r=Number(i[4]),n=h==="swipe"?10:12,u=h==="swipe"?8:16,m=i[5]?Number(i[5]):n,y=i[6]?Number(i[6]):u;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(o)||!Number.isFinite(r)||!Number.isFinite(m)||!Number.isFinite(y))&&(console.error(v(h,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let g=await c.send({type:"evaluate",code:`(async () => {
|
|
252
252
|
const interact = window.__sootsimInteract
|
|
253
253
|
if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
|
|
254
|
-
const value = await interact.drag(${e}, ${t}, ${
|
|
254
|
+
const value = await interact.drag(${e}, ${t}, ${o}, ${r}, ${Math.max(1,Math.round(m))}, ${Math.max(0,Math.round(y))})
|
|
255
255
|
return { ok: !!value, value }
|
|
256
|
-
})()`});if(g?.ok){let $=Math.max(1,Math.round(Math.max(1,m)*Math.max(0,y)));await j(`inspect ${h}`,{swipe:{start:`${e}, ${t}`,end:`${
|
|
256
|
+
})()`});if(g?.ok){let $=Math.max(1,Math.round(Math.max(1,m)*Math.max(0,y)));await j(`inspect ${h}`,{swipe:{start:`${e}, ${t}`,end:`${o}, ${r}`,duration:$}},`${h} ${e},${t} -> ${o},${r}`)}console.log(JSON.stringify(g,null,2));break}case"pinch":{let e=Number(i[1]),t=Number(i[2]),o=Number(i[3]),r=Number(i[4]),n=Number(i[5]),u=Number(i[6]),m=Number(i[7]),y=Number(i[8]),g=i[9]?Number(i[9]):12,$=i[10]?Number(i[10]):16;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(o)||!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(u)||!Number.isFinite(m)||!Number.isFinite(y)||!Number.isFinite(g)||!Number.isFinite($))&&(console.error(v("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let A=await c.send({type:"evaluate",code:`(async () => {
|
|
257
257
|
const interact = window.__sootsimInteract
|
|
258
258
|
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
259
|
-
const value = await interact.pinch(${e}, ${t}, ${
|
|
259
|
+
const value = await interact.pinch(${e}, ${t}, ${o}, ${r}, ${n}, ${u}, ${m}, ${y}, ${Math.max(1,Math.round(g))}, ${Math.max(0,Math.round($))})
|
|
260
260
|
return { ok: !!value, value }
|
|
261
|
-
})()`});A?.ok&&await j("inspect pinch",{pinch:{from:[e,t,
|
|
261
|
+
})()`});A?.ok&&await j("inspect pinch",{pinch:{from:[e,t,o,r],to:[n,u,m,y],steps:Math.max(1,Math.round(g)),stepMs:Math.max(0,Math.round($))}},`pinch (${e},${t}) (${o},${r}) -> (${n},${u}) (${m},${y})`),console.log(JSON.stringify(A,null,2));break}case"tap-text":{let e=i[1];e||(console.error(v("tap-text","<text>")),process.exit(1));let t=q=>{let P=s.indexOf(q);return P>=0&&P+1<s.length?s[P+1]:null},o=q=>s.includes(q),r=t("--nth")??t("--index"),n=r!==null?Number(r):null;n!==null&&!Number.isFinite(n)&&(console.error(` --nth/--index requires an integer, got: ${r}`),process.exit(1));let u=t("--within"),m=t("--role"),y=o("--exact"),g=o("--first"),$=t("--min-y"),A=t("--max-y"),B=t("--min-x"),H=t("--max-x");for(let[q,P]of[["--min-y",$],["--max-y",A],["--min-x",B],["--max-x",H]])P!==null&&!Number.isFinite(Number(P))&&(console.error(` ${q} requires a number, got: ${P}`),process.exit(1));let K=s.indexOf("--near"),k=null;if(K>=0){let q=Number(s[K+1]),P=Number(s[K+2]);(!Number.isFinite(q)||!Number.isFinite(P))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),k={x:q,y:P}}let b=JSON.stringify({query:e,exact:y,role:m,within:u,minX:B!==null?Number(B):null,maxX:H!==null?Number(H):null,minY:$!==null?Number($):null,maxY:A!==null?Number(A):null,near:k,nth:n,first:g}),p=await c.send({type:"evaluate",code:`(async () => {
|
|
262
262
|
const t = window.__sootsimTest
|
|
263
263
|
if (!t) return { error: 'bridge-not-ready' }
|
|
264
264
|
const F = ${b}
|
|
@@ -372,7 +372,7 @@ ${s}
|
|
|
372
372
|
total,
|
|
373
373
|
idx,
|
|
374
374
|
}
|
|
375
|
-
})()`});if(p?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),p?.ambiguous){let q=p.candidates;console.error(` ambiguous: ${p.total} matches for "${e}"`);for(let P of q){let ae=P.abs?`@(${Math.round(P.abs.x)},${Math.round(P.abs.y)})`:"",
|
|
375
|
+
})()`});if(p?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),p?.ambiguous){let q=p.candidates;console.error(` ambiguous: ${p.total} matches for "${e}"`);for(let P of q){let ae=P.abs?`@(${Math.round(P.abs.x)},${Math.round(P.abs.y)})`:"",Et=P.layout?` ${P.layout.width}x${P.layout.height}`:"",Ct=P.testID?` #${P.testID}`:"",Dt=P.text?` "${P.text}"`:"",Bt=P.ancestorTestIDs.length>0?` within ${P.ancestorTestIDs.slice(0,3).map(jt=>`#${jt}`).join(" > ")}`:"";console.error(` [${P.idx}] <${P.type}>${Dt}${Ct} ${ae}${Et}${Bt}`)}p.total>q.length&&console.error(` ... and ${p.total-q.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)}p?.nthOutOfRange&&(console.error(` not found: nth ${p.nth} of ${p.total} match${p.total===1?"":"es"} for "${e}"`),process.exit(1)),(!p||typeof p.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1));let O=await c.send({type:"tap",x:p.cx,y:p.cy});if(O?.hit!==!1&&O?.ok!==!1){let q=Te(e,{id:p.target?.id??null,testID:p.target?.testID??null,type:p.target?.type??null,cx:p.cx,cy:p.cy},"text");await j("inspect tap-text",q.step,q.summary)}console.log(JSON.stringify({matched:p.match,tapped:{nodeId:p.target?.nodeId??null,id:p.target?.id??null,testID:p.target?.testID??null,type:p.target?.type??null,cx:p.cx,cy:p.cy},...p.strategy&&p.strategy!=="matched-node"?{strategy:p.strategy}:{},...p.total>1||n!==null?{nth:{index:p.idx,total:p.total}}:{},result:O},null,2));break}case"tap-best":{let e=i[1];e||(console.error(v("tap-best","<query>")),process.exit(1));let t=JSON.stringify(e),o=await c.send({type:"evaluate",code:`(async () => {
|
|
376
376
|
const t = window.__sootsimTest
|
|
377
377
|
if (!t) return { error: 'bridge-not-ready' }
|
|
378
378
|
// try testID first \u2014 strongest signal of "this is the
|
|
@@ -413,7 +413,7 @@ ${s}
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
return { strategy: 'none' }
|
|
416
|
-
})()`});"error"in
|
|
416
|
+
})()`});"error"in o&&(console.error(` ${o.error}`),process.exit(1)),o.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${e}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1));let r=o.node,n=r.absolutePosition.x+r.layout.width/2,u=r.absolutePosition.y+r.layout.height/2,m=await c.send({type:"tap",x:n,y:u});if(m?.hit!==!1&&m?.ok!==!1){let y=Te(e,{id:r.id,testID:r.testID,type:r.type,cx:n,cy:u},o.strategy==="testid"?"id":"text");await j("inspect tap-best",y.step,y.summary)}console.log(JSON.stringify({matched:{strategy:o.strategy,nodeId:r.nodeId,id:r.id,testID:r.testID,type:r.type,text:r.text},tapped:{cx:n,cy:u},result:m},null,2));break}case"tap-id":{let e=i[1];e||(console.error(v("tap-id","<id>")),process.exit(1));let t=JSON.stringify(e),o=await c.send({type:"evaluate",code:`(async () => {
|
|
417
417
|
const t = window.__sootsimTest
|
|
418
418
|
if (!t) return null
|
|
419
419
|
const n = (await t.findByTestId(${t})) || (await t.findById(${t}))
|
|
@@ -448,10 +448,10 @@ ${s}
|
|
|
448
448
|
},
|
|
449
449
|
strategy: (resolved && resolved.strategy) || 'matched-node',
|
|
450
450
|
}
|
|
451
|
-
})()`});(!
|
|
451
|
+
})()`});(!o||typeof o.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1));let r=await c.send({type:"tap",x:o.cx,y:o.cy});if(r?.hit!==!1&&r?.ok!==!1){let n=Te(e,{id:o.target?.id??null,testID:o.target?.testID??null,type:o.target?.type??null,cx:o.cx,cy:o.cy},"id");await j("inspect tap-id",n.step,n.summary)}console.log(JSON.stringify({matched:o.match,tapped:{nodeId:o.target?.nodeId??null,id:o.target?.id??null,testID:o.target?.testID??null,type:o.target?.type??null,cx:o.cx,cy:o.cy},...o.strategy&&o.strategy!=="matched-node"?{strategy:o.strategy}:{},result:r},null,2));break}case"type-into":{let e=i[1],t=i.slice(2).join(" ");(!e||!t)&&(console.error(v("type-into","<id> <text>")),process.exit(1));let o=JSON.stringify(e),r=await c.send({type:"evaluate",code:`(async () => {
|
|
452
452
|
const t = window.__sootsimTest
|
|
453
453
|
if (!t) return null
|
|
454
|
-
const n = await (t.findByTestId(${
|
|
454
|
+
const n = await (t.findByTestId(${o}) || t.findById(${o}))
|
|
455
455
|
if (!n || !n.absolutePosition || !n.layout) return null
|
|
456
456
|
return {
|
|
457
457
|
cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
|
|
@@ -460,7 +460,7 @@ ${s}
|
|
|
460
460
|
isTextInput: !!n.isTextInput,
|
|
461
461
|
placeholder: n.placeholder || null,
|
|
462
462
|
}
|
|
463
|
-
})()`});(!r||typeof r.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1)),r.isTextInput||console.error(` warning: ${e} is not a text input (isTextInput: false)`);let n=await c.send({type:"tap",x:r.cx,y:r.cy}),u=await
|
|
463
|
+
})()`});(!r||typeof r.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1)),r.isTextInput||console.error(` warning: ${e} is not a text input (isTextInput: false)`);let n=await c.send({type:"tap",x:r.cx,y:r.cy}),u=await co(c);u.visible||(console.error(` keyboard did not open after tapping ${e}`),process.exit(1));let m=u.focusedInput;m&&(m.testID===e||m.id===e||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(e)} but focus is on ${JSON.stringify(m.testID??m.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await c.send({type:"keyboard",action:"type",text:t}),await j("inspect type-into",{tapOn:{id:e},inputText:t},`type-into #${e} ${JSON.stringify(t)}`),console.log(JSON.stringify({target:e,isTextInput:r.isTextInput,keyboardOpened:u.visible??n?.keyboardOpened??!1,focusedInput:u.focusedInput??null,typed:t},null,2));break}case"type":{let e=i.slice(1).join(" ");e||(console.error(v("type","<text>")),process.exit(1)),await fe(c,"type"),await c.send({type:"keyboard",action:"type",text:e}),await j("inspect type",{inputText:e},`type ${JSON.stringify(e)}`),console.log(` typed: ${JSON.stringify(e)}`);break}case"key":{let e=i[1];e||(console.error(v("key","<name>")),process.exit(1)),await fe(c,"key"),await c.send({type:"keyboard",action:"press",text:e}),await j("inspect key",{pressKey:e},`key ${e}`),console.log(` pressed: ${e}`);break}case"key-sequence":{let e=i.slice(1);e.length===0&&(console.error(v("key-sequence","<key> [<key> ...]")),process.exit(1)),await fe(c,"key-sequence");for(let t of e)await c.send({type:"keyboard",action:"press",text:t});await j("inspect key-sequence",{pressKey:e.join(" ")},`key-sequence ${e.join(" ")}`),console.log(` pressed: ${e.join(", ")}`);break}case"keycode":{let e=i.slice(1);e.length===0&&(console.error(v("keycode","<code> [<code> ...]")),process.exit(1));let t=e.map(r=>({code:r,key:uo(r)})),o=t.filter(r=>!r.key);o.length>0&&(console.error(` unsupported keycode(s): ${o.map(r=>r.code).join(", ")}`),process.exit(1)),await fe(c,"keycode");for(let r of t)await c.send({type:"keyboard",action:"press",text:r.key});await j("inspect keycode",{pressKey:t.map(r=>r.key).join(" ")},`keycode ${e.join(" ")}`),console.log(` pressed: ${e.join(", ")}`);break}case"dispatch":{let e=i[1];e||(console.error(v("dispatch","<char>")),process.exit(1)),await c.send({type:"keyboard",action:"dispatchKey",text:e}),await j("inspect dispatch",{dispatchKey:e},`dispatch ${JSON.stringify(e)}`),console.log(` dispatched: ${e}`);break}case"dismiss":{await c.send({type:"keyboard",action:"dismiss"}),await j("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let e=Number(i[1]),t=Number(i[2]),o=ie(s);if(o){let m=await ue(c,o);m||(console.error(` not found: ${o.value}`),o.mode==="testid"&&G("wait-selector-for-missing-testid",o.value),process.exit(1)),e=m.x,t=m.y}let r=i[3]?Number(i[3]):80;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&(console.error(v("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let n=Math.max(0,Math.round(r)),u=await c.send({type:"evaluate",code:`(async () => {
|
|
464
464
|
const interact = window.__sootsimInteract
|
|
465
465
|
if (interact?.doubleTap) {
|
|
466
466
|
return {
|
|
@@ -483,18 +483,18 @@ ${s}
|
|
|
483
483
|
first,
|
|
484
484
|
second,
|
|
485
485
|
}
|
|
486
|
-
})()`});u?.ok&&await j("inspect double-tap",{doubleTapAtCoords:{x:e,y:t,gapMs:n}},`double-tap @${e},${t}`),console.log(JSON.stringify(u,null,2));break}case"long-press":{let e=Number(i[1]),t=Number(i[2]),
|
|
486
|
+
})()`});u?.ok&&await j("inspect double-tap",{doubleTapAtCoords:{x:e,y:t,gapMs:n}},`double-tap @${e},${t}`),console.log(JSON.stringify(u,null,2));break}case"long-press":{let e=Number(i[1]),t=Number(i[2]),o=ie(s);if(o){let u=await ue(c,o);u||(console.error(` not found: ${o.value}`),o.mode==="testid"&&G("wait-selector-for-missing-testid",o.value),process.exit(1)),e=u.x,t=u.y}let r=i[3]?Number(i[3]):600;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(r))&&(console.error(v("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let n=await c.send({type:"evaluate",code:`(async () => {
|
|
487
487
|
const interact = window.__sootsimInteract
|
|
488
488
|
if (!interact?.longPress) return { ok: false, reason: 'no interact.longPress' }
|
|
489
489
|
const value = await interact.longPress(${e}, ${t}, ${Math.max(0,Math.round(r))})
|
|
490
490
|
return { ok: !!value, value }
|
|
491
|
-
})()`});n?.ok&&await j("inspect long-press",{tapAtCoords:{x:e,y:t}},`long-press @${e},${t}`),console.log(JSON.stringify(n,null,2));break}case"touch":{let e=i[1],t=Number(i[2]),
|
|
491
|
+
})()`});n?.ok&&await j("inspect long-press",{tapAtCoords:{x:e,y:t}},`long-press @${e},${t}`),console.log(JSON.stringify(n,null,2));break}case"touch":{let e=i[1],t=Number(i[2]),o=Number(i[3]),r=i[4]?Number(i[4]):999,n=e==="down"?"touchDown":e==="move"?"touchMove":e==="up"?"touchUp":e==="cancel"?"touchCancel":null;n||(console.error(v("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),e!=="cancel"&&(!Number.isFinite(t)||!Number.isFinite(o))&&(console.error(v("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let u=e==="down"?"tap":e==="move"?"move":null,m=u&&Number.isFinite(t)&&Number.isFinite(o)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${u}', x: ${t}, y: ${o} } }));`:"",y=await c.send({type:"evaluate",code:`(async () => {
|
|
492
492
|
${m}
|
|
493
493
|
const interact = window.__sootsimInteract
|
|
494
494
|
if (!interact?.${n}) return { ok: false, reason: 'no interact.${n}' }
|
|
495
|
-
const value = ${e==="cancel"?`await interact.${n}(${Math.max(1,Math.round(r))})`:`await interact.${n}(${t}, ${
|
|
495
|
+
const value = ${e==="cancel"?`await interact.${n}(${Math.max(1,Math.round(r))})`:`await interact.${n}(${t}, ${o}, ${Math.max(1,Math.round(r))})`}
|
|
496
496
|
return { ok: !!value, value }
|
|
497
|
-
})()`});y?.ok&&e!=="cancel"&&await j("inspect touch",{tapAtCoords:{x:t,y:
|
|
497
|
+
})()`});y?.ok&&e!=="cancel"&&await j("inspect touch",{tapAtCoords:{x:t,y:o}},`touch ${e} @${t},${o}`),console.log(JSON.stringify(y,null,2));break}case"gesture":{let e=i[1],t=i[2]?Number(i[2]):220;(!e||!Number.isFinite(t))&&(console.error(v("gesture","<preset> [durationMs]")),process.exit(1));let o=await c.send({type:"evaluate",code:`(async () => {
|
|
498
498
|
const spec = globalThis.__sootsimDeviceSpec || {}
|
|
499
499
|
return {
|
|
500
500
|
width: spec.width || window.innerWidth || 393,
|
|
@@ -502,12 +502,12 @@ ${s}
|
|
|
502
502
|
statusBarHeight: spec.statusBarHeight || 0,
|
|
503
503
|
homeIndicatorHeight: spec.homeIndicatorHeight || 0,
|
|
504
504
|
}
|
|
505
|
-
})()`}),r=Number(
|
|
505
|
+
})()`}),r=Number(o?.width)||393,n=Number(o?.height)||852,u=Number(o?.statusBarHeight)||0,m=Number(o?.homeIndicatorHeight)||0,y=Math.round(r/2),g=Math.round(n/2),$=Math.max(24,u+18),A=Math.max(24,m+18),B=18,H=Math.min(220,Math.round(n*.24)),K=Math.min(180,Math.round(r*.32)),k=y,b=g,p=y,O=g;switch(e){case"scroll-up":b=g+Math.round(H/2),O=g-Math.round(H/2);break;case"scroll-down":b=g-Math.round(H/2),O=g+Math.round(H/2);break;case"scroll-left":k=y+Math.round(K/2),p=y-Math.round(K/2);break;case"scroll-right":k=y-Math.round(K/2),p=y+Math.round(K/2);break;case"swipe-from-left-edge":k=B,b=g,p=Math.min(r-B,B+K);break;case"swipe-from-right-edge":k=r-B,b=g,p=Math.max(B,r-B-K);break;case"swipe-from-top-edge":k=y,b=$,O=Math.min(n-A,$+H);break;case"swipe-from-bottom-edge":k=y,b=n-A,O=Math.max($,n-A-H);break;default:console.error(` unknown gesture preset: ${e}`),process.exit(1)}let q=Math.max(8,Math.round(t/16)),P=Math.max(1,Math.round(t/q)),ae=await c.send({type:"evaluate",code:`(async () => {
|
|
506
506
|
const interact = window.__sootsimInteract
|
|
507
507
|
if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
|
|
508
508
|
const value = await interact.drag(${k}, ${b}, ${p}, ${O}, ${q}, ${P})
|
|
509
509
|
return { ok: !!value, value }
|
|
510
|
-
})()`});ae?.ok&&await j("inspect gesture",{swipe:{start:`${k}, ${b}`,end:`${p}, ${O}`,duration:Math.max(1,Math.round(t))}},`gesture ${e}`),console.log(JSON.stringify({preset:e,from:{x:k,y:b},to:{x:p,y:O},result:ae},null,2));break}case"scroll":{let e=ie(
|
|
510
|
+
})()`});ae?.ok&&await j("inspect gesture",{swipe:{start:`${k}, ${b}`,end:`${p}, ${O}`,duration:Math.max(1,Math.round(t))}},`gesture ${e}`),console.log(JSON.stringify({preset:e,from:{x:k,y:b},to:{x:p,y:O},result:ae},null,2));break}case"scroll":{let e=ie(s),t=e?.mode==="testid"?e.value:i[1],o=Number(i[e?1:2]),r=Number(i[e?2:3]);(!t||!Number.isFinite(o)||!Number.isFinite(r))&&(console.error(v("scroll","<id> <dx> <dy> | --testid <id> <dx> <dy>")),process.exit(1));let n=await c.send({type:"evaluate",code:`(async () => {
|
|
511
511
|
const t = window.__sootsimTest
|
|
512
512
|
if (!t) return null
|
|
513
513
|
const n = await t.findByTestId(${JSON.stringify(t)})
|
|
@@ -517,11 +517,11 @@ ${s}
|
|
|
517
517
|
cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
|
|
518
518
|
cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
|
|
519
519
|
}
|
|
520
|
-
})()`}),u=await z(c,"scrollTo",t,
|
|
520
|
+
})()`}),u=await z(c,"scrollTo",t,o,r,!1);u?.ok&&await j("inspect scroll",{scrollTo:{id:t,x:o,y:r}},`scroll ${t} -> ${o},${r}`),console.log(JSON.stringify({...u,...n?{at:{x:n.cx,y:n.cy}}:{}},null,2));break}case"state":{let e=i[1];if(a==="get"&&!e){let o=await z(c,"getRuntimeState"),r=await c.send({type:"evaluate",code:`({
|
|
521
521
|
errors: window.__sootsimConsole?.getErrors?.()?.length ?? 0,
|
|
522
522
|
warnings: window.__sootsimConsole?.getWarnings?.()?.length ?? 0,
|
|
523
|
-
})`});
|
|
524
|
-
${
|
|
523
|
+
})`});o&&typeof o=="object"&&o.diagnostics&&(o.diagnostics.errors=r?.errors??0,o.diagnostics.warnings=r?.warnings??0),console.log(JSON.stringify(o,null,2));break}if(!e||e==="--help"||e==="-h"){console.log(`
|
|
524
|
+
${w("state")} \u2014 dump raw runtime state
|
|
525
525
|
|
|
526
526
|
subcommands:
|
|
527
527
|
shell dump shell transition/layout state
|
|
@@ -535,14 +535,14 @@ ${s}
|
|
|
535
535
|
gesture <x> <y> dump gesture routing/debug info at coordinates
|
|
536
536
|
|
|
537
537
|
examples:
|
|
538
|
-
${
|
|
539
|
-
${
|
|
540
|
-
${
|
|
541
|
-
${
|
|
542
|
-
${
|
|
543
|
-
${
|
|
544
|
-
${
|
|
545
|
-
${
|
|
538
|
+
${w("state")} shell
|
|
539
|
+
${w("state")} worker
|
|
540
|
+
${w("state")} keyboard
|
|
541
|
+
${w("state")} ownership
|
|
542
|
+
${w("state")} node photos
|
|
543
|
+
${w("state")} scroll feed
|
|
544
|
+
${w("state")} scroll-hit 360 420
|
|
545
|
+
${w("state")} hit 200 720
|
|
546
546
|
`);break}let t;switch(e){case"shell":t=await se(c,500);break;case"worker":t=await he(c,"__sootsimRenderHost.queryStats");break;case"ownership":t=await c.send({type:"evaluate",code:`(() => {
|
|
547
547
|
const h = window.__sootsimRenderHost
|
|
548
548
|
if (!h || typeof h.getOwnershipSnapshot !== 'function') {
|
|
@@ -574,8 +574,8 @@ ${s}
|
|
|
574
574
|
text: focused.text || null,
|
|
575
575
|
} : null,
|
|
576
576
|
}
|
|
577
|
-
})()`});break;case"node":{let
|
|
578
|
-
${
|
|
577
|
+
})()`});break;case"node":{let o=i[2];o||(console.error(` usage: ${w("state")} node <id>`),process.exit(1)),t=await z(c,"findByTestId",o)||await z(c,"findById",o);break}case"scroll":{let o=i[2];o||(console.error(` usage: ${w("state")} scroll <id>`),process.exit(1)),t=await z(c,"getScrollState",o);break}case"scroll-hit":{let o=Number(i[2]),r=Number(i[3]);(!Number.isFinite(o)||!Number.isFinite(r))&&(console.error(` usage: ${w("state")} scroll-hit <x> <y>`),process.exit(1)),t=await z(c,"getScrollStateAt",o,r);break}case"hit":{let o=Number(i[2]),r=Number(i[3]);(!Number.isFinite(o)||!Number.isFinite(r))&&(console.error(` usage: ${w("state")} hit <x> <y>`),process.exit(1)),t=await z(c,"debugHitAt",o,r);break}case"gesture":{let o=Number(i[2]),r=Number(i[3]);(!Number.isFinite(o)||!Number.isFinite(r))&&(console.error(` usage: ${w("state")} gesture <x> <y>`),process.exit(1)),t=await z(c,"debugGestureAt",o,r);break}default:console.error(` unknown state subcommand: ${e}`),process.exit(1)}console.log(JSON.stringify(t,null,2));break}case"shell":{let e=i[1];if(!e||e==="--help"||e==="-h"){console.log(`
|
|
578
|
+
${w("shell")} \u2014 run built-in shell commands
|
|
579
579
|
|
|
580
580
|
subcommands:
|
|
581
581
|
launch <appId> [waitMs] [--clear-state]
|
|
@@ -590,15 +590,15 @@ ${s}
|
|
|
590
590
|
shake trigger the simulator shake gesture
|
|
591
591
|
|
|
592
592
|
examples:
|
|
593
|
-
${
|
|
594
|
-
${
|
|
595
|
-
${
|
|
596
|
-
${
|
|
597
|
-
${
|
|
598
|
-
${
|
|
599
|
-
${
|
|
600
|
-
${
|
|
601
|
-
`);break}let t=e==="launch"||e==="open-card"||e==="home"||e==="switcher",
|
|
593
|
+
${w("shell")} launch photos
|
|
594
|
+
${w("shell")} launch rn --clear-state
|
|
595
|
+
${w("shell")} launch photos 1500
|
|
596
|
+
${w("shell")} home 500
|
|
597
|
+
${w("shell")} switcher 800
|
|
598
|
+
${w("shell")} open-card clock 800
|
|
599
|
+
${w("shell")} appearance dark
|
|
600
|
+
${w("shell")} lock
|
|
601
|
+
`);break}let t=e==="launch"||e==="open-card"||e==="home"||e==="switcher",o=e==="launch"||e==="open-card"?i[3]:i[2],r=o?Number(o):350;t&&(!Number.isFinite(r)||r<0)&&(console.error(v("shell",e==="launch"||e==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let n=!1,u=!1,m=null,y=s.includes("--clear-state");if(e==="launch"){let g=i[2];g||(console.error(v("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),y&&await c.send({type:"evaluate",code:Re}),n=!!await ne(c,"launchApp",r,g),{settled:u,state:m}=await pe(c,Math.round(r),$=>!!$&&$.state==="app"&&$.activeApp===g&&$.showSwitcher===!1&&$.switcherPhase==="idle"&&typeof $.launchProgress=="number"&&$.launchProgress>=.98),n&&await j("inspect shell launch",y?{launchApp:{clearState:!0}}:{launchApp:{}},y?"launch app (clear state)":"launch app")}else if(e==="home")n=!!await ne(c,"goHome",r),{settled:u,state:m}=await pe(c,Math.round(r),g=>!!g&&g.state==="home"&&g.activeApp==null&&g.showSwitcher===!1&&g.switcherPhase==="idle"&&typeof g.launchProgress=="number"&&g.launchProgress>=.98);else if(e==="switcher")n=!!await ne(c,"openSwitcher",r),{settled:u,state:m}=await pe(c,Math.round(r),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),u&&(await X(lo),m=await se(c));else if(e==="open-card"){let g=i[2];g||(console.error(v("shell","open-card <appId> [settleMs]")),process.exit(1)),n=!!await ne(c,"openSwitcherCard",r,g),{settled:u,state:m}=await pe(c,Math.round(r),$=>!!$&&$.state==="app"&&$.activeApp===g&&$.showSwitcher===!1&&$.switcherPhase==="idle"&&typeof $.zoomLevel=="number"&&$.zoomLevel>=.98&&typeof $.horizontalZoom=="number"&&$.horizontalZoom>=.98),n&&await j("inspect shell open-card",{openSwitcherCard:{appId:g}},`open switcher card ${g}`)}else if(e==="appearance"){let g=i[2];(!g||!["light","dark","auto","toggle"].includes(g))&&(console.error(v("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let $=await At(c,"appearance",g);n=!!$?.ok,m={appearance:$}}else if(e==="lock"||e==="shake"){let g=await At(c,e);n=!!g?.ok,m={[e]:g}}else console.error(` unknown shell subcommand: ${e}`),process.exit(1);console.log(JSON.stringify({ok:n,settled:u,state:m},null,2));break}case"url":{await xt(c,{args:l});break}case"reload":{let o=!1,r=!1;try{await c.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let m=await c.send({type:"evaluate",code:`;(() => {
|
|
602
602
|
const reloadExternalApp = window.SootSim?.bridges?.hotRemount?.reloadExternalApp
|
|
603
603
|
if (typeof reloadExternalApp === 'function') {
|
|
604
604
|
reloadExternalApp()
|
|
@@ -606,10 +606,10 @@ ${s}
|
|
|
606
606
|
}
|
|
607
607
|
window.location.reload()
|
|
608
608
|
return { kind: 'page' }
|
|
609
|
-
})()`});r=!!m&&m.kind==="external-app",
|
|
609
|
+
})()`});r=!!m&&m.kind==="external-app",o=!0}catch{}console.log(" reloading...");let n=c,u=null;if(r)u=await xe(c,{timeoutMs:1e4,errorGraceMs:3e3});else{o&&await X(300);let m=await st(_,R,M,{timeoutMs:1e4});m?(n=m,u=await xe(m,{timeoutMs:1e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 10000ms"),n=null)}if(u)if(u.ready){let m=u.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${u.elapsedMs}ms: ${u.nodes} nodes${m}`)}else u.source==="error-bail"?console.log(` \u26A0 reload bailed after ${u.elapsedMs}ms: ${u.errors} console error(s), ready signal never fired`):console.log(` \u26A0 reload timed out after ${u.elapsedMs}ms (${u.nodes} nodes, ${u.errors} errors)`);if(n)try{let m=await n.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors(10) || []"});if(n!==c&&n.close(),Array.isArray(m)&&m.length>0){console.log(`
|
|
610
610
|
\u26A0 ${m.length} error(s) during mount:
|
|
611
611
|
`);for(let y of m){let g=y.args.map($=>typeof $=="object"?JSON.stringify($):$).join(" ");if(console.log(` ${g}`),y.stack){let $=y.stack.split(`
|
|
612
|
-
`).slice(0,2);for(let A of $)console.log(` ${A.trim()}`)}}}}catch{}u&&!u.ready&&(process.exitCode=1);break}case"eval":case"js":{let e=i.slice(1).join(" ");e||(console.error(v("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(` ${
|
|
612
|
+
`).slice(0,2);for(let A of $)console.log(` ${A.trim()}`)}}}}catch{}u&&!u.ready&&(process.exitCode=1);break}case"eval":case"js":{let e=i.slice(1).join(" ");e||(console.error(v("js","<javascript>")),console.error(""),console.error(" runs the snippet in the engine realm. SootSim is the"),console.error(" canonical state surface \u2014 reach into it directly."),console.error(""),console.error(" examples:"),console.error(` ${w("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${w("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${w("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${w("js")} SootSim.state.root.children.length`),process.exit(1));let t=e;t.startsWith("(async")||(t=`(async () => ${t})()`);let o=await c.send({type:"evaluate",code:t});console.log(JSON.stringify(o,null,2));let r=e.toLowerCase(),n=[];(r.includes("sootsim:gohome")||r.includes("gohome"))&&n.push("sootsim shell home"),(r.includes("sootsim:appswitcher")||r.includes("appswitcher"))&&n.push("sootsim shell switcher"),(r.includes("keyboard.isvisible")||r.includes("keyboard.getmode"))&&n.push("sootsim debug state keyboard"),r.includes("interact.tap")&&n.push("sootsim do tap <x> <y>"),r.includes("keyboard.type")&&n.push("sootsim do type <text>"),(r.includes("keyboard.press")||r.includes("keyboard.dispatchkey"))&&n.push("sootsim do key <name>"),r.includes("keyboard.dismiss")&&n.push("sootsim do dismiss"),r.includes("dumptree")&&n.push("sootsim get tree"),r.includes("dumpaccessibilitytree")&&n.push("sootsim get a11y"),r.includes("getnodecount")&&n.push("sootsim get count"),r.includes("findbytext")&&n.push("sootsim find <text>"),(r.includes("findbytestid")||r.includes("findbyid"))&&n.push("sootsim find --testid <id>"),r.includes("document.hidden")&&n.push("sootsim debug state keyboard (includes tab health)"),n.length>0&&G("prefer-cli-over-eval",n);break}case"globals":{let e=await c.send({type:"evaluate",code:`(async () => {
|
|
613
613
|
const globals = {}
|
|
614
614
|
|
|
615
615
|
// test bridge (proxy in worker mode)
|
|
@@ -647,8 +647,8 @@ ${s}
|
|
|
647
647
|
|
|
648
648
|
return globals
|
|
649
649
|
})()`});console.log(` sootsim JS API:
|
|
650
|
-
`);for(let[t,
|
|
651
|
-
${
|
|
650
|
+
`);for(let[t,o]of Object.entries(e)){console.log(` ${t}:`);for(let r of o)console.log(` .${r}`);console.log("")}console.log(` use: ${w("js")} <expression>`),console.log(` example: ${w("js")} test.findByText("Sign in")`);break}case"describe":{await dt({bridge:c,args:s,positional:i});break}case"perf":{let e=i[1];if(!e||e==="--help"||e==="-h"){console.log(`
|
|
651
|
+
${w("perf")} \u2014 performance profiling
|
|
652
652
|
|
|
653
653
|
subcommands:
|
|
654
654
|
stats one-shot stats (zero overhead query)
|
|
@@ -658,11 +658,11 @@ ${s}
|
|
|
658
658
|
transition <e> profile a shell transition (goHome, appSwitcher, lockScreen)
|
|
659
659
|
|
|
660
660
|
examples:
|
|
661
|
-
${
|
|
662
|
-
${
|
|
661
|
+
${w("perf")} stats
|
|
662
|
+
${w("perf")} start
|
|
663
663
|
# ... interact with the app ...
|
|
664
|
-
${
|
|
665
|
-
${
|
|
664
|
+
${w("perf")} stop
|
|
665
|
+
${w("perf")} transition goHome
|
|
666
666
|
`);break}switch(e){case"stats":{let t=await c.send({type:"evaluate",code:`(async () => {
|
|
667
667
|
// worker mode (host exposes these)
|
|
668
668
|
if (window.__sootsimPerfStats) {
|
|
@@ -688,7 +688,7 @@ ${s}
|
|
|
688
688
|
jankFrames: frameStats.recentFrames?.filter(f => f > 16.67).length || 0,
|
|
689
689
|
recentCount: frameStats.recentFrames?.length || 0,
|
|
690
690
|
}
|
|
691
|
-
})()`});t.error&&(console.error(` error: ${t.error}`),process.exit(1));let
|
|
691
|
+
})()`});t.error&&(console.error(` error: ${t.error}`),process.exit(1));let o=t.avgMs!=="?"?(1e3/parseFloat(t.avgMs)).toFixed(1):"?";console.log(" perf stats:"),console.log(` frames: ${t.frames}`),console.log(` avg: ${t.avgMs}ms (${o} fps)`),console.log(` max: ${t.maxMs}ms`),console.log(` layout: ${t.layoutMs}ms total`),console.log(` nodes: ${t.nodeCount}`),t.recentCount>0&&console.log(` jank: ${t.jankFrames}/${t.recentCount} frames >16.67ms`);break}case"start":{await c.send({type:"evaluate",code:`(async () => {
|
|
692
692
|
// worker mode
|
|
693
693
|
if (window.__sootsimPerfStart && window.__sootsimRenderHost) {
|
|
694
694
|
const result = window.__sootsimPerfStart()
|
|
@@ -710,7 +710,7 @@ ${s}
|
|
|
710
710
|
startedAt: performance.now(),
|
|
711
711
|
}
|
|
712
712
|
return { started: true }
|
|
713
|
-
})()`}),console.log(` profiling started \u2014 interact with the app, then run '${
|
|
713
|
+
})()`}),console.log(` profiling started \u2014 interact with the app, then run '${w("perf")} stop'`);break}case"stop":{let t=await c.send({type:"evaluate",code:`(async () => {
|
|
714
714
|
// worker mode
|
|
715
715
|
if (window.__sootsimRenderHost) {
|
|
716
716
|
const session = window.${Q} || {}
|
|
@@ -804,8 +804,8 @@ ${s}
|
|
|
804
804
|
jankFrames: recent.filter(f => f > 16.67).length,
|
|
805
805
|
sampleCount: recent.length,
|
|
806
806
|
}
|
|
807
|
-
})()`});t.error&&(console.error(` error: ${t.error}`),process.exit(1));let
|
|
808
|
-
`),console.log(` frames: ${t.frames}`),console.log(` total: ${t.totalMs.toFixed(1)}ms`),console.log(` avg: ${t.avgMs.toFixed(2)}ms (${
|
|
807
|
+
})()`});t.error&&(console.error(` error: ${t.error}`),process.exit(1));let o=t.avgMs>0?(1e3/t.avgMs).toFixed(1):"?",r=t.sampleCount>0?(t.jankFrames/t.sampleCount*100).toFixed(1):"0";console.log(` profiling stopped:
|
|
808
|
+
`),console.log(` frames: ${t.frames}`),console.log(` total: ${t.totalMs.toFixed(1)}ms`),console.log(` avg: ${t.avgMs.toFixed(2)}ms (${o} fps)`),console.log(` max: ${t.maxMs.toFixed(2)}ms`),console.log(""),t.layoutAvgMs!==void 0&&(console.log(" breakdown (avg per frame):"),console.log(` layout: ${t.layoutAvgMs.toFixed(2)}ms`),console.log(` render: ${t.renderAvgMs.toFixed(2)}ms`),console.log(` copy: ${t.copyAvgMs.toFixed(2)}ms`),t.auxAvgMs!==void 0&&console.log(` aux: ${t.auxAvgMs.toFixed(2)}ms`),t.otherAvgMs!==void 0&&console.log(` other: ${t.otherAvgMs.toFixed(2)}ms`),console.log("")),console.log(` distribution (${t.sampleCount} samples):`),console.log(` p50: ${t.p50.toFixed(2)}ms`),console.log(` p95: ${t.p95.toFixed(2)}ms`),console.log(` p99: ${t.p99.toFixed(2)}ms`),console.log(` jank: ${t.jankFrames} frames (${r}%) >16.67ms`);break}case"frames":{let t=i[2]?Number(i[2]):50;(!Number.isFinite(t)||t<=0)&&(console.error(` error: expected a positive frame count, got "${i[2]}"`),process.exit(1));let o=await c.send({type:"evaluate",code:`(async () => {
|
|
809
809
|
if (window.__sootsimRenderHost) {
|
|
810
810
|
const session = window.${Q} || {}
|
|
811
811
|
if (session.active) {
|
|
@@ -840,7 +840,7 @@ ${s}
|
|
|
840
840
|
mode: 'main-thread',
|
|
841
841
|
frames: (stats.recentFrames || []).slice(-${t}),
|
|
842
842
|
}
|
|
843
|
-
})()`});if(
|
|
843
|
+
})()`});if(o.error&&(console.error(` error: ${o.error}`),process.exit(1)),o.mode==="render-worker"){let n=Array.isArray(o.samples)?o.samples:[];if(n.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` last ${n.length} sampled frames (ms):`),console.log(" total layout render copy aux other t+");for(let[u,m,y,g,$,A,B]of n)console.log(` ${m.toFixed(2).padStart(7)} ${y.toFixed(2).padStart(7)} ${g.toFixed(2).padStart(7)} ${$.toFixed(2).padStart(7)} ${A.toFixed(2).padStart(6)} ${B.toFixed(2).padStart(7)} ${String(u).padStart(5)}`);console.log(""),ke(n.map(u=>u[1])),o.live&&console.log(" sampling continues");break}let r=Array.isArray(o.frames)?o.frames:Array.isArray(o)?o:[];if(r.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` last ${r.length} frame times (ms):`),console.log(` ${r.map(n=>n.toFixed(2)).join(", ")}`),ke(r);break}case"worst":{let t=i[2]?Number(i[2]):20;(!Number.isFinite(t)||t<=0)&&(console.error(` error: expected a positive frame count, got "${i[2]}"`),process.exit(1));let o=await c.send({type:"evaluate",code:`(async () => {
|
|
844
844
|
if (window.__sootsimRenderHost) {
|
|
845
845
|
const session = window.${Q} || {}
|
|
846
846
|
if (session.active) {
|
|
@@ -882,8 +882,8 @@ ${s}
|
|
|
882
882
|
mode: 'main-thread',
|
|
883
883
|
frames: recent.slice().sort((a, b) => b - a).slice(0, ${t}),
|
|
884
884
|
}
|
|
885
|
-
})()`});if(
|
|
886
|
-
${
|
|
885
|
+
})()`});if(o.error&&(console.error(` error: ${o.error}`),process.exit(1)),o.mode==="render-worker"){let n=Array.isArray(o.samples)?o.samples:[];if(n.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` worst ${n.length} sampled frames (ms):`),console.log(" total layout render copy aux other t+");for(let[u,m,y,g,$,A,B]of n)console.log(` ${m.toFixed(2).padStart(7)} ${y.toFixed(2).padStart(7)} ${g.toFixed(2).padStart(7)} ${$.toFixed(2).padStart(7)} ${A.toFixed(2).padStart(6)} ${B.toFixed(2).padStart(7)} ${String(u).padStart(5)}`);o.live&&(console.log(""),console.log(" sampling continues"));break}let r=Array.isArray(o.frames)?o.frames:Array.isArray(o)?o:[];if(r.length===0){console.log(` no frame data \u2014 run '${w("perf")} start' first`);break}console.log(` worst ${r.length} frame times (ms):`),console.log(` ${r.map(n=>n.toFixed(2)).join(", ")}`);break}case"transition":{let t=i[2];if(!t||!["goHome","appSwitcher","lockScreen"].includes(t)){console.log(`
|
|
886
|
+
${w("perf")} transition <event> \u2014 profile a shell transition
|
|
887
887
|
|
|
888
888
|
events:
|
|
889
889
|
goHome swipe-to-home animation
|
|
@@ -893,8 +893,8 @@ ${s}
|
|
|
893
893
|
note: uses 600ms capture window \u2014 may need --timeout 10000 flag
|
|
894
894
|
|
|
895
895
|
examples:
|
|
896
|
-
${
|
|
897
|
-
${
|
|
896
|
+
${w("perf")} transition goHome --timeout 10000
|
|
897
|
+
${w("perf")} transition appSwitcher
|
|
898
898
|
`);break}let r=`sootsim:${t}`;console.log(` profiling ${t} transition...`),console.log(" (use --timeout 10000 if this times out)");let n=await c.send({type:"evaluate",code:`(async () => {
|
|
899
899
|
// only supported in render-worker mode
|
|
900
900
|
if (!window.__sootsimRenderHost) {
|
|
@@ -972,22 +972,24 @@ ${s}
|
|
|
972
972
|
p50: ${n.p50.toFixed(2)}ms
|
|
973
973
|
p95: ${n.p95.toFixed(2)}ms
|
|
974
974
|
p99: ${n.p99.toFixed(2)}ms
|
|
975
|
-
jank: ${n.jankFrames} frames (${m}%) >16.67ms`),Array.isArray(n.samples)&&n.samples.length>0&&(console.log(""),ke(n.samples.map(y=>y[1])));break}default:console.error(` unknown perf subcommand: ${e}`),process.exit(1)}break}case"errors":{let e=i[1];if(e==="clear"){await ze(c),C(l)?D({cleared:!0}):console.log(" error buffer cleared");break}let t=e?Number(e):20,
|
|
976
|
-
`);for(let r of
|
|
975
|
+
jank: ${n.jankFrames} frames (${m}%) >16.67ms`),Array.isArray(n.samples)&&n.samples.length>0&&(console.log(""),ke(n.samples.map(y=>y[1])));break}default:console.error(` unknown perf subcommand: ${e}`),process.exit(1)}break}case"errors":{let e=i[1];if(e==="clear"){await ze(c),C(l)?D({cleared:!0}):console.log(" error buffer cleared");break}let t=e?Number(e):20,o=await Ke(c,t);if(C(l)){D(o);break}if(o.length===0){console.log(" no errors captured");break}console.log(` ${o.length} error(s):
|
|
976
|
+
`);for(let r of o){let n=new Date(r.timestamp).toLocaleTimeString(),u=r.args.map(m=>typeof m=="object"?JSON.stringify(m):m).join(" ");if(console.log(` [${n}] ${u}`),r.stack){let m=r.stack.split(`
|
|
977
977
|
`).slice(0,3);for(let y of m)console.log(` ${y.trim()}`)}}break}case"warnings":{let e=i[1]?Number(i[1]):20,t=await Ue(c,e);if(C(l)){D(t);break}if(t.length===0){console.log(" no warnings captured");break}console.log(` ${t.length} warning(s):
|
|
978
|
-
`);for(let
|
|
979
|
-
`);for(let t of e){let
|
|
980
|
-
`);for(let u of n){let m=new Date(u.timestamp).toLocaleTimeString();console.log(` [${m}] ${E(u)}`),u.responseBody?console.log(` ${u.responseBody}`):u.error&&console.log(` ${u.error}`)}break}case"network":{let e=i[1],t=null,
|
|
978
|
+
`);for(let o of t){let r=new Date(o.timestamp).toLocaleTimeString(),n=o.args.map(u=>typeof u=="object"?JSON.stringify(u):u).join(" ");console.log(` [${r}] ${n}`)}break}case"animations":{let e=await z(c,"listAnimations")??[];if(s.includes("--json")){console.log(JSON.stringify(e,null,2));break}if(e.length===0){console.log(" no active animations");break}console.log(` ${e.length} active animation(s):
|
|
979
|
+
`);for(let t of e){let o=String(t.kind).padEnd(6),r=`${Number(t.from).toFixed(2)}\u2192${Number(t.to).toFixed(2)}`,n=Number(t.current??0).toFixed(2),u=`${Math.round((t.progress??0)*100)}%`,m=`${Math.round(t.elapsedMs??0)}ms`,y=t.loop?" loop":"",g=t.layoutBound?" layout":"";console.log(` #${t.id} ${o} ${r.padEnd(14)} cur=${n.padEnd(7)} ${u.padStart(4)} ${m}${y}${g}`)}break}case"animation":{let e=i[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${w("animation")} <id>`),process.exit(1));let t=Number(e);Number.isFinite(t)||(console.error(` invalid id: ${e}`),process.exit(1));let o=await z(c,"getAnimation",t);console.log(JSON.stringify(o,null,2));break}case"stop-animation":{let e=i[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${w("stop-animation")} <id|all>`),process.exit(1));let t=e==="all"?"all":Number(e);t!=="all"&&!Number.isFinite(t)&&(console.error(` invalid id: ${e}`),process.exit(1));let o=await z(c,"stopAnimation",t);console.log(` stopped ${o??0} animation(s)`);break}case"requests":{let e=i[1];if(e==="clear"){await Ge(c),C(l)?D({cleared:!0}):console.log(" request buffer cleared");break}let t=e==="all",o=t?i[2]:e,r=o?Number(o):20,n=await Ye(c,{failed:!t,limit:r});if(C(l)){D(n);break}if(n.length===0){console.log(t?" no requests captured":" no failed requests captured");break}console.log(` ${n.length} ${t?"request(s)":"failed request(s)"}:
|
|
980
|
+
`);for(let u of n){let m=new Date(u.timestamp).toLocaleTimeString();console.log(` [${m}] ${E(u)}`),u.responseBody?console.log(` ${u.responseBody}`):u.error&&console.log(` ${u.error}`)}break}case"network":{let e=i[1],t=null,o=null,r=!1,n=!1,u=1e3,m=!1,y=!1;for(let k=0;k<l.length;k++){let b=l[k];if(b==="--filter")t=l[k+1]??null,k++;else if(b==="--limit"){let p=Number(l[k+1]);Number.isFinite(p)&&(o=p),k++}else if(b==="--threshold"){let p=Number(l[k+1]);Number.isFinite(p)&&p>0&&(u=p),k++}else b==="--failed"?r=!0:b==="--slow"?n=!0:b==="--tail"||b==="-f"?m=!0:b==="--json"&&(y=!0)}if(e==="clear"){await c.send({type:"evaluate",code:'window.__sootsimObservability?.network.clear(); "cleared"'}),console.log(" network buffer cleared");break}if(e==="get"){let k=i[2];k||(console.error(" usage: sootsim network get <id>"),process.exit(1));let b=await c.send({type:"evaluate",code:`(() => {
|
|
981
981
|
const obs = window.__sootsimObservability;
|
|
982
982
|
if (!obs) return null;
|
|
983
983
|
return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(k)}) || null;
|
|
984
|
-
})()`});b||(console.error(` no entry with id ${k}`),process.exit(1)),y?console.log(JSON.stringify(b,null,2)):
|
|
984
|
+
})()`});b||(console.error(` no entry with id ${k}`),process.exit(1)),y?console.log(JSON.stringify(b,null,2)):ro(b);break}let g=o??(m?200:e?Number(e):20);Number.isFinite(g)||(console.error(` invalid limit: ${e} \u2014 \`network\` takes a numeric count (e.g. ${w("network")} 100).
|
|
985
|
+
to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let $=async()=>{let k=await c.send({type:"evaluate",code:`(() => {
|
|
985
986
|
const obs = window.__sootsimObservability;
|
|
986
987
|
if (!obs) return { ok: false };
|
|
987
988
|
return { ok: true, entries: obs.network.getSnapshot() };
|
|
988
989
|
})()`});if(!k||!k.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return k.entries??[]},A=k=>{let b=k;if(r&&(b=b.filter(p=>!!p.error||p.status!=null&&p.status>=400)),n&&(b=b.filter(p=>p.durationMs!=null&&p.durationMs>=u)),t){let p=t.toLowerCase();b=b.filter(O=>(O.displayUrl||O.url).toLowerCase().includes(p))}return n&&!m&&(b=[...b].sort((p,O)=>(O.durationMs??0)-(p.durationMs??0))),b};if(!m){let k=await $(),b=A(k).slice(-g);if(y){console.log(JSON.stringify(b,null,2));break}if(b.length===0){k.length===0?console.log(" no network requests captured"):console.log(n?` no requests slower than ${u}ms (${k.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(n?` ${b.length} request(s) slower than ${u}ms (sorted by duration desc):
|
|
989
990
|
`:` ${b.length} request(s):
|
|
990
|
-
`);for(let p of b)
|
|
991
|
-
`);let B=new Set,H=!0,K=()=>{H=!1};process.on("SIGINT",K);try{for(;H;){let k=await $(),b=A(k);for(let p of b)p.durationMs!=null&&(B.has(p.id)||(B.add(p.id),y?console.log(JSON.stringify(p)):
|
|
992
|
-
|
|
993
|
-
`);
|
|
991
|
+
`);for(let p of b)Nt(p);break}console.log(` tailing network (ctrl-c to stop)...
|
|
992
|
+
`);let B=new Set,H=!0,K=()=>{H=!1};process.on("SIGINT",K);try{for(;H;){let k=await $(),b=A(k);for(let p of b)p.durationMs!=null&&(B.has(p.id)||(B.add(p.id),y?console.log(JSON.stringify(p)):Nt(p)));await X(250)}}finally{process.off("SIGINT",K)}break}case"logs":{let e=i[1],t=null,o=null,r=null,n=!1,u=!1,m=!1;for(let b=0;b<l.length;b++){let p=l[b];if(p==="--filter")t=l[b+1]??null,b++;else if(p==="--limit"){let O=Number(l[b+1]);Number.isFinite(O)&&(o=O),b++}else p==="--level"?(r=l[b+1]??null,b++):p==="--tail"||p==="-f"?n=!0:p==="--json"?u=!0:(p==="--internal"||p==="--all")&&(m=!0)}let y=r?new Set(r.split(",").map(b=>b.trim()).filter(b=>b==="log"||b==="info"||b==="warn"||b==="error"||b==="debug")):null;if(e==="clear"){await Ve(c),console.log(" log buffer cleared");break}let g=!u&&process.stdout.isTTY===!0,$=o??(n?500:e?Number(e):50);Number.isFinite($)||(console.error(` invalid limit: ${e} \u2014 \`logs\` takes a numeric count (e.g. ${w("logs")} 100).
|
|
993
|
+
to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let A=()=>Xe(c),B=b=>Qe(b,{level:y,filter:t,showInternal:m});if(!n){let b=await A(),p=B(b).slice(-$);if(u){console.log(JSON.stringify(p,null,2));break}if(p.length===0){console.log(b.length===0?" no logs captured":" no matching logs");break}console.log(` ${p.length} log(s):
|
|
994
|
+
`);for(let O of p)_t(O,g);break}console.log(` tailing logs (ctrl-c to stop)...
|
|
995
|
+
`);let H=new Set,K=!0,k=()=>{K=!1};process.on("SIGINT",k);try{for(;K;){let b=await A(),p=B(b);for(let O of p)H.has(O.id)||(H.add(O.id),u?console.log(JSON.stringify(O)):_t(O,g));await X(250)}}finally{process.off("SIGINT",k)}break}default:console.error(` unknown subcommand: ${h}`),process.exit(1)}if(F.has(h)&&!s.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&await L(c),!U.has(h)&&!C(l))try{await Z(c)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e);console.error(` ${h??"inspect"} failed: ${t}`);let o=/^no sim connected with id (.+)$/.exec(t);if(o)await rt(c,_,o[1]);else if(/^no sim connected$/.test(t))nt(_);else{try{await Ee(c)}catch{}try{await x({includeTail:!0})}catch{}try{await W({includeTail:!0})}catch{}}process.exit(1)}finally{c.close()}}export{zs as runInspect};
|