sootsim 0.1.51 → 0.1.52
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/dist-cli/bin.js +7 -7
- package/dist-cli/chunks/{agent-RLBVAUCW.js → agent-RUWGJCSS.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-TWLPNETE.js → agent-wrapper-FBCGP5N7.js} +2 -2
- package/dist-cli/chunks/{assert-JLQSBZPM.js → assert-IOU2NWE2.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-OYBDYAZM.js +2 -0
- package/dist-cli/chunks/beta-D4OEPOSE.js +2 -0
- package/dist-cli/chunks/{chunk-JZ65NOXB.js → chunk-2QNHBNWB.js} +2 -2
- package/dist-cli/chunks/{chunk-P45EZ2VW.js → chunk-3DDSYQHM.js} +2 -2
- package/dist-cli/chunks/{chunk-SLAAAEUZ.js → chunk-3MIWVHCX.js} +1 -1
- package/dist-cli/chunks/{chunk-PTW5KT4I.js → chunk-4TSGUAV3.js} +2 -2
- package/dist-cli/chunks/{chunk-3BUWCNVX.js → chunk-6QDFLMJL.js} +1 -1
- package/dist-cli/chunks/{chunk-VXLRXQER.js → chunk-7Y3FYPJH.js} +2 -2
- package/dist-cli/chunks/{chunk-2ZCJFJJN.js → chunk-A3YSGT76.js} +2 -2
- package/dist-cli/chunks/{chunk-ZT7672XM.js → chunk-ABEYZDD7.js} +3 -3
- package/dist-cli/chunks/{chunk-6NR6NFDC.js → chunk-BF7F45CZ.js} +2 -2
- package/dist-cli/chunks/{chunk-5PKYORP6.js → chunk-CTEXZ7BE.js} +1 -1
- package/dist-cli/chunks/{chunk-P2IC3VRD.js → chunk-DNKB2V2W.js} +2 -2
- package/dist-cli/chunks/chunk-DSJ7PGU3.js +2 -0
- package/dist-cli/chunks/{chunk-4QM4J2UK.js → chunk-DVCE2KQL.js} +1 -1
- package/dist-cli/chunks/{chunk-L4OPPOPY.js → chunk-EJYVXNQL.js} +2 -2
- package/dist-cli/chunks/{chunk-VDUWPVZT.js → chunk-EQPRFEHH.js} +2 -2
- package/dist-cli/chunks/{chunk-XWHWPFBE.js → chunk-EXQJSXDF.js} +1 -1
- package/dist-cli/chunks/{chunk-DBHV5S2L.js → chunk-EYRQG47K.js} +1 -1
- package/dist-cli/chunks/{chunk-SPMHQKNI.js → chunk-FPIJBBYW.js} +78 -78
- package/dist-cli/chunks/{chunk-RSEV5NWY.js → chunk-FVBSPGBR.js} +2 -2
- package/dist-cli/chunks/{chunk-45XEBYVX.js → chunk-GNQSOQXZ.js} +2 -2
- package/dist-cli/chunks/{chunk-265YGINI.js → chunk-H4G7IRXG.js} +6 -3
- package/dist-cli/chunks/{chunk-LMINUIAR.js → chunk-HRIQRZX3.js} +1 -1
- package/dist-cli/chunks/{chunk-DBYZF6KL.js → chunk-I5WEW3ES.js} +1 -1
- package/dist-cli/chunks/{chunk-54IIO5BV.js → chunk-IQU56D6C.js} +1 -1
- package/dist-cli/chunks/{chunk-IENPCJTB.js → chunk-IXITVIJV.js} +4 -4
- package/dist-cli/chunks/{chunk-FSTOUA6L.js → chunk-JPLTR6JM.js} +1 -1
- package/dist-cli/chunks/{chunk-FUHHRW7G.js → chunk-JPX7OS7B.js} +2 -2
- package/dist-cli/chunks/chunk-KVQWMXDV.js +2 -0
- package/dist-cli/chunks/{chunk-BKXH674Z.js → chunk-MBH3NFBC.js} +2 -2
- package/dist-cli/chunks/{chunk-HATEGE6O.js → chunk-MSKCUZ5B.js} +4 -4
- package/dist-cli/chunks/{chunk-BGZRRNK4.js → chunk-MTE3DEWY.js} +1 -1
- package/dist-cli/chunks/{chunk-IEYPDVW2.js → chunk-MWGIKDXO.js} +2 -2
- package/dist-cli/chunks/{chunk-EOYTPHOU.js → chunk-PDZ4JVAW.js} +1 -1
- package/dist-cli/chunks/{chunk-M7HK7MWE.js → chunk-PZJSYDQ7.js} +3 -3
- package/dist-cli/chunks/{chunk-67AZW4HJ.js → chunk-Q2424XB2.js} +1 -1
- package/dist-cli/chunks/chunk-SEETW74F.js +1 -0
- package/dist-cli/chunks/{chunk-AWQGGSDW.js → chunk-T6RAXKVI.js} +2 -2
- package/dist-cli/chunks/{chunk-ZEIDKF3M.js → chunk-U3UHXJNE.js} +1 -1
- package/dist-cli/chunks/{chunk-ET5NKJVL.js → chunk-UCCSXQ2P.js} +29 -29
- package/dist-cli/chunks/chunk-ULHAQFCE.js +1 -0
- package/dist-cli/chunks/{chunk-VR2UDTSA.js → chunk-USGUHWUJ.js} +2 -2
- package/dist-cli/chunks/{chunk-CLSZB5BN.js → chunk-UXE5BFPK.js} +2 -2
- package/dist-cli/chunks/{chunk-AQN3BB3D.js → chunk-YDKXZS7D.js} +1 -1
- package/dist-cli/chunks/chunk-YVGHAT6Q.js +1 -0
- package/dist-cli/chunks/cli-version-2VO66OZ6.js +2 -0
- package/dist-cli/chunks/{compat-WUI6VQPS.js → compat-ZBLH6EWV.js} +3 -3
- package/dist-cli/chunks/{config-XCFL4A6Z.js → config-DH2GG63H.js} +2 -2
- package/dist-cli/chunks/control-W3BOP6AT.js +2 -0
- package/dist-cli/chunks/{cpu-profile-CPOEDK5W.js → cpu-profile-3PRCXZMV.js} +2 -2
- package/dist-cli/chunks/{daemon-NFZOWPYN.js → daemon-XSFKUDKZ.js} +2 -2
- package/dist-cli/chunks/{debug-G6FBH3B4.js → debug-VAWCOXQ3.js} +3 -3
- package/dist-cli/chunks/demo-app-registry-7GNP7WE4.js +2 -0
- package/dist-cli/chunks/{detox-PUCPDKAO.js → detox-UABOFTDQ.js} +2 -2
- package/dist-cli/chunks/{device-IUUKTF7R.js → device-LCB4N66D.js} +2 -2
- package/dist-cli/chunks/diagnose-MT3WMY4M.js +41 -0
- package/dist-cli/chunks/drivers-YGVUWGMB.js +2 -0
- package/dist-cli/chunks/{electron-HGY5WSFG.js → electron-WVNFRA4S.js} +3 -3
- package/dist-cli/chunks/flow-OUOMEOSC.js +2 -0
- package/dist-cli/chunks/{hints-H7IVKEWB.js → hints-PFAKBGFX.js} +2 -2
- package/dist-cli/chunks/{home-paths-U5CDMYH5.js → home-paths-X6RB72PF.js} +2 -2
- package/dist-cli/chunks/{inspect-6WSCE3W3.js → inspect-UFYXDO6B.js} +74 -71
- package/dist-cli/chunks/install-NBUHIXEP.js +2 -0
- package/dist-cli/chunks/{install-desktop-QTZ3IBQW.js → install-desktop-W6QJX52Y.js} +3 -3
- package/dist-cli/chunks/{keys-DCQXAY66.js → keys-ORDSAMP7.js} +2 -2
- package/dist-cli/chunks/{launch-FTHBNATG.js → launch-NQZTWTPY.js} +3 -3
- package/dist-cli/chunks/{login-4GUBAGPQ.js → login-J2NVLHK5.js} +4 -4
- package/dist-cli/chunks/{logout-N25HFETU.js → logout-HI7A6PFH.js} +2 -2
- package/dist-cli/chunks/{maestro-WQBZZDTR.js → maestro-KIOOFK5M.js} +9 -9
- package/dist-cli/chunks/{preview-6MWJ6BSM.js → preview-QUJO4B4G.js} +2 -2
- package/dist-cli/chunks/{profile-UXJEGF4I.js → profile-U6RWYQV2.js} +2 -2
- package/dist-cli/chunks/{react-MHPIWH3F.js → react-3V65RTQC.js} +2 -2
- package/dist-cli/chunks/record-476LFCQV.js +41 -0
- package/dist-cli/chunks/runtime-4TK5DY5R.js +2 -0
- package/dist-cli/chunks/{runtime-delivery-IIDHK55K.js → runtime-delivery-BSRHUXJQ.js} +2 -2
- package/dist-cli/chunks/{screenshot-MDE5ZSST.js → screenshot-2S3BCN35.js} +2 -2
- package/dist-cli/chunks/{screenshot-mode-7W7L7IN3.js → screenshot-mode-SZCHOYZV.js} +2 -2
- package/dist-cli/chunks/{screenshots-24LEZPD7.js → screenshots-LGP7LA3M.js} +2 -2
- package/dist-cli/chunks/{server-52HFHX3S.js → server-G4BGS6GE.js} +11 -11
- package/dist-cli/chunks/setup-repo-5LUDPPSI.js +2 -0
- package/dist-cli/chunks/{skills-3DGYETTU.js → skills-2YOLQVV6.js} +2 -2
- package/dist-cli/chunks/{start-NFVPQX74.js → start-SF3I4SLN.js} +4 -4
- package/dist-cli/chunks/store-LLUQKQB7.js +2 -0
- package/dist-cli/chunks/telemetry-RDTORLS2.js +2 -0
- package/dist-cli/chunks/{test-THI53N25.js → test-YYHXTVDI.js} +3 -3
- package/dist-cli/chunks/{three-mode-HUI4SESE.js → three-mode-5U3H4QDF.js} +2 -2
- package/dist-cli/chunks/{timeline-KAJ6PR4S.js → timeline-IOEIFEH2.js} +2 -2
- package/dist-cli/chunks/{upgrade-APDFMQCW.js → upgrade-YF2U5QJY.js} +2 -2
- package/dist-cli/chunks/upload-3DFSK4NV.js +2 -0
- package/dist-cli/chunks/web-GAOXH77P.js +2 -0
- package/dist-cli/chunks/{what-happened-4VMBEL5Z.js → what-happened-DBI2RQVE.js} +2 -2
- package/dist-cli/chunks/{whoami-NJOQICNO.js → whoami-YDAMLYNA.js} +2 -2
- 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 +63 -7
- 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 +67 -7
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/dist-cli/chunks/auto-bootstrap-UKUFJBJA.js +0 -2
- package/dist-cli/chunks/beta-4OEWPO5F.js +0 -2
- package/dist-cli/chunks/chunk-3HO4Q25D.js +0 -1
- package/dist-cli/chunks/chunk-4D7Z64YQ.js +0 -2
- package/dist-cli/chunks/chunk-ACQXOAQI.js +0 -2
- package/dist-cli/chunks/chunk-DV3SI64Q.js +0 -1
- package/dist-cli/chunks/chunk-EWSS4C2R.js +0 -1
- package/dist-cli/chunks/control-KE4VM2BN.js +0 -2
- package/dist-cli/chunks/demo-app-registry-U4FCHIYP.js +0 -2
- package/dist-cli/chunks/diagnose-6RY4YXSP.js +0 -41
- package/dist-cli/chunks/drivers-2FY62QZA.js +0 -2
- package/dist-cli/chunks/flow-HEYPRCST.js +0 -2
- package/dist-cli/chunks/install-NPNUNOL6.js +0 -2
- package/dist-cli/chunks/record-K5DRP3G7.js +0 -18
- package/dist-cli/chunks/runtime-UVFYTDXE.js +0 -2
- package/dist-cli/chunks/setup-repo-ZHEBGISP.js +0 -2
- package/dist-cli/chunks/store-R2RI4XAS.js +0 -2
- package/dist-cli/chunks/telemetry-KGU6DBN6.js +0 -2
- package/dist-cli/chunks/upload-K7OWH74D.js +0 -2
- package/dist-cli/chunks/web-XDGC5KGT.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as G}from"./chunk-
|
|
3
|
-
`)}function
|
|
1
|
+
/*! sootsim v0.1.52 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as G}from"./chunk-3DDSYQHM.js";import{a as je,b as Le}from"./chunk-EXQJSXDF.js";import{a as X,b as D,c as B,d as Y,e as de,f as re,g as rt,h as it,i as ve}from"./chunk-A3YSGT76.js";import{D as nt,a as Je,b as We,c as qe,d as He,e as Ue,f as $e,g as Se,h as Ke,i as ze,j as Ye,k as Ge,l as Xe,m as Ve,n as Qe,o as Ze,p as et,q as tt,u as ot,w as ne,x as st}from"./chunk-DVCE2KQL.js";import{a as De,g as ce}from"./chunk-FPIJBBYW.js";import{b as at,c as lt,i as ct}from"./chunk-ABEYZDD7.js";import"./chunk-3MIWVHCX.js";import{a as Be}from"./chunk-HRIQRZX3.js";import"./chunk-H4G7IRXG.js";import"./chunk-I5WEW3ES.js";import"./chunk-YVGHAT6Q.js";import"./chunk-EQPRFEHH.js";import"./chunk-MTE3DEWY.js";import{a as be,c as we,d as Ae}from"./chunk-PDZ4JVAW.js";import{a as Fe}from"./chunk-KVQWMXDV.js";import{c as Oe,e as Re,f as Ee,g as Ce,h as xe}from"./chunk-MBH3NFBC.js";import{b as Pe}from"./chunk-CTEXZ7BE.js";import"./chunk-DSJ7PGU3.js";import"./chunk-JPLTR6JM.js";import"./chunk-6QDFLMJL.js";import{existsSync as Wt,mkdirSync as qt,readFileSync as Ht,rmSync as dt,writeFileSync as Ut}from"fs";import{tmpdir as Kt}from"os";import{dirname as zt,join as Yt,resolve as Gt}from"path";var ie=1,Xt="SOOTSIM_INSPECT_NOTICE_PATH",Vt=300*1e3,Qt=15e3;function ut(){return Gt(process.env[Xt]||Yt(Kt(),"sootsim-inspect-notice-state.json"))}function Zt(o,d){return Object.fromEntries(Object.entries(o).filter(([,a])=>typeof a?.signature=="string"&&Number.isFinite(a?.updatedAt)&&d-a.updatedAt<=Vt))}function eo(o){let d=ut();if(!Wt(d))return{version:ie,entries:{}};try{let a=JSON.parse(Ht(d,"utf8"));return a.version!==ie||!a.entries||typeof a.entries!="object"?(dt(d,{force:!0}),{version:ie,entries:{}}):{version:ie,entries:Zt(a.entries,o)}}catch{return dt(d,{force:!0}),{version:ie,entries:{}}}}function to(o){let d=ut();qt(zt(d),{recursive:!0}),Ut(d,JSON.stringify(o,null,2)+`
|
|
3
|
+
`)}function oo(o,d){let a=d.trim()||"default";return`${o}:${a}`}function ke(o,d,a,l={}){let f=l.nowMs??Date.now(),i=l.cooldownMs??Qt,y=eo(f),S=oo(o,d),I=y.entries[S];return I&&I.signature===a&&f-I.updatedAt<i?!1:(y.entries[S]={signature:a,updatedAt:f},to(y),!0)}async function mt(o,d={args:[]}){let a=await Je(o);if(D(d.args)){B(a);return}console.log(` nodes: ${a.nodes}`)}function Te(o,d){let a=o.indexOf(d);return a>=0&&a+1<o.length?o[a+1]:null}async function pt(o){let{bridge:d,args:a,positional:l}=o,f=a.includes("--verbose")||a.includes("-v"),i=D(a),y=f&&!i,S=a.includes("--watch")||a.includes("-w"),I=1e3,k=a.includes("--compact"),b=a.includes("--no-xy"),v=Te(a,"--testid-like"),_=Te(a,"--only"),T=Te(a,"--subtree"),C=l[1],c=C?/[*?]/.test(C):!1,J=!c&&!_?C:void 0,K=_??(c?C:void 0),E=async()=>{await de(d,{verbose:y});let z=await He(d,{describe:!0,verbose:f,filter:J||"",testIdLike:v||void 0,onlyGlob:K||void 0,subtreeRoot:T||void 0,compact:k,hideXy:b}),q=z?.tree,w=z?.shell,M=z?.keyboard;if(i){B({shell:w,tree:q??"",keyboard:M});return}if(w&&typeof w=="object"){let P=[w.state?`state=${w.state}`:null,w.activeApp?`app=${w.activeApp}`:null,w.showSwitcher?"switcher":null,w.switcherPhase&&w.switcherPhase!=="idle"?`phase=${w.switcherPhase}`:null].filter(Boolean);P.length>0&&console.log(` shell: ${P.join(" ")}`)}if(typeof q=="string"&&q.startsWith("__SUBTREE_NOT_FOUND__:")){let P=q.slice(22);console.log(` subtree root not found: ${P}`),G("subtree-root-not-found",P);return}if(!q){let P=z?.nodeCount??0;console.log(" no matching nodes found"),!(J||v||K||T)&&P<10&&G("app-still-loading",P);return}if(console.log(q),!(J||v||K||T)&&!S&&q.split(`
|
|
4
4
|
`).length>=80&&G("describe-use-filters"),M&&M.visible){let P=M.spec,V=[P?.keyboardType?`type=${P.keyboardType}`:null,P?.returnKeyType&&P.returnKeyType!=="default"?`return=${P.returnKeyType}`:null,M.mode!=="letters"?`mode=${M.mode}`:null,M.shifted?"shift":null,M.capsLock?"caps":null,P?.autoCapitalize&&P.autoCapitalize!=="sentences"?`autoCap=${P.autoCapitalize}`:null,M.accessoryBarId?`accessory=${M.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
|
|
6
|
+
`);;)console.clear(),await E(),await X(I);else await E()}var so=["SOOTSIM_AGENT","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function ft(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let o of so){let d=process.env[o];if(d&&d.trim()&&d!=="0")return!0}return!1}async function gt(o){let{bridge:d,args:a,effectiveArgs:l,positional:f,inspectUsage:i}=o,y=w=>{let M=l.indexOf(w);return M>=0&&M+1<l.length?l[M+1]:null},S=w=>l.includes(w),I=y("--testid")||y("--test-id"),k=y("--role"),b=y("--type"),v=y("--text"),_=S("--pressable"),T=S("--visible"),C=S("--interactive-targets")||S("--actions"),c=!I&&!k&&!b&&!v&&!_&&!T&&!C?f[1]:null,J=v??c,K=await Ue(d,{testId:I,role:k,type:b,text:J,pressable:_,visible:T,interactive:C});K||(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}=K,z=D(a),q=a.includes("--verbose")||a.includes("--dump");if(z)E==="interactive-targets"&&Array.isArray(L)?B($e(L).map(w=>({...w,tap:Se(w)}))):B(L??null);else if(Array.isArray(L))if(L.length===0){console.log(` no ${E} nodes found`);let w=await d.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof w=="number"&&w<10&&G("app-still-loading",w)}else if(E==="interactive-targets"){let w=$e(L);console.log(` found ${w.length} interactive target${w.length===1?"":"s"} (sorted by score):`);for(let M of w.slice(0,20)){let Z=M.absolutePosition?`@(${Math.round(M.absolutePosition.x)},${Math.round(M.absolutePosition.y)})`:"",P=M.layout?`${Math.round(M.layout.width)}x${Math.round(M.layout.height)}`:"?x?",V=M.text?` "${M.text.slice(0,30)}"`:"",ee=M.testID?` #${M.testID}`:"",oe=M.accessibilityLabel?` \u24D8"${String(M.accessibilityLabel).slice(0,24)}"`:"",ye=M.accessibilityRole?`[${M.accessibilityRole}]`:M.type,e=Se(M);console.log(` ${ye}${V}${oe}${ee} ${P} ${Z}`),console.log(` \u2192 ${e}`),q&&console.log(Me(JSON.stringify(M,null,2)," "))}w.length>20&&console.log(` ... and ${w.length-20} more`)}else{console.log(` found ${L.length} node${L.length===1?"":"s"} (${E}):`);for(let w of L.slice(0,20)){let M=w.absolutePosition?`@(${Math.round(w.absolutePosition.x)},${Math.round(w.absolutePosition.y)})`:"",Z=w.layout?`${Math.round(w.layout.width)}x${Math.round(w.layout.height)}`:"?x?",P=w.text?` "${w.text.slice(0,30)}"`:"",V=w.testID?` #${w.testID}`:"",ee=w.pressable?" (tap)":"",oe=w.accessibilityRole?`[${w.accessibilityRole}]`:w.type;console.log(` ${oe}${P}${V} ${Z} ${M}${ee}`),q&&console.log(Me(JSON.stringify(w,null,2)," "))}L.length>20&&console.log(` ... and ${L.length-20} more`)}else if(L==null)console.log(` not found: ${J||I||k||b||""||E}`),I&&G("wait-selector-for-missing-testid",I);else{let w=L;if(w.type&&w.absolutePosition){let M=`@(${Math.round(w.absolutePosition.x)},${Math.round(w.absolutePosition.y)})`,Z=w.layout?`${Math.round(w.layout.width)}x${Math.round(w.layout.height)}`:"?x?",P=w.text?` "${w.text.slice(0,40)}"`:"",V=w.testID?` #${w.testID}`:"",ee=w.pressable?" (tap)":"",oe=w.accessibilityRole?`[${w.accessibilityRole}]`:w.type;console.log(` ${oe}${P}${V} ${Z} ${M}${ee}`),q&&console.log(Me(JSON.stringify(w,null,2)," "))}else console.log(JSON.stringify(L,null,2))}}function Me(o,d){return o.split(`
|
|
7
7
|
`).map(a=>d+a).join(`
|
|
8
|
-
`)}async function
|
|
9
|
-
`))}async function
|
|
8
|
+
`)}async function yt(o,d={}){let a=await ot(o);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:y,capsLock:S,accessoryBarId:I}=a,k=[];k.push(`keyboard: ${l?"visible":"hidden"}`),f?(k.push(` type: ${f.keyboardType}`),k.push(` returnKey: ${f.returnKeyType}`),k.push(` autoCap: ${f.autoCapitalize}`),k.push(` autoCorrect: ${f.autoCorrect?"on":"off"}`),k.push(` appearance: ${f.keyboardAppearance}`),f.secureTextEntry&&k.push(" secureTextEntry: true"),f.enablesReturnKeyAutomatically&&k.push(` return: ${f.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):k.push(" spec: <none> (shown via dev-tools with no TextInput)"),k.push(` mode: ${i}${y?" (shifted)":""}${S?" (caps)":""}`),I&&k.push(` accessoryBar: ${I}`),console.log(k.join(`
|
|
9
|
+
`))}async function ht(o){let d=await o.bridge.listSims();if(D(o.args)){B(d.map(a=>({...a,active:a.id===o.simId})));return}ct(d,o.simId)}function te(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/1024/1024).toFixed(1)}MB`}function ue(o,d){return d<=0?"?":`${(o/d*100).toFixed(0)}%`}async function bt(o,d={args:[]}){let a=await nt(o);if(D(d.args)){B(a);return}if(console.log(" memory:"),a.imageLoader){let l=a.imageLoader;console.log(" image-loader cache"),console.log(` entries: ${l.cacheEntries} / ${l.cacheMaxEntries} (${ue(l.cacheEntries,l.cacheMaxEntries)})`),console.log(` pixel bytes: ${te(l.cachePixelBytes)} / ${te(l.cachePixelBudget)} (${ue(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: ${te(l.usedJSHeapSize)} / ${te(l.jsHeapSizeLimit)} (${ue(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${te(l.totalJSHeapSize)}`)}if(a.hostHeap){let l=a.hostHeap;console.log(" host heap (chrome only)"),console.log(` used: ${te(l.usedJSHeapSize)} / ${te(l.jsHeapSizeLimit)} (${ue(l.usedJSHeapSize,l.jsHeapSizeLimit)})`),console.log(` total: ${te(l.totalJSHeapSize)}`)}}function ae(o){let d=o.indexOf("--testid");if(d>=0&&o[d+1])return{mode:"testid",value:o[d+1]};let a=o.indexOf("--test-id");if(a>=0&&o[a+1])return{mode:"testid",value:o[a+1]};let l=o.indexOf("--text");return l>=0&&o[l+1]?{mode:"text",value:o[l+1]}:null}async function me(o,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 o.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-P45EZ2VW.js";import{a as De,b as Be}from"./chunk-XWHW
|
|
|
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
|
|
27
|
+
})()`})??null}async function wt(o,d={}){let{nav:a,keyboard:l,shell:f}=await st(o);if(d.json){console.log(JSON.stringify({shell:f??null,nav:a,keyboard:l},null,2));return}let i=[];if(f){let y=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: ${y}${S}${I}`)}else i.push("shell: <unavailable>");if(a){let y=a.transitionPhase!=="idle"?` (${a.transitionPhase}, ${a.activeTransitionCount} active)`:"";if(i.push(`nav: phase=${a.transitionPhase}${y}`),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":" ",k=S.routeName?` ${S.routeName}`:"",b=S.headerHeight>0?` header=${S.headerHeight}`:"",v=S.largeTitleState&&S.largeTitleState!=="expanded"?` large-title=${S.largeTitleState}`:"";i.push(` ${I} #${S.id}${k}${b}${v}`)}}else i.push("nav: <runtime not available>");if(l&&l.visible){let y=l.spec?.keyboardType??"default",S=l.spec?.returnKeyType??"default";i.push(`keyboard: visible (${y}, return=${S}, mode=${l.mode??"?"})`)}else i.push("keyboard: hidden");console.log(i.join(`
|
|
28
|
+
`))}async function se({bridge:o,maxMs:d,pollMs:a=50,stablePolls:l=3,strict:f=!1}){let i=await o.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-P45EZ2VW.js";import{a as De,b as Be}from"./chunk-XWHW
|
|
|
74
74
|
await sleep(pollMs)
|
|
75
75
|
}
|
|
76
76
|
return { settled: false, elapsed: Date.now() - start }
|
|
77
|
-
})()`}),{elapsed:y,settled:S}=i??{};return{elapsed:typeof y=="number"?y:d,settled:S===!0}}async function
|
|
77
|
+
})()`}),{elapsed:y,settled:S}=i??{};return{elapsed:typeof y=="number"?y:d,settled:S===!0}}async function xt(o){let{bridge:d,args:a,positional:l}=o,f=l[1]?Number(l[1])*1e3:3e3,i=a.includes("--strict"),{elapsed:y,settled:S}=await se({bridge:d,maxMs:f,strict:i});console.log(S?` settled in ${y}ms`:` timed out after ${y}ms (may still be animating)`)}async function $t(o){let d=o.positional[1]?Number(o.positional[1]):.5;(!Number.isFinite(d)||d<0)&&(console.error(o.inspectUsage("sleep","[seconds]")),process.exit(1)),await X(d*1e3),console.log(` slept ${d}s`)}async function St(o){let{bridge:d,args:a,positional:l}=o,f=l[1]?Number(l[1]):5,{tree:i}=await We(d,f);if(D(a)){B({depth:f,tree:i??null});return}console.log(typeof i=="string"?i:JSON.stringify(i,null,2))}async function vt(o,d={args:[]}){let a=await qe(o);if(D(d.args)){B(a);return}console.log(a.url)}async function kt(o){let{wsPort:d,commandTimeoutMs:a,simId:l,positional:f}=o,i=f[1]?Number(f[1]):30,y=Math.max(1e3,(Number.isFinite(i)?i:30)*1e3),S=Math.max(1,Math.ceil(y/500));console.log(" waiting for sim reconnect...");let I=await rt(d,a,l,{attempts:S});I||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),I.bridge.close(),ce({source:"inspect wait",step:{wait:y},summary:`wait ${Math.round(y/1e3)}s`}),console.log(` ready: ${I.count} nodes`)}var Tt=new Set(["app-launch","toast","keyboard","screen","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function pe(o,d){let a=o.indexOf(d);if(a>=0&&a+1<o.length)return o[a+1]}function no(o,d){if(!d.filter&&!d.equals)return!0;let a=o.data,l=[];if(a&&typeof a=="object")for(let i of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let y=a[i];typeof y=="string"&&y.length>0&&l.push(y)}let f=l.join(" ");return d.equals?l.some(i=>i===d.equals):d.filter?f.toLowerCase().includes(d.filter.toLowerCase()):!0}async function Mt(o){let{bridge:d,args:a,positional:l,inspectUsage:f}=o,i=l[1];i||(console.error(f("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),Tt.has(i)||console.error(` warning: '${i}' is not a known timeline kind \u2014 waiting anyway. known: ${[...Tt].sort().join(", ")}`);let y=pe(a,"--max-ms"),S=y&&Number.isFinite(Number(y))?Math.max(100,Number(y)):5e3,I=pe(a,"--filter"),k=pe(a,"--equals"),b=pe(a,"--since")??"now",v=a.includes("--json"),_=Date.now(),T=_+S,C=200,c=_;for(;Date.now()<T;){let K={kinds:[i],since:b==="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
|
-
return { ok: true, result: await t.recent(${JSON.stringify(
|
|
81
|
-
})()`});(!
|
|
82
|
-
`).slice(0,5);for(let y of i)console.log(` ${y.trim()}`)}}var Q="__sootsimCliPerf",
|
|
80
|
+
return { ok: true, result: await t.recent(${JSON.stringify(K)}) }
|
|
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 z of L)if(no(z,{filter:I,equals:k})){let q=Date.now()-_;console.log(v?JSON.stringify({found:!0,elapsedMs:q,event:z}):` ${i} event after ${q}ms${I?` (filter: ${I})`:""}${k?` (equals: ${k})`:""}`);return}E.result.watermark&&E.result.watermark>c&&(c=E.result.watermark),await new Promise(z=>setTimeout(z,C))}let J=Date.now()-_;v?console.log(JSON.stringify({found:!1,elapsedMs:J,kind:i,filter:I,equals:k})):console.error(` \u26A0 wait event ${i} timed out after ${J}ms${I?` (filter: ${I})`:""}${k?` (equals: ${k})`:""}`),process.exit(1)}async function Nt(o){let{bridge:d,args:a}=o,l=a.includes("--strict"),f=a.indexOf("--max-ms"),i=f>=0&&a[f+1]?Math.max(100,Number(a[f+1])):3e3,{elapsed:y,settled:S}=await se({bridge:d,maxMs:i,strict:l});S?console.log(` idle in ${y}ms`):(console.error(` \u26A0 wait idle timed out after ${y}ms (may still be animating)`),process.exit(1))}async function It(o){let{bridge:d,args:a}=o,l=2e4,f=a.indexOf("--max-ms");f>=0&&a[f+1]&&(l=Math.max(100,Number(a[f+1])));let{ready:i,elapsedMs:y,nodes:S}=await Ke(d,l);if(i){console.log(` ready in ${y}ms: ${S} nodes (flag)`);return}console.error(` \u26A0 wait ready timed out after ${y}ms \u2014 guest app did not emit sootsim:externalAppReady (nodes: ${S})`),process.exit(1)}async function _t(o){let{bridge:d,args:a,positional:l,inspectUsage:f}=o,i=l[1];i||(console.error(f("wait selector","<testid> [--max-ms 5000]")),process.exit(1));let y=a.indexOf("--max-ms"),S=y>=0&&a[y+1]?Math.max(100,Number(a[y+1])):5e3,{found:I,node:k,elapsed:b}=await ze(d,i,S);if(I&&k){let v=k.absolutePosition?`@(${Math.round(k.absolutePosition.x)},${Math.round(k.absolutePosition.y)})`:"",_=k.layout?`${Math.round(k.layout.width)}x${Math.round(k.layout.height)}`:"?x?";console.log(` found #${i} in ${b}ms ${_} ${v}`)}else console.error(` \u26A0 wait selector #${i} timed out after ${b??S}ms`),process.exit(1)}function Et(o){return o==null?"\u2014":o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}K`:`${(o/1024/1024).toFixed(1)}M`}function Ct(o){return o==null?" \u2026":o<1e3?`${o}ms`.padStart(5):`${(o/1e3).toFixed(2)}s`.padStart(5)}function io(o){return o.error?"err":o.status==null?" \u2026 ":String(o.status)}function Ft(o){let d=new Date(o.startTs).toLocaleTimeString(),a=io(o).padEnd(3),l=o.method.padEnd(5),f=Et(o.size).padStart(6),i=Ct(o.durationMs);console.log(` [${d}] ${a} ${l} ${f} ${i} ${o.displayUrl}`),o.error&&console.log(` error: ${o.error}`)}function ao(o){let d=[["id",o.id],["source",o.source],["kind",o.kind],["method",o.method],["status",o.error?`error: ${o.error}`:`${o.status??"\u2014"} ${o.statusText??""}`.trim()],["url",o.url],["started",new Date(o.startTs).toLocaleTimeString()],["duration",Ct(o.durationMs).trim()],["size",Et(o.size)],["content-type",o.type??"\u2014"]];for(let[a,l]of d)console.log(` ${a.padEnd(13)} ${l}`)}var lo={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},At="\x1B[0m",co="\x1B[2m";function Pt(o,d){let a=new Date(o.ts).toLocaleTimeString(),l=o.level.toUpperCase().padEnd(5),f=o.args.join(" ");if(d){let i=lo[o.level];console.log(` ${co}[${a}]${At} ${i}${l}${At} ${f}`)}else console.log(` [${a}] ${l} ${f}`);if(o.stack&&o.level==="error"){let i=o.stack.split(`
|
|
82
|
+
`).slice(0,5);for(let y of i)console.log(` ${y.trim()}`)}}var Q="__sootsimCliPerf",uo=120;async function Ot(o,d){let a=o.find((_,T)=>o[T-1]==="--id"),l=o.find((_,T)=>o[T-1]==="--text");if(a||l){let _=await d.send({type:"evaluate",code:je({id:a,text:l})});if(!_)throw new Error(a?`no node with id "${a}"`:`no node matching text "${l}"`);let{x:T,y:C,w:c,h:J}=_;return{x:T,y:C,w:c,h:J}}let f=o.find((_,T)=>o[T-1]==="--area");if(f){let _=f.split(",").map(K=>Number(K.trim()));if(_.length!==4||_.some(K=>!Number.isFinite(K)))throw new Error(`--area expects x,y,w,h (got "${f}")`);let[T,C,c,J]=_;return{x:T,y:C,w:c,h:J}}let i=_=>{let T=o.find((c,J)=>o[J-1]===_);if(T==null)return null;let C=Number(T);return Number.isFinite(C)?C:null},y=i("--x"),S=i("--y"),I=i("--w"),k=i("--h");if(y!=null||S!=null||I!=null||k!=null)return{x:y??0,y:S??0,w:I??1,h:k??1};let v=o.filter((_,T)=>T>0&&!_.startsWith("-")&&o[T-1]!=="--output"&&o[T-1]!=="--area"&&o[T-1]!=="--id"&&o[T-1]!=="--text"&&o[T-1]!=="--x"&&o[T-1]!=="--y"&&o[T-1]!=="--w"&&o[T-1]!=="--h").map(Number).filter(_=>Number.isFinite(_));if(v.length>=2){let[_,T,C=1,c=1]=v;return{x:_,y:T,w:C,h:c}}return null}function Ne(o){let d={"<8":0,"8-12":0,"12-16":0,"16-20":0,"20-33":0,">33":0};for(let a of o)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/o.length*40));console.log(` ${a.padEnd(6)} ${f} ${l}`)}}async function fe(o,d,a){let l=Date.now()+d,f=await ne(o,d);for(;;){if(a(f))return{settled:!0,state:f};if(Date.now()>=l)return{settled:!1,state:f};await X(16),f=await ne(o)}}async function _e(o){return o.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-P45EZ2VW.js";import{a as De,b as Be}from"./chunk-XWHW
|
|
|
111
111
|
frame: runtimeSnapshot?.keyboard?.frame ?? null,
|
|
112
112
|
focusedRect: runtimeSnapshot?.focused?.rect ?? null,
|
|
113
113
|
}
|
|
114
|
-
})()`})}async function
|
|
114
|
+
})()`})}async function mo(o,d=600){let a=Date.now()+d;for(;Date.now()<=a;){let l=await _e(o);if(l.visible)return l;await X(30)}return _e(o)}async function ge(o,d){let a=await _e(o);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 Rt(o,d,a){return d==="appearance"?o.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-P45EZ2VW.js";import{a as De,b as Be}from"./chunk-XWHW
|
|
|
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
|
+
})()`}):o.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
|
|
132
|
-
`),process.exit(0))}if(
|
|
133
|
-
`),process.exit(0))}let t=
|
|
131
|
+
})()`})}function po(o){let d={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(d[o])return d[o];let a=o.match(/^Digit([0-9])$/);if(a)return a[1];let l=o.match(/^Key([A-Z])$/);return l?l[1].toLowerCase():null}function fo(o){if(typeof o!="string")return null;let d=o.replace(/\s+/g," ").trim();return d?d.slice(0,80):null}function Dt(...o){for(let d of o){if(typeof d!="string")continue;let a=d.trim();if(a)return a}return null}async function j(o,d,a){let l=ce({source:o,step:d,summary:a});l.active&&(l.replaced?console.error(` draft: replaced unkept action "${l.replaced.summary}" \u2014 \`flow keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `sootsim flow keep` to commit"))}function go(o,d,a){if(!a||a.hit===!1)return null;let l=Dt(a.responderTestID,a.testID);if(l)return{step:{tapOn:{id:l}},summary:`tap #${l}`};let f=fo(a.text);return f?{step:{tapOn:f},summary:`tap "${f}"`}:{step:{tapAtCoords:{x:o,y:d}},summary:`tap @${Math.round(o)},${Math.round(d)}`}}function Ie(o,d,a){let l=Dt(d?.testID,d?.id);return l?{step:{tapOn:{id:l}},summary:`tap #${l}`}:a==="id"?{step:{tapOn:{id:o}},summary:`tap #${o}`}:{step:{tapOn:o},summary:`tap "${o}"`}}async function Gs(o,d){let a=o[0]==="get"||o[0]==="do"||o[0]==="debug"||o[0]==="wait"?o[0]:null,l=a?o.slice(1):o,f=Oe(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,y=i[0],S=a==="get"||a==="do"||a==="debug"||a==="wait"?a:"inspect",I=typeof l[0]=="string"&&Ae.has(l[0]),k=I?l[0]:null,b=e=>I&&e===l[0]?`sootsim ${e}`:`sootsim ${S} ${e}`,v=(e,t)=>` usage: ${b(e)}${t?` ${t}`:""}`;if(!y||o.includes("--help")||o.includes("-h")){let e={bridgePort:7668,defaultShellUrl:Fe};if(S==="do"||S==="get"||S==="debug"||S==="wait"){let r=be(S,e);r&&(console.log(`${r}
|
|
132
|
+
`),process.exit(0))}if(k==="shell"){let r=we("shell",e);r&&(console.log(`${r}
|
|
133
|
+
`),process.exit(0))}let t=we("inspect",e),s=["do","get","debug","wait"].map(r=>be(r,e)).filter(r=>r!=null).join(`
|
|
134
134
|
|
|
135
135
|
`);console.log(`${t??""}
|
|
136
136
|
|
|
137
|
-
${
|
|
138
|
-
`),process.exit(0)}let _=f.wsPort,T=f.simId,
|
|
139
|
-
`);let
|
|
140
|
-
`)}catch{}}async function
|
|
137
|
+
${s}
|
|
138
|
+
`),process.exit(0)}let _=f.wsPort,T=f.simId,C=f.commandTimeoutMs;if(y==="list"&&l.some(e=>e==="--drivers"||e==="-D")){let{buildDriverListRows:e}=await import("./drivers-YGVUWGMB.js"),t=e();console.log(` available drivers (${t.length}):
|
|
139
|
+
`);let s=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(s),$=n.kind.padEnd(r);console.log(` ${u} ${m} ${$} ${n.description}`),n.available&&n.detail?console.log(` ${n.detail}`):!n.available&&n.reason&&console.log(` unavailable: ${n.reason}`)}return}let c=Re(f),J=T||"default",K=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","list","wait","sleep"]),E=200;function L(e){let t=e.replace(/\s+/g," ").trim();if(!t)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(t)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec(e)?.[1]?.trim(),n=/<body[^>]*>([\s\S]*?)<\//i.exec(e)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),u=r||n||"html error page";return`<html ${e.length}B> "${u}" (body elided \u2014 add --json for the full payload)`}return t.length<=E?t:`${t.slice(0,E)}\u2026 (+${t.length-E} more bytes)`}function z(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 q(e){let t=ft()?1200:350;try{let{settled:s,elapsed:r}=await se({bridge:e,maxMs:t,pollMs:32,stablePolls:2});s||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
|
+
`)}catch{}}async function w(){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
|
|
144
|
-
network: ${
|
|
143
|
+
}))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function M(e={}){let t=e.counts!==void 0?e.counts:await Y(c,"getRequestCounts");if(!t||typeof t!="object")return;let s=Math.max(0,Number(t.failed)||0);if(s===0||!e.includeTail&&!ke("requests",J,String(s))||(console.log(`
|
|
144
|
+
network: ${s} failed request${s===1?"":"s"}`),console.log(` inspect: ${b("requests")} 5`),!e.includeTail))return;let r=await Y(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}] ${
|
|
146
|
+
`);for(let n of r){let u=new Date(n.timestamp).toLocaleTimeString();console.log(` [${u}] ${z(n)}`),n.responseBody?console.log(` ${L(n.responseBody)}`):n.error&&console.log(` ${n.error}`)}}}async function Z(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 s=t,r=Math.max(0,Number(s.errors)||0),n=Math.max(0,Number(s.warnings)||0);if(r===0&&n===0||!e.includeTail&&!ke("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
147
|
console: ${u.join(", ")}`),console.log(` inspect: ${b("errors")} 5`),n>0&&console.log(` inspect: ${b("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 $ of m){let g=new Date($.timestamp).toLocaleTimeString(),x=Array.isArray($.args)?$.args.map(F=>typeof F=="object"?JSON.stringify(F):String(F)).join(" "):String($);console.log(` [${g}] ${x}`)}}}let
|
|
149
|
+
`);for(let $ of m){let g=new Date($.timestamp).toLocaleTimeString(),x=Array.isArray($.args)?$.args.map(F=>typeof F=="object"?JSON.stringify(F):String(F)).join(" "):String($);console.log(` [${g}] ${x}`)}}}let P=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function V(e){let t=Pe(),s=null;try{s=await Ce(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 @@ ${o}
|
|
|
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(!s||!s.summary||!s.summary.total)return;let r=s.summary.byKind??{},n=[],u=new Set;for(let m of P){let $=r[m];if($)if(u.add(m),m==="console"&&s.consoleSplit){let{error:g,warn:x}=s.consoleSplit;g>0&&n.push(`${g} error${g===1?"":"s"}`),x>0&&n.push(`${x} warning${x===1?"":"s"}`)}else n.push(`${$} ${m}${$===1?"":"s"}`)}for(let[m,$]of Object.entries(r))!u.has(m)&&$&&n.push(`${$} ${m}${$===1?"":"s"}`);if(n.length!==0&&(console.log(`
|
|
166
|
+
since last: ${n.join(" \xB7 ")} \u2014 sootsim what-happened`),s.summary.lastAt))try{await xe(e,"SootSim.bridges.timeline.cursorAdvance",t,s.summary.lastAt)}catch{}}let ee=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"]),oe=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"]),ye=(o.includes("--verbose")||o.includes("-v"))&&!o.includes("--json");S==="do"&&y==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),ee.has(y)&&await Ee(c),oe.has(y)&&await de(c,{verbose:ye});try{switch(y){case"list":{await ht({bridge:c,simId:T,args:l});break}case"tree":{await St({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 @@ ${o}
|
|
|
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(o.includes("--json"))console.log(JSON.stringify(t,null,2));else{console.log(` accessibility tree (${t.length} nodes):
|
|
195
|
+
`);for(let s of t){let r=[];if(r.push(`[${s.role}]`),s.label){let n=s.label.length>50?s.label.slice(0,47)+"...":s.label;r.push(`"${n}"`)}if(s.hint&&r.push(`(hint: "${s.hint}")`),s.testID&&r.push(`#${s.testID}`),s.state){let n=[];s.state.disabled&&n.push("disabled"),s.state.selected&&n.push("selected"),s.state.checked===!0&&n.push("checked"),s.state.checked==="mixed"&&n.push("mixed"),s.state.busy&&n.push("busy"),s.state.expanded===!0&&n.push("expanded"),s.state.expanded===!1&&n.push("collapsed"),n.length&&r.push(`{${n.join(", ")}}`)}s.position&&r.push(`@(${s.position.x},${s.position.y})`),s.size&&r.push(`${s.size.w}x${s.size.h}`),console.log(" "+r.join(" "))}}break}case"find":{await gt({bridge:c,args:o,effectiveArgs:l,positional:i,inspectUsage:v});break}case"count":{await mt(c,{args:l});break}case"keyboard":{await yt(c,{json:o.includes("--json")});break}case"screens":{await wt(c,{json:o.includes("--json")});break}case"memory":{await bt(c,{args:l});break}case"wait":{await kt({wsPort:_,commandTimeoutMs:C,simId:T,positional:i});break}case"sleep":{await $t({positional:i,inspectUsage:v});break}case"settle":{await xt({bridge:c,args:o,positional:i});break}case"ready":{await It({bridge:c,args:o});break}case"idle":{await Nt({bridge:c,args:o,positional:i});break}case"selector":{await _t({bridge:c,args:o,positional:i,inspectUsage:v});break}case"event":{await Mt({bridge:c,args:o,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=o.find(($,g)=>o[g-1]==="--output")||"/tmp/sootsim-inspect.png",s=await Ot(o,c),r={type:"screenshot"};s&&(r.crop=s);let u=(await c.send(r)).replace(/^data:image\/png;base64,/,"");s&&console.log(` area: x=${s.x} y=${s.y} w=${s.w} h=${s.h}`),(await import("fs")).writeFileSync(t,Buffer.from(u,"base64")),console.log(` saved: ${t}`);break}case"sample-color":{let e=await Ot(o,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:Le(e)});if(o.includes("--json"))console.log(JSON.stringify(t,null,2));else{let{r:s,g:r,b:n,a:u,hex:m,samples:$}=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(${s}, ${r}, ${n}, ${u}) ${g} ${$} 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 @@ ${o}
|
|
|
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]),s=ae(o);if(s){let u=await me(c,s);u||(console.error(` not found: ${s.value}`),s.mode==="testid"&&G("wait-selector-for-missing-testid",s.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=go(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]),s=Number(i[3]),r=Number(i[4]),n=y==="swipe"?10:12,u=y==="swipe"?8:16,m=i[5]?Number(i[5]):n,$=i[6]?Number(i[6]):u;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(m)||!Number.isFinite($))&&(console.error(v(y,"<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}, ${s}, ${r}, ${Math.max(1,Math.round(m))}, ${Math.max(0,Math.round($))})
|
|
255
255
|
return { ok: !!value, value }
|
|
256
|
-
})()`});if(g?.ok){let x=Math.max(1,Math.round(Math.max(1,m)*Math.max(0,$)));await j(`inspect ${y}`,{swipe:{start:`${e}, ${t}`,end:`${
|
|
256
|
+
})()`});if(g?.ok){let x=Math.max(1,Math.round(Math.max(1,m)*Math.max(0,$)));await j(`inspect ${y}`,{swipe:{start:`${e}, ${t}`,end:`${s}, ${r}`,duration:x}},`${y} ${e},${t} -> ${s},${r}`)}console.log(JSON.stringify(g,null,2));break}case"pinch":{let e=Number(i[1]),t=Number(i[2]),s=Number(i[3]),r=Number(i[4]),n=Number(i[5]),u=Number(i[6]),m=Number(i[7]),$=Number(i[8]),g=i[9]?Number(i[9]):12,x=i[10]?Number(i[10]):16;(!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(s)||!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(u)||!Number.isFinite(m)||!Number.isFinite($)||!Number.isFinite(g)||!Number.isFinite(x))&&(console.error(v("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let F=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}, ${s}, ${r}, ${n}, ${u}, ${m}, ${$}, ${Math.max(1,Math.round(g))}, ${Math.max(0,Math.round(x))})
|
|
260
260
|
return { ok: !!value, value }
|
|
261
|
-
})()`});F?.ok&&await j("inspect pinch",{pinch:{from:[e,t,
|
|
261
|
+
})()`});F?.ok&&await j("inspect pinch",{pinch:{from:[e,t,s,r],to:[n,u,m,$],steps:Math.max(1,Math.round(g)),stepMs:Math.max(0,Math.round(x))}},`pinch (${e},${t}) (${s},${r}) -> (${n},${u}) (${m},${$})`),console.log(JSON.stringify(F,null,2));break}case"tap-text":{let e=i[1];e||(console.error(v("tap-text","<text>")),process.exit(1));let t=R=>{let A=o.indexOf(R);return A>=0&&A+1<o.length?o[A+1]:null},s=R=>o.includes(R),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"),$=s("--exact"),g=s("--first"),x=t("--min-y"),F=t("--max-y"),W=t("--min-x"),H=t("--max-x");for(let[R,A]of[["--min-y",x],["--max-y",F],["--min-x",W],["--max-x",H]])A!==null&&!Number.isFinite(Number(A))&&(console.error(` ${R} requires a number, got: ${A}`),process.exit(1));let U=o.indexOf("--near"),N=null;if(U>=0){let R=Number(o[U+1]),A=Number(o[U+2]);(!Number.isFinite(R)||!Number.isFinite(A))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),N={x:R,y:A}}let h=JSON.stringify({query:e,exact:$,role:m,within:u,minX:W!==null?Number(W):null,maxX:H!==null?Number(H):null,minY:x!==null?Number(x):null,maxY:F!==null?Number(F):null,near:N,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 = ${h}
|
|
@@ -372,7 +372,7 @@ ${o}
|
|
|
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 R=p.candidates;console.error(` ambiguous: ${p.total} matches for "${e}"`);for(let A of R){let
|
|
375
|
+
})()`});if(p?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),p?.ambiguous){let R=p.candidates;console.error(` ambiguous: ${p.total} matches for "${e}"`);for(let A of R){let he=A.abs?`@(${Math.round(A.abs.x)},${Math.round(A.abs.y)})`:"",le=A.layout?` ${A.layout.width}x${A.layout.height}`:"",Bt=A.testID?` #${A.testID}`:"",jt=A.text?` "${A.text}"`:"",Lt=A.ancestorTestIDs.length>0?` within ${A.ancestorTestIDs.slice(0,3).map(Jt=>`#${Jt}`).join(" > ")}`:"";console.error(` [${A.idx}] <${A.type}>${jt}${Bt} ${he}${le}${Lt}`)}p.total>R.length&&console.error(` ... and ${p.total-R.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 R=Ie(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",R.step,R.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),s=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 @@ ${o}
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
return { strategy: 'none' }
|
|
416
|
-
})()`});"error"in
|
|
416
|
+
})()`});"error"in s&&(console.error(` ${s.error}`),process.exit(1)),s.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=s.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 $=Ie(e,{id:r.id,testID:r.testID,type:r.type,cx:n,cy:u},s.strategy==="testid"?"id":"text");await j("inspect tap-best",$.step,$.summary)}console.log(JSON.stringify({matched:{strategy:s.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),s=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 @@ ${o}
|
|
|
448
448
|
},
|
|
449
449
|
strategy: (resolved && resolved.strategy) || 'matched-node',
|
|
450
450
|
}
|
|
451
|
-
})()`});(!
|
|
451
|
+
})()`});(!s||typeof s.cx!="number")&&(console.error(` not found: ${e}`),process.exit(1));let r=await c.send({type:"tap",x:s.cx,y:s.cy});if(r?.hit!==!1&&r?.ok!==!1){let n=Ie(e,{id:s.target?.id??null,testID:s.target?.testID??null,type:s.target?.type??null,cx:s.cx,cy:s.cy},"id");await j("inspect tap-id",n.step,n.summary)}console.log(JSON.stringify({matched:s.match,tapped:{nodeId:s.target?.nodeId??null,id:s.target?.id??null,testID:s.target?.testID??null,type:s.target?.type??null,cx:s.cx,cy:s.cy},...s.strategy&&s.strategy!=="matched-node"?{strategy:s.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 s=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(${s}) || t.findById(${s}))
|
|
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 @@ ${o}
|
|
|
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 mo(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 ge(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 ge(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 ge(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:po(r)})),s=t.filter(r=>!r.key);s.length>0&&(console.error(` unsupported keycode(s): ${s.map(r=>r.code).join(", ")}`),process.exit(1)),await ge(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]),s=ae(o);if(s){let m=await me(c,s);m||(console.error(` not found: ${s.value}`),s.mode==="testid"&&G("wait-selector-for-missing-testid",s.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 @@ ${o}
|
|
|
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]),s=ae(o);if(s){let u=await me(c,s);u||(console.error(` not found: ${s.value}`),s.mode==="testid"&&G("wait-selector-for-missing-testid",s.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]),s=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(s))&&(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(s)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${u}', x: ${t}, y: ${s} } }));`:"",$=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}, ${s}, ${Math.max(1,Math.round(r))})`}
|
|
496
496
|
return { ok: !!value, value }
|
|
497
|
-
})()`});$?.ok&&e!=="cancel"&&await j("inspect touch",{tapAtCoords:{x:t,y:
|
|
497
|
+
})()`});$?.ok&&e!=="cancel"&&await j("inspect touch",{tapAtCoords:{x:t,y:s}},`touch ${e} @${t},${s}`),console.log(JSON.stringify($,null,2));break}case"gesture":{let e=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],t=i[1],s=i[2]?Number(i[2]):220;(!t||!Number.isFinite(s))&&(console.error(v("gesture","<preset> [durationMs]")),console.error(` presets: ${e.join(", ")}`),process.exit(1)),e.includes(t)||(console.error(` unknown gesture preset: ${t}`),console.error(` presets: ${e.join(", ")}`),process.exit(1));let r=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 @@ ${o}
|
|
|
502
502
|
statusBarHeight: spec.statusBarHeight || 0,
|
|
503
503
|
homeIndicatorHeight: spec.homeIndicatorHeight || 0,
|
|
504
504
|
}
|
|
505
|
-
})()`}),n=Number(r?.width)||393,u=Number(r?.height)||852,m=Number(r?.statusBarHeight)||0,$=Number(r?.homeIndicatorHeight)||0,g=Math.round(n/2),x=Math.round(u/2),F=Math.max(24,m+18),
|
|
505
|
+
})()`}),n=Number(r?.width)||393,u=Number(r?.height)||852,m=Number(r?.statusBarHeight)||0,$=Number(r?.homeIndicatorHeight)||0,g=Math.round(n/2),x=Math.round(u/2),F=Math.max(24,m+18),W=Math.max(24,$+18),H=18,U=Math.min(220,Math.round(u*.24)),N=Math.min(180,Math.round(n*.32)),h=g,p=x,O=g,R=x;switch(t){case"scroll-up":p=x+Math.round(U/2),R=x-Math.round(U/2);break;case"scroll-down":p=x-Math.round(U/2),R=x+Math.round(U/2);break;case"scroll-left":h=g+Math.round(N/2),O=g-Math.round(N/2);break;case"scroll-right":h=g-Math.round(N/2),O=g+Math.round(N/2);break;case"swipe-from-left-edge":h=H,p=x,O=Math.min(n-H,H+N);break;case"swipe-from-right-edge":h=n-H,p=x,O=Math.max(H,n-H-N);break;case"swipe-from-top-edge":h=g,p=F,R=Math.min(u-W,F+U);break;case"swipe-from-bottom-edge":h=g,p=u-W,R=Math.max(F,u-W-U);break}let A=Math.max(8,Math.round(s/16)),he=Math.max(1,Math.round(s/A)),le=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
|
-
const value = await interact.drag(${h}, ${p}, ${O}, ${R}, ${A}, ${
|
|
508
|
+
const value = await interact.drag(${h}, ${p}, ${O}, ${R}, ${A}, ${he})
|
|
509
509
|
return { ok: !!value, value }
|
|
510
|
-
})()`});
|
|
510
|
+
})()`});le?.ok&&await j("inspect gesture",{swipe:{start:`${h}, ${p}`,end:`${O}, ${R}`,duration:Math.max(1,Math.round(s))}},`gesture ${t}`),console.log(JSON.stringify({preset:t,from:{x:h,y:p},to:{x:O,y:R},result:le},null,2));break}case"scroll":{let e=ae(o),t=e?.mode==="testid"?e.value:i[1],s=Number(i[e?1:2]),r=Number(i[e?2:3]);(!t||!Number.isFinite(s)||!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,10 +517,10 @@ ${o}
|
|
|
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
|
|
520
|
+
})()`}),u=await Y(c,"scrollTo",t,s,r,!1);u?.ok&&await j("inspect scroll",{scrollTo:{id:t,x:s,y:r}},`scroll ${t} -> ${s},${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 s=await Y(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
|
-
})`});
|
|
523
|
+
})`});s&&typeof s=="object"&&s.diagnostics&&(s.diagnostics.errors=r?.errors??0,s.diagnostics.warnings=r?.warnings??0),console.log(JSON.stringify(s,null,2));break}if(!e||e==="--help"||e==="-h"){console.log(`
|
|
524
524
|
${b("state")} \u2014 dump raw runtime state
|
|
525
525
|
|
|
526
526
|
subcommands:
|
|
@@ -543,7 +543,7 @@ ${o}
|
|
|
543
543
|
${b("state")} scroll feed
|
|
544
544
|
${b("state")} scroll-hit 360 420
|
|
545
545
|
${b("state")} hit 200 720
|
|
546
|
-
`);break}let t;switch(e){case"shell":t=await
|
|
546
|
+
`);break}let t;switch(e){case"shell":t=await ne(c,500);break;case"worker":t=await xe(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') {
|
|
549
549
|
return { error: 'getOwnershipSnapshot not available' }
|
|
@@ -574,7 +574,7 @@ ${o}
|
|
|
574
574
|
text: focused.text || null,
|
|
575
575
|
} : null,
|
|
576
576
|
}
|
|
577
|
-
})()`});break;case"node":{let
|
|
577
|
+
})()`});break;case"node":{let s=i[2];s||(console.error(` usage: ${b("state")} node <id>`),process.exit(1)),t=await Y(c,"findByTestId",s)||await Y(c,"findById",s);break}case"scroll":{let s=i[2];s||(console.error(` usage: ${b("state")} scroll <id>`),process.exit(1)),t=await Y(c,"getScrollState",s);break}case"scroll-hit":{let s=Number(i[2]),r=Number(i[3]);(!Number.isFinite(s)||!Number.isFinite(r))&&(console.error(` usage: ${b("state")} scroll-hit <x> <y>`),process.exit(1)),t=await Y(c,"getScrollStateAt",s,r);break}case"hit":{let s=Number(i[2]),r=Number(i[3]);(!Number.isFinite(s)||!Number.isFinite(r))&&(console.error(` usage: ${b("state")} hit <x> <y>`),process.exit(1)),t=await Y(c,"debugHitAt",s,r);break}case"gesture":{let s=Number(i[2]),r=Number(i[3]);(!Number.isFinite(s)||!Number.isFinite(r))&&(console.error(` usage: ${b("state")} gesture <x> <y>`),process.exit(1)),t=await Y(c,"debugGestureAt",s,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
578
|
${b("shell")} \u2014 run built-in shell commands
|
|
579
579
|
|
|
580
580
|
subcommands:
|
|
@@ -598,7 +598,7 @@ ${o}
|
|
|
598
598
|
${b("shell")} open-card clock 800
|
|
599
599
|
${b("shell")} appearance dark
|
|
600
600
|
${b("shell")} lock
|
|
601
|
-
`);break}let t=e==="launch"||e==="open-card"||e==="home"||e==="switcher",
|
|
601
|
+
`);break}let t=e==="launch"||e==="open-card"||e==="home"||e==="switcher",s=e==="launch"||e==="open-card"?i[3]:i[2],r=s?Number(s):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,$=o.includes("--clear-state");if(e==="launch"){let g=i[2];g||(console.error(v("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),$&&await c.send({type:"evaluate",code:De}),n=!!await re(c,"launchApp",r,g),{settled:u,state:m}=await fe(c,Math.round(r),x=>!!x&&x.state==="app"&&x.activeApp===g&&x.showSwitcher===!1&&x.switcherPhase==="idle"&&typeof x.launchProgress=="number"&&x.launchProgress>=.98),n&&await j("inspect shell launch",$?{launchApp:{clearState:!0}}:{launchApp:{}},$?"launch app (clear state)":"launch app")}else if(e==="home")n=!!await re(c,"goHome",r),{settled:u,state:m}=await fe(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 re(c,"openSwitcher",r),{settled:u,state:m}=await fe(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(uo),m=await ne(c));else if(e==="open-card"){let g=i[2];g||(console.error(v("shell","open-card <appId> [settleMs]")),process.exit(1)),n=!!await re(c,"openSwitcherCard",r,g),{settled:u,state:m}=await fe(c,Math.round(r),x=>!!x&&x.state==="app"&&x.activeApp===g&&x.showSwitcher===!1&&x.switcherPhase==="idle"&&typeof x.zoomLevel=="number"&&x.zoomLevel>=.98&&typeof x.horizontalZoom=="number"&&x.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 x=await Rt(c,"appearance",g);if(n=!!x?.ok,m={appearance:x},n){let F=x?.applied??g;console.log(` appearance: ${F}`)}}else if(e==="lock"||e==="shake"){let g=await Rt(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 vt(c,{args:l});break}case"reload":{let s=!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 @@ ${o}
|
|
|
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",s=!0}catch{}console.log(" reloading...");let n=c,u=null;if(r)u=await ve(c,{timeoutMs:1e4,errorGraceMs:3e3});else{s&&await X(300);let m=await it(_,C,T,{timeoutMs:1e4});m?(n=m,u=await ve(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 $ of m){let g=$.args.map(x=>typeof x=="object"?JSON.stringify(x):x).join(" ");if(console.log(` ${g}`),$.stack){let x=$.stack.split(`
|
|
612
|
-
`).slice(0,2);for(let F of x)console.log(` ${F.trim()}`)}}}}catch{}u&&!u.ready&&(process.exitCode=1);break}case"eval":case"js":{let e=i.slice(1).join(" ");e||(console.error(
|
|
612
|
+
`).slice(0,2);for(let F of x)console.log(` ${F.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(` ${b("js")} SootSim.bridges.test.findByText("Sign in")`),console.error(` ${b("js")} SootSim.bridges.debug.snapshot("before")`),console.error(` ${b("js")} SootSim.bridges.keyboard.type("hello")`),console.error(` ${b("js")} SootSim.state.root.children.length`),process.exit(1));let t=e;t.startsWith("(async")||(t=`(async () => ${t})()`);let s=await c.send({type:"evaluate",code:t});console.log(JSON.stringify(s,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,7 +647,7 @@ ${o}
|
|
|
647
647
|
|
|
648
648
|
return globals
|
|
649
649
|
})()`});console.log(` sootsim JS API:
|
|
650
|
-
`);for(let[t,
|
|
650
|
+
`);for(let[t,s]of Object.entries(e)){console.log(` ${t}:`);for(let r of s)console.log(` .${r}`);console.log("")}console.log(` use: ${b("js")} <expression>`),console.log(` example: ${b("js")} test.findByText("Sign in")`);break}case"describe":{await pt({bridge:c,args:o,positional:i});break}case"perf":{let e=i[1];if(!e||e==="--help"||e==="-h"){console.log(`
|
|
651
651
|
${b("perf")} \u2014 performance profiling
|
|
652
652
|
|
|
653
653
|
subcommands:
|
|
@@ -688,7 +688,7 @@ ${o}
|
|
|
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 s=t.avgMs!=="?"?(1e3/parseFloat(t.avgMs)).toFixed(1):"?";console.log(" perf stats:"),console.log(` frames: ${t.frames}`),console.log(` avg: ${t.avgMs}ms (${s} 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()
|
|
@@ -804,8 +804,8 @@ ${o}
|
|
|
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 s=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 (${s} 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 s=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 @@ ${o}
|
|
|
840
840
|
mode: 'main-thread',
|
|
841
841
|
frames: (stats.recentFrames || []).slice(-${t}),
|
|
842
842
|
}
|
|
843
|
-
})()`});if(
|
|
843
|
+
})()`});if(s.error&&(console.error(` error: ${s.error}`),process.exit(1)),s.mode==="render-worker"){let n=Array.isArray(s.samples)?s.samples:[];if(n.length===0){console.log(` no frame data \u2014 run '${b("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,$,g,x,F,W]of n)console.log(` ${m.toFixed(2).padStart(7)} ${$.toFixed(2).padStart(7)} ${g.toFixed(2).padStart(7)} ${x.toFixed(2).padStart(7)} ${F.toFixed(2).padStart(6)} ${W.toFixed(2).padStart(7)} ${String(u).padStart(5)}`);console.log(""),Ne(n.map(u=>u[1])),s.live&&console.log(" sampling continues");break}let r=Array.isArray(s.frames)?s.frames:Array.isArray(s)?s:[];if(r.length===0){console.log(` no frame data \u2014 run '${b("perf")} start' first`);break}console.log(` last ${r.length} frame times (ms):`),console.log(` ${r.map(n=>n.toFixed(2)).join(", ")}`),Ne(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 s=await c.send({type:"evaluate",code:`(async () => {
|
|
844
844
|
if (window.__sootsimRenderHost) {
|
|
845
845
|
const session = window.${Q} || {}
|
|
846
846
|
if (session.active) {
|
|
@@ -882,7 +882,7 @@ ${o}
|
|
|
882
882
|
mode: 'main-thread',
|
|
883
883
|
frames: recent.slice().sort((a, b) => b - a).slice(0, ${t}),
|
|
884
884
|
}
|
|
885
|
-
})()`});if(
|
|
885
|
+
})()`});if(s.error&&(console.error(` error: ${s.error}`),process.exit(1)),s.mode==="render-worker"){let n=Array.isArray(s.samples)?s.samples:[];if(n.length===0){console.log(` no frame data \u2014 run '${b("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,$,g,x,F,W]of n)console.log(` ${m.toFixed(2).padStart(7)} ${$.toFixed(2).padStart(7)} ${g.toFixed(2).padStart(7)} ${x.toFixed(2).padStart(7)} ${F.toFixed(2).padStart(6)} ${W.toFixed(2).padStart(7)} ${String(u).padStart(5)}`);s.live&&(console.log(""),console.log(" sampling continues"));break}let r=Array.isArray(s.frames)?s.frames:Array.isArray(s)?s:[];if(r.length===0){console.log(` no frame data \u2014 run '${b("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
886
|
${b("perf")} transition <event> \u2014 profile a shell transition
|
|
887
887
|
|
|
888
888
|
events:
|
|
@@ -972,24 +972,27 @@ ${o}
|
|
|
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(""),
|
|
976
|
-
`);for(let r of
|
|
977
|
-
`).slice(0,3);for(let $ of m)console.log(` ${$.trim()}`)}}break}case"warnings":{let e=i[1]?Number(i[1]):20,t=await
|
|
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}] ${
|
|
975
|
+
jank: ${n.jankFrames} frames (${m}%) >16.67ms`),Array.isArray(n.samples)&&n.samples.length>0&&(console.log(""),Ne(n.samples.map($=>$[1])));break}default:console.error(` unknown perf subcommand: ${e}`),process.exit(1)}break}case"errors":{let e=i[1];if(e==="clear"){await Xe(c),D(l)?B({cleared:!0}):console.log(" error buffer cleared");break}let t=e?Number(e):20,s=await Ye(c,t);if(D(l)){B(s);break}if(s.length===0){console.log(" no errors captured");break}console.log(` ${s.length} error(s):
|
|
976
|
+
`);for(let r of s){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
|
+
`).slice(0,3);for(let $ of m)console.log(` ${$.trim()}`)}}break}case"warnings":{let e=i[1]?Number(i[1]):20,t=await Ge(c,e);if(D(l)){B(t);break}if(t.length===0){console.log(" no warnings captured");break}console.log(` ${t.length} warning(s):
|
|
978
|
+
`);for(let s of t){let r=new Date(s.timestamp).toLocaleTimeString(),n=s.args.map(u=>typeof u=="object"?JSON.stringify(u):u).join(" ");console.log(` [${r}] ${n}`)}break}case"animations":{let e=await Y(c,"listAnimations")??[];if(o.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 s=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`,$=t.loop?" loop":"",g=t.layoutBound?" layout":"";console.log(` #${t.id} ${s} ${r.padEnd(14)} cur=${n.padEnd(7)} ${u.padStart(4)} ${m}${$}${g}`)}break}case"animation":{let e=i[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${b("animation")} <id>`),process.exit(1));let t=Number(e);Number.isFinite(t)||(console.error(` invalid id: ${e}`),process.exit(1));let s=await Y(c,"getAnimation",t);console.log(JSON.stringify(s,null,2));break}case"stop-animation":{let e=i[1];(!e||e==="--help"||e==="-h")&&(console.error(` usage: ${b("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 s=await Y(c,"stopAnimation",t);console.log(` stopped ${s??0} animation(s)`);break}case"requests":{let e=i[1];if(e==="clear"){await Qe(c),D(l)?B({cleared:!0}):console.log(" request buffer cleared");break}let t=e==="all",s=t?i[2]:e,r=s?Number(s):20,n=await Ve(c,{failed:!t,limit:r});if(D(l)){B(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}] ${z(u)}`),u.responseBody?console.log(` ${u.responseBody}`):u.error&&console.log(` ${u.error}`)}break}case"network":{let e=i[1],t=null,s=null,r=!1,n=!1,u=1e3,m=!1,$=!1;for(let N=0;N<l.length;N++){let h=l[N];if(h==="--filter")t=l[N+1]??null,N++;else if(h==="--limit"){let p=Number(l[N+1]);Number.isFinite(p)&&(s=p),N++}else if(h==="--threshold"){let p=Number(l[N+1]);Number.isFinite(p)&&p>0&&(u=p),N++}else h==="--failed"?r=!0:h==="--slow"?n=!0:h==="--tail"||h==="-f"?m=!0:h==="--json"&&($=!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 N=i[2];N||(console.error(" usage: sootsim network get <id>"),process.exit(1));let h=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(N)}) || null;
|
|
984
|
-
})()`});h||(console.error(` no entry with id ${N}`),process.exit(1)),$?console.log(JSON.stringify(h,null,2)):
|
|
984
|
+
})()`});h||(console.error(` no entry with id ${N}`),process.exit(1)),$?console.log(JSON.stringify(h,null,2)):ao(h);break}let g=s??(m?200:e?Number(e):20);Number.isFinite(g)||(console.error(` invalid limit: ${e} \u2014 \`network\` takes a numeric count (e.g. ${b("network")} 100).
|
|
985
985
|
to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let x=async()=>{let N=await c.send({type:"evaluate",code:`(() => {
|
|
986
986
|
const obs = window.__sootsimObservability;
|
|
987
987
|
if (!obs) return { ok: false };
|
|
988
988
|
return { ok: true, entries: obs.network.getSnapshot() };
|
|
989
989
|
})()`});if(!N||!N.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return N.entries??[]},F=N=>{let h=N;if(r&&(h=h.filter(p=>!!p.error||p.status!=null&&p.status>=400)),n&&(h=h.filter(p=>p.durationMs!=null&&p.durationMs>=u)),t){let p=t.toLowerCase();h=h.filter(O=>(O.displayUrl||O.url).toLowerCase().includes(p))}return n&&!m&&(h=[...h].sort((p,O)=>(O.durationMs??0)-(p.durationMs??0))),h};if(!m){let N=await x(),h=F(N).slice(-g);if($){console.log(JSON.stringify(h,null,2));break}if(h.length===0){N.length===0?console.log(" no network requests captured"):console.log(n?` no requests slower than ${u}ms (${N.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(n?` ${h.length} request(s) slower than ${u}ms (sorted by duration desc):
|
|
990
990
|
`:` ${h.length} request(s):
|
|
991
|
-
`);for(let p of h)
|
|
992
|
-
`);let
|
|
993
|
-
to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let F=()=>
|
|
994
|
-
`);for(let O of p)
|
|
995
|
-
`);let H=new Set,
|
|
991
|
+
`);for(let p of h)Ft(p);break}console.log(` tailing network (ctrl-c to stop)...
|
|
992
|
+
`);let W=new Set,H=!0,U=()=>{H=!1};process.on("SIGINT",U);try{for(;H;){let N=await x(),h=F(N);for(let p of h)p.durationMs!=null&&(W.has(p.id)||(W.add(p.id),$?console.log(JSON.stringify(p)):Ft(p)));await X(250)}}finally{process.off("SIGINT",U)}break}case"logs":{let e=i[1],t=null,s=null,r=null,n=!1,u=!1,m=!1;for(let h=0;h<l.length;h++){let p=l[h];if(p==="--filter")t=l[h+1]??null,h++;else if(p==="--limit"){let O=Number(l[h+1]);Number.isFinite(O)&&(s=O),h++}else p==="--level"?(r=l[h+1]??null,h++):p==="--tail"||p==="-f"?n=!0:p==="--json"?u=!0:(p==="--internal"||p==="--all")&&(m=!0)}let $=r?new Set(r.split(",").map(h=>h.trim()).filter(h=>h==="log"||h==="info"||h==="warn"||h==="error"||h==="debug")):null;if(e==="clear"){await et(c),console.log(" log buffer cleared");break}let g=!u&&process.stdout.isTTY===!0,x=s??(n?500:e?Number(e):50);Number.isFinite(x)||(console.error(` invalid limit: ${e} \u2014 \`logs\` takes a numeric count (e.g. ${b("logs")} 100).
|
|
993
|
+
to target a specific sim, use \`--sim ${e}\` instead.`),process.exit(1));let F=()=>Ze(c),W=h=>tt(h,{level:$,filter:t,showInternal:m});if(!n){let h=await F(),p=W(h).slice(-x);if(u){console.log(JSON.stringify(p,null,2));break}if(p.length===0){console.log(h.length===0?" no logs captured":" no matching logs");break}console.log(` ${p.length} log(s):
|
|
994
|
+
`);for(let O of p)Pt(O,g);break}console.log(` tailing logs (ctrl-c to stop)...
|
|
995
|
+
`);let H=new Set,U=!0,N=()=>{U=!1};process.on("SIGINT",N);try{for(;U;){let h=await F(),p=W(h);for(let O of p)H.has(O.id)||(H.add(O.id),u?console.log(JSON.stringify(O)):Pt(O,g));await X(250)}}finally{process.off("SIGINT",N)}break}default:console.error(` unknown subcommand: ${y}`),process.exit(1)}if(ee.has(y)&&!o.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&await q(c),!K.has(y)&&!D(l))try{await V(c)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e);console.error(` ${y??"inspect"} failed: ${t}`);let s=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after \d+s$/.test(t)||t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(s)await lt(c,_,s[1]);else if(/^no sim connected$/.test(t))at(_);else if(r)process.stderr.write(` the sim is not responding. recover it with:
|
|
996
|
+
sootsim close --sim <id> # force-close the wedged sim
|
|
997
|
+
sootsim list # confirm it's gone
|
|
998
|
+
`);else{try{await Be(c)}catch{}try{await Z({includeTail:!0})}catch{}try{await M({includeTail:!0})}catch{}}process.exit(1)}finally{c.close()}}export{Gs as runInspect};
|