sootsim 0.1.236 → 0.1.238
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 +4 -4
- package/dist-cli/chunks/{agent-CU7Q5K22.js → agent-VQVLJBBZ.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-FCUDUV52.js → agent-wrapper-ABFE7KJQ.js} +2 -2
- package/dist-cli/chunks/{app-fonts-SPA6U6OA.js → app-fonts-ODI2DJ7C.js} +2 -2
- package/dist-cli/chunks/{assert-MZVVW7DV.js → assert-ZXNN3U2C.js} +2 -2
- package/dist-cli/chunks/{auth-FV3CIFG6.js → auth-LMHWH6T3.js} +2 -2
- package/dist-cli/chunks/beta-TN34R6YC.js +2 -0
- package/dist-cli/chunks/{camera-ALWQVYHU.js → camera-VWTIE3VW.js} +2 -2
- package/dist-cli/chunks/{chunk-BDL6UO36.js → chunk-2FFZXFDY.js} +1 -1
- package/dist-cli/chunks/{chunk-VKJ4BFFU.js → chunk-2PFG3UHP.js} +2 -2
- package/dist-cli/chunks/{chunk-GB3IT6AN.js → chunk-3KVQ35TN.js} +1 -1
- package/dist-cli/chunks/{chunk-QPZYFSTW.js → chunk-4DN5YMPS.js} +1 -1
- package/dist-cli/chunks/{chunk-RBDWTH6O.js → chunk-4DPHH2DS.js} +2 -2
- package/dist-cli/chunks/{chunk-IQ2IFKZ4.js → chunk-54XALXOI.js} +2 -2
- package/dist-cli/chunks/{chunk-UGRYC3HL.js → chunk-5MFTB3S4.js} +1 -1
- package/dist-cli/chunks/{chunk-5E24H5Z5.js → chunk-5MQZW32V.js} +2 -2
- package/dist-cli/chunks/{chunk-NX4NOT7Z.js → chunk-6KMMJDSE.js} +1 -1
- package/dist-cli/chunks/{chunk-G3EZ5KVE.js → chunk-6PYVHZVH.js} +1 -1
- package/dist-cli/chunks/{chunk-PUH4S4CC.js → chunk-6UMCNLKY.js} +2 -2
- package/dist-cli/chunks/{chunk-RGDT3EBF.js → chunk-7OQU5M3J.js} +2 -2
- package/dist-cli/chunks/{chunk-TB7CIKZ3.js → chunk-A46S76WN.js} +2 -2
- package/dist-cli/chunks/{chunk-7NCUVJSZ.js → chunk-CDAMSEOW.js} +34 -34
- package/dist-cli/chunks/{chunk-V5LQP2JL.js → chunk-CGQTOBHQ.js} +141 -115
- package/dist-cli/chunks/{chunk-APQFVJDK.js → chunk-CU7M5IBW.js} +1 -1
- package/dist-cli/chunks/{chunk-BGW73A3C.js → chunk-CXV3CSSF.js} +2 -2
- package/dist-cli/chunks/{chunk-SXENH4HF.js → chunk-D5LYVGSE.js} +3 -3
- package/dist-cli/chunks/{chunk-KWNVZ2LX.js → chunk-DMSG7ESJ.js} +1 -1
- package/dist-cli/chunks/{chunk-BA4Q3KRH.js → chunk-ECCUSCHO.js} +2 -2
- package/dist-cli/chunks/{chunk-3PLNSSEF.js → chunk-EGRRMDLA.js} +1 -1
- package/dist-cli/chunks/{chunk-I664RIMB.js → chunk-GI4YPHU6.js} +2 -2
- package/dist-cli/chunks/{chunk-Q2X3WO5X.js → chunk-HC6JXVIP.js} +2 -2
- package/dist-cli/chunks/{chunk-T7KUJUST.js → chunk-HTTHCQQS.js} +3 -3
- package/dist-cli/chunks/{chunk-4Z3JQFES.js → chunk-IHEPAACR.js} +1 -1
- package/dist-cli/chunks/{chunk-7KGIZCO3.js → chunk-KGAN3JXK.js} +2 -2
- package/dist-cli/chunks/{chunk-DKGKL6KP.js → chunk-LYSW5PTM.js} +2 -2
- package/dist-cli/chunks/{chunk-DUCTVOTV.js → chunk-MD5GBDM4.js} +1 -1
- package/dist-cli/chunks/{chunk-PEFAS7Q4.js → chunk-MT2HMCDI.js} +2 -2
- package/dist-cli/chunks/{chunk-ORSIJ76W.js → chunk-NCJGR7VZ.js} +1 -1
- package/dist-cli/chunks/{chunk-VQKTMX3M.js → chunk-OHLPCYOM.js} +1 -1
- package/dist-cli/chunks/chunk-QAKSIRZO.js +1 -0
- package/dist-cli/chunks/{chunk-54UQB2TW.js → chunk-QGCNRLCM.js} +2 -2
- package/dist-cli/chunks/{chunk-SACUEZZP.js → chunk-QGFPGXNJ.js} +1 -1
- package/dist-cli/chunks/{chunk-W7H4OAY4.js → chunk-RTMLR7KA.js} +2 -2
- package/dist-cli/chunks/{chunk-HBQ7CCHG.js → chunk-SCLKEUCN.js} +1 -1
- package/dist-cli/chunks/chunk-UV4NF53M.js +1 -0
- package/dist-cli/chunks/{chunk-EURBYQXU.js → chunk-UYFE2VRP.js} +2 -2
- package/dist-cli/chunks/{chunk-6ALJUG36.js → chunk-VTY35NKD.js} +4 -4
- package/dist-cli/chunks/{chunk-VRXFBWBW.js → chunk-XOKMWX3P.js} +2 -2
- package/dist-cli/chunks/chunk-XUOCSWW4.js +118 -0
- package/dist-cli/chunks/{chunk-PGLRJ4GA.js → chunk-XWGGIFDB.js} +35 -12
- package/dist-cli/chunks/{chunk-FK57ISRW.js → chunk-YK4NG4BL.js} +1 -1
- package/dist-cli/chunks/{chunk-G3MVPZBK.js → chunk-YNSDDYLM.js} +2 -2
- package/dist-cli/chunks/cli-version-JMIF5EGD.js +2 -0
- package/dist-cli/chunks/{compat-JCUMIY6N.js → compat-JZPFXICF.js} +3 -3
- package/dist-cli/chunks/{config-3RHULBQA.js → config-UL7HLQDC.js} +2 -2
- package/dist-cli/chunks/{control-NZJHUGDA.js → control-QKU5C5S2.js} +2 -2
- package/dist-cli/chunks/daemon-IREYS2N7.js +2 -0
- package/dist-cli/chunks/{debug-FXTGTIA4.js → debug-H5DH3AQF.js} +3 -3
- package/dist-cli/chunks/{desktop-4Z3DFJZ3.js → desktop-6KNJHXC3.js} +3 -3
- package/dist-cli/chunks/{detox-ZHVRCYVV.js → detox-GGHGQ4ZT.js} +2 -2
- package/dist-cli/chunks/{device-B7RJOTO2.js → device-BRDNCJVC.js} +2 -2
- package/dist-cli/chunks/{diagnose-TWMUMITQ.js → diagnose-YYUH2HKW.js} +2 -2
- package/dist-cli/chunks/drivers-IHDBZZUB.js +2 -0
- package/dist-cli/chunks/{film-DGR6ALQ2.js → film-ZCOJKWH3.js} +3 -3
- package/dist-cli/chunks/flow-TXWXTHAY.js +2 -0
- package/dist-cli/chunks/help-TAORLP73.js +2 -0
- package/dist-cli/chunks/{hidden-runtime-alias-XM5Z6GME.js → hidden-runtime-alias-FKPQZHNW.js} +2 -2
- package/dist-cli/chunks/{home-paths-BVXLMDUT.js → home-paths-XVONOHWM.js} +2 -2
- package/dist-cli/chunks/inspect-ALJUDST3.js +2 -0
- package/dist-cli/chunks/install-desktop-W5JGGPCV.js +2 -0
- package/dist-cli/chunks/{login-CTAICT4D.js → login-4DXNKRVF.js} +4 -4
- package/dist-cli/chunks/{logout-X4T57OXG.js → logout-ARENLQQ5.js} +2 -2
- package/dist-cli/chunks/{maestro-ZQYSFWKY.js → maestro-G7VNKI32.js} +3 -3
- package/dist-cli/chunks/{maestro-generate-Y25ETFOO.js → maestro-generate-U3YRKKPN.js} +3 -3
- package/dist-cli/chunks/{mode-KBQ2HTV2.js → mode-FNLKDZKM.js} +2 -2
- package/dist-cli/chunks/optional-demo-registry-Y5KQWQ6V.js +2 -0
- package/dist-cli/chunks/{perf-MRGDCXKC.js → perf-C3O4QGRB.js} +11 -8
- package/dist-cli/chunks/{record-6JMMR3DI.js → record-YEOZEOTK.js} +3 -3
- package/dist-cli/chunks/runtime-VCWHZCYU.js +2 -0
- package/dist-cli/chunks/{screenshot-command-SEHNB5PW.js → screenshot-command-CCVMBNZ7.js} +3 -3
- package/dist-cli/chunks/{screenshots-capture-GAZMPQ2T.js → screenshots-capture-GIVPWSQG.js} +2 -2
- package/dist-cli/chunks/{serve-HQAJCUJP.js → serve-KYU7THWX.js} +2 -2
- package/dist-cli/chunks/{setup-A3PIKOJA.js → setup-OQ7EMGIY.js} +3 -3
- package/dist-cli/chunks/{skills-4522XNAV.js → skills-Z25AHTRM.js} +2 -2
- package/dist-cli/chunks/{storage-VC4FO3X4.js → storage-EDYGSOMU.js} +2 -2
- package/dist-cli/chunks/store-BP3EICTQ.js +2 -0
- package/dist-cli/chunks/telemetry-K2S6RLSW.js +2 -0
- package/dist-cli/chunks/{timeline-AU6ZXEJY.js → timeline-FTAZATIZ.js} +2 -2
- package/dist-cli/chunks/{upgrade-M5V7P7HI.js → upgrade-JBRL4AHX.js} +2 -2
- package/dist-cli/chunks/upload-JVFQZS5Z.js +2 -0
- package/dist-cli/chunks/{version-BIWUB3OU.js → version-H6PRWWUE.js} +2 -2
- package/dist-cli/chunks/{web-Y2HUWQL6.js → web-D45A6FKK.js} +2 -2
- package/dist-cli/chunks/{what-happened-TTM4T2XG.js → what-happened-A7IDSBXP.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +2 -2
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +2 -2
- 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/beta.cjs +1 -1
- package/dist-lib/beta.mjs +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/detox/index.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 +2 -2
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +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/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +32 -4
- package/dist-lib/sdk.mjs +32 -4
- package/dist-lib/skills.cjs +28 -4
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/skills/contrast/SKILL.md +1 -1
- package/src/agent-sessions.ts +4 -5
- package/src/vite-plugin.ts +3 -6
- package/dist-cli/chunks/beta-7X7N2CB2.js +0 -2
- package/dist-cli/chunks/chunk-6NWVRY7I.js +0 -1
- package/dist-cli/chunks/chunk-LBXFCH5I.js +0 -118
- package/dist-cli/chunks/chunk-ZYEIV7ZN.js +0 -1
- package/dist-cli/chunks/cli-version-457KT7IL.js +0 -2
- package/dist-cli/chunks/daemon-4WYYSXCN.js +0 -2
- package/dist-cli/chunks/drivers-AK6KP6X4.js +0 -2
- package/dist-cli/chunks/flow-RYMDNC4V.js +0 -2
- package/dist-cli/chunks/help-JVO6L7HS.js +0 -2
- package/dist-cli/chunks/inspect-TBOCLFLQ.js +0 -2
- package/dist-cli/chunks/install-desktop-N6IVQZBG.js +0 -2
- package/dist-cli/chunks/optional-demo-registry-G6FLEREA.js +0 -2
- package/dist-cli/chunks/runtime-3EJHJAAM.js +0 -2
- package/dist-cli/chunks/store-Y6DYP7EA.js +0 -2
- package/dist-cli/chunks/telemetry-3M5Y7GDR.js +0 -2
- package/dist-cli/chunks/upload-F47SYC4Y.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as ce}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.238 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as ce}from"./chunk-UYFE2VRP.js";import{b as Et,c as Pt,k as Rt}from"./chunk-A46S76WN.js";import{a as oe,b as A,c as D,d as Ie,e as ie,f as X,g as de,h as ye,i as Mt,j as Ft,k as Te,l as Ot}from"./chunk-54XALXOI.js";import{A as wt,B as $t,E as xt,G as St,I as ue,J as vt,P as We,a as ke,b as nt,c as rt,d as it,e as at,f as lt,g as ct,h as ut,i as dt,j as pt,k as Be,l as Ce,q as je,r as mt,s as ft,t as fe,u as gt,v as _e,w as Le,x as yt,y as ht,z as bt}from"./chunk-XWGGIFDB.js";import{e as kt,g as _t,i as It,j as Tt,k as Nt,l as ge}from"./chunk-CXV3CSSF.js";import{a as tt}from"./chunk-QGFPGXNJ.js";import{a as Q}from"./chunk-RTMLR7KA.js";import{c as ot}from"./chunk-6PYVHZVH.js";import{c as st}from"./chunk-NCJGR7VZ.js";import{c as Ae,e as De}from"./chunk-XUOCSWW4.js";function qe(e){return`(async () => {
|
|
3
3
|
const bridge = globalThis.SootSim && globalThis.SootSim.bridges && globalThis.SootSim.bridges.hotRemount
|
|
4
4
|
if (!bridge || typeof bridge.reloadExternalApp !== 'function') return false
|
|
5
5
|
await bridge.reloadExternalApp({ resetStorage: ${e?"true":"false"} })
|
|
@@ -71,14 +71,14 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
71
71
|
deviceWidth: __w / __dpr,
|
|
72
72
|
deviceHeight: __h / __dpr,
|
|
73
73
|
}
|
|
74
|
-
})()`}import{existsSync as
|
|
75
|
-
`)}function Ge(){let e=Me();if(!
|
|
76
|
-
`}function Cs(e){let o=Ge();if(!o)return{active:!1};let s=Co(o.steps),
|
|
77
|
-
`)}function Zo(e,o){let s=o.trim()||"default";return`${e}:${s}`}function
|
|
74
|
+
})()`}import{existsSync as Po,mkdirSync as Ct,readFileSync as Ro,rmSync as He,writeFileSync as jt}from"fs";import{tmpdir as Ao}from"os";import{dirname as Lt,join as Do,resolve as Wt}from"path";import*as Ne from"fs";function Eo(e){let o={},s=e,i=p=>Array.isArray(p)?p:[],u=e.match(/^---\n([\s\S]*?)\n---\n?/);if(u){try{o=ce.parse(u[1])??{}}catch(y){console.warn(` warn: could not parse frontmatter: ${y.message}`)}s=e.slice(u[0].length);let p=ce.parse(s);return{frontmatter:o,steps:i(p)}}if(/\n---\s*\n/.test(e))try{let p=ce.parseAllDocuments(e);if(p.length>=2){let y=p[0].toJS(),g=p[p.length-1].toJS();return{frontmatter:y&&typeof y=="object"?y:{},steps:i(g)}}}catch(p){console.warn(` warn: could not parse multi-doc flow: ${p.message}`)}let l=ce.parse(s);return{frontmatter:o,steps:i(l)}}var Bt=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function Je(e){let o=[];if(!Array.isArray(e)||e.length===0)return o.push("flow body must be a non-empty YAML array of steps"),o;let s=0;for(let i of e)i&&typeof i=="object"?Object.keys(i).some(l=>Bt.has(l))&&(s+=1):typeof i=="string"&&Bt.has(i)&&(s+=1);return s===0&&o.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),o}function Ns(e){if(!Ne.existsSync(e))return[`file not found: ${e}`];let o;try{o=Ne.readFileSync(e,"utf8")}catch(s){return[`cannot read file: ${s.message}`]}if(o.trim().length===0)return["file is empty"];try{let s=Eo(o);return Je(s.steps)}catch(s){return[`yaml parse error: ${s.message}`]}}var Ke=1;function Me(){return Wt(process.env.SOOTSIM_FLOW_SESSION_PATH||Do(Ao(),"sootsim-flow-session.json"))}function Ue(e){let o=Me();Ct(Lt(o),{recursive:!0}),jt(o,JSON.stringify(e,null,2)+`
|
|
75
|
+
`)}function Ge(){let e=Me();if(!Po(e))return null;try{let o=JSON.parse(Ro(e,"utf8"));return o.version!==Ke||!Array.isArray(o.steps)||typeof o.startedAt!="string"||typeof o.updatedAt!="string"?(He(e,{force:!0}),null):{version:Ke,startedAt:o.startedAt,updatedAt:o.updatedAt,steps:o.steps,candidate:o.candidate??null}}catch{return He(e,{force:!0}),null}}function As(){let e=new Date().toISOString(),o={version:Ke,startedAt:e,updatedAt:e,steps:[],candidate:null};return Ue(o),{path:Me(),state:o}}function Bo(){He(Me(),{force:!0})}function Ds(){Bo()}function Fe(e){let o=Ge();if(!o)return{active:!1};let s=o.candidate,i={...o,updatedAt:new Date().toISOString(),candidate:{step:e.step,summary:e.summary,source:e.source,recordedAt:new Date().toISOString()}};return Ue(i),{active:!0,candidate:i.candidate,replaced:s}}function Bs(){let e=Ge();if(!e)return{active:!1,kept:!1,reason:"no-session"};if(!e.candidate)return{active:!0,kept:!1,reason:"no-candidate"};let o=e.candidate,s={...e,updatedAt:new Date().toISOString(),steps:[...e.steps,o.step],candidate:null};return Ue(s),{active:!0,kept:!0,candidate:o,stepCount:s.steps.length}}function Co(e){return ce.stringify(e).trimEnd()+`
|
|
76
|
+
`}function Cs(e){let o=Ge();if(!o)return{active:!1};let s=Co(o.steps),i=Je(o.steps);if(i.length>0)return{active:!0,valid:!1,issues:i,yaml:s,stepCount:o.steps.length,outputPath:null};let u=null;return e&&(u=Wt(e),Ct(Lt(u),{recursive:!0}),jt(u,s)),{active:!0,valid:!0,issues:[],yaml:s,stepCount:o.steps.length,outputPath:u}}import{existsSync as jo,mkdirSync as Lo,readFileSync as Wo,rmSync as qt,writeFileSync as qo}from"fs";import{tmpdir as Jo}from"os";import{dirname as Ho,join as Ko,resolve as Uo}from"path";var he=1,Go="SOOTSIM_INSPECT_NOTICE_PATH",Yo=300*1e3,zo=15e3;function Jt(){return Uo(process.env[Go]||Ko(Jo(),"sootsim-inspect-notice-state.json"))}function Xo(e,o){return Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s?.signature=="string"&&Number.isFinite(s?.updatedAt)&&o-s.updatedAt<=Yo))}function Vo(e){let o=Jt();if(!jo(o))return{version:he,entries:{}};try{let s=JSON.parse(Wo(o,"utf8"));return s.version!==he||!s.entries||typeof s.entries!="object"?(qt(o,{force:!0}),{version:he,entries:{}}):{version:he,entries:Xo(s.entries,e)}}catch{return qt(o,{force:!0}),{version:he,entries:{}}}}function Qo(e){let o=Jt();Lo(Ho(o),{recursive:!0}),qo(o,JSON.stringify(e,null,2)+`
|
|
77
|
+
`)}function Zo(e,o){let s=o.trim()||"default";return`${e}:${s}`}function Ye(e,o,s,i={}){let u=i.nowMs??Date.now(),l=i.cooldownMs??zo,p=Vo(u),y=Zo(e,o),g=p.entries[y];return g&&g.signature===s&&u-g.updatedAt<l?!1:(p.entries[y]={signature:s,updatedAt:u},Qo(p),!0)}async function se({bridge:e,simId:o,maxMs:s,pollMs:i=50,stablePolls:u=3,strict:l=!1}){let p=await e.send({type:"evaluate",simId:o,code:`(async () => {
|
|
78
78
|
const start = Date.now()
|
|
79
79
|
const deadline = start + ${Math.max(0,Math.round(s))}
|
|
80
|
-
const pollMs = ${Math.max(1,Math.round(
|
|
81
|
-
const requiredStablePolls = ${Math.max(1,Math.round(
|
|
80
|
+
const pollMs = ${Math.max(1,Math.round(i))}
|
|
81
|
+
const requiredStablePolls = ${Math.max(1,Math.round(u))}
|
|
82
82
|
const strict = ${l?"true":"false"}
|
|
83
83
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
84
84
|
|
|
@@ -191,10 +191,10 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
191
191
|
await sleep(pollMs)
|
|
192
192
|
}
|
|
193
193
|
return { settled: false, elapsed: Date.now() - start }
|
|
194
|
-
})()`},{timeoutMs:s+1e3}),{elapsed:y,settled:
|
|
194
|
+
})()`},{timeoutMs:s+1e3}),{elapsed:y,settled:g}=p??{};return{elapsed:typeof y=="number"?y:s,settled:g===!0}}var es={initialWaitMs:3e3,deadlineMs:5e3,retryWaitMs:700},ts={initialWaitMs:1200,deadlineMs:2500,retryWaitMs:700};function os(e,o={}){return{...e?es:ts,...o}}function pe(e){return!(!e||e.hit===!1||e.ok===!1||e.pointerTapHandled===!1&&!e.keyboardOpened&&!e.isTextInput)}function ss(e,o){return{id:e.target?.id??e.match?.id??e.node?.id??null,testID:e.target?.testID??e.match?.testID??e.node?.testID??null,text:e.target?.text??e.target?.accessibilityLabel??e.match?.text??e.match?.accessibilityLabel??e.node?.text??o??null,type:e.target?.type??e.match?.type??e.node?.type??null}}async function be(e,o){let s=os(!!o.agent,o.timing),i=0,u=null,l=null;try{await se({bridge:e,maxMs:s.initialWaitMs,pollMs:32,stablePolls:2})}catch{}let p=Date.now()+s.deadlineMs,y=null;for(;Date.now()<=p||i===0;){i++;let g=await o.resolve();if(u=g,g?.error==="bridge-not-ready"||g?.ambiguous||g?.nthOutOfRange)return{payload:g,result:null,attempts:i,failure:"special"};if(g&&typeof g.cx=="number"&&typeof g.cy=="number")if(g.offscreen){l={hit:!1,reason:"offscreen",x:g.cx,y:g.cy,screen:g.screen};let b=`${Math.round(g.cx)},${Math.round(g.cy)}`;if(y===b)return{payload:g,result:l,attempts:i,failure:"missed"};y=b}else{y=null;let b=await e.send({type:"tap",x:g.cx,y:g.cy,target:ss(g,o.textFallback)});if(l=b,pe(b))return{payload:g,result:b,attempts:i}}let k=p-Date.now();if(k<=0)break;try{await se({bridge:e,maxMs:Math.min(k,s.retryWaitMs),pollMs:32,stablePolls:2})}catch{await new Promise(b=>setTimeout(b,Math.min(120,k)))}}return{payload:u,result:l,attempts:i,failure:u&&typeof u.cx=="number"?"missed":"not-found"}}async function Ht(e,o,s,i){return e.send({type:"tap",x:o,y:s,...i?{target:i}:{}})}async function Kt(e,o,s={}){let i=JSON.stringify(o);return be(e,{agent:s.agent,timing:s.timing,resolve:()=>e.send({type:"evaluate",code:`(async () => {
|
|
195
195
|
const t = window.__sootsimTest
|
|
196
196
|
if (!t) return null
|
|
197
|
-
const n = (await t.findByTestId(${
|
|
197
|
+
const n = (await t.findByTestId(${i})) || (await t.findById(${i}))
|
|
198
198
|
if (!n || !n.absolutePosition || !n.layout) return { cx: null }
|
|
199
199
|
const resolved =
|
|
200
200
|
typeof n.nodeId === 'number' && typeof t.resolveTapTarget === 'function'
|
|
@@ -241,10 +241,10 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
241
241
|
},
|
|
242
242
|
strategy: (resolved && resolved.strategy) || 'matched-node',
|
|
243
243
|
}
|
|
244
|
-
})()`})})}async function Ut(e,o,s={},
|
|
244
|
+
})()`})})}async function Ut(e,o,s={},i={}){let u=JSON.stringify({query:o,exact:!!s.exact,role:s.role??null,within:s.within??null,minX:s.minX??null,maxX:s.maxX??null,minY:s.minY??null,maxY:s.maxY??null,near:s.near??null,nth:s.nth??null,first:!!s.first});return be(e,{agent:i.agent,timing:i.timing,textFallback:o,resolve:()=>e.send({type:"evaluate",code:`(async () => {
|
|
245
245
|
const t = window.__sootsimTest
|
|
246
246
|
if (!t) return { error: 'bridge-not-ready' }
|
|
247
|
-
const F = ${
|
|
247
|
+
const F = ${u}
|
|
248
248
|
|
|
249
249
|
const res = await t.queryTextCandidates({
|
|
250
250
|
query: F.query,
|
|
@@ -369,11 +369,11 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
369
369
|
total,
|
|
370
370
|
idx,
|
|
371
371
|
}
|
|
372
|
-
})()`})})}async function Gt(e,o,s={}){let
|
|
372
|
+
})()`})})}async function Gt(e,o,s={}){let i=JSON.stringify(o);return be(e,{agent:s.agent,timing:s.timing,textFallback:o,resolve:async()=>{let u=await e.send({type:"evaluate",code:`(async () => {
|
|
373
373
|
const t = window.__sootsimTest
|
|
374
374
|
if (!t) return { error: 'bridge-not-ready' }
|
|
375
375
|
const byTestId =
|
|
376
|
-
(await t.findByTestId(${
|
|
376
|
+
(await t.findByTestId(${i})) || (await t.findById(${i}))
|
|
377
377
|
if (byTestId && byTestId.absolutePosition && byTestId.layout) {
|
|
378
378
|
return {
|
|
379
379
|
strategy: 'testid',
|
|
@@ -394,7 +394,7 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
394
394
|
})(),
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
const byText = await t.findByText(${
|
|
397
|
+
const byText = await t.findByText(${i})
|
|
398
398
|
if (byText && byText.absolutePosition && byText.layout) {
|
|
399
399
|
return {
|
|
400
400
|
strategy: 'text',
|
|
@@ -416,20 +416,20 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
return { strategy: 'none' }
|
|
419
|
-
})()`});if(!
|
|
419
|
+
})()`});if(!u||!("node"in u))return u;let l=u.node,p=l.absolutePosition.x+l.layout.width/2,y=l.absolutePosition.y+l.layout.height/2,g=u.screen??null,k=!!g&&(p<0||y<0||p>g.width||y>g.height);return{...u,cx:p,cy:y,...k?{offscreen:!0,screen:g}:{},target:{id:l.id,testID:l.testID,text:u.strategy==="text"?o:l.text,type:l.type}}}})}async function Yt(e,o={args:[]}){let s=await rt(e);if(A(o.args)){D(s);return}console.log(` nodes: ${s.nodes}`)}function ze(e,o){let s=e.indexOf(o);return s>=0&&s+1<e.length?e[s+1]:null}async function zt(e){let{bridge:o,args:s,positional:i}=e,u=s.includes("--verbose")||s.includes("-v"),l=A(s),p=u&&!l,y=s.includes("--watch")||s.includes("-w"),g=1e3,k=s.includes("--compact"),b=s.includes("--no-xy"),I=s.includes("--no-clipped"),M=s.includes("--include-occluded"),N=ze(s,"--testid-like"),j=ze(s,"--only"),O=ze(s,"--subtree"),c=i[1]&&!i[1].startsWith("-")?i[1]:void 0,L=c?/[*?]/.test(c):!1,R=!L&&!j?c:void 0,P=j??(L?c:void 0),K=async()=>{await de(o,{verbose:p});let v=await lt(o,{describe:!0,verbose:u,filter:R||"",testIdLike:N||void 0,onlyGlob:P||void 0,subtreeRoot:O||void 0,compact:k,hideXy:b,includeOccluded:M}),F=v?.tree,J=v?.shell,H=v?.keyboard;if(l){D({shell:J,tree:F??"",keyboard:H});return}if(J&&typeof J=="object"){let C=[J.state?`state=${J.state}`:null,J.activeApp?`app=${J.activeApp}`:null,J.showSwitcher?"switcher":null,J.switcherPhase&&J.switcherPhase!=="idle"?`phase=${J.switcherPhase}`:null].filter(Boolean);C.length>0&&console.log(` shell: ${C.join(" ")}`)}if(typeof F=="string"&&F.startsWith("__SUBTREE_NOT_FOUND__:")){let C=F.slice(22);console.log(` subtree root not found: ${C}`),Q("subtree-root-not-found",C);return}if(!F){let C=v?.nodeCount??0;console.log(" no matching nodes found"),!(R||N||P||O)&&C<10&&Q("app-still-loading",C);return}let ee=F,te=0;if(I&&typeof ee=="string"){let C=ee.split(`
|
|
420
420
|
`),le=[];for(let Se of C){if(Se.includes("(clipped:")){te+=1;continue}le.push(Se)}ee=le.join(`
|
|
421
|
-
`)}console.log(ee),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let re=
|
|
421
|
+
`)}console.log(ee),te>0&&console.log(` ${te} clipped row(s) hidden (omit --no-clipped to see)`);let re=R||N||P||O;if((R||N||P)&&!y&&Q("describe-filter-context"),!re&&!y&&F.split(`
|
|
422
422
|
`).length>=80&&Q("describe-use-filters"),H&&H.visible){let C=H.spec,le=[C?.keyboardType?`type=${C.keyboardType}`:null,C?.returnKeyType&&C.returnKeyType!=="default"?`return=${C.returnKeyType}`:null,H.mode!=="letters"?`mode=${H.mode}`:null,H.shifted?"shift":null,H.capsLock?"caps":null,C?.autoCapitalize&&C.autoCapitalize!=="sentences"?`autoCap=${C.autoCapitalize}`:null,H.accessoryBarId?`accessory=${H.accessoryBarId}`:null].filter(Boolean);console.log(`
|
|
423
423
|
keyboard: ${le.join(" ")||"visible"}`)}};if(y)for(console.log(` watching... (Ctrl+C to stop)
|
|
424
|
-
`);;)console.clear(),await K(),await oe(
|
|
424
|
+
`);;)console.clear(),await K(),await oe(g);else await K()}var ns=["SOOTSIM_AGENT","AGENTBUS_SESSION","CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","CURSOR_TRACE_ID","AIDER_MODEL"];function me(){if(process.env.SOOTSIM_AGENT==="0")return!1;for(let e of ns){let o=process.env[e];if(o&&o.trim()&&o!=="0")return!0}return!1}async function Xt(e){let{bridge:o,args:s,effectiveArgs:i,positional:u,inspectUsage:l}=e,p=v=>{let F=i.indexOf(v);return F>=0&&F+1<i.length?i[F+1]:null},y=v=>i.includes(v),g=p("--testid")||p("--test-id"),k=p("--role"),b=p("--type"),I=p("--text"),M=y("--pressable"),N=y("--visible"),j=y("--interactive-targets")||y("--actions"),O=!g&&!k&&!b&&!I&&!M&&!N&&!j?u[1]:null,c=I??O,L=await pt(o,{testId:g,role:k,type:b,text:c,pressable:M,visible:N,interactive:j});L||(console.error(l("find","<text> | --text <t> | --testid <id> | --role <r> | --type <t> | --pressable | --visible | --interactive-targets")),process.exit(1));let{mode:R,result:P}=L,K=A(s),U=s.includes("--verbose")||s.includes("--dump");if(K)R==="interactive-targets"&&Array.isArray(P)?D(Be(P).map(v=>({...v,tap:Ce(v)}))):D(P??null);else if(Array.isArray(P))if(P.length===0){console.log(` no ${R} nodes found`);let v=await o.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()"});typeof v=="number"&&v<10&&Q("app-still-loading",v)}else if(R==="interactive-targets"){let v=Be(P);console.log(` found ${v.length} interactive target${v.length===1?"":"s"} (sorted by score):`);for(let F of v.slice(0,20)){let J=F.absolutePosition?`@(${Math.round(F.absolutePosition.x)},${Math.round(F.absolutePosition.y)})`:"",H=F.layout?`${Math.round(F.layout.width)}x${Math.round(F.layout.height)}`:"?x?",ee=F.text?` "${F.text.slice(0,30)}"`:"",te=F.testID?` #${F.testID}`:"",re=F.accessibilityLabel?` \u24D8"${String(F.accessibilityLabel).slice(0,24)}"`:"",xe=F.accessibilityRole?`[${F.accessibilityRole}]`:F.type,C=Ce(F);console.log(` ${xe}${ee}${re}${te} ${H} ${J}`),console.log(` \u2192 ${C}`),U&&console.log(Xe(JSON.stringify(F,null,2)," "))}v.length>20&&console.log(` ... and ${v.length-20} more`)}else{console.log(` found ${P.length} node${P.length===1?"":"s"} (${R}):`);for(let v of P.slice(0,20)){let F=v.absolutePosition?`@(${Math.round(v.absolutePosition.x)},${Math.round(v.absolutePosition.y)})`:"",J=v.layout?`${Math.round(v.layout.width)}x${Math.round(v.layout.height)}`:"?x?",H=v.text?` "${v.text.slice(0,30)}"`:"",ee=v.testID?` #${v.testID}`:"",te=v.pressable?" (tap)":"",re=v.accessibilityRole?`[${v.accessibilityRole}]`:v.type;console.log(` ${re}${H}${ee} ${J} ${F}${te}`),U&&console.log(Xe(JSON.stringify(v,null,2)," "))}P.length>20&&console.log(` ... and ${P.length-20} more`)}else if(P==null)console.log(` not found: ${c||g||k||b||""||R}`),g&&Q("wait-selector-for-missing-testid",g);else{let v=P;if(v.type&&v.absolutePosition){let F=`@(${Math.round(v.absolutePosition.x)},${Math.round(v.absolutePosition.y)})`,J=v.layout?`${Math.round(v.layout.width)}x${Math.round(v.layout.height)}`:"?x?",H=v.text?` "${v.text.slice(0,40)}"`:"",ee=v.testID?` #${v.testID}`:"",te=v.pressable?" (tap)":"",re=v.accessibilityRole?`[${v.accessibilityRole}]`:v.type;console.log(` ${re}${H}${ee} ${J} ${F}${te}`),U&&console.log(Xe(JSON.stringify(v,null,2)," "))}else console.log(JSON.stringify(P,null,2))}}function Xe(e,o){return e.split(`
|
|
425
425
|
`).map(s=>o+s).join(`
|
|
426
|
-
`)}async function Vt(e){let{bridge:o,args:s}=e,
|
|
427
|
-
`),console.log(ut(
|
|
428
|
-
`))}async function Zt(e){let o=await e.bridge.listSims(),s=e.args.includes("--all"),
|
|
429
|
-
slope over ${M.toFixed(0)}s:`);let j=Object.entries(N).filter(([,O])=>O!==0).sort((O,
|
|
426
|
+
`)}async function Vt(e){let{bridge:o,args:s}=e,i=A(s);await de(o,{verbose:!i});let u=s.includes("--styling"),l=s.indexOf("--filter"),p=l>=0?s[l+1]:void 0,y=await ct(o,{styling:u,filter:p});if(i){D({count:y.length,elements:y});return}console.log(` layout (${y.length} element${y.length===1?"":"s"}):
|
|
427
|
+
`),console.log(ut(y,{styling:u}))}async function Qt(e,o={}){let s=await St(e);if("error"in s&&(console.error(s.error),process.exit(1)),o.json){console.log(JSON.stringify(s,null,2));return}let{visible:i,spec:u,mode:l,shifted:p,capsLock:y,accessoryBarId:g}=s,k=[];k.push(`keyboard: ${i?"visible":"hidden"}`),u?(k.push(` type: ${u.keyboardType}`),k.push(` returnKey: ${u.returnKeyType}`),k.push(` autoCap: ${u.autoCapitalize}`),k.push(` autoCorrect: ${u.autoCorrect?"on":"off"}`),k.push(` appearance: ${u.keyboardAppearance}`),u.secureTextEntry&&k.push(" secureTextEntry: true"),u.enablesReturnKeyAutomatically&&k.push(` return: ${u.currentTextIsEmpty?"disabled (empty)":"enabled"}`)):k.push(" spec: <none> (shown via dev-tools with no TextInput)"),k.push(` mode: ${l}${p?" (shifted)":""}${y?" (caps)":""}`),g&&k.push(` accessoryBar: ${g}`),console.log(k.join(`
|
|
428
|
+
`))}async function Zt(e){let o=await e.bridge.listSims(),s=e.args.includes("--all"),i=e.args.find((y,g)=>e.args[g-1]==="--bundle"),u=e.args.find((y,g)=>e.args[g-1]==="--app-port"),l=e.args.includes("--primary"),p=o.filter(y=>!(l&&!y.isPrimary||i&&!(y.url??"").includes(i)||u&&!(y.url??"").includes(`/rn/${u}`)||!s&&!i&&!u&&!l&&!(y.url&&(y.url.includes("bundle=")||y.url.includes("/index.bundle")))&&y.id!==e.simId));if(A(e.args)){D(p.map(y=>({...y,active:y.id===e.simId})));return}Rt(p,e.simId),p.length<o.length&&!A(e.args)&&console.log(` (${o.length-p.length} more hidden \u2014 pass --all to show)`)}function ae(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`}function rs(e,o){return o<=0?"?":`${(e/o*100).toFixed(0)}%`}function is(e){let o={},s=(i,u)=>{u&&(u.nodesRegistered!=null&&(o[`${i}.nodes`]=u.nodesRegistered),u.nodesDetached!=null&&(o[`${i}.detached`]=u.nodesDetached),u.objects&&(o[`${i}.paragraphs`]=u.objects.paragraphs,o[`${i}.yogaNodes`]=u.objects.yogaNodes,o[`${i}.pictures`]=u.objects.pictures,o[`${i}.rasterImages`]=u.objects.rasterImages),u.imageLoader&&(o[`${i}.imageCacheEntries`]=u.imageLoader.cacheEntries,o[`${i}.imagePixelBytes`]=u.imageLoader.cachePixelBytes),u.workerHeap&&(o[`${i}.heapBytes`]=u.workerHeap.usedJSHeapSize))};return s("tenant",e.tenant),s("shell",e.shell),e.hostHeap&&(o["host.heapBytes"]=e.hostHeap.usedJSHeapSize),o}function eo(e,o){return e.endsWith("Bytes")?ae(o):String(o)}function to(e,o){if(!o){console.log(` ${e}: not available`);return}let s=o.objects;if(console.log(` ${e}`),o.nodesRegistered!=null&&console.log(` nodes registered: ${o.nodesRegistered}`),o.nodesDetached!=null){let i=Object.entries(o.detachedTypes??{}).map(([u,l])=>`${u}:${l}`).join(" ");console.log(` nodes detached: ${o.nodesDetached}${i?` (${i})`:""}`)}if(s&&(console.log(` paragraphs: ${s.paragraphs}`),console.log(` yoga nodes: ${s.yogaNodes}`),console.log(` pictures: ${s.pictures}`),console.log(` raster images: ${s.rasterImages}`)),o.activeNativeAnimations!=null&&console.log(` native anims: ${o.activeNativeAnimations}`),o.imageLoader){let i=o.imageLoader;console.log(` image cache: ${i.cacheEntries}/${i.cacheMaxEntries} entries, ${ae(i.cachePixelBytes)}/${ae(i.cachePixelBudget)} (${rs(i.cachePixelBytes,i.cachePixelBudget)})`)}o.workerHeap&&console.log(` js heap: ${ae(o.workerHeap.usedJSHeapSize)} used / ${ae(o.workerHeap.totalJSHeapSize)} total`)}function as(e){console.log(" memory:"),to("tenant worker",e.tenant),to("shell worker",e.shell),e.hostHeap?(console.log(" host"),console.log(` js heap: ${ae(e.hostHeap.usedJSHeapSize)} used / ${ae(e.hostHeap.totalJSHeapSize)} total`)):console.log(" host js heap: not available (chrome only)")}function ls(e,o,s){let i=e.indexOf(o);if(i===-1)return s;let u=Number(e[i+1]);return Number.isFinite(u)&&u>0?u:s}async function oo(e,o={args:[]}){let s=A(o.args),i=o.args.indexOf("--watch");if(i===-1){let O=await We(e);if(s){D(O);return}as(O);return}let u=Number(o.args[i+1]),l=Number.isFinite(u)&&u>0?u:60,p=ls(o.args,"--interval",5),y=[],g=Date.now(),k=null;for(s||console.log(` sampling every ${p}s for ${l}s \u2014 deltas per tick:`);;){let O=await We(e),c=(Date.now()-g)/1e3,L=is(O);if(y.push({tSec:c,counters:L}),!s){let R=[];for(let[P,K]of Object.entries(L)){let U=k&&P in k?K-k[P]:null;if(U===null||U===0)continue;let v=U>0?"+":"-",F=P.endsWith("Bytes")?`${v}${ae(Math.abs(U))}`:`${v}${Math.abs(U)}`;R.push(`${P} ${eo(P,K)} (${F})`)}console.log(` t+${c.toFixed(0)}s ${R.length?R.join(" "):k?"no change":Object.entries(L).map(([P,K])=>`${P} ${eo(P,K)}`).join(" ")}`)}if(k=L,c>=l)break;await new Promise(R=>setTimeout(R,p*1e3))}let b=y[0],I=y[y.length-1],M=Math.max(I.tSec-b.tSec,.001),N={};for(let O of Object.keys(I.counters))O in b.counters&&(N[O]=(I.counters[O]-b.counters[O])/M);if(s){D({samples:y,perSecond:N,elapsedSec:M});return}console.log(`
|
|
429
|
+
slope over ${M.toFixed(0)}s:`);let j=Object.entries(N).filter(([,O])=>O!==0).sort((O,c)=>Math.abs(c[1])-Math.abs(O[1]));if(j.length===0){console.log(" all counters flat");return}for(let[O,c]of j){let L=O.endsWith("Bytes")?`${ae(Math.abs(c))}/s${c<0?" (shrinking)":""}`:`${c>0?"+":""}${c.toFixed(2)}/s`;console.log(` ${O.padEnd(28)}${L}`)}}var Z="<redacted secure text>";function we(e){let o=e?.layout?.spec??e?.spec??null;return!!o?.secureTextEntry&&o.keyboardType!=="visible-password"}function Ve(e,o){return we(o)?Z:e}function Qe(e){if(!e||!we(e))return e;let o=e.focusedInput;return!o||typeof o!="object"?e:{...e,focusedInput:{...o,secureTextEntry:!0,text:typeof o.text=="string"?Z:o.text}}}function $e(e){let o=e.indexOf("--testid");if(o>=0&&e[o+1])return{mode:"testid",value:e[o+1]};let s=e.indexOf("--test-id");if(s>=0&&e[s+1])return{mode:"testid",value:e[s+1]};let i=e.indexOf("--text");return i>=0&&e[i+1]?{mode:"text",value:e[i+1]}:null}async function Oe(e,o){let s=JSON.stringify(o.value),i=o.mode==="testid"?`(await t.findByTestId(${s})) || (await t.findById(${s}))`:`await t.findByText(${s})`;return await e.send({type:"evaluate",code:`(async () => {
|
|
430
430
|
const t = window.__sootsimTest
|
|
431
431
|
if (!t) return null
|
|
432
|
-
const n = ${
|
|
432
|
+
const n = ${i}
|
|
433
433
|
if (!n || !n.absolutePosition || !n.layout) return null
|
|
434
434
|
const resolved =
|
|
435
435
|
typeof n.nodeId === 'number' && typeof t.resolveTapTarget === 'function'
|
|
@@ -451,12 +451,12 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
451
451
|
text: ${JSON.stringify(o.mode==="text")} ? ${s} : (n.text ?? n.accessibilityLabel ?? null),
|
|
452
452
|
type: n.type ?? null,
|
|
453
453
|
}
|
|
454
|
-
})()`})??null}async function so(e,o={}){let{nav:s,keyboard:
|
|
455
|
-
`))}async function no(e){let{bridge:o,args:s,positional:
|
|
454
|
+
})()`})??null}async function so(e,o={}){let{nav:s,keyboard:i,shell:u}=await vt(e);if(o.json){console.log(JSON.stringify({shell:u??null,nav:s,keyboard:i},null,2));return}let l=[];if(u){let p=u.activeApp??u.state??"<none>",y=u.showSwitcher?" (app switcher open)":"",g=typeof u.launchProgress=="number"&&u.launchProgress<.98?` launching (${Math.round(u.launchProgress*100)}%)`:"";l.push(`shell: ${p}${y}${g}`)}else l.push("shell: <unavailable>");if(s){let p=s.transitionPhase!=="idle"?` (${s.transitionPhase}, ${s.activeTransitionCount} active)`:"";if(l.push(`nav: phase=${s.transitionPhase}${p}`),s.screens.length===0)l.push(" <no registered screens \u2014 app may not use react-native-screens>");else for(let y of s.screens){let g=y.isActive?"\u25B6":" ",k=y.routeName?` ${y.routeName}`:"",b=y.headerHeight>0?` header=${y.headerHeight}`:"",I=y.largeTitleState&&y.largeTitleState!=="expanded"?` large-title=${y.largeTitleState}`:"";l.push(` ${g} #${y.id}${k}${b}${I}`)}}else l.push("nav: <runtime not available>");if(i&&i.visible){let p=i.spec?.keyboardType??"default",y=i.spec?.returnKeyType??"default";l.push(`keyboard: visible (${p}, return=${y}, mode=${i.mode??"?"})`)}else l.push("keyboard: hidden");console.log(l.join(`
|
|
455
|
+
`))}async function no(e){let{bridge:o,args:s,positional:i}=e,u=i[1]?Number(i[1])*1e3:3e3,l=s.includes("--strict"),{elapsed:p,settled:y}=await se({bridge:o,maxMs:u,strict:l});console.log(y?` settled in ${p}ms`:` timed out after ${p}ms (may still be animating)`)}async function ro(e){let o=e.positional[1]?Number(e.positional[1]):.5;(!Number.isFinite(o)||o<0)&&(console.error(e.inspectUsage("sleep","[seconds]")),process.exit(1)),await oe(o*1e3),console.log(` slept ${o}s`)}async function io(e){let{bridge:o,args:s,positional:i}=e,u=s.includes("--boxes"),l=i[1]?Number(i[1]):u?50:5,{tree:p}=await it(o,l,u?{format:"boxes"}:void 0);if(A(s)){D({depth:l,tree:p??null});return}console.log(typeof p=="string"?p:JSON.stringify(p,null,2))}async function ao(e,o={args:[]}){let s=await at(e);if(A(o.args)){D(s);return}console.log(s.url)}async function lo(e){let{wsPort:o,commandTimeoutMs:s,simId:i,simIdSource:u,positional:l}=e,p=l[1]?Number(l[1]):30,y=Math.max(1e3,(Number.isFinite(p)?p:30)*1e3),g=Math.max(1,Math.ceil(y/500));console.log(" waiting for sim reconnect...");let k=await Mt(o,s,i,{attempts:g,simIdSource:u});k||(console.error(" timed out waiting for sim reconnect"),process.exit(1)),k.bridge.close(),Fe({source:"inspect wait",step:{wait:y},summary:`wait ${Math.round(y/1e3)}s`}),console.log(` ready: ${k.count} nodes`)}var co=new Set(["app-launch","toast","keyboard","screen","flow-step","route","alert","actionsheet","picker","notification","fetch","console","shell","scroll","gesture","text-input","react-commit","animation","reanimated"]);function Ee(e,o){let s=e.indexOf(o);if(s>=0&&s+1<e.length)return e[s+1]}function cs(e,o){if(!o.filter&&!o.equals)return!0;let s=e.data,i=[];if(s&&typeof s=="object")for(let l of["url","displayUrl","message","name","activeName","path","pathname","title","phase","event","type","kind"]){let p=s[l];typeof p=="string"&&p.length>0&&i.push(p)}let u=i.join(" ");return o.equals?i.some(l=>l===o.equals):o.filter?u.toLowerCase().includes(o.filter.toLowerCase()):!0}async function uo(e){let{bridge:o,args:s,positional:i,inspectUsage:u}=e,l=i[1];l||(console.error(u("wait event","<kind> [--max-ms 5000] [--filter <substring>] [--equals <exact>] [--since now|cursor]")),process.exit(1)),co.has(l)||console.error(` warning: '${l}' is not a known timeline kind \u2014 waiting anyway. known: ${[...co].sort().join(", ")}`);let p=Ee(s,"--max-ms"),y=p&&Number.isFinite(Number(p))?Math.max(100,Number(p)):5e3,g=Ee(s,"--filter"),k=Ee(s,"--equals"),b=Ee(s,"--since")??"now",I=s.includes("--json"),M=Date.now(),N=M+y,j=200,O=M;for(;Date.now()<N;){let L={kinds:[l],since:b==="cursor"?void 0:O,limit:50},R=await o.send({type:"evaluate",code:`(async () => {
|
|
456
456
|
const t = window.SootSim?.bridges?.timeline
|
|
457
457
|
if (!t) return { ok: false, error: 'timeline bridge missing' }
|
|
458
458
|
return { ok: true, result: await t.recent(${JSON.stringify(L)}) }
|
|
459
|
-
})()`});(!
|
|
459
|
+
})()`});(!R||!R.ok)&&(console.error(` could not query timeline: ${R&&"error"in R?R.error:"unknown"}`),process.exit(1));let P=R.result.events??[];for(let K of P)if(cs(K,{filter:g,equals:k})){let U=Date.now()-M;console.log(I?JSON.stringify({found:!0,elapsedMs:U,event:K}):` ${l} event after ${U}ms${g?` (filter: ${g})`:""}${k?` (equals: ${k})`:""}`);return}R.result.watermark&&R.result.watermark>O&&(O=R.result.watermark),await new Promise(K=>setTimeout(K,j))}let c=Date.now()-M;I?console.log(JSON.stringify({found:!1,elapsedMs:c,kind:l,filter:g,equals:k})):console.error(` \u26A0 wait event ${l} timed out after ${c}ms${g?` (filter: ${g})`:""}${k?` (equals: ${k})`:""}`),process.exit(1)}async function po(e){let{bridge:o,args:s}=e,i=s.includes("--strict"),u=ke(s,3e3),{elapsed:l,settled:p}=await se({bridge:o,maxMs:u,strict:i});p?console.log(` idle in ${l}ms`):(console.error(` \u26A0 wait idle timed out after ${l}ms (may still be animating)`),process.exit(1))}async function mo(e){let{bridge:o,args:s}=e,i=ke(s,2e4),{ready:u,elapsedMs:l,nodes:p,targets:y,flag:g,loadingText:k,externalReady:b,externalError:I,suppressedEntryError:M,errors:N,bridgeError:j}=await mt(o,i,{onProgress(c){console.error(` still waiting after ${c.elapsedMs}ms \u2014 ${je(c)} (nodes: ${c.nodes}, targets: ${c.targets}, errors: ${c.errors})`)}});if(u){let c=i-l,L=Math.max(100,Math.min(1e4,c)),R=await se({bridge:o,maxMs:L,pollMs:32,stablePolls:2});R.settled||(console.error(` \u26A0 wait ready timed out after ${l+R.elapsed}ms \u2014 app mounted but did not settle (nodes: ${p}, targets: ${y})`),process.exit(1)),console.log(` ready in ${l+R.elapsed}ms: ${p} nodes, ${y} targets`);return}let O=je({externalError:I,loadingText:k,externalReady:b,flag:g,targets:y,suppressedEntryError:M,bridgeError:j});console.error(` \u26A0 wait ready timed out after ${l}ms \u2014 ${O} (nodes: ${p}, targets: ${y}, errors: ${N})`),process.exit(1)}async function fo(e){let{bridge:o,args:s,positional:i,inspectUsage:u}=e,l=i[1];l||(console.error(u("wait selector","<testid> [--max-ms 5000] [--gone]")),process.exit(1));let p=s.indexOf("--max-ms"),y=p>=0&&s[p+1]?Math.max(100,Number(s[p+1])):5e3,g=s.includes("--gone"),{found:k,node:b,elapsed:I}=await ft(o,l,y,{gone:g});if(g){k?console.log(` #${l} gone after ${I}ms`):(console.error(` \u26A0 wait selector #${l} --gone timed out after ${I??y}ms (still present)`),process.exit(1));return}if(k&&b){let M=b.absolutePosition?`@(${Math.round(b.absolutePosition.x)},${Math.round(b.absolutePosition.y)})`:"",N=b.layout?`${Math.round(b.layout.width)}x${Math.round(b.layout.height)}`:"?x?";console.log(` found #${l} in ${I}ms ${N} ${M}`)}else console.error(` \u26A0 wait selector #${l} timed out after ${I??y}ms`),process.exit(1)}function ko(e){return e==null?"\u2014":e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}K`:`${(e/1024/1024).toFixed(1)}M`}function _o(e){return e==null?" \u2026":e<1e3?`${e}ms`.padStart(5):`${(e/1e3).toFixed(2)}s`.padStart(5)}function go(){process.stderr.write(` the sim is not responding. recover it with:
|
|
460
460
|
sootsim close --sim <id> # force-close the wedged sim
|
|
461
461
|
sootsim list # confirm it's gone
|
|
462
462
|
`)}async function ds(e){try{return await e.send({type:"evaluate",code:"1"},{timeoutMs:3e3}),!0}catch{return!1}}async function ps(e,o){try{let s=await e.send({type:"evaluate",code:`(async () => {
|
|
@@ -478,9 +478,9 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
478
478
|
} catch {
|
|
479
479
|
return []
|
|
480
480
|
}
|
|
481
|
-
})()`});if(!Array.isArray(s)||s.length===0)return;let
|
|
482
|
-
`).slice(0,5);for(let p of l)console.log(` ${p.trim()}`)}}var ws=120;async function
|
|
483
|
-
`),console.log(` painted frames: ${e.frames}${e.skippedFrames?` (+${e.skippedFrames} skipped idle ticks)`:""}`),console.log(` avg:
|
|
481
|
+
})()`});if(!Array.isArray(s)||s.length===0)return;let i=o.toLowerCase(),u=s.map(l=>({id:l,score:ms(i,l.toLowerCase())})).filter(l=>l.score<i.length+4).sort((l,p)=>l.score-p.score).slice(0,5);if(u.length===0)return;console.error(" similar testIDs:");for(let l of u)console.error(` ${l.id}`)}catch{}}function ms(e,o){if(o===e)return 0;if(o.includes(e))return 1;if(e.includes(o))return 2;let s=0;for(;s<e.length&&s<o.length&&e[s]===o[s];)s+=1;return fs(e,o)-s}function fs(e,o){if(e===o)return 0;if(!e.length)return o.length;if(!o.length)return e.length;let s=new Array(o.length+1),i=new Array(o.length+1);for(let u=0;u<=o.length;u++)s[u]=u;for(let u=1;u<=e.length;u++){i[0]=u;for(let p=1;p<=o.length;p++)i[p]=Math.min(s[p]+1,i[p-1]+1,s[p-1]+(e[u-1]===o[p-1]?0:1));let l=s;s=i,i=l}return s[o.length]}function gs(e){return e.error?"err":e.status==null?" \u2026 ":String(e.status)}function yo(e){return e.externalError?`guest app errored: ${e.externalError}`:e.loadingText?`still showing "${e.loadingText}"`:e.externalReady===!1?"guest app is still loading":e.flag!==!0?"guest app has not emitted sootsim:externalAppReady":e.targets<=0?"ready flag emitted but no visible app content is inspectable yet":"node tree is still changing"}function ho(e){let o=ie(e.startTs),s=gs(e).padEnd(3),i=e.method.padEnd(5),u=ko(e.size).padStart(6),l=_o(e.durationMs);console.log(` [${o}] ${s} ${i} ${u} ${l} ${e.displayUrl}`),e.error&&console.log(` error: ${e.error}`)}function ys(e){let o=[["id",e.id],["source",e.source],["kind",e.kind],["method",e.method],["status",e.error?`error: ${e.error}`:`${e.status??"\u2014"} ${e.statusText??""}`.trim()],["url",e.url],["started",ie(e.startTs)],["duration",_o(e.durationMs).trim()],["size",ko(e.size)],["content-type",e.type??"\u2014"]];for(let[s,i]of o)console.log(` ${s.padEnd(13)} ${i}`)}var hs={error:"\x1B[31m",warn:"\x1B[33m",info:"\x1B[36m",debug:"\x1B[35m",log:"\x1B[37m"},bo="\x1B[0m",bs="\x1B[2m";function wo(e,o){let s=ie(e.ts),i=e.level.toUpperCase().padEnd(5),u=e.args.join(" ");if(o){let l=hs[e.level];console.log(` ${bs}[${s}]${bo} ${l}${i}${bo} ${u}`)}else console.log(` [${s}] ${i} ${u}`);if(e.stack&&e.level==="error"){let l=e.stack.split(`
|
|
482
|
+
`).slice(0,5);for(let p of l)console.log(` ${p.trim()}`)}}var ws=120;async function $o(e,o){let s=e.find((M,N)=>e[N-1]==="--id"),i=e.find((M,N)=>e[N-1]==="--text");if(s||i){let M=await o.send({type:"evaluate",code:At({id:s,text:i})});if(!M)throw new Error(s?`no node with id "${s}"`:`no node matching text "${i}"`);let{x:N,y:j,w:O,h:c}=M;return{x:N,y:j,w:O,h:c}}let u=e.find((M,N)=>e[N-1]==="--area");if(u){let M=u.split(",").map(L=>Number(L.trim()));if(M.length!==4||M.some(L=>!Number.isFinite(L)))throw new Error(`--area expects x,y,w,h (got "${u}")`);let[N,j,O,c]=M;return{x:N,y:j,w:O,h:c}}let l=M=>{let N=e.find((O,c)=>e[c-1]===M);if(N==null)return null;let j=Number(N);return Number.isFinite(j)?j:null},p=l("--x"),y=l("--y"),g=l("--w"),k=l("--h");if(p!=null||y!=null||g!=null||k!=null)return{x:p??0,y:y??0,w:g??1,h:k??1};let I=e.filter((M,N)=>N>0&&!M.startsWith("-")&&e[N-1]!=="--output"&&e[N-1]!=="--area"&&e[N-1]!=="--id"&&e[N-1]!=="--text"&&e[N-1]!=="--x"&&e[N-1]!=="--y"&&e[N-1]!=="--w"&&e[N-1]!=="--h").map(Number).filter(M=>Number.isFinite(M));if(I.length>=2){let[M,N,j=1,O=1]=I;return{x:M,y:N,w:j,h:O}}return null}function xo(e){let o=e.avgMs>0?(1e3/e.avgMs).toFixed(1):"?",s=e.jank&&typeof e.jank=="object"?e.jank:null;if(console.log(` shell frame profile:
|
|
483
|
+
`),s){let k=(Array.isArray(s.compositor)?s.compositor:[]).reduce((b,I)=>b+(I.jankPaints??0),0);console.log(` health: ${s.detected?"jank or cadence gaps observed":"no jank or cadence gaps observed"} \xB7 shell ${s.shell?.jankFrames??0} \xB7 compositor ${k} \xB7 host clock gaps ${s.hostGaps??0}`),console.log(" series: independent worker clocks, no per-frame pairing")}if(console.log(` painted frames: ${e.frames}${e.skippedFrames?` (+${e.skippedFrames} skipped idle ticks)`:""}`),console.log(` shell work avg: ${e.avgMs}ms (${o} fps) \xB7 worst observed ${e.maxMs}ms`),console.log(` shell p50/95/99:${e.p50} / ${e.p95} / ${e.p99} ms`),s){console.log(` shell jank: ${s.shell?.jankFrames??0}/${s.shell?.sampledFrames??0} (${s.shell?.jankPct??0}%) >16.67ms \xB7 max ${s.shell?.maxMs??0}ms`);for(let g of Array.isArray(s.compositor)?s.compositor:[])console.log(` ${String(g.surfaceId).padEnd(12)} ${g.jankPaints}/${g.sampledPaints} compositor paints (${g.jankPct}%) >16.67ms \xB7 max ${g.maxMs}ms`)}else console.log(` jank: ${e.jankFrames} frames (${e.jankPct}%) >16.67ms`);console.log(` avg per frame: overlay ${e.avgOverlayMs}ms \xB7 aux ${e.avgAuxMs}ms \xB7 layout ${e.avgLayoutMs}ms`);let i=e.cadence;i&&typeof i=="object"&&(console.log(""),console.log(` cadence (frame delivery, ${i.vsyncTicks} vsync ticks):`),console.log(` display clock: ${i.displayHz}hz \xB7 host rAF interval p50 ${i.hostIntervalP50} / p95 ${i.hostIntervalP95} / max ${i.hostIntervalMax} ms${i.hostGaps?` \xB7 ${i.hostGaps} gaps >1.5x (host rAF starved)`:""}`),console.log(` delivery lag: p50 ${i.deliveryLagP50} / p95 ${i.deliveryLagP95} / max ${i.deliveryLagMax} ms (vsync postMessage \u2192 shell receipt)`),console.log(` paint interval: p50 ${i.paintIntervalP50} / p95 ${i.paintIntervalP95} / max ${i.paintIntervalMax} ms${i.idleBreaks?` \xB7 ${i.idleBreaks} idle breaks excluded`:""}`));let u=e.compositorCadence;u&&typeof u=="object"&&console.log(` compositor rAF: p50 ${u.p50} / p95 ${u.p95} / max ${u.max} ms \xB7 ${u.gaps} gaps >1.5x`);let l=Array.isArray(e.auxSurfaces)?e.auxSurfaces:[];if(l.length>0){console.log(""),console.log(" surfaces (last 100 frames):");for(let g of l)console.log(` ${String(g.surfaceId).padEnd(10)} ${String(g.frames).padStart(4)} paints avg ${g.avgMs}ms (layout ${g.avgLayoutMs}, render ${g.avgRenderMs}, flush ${g.avgFlushMs}) max ${g.maxMs}ms`),typeof g.gpuCacheBytes=="number"&&typeof g.gpuCacheLimitBytes=="number"&&console.log(` ${"".padEnd(10)} gpu cache ${(g.gpuCacheBytes/1024/1024).toFixed(1)}MB/${(g.gpuCacheLimitBytes/1024/1024).toFixed(1)}MB`)}let p=e.renderProfile;if(p&&typeof p=="object"){console.log(""),console.log(" render profile (per frame):"),console.log(` node visits: ${p.nodeVisitsPerFrame}`),console.log(` boundaries: ${p.recordsPerFrame} records (${p.avgBoundaryRecordMs}ms) / ${p.replaysPerFrame} replays`),console.log(` raster tier: ${p.rasterPromotionsPerFrame} promotions / ${p.rasterBlitsPerFrame} blits`);let g=[p.rasterRejectRebuild?`rebuild ${p.rasterRejectRebuild}`:"",p.rasterRejectLinear?`linear ${p.rasterRejectLinear}`:"",p.rasterRejectAnimated?`animated ${p.rasterRejectAnimated}`:"",p.rasterRejectTransform?`transform ${p.rasterRejectTransform}`:"",p.rasterRejectOpacity?`opacity ${p.rasterRejectOpacity}`:"",p.rasterRejectCacheable?`cacheable ${p.rasterRejectCacheable}`:"",p.rasterRejectBounds?`bounds ${p.rasterRejectBounds}`:"",p.rasterRejectPixels?`pixels ${p.rasterRejectPixels}`:"",p.rasterRejectBudget?`budget ${p.rasterRejectBudget}`:"",p.rasterWarming?`warming ${p.rasterWarming}`:""].filter(Boolean).join(" \xB7 ");g&&console.log(` raster skips: ${g} (total across run)`),console.log(` blur: ${p.avgBlurMs}ms`),console.log(` draw calls: text ${p.textDrawsPerFrame} \xB7 image ${p.imageDrawsPerFrame} \xB7 path ${p.pathDrawsPerFrame} \xB7 saveLayer ${p.saveLayersPerFrame}`)}let y=Array.isArray(e.worstFrames)?e.worstFrames:[];if(y.length>0){console.log(""),console.log(" worst observations (shell and compositor series are unpaired):");for(let g of y){if(g.source==="compositor"){console.log(` ${String(g.totalMs).padStart(7)}ms compositor ${g.surfaceId} paint ${g.paint} \xB7 layout ${g.layoutMs} \xB7 render ${g.renderMs} \xB7 flush ${g.flushMs}`);continue}let k=(g.auxSurfaces??[]).map(b=>`${b.surfaceId} ${b.totalMs}ms (layout ${b.layoutMs}, render ${b.renderMs})`).join(" \xB7 ");console.log(` ${String(g.totalMs).padStart(7)}ms overlay ${g.overlayMs} \xB7 aux ${g.auxMs} \xB7 layout ${g.layoutMs}${k?` [${k}]`:""}`)}}}async function Pe(e,o,s){let i=Date.now()+o,u=await ue(e,o);for(;;){if(s(u))return{settled:!0,state:u};if(Date.now()>=i)return{settled:!1,state:u};await oe(16),u=await ue(e)}}async function et(e){return e.send({type:"evaluate",code:`(async () => {
|
|
484
484
|
const kb = window.__sootsimKeyboard
|
|
485
485
|
const test = window.__sootsimTest
|
|
486
486
|
if (!kb) return { error: 'keyboard bridge not available' }
|
|
@@ -517,7 +517,7 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
517
517
|
frame: runtimeSnapshot?.keyboard?.frame ?? null,
|
|
518
518
|
focusedRect: runtimeSnapshot?.focused?.rect ?? null,
|
|
519
519
|
}
|
|
520
|
-
})()`}).then(o=>Qe(o))}function
|
|
520
|
+
})()`}).then(o=>Qe(o))}function $s(e,o,s){if(!e.visible)return!1;let i=e.focusedInput;return!(o&&i&&!(i.testID===o||i.id===o)||s!==null&&we(e)!==s)}async function xs(e,o=600,s={}){let i=Date.now()+o;for(;Date.now()<=i;){let u=await et(e);if($s(u,s.targetId??null,s.secureTextEntry??null))return u;await oe(30)}return et(e)}async function Re(e,o){let s=await et(e);if(s.visible&&s.focusedInput)return s;s.visible&&(console.error(` ${o} requires a focused TextInput. the iOS keyboard is visible, but no input owns focus.`),process.exit(1)),console.error(` ${o} 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 So(e,o,s){return o==="appearance"?e.send({type:"evaluate",code:`(async () => {
|
|
521
521
|
const requested = ${JSON.stringify(s??"toggle")}
|
|
522
522
|
// the engine owns toggle + auto resolution (settingsStore is the single
|
|
523
523
|
// source of truth). never infer the current scheme client-side \u2014 the old
|
|
@@ -540,26 +540,26 @@ import{a as ce}from"./chunk-EURBYQXU.js";import{b as Et,c as Rt,k as Pt}from"./c
|
|
|
540
540
|
})()`}):e.send({type:"evaluate",code:`(async () => {
|
|
541
541
|
window.dispatchEvent(new CustomEvent('sootsim:shake'))
|
|
542
542
|
return { ok: true, action: 'shake' }
|
|
543
|
-
})()`})}function Ss(e){let o={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(o[e])return o[e];let s=e.match(/^Digit([0-9])$/);if(s)return s[1];let
|
|
544
|
-
`),process.exit(0))}if(
|
|
545
|
-
`),process.exit(0))}let t=De("inspect"
|
|
543
|
+
})()`})}function Ss(e){let o={Enter:"return",NumpadEnter:"return",Backspace:"delete",Delete:"delete",Space:"space",ShiftLeft:"shift",ShiftRight:"shift"};if(o[e])return o[e];let s=e.match(/^Digit([0-9])$/);if(s)return s[1];let i=e.match(/^Key([A-Z])$/);return i?i[1].toLowerCase():null}function vs(e){if(typeof e!="string")return null;let o=e.replace(/\s+/g," ").trim();return o?o.slice(0,80):null}function Io(...e){for(let o of e){if(typeof o!="string")continue;let s=o.trim();if(s)return s}return null}function ks(e){let o=e.indexOf("--node-id");if(o<0)return null;let s=e[o+1];if(!s)return null;let i=Number(s);return Number.isInteger(i)&&i>0?i:null}async function q(e,o,s){let i=Fe({source:e,step:o,summary:s});i.active&&(i.replaced?console.error(` draft: replaced unkept action "${i.replaced.summary}" \u2014 \`maestro keep\` commits one action at a time`):console.error(" draft: action pending \u2014 `sootsim maestro keep` to commit"))}function vo(e,o,s){if(!s||s.hit===!1)return null;let i=Io(s.responderTestID,s.testID);if(i)return{step:{tapOn:{id:i}},summary:`tap #${i}`};let u=vs(s.text);return u?{step:{tapOn:u},summary:`tap "${u}"`}:{step:{tapAtCoords:{x:e,y:o}},summary:`tap @${Math.round(e)},${Math.round(o)}`}}function Ze(e,o,s){let i=Io(o?.testID,o?.id);return i?{step:{tapOn:{id:i}},summary:`tap #${i}`}:s==="id"?{step:{tapOn:{id:e}},summary:`tap #${e}`}:{step:{tapOn:e},summary:`tap "${e}"`}}async function Or(e,o){let s=e[0]==="get"||e[0]==="do"||e[0]==="debug"||e[0]==="wait"?e[0]:null,i=s?e.slice(1):e,u=_t(i,{port:o.port,commandTimeoutMs:o.timeoutMs,stripBooleanFlags:["--verbose","-v","--help","-h","--clear-state","--json","--all","--watch","-w","--strict","--no-wait","--dump","--failed","--slow","--tail","-f","--interactive-targets","--actions","--internal","--compact","--no-xy","--no-clipped","--include-occluded"],stripValueFlags:["--output","--nth","--index","--testid","--test-id","--text","--node-id","--max-ms","--filter","--limit","--level","--threshold","--equals","--since","--testid-like","--only","--subtree"]}),l=u.positional,p=l[0],y=s==="get"||s==="do"||s==="debug"||s==="wait"?s:"inspect",g=typeof i[0]=="string"&&tt.has(i[0]),k=g?i[0]:null,b=$=>o.internalPerfCommand&&$==="perf"?`sootsim perf ${o.internalPerfCommand}`:g&&$===i[0]?`sootsim ${$}`:`sootsim ${y} ${$}`,I=($,t)=>` usage: ${b($)}${t?` ${t}`:""}`;if(!p||e.includes("--help")||e.includes("-h")){let $={bridgePort:7668,defaultShellUrl:ot};if(y==="do"||y==="get"||y==="debug"||y==="wait"){let r=Ae(y,$);r&&(console.log(`${r}
|
|
544
|
+
`),process.exit(0))}if(k==="shell"){let r=De("shell",$);r&&(console.log(`${r}
|
|
545
|
+
`),process.exit(0))}let t=De("inspect",$),n=["do","get","debug","wait"].map(r=>Ae(r,$)).filter(r=>r!=null).join(`
|
|
546
546
|
|
|
547
547
|
`);console.log(`${t??""}
|
|
548
548
|
|
|
549
549
|
${n}
|
|
550
|
-
`),process.exit(0)}let M=
|
|
551
|
-
`);let n=Math.max(...t.map(
|
|
552
|
-
`)}catch{}}function F(
|
|
550
|
+
`),process.exit(0)}let M=u.wsPort,N=u.simId,j=u.simIdSource,O=u.commandTimeoutMs;if(y==="get"&&p==="diagnosis"){let $=i.indexOf("diagnosis"),t=$>=0?[...i.slice(0,$),...i.slice($+1)]:i,{runDiagnose:n}=await import("./diagnose-YYUH2HKW.js"),r=await n(["recent",...t],o);process.exitCode=r;return}if(y==="do"&&p==="scan"){let{runCamera:$}=await import("./camera-VWTIE3VW.js");await $(i,{port:o.port});return}if(p==="list"&&i.some($=>$==="--drivers"||$==="-D")){let{buildDriverListRows:$}=await import("./drivers-IHDBZZUB.js"),t=$();console.log(` available drivers (${t.length}):
|
|
551
|
+
`);let n=Math.max(...t.map(a=>a.id.length),6),r=Math.max(...t.map(a=>a.kind.length),4);for(let a of t){let d=a.available?"\u2713":"\u2717",m=a.id.padEnd(n),f=a.kind.padEnd(r);console.log(` ${d} ${m} ${f} ${a.description}`),a.available&&a.detail?console.log(` ${a.detail}`):!a.available&&a.reason&&console.log(` unavailable: ${a.reason}`)}return}let c=It(u),L=N||"default",R=new Set(["errors","warnings","requests","js","eval","reload","globals","perf","storage-clear","list","wait","sleep"]),P=200;function K($){let t=$.replace(/\s+/g," ").trim();if(!t)return"";if(/^<(!doctype html|html|\?xml)|<body[\s>]/i.test(t)){let r=/<title[^>]*>([^<]+)<\/title>/i.exec($)?.[1]?.trim(),a=/<body[^>]*>([\s\S]*?)<\//i.exec($)?.[1]?.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80),d=r||a||"html error page";return`<html ${$.length}B> "${d}" (body elided \u2014 add --json for the full payload)`}return t.length<=P?t:`${t.slice(0,P)}\u2026 (+${t.length-P} more bytes)`}function U($){let t=$.displayUrl||$.url;return $.status!=null?`${$.method} ${t} -> ${$.status}${$.statusText?` ${$.statusText}`:""}`:$.error?`${$.method} ${t} -> ${$.error}`:`${$.method} ${t}`}async function v($){let t=me()?400:200;try{let{settled:n,elapsed:r}=await se({bridge:$,maxMs:t,pollMs:32,stablePolls:2});n||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.
|
|
552
|
+
`)}catch{}}function F($,t){if(t.result?.reason==="offscreen"){let{x:n,y:r,screen:a}=t.result;console.error(` tap failed: ${$} resolved to (${Math.round(n)},${Math.round(r)}), outside the ${a?.width}x${a?.height} screen`),console.error(" the node exists but is scrolled out of view \u2014 scroll it on-screen first (sootsim do scroll / swipe), then tap.");return}console.error(` tap failed: ${$} stayed visible but did not receive a hittable press after ${t.attempts} attempt${t.attempts===1?"":"s"}`),t.result&&console.error(` last result: ${JSON.stringify(t.result)}`)}async function J(){try{return await c.send({type:"evaluate",code:`(() => ({
|
|
553
553
|
console: ${_e},
|
|
554
554
|
requests: window.__sootsimTest?.getRequestCounts?.() || null,
|
|
555
|
-
}))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function H(
|
|
556
|
-
network: ${n} failed request${n===1?"":"s"}`),console.log(` inspect: ${
|
|
555
|
+
}))()`})||{console:null,requests:null}}catch{return{console:null,requests:null}}}async function H($={}){let t=$.counts!==void 0?$.counts:await X(c,"getRequestCounts");if(!t||typeof t!="object")return;let n=Math.max(0,Number(t.failed)||0);if(n===0||!$.includeTail&&!Ye("requests",L,String(n))||(console.log(`
|
|
556
|
+
network: ${n} failed request${n===1?"":"s"}`),console.log(` inspect: ${b("requests")} 5`),!$.includeTail))return;let r=await X(c,"getFailedRequests",5);if(!(!Array.isArray(r)||r.length===0)){console.log(`
|
|
557
557
|
recent failed requests:
|
|
558
|
-
`);for(let
|
|
559
|
-
note: ${t.label} is open${n} \u2014 taps/drags hit it, not the app`)}}async function te(
|
|
560
|
-
console: ${d.join(", ")}`),console.log(` inspect: ${
|
|
558
|
+
`);for(let a of r){let d=ie(a.timestamp);console.log(` [${d}] ${U(a)}`),a.responseBody?console.log(` ${K(a.responseBody)}`):a.error&&console.log(` ${a.error}`)}}}function ee($){for(let t of $){let n=t.title?` (\u201C${t.title}\u201D)`:"";console.log(`
|
|
559
|
+
note: ${t.label} is open${n} \u2014 taps/drags hit it, not the app`)}}async function te($={}){let t=$.counts!==void 0?$.counts:await c.send({type:"evaluate",code:_e});if(!t||typeof t!="object")return;let n=t,r=Math.max(0,Number(n.errors)||0),a=Math.max(0,Number(n.warnings)||0);if(r===0&&a===0||!$.includeTail&&!Ye("console",L,`${r}:${a}`))return;let d=[];if(r>0&&d.push(`${r} console error${r===1?"":"s"}`),a>0&&d.push(`${a} console warning${a===1?"":"s"}`),console.log(`
|
|
560
|
+
console: ${d.join(", ")}`),console.log(` inspect: ${b("errors")} 5`),a>0&&console.log(` inspect: ${b("warnings")} 5`),!$.includeTail||r===0)return;let m=await fe(c,5);if(!(!Array.isArray(m)||m.length===0)){console.log(`
|
|
561
561
|
recent console errors:
|
|
562
|
-
`);for(let f of m){let w=ie(f.timestamp),
|
|
562
|
+
`);for(let f of m){let w=ie(f.timestamp),h=Array.isArray(f.args)?f.args.map(S=>typeof S=="object"?JSON.stringify(S):String(S)).join(" "):String(f);console.log(` [${w}] ${h}`)}}}let re=["console","fetch","toast","alert","notification","screen","app-launch","keyboard","route","actionsheet","picker","shell","scroll","gesture","text-input","animation","reanimated"];async function xe($){let t=st(),n=null;try{n=await Nt($,`(() => {
|
|
563
563
|
const tl = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.timeline
|
|
564
564
|
if (!tl || typeof tl.summary !== 'function') return null
|
|
565
565
|
const cursorKey = ${JSON.stringify(t)}
|
|
@@ -575,9 +575,9 @@ ${n}
|
|
|
575
575
|
}
|
|
576
576
|
}
|
|
577
577
|
return summary ? { summary, consoleSplit } : null
|
|
578
|
-
})()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},
|
|
579
|
-
since last: ${
|
|
580
|
-
`);for(let n of t){let r=[];if(r.push(`[${n.role}]`),n.label){let
|
|
578
|
+
})()`)}catch{return}if(!n||!n.summary||!n.summary.total)return;let r=n.summary.byKind??{},a=[],d=new Set;for(let m of re){let f=r[m];if(f)if(d.add(m),m==="console"&&n.consoleSplit){let{error:w,warn:h}=n.consoleSplit;w>0&&a.push(`${w} error${w===1?"":"s"}`),h>0&&a.push(`${h} warning${h===1?"":"s"}`)}else a.push(`${f} ${m}${f===1?"":"s"}`)}for(let[m,f]of Object.entries(r))!d.has(m)&&f&&a.push(`${f} ${m}${f===1?"":"s"}`);if(a.length!==0&&(console.log(`
|
|
579
|
+
since last: ${a.join(" \xB7 ")} \u2014 sootsim what-happened`),n.summary.lastAt))try{await ge($,"SootSim.bridges.timeline.cursorAdvance",t,n.summary.lastAt)}catch{}}let C=new Set(["tap","double-tap","tap-text","tap-id","type","type-into","key","key-sequence","keycode","drag","swipe","long-press","touch","gesture","pinch","scroll","shell","storage-clear"]),le=new Set(["a11y","capture","count","double-tap","drag","find","gesture","layout","long-press","node","pinch","sample-color","scroll","screenshot","swipe","tap","tap-id","tap-text","touch","tree","type-into"]),Se=(e.includes("--verbose")||e.includes("-v"))&&!e.includes("--json");y==="do"&&p==="shell"&&(console.error(" `sootsim do shell` was removed. use `sootsim shell ...` instead."),process.exit(1)),C.has(p)&&await Tt(c),le.has(p)&&await de(c,{verbose:Se});try{let $=C.has(p)&&!A(i)?await xt(c):[];switch(p){case"list":{kt(u.wsPort),await Zt({bridge:c,simId:N,args:i});break}case"tree":{await io({bridge:c,args:i,positional:l});break}case"a11y":{let t=await dt(c);if(!Array.isArray(t)||t.length===0){console.log(" no accessible nodes found");break}if(e.includes("--json"))console.log(JSON.stringify(t,null,2));else{console.log(` accessibility tree (${t.length} nodes):
|
|
580
|
+
`);for(let n of t){let r=[];if(r.push(`[${n.role}]`),n.label){let a=n.label.length>50?n.label.slice(0,47)+"...":n.label;r.push(`"${a}"`)}if(n.hint&&r.push(`(hint: "${n.hint}")`),n.testID&&r.push(`#${n.testID}`),n.state){let a=[];n.state.disabled&&a.push("disabled"),n.state.selected&&a.push("selected"),n.state.checked===!0&&a.push("checked"),n.state.checked==="mixed"&&a.push("mixed"),n.state.busy&&a.push("busy"),n.state.expanded===!0&&a.push("expanded"),n.state.expanded===!1&&a.push("collapsed"),a.length&&r.push(`{${a.join(", ")}}`)}n.position&&r.push(`@(${n.position.x},${n.position.y})`),n.size&&r.push(`${n.size.w}x${n.size.h}`),console.log(" "+r.join(" "))}}break}case"find":{await Xt({bridge:c,args:e,effectiveArgs:i,positional:l,inspectUsage:I});break}case"count":{await Yt(c,{args:i});break}case"keyboard":{await Qt(c,{json:e.includes("--json")});break}case"screens":{await so(c,{json:e.includes("--json")});break}case"memory":{await oo(c,{args:i});break}case"wait":{await lo({wsPort:M,commandTimeoutMs:O,simId:N,simIdSource:j,positional:l});break}case"sleep":{await ro({positional:l,inspectUsage:I});break}case"settle":{await no({bridge:c,args:e,positional:l});break}case"ready":{await mo({bridge:c,args:e});break}case"idle":{await po({bridge:c,args:e,positional:l});break}case"selector":{await fo({bridge:c,args:e,positional:l,inspectUsage:I});break}case"event":{await uo({bridge:c,args:e,positional:l,inspectUsage:I});break}case"layout":{let t=l[1];if(!t){await Vt({bridge:c,args:i});break}let n=await c.send({type:"evaluate",code:`(async () => await window.__sootsimTest.getLayout(${JSON.stringify(t)}))()`});console.log(JSON.stringify(n,null,2));break}case"capture":case"screenshot":{let n=e.find((w,h)=>e[h-1]==="--output")||"/tmp/sootsim-inspect.png",r=await $o(e,c),a={type:"screenshot"};r&&(a.crop=r);let m=(await c.send(a)).replace(/^data:image\/png;base64,/,"");r&&console.log(` area: x=${r.x} y=${r.y} w=${r.w} h=${r.h}`),(await import("fs")).writeFileSync(n,Buffer.from(m,"base64")),console.log(` saved: ${n}`);break}case"sample-color":{let t=await $o(e,c);t||(console.error(I("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 n=await c.send({type:"evaluate",code:Dt(t)});if(e.includes("--json"))console.log(JSON.stringify(n,null,2));else{let{r,g:a,b:d,a:m,hex:f,samples:w}=n,h=t.w===1&&t.h===1?`@(${t.x},${t.y})`:`@(${t.x},${t.y}) ${t.w}x${t.h}`;console.log(` ${f} rgba(${r}, ${a}, ${d}, ${m}) ${h} ${w} samples`)}break}case"node":{let t=l[1];t||(console.error(I("node","<matcher>")),console.error(" resolves testID, id, then text \u2014 dumps full node info as JSON"),process.exit(1));let n=await c.send({type:"evaluate",code:`(async () => {
|
|
581
581
|
const t = window.__sootsimTest
|
|
582
582
|
const q = ${JSON.stringify(t)}
|
|
583
583
|
let node = null
|
|
@@ -633,17 +633,17 @@ ${n}
|
|
|
633
633
|
transform,
|
|
634
634
|
parentChain,
|
|
635
635
|
}
|
|
636
|
-
})()`});console.log(JSON.stringify(n,null,2));break}case"tap":{let t=Number(l[1]),n=Number(l[2]),r
|
|
636
|
+
})()`});console.log(JSON.stringify(n,null,2));break}case"tap":{let t=Number(l[1]),n=Number(l[2]),r=$e(e);if(r){let m=await be(c,{agent:me(),textFallback:r.mode==="text"?r.value:void 0,resolve:async()=>{let h=await Oe(c,r);return h?{cx:h.x,cy:h.y,match:{id:r.mode==="testid"?r.value:h.id??null,testID:r.mode==="testid"?r.value:h.testID??null,text:r.mode==="text"?r.value:h.text??null,type:h.type??null},target:{id:h.id??null,testID:h.testID??null,text:h.text??null,type:h.type??null}}:null}}),f=m.payload;(!f||typeof f.cx!="number")&&(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),pe(m.result)||(F(`${r.mode} "${r.value}"`,m),process.exit(1));let w=vo(f.cx,f.cy,m.result);w&&await q("inspect tap",w.step,w.summary),console.log(JSON.stringify({...m.attempts>1?{attempts:m.attempts}:{},...m.result},null,2));break}(!Number.isFinite(t)||!Number.isFinite(n))&&(console.error(I("tap","<x> <y> | --testid <id> | --text <t>")),process.exit(1));let a=await Ht(c,t,n),d=vo(t,n,a);d&&await q("inspect tap",d.step,d.summary),console.log(JSON.stringify(a,null,2));break}case"drag":case"swipe":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),a=Number(l[4]),d=p==="swipe"?10:12,m=p==="swipe"?8:16,f=l[5]?Number(l[5]):d,w=l[6]?Number(l[6]):m;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(f)||!Number.isFinite(w))&&(console.error(I(p,"<x1> <y1> <x2> <y2> [steps] [stepMs]")),process.exit(1));let h=await c.send({type:"evaluate",code:`(async () => {
|
|
637
637
|
const interact = window.__sootsimInteract
|
|
638
638
|
if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
|
|
639
|
-
const value = await interact.drag(${t}, ${n}, ${r}, ${
|
|
639
|
+
const value = await interact.drag(${t}, ${n}, ${r}, ${a}, ${Math.max(1,Math.round(f))}, ${Math.max(0,Math.round(w))})
|
|
640
640
|
return { ok: !!value, value }
|
|
641
|
-
})()`});if(
|
|
641
|
+
})()`});if(h?.ok){let S=Math.max(1,Math.round(Math.max(1,f)*Math.max(0,w)));await q(`inspect ${p}`,{swipe:{start:`${t}, ${n}`,end:`${r}, ${a}`,duration:S}},`${p} ${t},${n} -> ${r},${a}`)}console.log(JSON.stringify(h,null,2));break}case"pinch":{let t=Number(l[1]),n=Number(l[2]),r=Number(l[3]),a=Number(l[4]),d=Number(l[5]),m=Number(l[6]),f=Number(l[7]),w=Number(l[8]),h=l[9]?Number(l[9]):12,S=l[10]?Number(l[10]):16;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(d)||!Number.isFinite(m)||!Number.isFinite(f)||!Number.isFinite(w)||!Number.isFinite(h)||!Number.isFinite(S))&&(console.error(I("pinch","<x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]")),process.exit(1));let W=await c.send({type:"evaluate",code:`(async () => {
|
|
642
642
|
const interact = window.__sootsimInteract
|
|
643
643
|
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
644
|
-
const value = await interact.pinch(${t}, ${n}, ${r}, ${
|
|
644
|
+
const value = await interact.pinch(${t}, ${n}, ${r}, ${a}, ${d}, ${m}, ${f}, ${w}, ${Math.max(1,Math.round(h))}, ${Math.max(0,Math.round(S))})
|
|
645
645
|
return { ok: !!value, value }
|
|
646
|
-
})()`});W?.ok&&await q("inspect pinch",{pinch:{from:[t,n,r,
|
|
646
|
+
})()`});W?.ok&&await q("inspect pinch",{pinch:{from:[t,n,r,a],to:[d,m,f,w],steps:Math.max(1,Math.round(h)),stepMs:Math.max(0,Math.round(S))}},`pinch (${t},${n}) (${r},${a}) -> (${d},${m}) (${f},${w})`),console.log(JSON.stringify(W,null,2));break}case"tap-text":{let t=l[1];t||(console.error(I("tap-text","<text>")),process.exit(1));let n=z=>{let B=e.indexOf(z);return B>=0&&B+1<e.length?e[B+1]:null},r=z=>e.includes(z),a=n("--nth")??n("--index"),d=a!==null?Number(a):null;d!==null&&!Number.isFinite(d)&&(console.error(` --nth/--index requires an integer, got: ${a}`),process.exit(1));let m=n("--within"),f=n("--role"),w=r("--exact"),h=r("--first"),S=n("--min-y"),W=n("--max-y"),V=n("--min-x"),G=n("--max-x");for(let[z,B]of[["--min-y",S],["--max-y",W],["--min-x",V],["--max-x",G]])B!==null&&!Number.isFinite(Number(B))&&(console.error(` ${z} requires a number, got: ${B}`),process.exit(1));let Y=e.indexOf("--near"),E=null;if(Y>=0){let z=Number(e[Y+1]),B=Number(e[Y+2]);(!Number.isFinite(z)||!Number.isFinite(B))&&(console.error(" --near requires two numbers: --near <x> <y>"),process.exit(1)),E={x:z,y:B}}let x={exact:w,role:f,within:m,minX:V!==null?Number(V):null,maxX:G!==null?Number(G):null,minY:S!==null?Number(S):null,maxY:W!==null?Number(W):null,near:E,nth:d,first:h},_=await Ut(c,t,x,{agent:me()}),T=_.payload;if(T?.error==="bridge-not-ready"&&(console.error(" sootsim test bridge not ready"),process.exit(1)),T?.ambiguous){let z=T.candidates;console.error(` ambiguous: ${T.total} matches for "${t}"`);for(let B of z){let ve=B.abs?`@(${Math.round(B.abs.x)},${Math.round(B.abs.y)})`:"",To=B.layout?` ${B.layout.width}x${B.layout.height}`:"",No=B.testID?` #${B.testID}`:"",Mo=B.text?` "${B.text}"`:"",Fo=B.ancestorTestIDs.length>0?` within ${B.ancestorTestIDs.slice(0,3).map(Oo=>`#${Oo}`).join(" > ")}`:"";console.error(` [${B.idx}] <${B.type}>${Mo}${No} ${ve}${To}${Fo}`)}T.total>z.length&&console.error(` ... and ${T.total-z.length} more`),console.error(" pick one:"),console.error(" --nth <index> pick the nth match (top-to-bottom, left-to-right; negatives from end)"),console.error(" --within <testID> narrow to descendants of a node"),console.error(" --min-y / --max-y geometric filter (pixels, absolute)"),console.error(" --min-x / --max-x geometric filter (pixels, absolute)"),console.error(" --near <x> <y> pick the closest match to a point"),console.error(" --exact exact text match (default is substring)"),console.error(" --role <role> narrow to accessibilityRole"),console.error(" --first keep the old pick-first-silently behavior"),process.exit(2)}T?.nthOutOfRange&&(console.error(` not found: nth ${T.nth} of ${T.total} match${T.total===1?"":"es"} for "${t}"`),process.exit(1)),(!T||typeof T.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),pe(_.result)||(F(`text "${t}"`,_),process.exit(1));let ne=Ze(t,{id:T.target?.id??null,testID:T.target?.testID??null,type:T.target?.type??null,cx:T.cx,cy:T.cy},"text");await q("inspect tap-text",ne.step,ne.summary),console.log(JSON.stringify({matched:T.match,tapped:{nodeId:T.target?.nodeId??null,id:T.target?.id??null,testID:T.target?.testID??null,type:T.target?.type??null,cx:T.cx,cy:T.cy},...T.strategy&&T.strategy!=="matched-node"?{strategy:T.strategy}:{},...T.total>1||d!==null?{nth:{index:T.idx,total:T.total}}:{},..._.attempts>1?{attempts:_.attempts}:{},result:_.result},null,2));break}case"tap-best":{let t=l[1];t||(console.error(I("tap-best","<query>")),process.exit(1));let n=await Gt(c,t,{agent:me()}),r=n.payload;r||(console.error(` tap-best: no testID or visible text matched "${t}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1)),"error"in r&&(console.error(` ${r.error}`),process.exit(1)),r.strategy==="none"&&(console.error(` tap-best: no testID or visible text matched "${t}". try \`sootsim find --interactive-targets\` to list candidates.`),process.exit(1));let a=r.node;pe(n.result)||(F(`best "${t}"`,n),process.exit(1));let d=Ze(t,{id:a.id,testID:a.testID,type:a.type,cx:r.cx,cy:r.cy},r.strategy==="testid"?"id":"text");await q("inspect tap-best",d.step,d.summary),console.log(JSON.stringify({matched:{strategy:r.strategy,nodeId:a.nodeId,id:a.id,testID:a.testID,type:a.type,text:a.text},tapped:{cx:r.cx,cy:r.cy},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"tap-id":{let t=l[1];t||(console.error(I("tap-id","<id>")),process.exit(1));let n=await Kt(c,t,{agent:me()}),r=n.payload;(!r||typeof r.cx!="number")&&(console.error(` not found: ${t}`),await ps(c,t),process.exit(1)),pe(n.result)||(F(`id "${t}"`,n),process.exit(1));let a=Ze(t,{id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},"id");await q("inspect tap-id",a.step,a.summary),console.log(JSON.stringify({matched:r.match,tapped:{nodeId:r.target?.nodeId??null,id:r.target?.id??null,testID:r.target?.testID??null,type:r.target?.type??null,cx:r.cx,cy:r.cy},...r.strategy&&r.strategy!=="matched-node"?{strategy:r.strategy}:{},...n.attempts>1?{attempts:n.attempts}:{},result:n.result},null,2));break}case"type-into":{let t=l[1],n=l.slice(2).join(" ");(!t||!n)&&(console.error(I("type-into","<id> <text>")),process.exit(1));let r=JSON.stringify(t),a=await c.send({type:"evaluate",code:`(async () => {
|
|
647
647
|
const t = window.__sootsimTest
|
|
648
648
|
if (!t) return null
|
|
649
649
|
const n = await (t.findByTestId(${r}) || t.findById(${r}))
|
|
@@ -658,7 +658,7 @@ ${n}
|
|
|
658
658
|
secureTextEntry: !!n.secureTextEntry,
|
|
659
659
|
placeholder: n.placeholder || null,
|
|
660
660
|
}
|
|
661
|
-
})()`});(!
|
|
661
|
+
})()`});(!a||typeof a.cx!="number")&&(console.error(` not found: ${t}`),process.exit(1)),a.isTextInput||console.error(` warning: ${t} is not a text input (isTextInput: false)`);let d=await c.send({type:"tap",x:a.cx,y:a.cy,target:{id:a.id??t,testID:a.testID??t,text:null,type:a.type??null}}),m=a.secureTextEntry===!0,f=await xs(c,1e3,{targetId:t,secureTextEntry:m});f.visible||(console.error(` keyboard did not open after tapping ${t}`),process.exit(1));let w=f.focusedInput;w&&(w.testID===t||w.id===t||(console.error(` focus routing mismatch after tap: requested ${JSON.stringify(t)} but focus is on ${JSON.stringify(w.testID??w.id??null)}. did the tap land on an outer Pressable wrapper?`),process.exit(1))),await c.send({type:"keyboard",action:"type",text:n});let h=m||we(f),S=h?Z:Ve(n,f),W=h&&f.focusedInput?{...f.focusedInput,secureTextEntry:!0,text:typeof f.focusedInput.text=="string"?Z:f.focusedInput.text}:f.focusedInput??null;await q("inspect type-into",{tapOn:{id:t},inputText:S},S===Z?`type-into #${t} ${Z}`:`type-into #${t} ${JSON.stringify(n)}`),console.log(JSON.stringify({target:t,isTextInput:a.isTextInput,secureTextEntry:h,keyboardOpened:f.visible??d?.keyboardOpened??!1,focusedInput:W,typed:S},null,2));break}case"type":{let t=l.slice(1).join(" ");t||(console.error(I("type","<text>")),process.exit(1));let n=await Re(c,"type");await c.send({type:"keyboard",action:"type",text:t});let r=Ve(t,n);await q("inspect type",{inputText:r},r===Z?`type ${Z}`:`type ${JSON.stringify(t)}`),console.log(r===Z?` typed: ${Z}`:` typed: ${JSON.stringify(t)}`);break}case"key":{let t=l[1];t||(console.error(I("key","<name>")),process.exit(1)),await Re(c,"key"),await c.send({type:"keyboard",action:"press",text:t}),await q("inspect key",{pressKey:t},`key ${t}`),console.log(` pressed: ${t}`);break}case"key-sequence":{let t=l.slice(1);t.length===0&&(console.error(I("key-sequence","<key> [<key> ...]")),process.exit(1)),await Re(c,"key-sequence");for(let n of t)await c.send({type:"keyboard",action:"press",text:n});await q("inspect key-sequence",{pressKey:t.join(" ")},`key-sequence ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"keycode":{let t=l.slice(1);t.length===0&&(console.error(I("keycode","<code> [<code> ...]")),process.exit(1));let n=t.map(a=>({code:a,key:Ss(a)})),r=n.filter(a=>!a.key);r.length>0&&(console.error(` unsupported keycode(s): ${r.map(a=>a.code).join(", ")}`),process.exit(1)),await Re(c,"keycode");for(let a of n)await c.send({type:"keyboard",action:"press",text:a.key});await q("inspect keycode",{pressKey:n.map(a=>a.key).join(" ")},`keycode ${t.join(" ")}`),console.log(` pressed: ${t.join(", ")}`);break}case"dispatch":{let t=l[1];t||(console.error(I("dispatch","<char>")),process.exit(1)),await c.send({type:"keyboard",action:"dispatchKey",text:t}),await q("inspect dispatch",{dispatchKey:t},`dispatch ${JSON.stringify(t)}`),console.log(` dispatched: ${t}`);break}case"dismiss":{await c.send({type:"keyboard",action:"dismiss"}),await q("inspect dismiss",{hideKeyboard:!0},"dismiss keyboard"),console.log(" keyboard dismissed");break}case"double-tap":{let t=Number(l[1]),n=Number(l[2]),r=$e(e);if(r){let f=await Oe(c,r);f||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),t=f.x,n=f.y}let a=l[3]?Number(l[3]):80;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(a))&&(console.error(I("double-tap","<x> <y> [gapMs] | --testid <id>")),process.exit(1));let d=Math.max(0,Math.round(a)),m=await c.send({type:"evaluate",code:`(async () => {
|
|
662
662
|
const interact = window.__sootsimInteract
|
|
663
663
|
if (interact?.doubleTap) {
|
|
664
664
|
return {
|
|
@@ -681,13 +681,13 @@ ${n}
|
|
|
681
681
|
first,
|
|
682
682
|
second,
|
|
683
683
|
}
|
|
684
|
-
})()`});m?.ok&&await q("inspect double-tap",{doubleTapAtCoords:{x:t,y:n,gapMs:d}},`double-tap @${t},${n}`),console.log(JSON.stringify(m,null,2));break}case"long-press":{let t=Number(l[1]),n=Number(l[2]),r
|
|
684
|
+
})()`});m?.ok&&await q("inspect double-tap",{doubleTapAtCoords:{x:t,y:n,gapMs:d}},`double-tap @${t},${n}`),console.log(JSON.stringify(m,null,2));break}case"long-press":{let t=Number(l[1]),n=Number(l[2]),r=$e(e),a=null;if(r){let h=await Oe(c,r);h||(console.error(` not found: ${r.value}`),r.mode==="testid"&&Q("wait-selector-for-missing-testid",r.value),process.exit(1)),t=h.x,n=h.y,a={id:h.id??null,testID:h.testID??null,text:h.text??null,type:h.type??null}}let d=r?l[1]:l[3],m=d?Number(d):600;(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(m))&&(console.error(I("long-press","<x> <y> [durationMs] | --testid <id>")),process.exit(1));let f=Math.max(0,Math.round(m)),w=await c.send({type:"longPress",x:t,y:n,durationMs:f,target:a});w?.ok&&await q("inspect long-press",{tapAtCoords:{x:t,y:n}},`long-press @${t},${n}`),console.log(JSON.stringify(w,null,2));break}case"touch":{let t=l[1],n=Number(l[2]),r=Number(l[3]),a=l[4]?Number(l[4]):999,d=t==="down"?"touchDown":t==="move"?"touchMove":t==="up"?"touchUp":t==="cancel"?"touchCancel":null;d||(console.error(I("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1)),t!=="cancel"&&(!Number.isFinite(n)||!Number.isFinite(r))&&(console.error(I("touch","<down|move|up|cancel> <x> <y> [pointerId]")),process.exit(1));let m=t==="down"?"tap":t==="move"?"move":null,f=m&&Number.isFinite(n)&&Number.isFinite(r)?`window.dispatchEvent(new CustomEvent('sootsim:agentAction', { detail: { type: '${m}', x: ${n}, y: ${r} } }));`:"",w=await c.send({type:"evaluate",code:`(async () => {
|
|
685
685
|
${f}
|
|
686
686
|
const interact = window.__sootsimInteract
|
|
687
687
|
if (!interact?.${d}) return { ok: false, reason: 'no interact.${d}' }
|
|
688
|
-
const value = ${t==="cancel"?`await interact.${d}(${Math.max(1,Math.round(
|
|
688
|
+
const value = ${t==="cancel"?`await interact.${d}(${Math.max(1,Math.round(a))})`:`await interact.${d}(${n}, ${r}, ${Math.max(1,Math.round(a))})`}
|
|
689
689
|
return { ok: !!value, value }
|
|
690
|
-
})()`});w?.ok&&t!=="cancel"&&await q("inspect touch",{tapAtCoords:{x:n,y:r}},`touch ${t} @${n},${r}`),console.log(JSON.stringify(w,null,2));break}case"gesture":{let t=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],n=l[1],r=l[2]?Number(l[2]):220;(!n||!Number.isFinite(r))&&(console.error(I("gesture","<preset> [durationMs]")),console.error(` presets: ${t.join(", ")}`),process.exit(1)),t.includes(n)||(console.error(` unknown gesture preset: ${n}`),console.error(` presets: ${t.join(", ")}`),process.exit(1));let
|
|
690
|
+
})()`});w?.ok&&t!=="cancel"&&await q("inspect touch",{tapAtCoords:{x:n,y:r}},`touch ${t} @${n},${r}`),console.log(JSON.stringify(w,null,2));break}case"gesture":{let t=["scroll-up","scroll-down","scroll-left","scroll-right","swipe-from-left-edge","swipe-from-right-edge","swipe-from-top-edge","swipe-from-bottom-edge"],n=l[1],r=l[2]?Number(l[2]):220;(!n||!Number.isFinite(r))&&(console.error(I("gesture","<preset> [durationMs]")),console.error(` presets: ${t.join(", ")}`),process.exit(1)),t.includes(n)||(console.error(` unknown gesture preset: ${n}`),console.error(` presets: ${t.join(", ")}`),process.exit(1));let a=await c.send({type:"evaluate",code:`(async () => {
|
|
691
691
|
const spec = globalThis.__sootsimDeviceSpec || {}
|
|
692
692
|
return {
|
|
693
693
|
width: spec.width || window.innerWidth || 393,
|
|
@@ -695,12 +695,12 @@ ${n}
|
|
|
695
695
|
statusBarHeight: spec.statusBarHeight || 0,
|
|
696
696
|
homeIndicatorHeight: spec.homeIndicatorHeight || 0,
|
|
697
697
|
}
|
|
698
|
-
})()`}),d=Number(
|
|
698
|
+
})()`}),d=Number(a?.width)||393,m=Number(a?.height)||852,f=Number(a?.statusBarHeight)||0,w=Number(a?.homeIndicatorHeight)||0,h=Math.round(d/2),S=Math.round(m/2),W=Math.max(24,f+18),V=Math.max(24,w+18),G=18,Y=Math.min(220,Math.round(m*.24)),E=Math.min(180,Math.round(d*.32)),x=h,_=S,T=h,ne=S;switch(n){case"scroll-up":_=S+Math.round(Y/2),ne=S-Math.round(Y/2);break;case"scroll-down":_=S-Math.round(Y/2),ne=S+Math.round(Y/2);break;case"scroll-left":x=h+Math.round(E/2),T=h-Math.round(E/2);break;case"scroll-right":x=h-Math.round(E/2),T=h+Math.round(E/2);break;case"swipe-from-left-edge":x=G,_=S,T=Math.min(d-G,G+E);break;case"swipe-from-right-edge":x=d-G,_=S,T=Math.max(G,d-G-E);break;case"swipe-from-top-edge":x=h,_=W,ne=Math.min(m-V,W+Y);break;case"swipe-from-bottom-edge":x=h,_=m-V,ne=Math.max(W,m-V-Y);break}let z=Math.max(8,Math.round(r/16)),B=Math.max(1,Math.round(r/z)),ve=await c.send({type:"evaluate",code:`(async () => {
|
|
699
699
|
const interact = window.__sootsimInteract
|
|
700
700
|
if (!interact?.drag) return { ok: false, reason: 'no interact.drag' }
|
|
701
|
-
const value = await interact.drag(${
|
|
701
|
+
const value = await interact.drag(${x}, ${_}, ${T}, ${ne}, ${z}, ${B})
|
|
702
702
|
return { ok: !!value, value }
|
|
703
|
-
})()`});ve?.ok&&await q("inspect gesture",{swipe:{start:`${
|
|
703
|
+
})()`});ve?.ok&&await q("inspect gesture",{swipe:{start:`${x}, ${_}`,end:`${T}, ${ne}`,duration:Math.max(1,Math.round(r))}},`gesture ${n}`),console.log(JSON.stringify({preset:n,from:{x,y:_},to:{x:T,y:ne},result:ve},null,2));break}case"scroll":{let t=$e(e),n=ks(e),r=t?.mode==="testid"?t.value:n==null?l[1]:null,a=t||n!=null?1:2,d=Number(l[a]),m=Number(l[a+1]);(!r&&n==null||!Number.isFinite(d)||!Number.isFinite(m))&&(console.error(I("scroll","<id> <x> <y> | --testid <id> <x> <y> | --node-id <nodeId> <x> <y>")),process.exit(1));let f=await c.send({type:"evaluate",code:`(async () => {
|
|
704
704
|
const t = window.__sootsimTest
|
|
705
705
|
if (!t) return null
|
|
706
706
|
const n = ${n!=null?`await t.inspectByNodeId(${JSON.stringify(n)})`:`await t.findByTestId(${JSON.stringify(r)})
|
|
@@ -710,8 +710,8 @@ ${n}
|
|
|
710
710
|
cx: n.absolutePosition.x + (n.layout.width || 0) / 2,
|
|
711
711
|
cy: n.absolutePosition.y + (n.layout.height || 0) / 2,
|
|
712
712
|
}
|
|
713
|
-
})()`}),w=await X(
|
|
714
|
-
${
|
|
713
|
+
})()`}),w=await X(c,"scrollTo",n!=null?{nodeId:n}:r,d,m,!1);if(w?.ok){let h=n!=null?`node ${n}`:`#${r}`;await q("inspect scroll",{scrollTo:{...n!=null?{nodeId:n}:{id:r},x:d,y:m}},`scroll ${h} -> ${d},${m}`)}console.log(JSON.stringify({...w,...f?{at:{x:f.cx,y:f.cy}}:{}},null,2));break}case"state":{let t=l[1];if(s==="get"&&!t){let r=await X(c,"getRuntimeState"),a=await c.send({type:"evaluate",code:_e});if(r&&typeof r=="object"&&r.diagnostics&&(r.diagnostics.errors=a?.errors??0,r.diagnostics.warnings=a?.warnings??0),r&&typeof r=="object"&&r.shell==null)try{let d=await ue(c);d&&(r.shell=d)}catch{}console.log(JSON.stringify(r,null,2));break}if(!t||t==="--help"||t==="-h"){console.log(`
|
|
714
|
+
${b("state")} \u2014 dump raw runtime state
|
|
715
715
|
|
|
716
716
|
subcommands:
|
|
717
717
|
shell dump shell transition/layout state
|
|
@@ -727,22 +727,22 @@ ${n}
|
|
|
727
727
|
gesture-seam dump shell-hosted gesture recognizer state/events
|
|
728
728
|
|
|
729
729
|
examples:
|
|
730
|
-
${
|
|
731
|
-
${
|
|
732
|
-
${
|
|
733
|
-
${
|
|
734
|
-
${
|
|
735
|
-
${
|
|
736
|
-
${
|
|
737
|
-
${
|
|
738
|
-
${
|
|
739
|
-
`);break}let n;switch(t){case"shell":n=await ue(
|
|
730
|
+
${b("state")} shell
|
|
731
|
+
${b("state")} worker
|
|
732
|
+
${b("state")} keyboard
|
|
733
|
+
${b("state")} ownership
|
|
734
|
+
${b("state")} worklets
|
|
735
|
+
${b("state")} node photos
|
|
736
|
+
${b("state")} scroll feed
|
|
737
|
+
${b("state")} scroll-hit 360 420
|
|
738
|
+
${b("state")} hit 200 720
|
|
739
|
+
`);break}let n;switch(t){case"shell":n=await ue(c,500);break;case"worker":n=await ge(c,"__sootsimRenderHost.queryStats");break;case"ownership":n=await c.send({type:"evaluate",code:`(() => {
|
|
740
740
|
const h = window.__sootsimRenderHost
|
|
741
741
|
if (!h || typeof h.getOwnershipSnapshot !== 'function') {
|
|
742
742
|
return { error: 'getOwnershipSnapshot not available' }
|
|
743
743
|
}
|
|
744
744
|
return h.getOwnershipSnapshot()
|
|
745
|
-
})()`});break;case"keyboard":n=await
|
|
745
|
+
})()`});break;case"keyboard":n=await c.send({type:"evaluate",code:`(async () => {
|
|
746
746
|
const kb = window.__sootsimKeyboard
|
|
747
747
|
const test = window.__sootsimTest
|
|
748
748
|
if (!kb) return { error: 'keyboard bridge not available' }
|
|
@@ -770,8 +770,8 @@ ${n}
|
|
|
770
770
|
text: secureTextEntry ? ${JSON.stringify(Z)} : (focused.text || null),
|
|
771
771
|
} : null,
|
|
772
772
|
}
|
|
773
|
-
})()`}),n=Qe(n);break;case"node":{let r=l[2];r||(console.error(` usage: ${
|
|
774
|
-
${
|
|
773
|
+
})()`}),n=Qe(n);break;case"node":{let r=l[2];r||(console.error(` usage: ${b("state")} node <id>`),process.exit(1)),n=await X(c,"findByTestId",r)||await X(c,"findById",r);break}case"scroll":{let r=l[2];r||(console.error(` usage: ${b("state")} scroll <id>`),process.exit(1)),n=await X(c,"getScrollState",r);break}case"scroll-hit":{let r=Number(l[2]),a=Number(l[3]);(!Number.isFinite(r)||!Number.isFinite(a))&&(console.error(` usage: ${b("state")} scroll-hit <x> <y>`),process.exit(1)),n=await X(c,"getScrollStateAt",r,a);break}case"hit":{let r=Number(l[2]),a=Number(l[3]);(!Number.isFinite(r)||!Number.isFinite(a))&&(console.error(` usage: ${b("state")} hit <x> <y>`),process.exit(1)),n=await X(c,"debugHitAt",r,a);break}case"gesture":{let r=Number(l[2]),a=Number(l[3]);(!Number.isFinite(r)||!Number.isFinite(a))&&(console.error(` usage: ${b("state")} gesture <x> <y>`),process.exit(1)),n=await X(c,"debugGestureAt",r,a);break}case"gesture-seam":n=await ge(c,"SootSim.bridges.mainShell.callTestBridge","getShellGestureSeamDebug");break;case"worklets":{let[r,a]=await Promise.all([X(c,"getWorkletSlotStats"),ge(c,"SootSim.bridges.mainShell.callTestBridge","getWorkletSlotStats")]);n={tenant:r,shell:a};break}default:console.error(` unknown state subcommand: ${t}`),process.exit(1)}console.log(JSON.stringify(n,null,2));break}case"shell":{let t=l[1];if(!t||t==="--help"||t==="-h"){console.log(`
|
|
774
|
+
${b("shell")} \u2014 run built-in shell commands
|
|
775
775
|
|
|
776
776
|
subcommands:
|
|
777
777
|
launch <appId> [waitMs] [--clear-state]
|
|
@@ -786,15 +786,15 @@ ${n}
|
|
|
786
786
|
shake trigger the simulator shake gesture
|
|
787
787
|
|
|
788
788
|
examples:
|
|
789
|
-
${
|
|
790
|
-
${
|
|
791
|
-
${
|
|
792
|
-
${
|
|
793
|
-
${
|
|
794
|
-
${
|
|
795
|
-
${
|
|
796
|
-
${
|
|
797
|
-
`);break}let n=t==="launch"||t==="open-card"||t==="home"||t==="switcher",r=t==="launch"||t==="open-card"?l[3]:l[2],
|
|
789
|
+
${b("shell")} launch photos
|
|
790
|
+
${b("shell")} launch rn --clear-state
|
|
791
|
+
${b("shell")} launch photos 1500
|
|
792
|
+
${b("shell")} home 500
|
|
793
|
+
${b("shell")} switcher 800
|
|
794
|
+
${b("shell")} open-card clock 800
|
|
795
|
+
${b("shell")} appearance dark
|
|
796
|
+
${b("shell")} lock
|
|
797
|
+
`);break}let n=t==="launch"||t==="open-card"||t==="home"||t==="switcher",r=t==="launch"||t==="open-card"?l[3]:l[2],a=r?Number(r):350;n&&(!Number.isFinite(a)||a<0)&&(console.error(I("shell",t==="launch"||t==="open-card"?"<launch|open-card> <appId> [settleMs]":"<home|switcher> [settleMs]")),process.exit(1));let d=!1,m=!1,f=null,w=e.includes("--clear-state");if(t==="launch"){let h=l[2];h||(console.error(I("shell","launch <appId> [settleMs] [--clear-state]")),process.exit(1)),w&&await c.send({type:"evaluate",code:qe(!0)}),d=!!await ye(c,"launchApp",a,h),{settled:m,state:f}=await Pe(c,Math.round(a),S=>!!S&&S.state==="app"&&S.activeApp===h&&S.showSwitcher===!1&&S.switcherPhase==="idle"&&typeof S.launchProgress=="number"&&S.launchProgress>=.98),d&&await q("inspect shell launch",w?{launchApp:{clearState:!0}}:{launchApp:{}},w?"launch app (clear state)":"launch app")}else if(t==="home")d=!!await ye(c,"goHome",a),{settled:m,state:f}=await Pe(c,Math.round(a),h=>!!h&&h.state==="home"&&h.activeApp==null&&h.showSwitcher===!1&&h.switcherPhase==="idle"&&typeof h.launchProgress=="number"&&h.launchProgress>=.98);else if(t==="switcher")d=!!await ye(c,"openSwitcher",a),{settled:m,state:f}=await Pe(c,Math.round(a),h=>!!h&&h.state==="app"&&h.showSwitcher===!0&&h.switcherPhase==="idle"&&typeof h.zoomLevel=="number"&&Math.abs(h.zoomLevel)<=.02&&typeof h.horizontalZoom=="number"&&Math.abs(h.horizontalZoom)<=.02),m&&(await oe(ws),f=await ue(c));else if(t==="open-card"){let h=l[2];h||(console.error(I("shell","open-card <appId> [settleMs]")),process.exit(1)),d=!!await ye(c,"openSwitcherCard",a,h),{settled:m,state:f}=await Pe(c,Math.round(a),S=>!!S&&S.state==="app"&&S.activeApp===h&&S.showSwitcher===!1&&S.switcherPhase==="idle"&&typeof S.zoomLevel=="number"&&S.zoomLevel>=.98&&typeof S.horizontalZoom=="number"&&S.horizontalZoom>=.98),d&&await q("inspect shell open-card",{openSwitcherCard:{appId:h}},`open switcher card ${h}`)}else if(t==="appearance"){let h=l[2];(!h||!["light","dark","auto","toggle"].includes(h))&&(console.error(I("shell","appearance <light|dark|auto|toggle>")),process.exit(1));let S=await So(c,"appearance",h);if(d=!!S?.ok,f={appearance:S},d){let W=S?.applied??h;console.log(` appearance: ${W}`)}}else if(t==="lock"||t==="shake"){let h=await So(c,t);d=!!h?.ok,f={[t]:h}}else console.error(` unknown shell subcommand: ${t}`),process.exit(1);console.log(JSON.stringify({ok:d,settled:m,state:f},null,2));break}case"url":{await ao(c,{args:i});break}case"reload":{let r=!1,a=!1;try{await c.send({type:"evaluate",code:"window.__sootsimConsole?.clear()"});let f=await c.send({type:"evaluate",code:`;(async () => {
|
|
798
798
|
// in-place guest reload is only valid while the page still runs
|
|
799
799
|
// the engine build the server would serve NOW. the shell dev
|
|
800
800
|
// server has no HMR client, so a long-lived sim tab otherwise
|
|
@@ -818,13 +818,13 @@ ${n}
|
|
|
818
818
|
}
|
|
819
819
|
window.location.reload()
|
|
820
820
|
return { kind: 'page', engineStale }
|
|
821
|
-
})()`});
|
|
821
|
+
})()`});a=!!f&&f.kind==="external-app",r=!0,f&&f.engineStale&&console.log(" engine build changed since page load \u2014 full page reload")}catch{}console.log(" reloading...");let d=c,m=null;if(a)m=await Te(c,{timeoutMs:1e4,errorGraceMs:3e3});else{r&&await oe(300);let w=await Ft(M,O,N,{timeoutMs:3e4,simIdSource:j});w?(d=w,m=await Te(w,{timeoutMs:3e4,errorGraceMs:3e3})):(console.log(" \u26A0 reload: bridge never reconnected within 30000ms"),d=null)}if(m)if(m.ready){let f=m.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` ready in ${m.elapsedMs}ms: ${m.nodes} nodes${f}`)}else if(m.source==="error-bail")console.log(` \u26A0 reload bailed after ${m.elapsedMs}ms: ${m.errors} console error(s), ready signal never fired`);else{let f=yo(m);console.log(` \u26A0 reload timed out after ${m.elapsedMs}ms \u2014 ${f} (nodes: ${m.nodes}, targets: ${m.targets}, errors: ${m.errors})`)}if(d)try{let f=await fe(d,10);if(d!==c&&d.close(),Array.isArray(f)&&f.length>0){console.log(`
|
|
822
822
|
\u26A0 ${f.length} error(s) during mount:
|
|
823
|
-
`);for(let w of f){let
|
|
824
|
-
`).slice(0,2);for(let W of S)console.log(` ${W.trim()}`)}}}}catch{}m&&!m.ready&&(process.exitCode=1);break}case"storage-clear":{if(await Le(
|
|
823
|
+
`);for(let w of f){let h=w.args.map(S=>typeof S=="object"?JSON.stringify(S):S).join(" ");if(console.log(` ${h}`),w.stack){let S=w.stack.split(`
|
|
824
|
+
`).slice(0,2);for(let W of S)console.log(` ${W.trim()}`)}}}}catch{}m&&!m.ready&&(process.exitCode=1);break}case"storage-clear":{if(await Le(c),await c.send({type:"evaluate",code:qe(!0)})!==!0){A(i)?D({cleared:!1,ready:!1,error:"external app reload bridge is unavailable"}):console.error(" storage clear failed: external app reload bridge is unavailable"),process.exitCode=1;break}let a=await Te(c,{timeoutMs:1e4,errorGraceMs:3e3});if(A(i)){D({cleared:!0,ready:a.ready,reload:a}),a.ready||(process.exitCode=1);break}if(a.ready){let d=a.source==="nodes-fallback"?" (no ready signal, node-count fallback)":"";console.log(` cleared tenant storage; ready in ${a.elapsedMs}ms: ${a.nodes} nodes${d}`)}else if(a.source==="error-bail")console.log(` \u26A0 storage clear reloaded but bailed after ${a.elapsedMs}ms: ${a.errors} console error(s), ready signal never fired`);else{let d=yo(a);console.log(` \u26A0 storage clear reloaded but timed out after ${a.elapsedMs}ms \u2014 ${d} (nodes: ${a.nodes}, targets: ${a.targets}, errors: ${a.errors})`)}try{let d=await fe(c,10);if(Array.isArray(d)&&d.length>0){console.log(`
|
|
825
825
|
\u26A0 ${d.length} error(s) during mount:
|
|
826
826
|
`);for(let m of d){let f=m.args.map(w=>typeof w=="object"?JSON.stringify(w):w).join(" ");if(console.log(` ${f}`),m.stack){let w=m.stack.split(`
|
|
827
|
-
`).slice(0,2);for(let
|
|
827
|
+
`).slice(0,2);for(let h of w)console.log(` ${h.trim()}`)}}}}catch{}a.ready||(process.exitCode=1);break}case"eval":case"js":{let t=l.slice(1).join(" ");if(t||(console.error(I("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)),e.includes("--tenant")){let m=l.slice(1).filter(w=>w!=="--tenant").join(" "),f=await c.send({type:"evaluate",code:`(async () => SootSim.bridges.test.evalInTenant(${JSON.stringify(m)}))()`});console.log(JSON.stringify(f,null,2));break}let n=t;n.startsWith("(async")||(n=`(async () => ${n})()`);let r=await c.send({type:"evaluate",code:n});console.log(JSON.stringify(r,null,2));let a=t.toLowerCase(),d=[];(a.includes("sootsim:gohome")||a.includes("gohome"))&&d.push("sootsim shell home"),(a.includes("sootsim:appswitcher")||a.includes("appswitcher"))&&d.push("sootsim shell switcher"),(a.includes("keyboard.isvisible")||a.includes("keyboard.getmode"))&&d.push("sootsim debug state keyboard"),a.includes("interact.tap")&&d.push("sootsim do tap <x> <y>"),a.includes("keyboard.type")&&d.push("sootsim do type <text>"),(a.includes("keyboard.press")||a.includes("keyboard.dispatchkey"))&&d.push("sootsim do key <name>"),a.includes("keyboard.dismiss")&&d.push("sootsim do dismiss"),a.includes("dumptree")&&d.push("sootsim get tree"),a.includes("dumpaccessibilitytree")&&d.push("sootsim get a11y"),a.includes("getnodecount")&&d.push("sootsim get count"),a.includes("findbytext")&&d.push("sootsim find <text>"),(a.includes("findbytestid")||a.includes("findbyid"))&&d.push("sootsim find --testid <id>"),a.includes("document.hidden")&&d.push("sootsim debug state keyboard (includes tab health)"),d.length>0&&Q("prefer-cli-over-eval",d);break}case"globals":{let t=await c.send({type:"evaluate",code:`(async () => {
|
|
828
828
|
const globals = {}
|
|
829
829
|
|
|
830
830
|
// test bridge (proxy in worker mode)
|
|
@@ -862,8 +862,34 @@ ${n}
|
|
|
862
862
|
|
|
863
863
|
return globals
|
|
864
864
|
})()`});console.log(` sootsim JS API:
|
|
865
|
-
`);for(let[n,r]of Object.entries(t)){console.log(` ${n}:`);for(let
|
|
866
|
-
${
|
|
865
|
+
`);for(let[n,r]of Object.entries(t)){console.log(` ${n}:`);for(let a of r)console.log(` .${a}`);console.log("")}console.log(` use: ${b("js")} <expression>`),console.log(` example: ${b("js")} test.findByText("Sign in")`);break}case"describe":{await zt({bridge:c,args:e,positional:l});break}case"perf":{y==="debug"&&!o.internalPerfCommand&&(console.error(" `sootsim debug perf` was removed. use `sootsim perf shell ...`."),process.exit(1));let t=l[1];if(o.internalPerfCommand==="scroll"){if(!t||t==="--help"||t==="-h"){console.log(`
|
|
866
|
+
${b("perf")} <start|stop> [options]
|
|
867
|
+
|
|
868
|
+
records per-frame scroll offsets from the tenant worker, shell worker,
|
|
869
|
+
and compositor worker. timestamps use the shared wall clock, while frame
|
|
870
|
+
sequences remain separate because the workers do not share a frame id.
|
|
871
|
+
|
|
872
|
+
options:
|
|
873
|
+
--limit <n> maximum samples retained per layer (default 6000)
|
|
874
|
+
--json emit every per-frame sample on stop
|
|
875
|
+
|
|
876
|
+
examples:
|
|
877
|
+
${b("perf")} start
|
|
878
|
+
# ... perform consecutive swipes ...
|
|
879
|
+
${b("perf")} stop
|
|
880
|
+
${b("perf")} stop --json
|
|
881
|
+
`);break}if(t==="start"){let n=i.find((d,m)=>i[m-1]==="--limit"),r=n===void 0?6e3:Number(n);(!Number.isFinite(r)||r<120)&&(console.error(" error: --limit must be a number of at least 120"),process.exit(1));let a=await c.send({type:"evaluate",code:`(async () => {
|
|
882
|
+
const perf = window.SootSim?.bridges?.scrollPerf
|
|
883
|
+
if (!perf) return { error: 'scroll performance profile unavailable' }
|
|
884
|
+
await perf.start(${Math.floor(r)})
|
|
885
|
+
return { started: true }
|
|
886
|
+
})()`});a?.error&&(console.error(` error: ${a.error}`),process.exit(1)),console.log(` scroll profiling started: perform consecutive swipes, then run '${b("perf")} stop'`);break}if(t==="stop"){let n=await c.send({type:"evaluate",code:`(async () => {
|
|
887
|
+
const perf = window.SootSim?.bridges?.scrollPerf
|
|
888
|
+
if (!perf) return { error: 'scroll performance profile unavailable' }
|
|
889
|
+
return await perf.stop()
|
|
890
|
+
})()`});n?.error&&(console.error(` error: ${n.error}`),process.exit(1));let r=n;if(A(i)){D(r);break}console.log(` scroll performance trace:
|
|
891
|
+
`),console.log(` duration: ${r.stoppedAt-r.startedAt}ms (worker series are timestamp-aligned, not frame-paired)`),console.log(` samples: tenant ${r.layers.tenant.length} \xB7 shell ${r.layers.shell.length} \xB7 compositor ${r.layers.compositor.length}`),console.log(""),console.log(" offset and phase changes (--json includes every per-frame sample):"),console.log(" t(ms) layer surface node offsetY slotY phase paint");let a=[];for(let d of Object.values(r.layers)){let m=new Map;for(let f of d){let w=`${f.surfaceId}:${f.nodeId}`,h=`${f.offsetY}:${f.slotY??""}:${f.phase??""}`;m.get(w)!==h&&(m.set(w,h),a.push(f))}}a.sort((d,m)=>d.t-m.t||d.seq-m.seq);for(let d of a)console.log(` ${String(d.t-r.startedAt).padStart(5)} ${d.layer.padEnd(10)} ${d.surfaceId.padEnd(8)} ${String(d.nodeId).padStart(5)} ${d.offsetY.toFixed(2).padStart(8)} ${d.slotY===void 0?" -":d.slotY.toFixed(2).padStart(8)} ${(d.phase??"-").padEnd(8)} ${d.paint===void 0?"-":d.paint}`);break}console.error(` unknown scroll perf command: ${t}`),process.exit(1)}if(!t||t==="--help"||t==="-h"){console.log(`
|
|
892
|
+
${b("perf")} \u2014 shell frame profiling (the worker that paints)
|
|
867
893
|
|
|
868
894
|
records per-painted-frame timing in the shell worker \u2014 the surface that
|
|
869
895
|
actually draws the app's pixels \u2014 merged with render-profile counters
|
|
@@ -877,24 +903,24 @@ ${n}
|
|
|
877
903
|
stop and transition accept --json for the full machine-readable payload.
|
|
878
904
|
|
|
879
905
|
examples:
|
|
880
|
-
${
|
|
906
|
+
${b("perf")} start
|
|
881
907
|
# ... interact with the app ...
|
|
882
|
-
${
|
|
883
|
-
${
|
|
884
|
-
${
|
|
885
|
-
`);break}switch(t){case"start":{let n=await
|
|
908
|
+
${b("perf")} stop
|
|
909
|
+
${b("perf")} stop --json
|
|
910
|
+
${b("perf")} transition goHome
|
|
911
|
+
`);break}switch(t){case"start":{let n=await c.send({type:"evaluate",code:`(() => {
|
|
886
912
|
if (!window.__sootsimShellPerf) {
|
|
887
913
|
return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
|
|
888
914
|
}
|
|
889
915
|
window.__sootsimShellPerf.start()
|
|
890
916
|
return { started: true }
|
|
891
|
-
})()`});n?.error&&(console.error(` error: ${n.error}`),process.exit(1)),console.log(` shell profiling started \u2014 interact with the app, then run '${
|
|
917
|
+
})()`});n?.error&&(console.error(` error: ${n.error}`),process.exit(1)),console.log(` shell profiling started \u2014 interact with the app, then run '${b("perf")} stop'`);break}case"stop":{let n=await c.send({type:"evaluate",code:`(async () => {
|
|
892
918
|
if (!window.__sootsimShellPerf) {
|
|
893
919
|
return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
|
|
894
920
|
}
|
|
895
921
|
return await window.__sootsimShellPerf.stop()
|
|
896
|
-
})()`});if(n?.error&&(console.error(` error: ${n.error}`),n.error==="timeout"&&console.error(" (shell worker did not answer within 5s \u2014 is a sim loaded?)"),process.exit(1)),A(
|
|
897
|
-
${
|
|
922
|
+
})()`});if(n?.error&&(console.error(` error: ${n.error}`),n.error==="timeout"&&console.error(" (shell worker did not answer within 5s \u2014 is a sim loaded?)"),process.exit(1)),A(i)){D(n);break}xo(n);break}case"transition":{let n=l[2];if(!n||!["goHome","appSwitcher","lockScreen"].includes(n)){console.log(`
|
|
923
|
+
${b("perf")} transition <event> \u2014 profile a shell transition
|
|
898
924
|
|
|
899
925
|
events:
|
|
900
926
|
goHome swipe-to-home animation
|
|
@@ -904,43 +930,43 @@ ${n}
|
|
|
904
930
|
note: uses 600ms capture window \u2014 may need --timeout 10000 flag
|
|
905
931
|
|
|
906
932
|
examples:
|
|
907
|
-
${
|
|
908
|
-
${
|
|
909
|
-
`);break}let
|
|
933
|
+
${b("perf")} transition goHome --timeout 10000
|
|
934
|
+
${b("perf")} transition appSwitcher
|
|
935
|
+
`);break}let a=`sootsim:${n}`;Ie(` profiling ${n} transition...`),Ie(" (use --timeout 10000 if this times out)");let d=await c.send({type:"evaluate",code:`(async () => {
|
|
910
936
|
if (!window.__sootsimShellPerf) {
|
|
911
937
|
return { error: 'shell frame profile unavailable (__sootsimShellPerf missing on the page)' }
|
|
912
938
|
}
|
|
913
939
|
window.__sootsimShellPerf.start()
|
|
914
940
|
// give a frame for profiling to engage before the event
|
|
915
941
|
await new Promise(r => requestAnimationFrame(() => r(undefined)))
|
|
916
|
-
window.dispatchEvent(new Event('${
|
|
942
|
+
window.dispatchEvent(new Event('${a}'))
|
|
917
943
|
// shell animations are ~300-500ms; fixed timing avoids complex
|
|
918
944
|
// animation-end detection
|
|
919
945
|
await new Promise(r => setTimeout(r, 600))
|
|
920
946
|
return await window.__sootsimShellPerf.stop()
|
|
921
|
-
})()`});if(d?.error&&(console.error(` error: ${d.error}`),process.exit(1)),A(
|
|
922
|
-
`);for(let
|
|
923
|
-
`).slice(0,3);for(let w of f)console.log(` ${w.trim()}`)}}break}case"warnings":{let t=l[1]?Number(l[1]):20,n=await gt(
|
|
924
|
-
`);for(let r of n){let
|
|
925
|
-
`);for(let n of t){let r=String(n.kind).padEnd(6),
|
|
926
|
-
`);for(let m of d){let f=ie(m.timestamp);console.log(` [${f}] ${U(m)}`),m.responseBody?console.log(` ${m.responseBody}`):m.error&&console.log(` ${m.error}`)}break}case"network":{let t=l[1],n=null,r=null,
|
|
947
|
+
})()`});if(d?.error&&(console.error(` error: ${d.error}`),process.exit(1)),A(i)){D(d);break}Ie(` ${n} transition profiled:`),xo(d);break}default:console.error(` unknown perf subcommand: ${t}`),console.error(" valid: start, stop, transition"),/^--?reset$/.test(t)&&console.error(" note: 'perf start' already clears prior frames \u2014 no reset needed"),(t==="stats"||t==="frames"||t==="worst")&&(console.error(" note: the tenant sampler (stats/frames/worst) was removed \u2014 it hardcoded"),console.error(" layout/render/copy to zero because the shell worker owns every real paint."),console.error(" use 'perf start' / 'perf stop' (worst frames are in the stop report).")),process.exit(1)}break}case"errors":{let t=l[1];if(t==="clear"){await Le(c),A(i)?D({cleared:!0}):console.log(" error buffer cleared");break}let n=t?Number(t):20,r=await fe(c,n);if(A(i)){D(r);break}if(r.length===0){console.log(" no errors captured");break}console.log(` ${r.length} error(s):
|
|
948
|
+
`);for(let a of r){let d=ie(a.timestamp),m=a.args.map(f=>typeof f=="object"?JSON.stringify(f):f).join(" ");if(console.log(` [${d}] ${m}`),a.stack){let f=a.stack.split(`
|
|
949
|
+
`).slice(0,3);for(let w of f)console.log(` ${w.trim()}`)}}break}case"warnings":{let t=l[1]?Number(l[1]):20,n=await gt(c,t);if(A(i)){D(n);break}if(n.length===0){console.log(" no warnings captured");break}console.log(` ${n.length} warning(s):
|
|
950
|
+
`);for(let r of n){let a=ie(r.timestamp),d=r.args.map(m=>typeof m=="object"?JSON.stringify(m):m).join(" ");console.log(` [${a}] ${d}`)}break}case"animations":{let t=await X(c,"listAnimations")??[];if(e.includes("--json")){console.log(JSON.stringify(t,null,2));break}if(t.length===0){console.log(" no active animations");break}console.log(` ${t.length} active animation(s):
|
|
951
|
+
`);for(let n of t){let r=String(n.kind).padEnd(6),a=`${Number(n.from).toFixed(2)}\u2192${Number(n.to).toFixed(2)}`,d=Number(n.current??0).toFixed(2),m=`${Math.round((n.progress??0)*100)}%`,f=`${Math.round(n.elapsedMs??0)}ms`,w=n.loop?" loop":"",h=n.layoutBound?" layout":"";console.log(` #${n.id} ${r} ${a.padEnd(14)} cur=${d.padEnd(7)} ${m.padStart(4)} ${f}${w}${h}`)}break}case"animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${b("animation")} <id>`),process.exit(1));let n=Number(t);Number.isFinite(n)||(console.error(` invalid id: ${t}`),process.exit(1));let r=await X(c,"getAnimation",n);console.log(JSON.stringify(r,null,2));break}case"stop-animation":{let t=l[1];(!t||t==="--help"||t==="-h")&&(console.error(` usage: ${b("stop-animation")} <id|all>`),process.exit(1));let n=t==="all"?"all":Number(t);n!=="all"&&!Number.isFinite(n)&&(console.error(` invalid id: ${t}`),process.exit(1));let r=await X(c,"stopAnimation",n);console.log(` stopped ${r??0} animation(s)`);break}case"requests":{let t=l[1];if(t==="clear"){await ht(c),A(i)?D({cleared:!0}):console.log(" request buffer cleared");break}let n=t==="all",r=n?l[2]:t,a=r?Number(r):20,d=await yt(c,{failed:!n,limit:a});if(A(i)){D(d);break}if(d.length===0){console.log(n?" no requests captured":" no failed requests captured");break}console.log(` ${d.length} ${n?"request(s)":"failed request(s)"}:
|
|
952
|
+
`);for(let m of d){let f=ie(m.timestamp);console.log(` [${f}] ${U(m)}`),m.responseBody?console.log(` ${m.responseBody}`):m.error&&console.log(` ${m.error}`)}break}case"network":{let t=l[1],n=null,r=null,a=!1,d=!1,m=1e3,f=!1,w=!1;for(let E=0;E<i.length;E++){let x=i[E];if(x==="--filter")n=i[E+1]??null,E++;else if(x==="--limit"){let _=Number(i[E+1]);Number.isFinite(_)&&(r=_),E++}else if(x==="--threshold"){let _=Number(i[E+1]);Number.isFinite(_)&&_>0&&(m=_),E++}else x==="--failed"?a=!0:x==="--slow"?d=!0:x==="--tail"||x==="-f"?f=!0:x==="--json"&&(w=!0)}if(t==="clear"){await c.send({type:"evaluate",code:'window.__sootsimObservability?.network.clear(); "cleared"'}),console.log(" network buffer cleared");break}if(t==="get"){let E=l[2];E||(console.error(" usage: sootsim network get <id>"),process.exit(1));let x=await c.send({type:"evaluate",code:`(() => {
|
|
927
953
|
const obs = window.__sootsimObservability;
|
|
928
954
|
if (!obs) return null;
|
|
929
955
|
return obs.network.getSnapshot().find(e => e.id === ${JSON.stringify(E)}) || null;
|
|
930
|
-
})()`})
|
|
931
|
-
to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let S=async()=>{let E=await
|
|
956
|
+
})()`});x||(console.error(` no entry with id ${E}`),process.exit(1)),w?console.log(JSON.stringify(x,null,2)):ys(x);break}let h=r??(f?200:t?Number(t):20);Number.isFinite(h)||(console.error(` invalid limit: ${t} \u2014 \`network\` takes a numeric count (e.g. ${b("network")} 100).
|
|
957
|
+
to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let S=async()=>{let E=await c.send({type:"evaluate",code:`(() => {
|
|
932
958
|
const obs = window.__sootsimObservability;
|
|
933
959
|
if (!obs) return { ok: false };
|
|
934
960
|
return { ok: true, entries: obs.network.getSnapshot() };
|
|
935
|
-
})()`});if(!E||!E.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return E.entries??[]},W=E=>{let
|
|
936
|
-
`:` ${
|
|
937
|
-
`);for(let
|
|
938
|
-
`);let V=new Set,G=!0,
|
|
939
|
-
to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let W=()=>bt(
|
|
940
|
-
`);for(let T of
|
|
941
|
-
`);let G=new Set,
|
|
961
|
+
})()`});if(!E||!E.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return E.entries??[]},W=E=>{let x=E;if(a&&(x=x.filter(_=>!!_.error||_.status!=null&&_.status>=400)),d&&(x=x.filter(_=>_.durationMs!=null&&_.durationMs>=m)),n){let _=n.toLowerCase();x=x.filter(T=>(T.displayUrl||T.url).toLowerCase().includes(_))}return d&&!f&&(x=[...x].sort((_,T)=>(T.durationMs??0)-(_.durationMs??0))),x};if(!f){let E=await S(),x=W(E).slice(-h);if(w){console.log(JSON.stringify(x,null,2));break}if(x.length===0){E.length===0?console.log(" no network requests captured"):console.log(d?` no requests slower than ${m}ms (${E.length} total \u2014 try --threshold <ms>)`:" no matching requests");break}console.log(d?` ${x.length} request(s) slower than ${m}ms (sorted by duration desc):
|
|
962
|
+
`:` ${x.length} request(s):
|
|
963
|
+
`);for(let _ of x)ho(_);break}console.log(` tailing network (ctrl-c to stop)...
|
|
964
|
+
`);let V=new Set,G=!0,Y=()=>{G=!1};process.on("SIGINT",Y);try{for(;G;){let E=await S(),x=W(E);for(let _ of x)_.durationMs!=null&&(V.has(_.id)||(V.add(_.id),w?console.log(JSON.stringify(_)):ho(_)));await oe(250)}}finally{process.off("SIGINT",Y)}break}case"logs":{let t=l[1],n=null,r=null,a=null,d=!1,m=!1,f=!1;for(let x=0;x<i.length;x++){let _=i[x];if(_==="--filter")n=i[x+1]??null,x++;else if(_==="--limit"){let T=Number(i[x+1]);Number.isFinite(T)&&(r=T),x++}else _==="--level"?(a=i[x+1]??null,x++):_==="--tail"||_==="-f"?d=!0:_==="--json"?m=!0:(_==="--internal"||_==="--all")&&(f=!0)}let w=a?new Set(a.split(",").map(x=>x.trim()).filter(x=>x==="log"||x==="info"||x==="warn"||x==="error"||x==="debug")):null;if(t==="clear"){await wt(c),console.log(" log buffer cleared");break}let h=!m&&process.stdout.isTTY===!0,S=r??(d?500:t?Number(t):50);Number.isFinite(S)||(console.error(` invalid limit: ${t} \u2014 \`logs\` takes a numeric count (e.g. ${b("logs")} 100).
|
|
965
|
+
to target a specific sim, use \`--sim ${t}\` instead.`),process.exit(1));let W=()=>bt(c),V=x=>$t(x,{level:w,filter:n,showInternal:f});if(!d){let x=await W(),_=V(x).slice(-S);if(m){console.log(JSON.stringify(_,null,2));break}if(_.length===0){console.log(x.length===0?" no logs captured":" no matching logs");break}console.log(` ${_.length} log(s):
|
|
966
|
+
`);for(let T of _)wo(T,h);break}console.log(` tailing logs (ctrl-c to stop)...
|
|
967
|
+
`);let G=new Set,Y=!0,E=()=>{Y=!1};process.on("SIGINT",E);try{for(;Y;){let x=await W(),_=V(x);for(let T of _)G.has(T.id)||(G.add(T.id),m?console.log(JSON.stringify(T)):wo(T,h));await oe(250)}}finally{process.off("SIGINT",E)}break}default:console.error(` unknown subcommand: ${p}`),process.exit(1)}if(C.has(p)&&!e.includes("--no-wait")&&process.env.SOOTSIM_NO_AUTO_WAIT!=="1"&&!await nt(c,p)&&await v(c),$.length>0&&ee($),!R.has(p)&&!A(i))try{await xe(c)}catch{}}catch($){let t=$ instanceof Error?$.message:String($);console.error(` ${p??"inspect"} failed: ${t}`);let n=/^no sim connected with id (.+)$/.exec(t),r=/^command timed out after (\d+)s$/.exec(t),a=t.startsWith("sim disconnected:")||t.startsWith("bridge never reconnected")||t.startsWith("could not connect to ws://");if(n)await Pt(c,M,n[1]);else if(/^no sim connected$/.test(t))Et(M);else if(r)if(await ds(c)){let m=p??"describe";process.stderr.write(` the sim is still responsive \u2014 '${m}' just exceeded the ${r[1]}s command budget.
|
|
942
968
|
the screen's node tree is large; narrow the query or raise the budget:
|
|
943
969
|
sootsim ${m} --testid <id> # scope to one subtree
|
|
944
970
|
sootsim find --testid <id> # targeted single-node lookup
|
|
945
971
|
sootsim ${m} --timeout 60000 # raise per-command budget (ms)
|
|
946
|
-
`)}else go();else if(
|
|
972
|
+
`)}else go();else if(a)go();else{try{await Ot(c)}catch{}try{await te({includeTail:!0})}catch{}try{await H({includeTail:!0})}catch{}}process.exit(1)}finally{c.close()}}export{qe as a,At as b,Eo as c,Ns as d,As as e,Ds as f,Bs as g,Cs as h,se as i,xo as j,Or as k};
|