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