sootsim 0.0.1 → 0.0.3
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 +12 -0
- package/dist-cli/bin.js +16 -10
- package/dist-cli/chunks/agent-D5NBV32O.js +61 -0
- package/dist-cli/chunks/agent-wrapper-Y7I5QGHM.js +15 -0
- package/dist-cli/chunks/assert-EJ7DQS2H.js +47 -0
- package/dist-cli/chunks/auto-bootstrap-Q7GNLISM.js +2 -0
- package/dist-cli/chunks/{chunk-7X6OPSRD.js → chunk-2FPPPJE5.js} +2 -2
- package/dist-cli/chunks/{chunk-G5MR66EB.js → chunk-3K6VDPVD.js} +2 -2
- package/dist-cli/chunks/{chunk-PWXPA745.js → chunk-3SLEIN6B.js} +1 -1
- package/dist-cli/chunks/chunk-3WPAEUOO.js +1 -0
- package/dist-cli/chunks/chunk-44CBTM22.js +2 -0
- package/dist-cli/chunks/chunk-46LRF7PH.js +5 -0
- package/dist-cli/chunks/chunk-4RYT6AQV.js +16 -0
- package/dist-cli/chunks/chunk-5AG24UFX.js +119 -0
- package/dist-cli/chunks/chunk-5IPP4HAW.js +5 -0
- package/dist-cli/chunks/{chunk-J2S3OCWA.js → chunk-AFTHIY3L.js} +1 -1
- package/dist-cli/chunks/chunk-BU3TZP4Y.js +11 -0
- package/dist-cli/chunks/chunk-BYLX2DO4.js +27 -0
- package/dist-cli/chunks/chunk-CPMW2QLM.js +1 -0
- package/dist-cli/chunks/{chunk-YCETS3B3.js → chunk-CQ6PX2EU.js} +2 -2
- package/dist-cli/chunks/chunk-D4JFMCXD.js +2 -0
- package/dist-cli/chunks/chunk-EEBR5YP5.js +62 -0
- package/dist-cli/chunks/chunk-EQ7G3UHS.js +4 -0
- package/dist-cli/chunks/{chunk-64TOMNZX.js → chunk-FTRI7SVV.js} +2 -2
- package/dist-cli/chunks/{chunk-GPVPHE2B.js → chunk-H3JVJXOC.js} +2 -2
- package/dist-cli/chunks/chunk-LV5U7TI4.js +1 -0
- package/dist-cli/chunks/chunk-NKJLTISU.js +4 -0
- package/dist-cli/chunks/chunk-O2HBPZW5.js +22 -0
- package/dist-cli/chunks/{chunk-KSACMDXK.js → chunk-OG5CKIPC.js} +2 -2
- package/dist-cli/chunks/{chunk-E522F5JW.js → chunk-P5C3UASK.js} +1 -1
- package/dist-cli/chunks/chunk-REYWQVAH.js +2 -0
- package/dist-cli/chunks/chunk-RLS6PHBW.js +4 -0
- package/dist-cli/chunks/chunk-SUZR2SZZ.js +34 -0
- package/dist-cli/chunks/{chunk-OROM7DZI.js → chunk-USRNDVQ3.js} +1 -1
- package/dist-cli/chunks/{chunk-JSF5LPNT.js → chunk-UZL5ZZ4E.js} +5 -5
- package/dist-cli/chunks/{chunk-QOBRRY5X.js → chunk-VI3VW5BL.js} +1 -1
- package/dist-cli/chunks/chunk-WUYJFYOW.js +2 -0
- package/dist-cli/chunks/chunk-X2W4IRXK.js +3 -0
- package/dist-cli/chunks/chunk-XJBPH4JR.js +308 -0
- package/dist-cli/chunks/chunk-ZSRMXBGK.js +2 -0
- package/dist-cli/chunks/{compat-MRN2ORY5.js → compat-5KSMOWLB.js} +4 -4
- package/dist-cli/chunks/{config-CO5IYWUY.js → config-NJB6PQHU.js} +5 -5
- package/dist-cli/chunks/control-2F3AGZAO.js +2 -0
- package/dist-cli/chunks/{daemon-G4XVRFHM.js → daemon-MLG65V4S.js} +2 -2
- package/dist-cli/chunks/{debug-ZNSZTWT6.js → debug-QVOBTTLP.js} +4 -4
- package/dist-cli/chunks/demo-app-registry-XRYNJ4GC.js +2 -0
- package/dist-cli/chunks/{detox-JEGYNTYV.js → detox-ZZSNZL4T.js} +2 -2
- package/dist-cli/chunks/{device-BS34FAFM.js → device-PQB3YGHN.js} +2 -2
- package/dist-cli/chunks/drivers-GWDQEGWD.js +2 -0
- package/dist-cli/chunks/electron-JB26VHOO.js +15 -0
- package/dist-cli/chunks/flow-7JRQXMFV.js +2 -0
- package/dist-cli/chunks/{hints-7Z656W4H.js → hints-IGYDXXDS.js} +2 -2
- package/dist-cli/chunks/home-paths-CEGSGQTD.js +2 -0
- package/dist-cli/chunks/{inspect-NAHXP2M5.js → inspect-DSU6ELRM.js} +153 -165
- package/dist-cli/chunks/install-K6IJKADG.js +65 -0
- package/dist-cli/chunks/{install-desktop-PYIZIH67.js → install-desktop-SC3LNFFF.js} +8 -4
- package/dist-cli/chunks/install-dev-desktop-4DP3UY2X.js +100 -0
- package/dist-cli/chunks/keys-R5LAPAAL.js +19 -0
- package/dist-cli/chunks/launch-K3WJV4QA.js +16 -0
- package/dist-cli/chunks/{login-Z5Z54HUJ.js → login-A23PYJAW.js} +5 -5
- package/dist-cli/chunks/{logout-T2QDYGCB.js → logout-AJ24PH5O.js} +2 -2
- package/dist-cli/chunks/{maestro-4AXTS7OE.js → maestro-YALWKKGU.js} +2 -2
- package/dist-cli/chunks/{preview-NMGWHWMX.js → preview-D35EEONY.js} +2 -2
- package/dist-cli/chunks/{profile-6RGJA4FR.js → profile-MAF7NM5Q.js} +3 -3
- package/dist-cli/chunks/record-ZCPQNGFW.js +37 -0
- package/dist-cli/chunks/runtime-Z2WIXYUN.js +25 -0
- package/dist-cli/chunks/{screenshot-R3GCCSCI.js → screenshot-NQVZYC3C.js} +3 -3
- package/dist-cli/chunks/screenshot-mode-E45D2ZFH.js +17 -0
- package/dist-cli/chunks/{screenshots-4UQJE4NC.js → screenshots-I4SQI4DA.js} +2 -2
- package/dist-cli/chunks/server-ZUXKJRR5.js +29 -0
- package/dist-cli/chunks/{skills-2PPKPL4B.js → skills-N4U63E5W.js} +2 -2
- package/dist-cli/chunks/store-4A6X4GBJ.js +2 -0
- package/dist-cli/chunks/{test-5LFKOQ4M.js → test-VBD6N3AR.js} +3 -3
- package/dist-cli/chunks/upload-Y6FZ5XF2.js +2 -0
- package/dist-cli/chunks/{whoami-H6FW34JS.js → whoami-4K6JGMWH.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +414 -0
- package/dist-lib/agent-events.cjs +48 -0
- package/dist-lib/agent-sessions.cjs +692 -0
- package/dist-lib/attached-projects.cjs +448 -0
- package/dist-lib/auth/shared-session.cjs +174 -0
- package/dist-lib/backend-origin.cjs +70 -0
- package/dist-lib/bridge-constants.cjs +32 -0
- package/dist-lib/cli-constants.cjs +32 -0
- package/dist-lib/config.cjs +88 -0
- package/dist-lib/dev-bundle-resolution.cjs +236 -0
- package/dist-lib/home-paths.cjs +234 -0
- package/dist-lib/host/bridge-host.cjs +3458 -0
- package/dist-lib/index.cjs +361 -0
- package/dist-lib/metro.cjs +215 -0
- package/dist-lib/render-mode.cjs +54 -0
- package/dist-lib/vite-base.cjs +4217 -0
- package/dist-lib/vite.cjs +178 -0
- package/package.json +80 -13
- package/scripts/postinstall.cjs +70 -0
- package/dist-cli/chunks/bridge-host-2EY7Z4AO.js +0 -2
- package/dist-cli/chunks/chunk-3C3ZH7PP.js +0 -4
- package/dist-cli/chunks/chunk-3R4ZZESY.js +0 -119
- package/dist-cli/chunks/chunk-74XPLOV4.js +0 -2
- package/dist-cli/chunks/chunk-7LMDCMSI.js +0 -8
- package/dist-cli/chunks/chunk-A2CZQIWO.js +0 -1
- package/dist-cli/chunks/chunk-CKZ376AY.js +0 -322
- package/dist-cli/chunks/chunk-E5UBZEYR.js +0 -2
- package/dist-cli/chunks/chunk-HOIHCO7S.js +0 -3
- package/dist-cli/chunks/chunk-KQWZZ56P.js +0 -2
- package/dist-cli/chunks/chunk-KSB6MSZ4.js +0 -34
- package/dist-cli/chunks/chunk-KXYKAYYB.js +0 -51
- package/dist-cli/chunks/chunk-MBFP2LVH.js +0 -3
- package/dist-cli/chunks/chunk-MPSZ5EWF.js +0 -16
- package/dist-cli/chunks/chunk-X2U72K7X.js +0 -1
- package/dist-cli/chunks/control-Y7TKKB6D.js +0 -2
- package/dist-cli/chunks/dev-ZUKCZQEX.js +0 -25
- package/dist-cli/chunks/dev-checkout-IEZVVTCN.js +0 -2
- package/dist-cli/chunks/drivers-46PFFIDF.js +0 -2
- package/dist-cli/chunks/electron-P2KOPX2S.js +0 -15
- package/dist-cli/chunks/flow-VVOF6UNC.js +0 -2
- package/dist-cli/chunks/install-EPUJX4AT.js +0 -67
- package/dist-cli/chunks/record-IE27Z2GA.js +0 -37
- package/dist-cli/chunks/screenshot-mode-SZQDNGYE.js +0 -17
- package/dist-cli/chunks/server-AN2G5KO4.js +0 -21
- package/dist-cli/chunks/store-PU5ES4YQ.js +0 -2
- package/dist-cli/chunks/upload-BYNPC54C.js +0 -2
- package/dist-cli/chunks/vite-plugin-5AEUUBKP.js +0 -9
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as Oe}from"./chunk-G5MR66EB.js";import{a as Ce,b as ae,c as Ne}from"./chunk-KXYKAYYB.js";import{f as ve}from"./chunk-YCETS3B3.js";import{a as H,b as R,c as Ee,d as se,f as Ae,g as Pe}from"./chunk-JSF5LPNT.js";import{a as ke,c as Re,i as $e}from"./chunk-HOIHCO7S.js";import{b as Te}from"./chunk-KSB6MSZ4.js";import{b as ie,c as Ie,d as Fe}from"./chunk-MPSZ5EWF.js";import{d as xe}from"./chunk-3C3ZH7PP.js";import{a as _e}from"./chunk-MBFP2LVH.js";import{a as st}from"./chunk-E522F5JW.js";import*as I from"fs";import{tmpdir as ze}from"os";import*as S from"path";import{execSync as je}from"child_process";import St from"http";import vt from"net";import{existsSync as y,readFileSync as D,writeFileSync as M}from"node:fs";import{homedir as it}from"node:os";import{dirname as at,join as w,resolve as lt}from"node:path";import{fileURLToPath as ct}from"node:url";var N=it(),dt=()=>{let t=at(ct(import.meta.url));return lt(t,"../../sootsim-engine/scripts/expensify-web-proxy.ts")},le={USE_NGROK:"true",NGROK_URL:"http://localhost:9000/",SECURE_NGROK_URL:"http://localhost:9000/"},V=w(N,"github/uniswap-interface"),ut=w(V,"apps/mobile"),q=w(V,".env.defaults.local"),ft="stored-in-.env.local",Me="# sootsim demo env overrides",pt=w(V,"packages/uniswap/src/features/forceUpgrade/hooks/useForceUpgradeStatus.ts"),mt=w(V,"apps/mobile/src/notification-service/data-sources/createForceUpgradeNotificationDataSource.ts"),De="SOOTSIM_DEMO_DISABLE_FORCE_UPGRADE";function Ue(t){if(!y(t))return{};let e={},o=D(t,"utf8");for(let r of o.split(/\r?\n/)){let n=r.trim();if(!n||n.startsWith("#"))continue;let i=n.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);if(!i)continue;let s=i[2].trim();(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1)),e[i[1]]=s}return e}function ce(t){if(!t)return!1;let e=t.trim();return!(!e||e.includes(ft)||e==="TRADING_API_KEY"||e==="UNISWAP_API_KEY")}function Le(t,e){for(let o of t)for(let r of e){let n=o[r];if(ce(n))return n.trim()}}function Ve(){let t=Ue(q),e=Ue(w(V,"apps/web/.env")),o=[process.env,t,e],r={},n=[["AMPLITUDE_PROXY_URL_OVERRIDE",["REACT_APP_AMPLITUDE_PROXY_URL"]],["QUICKNODE_ENDPOINT_NAME",["REACT_APP_QUICKNODE_ENDPOINT_NAME"]],["QUICKNODE_ENDPOINT_TOKEN",["REACT_APP_QUICKNODE_ENDPOINT_TOKEN"]],["INFURA_KEY",["REACT_APP_INFURA_KEY"]],["STATSIG_API_KEY",["REACT_APP_STATSIG_API_KEY"]],["STATSIG_PROXY_URL_OVERRIDE",["REACT_APP_STATSIG_PROXY_URL"]],["WALLETCONNECT_PROJECT_ID",["REACT_APP_WALLET_CONNECT_PROJECT_ID"]],["WALLETCONNECT_PROJECT_ID_BETA",["REACT_APP_WALLET_CONNECT_PROJECT_ID"]],["WALLETCONNECT_PROJECT_ID_DEV",["REACT_APP_WALLET_CONNECT_PROJECT_ID"]],["TRADING_API_KEY",["REACT_APP_TRADING_API_KEY"]],["UNISWAP_API_KEY",[]]];for(let[s,a]of n){let l=Le(o,[s,...a]);if(l){r[s]=l;for(let c of a)r[c]=l}}if(!(ce(r.TRADING_API_KEY)&&ce(r.UNISWAP_API_KEY))){let s=Le(o,["GRAPHQL_URL_OVERRIDE","REACT_APP_AWS_API_ENDPOINT"])||"https://interface.gateway.uniswap.org/v1/graphql";r.API_BASE_URL_OVERRIDE="https://interface.gateway.uniswap.org",r.API_BASE_URL_V2_OVERRIDE="https://interface.gateway.uniswap.org/v2",r.GRAPHQL_URL_OVERRIDE=s,r.TRADING_API_URL_OVERRIDE="https://trading-api-labs.interface.gateway.uniswap.org",r.FOR_API_URL_OVERRIDE="https://for.interface.gateway.uniswap.org/v2/FOR.v1.FORService"}return r}function wt(){let t=y(q)?D(q,"utf8"):"";if(t&&!t.includes(Me))return;let e=Ve(),o=[Me];for(let[r,n]of Object.entries(e).sort(([i],[s])=>i.localeCompare(s)))o.push(`${r}=${JSON.stringify(n)}`);o.push(""),M(q,`${o.join(`
|
|
3
|
-
`)}
|
|
4
|
-
`)}function gt(){let t=`export function useForceUpgradeStatus(): ForceUpgradeStatus {
|
|
5
|
-
`,e=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
6
|
-
return 'not-required'
|
|
7
|
-
|
|
8
|
-
`,o=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
9
|
-
if (process.env.${De} === 'true') {
|
|
10
|
-
return 'not-required'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
`,r=` const getForceUpgradeStatus = (): ForceUpgradeStatus => {
|
|
14
|
-
`,n=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
15
|
-
return 'not-required'
|
|
16
|
-
|
|
17
|
-
`,i=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
18
|
-
if (process.env.${De} === 'true') {
|
|
19
|
-
return 'not-required'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
`,s=(a,l,c,m)=>{let h=D(a,"utf8");if(!h.includes(c)){if(h.includes(m)){M(a,h.replace(m,c));return}if(!h.includes(l))throw new Error(`uniswap demo patch failed: expected snippet not found in ${a}`);M(a,h.replace(l,`${l}${c}`))}};s(pt,t,e,o),s(mt,r,n,i)}var v=w(N,"github/eigen"),z=w(v,"keys.shared.json"),We=w(v,"metaflags.json"),Ke=w(v,"src/__generated__/.relay-complete");function ht(){if(y(z))try{let t=JSON.parse(D(z,"utf8"));if(!t||typeof t!="object")return;let e=t.secure&&typeof t.secure=="object"?t.secure:void 0,o=t.public&&typeof t.public=="object"?t.public:void 0;return!e&&!o?void 0:{secure:e,public:o}}catch{return}}function bt(){let t=process.env.SOOTSIM_ARTSY_EMAIL??process.env.MAESTRO_TEST_EMAIL,e=process.env.SOOTSIM_ARTSY_PASSWORD??process.env.MAESTRO_TEST_PASSWORD,o=ht(),r={};if(t&&e&&(r.SOOTSIM_LAUNCH_ARGUMENTS=JSON.stringify({email:t,password:e,useMaestroInit:!0})),o&&(r.SOOTSIM_REACT_NATIVE_KEYS_JSON=JSON.stringify(o)),Object.keys(r).length!==0)return{env:r}}function yt(){if(!y(v))return;let{execSync:t}=st("node:child_process"),e=w(v,".yarn/releases/yarn-4.10.3.cjs");if(y(e)){let r=D(e,"utf8"),n='["clone","-c core.autocrlf=false",';r.includes(n)&&M(e,r.replace(n,'["clone","-c","core.autocrlf=false",'))}if(y(w(v,"node_modules/.yarn-state.yml"))||t("yarn install",{cwd:v,stdio:"inherit",env:{...process.env,YARN_CHECKSUM_BEHAVIOR:"update"}}),!y(z)||!y(We))try{t("yarn setup:oss",{cwd:v,stdio:"inherit"})}catch{if(!y(z)||!y(We))throw new Error("artsy demo: setup:oss did not create keys/metaflags")}let o=w(v,"node_modules/react-native-launch-arguments/package.json");if(y(o)){let r=D(o,"utf8");r.includes('"dist/index.js"')&&M(o,r.replace('"dist/index.js"','"src/index.ts"'))}y(Ke)||(t("yarn relay",{cwd:v,stdio:"inherit"}),M(Ke,""))}var Be=[{name:"bluesky",label:"Bluesky",dir:w(N,"github/bluesky"),preferredPort:8082,framework:"expo",command:t=>({cmd:`npx expo start --port ${t}`}),credentials:{envVars:["SOOTSIM_BLUESKY_PASSWORD"],known:{HANDLE:"natew.bsky.social"}}},{name:"3pc",label:"3PunchConvo",dir:w(N,"lightstrike-labs/three-punch-convo-app/apps/one"),preferredPort:8081,framework:"one",command:t=>({cmd:"npx one dev",env:{ONE_PORT:String(t)}})},{name:"uniswap",label:"Uniswap",dir:ut,preferredPort:8085,framework:"expo",prepare:()=>{wt(),gt()},command:t=>({cmd:`npx expo start --clear --port ${t}`,env:Ve()})},{name:"takeout",label:"Takeout",dir:w(N,"takeout"),preferredPort:8086,framework:"one",command:t=>({cmd:"npx one dev",env:{ONE_PORT:String(t)}})},{name:"expensify",label:"Expensify",dir:w(N,"github/expensify"),preferredPort:8087,framework:"rock",runtimeConfig:{env:le},sidecars:[{name:"web-proxy",port:9e3,readyPath:"/api/Ping",command:()=>({cmd:`bun ${JSON.stringify(dt())}`,env:le})}],command:t=>({cmd:`fnm exec --using=20.20.0 npx rock start --port ${t} --no-interactive`,env:le})},{name:"artsy",label:"Artsy",dir:v,preferredPort:8088,framework:"expo",runtimeConfig:bt(),prepare:()=>{yt()},command:t=>({cmd:`npx react-native start --port ${t}`}),credentials:{envVars:["SOOTSIM_ARTSY_EMAIL","SOOTSIM_ARTSY_PASSWORD"],note:"auto-login reuses Artsy\u2019s built-in Maestro launch-arguments hook"}}];var Je=250,_t=120;function Tt(t,e=_t){return new Promise(o=>{let r=new vt.Socket,n=!1,i=s=>{n||(n=!0,r.destroy(),o(s))};r.setTimeout(e),r.once("connect",()=>i(!0)),r.once("timeout",()=>i(!1)),r.once("error",()=>i(!1)),r.connect(t,"localhost")})}function B(t,e,o="GET",r=Je,n={}){return new Promise(i=>{let s=St.request({hostname:"localhost",port:t,path:e,method:o,timeout:r,headers:n},a=>{let l="";a.on("data",c=>l+=c.toString()),a.on("end",()=>i({statusCode:a.statusCode||0,body:l}))});s.on("error",()=>i(null)),s.setTimeout(r,()=>{s.destroy(),i(null)}),s.end()})}var Et=[8081,8082,8083,8084,8085,8086,3e3,3001,19e3].map(t=>({port:t,pid:0}));function de(t,e){return!(t<=0||t>=2e4||e.has(t)||t>=5170&&t<=5200)}function At(t=[]){let e=new Set(t);try{let o=je("lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'",{encoding:"utf8",timeout:2e3});if(o.trim()){let r=new Map;for(let n of o.trim().split(`
|
|
23
|
-
`)){let i=n.trim().split(/\s+/);if(i.length<9)continue;let s=Number(i[1]),l=i[8].match(/:(\d+)$/);if(!l)continue;let c=Number(l[1]);de(c,e)&&(r.has(c)||r.set(c,s))}if(r.size>0)return[...r.entries()].map(([n,i])=>({port:n,pid:i}))}}catch{}try{let o=je(`ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`,{encoding:"utf8",timeout:2e3});if(o.trim()){let r=new Map;for(let n of o.trim().split(`
|
|
24
|
-
`)){let i=n.match(/:(\d+)\s/),s=n.match(/pid=(\d+)/);if(!i)continue;let a=Number(i[1]),l=s?Number(s[1]):0;de(a,e)&&(r.has(a)||r.set(a,l))}if(r.size>0)return[...r.entries()].map(([n,i])=>({port:n,pid:i}))}}catch{}return Et.filter(o=>de(o.port,e))}function Pt(t,e){return{port:t,framework:e,bundleUrl:U(t,`http://localhost:${t}/index.bundle?platform=ios&dev=true&hot=true&minify=false`),hmrUrl:`ws://localhost:${t}/hot`,lastSeen:Date.now()}}function U(t,e){let o=Be.find(r=>r.preferredPort===t);return o?.runtimeConfig?ke(e,o.runtimeConfig):e}function xt(t){return t.includes("/node_modules/one/metro-entry.bundle")}function X(t,e,o){if(!e)return t;try{let r=JSON.parse(e.body),n=r?.extra?.expoClient||r?.extra||{};n.name&&(t.projectName=n.name),n.ios?.bundleIdentifier&&(t.bundleId=n.ios.bundleIdentifier),t.framework==="metro"&&n.sdkVersion&&(t.framework="expo");let i=r?.launchAsset?.url;i&&!t.patched&&!xt(t.bundleUrl)&&(t.bundleUrl=U(t.port,i));let s=n.iconUrl||n.ios?.iconUrl||n.icon||n.ios?.icon;if(s)if(t.iconPath=s,o)if(s.startsWith("http"))t.iconUrl=o(s);else{let a=s.replace(/^\.\//,"");t.iconUrl=o(`http://localhost:${t.port}/assets/${a}`)}else t.iconUrl=s.startsWith("http")?s:`http://localhost:${t.port}/assets/${s.replace(/^\.\//,"")}`}catch{}return t}var A=new Set,$=new Set;async function It(t,e){if(!await Tt(t))return null;let o="/node_modules/one/metro-entry.bundle?platform=ios&dev=true",[r,n,i,s,a]=await Promise.all([A.has(t)?Promise.resolve(null):B(t,"/__soot/"),B(t,"/status"),B(t,o,"HEAD"),B(t,"/","GET",Je,{"expo-platform":"ios"}),$.has(t)?Promise.resolve(null):B(t,"/_expo/status")]);if(a&&a.statusCode===200?$.delete(t):$.has(t)||$.add(t),i&&i.statusCode>0&&i.statusCode<400)return A.add(t),X({port:t,framework:"one",bundleUrl:U(t,`http://localhost:${t}${o}&minify=false`),hmrUrl:`ws://localhost:${t}/hot`,lastSeen:Date.now()},s,e);if(n&&n.body.includes("packager-status:running"))return A.add(t),X(Pt(t,a&&a.statusCode===200?"expo":"metro"),s,e);if(s)try{let l=JSON.parse(s.body);if((l?.extra?.expoClient||{}).name){let m=l?.launchAsset?.url||`http://localhost:${t}/index.bundle?platform=ios&dev=true&hot=true&minify=false`;return A.add(t),X({port:t,framework:"one",bundleUrl:U(t,m),hmrUrl:`ws://localhost:${t}/hot`,lastSeen:Date.now()},s,e)}}catch{}return r&&r.statusCode===200&&r.body.includes("sootsim-patched")?(A.delete(t),X({port:t,framework:"one",bundleUrl:U(t,`http://localhost:${t}/__soot/bundle.js`),hmrUrl:`ws://localhost:${t}/hot`,lastSeen:Date.now(),patched:!0},s,e)):(A.add(t),null)}function Ft(t){let e=t.projectName?.trim().toLowerCase();return!!(e==="soot"||e==="sootsim"||t.bundleId?.trim().toLowerCase()?.startsWith("dev.soot"))}var Q=new Map,kt=3e4,Rt=1500;function $t(t){return!!(!t||t.framework==="metro"||t.framework==="unknown"||t.bundleUrl.includes("minify=false"))}function Ot(t){return t?U(t.port,t.bundleUrl)===t.bundleUrl:!0}function Ct(t,e,o=Date.now()){if(e===0||t.pid!==e||!Ot(t.result))return!1;let r=o-t.cachedAt;return!(t.result===null&&r>=kt||$t(t.result)&&r>=Rt)}async function Ye(t={}){let e=At(t.excludePorts),o=new Set(e.map(i=>i.port));for(let i of[...Q.keys()])o.has(i)||Q.delete(i);for(let i of[...A])o.has(i)||A.delete(i);for(let i of[...$])o.has(i)||$.delete(i);let r=[],n=[];for(let{port:i,pid:s}of e){let a=Q.get(i);if(a&&Ct(a,s)){a.result&&r.push(a.result);continue}a&&a.pid!==s&&(A.delete(i),$.delete(i)),n.push({port:i,pid:s})}return n.length>0&&(await Promise.all(n.map(s=>It(s.port,t.buildIconProxyUrl)))).forEach((s,a)=>{let{port:l,pid:c}=n[a];c!==0&&Q.set(l,{pid:c,result:s,cachedAt:Date.now()}),s&&r.push(s)}),r.filter(i=>!Ft(i))}import*as b from"fs";import*as g from"path";var Z=1e4,ee=393,L=852,Ge="__sootsimCliPerf",Nt="maestroCopiedText",fe=new Map;function p(t){return new Promise(e=>setTimeout(e,t))}function Mt(t){return t?g.basename(t)===".maestro"?g.dirname(t):t:process.cwd()}function Dt(t,e,o){let r=e.endsWith(".png")?e:`${e}.png`;if(g.isAbsolute(r))return r;if(o.mode==="flow"&&/[\\/]/.test(r)){let n=r.startsWith("./")||r.startsWith("../")?o.flowDir??process.cwd():Mt(o.flowDir);return g.resolve(n,r)}return g.join(t,r)}function Ut(t){if(typeof t=="string")return{path:t,withFrame:!1};let e=t.path?.trim()||t.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:t.withFrame===!0}}function ue(t){let[e,o]=t.split(",").map(n=>n.trim()),r=(n,i)=>n.endsWith("%")?Number.parseFloat(n)/100*i:Number.parseFloat(n);return{x:r(e,ee),y:r(o,L)}}function pe(t){return typeof t=="string"?t.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,o)=>{if(fe.has(o))return fe.get(o);let r=process.env[o];if(r===void 0)throw new Error(`missing environment variable for flow placeholder: ${o}`);return r}):Array.isArray(t)?t.map(e=>pe(e)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([e,o])=>[e,pe(o)])):t}function Lt(t){let e=t.split(/^---$/m),o=e.length>1?e[e.length-1]:t,r=pe(R.parse(o));return Array.isArray(r)?r:[]}var te=class{constructor(e,o){this.bridge=e;this.opts=o}stepDelay=0;firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;browserRouteHint=null;lastFailedStep=null;get browserId(){return this.opts.browserId}setBrowserRouteHint(e){this.browserRouteHint=this.normalizeBrowserRoute(e)}normalizeBrowserRoute(e){if(!e)return null;try{let o=new URL(e);o.searchParams.delete("inspectOpen");let r=o.searchParams.toString();return`${o.origin}${o.pathname}${r?`?${r}`:""}`}catch{return e}}async refreshBrowserId(){if(this.opts.browserId)try{let e=await this.bridge.listBrowsers(),o=e.find(l=>l.id===this.opts.browserId);if(o&&(this.browserRouteHint=this.normalizeBrowserRoute(o.url||o.origin)),e.find(l=>l.id===this.opts.browserId&&l.readyState==="open")||!this.browserRouteHint)return;let n=this.browserRouteHint&&e.find(l=>l.readyState==="open"&&this.normalizeBrowserRoute(l.url||l.origin)===this.browserRouteHint);if(!n)return;let i=e.find(l=>l.isPrimary&&l.readyState==="open"),s=e.find(l=>l.readyState==="open"),a=n??i??s;a&&(this.opts.browserId=a.id,console.log(` [flow] session rotated to ${a.id}`))}catch{}}async evaluate(e){return this.bridge.send({type:"evaluate",browserId:this.opts.browserId,code:e})}async callTest(e,...o){return this.bridge.send({type:"call",browserId:this.opts.browserId,path:`__sootsimTest.${e}`,args:o})}async waitForTree(e=Z){let o=Date.now()+e,r=null;for(;Date.now()<o;){try{let n=await this.evaluate(`(async () => {
|
|
25
|
-
const test = window.__sootsimTest
|
|
26
|
-
if (!test) return { count: 0, loading: true }
|
|
27
|
-
const count = (await test.getNodeCount?.()) || 0
|
|
28
|
-
const external = globalThis.__sootsimExternalAppState
|
|
29
|
-
if (external?.error) {
|
|
30
|
-
return { count, loading: false, error: String(external.error) }
|
|
31
|
-
}
|
|
32
|
-
if (external) {
|
|
33
|
-
return {
|
|
34
|
-
count,
|
|
35
|
-
loading: !external.ready,
|
|
36
|
-
error: null,
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const loadingNode = await test.findByText?.('loading')
|
|
40
|
-
const capturingNode = await test.findByText?.('capturing')
|
|
41
|
-
const openingAppNode = await test.findByText?.('opening app')
|
|
42
|
-
const isLoading = !!loadingNode || !!capturingNode || !!openingAppNode || count < 5
|
|
43
|
-
return { count, loading: isLoading, error: null }
|
|
44
|
-
})()`);if(n?.error)throw new Error(`app failed to load: ${n.error}`);if(n&&n.count>10&&!n.loading)return}catch(n){r=n instanceof Error?n:new Error(String(n)),await this.refreshBrowserId()}await p(500)}throw r?.message.startsWith("app failed to load:")?r:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");let e=await this.evaluate(`(() => {
|
|
45
|
-
const rec = window.__sootsimRecorder
|
|
46
|
-
if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
|
|
47
|
-
if (rec.state() === 'recording') return { ok: true, format: 'webm' }
|
|
48
|
-
return rec.start({ format: 'webm', fps: 24 })
|
|
49
|
-
})()`);if(!e?.ok)throw new Error(e?.error||"recording unavailable on this page")}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}async stopRecording(){if(!this.recordingEnabled||!this.opts.recordingOutputDir)return null;this.recordingEnabled=!1,await this.evaluate("window.__sootsimRecorder.stop()");let e=[],o=0;for(;;){let n=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${o}, chunk: 2097152 })`);if(!n||(e.push(Buffer.from(n.data,"base64")),o=n.offset,n.done))break}if(e.length===0)throw new Error("recording requested but no video buffer was produced");b.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let r=g.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.webm`);return b.writeFileSync(r,Buffer.concat(e)),r}async findElement(e){return this.evaluate(`(async () => {
|
|
50
|
-
const test = window.__sootsimTest
|
|
51
|
-
if (!test) return null
|
|
52
|
-
let node = null
|
|
53
|
-
if (${JSON.stringify(!!e.text)}) node = await test.findByText(${JSON.stringify(e.text||"")})
|
|
54
|
-
if (!node && ${JSON.stringify(!!e.id)}) {
|
|
55
|
-
node = (await test.findByTestId(${JSON.stringify(e.id||"")})) || (await test.findById(${JSON.stringify(e.id||"")}))
|
|
56
|
-
}
|
|
57
|
-
if (!node || !node.absolutePosition || !node.layout) return null
|
|
58
|
-
return {
|
|
59
|
-
nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
|
|
60
|
-
id: node.id || null,
|
|
61
|
-
testID: node.testID || null,
|
|
62
|
-
text: node.text || null,
|
|
63
|
-
absolutePosition: node.absolutePosition,
|
|
64
|
-
layout: node.layout,
|
|
65
|
-
isTextInput: !!node.isTextInput,
|
|
66
|
-
}
|
|
67
|
-
})()`)}async resolveTapTarget(e){return this.evaluate(`(async () => {
|
|
68
|
-
const test = window.__sootsimTest
|
|
69
|
-
if (!test?.resolveTapTarget) return null
|
|
70
|
-
return await test.resolveTapTarget(${e})
|
|
71
|
-
})()`)}async activatePressTarget(e){return this.evaluate(`(async () => {
|
|
72
|
-
const test = window.__sootsimTest
|
|
73
|
-
if (!test) return null
|
|
74
|
-
${e.id?`const direct = await test.activatePressById?.(${JSON.stringify(e.id)})`:`const direct = await test.activatePressByText?.(${JSON.stringify(e.text||"")})`}
|
|
75
|
-
return direct || null
|
|
76
|
-
})()`)}async activatePressAt(e,o){return this.evaluate(`(async () => {
|
|
77
|
-
const test = window.__sootsimTest
|
|
78
|
-
if (!test?.activatePressAt) return null
|
|
79
|
-
return await test.activatePressAt(${e}, ${o})
|
|
80
|
-
})()`)}async tap(e,o){return this.bridge.send({type:"tap",browserId:this.opts.browserId,x:e,y:o})}async tapOn(e){let o=typeof e=="string"?{text:e}:e;if(o.point){let l=ue(o.point);(await this.activatePressAt(l.x,l.y))?.ok||await this.tap(l.x,l.y),await p(300);return}let r=5e3,n=150,i=Date.now()+r,s=await this.findElement({text:o.text,id:o.id});for(;!s&&Date.now()<i;)await p(n),s=await this.findElement({text:o.text,id:o.id});if(s&&!s.isTextInput&&(await this.activatePressTarget(o))?.ok){await p(300);return}if(s){let l=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,c=l?.cx??s.absolutePosition.x+s.layout.width/2,m=l?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(c,m))?.hit!==!1){await p(300);return}}if((await this.activatePressTarget(o))?.ok){await p(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(o)}`)}async tapAtCoords(e,o){await this.tap(e,o),await p(300)}async doubleTapAtCoords(e,o,r=80){let n=Math.max(0,Math.round(r));if(!await this.evaluate(`(async () => {
|
|
81
|
-
const interact = window.__sootsimInteract
|
|
82
|
-
if (interact?.doubleTap) {
|
|
83
|
-
return !!(await interact.doubleTap(${e}, ${o}, ${n}))
|
|
84
|
-
}
|
|
85
|
-
if (!interact?.tap) return false
|
|
86
|
-
const first = await interact.tap(${e}, ${o})
|
|
87
|
-
if (!first || first.hit === false) return false
|
|
88
|
-
await new Promise((resolve) => setTimeout(resolve, ${n}))
|
|
89
|
-
const second = await interact.tap(${e}, ${o})
|
|
90
|
-
return !!second && second.hit !== false
|
|
91
|
-
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${o})`);await p(300)}async assertVisible(e){let o=typeof e=="string"?{text:e}:e;for(let r=0;r<15;r++){let n=await this.findElement(o);if(n&&n.absolutePosition.y+n.layout.height>0&&n.absolutePosition.y<L)return;await p(200)}throw new Error(`assertVisible: ${JSON.stringify(o)} not found or off-screen`)}async assertNotVisible(e){let o=typeof e=="string"?{text:e}:e,r=await this.findElement(o);if(r&&r.absolutePosition.y+r.layout.height>0&&r.absolutePosition.y<L)throw new Error(`assertNotVisible: ${JSON.stringify(o)} IS visible`)}async inputText(e){await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"type",text:e}),await p(200)}async pressKey(e){await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"press",text:e}),await p(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"dispatchKey",text:e}),await p(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let o=await this.evaluate(`(() => {
|
|
92
|
-
const keyboard =
|
|
93
|
-
window.__sootsimKeyboard ??
|
|
94
|
-
window.SootSim?.bridges?.keyboard ??
|
|
95
|
-
null
|
|
96
|
-
const test = window.__sootsimTest
|
|
97
|
-
return {
|
|
98
|
-
visible: !!keyboard?.isVisible?.(),
|
|
99
|
-
focused: !!test?.isTextInputFocused?.(),
|
|
100
|
-
}
|
|
101
|
-
})()`);if(!o?.visible&&!o?.focused){await p(80);return}await p(80)}}async eraseText(e){for(let o=0;o<e;o++)await this.pressKey("Backspace");await p(100)}async waitFor(e){let o=Date.now()+(e.timeout||Z);for(;Date.now()<o;){if(await this.findElement(e))return;await p(200)}throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||Z}ms`)}async takeScreenshot(e){await p(250);let o=Ut(e),r=Dt(this.opts.screenshotDir,o.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});b.mkdirSync(g.dirname(r),{recursive:!0});let i=(await this.bridge.send({type:"screenshot",browserId:this.opts.browserId})).replace(/^data:image\/png;base64,/,""),s=Buffer.from(i,"base64");if(o.withFrame){let a=await this.readCurrentDeviceModel();if(!a)throw new Error("could not read current device model for framed screenshot");let l=await Oe(s,a);b.writeFileSync(r,l),console.log(`[flow] screenshot: ${r} (frame: ${a})`);return}b.writeFileSync(r,s),console.log(`[flow] screenshot: ${r}`)}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",browserId:this.opts.browserId,path:"SootSim.bridges.settings.get",args:[]}),o=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!o||!(o in ve)?null:o}async captureFailureScreenshot(e){b.mkdirSync(g.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",browserId:this.opts.browserId})).replace(/^data:image\/png;base64,/,"");b.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,o){b.mkdirSync(e,{recursive:!0});let r=(c,m)=>{try{b.writeFileSync(g.join(e,c),m)}catch{}},n=async c=>{try{return await this.bridge.send({type:"evaluate",browserId:this.opts.browserId,code:c})}catch{return null}};r("error.json",JSON.stringify({message:o.error.message,stack:o.error.stack,stepIndex:o.stepIndex,stepKind:o.stepKind,stepTarget:o.stepTarget,capturedAt:new Date().toISOString()},null,2));try{let m=(await this.bridge.send({type:"screenshot",browserId:this.opts.browserId})).replace(/^data:image\/png;base64,/,"");r("screenshot.png",Buffer.from(m,"base64"))}catch{}let i=await n(`(async () => {
|
|
102
|
-
const t = window.__sootsimTest
|
|
103
|
-
const mainShell = window.SootSim?.bridges?.mainShell
|
|
104
|
-
if (!t) return { error: 'no test bridge' }
|
|
105
|
-
let shell = null
|
|
106
|
-
try {
|
|
107
|
-
shell = typeof mainShell?.getState === 'function' ? await mainShell.getState() : null
|
|
108
|
-
} catch {}
|
|
109
|
-
const all = await t.queryAll({ pruneHidden: true })
|
|
110
|
-
return { shell, nodes: all, url: location.href, title: document.title }
|
|
111
|
-
})()`);i&&r("describe.json",JSON.stringify(i,null,2));let s=await n("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof s=="string"&&r("a11y.txt",s);let a=await n("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof a=="string"&&r("tree.txt",a);let l=await n(`(() => {
|
|
112
|
-
const c = window.__sootsimConsole
|
|
113
|
-
return {
|
|
114
|
-
errors: c?.getErrors?.() ?? [],
|
|
115
|
-
warnings: c?.getWarnings?.() ?? [],
|
|
116
|
-
requests: (window.__sootsimGetFailedRequests?.() ?? []),
|
|
117
|
-
}
|
|
118
|
-
})()`);return l&&r("console.json",JSON.stringify(l,null,2)),e}async swipe(e="UP",o=300){let r=ee/2,n=L/2,i=200,s=r,a=n,l=r,c=n;switch(e.toUpperCase()){case"UP":a+=i,c-=i;break;case"DOWN":a-=i,c+=i;break;case"LEFT":s+=i,l-=i;break;case"RIGHT":s-=i,l+=i;break}let m=Math.max(10,Math.round(o/16));await this.drag(s,a,l,c,m,16)}async drag(e,o,r,n,i=12,s=16){if(!(await this.evaluate(`(async () => {
|
|
119
|
-
const interact = window.__sootsimInteract
|
|
120
|
-
if (!interact?.drag) return { ok: false }
|
|
121
|
-
const value = await interact.drag(${e}, ${o}, ${r}, ${n}, ${Math.max(1,Math.round(i))}, ${Math.max(0,Math.round(s))})
|
|
122
|
-
return { ok: !!value, value }
|
|
123
|
-
})()`))?.ok)throw new Error("drag failed");await p(300)}async swipeCoords(e,o,r=300){let n=ue(e),i=ue(o),s=Math.max(10,Math.round(r/16));await this.drag(n.x,n.y,i.x,i.y,s,16)}async swipeFrom(e,o="UP",r=300){let n=await this.findElement(e);if(!n)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let i=n.absolutePosition.x+n.layout.width/2,s=n.absolutePosition.y+n.layout.height/2,a=180,l=i,c=s;switch(o.toUpperCase()){case"UP":c-=a;break;case"DOWN":c+=a;break;case"LEFT":l-=a;break;case"RIGHT":l+=a;break}let m=Math.max(10,Math.round(r/16));await this.drag(i,s,l,c,m,16)}async scrollTo(e,o,r){let n=await this.callTest("scrollTo",e,o,r,!1);if(!n?.ok)throw new Error(`scrollTo failed: ${n?.reason||"unknown error"}`);await p(250)}async pinch(e){let o=await this.evaluate(`(async () => {
|
|
124
|
-
const interact = window.__sootsimInteract
|
|
125
|
-
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
126
|
-
const ok = await interact.pinch(
|
|
127
|
-
${e.from[0]}, ${e.from[1]}, ${e.from[2]}, ${e.from[3]},
|
|
128
|
-
${e.to[0]}, ${e.to[1]}, ${e.to[2]}, ${e.to[3]},
|
|
129
|
-
${e.steps||12}, ${e.stepMs||16}
|
|
130
|
-
)
|
|
131
|
-
return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
|
|
132
|
-
})()`);if(!o?.ok)throw new Error(`pinch failed: ${o?.reason||"unknown error"}`);await p(250)}async dumpTree(e=6){let o=await this.bridge.send({type:"tree",browserId:this.opts.browserId,depth:e});return console.log("[flow] tree:"),console.log(typeof o=="string"?o:JSON.stringify(o,null,2)),typeof o=="string"?o:JSON.stringify(o)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){await p(e)}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let o=Date.now()+(e.timeout||15e3),r=e.direction?.toUpperCase()||"DOWN",n=r==="DOWN"?"UP":r==="UP"?"DOWN":r;for(;Date.now()<o;){let i=await this.findElement({text:e.element});if(i&&i.absolutePosition.y>=0&&i.absolutePosition.y+i.layout.height>0&&i.absolutePosition.y<L-50){if(e.centerElement){let s=L/2,a=i.absolutePosition.y-s;if(Math.abs(a)>100){let l=Math.min(150,Math.abs(a)*.5),c=a>0?s-l:s+l;await this.drag(ee/2,s,ee/2,c,10,16)}}return}await this.swipe(n,250),await p(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let o=Date.now()+(e.timeout||Z);for(;Date.now()<o;){let r=e.visible?!!await this.findElement(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,n=e.notVisible?!await this.findElement(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(r&&n)return;await p(200)}throw new Error("extendedWaitUntil timed out")}async launchApp(e){await this.refreshBrowserId();let o=!!(e&&typeof e=="object"&&e.clearState);if(o&&await this.evaluate(`(async () => {
|
|
133
|
-
await (${H})
|
|
134
|
-
try {
|
|
135
|
-
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
136
|
-
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
137
|
-
} catch {}
|
|
138
|
-
})()`),!this.firstLaunchDone&&!o)this.firstLaunchDone=!0,await this.waitForTree(3e4);else if(this.firstLaunchDone=!0,await this.evaluate("window.location.reload()").catch(()=>{}),await p(500),await this.refreshBrowserId(),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(r){console.warn(` warn: onAfterLaunch hook threw: ${r instanceof Error?r.message:r}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
|
|
139
|
-
requestAnimationFrame(() => {
|
|
140
|
-
requestAnimationFrame(() => {
|
|
141
|
-
requestAnimationFrame(() => {
|
|
142
|
-
setTimeout(resolve, 180)
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
})`)}catch{await p(180)}}async startProfile(){await this.evaluate(`((sessionKey) => {
|
|
147
|
-
const host = window.__sootsimRenderHost
|
|
148
|
-
if (host?.startPerfSession) {
|
|
149
|
-
host.startPerfSession(sessionKey)
|
|
150
|
-
window[sessionKey] = {
|
|
151
|
-
active: true,
|
|
152
|
-
mode: 'render-worker',
|
|
153
|
-
startedAt: performance.now(),
|
|
154
|
-
}
|
|
155
|
-
return
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const perf = window.__sootsimPerf
|
|
159
|
-
const a11y = window.__sootsimA11y
|
|
160
|
-
perf?.enableFrameStats?.()
|
|
161
|
-
perf?.resetFrameStats?.()
|
|
162
|
-
a11y?.resetProfile?.()
|
|
163
|
-
window[sessionKey] = {
|
|
164
|
-
active: true,
|
|
165
|
-
mode: 'main-thread',
|
|
166
|
-
startedAt: performance.now(),
|
|
167
|
-
}
|
|
168
|
-
})(${JSON.stringify(Ge)})`),this.profilingEnabled=!0}async stopProfile(){let e=await this.evaluate(`(async (sessionKey) => {
|
|
169
|
-
const host = window.__sootsimRenderHost
|
|
170
|
-
if (host?.stopPerfSession) {
|
|
171
|
-
const stopped = await host.stopPerfSession(sessionKey)
|
|
172
|
-
if (!stopped || !Array.isArray(stopped.samples)) {
|
|
173
|
-
return { error: 'no render-worker perf samples available' }
|
|
174
|
-
}
|
|
175
|
-
const samples = stopped.samples
|
|
176
|
-
const frameTimes = samples.map((sample) => Number(sample?.[1]) || 0).filter((value) => value > 0)
|
|
177
|
-
const sorted = [...frameTimes].sort((a, b) => a - b)
|
|
178
|
-
const worstFrames = samples
|
|
179
|
-
.slice()
|
|
180
|
-
.sort((a, b) => (Number(b?.[1]) || 0) - (Number(a?.[1]) || 0))
|
|
181
|
-
.slice(0, 10)
|
|
182
|
-
.map((sample) => [
|
|
183
|
-
Number(sample?.[0]) || 0,
|
|
184
|
-
Number(sample?.[1]) || 0,
|
|
185
|
-
Number(sample?.[2]) || 0,
|
|
186
|
-
Number(sample?.[3]) || 0,
|
|
187
|
-
Number(sample?.[4]) || 0,
|
|
188
|
-
])
|
|
189
|
-
|
|
190
|
-
return {
|
|
191
|
-
mode: 'render-worker',
|
|
192
|
-
frames: Number(stopped.frameCount) || frameTimes.length,
|
|
193
|
-
totalMs: Number(stopped.totalMs) || frameTimes.reduce((sum, value) => sum + value, 0),
|
|
194
|
-
avgMs: Number(stopped.avgMs) || (frameTimes.length ? frameTimes.reduce((sum, value) => sum + value, 0) / frameTimes.length : 0),
|
|
195
|
-
maxMs: Number(stopped.maxMs) || (sorted[sorted.length - 1] || 0),
|
|
196
|
-
layoutTotalMs: Number(stopped.layoutTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[2]) || 0), 0),
|
|
197
|
-
renderTotalMs: Number(stopped.renderTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[3]) || 0), 0),
|
|
198
|
-
copyTotalMs: Number(stopped.copyTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[4]) || 0), 0),
|
|
199
|
-
layoutAvgMs: Number(stopped.layoutAvgMs) || 0,
|
|
200
|
-
renderAvgMs: Number(stopped.renderAvgMs) || 0,
|
|
201
|
-
copyAvgMs: Number(stopped.copyAvgMs) || 0,
|
|
202
|
-
p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
|
|
203
|
-
p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
|
|
204
|
-
p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
|
|
205
|
-
jankFrames: frameTimes.filter((value) => value > 16.67).length,
|
|
206
|
-
sampleCount: frameTimes.length,
|
|
207
|
-
worstFrames,
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const perf = window.__sootsimPerf
|
|
212
|
-
const a11y = window.__sootsimA11y
|
|
213
|
-
if (!perf && !a11y) return { error: 'no perf globals available' }
|
|
214
|
-
|
|
215
|
-
const frameStats = perf?.getFrameStats?.() || {}
|
|
216
|
-
const profile = a11y?.profile?.() || {}
|
|
217
|
-
const recent = Array.isArray(frameStats.recentFrames) ? frameStats.recentFrames : []
|
|
218
|
-
const sorted = [...recent].sort((a, b) => a - b)
|
|
219
|
-
perf?.disableFrameStats?.()
|
|
220
|
-
|
|
221
|
-
return {
|
|
222
|
-
mode: 'main-thread',
|
|
223
|
-
frames: frameStats.frames || profile.syncCount || 0,
|
|
224
|
-
totalMs: frameStats.totalMs || 0,
|
|
225
|
-
avgMs: frameStats.totalMs && frameStats.frames ? frameStats.totalMs / frameStats.frames : profile.avgSyncMs || 0,
|
|
226
|
-
maxMs: frameStats.maxMs || profile.maxSyncMs || 0,
|
|
227
|
-
layoutTotalMs: frameStats.layoutTotalMs || 0,
|
|
228
|
-
p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
|
|
229
|
-
p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
|
|
230
|
-
p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
|
|
231
|
-
jankFrames: recent.filter((value) => value > 16.67).length,
|
|
232
|
-
sampleCount: recent.length,
|
|
233
|
-
worstFrames: recent.slice().sort((a, b) => b - a).slice(0, 10),
|
|
234
|
-
}
|
|
235
|
-
})(${JSON.stringify(Ge)})`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.evaluate(`(async () => {
|
|
236
|
-
try { await (${H}) } catch {}
|
|
237
|
-
try {
|
|
238
|
-
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
239
|
-
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
240
|
-
} catch {}
|
|
241
|
-
})()`)}async clearState(){await this.evaluate(`(async () => {
|
|
242
|
-
await (${H})
|
|
243
|
-
})()`)}clearKeychain(){console.warn("[flow] clearKeychain: sootsim has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let o=typeof e=="string"?{id:e}:e,r=await this.findElement(o);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(o)}`);let n=r.text??r.testID??"";fe.set(Nt,n),console.log(`[flow] copied text: ${JSON.stringify(n)}`)}async evalScript(e){let r=await this.evaluate(`(async () => {
|
|
244
|
-
try {
|
|
245
|
-
return { ok: true, value: await (async () => { ${e} })() }
|
|
246
|
-
} catch (err) {
|
|
247
|
-
return { ok: false, error: err && err.message ? err.message : String(err) }
|
|
248
|
-
}
|
|
249
|
-
})()`);if(!r.ok)throw new Error(`evalScript failed: ${r.error}`);r.value!==void 0&&console.log("[flow] evalScript ->",r.value)}async openLink(e){let o=typeof e=="string"?e:e.link;if(!o)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(o)}`),await p(300),await this.refreshBrowserId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let o=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(o)}if(e.notVisible!==void 0){let o=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(o)}return e.platform!==void 0?e.platform.toLowerCase()==="ios":e.true!==void 0?e.true.toLowerCase()!=="false":!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([i])=>i!=="when"&&i!=="optional"),n=r?r[1]:void 0;return!!(n&&typeof n=="object"&&"optional"in n&&n.optional)}async runStep(e,o){let r=Object.keys(e).find(n=>n!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${o+1}: ${r}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let n=!!(e.extendedWaitUntil||e.waitFor||e.launchApp||e.runFlow),i=1e4,s=this.runStepInner(e);if(n)await s;else{let l=null,c=new Promise((m,h)=>{l=setTimeout(()=>{h(new Error(`step watchdog: ${r} made no progress in ${i}ms \u2014 bridge or bundle probably hung`))},i)});try{await Promise.race([s,c])}finally{l&&clearTimeout(l)}}let a=!!(e.assertVisible||e.assertNotVisible||e.extendedWaitUntil||e.waitFor);this.stepDelay>0&&!a&&await p(this.stepDelay)}catch(n){if(this.isOptional(e)){console.log(`[flow] (optional, skipped: ${n.message.slice(0,80)})`);return}throw this.lastFailedStep={index:o,kind:r,target:e[r]},n}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else if(e.takeScreenshot)await this.takeScreenshot(e.takeScreenshot);else if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo)await this.scrollTo(e.scrollTo.id,e.scrollTo.x,e.scrollTo.y);else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd)await this.waitForAnimationToEnd(typeof e.waitForAnimationToEnd=="number"?e.waitForAnimationToEnd:2e3);else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await p(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat)for(let o=0;o<e.repeat.times;o++)for(let r=0;r<e.repeat.commands.length;r++)await this.runStep(e.repeat.commands[r],r);else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")await this.evalScript(e.evalScript);else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let o=e.runFlow,r=typeof o=="string"?o:o.file,n=typeof o=="string"?void 0:o.when;if(n&&!await this.evaluateWhen(n)){console.log(`[flow] runFlow skipped (when predicate false): ${r}`);return}let i=g.resolve(this.opts.flowDir,r),s=b.readFileSync(i,"utf8"),a=this.opts.flowDir;this.opts.flowDir=g.dirname(i),await this.runFlow(Lt(s)),this.opts.flowDir=a}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let o=[],r=[],n=[];for(let s of e){let a=Object.keys(s);if(a.length===1&&a[0]==="onFlowStart"&&Array.isArray(s.onFlowStart)){o.push(...s.onFlowStart);continue}if(a.length===1&&a[0]==="onFlowComplete"&&Array.isArray(s.onFlowComplete)){r.push(...s.onFlowComplete);continue}n.push(s)}if(o.length>0){console.log(`[flow] onFlowStart (${o.length} steps)`);for(let s=0;s<o.length;s++)await this.runStep(o[s],s)}let i=null;try{await this.runFlowBody(n)}catch(s){i=s instanceof Error?s:new Error(String(s))}if(r.length>0){console.log(`[flow] onFlowComplete (${r.length} steps)`);for(let s=0;s<r.length;s++)try{await this.runStep(r[s],s)}catch(a){console.warn(`[flow] onFlowComplete step ${s+1} failed: ${a instanceof Error?a.message:a}`)}}if(i)throw i}async runFlowBody(e){for(let o=0;o<e.length;o++){let r=e[o],n=typeof r.wait=="number"?r.wait:0,i=typeof r.waitFor?.timeout=="number"?r.waitFor.timeout:0,s=Math.max(6e4,n+15e3,i+15e3);if(r.runFlow){await this.runStep(r,o);continue}await Promise.race([this.runStep(r,o),new Promise((a,l)=>setTimeout(()=>l(new Error(`step ${o+1} (${Object.keys(r)[0]}) exceeded ${s}ms deadline`)),s))])}}};function Xe(t){let e={},o=t,r=t.match(/^---\n([\s\S]*?)\n---\n?/);if(r){try{e=R.parse(r[1])??{}}catch(s){console.warn(` warn: could not parse frontmatter: ${s.message}`)}o=t.slice(r[0].length);let i=R.parse(o);return{frontmatter:e,steps:Array.isArray(i)?i:[]}}if(/\n---\s*\n/.test(t))try{let i=R.parseAllDocuments(t);if(i.length>=2){let s=i[0].toJS(),a=i[i.length-1].toJS();return{frontmatter:s&&typeof s=="object"?s:{},steps:Array.isArray(a)?a:[]}}}catch(i){console.warn(` warn: could not parse multi-doc flow: ${i.message}`)}let n=R.parse(o);return{frontmatter:e,steps:Array.isArray(n)?n:[]}}async function Wt(){let t=await Ye(),e=t.find(r=>r.patched);if(e)return`http://localhost:${e.port}/__soot/`;let o=t[0];return o?`http://localhost:${o.port}/__soot/`:null}async function Qe(t){(t.length===0||t.includes("--help")||t.includes("-h"))&&(console.log(`
|
|
250
|
-
sootsim flow \u2014 run flows or manage a draft session
|
|
251
|
-
|
|
252
|
-
usage:
|
|
253
|
-
sootsim flow <flow.yaml> [options]
|
|
254
|
-
sootsim flow start
|
|
255
|
-
sootsim flow keep
|
|
256
|
-
sootsim flow end [--output <path>] [--validate] [--video]
|
|
257
|
-
sootsim flow validate <path>
|
|
258
|
-
|
|
259
|
-
options:
|
|
260
|
-
--record record a webm artifact while the flow runs
|
|
261
|
-
--profile capture perf stats while the flow runs
|
|
262
|
-
--out <dir> output directory (default: /tmp/sootsim-recordings)
|
|
263
|
-
--device <model> override the flow frontmatter device for this run
|
|
264
|
-
--slow <ms> delay between steps for natural pacing
|
|
265
|
-
--url <url> load this target before running the flow
|
|
266
|
-
--screenshot-paths <mode>
|
|
267
|
-
screenshot path mode: dir (default) or flow
|
|
268
|
-
--replace <m>=<f> replace a Metro module with a local file for this run
|
|
269
|
-
--new open a fresh session before running the flow
|
|
270
|
-
--electron prefer opening the target in the desktop companion
|
|
271
|
-
--session <id> target a specific current session
|
|
272
|
-
--validate replay the drafted flow before clearing it
|
|
273
|
-
--video replay and record the drafted flow before clearing it
|
|
274
|
-
|
|
275
|
-
frontmatter (top of flow.yaml between --- markers):
|
|
276
|
-
app: 8081 load this target before the flow starts
|
|
277
|
-
device: iphone-14 set the live device model for this flow run
|
|
278
|
-
electron: true prefer the desktop companion session for this flow
|
|
279
|
-
|
|
280
|
-
default runtime:
|
|
281
|
-
bridge-backed flow playback against the current sootsim session
|
|
282
|
-
if no current session exists, flow opens the discovered target first
|
|
283
|
-
recording and profiling both run on the same bridge-backed path
|
|
284
|
-
|
|
285
|
-
examples:
|
|
286
|
-
sootsim flow login.yaml
|
|
287
|
-
sootsim flow demo.yaml --url 8081 --record --slow 500 --out ./recordings
|
|
288
|
-
sootsim flow demo.yaml --session tab-2
|
|
289
|
-
sootsim flow start
|
|
290
|
-
sootsim flow keep
|
|
291
|
-
sootsim flow end --output ./flows/draft.yaml
|
|
292
|
-
sootsim flow end --output ./flows/draft.yaml --validate
|
|
293
|
-
sootsim flow end --output ./flows/draft.yaml --video
|
|
294
|
-
sootsim flow validate ./flows/draft.yaml
|
|
295
|
-
|
|
296
|
-
flow extension:
|
|
297
|
-
takeScreenshot: hero
|
|
298
|
-
takeScreenshot:
|
|
299
|
-
path: marketing/hero
|
|
300
|
-
withFrame: true
|
|
301
|
-
`),process.exit(0));let e=t[0];I.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let o=d=>t.find((f,_)=>t[_-1]===d),r=t.includes("--profile"),n=t.includes("--new"),i=o("--out")||"/tmp/sootsim-recordings",s=o("--screenshots")||"/tmp/sootsim-flow",a=o("--screenshot-paths")==="flow"?"flow":"dir",l=o("--device")?.trim()||"",c=t.includes("--slow")?+(o("--slow")||"500"):0,m=t.includes("--electron"),h=t.includes("--preview"),me=await Ne(o("--preview-origin")),Ze=t.includes("--preview-open"),et=t.flatMap((d,f)=>t[f-1]==="--replace"?["--replace",d]:[]),O=t.includes("--record")||h,tt=I.readFileSync(e,"utf8"),{frontmatter:F,steps:C}=Xe(tt);C.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let W=l||F.device||"",j=m||F.electron===!0,re=F.app===void 0||F.app===null?"":typeof F.app=="number"?String(F.app):F.app,we={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open"],stripValueFlags:["--out","--device","--slow","--url","--replace","--headless","--screenshots","--screenshot-paths","--preview-origin"]},T=ie(t,we),rt=o("--url")||"";j&&!_e()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let ge=j?"desktop companion":"bridge",ot=re?` | target: ${re}`:"";console.log(`
|
|
302
|
-
sootsim flow \u2014 ${S.basename(e)}
|
|
303
|
-
${C.length} steps | ${ge}${ot}${O?" | recording":""}${r?" | profiling":""}${c?` | ${c}ms delay`:""}
|
|
304
|
-
`),h&&Ce({event:"preview_flow_started",properties:{flowName:S.basename(e),stepCount:C.length,mode:ge,electron:j,record:O,profile:r,previewOrigin:me}});let P=rt||re||"",oe=n||j&&T.browserIdSource!=="flag",he=!1;if(!P&&!oe&&T.browserIdSource==="none"){let d=Fe(T);try{let f=await d.listBrowsers(),_=f.find(G=>G.isPrimary&&G.readyState==="open"),Y=f.find(G=>G.readyState==="open"),Se=_??Y;Se&&(he=!0,console.log(` reusing active session: ${Se.id}`))}catch{}finally{d.close()}}if(!P&&!he&&(oe||T.browserIdSource==="none")){let d=await Wt();d||(console.error(" error: no current session and no sootsim target found"),await ae(),process.exit(1)),P=d}if(P&&W){let d=new URL(await Re(P));d.searchParams.set("device",W),P=d.toString()}if(P){let d=[P];d.push(...et),oe&&d.push("--new"),T.browserIdSource==="flag"&&T.browserId&&d.push("--session",T.browserId),await $e(d,{port:T.wsPort,timeoutMs:T.commandTimeoutMs})}let K=ie(t,we),be=K.browserIdSource==="flag"?K.browserId:xe()||K.browserId,x=Ie(K.wsPort,{commandTimeoutMs:K.commandTimeoutMs,browserId:be,fallbackOnMissingBrowserId:!1}),u,ye=async()=>{if(!W)return!1;let d=await x.send({type:"evaluate",browserId:u.browserId,code:"window.location.href"});if(typeof d=="string"&&d.length>0){let f=new URL(d);f.searchParams.set("device",W),u.setBrowserRouteHint(f.toString())}return!!await x.send({type:"call",browserId:u.browserId,path:"SootSim.bridges.settings.set",args:["deviceModel",W]})};u=new te(x,{screenshotDir:s,flowDir:S.dirname(S.resolve(e)),screenshotPathMode:a,browserId:be,recordingOutputDir:O?i:void 0,onAfterLaunch:async()=>{await ye()&&await u.waitForTree(12e4),h&&await x.send({type:"evaluate",browserId:u.browserId,code:`(() => {
|
|
305
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
306
|
-
return r?.start?.() ?? false
|
|
307
|
-
})()`})}}),c&&(u.stepDelay=c);let k=null,E=null,ne=null,J=0,nt=!!C[0]?.launchApp;try{await u.waitForTree(12e4),await ye()&&await u.waitForTree(12e4),O&&(nt?u.prepareRecording():await u.startRecording()),r&&await u.startProfile(),h&&(await x.send({type:"evaluate",browserId:u.browserId,code:`(() => {
|
|
308
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
309
|
-
return r?.start?.() ?? false
|
|
310
|
-
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await u.runFlow(C),r&&(k=await u.stopProfile()),O&&(E=await u.stopRecording()),h&&(ne=await x.send({type:"evaluate",browserId:u.browserId,code:`(() => {
|
|
311
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
312
|
-
return r?.stop?.() ?? []
|
|
313
|
-
})()`}),console.log(` captured ${ne.length} replay events`)),console.log(`
|
|
314
|
-
+ completed (${C.length} steps)`),k&&qe(k),E&&console.log(` video: ${E}`),console.log()}catch(d){if(r&&!k)try{k=await u.stopProfile()}catch{}if(O&&!E)try{E=await u.stopRecording()}catch(f){console.warn(` recording stop failed: ${f?.message||String(f)}`)}console.error(`
|
|
315
|
-
x failed: ${d.message}
|
|
316
|
-
`),k&&(console.log(" partial profile:"),qe(k)),E&&console.log(` partial video: ${E}`);try{let f=u.lastFailedStep,_=f?`step-${String(f.index+1).padStart(2,"0")}-${f.kind}`:"unstaged",Y=S.join(s,_);await u.captureFailureBundle(Y,{error:d,stepIndex:f?.index,stepKind:f?.kind,stepTarget:f?.target}),console.log(` failure bundle: ${Y}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(f){try{let _=S.join(s,"error.png");await u.captureFailureScreenshot(_),console.log(` error screenshot: ${_}`)}catch{}console.log(` (failure bundle capture failed: ${f instanceof Error?f.message:String(f)})`)}await Te(x,{errorsCommand:`sootsim get errors 5${u.browserId?` --session ${u.browserId}`:""}`,warningsCommand:`sootsim get warnings 5${u.browserId?` --session ${u.browserId}`:""}`,requestsCommand:`sootsim get requests 5${u.browserId?` --session ${u.browserId}`:""}`}),J=1}finally{x.close()}if(J===0&&h)try{let d=await Kt(ne??[]),f=["--origin",me,"--events",d];E&&f.push("--video",E),u.browserId&&f.push("--session",u.browserId),Ze&&f.push("--open"),console.log(`
|
|
317
|
-
preparing preview upload\u2026`);let{runUpload:_}=await import("./upload-BYNPC54C.js");await _(f,{})}catch(d){console.error(` preview upload failed: ${d?.message||d}`),J=1}return await ae(),J}async function Kt(t){let{gzipSync:e}=await import("zlib"),o=t.map(i=>JSON.stringify(i)).join(`
|
|
318
|
-
`)+(t.length?`
|
|
319
|
-
`:""),r=e(Buffer.from(o,"utf8")),n=S.join(ze(),`sootsim-events-${Date.now()}.jsonl.gz`);return I.writeFileSync(n,r),console.log(` events: ${t.length} written to ${n} (${r.length} bytes gz)`),n}async function Vt(t){let e=t[0],o=r=>t.find((n,i)=>t[i-1]===r);switch(e){case"start":{let{path:r,state:n}=Ee();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${n.steps.length}`);return}case"keep":case"good":{let r=Ae();if(r.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!r.kept){console.log(" no pending action to keep");return}console.log(` kept: ${r.candidate.summary}`),console.log(` steps: ${r.stepCount}`);return}case"end":{let r=o("--output")||(t[1]&&!t[1].startsWith("-")?t[1]:void 0),n=t.includes("--validate")||t.includes("--video"),i=t.includes("--video"),s=Pe(r||(n?jt():void 0));if(s.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),n){let a=Jt(t,s.outputPath),l=await Qe(a);if(l!==0){console.error(`
|
|
320
|
-
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=l;return}se(),console.log(` flow draft validated (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath&&console.log(` saved: ${s.outputPath}`),i&&console.log(" video: recorded during validation run");return}if(se(),console.log(` flow draft ended (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath){console.log(` saved: ${s.outputPath}`),console.log(` next: sootsim flow ${s.outputPath} --record`);return}console.log(""),process.stdout.write(s.yaml);return}case"validate":{let r=t[1];(!r||r.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let n=Bt(r);if(n.length>0){console.error(` x ${r} failed validation:`);for(let i of n)console.error(` - ${i}`);process.exit(1)}console.log(` + ${r} looks valid`);return}}}var He=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function Bt(t){let e=[];if(!I.existsSync(t))return[`file not found: ${t}`];let o;try{o=I.readFileSync(t,"utf8")}catch(i){return[`cannot read file: ${i.message}`]}if(o.trim().length===0)return["file is empty"];let r;try{r=Xe(o)}catch(i){return[`yaml parse error: ${i.message}`]}if(!Array.isArray(r.steps)||r.steps.length===0)return e.push("flow body must be a non-empty YAML array of steps"),e;let n=0;for(let i=0;i<r.steps.length;i++){let s=r.steps[i];s&&typeof s=="object"?Object.keys(s).some(l=>He.has(l))&&(n+=1):typeof s=="string"&&He.has(s)&&(n+=1)}return n===0&&e.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),e}async function Sr(t){let e=t[0];if(e==="start"||e==="keep"||e==="good"||e==="end"||e==="validate")return await Vt(t),0;let o=await Qe(t);return o!==0&&(process.exitCode=o),o}function qe(t){let e=t.avgMs>0?(1e3/t.avgMs).toFixed(1):"?",o=t.sampleCount>0?(t.jankFrames/t.sampleCount*100).toFixed(1):"0";console.log(`
|
|
321
|
-
profile:`),console.log(` frames: ${t.frames}`),console.log(` total: ${t.totalMs.toFixed(1)}ms`),console.log(` avg: ${t.avgMs.toFixed(2)}ms (${e} fps)`),console.log(` max: ${t.maxMs.toFixed(2)}ms`),t.layoutAvgMs!==void 0&&console.log(` breakdown: layout ${t.layoutAvgMs.toFixed(2)}ms | render ${t.renderAvgMs?.toFixed(2)||"0.00"}ms | copy ${t.copyAvgMs?.toFixed(2)||"0.00"}ms`),console.log(` p95: ${t.p95.toFixed(2)}ms`),console.log(` p99: ${t.p99.toFixed(2)}ms`),console.log(` jank: ${t.jankFrames}/${t.sampleCount} (${o}%) >16.67ms`);let r=Array.isArray(t.worstFrames)?t.worstFrames:[];if(r.length!==0){if(console.log(`
|
|
322
|
-
worst frames:`),t.mode==="render-worker"){console.log(" total layout render copy t+");for(let n of r){let[i,s,a,l,c]=n;console.log(` ${s.toFixed(2).padStart(7)} ${a.toFixed(2).padStart(7)} ${l.toFixed(2).padStart(7)} ${c.toFixed(2).padStart(7)} ${String(i).padStart(5)}`)}return}console.log(` ${r.map(n=>n.toFixed(2)).join(", ")}`)}}function jt(){return S.join(ze(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Jt(t,e){if(!e)throw new Error("validated flow draft requires an output path");let o=[e];for(let r=1;r<t.length;r++){let n=t[r];if(!(n==="--validate"||n==="--video")){if(n==="--output"){r+=1;continue}r===1&&!n.startsWith("-")||o.push(n)}}return!o.includes("--record")&&t.includes("--video")&&o.push("--record"),o}export{Xe as a,Wt as b,Qe as c,Sr as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{b as P}from"./chunk-KSB6MSZ4.js";import{a as V}from"./chunk-OROM7DZI.js";import{a as K,b,c as $,d as y}from"./chunk-MPSZ5EWF.js";import{d as E,e as p,f as A}from"./chunk-3C3ZH7PP.js";import{a as T}from"./chunk-E5UBZEYR.js";import{b as J}from"./chunk-74XPLOV4.js";import{a as j,b as q}from"./chunk-MBFP2LVH.js";import ge from"node:fs";import we from"node:os";import D from"node:path";var W="sootsimConfig";function C(t){return!!t&&Object.keys(t).length>0}function ie(t){return t?C(t.modules)||C(t.turboModules)||C(t.env)||C(t.settings)||C(t.initialState):!1}function R(t,o){let e=new URL(t);return ie(o)?e.searchParams.set(W,JSON.stringify(o)):e.searchParams.delete(W),e.toString()}var U="/node_modules/one/metro-entry.bundle?platform=ios&dev=true&minify=false",k="/index.bundle?platform=ios&dev=true&hot=true&minify=false",ae=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);function G(t){return new Error(`could not resolve a native bundle for ${t}. pass an explicit bundle URL or open Connect and choose the app there.`)}function ce(t,o){return t?.includes("/one/metro-entry.bundle")?"one":typeof o=="string"&&o?"expo":"unknown"}function le(t){return t.replace(/^\[|\]$/g,"").toLowerCase()}function Q(t){return ae.has(le(t))}function Y(t,o,e){return`${t}//${o}:${e}`}function ue(t){if(typeof window>"u")return!1;try{let o=new URL(t);return Q(o.hostname)&&o.origin!==window.location.origin}catch{return!1}}async function B(t,o){return ue(t)?fetch(`/__fetch-proxy?url=${encodeURIComponent(t)}`,o):fetch(t,o)}function de(t){return t==="https:"?443:80}function me(t){let o=t.pathname||"/";return(o==="/"||o==="")&&!t.search&&!t.hash}async function fe(t){try{return(await B(`${t}${U}`,{method:"HEAD"})).ok}catch{return!1}}async function X(t,o){let e=t.replace(/\/+$/,"");try{let n=await B(`${e}/`,{headers:{"expo-platform":"ios"}});if(n.ok){let r=await n.json(),s=r?.extra?.expoClient||r?.extra||{},i=typeof r?.launchAsset?.url=="string"?r.launchAsset.url:void 0;if(i||s.name){let a=ce(i,s.sdkVersion);return{bundleUrl:a==="one"&&await fe(e)?`${e}${U}`:i||`${e}${k}`,port:o,framework:a,projectName:s.name}}}}catch{}try{if((await B(`${e}${U}`,{method:"HEAD"})).ok)return{bundleUrl:`${e}${U}`,port:o,framework:"one"}}catch{}try{if((await B(`${e}${k}`,{method:"HEAD"})).ok)return{bundleUrl:`${e}${k}`,port:o,framework:"metro"}}catch{}try{let n=await B(`${e}/status`);if(n.ok&&(await n.text()).includes("packager-status:running"))return{bundleUrl:`${e}${k}`,port:o,framework:"metro"}}catch{}return null}async function pe(t){return X(Y("http:","localhost",t),t)}async function Z(t){let o=t.trim();if(/^\d+$/.test(o)){let a=parseInt(o,10),c=await pe(a);if(c)return c;throw G(`localhost:${a}`)}let e=o.startsWith("http")?o:`http://${o}`,n;try{n=new URL(e)}catch{throw new Error(`could not parse "${t}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let r=n.protocol||"http:",s=n.port?parseInt(n.port,10):de(r),i=Y(r,n.hostname,s);if(Q(n.hostname)&&me(n)){let a=await X(i,s);if(a)return a;throw G(i)}return{bundleUrl:n.toString(),port:s,framework:"unknown"}}var he={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function M(t){return new Promise(o=>setTimeout(o,t))}function oe(t){return t.trim()}function F(t){try{let o=new URL(t),e=o.pathname.replace(/\/+$/,"")||"/";return o.searchParams.has("open")||o.searchParams.has("port")||o.searchParams.has("bundle")||o.searchParams.has("demo")||o.pathname.includes("/sootsim/index.html")||o.pathname==="/__soot"||o.pathname==="/__soot/"||e==="/rn"||/^\/rn\/[^/]+$/i.test(e)||/^\/app\/[^/]+$/i.test(e)||e==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(e)||/^\/__soot\/app\/[^/]+$/i.test(e)}catch{return!1}}async function Fe(t){let o=oe(t);return(await Z(o)).bundleUrl}function ne(t){let o=t.replace(/\/+$/,"")||"/";return o==="/__soot"||o.startsWith("/__soot/")?"/__soot":""}function be(t,o){let e=oe(t),n=new URL(o),r=ne(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),/^\d+$/.test(e)?n.pathname=`${r}/rn/${e}`:(n.pathname=`${r}/rn`,n.searchParams.set("open",e)),n.toString()}function $e(t){return t.startsWith("~/")?D.join(we.homedir(),t.slice(2)):D.isAbsolute(t)?t:D.resolve(process.cwd(),t)}function ye(t){let o={};for(let e=0;e<t.length;e++){if(t[e]!=="--replace")continue;let n=t[e+1];n||(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let r=n.indexOf("=");(r<=0||r===n.length-1)&&(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let s=n.slice(0,r).trim(),i=$e(n.slice(r+1).trim());ge.existsSync(i)||(console.error(` sootsim open: replacement file not found: ${i}`),process.exit(1)),o[s]={file:i},e++}return Object.keys(o).length>0?{modules:o}:void 0}async function v(t,o=T){if(!t)return new URL(o).toString();if(F(t))return new URL(t).toString();let e=he[t.toLowerCase()];if(e){let n=new URL(o),r=ne(n.pathname);return n.pathname=`${r}${e}`,n.toString()}return be(t,o)}function ee(t,o){let e=t?.url||t?.origin||o;try{let n=new URL(e);return n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("inspectOpen"),n.toString()}catch{return o}}async function Se(t,o,e){let n=new URL(await v(t,o));return n.searchParams.set("inspectOpen",e),n.toString()}async function Ce(t,o,e,n={}){let r=n.attempts??30,s=n.intervalMs??500,i=n.minNodeCount??10;for(let a=0;a<r;a++){let c=$(t,{commandTimeoutMs:o,browserId:e});try{let u=await c.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof u=="number"&&u>i)return{bridge:c,count:u}}catch{}c.close(),await M(s)}return null}function Be(t){if(!t)return"unknown";try{let o=new URL(t);if(o.searchParams.has("bundle")){let e=o.searchParams.get("bundle")||"";try{let n=new URL(e),r=n.pathname.length>36?`...${n.pathname.slice(-36)}`:n.pathname;return`bundle ${n.host}${r}`}catch{return"bundle"}}return o.searchParams.has("port")?`connect :${o.searchParams.get("port")||""}`:o.searchParams.has("open")?`connect ${o.searchParams.get("open")||""}`:o.searchParams.has("demo")?`demo ${o.searchParams.get("demo")||"default"}`:o.pathname.includes("/sootsim/index.html")?"embedded sootsim":`${o.host}${o.pathname}${o.search}`}catch{return t}}function xe(t,o){if(t.length===0){console.log(" no browser tabs connected");return}console.log(` connected browser tabs (${t.length}):
|
|
3
|
-
`);for(let e of t){let n=e.lockedBy&&e.lockExpiresAt?`locked by ${e.lockedBy} (${Math.max(0,Math.round((e.lockExpiresAt-Date.now())/1e3))}s)`:"",r=[e.isPrimary?"primary":"",e.id===o?"selected":"",e.readyState,e.attachedCliCount&&e.attachedCliCount>0?"in use":"",e.userFocused?"focused":"",n].filter(Boolean);if(console.log(` ${e.id}${r.length?` [${r.join(", ")}]`:""}`),console.log(` loaded: ${Be(e.url)}`),e.url?console.log(` url: ${e.url}`):e.origin&&console.log(` origin: ${e.origin}`),e.title&&console.log(` title: ${e.title}`),console.log(` connected: ${new Date(e.connectedAt).toISOString()}`),e.lastActiveAt&&e.lastActiveAt>0){let s=Math.round((Date.now()-e.lastActiveAt)/1e3),i=s<60?`${s}s ago`:s<3600?`${Math.round(s/60)}m ago`:`${Math.round(s/3600)}h ago`;console.log(` last active: ${i}`)}}}async function te(t,o,e,n={}){let r=n.attempts??30,s=n.intervalMs??500;for(let i=0;i<r;i++){let a=$(t,{commandTimeoutMs:o});try{let u=(await a.listBrowsers()).find(e);if(u)return u}catch{}finally{a.close()}await M(s)}return null}async function Pe(t,o,e,n={}){let r=n.attempts??20,s=n.intervalMs??250;for(let i=0;i<r;i++){let a=$(t,{commandTimeoutMs:o});try{let u=(await a.listBrowsers()).find(g=>g.id===e);if(!u||u.readyState!=="open")return!0}catch{return!0}finally{a.close()}await M(s)}return!1}function I(t,o){if(o){let r=t.find(s=>s.id===o);if(!r)throw new Error(`no browser connected with id ${o}`);return r}let e=t.find(r=>r.isPrimary&&r.readyState==="open");if(e)return e;let n=t.find(r=>r.readyState==="open");if(n)return n;throw new Error("no browser connected")}function N(t,o,e){console.log(` ${e==="current session"?"loaded":"opened"}: ${t} [${e}]`),console.log(` active session: ${o.id}`),console.log(JSON.stringify({id:o.id,url:o.url},null,2))}async function He(t,o={}){let e=b(t,{port:o.port,commandTimeoutMs:o.timeoutMs}),n=y(e);try{let r=await n.listBrowsers();xe(r,e.browserId)}finally{n.close()}}async function ze(t,o={}){let e=b(t,{port:o.port,commandTimeoutMs:o.timeoutMs,stripBooleanFlags:["--new"],stripValueFlags:["--base-url","--replace"]}),n=t.includes("--new"),r=ye(t);n&&e.browserIdSource==="flag"&&(console.error(" sootsim open: --new cannot be combined with --session/--id"),process.exit(1));let s=e.positional[0]||"",i=t.find((l,w)=>t[w-1]==="--base-url")||T,a=t.includes("--base-url"),c=E();if(!n&&(e.browserIdSource==="flag"||e.browserIdSource==="saved"&&!!c)){let l=y(e),w=e.browserId?` --session ${e.browserId}`:"",f=!1;try{let d=null;try{let m=await l.listBrowsers();if(e.browserIdSource==="saved"?(d=m.find(h=>h.id===c&&h.readyState==="open"),d||A()):d=I(m,e.browserId),!d)if(e.browserIdSource==="saved")f=!0;else throw new Error("no browser connected");if(!f&&d){let h=a||F(s)?i:ee(d,i),x=await v(s,R(h,r));l.send({type:"evaluate",browserId:d.id,code:`window.location.href = ${JSON.stringify(x)}`}).catch(()=>{})}}catch(m){console.error(` open failed: ${m instanceof Error?m.message:String(m)}`),await P(l,{errorsCommand:`sootsim get errors 5${w}`,warningsCommand:`sootsim get warnings 5${w}`,requestsCommand:`sootsim get requests 5${w}`}),process.exit(1)}if(!f&&d){await M(1500);let m=await Ce(e.wsPort,e.commandTimeoutMs,d.id);m||(console.error(" timed out waiting for current session to load target"),process.exit(1)),m.bridge.close(),p(d.id);let h=a||F(s)?i:ee(d,i),x=await v(s,R(h,r));N(x,{...d,url:x},"current session");return}}finally{l.close()}}let g=R(i,r),se=await v(s,g),H=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,S=await Se(s,g,H),z=l=>l.url?.includes(`inspectOpen=${H}`)??!1,O=!1,_=!1;try{let l=$(e.wsPort,{commandTimeoutMs:2e3});try{await l.listBrowsers(),O=!0}finally{l.close()}}catch{}if(O)try{let l=$(e.wsPort,{commandTimeoutMs:3e3});try{await l.openUrl(S),_=!0}finally{l.close()}}catch{}if(!_){let l=j();if(l)try{if((await q(S,l)).launched){let f=await te(e.wsPort,e.commandTimeoutMs,z,{attempts:20,intervalMs:500});if(f){p(f.id),N(S,f,"desktop companion");return}}}catch{}if(await V(S),!O){console.log(` opened: ${se}`),J(e.wsPort);return}}let L=await te(e.wsPort,e.commandTimeoutMs,z,{attempts:30,intervalMs:500});L||(console.error(" timed out waiting for opened tab to connect"),process.exit(1)),p(L.id),N(S,L,_?"bridge":"direct open")}async function re(t,o={}){let e=b(t,{port:o.port,commandTimeoutMs:o.timeoutMs}),n=y(e),r=e.browserId?` --session ${e.browserId}`:"";try{try{let s=await n.listBrowsers(),i=I(s,e.positional[0]||e.browserId);await n.focusBrowser(i.id),p(i.id),console.log(` using: ${i.id}`)}catch(s){console.error(` use failed: ${s instanceof Error?s.message:String(s)}`),await P(n,{errorsCommand:`sootsim get errors 5${r}`,warningsCommand:`sootsim get warnings 5${r}`,requestsCommand:`sootsim get requests 5${r}`}),process.exit(1)}}finally{n.close()}}async function je(t,o={}){await re(t,o)}async function qe(t,o={}){await re(t,o)}async function Je(t,o={}){let e=b(t,{port:o.port,commandTimeoutMs:o.timeoutMs,stripBooleanFlags:["--force"]}),n=t.includes("--force"),r=y(e);try{try{let s=await r.listBrowsers(),i=I(s,e.positional[0]||e.browserId),a=n&&i.lockedBy&&i.lockedByKind!=="user-active"?i.lockedBy:null,c=await r.claim(i.id,{force:n});p(i.id);let u=Math.max(0,Math.round((c.lockExpiresAt-Date.now())/1e3)),g=c.bootedCount>0?` (booted ${c.bootedCount})`:"";console.log(` claimed: ${c.browserId} [${u}s]${g}`),a&&console.log(` took over from: ${a}`)}catch(s){if(s instanceof K){let i=Math.max(0,Math.round(s.lock.expiresInMs/1e3));console.error(` claim failed: locked by ${s.lock.by} for ${i}s more`),console.error(" use --force to take it, or `sootsim open --new` for a fresh session"),process.exit(1)}console.error(` claim failed: ${s instanceof Error?s.message:String(s)}`),process.exit(1)}}finally{r.close()}}async function Ke(t,o={}){let e=b(t,{port:o.port,commandTimeoutMs:o.timeoutMs}),n=y(e),r=e.browserId?` --session ${e.browserId}`:"";try{try{let s=await n.listBrowsers(),i=I(s,e.positional[0]||e.browserId),a=s.find(u=>u.id!==i.id&&u.readyState==="open");if(await n.closeBrowser(i.id),!await Pe(e.wsPort,e.commandTimeoutMs,i.id)){console.log(` close requested: ${i.id} (still connected)`);return}E()===i.id&&(a?p(a.id):A()),console.log(` closed: ${i.id}`)}catch(s){console.error(` close failed: ${s instanceof Error?s.message:String(s)}`),await P(n,{errorsCommand:`sootsim get errors 5${r}`,warningsCommand:`sootsim get warnings 5${r}`,requestsCommand:`sootsim get requests 5${r}`}),process.exit(1)}}finally{n.close()}}export{R as a,Fe as b,v as c,Se as d,Be as e,xe as f,te as g,He as h,ze as i,je as j,qe as k,Je as l,Ke as m};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{g,i as u,j as d}from"./chunk-YCETS3B3.js";var S="sootsim:settings",p=["errorReporting","colorScheme","a11yMode","a11yDepth","screenshotCanvas","screenshotBackground","screenshotText","screenshotPose","screenshotDynamicSize"];function y(){try{let e=localStorage.getItem(S);if(!e)return{};let t=JSON.parse(e),n={};for(let o of p)o in t&&(n[o]=t[o]);return n}catch{return{}}}function h(e){try{let t={};for(let n of p)t[n]=e[n];localStorage.setItem(S,JSON.stringify(t))}catch{}}var v=d(),K=typeof localStorage<"u"?y():{},s={...v,...K},a=[],i=null;function f(){for(let e of a)e();typeof localStorage<"u"&&h(s)}var V={get(e){return s[e]},set(e,t){let n=u[e];n.validate&&!n.validate(t)||n.options&&!n.options.includes(t)||s[e]!==t&&(s={...s,[e]:t},e==="deviceModel"&&(i=null),f())},getAll(){return s},apply(e){let t=!1,n={...s};for(let[o,r]of Object.entries(e)){if(r===void 0)continue;let l=o,c=u[l];c&&(c.validate&&!c.validate(r)||c.options&&!c.options.includes(r)||n[l]!==r&&(n[l]=r,t=!0))}t&&(s=n,i=null,f())},reset(){s=d(),i=null,f()},subscribe(e){return a.push(e),()=>{a=a.filter(t=>t!==e)}},getDeviceSpec(){return i||(i=g(s.deviceModel)),i},getA11yMode(){return s.a11yMode},setA11yMode(e){this.set("a11yMode",e)},getInspectMode(){return s.inspectMode},setInspectMode(e){this.set("inspectMode",e)}};export{V as a};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
function d(o){let e=o.displayUrl||o.url;return o.status!=null?`${o.method} ${e} -> ${o.status}${o.statusText?` ${o.statusText}`:""}`:o.error?`${o.method} ${e} -> ${o.error}`:`${o.method} ${e}`}async function c(o,e,...n){return o.send({type:"call",path:`__sootsimTest.${e}`,args:n})}async function g(o,e={}){let n=await o.send({type:"evaluate",code:"window.__sootsimConsole?.count?.() || { errors: 0, warnings: 0, total: 0 }"});if(!n||typeof n!="object")return;let t=Math.max(0,Number(n.errors)||0),r=Math.max(0,Number(n.warnings)||0);if(t===0&&r===0)return;let s=[];if(t>0&&s.push(`${t} console error${t===1?"":"s"}`),r>0&&s.push(`${r} console warning${r===1?"":"s"}`),console.log(`
|
|
3
|
-
console: ${s.join(", ")}`),e.errorsCommand&&console.log(` inspect: ${e.errorsCommand}`),r>0&&e.warningsCommand&&console.log(` inspect: ${e.warningsCommand}`),!e.includeTail||t===0)return;let a=await o.send({type:"evaluate",code:"window.__sootsimConsole?.getErrors?.(5) || []"});if(!(!Array.isArray(a)||a.length===0)){console.log(`
|
|
4
|
-
recent console errors:
|
|
5
|
-
`);for(let i of a){let u=new Date(i.timestamp).toLocaleTimeString(),m=Array.isArray(i.args)?i.args.map(l=>typeof l=="object"?JSON.stringify(l):String(l)).join(" "):String(i);console.log(` [${u}] ${m}`)}}}async function f(o,e={}){let n=await c(o,"getRequestCounts");if(!n||typeof n!="object")return;let t=Math.max(0,Number(n.failed)||0);if(t===0||(console.log(`
|
|
6
|
-
network: ${t} failed request${t===1?"":"s"}`),e.requestsCommand&&console.log(` inspect: ${e.requestsCommand}`),!e.includeTail))return;let r=await c(o,"getFailedRequests",5);if(!(!Array.isArray(r)||r.length===0)){console.log(`
|
|
7
|
-
recent failed requests:
|
|
8
|
-
`);for(let s of r){let a=new Date(s.timestamp).toLocaleTimeString();console.log(` [${a}] ${d(s)}`),s.responseBody?console.log(` ${s.responseBody}`):s.error&&console.log(` ${s.error}`)}}}async function w(o){let e=await o.send({type:"evaluate",code:`(async () => {
|
|
9
|
-
const test = window.__sootsimTest
|
|
10
|
-
const mainShell = window.SootSim?.bridges?.mainShell
|
|
11
|
-
let shell = null
|
|
12
|
-
try {
|
|
13
|
-
shell = typeof mainShell?.getState === 'function' ? await mainShell.getState() : null
|
|
14
|
-
} catch {}
|
|
15
|
-
let nodeCount = 0
|
|
16
|
-
try {
|
|
17
|
-
nodeCount = typeof test?.getNodeCount === 'function' ? await test.getNodeCount() : 0
|
|
18
|
-
} catch {}
|
|
19
|
-
return {
|
|
20
|
-
url: window.location.href,
|
|
21
|
-
bridgeId: window.__sootsimBridgeId || null,
|
|
22
|
-
nodeCount,
|
|
23
|
-
mode: window.__sootsimRenderHost ? 'render-worker' : 'main-thread',
|
|
24
|
-
shell: shell
|
|
25
|
-
? {
|
|
26
|
-
state: shell.state || null,
|
|
27
|
-
activeApp: shell.activeApp || null,
|
|
28
|
-
showSwitcher: !!shell.showSwitcher,
|
|
29
|
-
switcherPhase: shell.switcherPhase || null,
|
|
30
|
-
}
|
|
31
|
-
: null,
|
|
32
|
-
}
|
|
33
|
-
})()`});if(!e||typeof e!="object")return;console.log(`
|
|
34
|
-
state:`),e.bridgeId&&console.log(` session: ${e.bridgeId}`),e.url&&console.log(` url: ${e.url}`),e.mode&&console.log(` mode: ${e.mode}`),console.log(` nodes: ${Number(e.nodeCount)||0}${(Number(e.nodeCount)||0)>10?" (ready)":" (not ready)"}`);let n=e.shell;if(n&&typeof n=="object"){let t=[n.state?`state=${n.state}`:null,n.activeApp?`app=${n.activeApp}`:null,n.showSwitcher?"switcher=open":null,n.switcherPhase?`phase=${n.switcherPhase}`:null].filter(Boolean);t.length>0&&console.log(` shell: ${t.join(" ")}`)}}async function h(o,e={}){try{await w(o)}catch{}try{await g(o,{includeTail:!0,errorsCommand:e.errorsCommand,warningsCommand:e.warningsCommand})}catch{}try{await f(o,{includeTail:!0,requestsCommand:e.requestsCommand})}catch{}}export{w as a,h as b};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as v}from"./chunk-PWXPA745.js";import{a as F}from"./chunk-OROM7DZI.js";import{b as L,d as A,f}from"./chunk-MPSZ5EWF.js";import{readFileSync as K}from"fs";function ee(){let t=process.env.SOOT_POSTHOG_API_KEY||process.env.VITE_POSTHOG_API_KEY||"";if(!t)return null;let e=process.env.SOOT_POSTHOG_HOST||process.env.VITE_POSTHOG_HOST||"https://us.i.posthog.com";return{apiKey:t,host:e.replace(/\/+$/,"")}}function te(t){return t?t.userId?t.userId:t.installationId!=null?`install:${t.installationId}`:t.repoId?`repo:${t.repoId}`:t.shareId?`share:${t.shareId}`:"anonymous-cli":"anonymous-cli"}function ne(t){let e=t.identity??{},r={$lib:"soot-cli",source:e.source??"cli",...t.properties};return e.userId&&(r.userId=e.userId),e.repoId&&(r.repoId=e.repoId),e.installationId!=null&&(r.installationId=String(e.installationId)),e.shareId&&(r.shareId=e.shareId),e.plan&&(r.plan=e.plan),{event:t.event,distinct_id:te(e),properties:r,timestamp:new Date().toISOString()}}var g=[],N=!1;async function T(){if(g.length===0)return;let t=ee();if(!t){g.length=0;return}let e=g.splice(0,g.length).map(ne);try{await fetch(`${t.host}/batch/`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({api_key:t.apiKey,batch:e}),keepalive:!0})}catch{}}function re(){N||(N=!0,process.on("beforeExit",()=>{T()}),process.on("exit",()=>{T()}))}function H(t){re();let e=null;try{e=v()?.user?.id??null}catch{e=null}g.push({...t,identity:{source:"cli",userId:e,...t.identity}})}async function h(){await T()}var W=process.env.SOOTSIM_UPLOAD_ORIGIN||"https://sootbean.com",P="http://localhost:3000";async function oe(t){if(t)return t;if(process.env.SOOTSIM_UPLOAD_ORIGIN)return process.env.SOOTSIM_UPLOAD_ORIGIN;try{let e=await fetch(`${P}/api/preview/upload`,{method:"OPTIONS"});if(e.ok||e.status===204||e.status===405)return P}catch{}return W}function se(){console.log(`
|
|
3
|
-
sootsim upload \u2014 publish the current bundle as a /preview/<id> link
|
|
4
|
-
|
|
5
|
-
usage:
|
|
6
|
-
sootsim upload [--origin <url>] [--events <path>] [--session <tab-id>] [--open] [--assets-only]
|
|
7
|
-
|
|
8
|
-
options:
|
|
9
|
-
--origin <url> upload target (default: auto)
|
|
10
|
-
prefers ${P} when available, otherwise
|
|
11
|
-
falls back to ${W}
|
|
12
|
-
override with SOOTSIM_UPLOAD_ORIGIN env var
|
|
13
|
-
--events <path> path to a gzipped events .jsonl.gz file to attach
|
|
14
|
-
--video <path> path to a webm/mp4/gif flow recording. embedded inline
|
|
15
|
-
in the pr sticky comment served at
|
|
16
|
-
/api/preview/flow-video?id=<share-id>
|
|
17
|
-
--session <tab-id> target a specific sootsim tab (see: sootsim list)
|
|
18
|
-
--open open the resulting /preview/<id> url in the browser
|
|
19
|
-
--assets-only drop API/JSON/HTML records before upload; keep images,
|
|
20
|
-
fonts, css, js, and binary blobs. live-data demos hit
|
|
21
|
-
the real network at replay time instead of serving
|
|
22
|
-
recorded API snapshots
|
|
23
|
-
-h, --help
|
|
24
|
-
|
|
25
|
-
examples:
|
|
26
|
-
sootsim upload
|
|
27
|
-
sootsim upload --origin http://localhost:3000 --open
|
|
28
|
-
sootsim upload --events ./my-session.jsonl.gz
|
|
29
|
-
sootsim upload --video /tmp/soot-flow.webm
|
|
30
|
-
`)}function _(t,e){let r=t.findIndex(l=>l===e);if(r<0)return;let i=t[r+1];return t.splice(r,2),i}function j(t,e){let r=t.findIndex(i=>i===e);return r<0?!1:(t.splice(r,1),!0)}function z(t){let e=(t||"").toLowerCase().split(";")[0].trim();return e?!!(e.startsWith("image/")||e.startsWith("font/")||e.startsWith("video/")||e.startsWith("audio/")||e.startsWith("model/")||e==="text/css"||e==="application/javascript"||e==="text/javascript"||e==="application/wasm"||e==="application/font-woff"||e==="application/font-woff2"||e==="application/octet-stream"):!1}async function D(t){let e=await fetch(t);if(!e.ok)throw new Error(`fetch ${t} -> ${e.status} ${e.statusText}`);return new Uint8Array(await e.arrayBuffer())}function G(t){return Buffer.from(t).toString("base64")}function ie(t){return/\.bundle($|\?)/.test(t)||/\.js($|\?)/.test(t)?"application/javascript":/\.zip($|\?)/.test(t)?"application/zip":"application/javascript"}function le(t){try{let e=new URL(t);return e.searchParams.get("lazy")==="true"?(e.searchParams.set("lazy","false"),e.toString()):t}catch{return t}}async function ae(t,e){let i=[];for(let l=0;l<e;l+=15e5){let u=Math.min(l+15e5,e),m=await f(t,`(window.__sootsimLastTransformedBundle?.text || "").slice(${l}, ${u})`);if(typeof m!="string")return null;i.push(m)}return i.join("")}async function ye(t,e){(t.includes("--help")||t.includes("-h"))&&(se(),process.exit(0));let r=[...t],i=await oe(_(r,"--origin")),l=_(r,"--events"),u=_(r,"--video"),m=j(r,"--open"),U=j(r,"--assets-only"),M=L(r,{stripBooleanFlags:[],stripValueFlags:[]}),c=A(M),o,R=[],a=[],I=null;try{if(o=await f(c,'(typeof window.__sootsimCaptureBundle === "function") ? window.__sootsimCaptureBundle() : null'),o?.bundleUrl){let n=new URL(o.bundleUrl).origin;R=await f(c,`(window.__sootsimPreviewRecorder?.list?.(${JSON.stringify(n)}) || [])`);let s=await f(c,`(() => {
|
|
31
|
-
const rec = window.__sootsimPreviewRecorder
|
|
32
|
-
if (!rec?.list) return null
|
|
33
|
-
const all = rec.list()
|
|
34
|
-
const cross = all.filter((e) => {
|
|
35
|
-
try { return new URL(e.url).origin !== ${JSON.stringify(n)} } catch { return false }
|
|
36
|
-
})
|
|
37
|
-
return {
|
|
38
|
-
count: cross.length,
|
|
39
|
-
totalBytes: cross.reduce((n, e) => n + (e.size || 0), 0),
|
|
40
|
-
}
|
|
41
|
-
})()`);if(s&&s.count>0&&(console.log(` ${s.count} recorded cross-origin responses (${(s.totalBytes/1024).toFixed(1)} KiB)`),a=await f(c,`(() => {
|
|
42
|
-
const rec = window.__sootsimPreviewRecorder
|
|
43
|
-
if (!rec?.dump) return []
|
|
44
|
-
const all = rec.dump()
|
|
45
|
-
return all.filter((r) => {
|
|
46
|
-
try { return new URL(r.url).origin !== ${JSON.stringify(n)} } catch { return false }
|
|
47
|
-
})
|
|
48
|
-
})()`),U)){let Q=a.length;a=a.filter(x=>z(x.contentType));let X=s.totalBytes-a.reduce((x,Z)=>x+(Z.size||0),0);console.log(` --assets-only: kept ${a.length}/${Q} records (dropped ${(X/1024).toFixed(1)} KiB of API responses)`)}}o?.transformedBundle&&(I=await ae(c,o.transformedBundle.byteLength))}finally{c.close()}o||(console.error(" could not read bundle snapshot \u2014 is sootsim running and is the bundle loaded?"),process.exit(2)),o.bundleUrl||(console.error(` no ?bundle= URL on the current sootsim tab.
|
|
49
|
-
open the app you want to share first (e.g. sootsim open 8082), then run upload.`),process.exit(2));let d,O=!1;if(I!==null)d=new TextEncoder().encode(I),O=!0,console.log(` using post-transform bundle: ${(d.byteLength/1024).toFixed(1)} KiB`);else{let n=le(o.bundleUrl);n!==o.bundleUrl&&console.log(" forcing lazy=false for self-contained bundle"),console.log(` capturing: ${n}`),d=await D(n),console.log(` main bundle: ${(d.byteLength/1024).toFixed(1)} KiB`)}let y=R.filter(n=>n.url!==o.bundleUrl);U&&(y=y.filter(n=>z(n.contentType))),console.log(` fetching ${y.length} extra files\u2026`);let b=(await Promise.all(y.map(async n=>{try{let s=await D(n.url);return{...n,bytes:s}}catch(s){return console.error(` warning: failed to re-fetch ${n.url}: ${s instanceof Error?s.message:s}`),null}}))).filter(n=>!!n),J=b.reduce((n,s)=>n+s.bytes.byteLength,0);console.log(` ${b.length} extra files: ${(J/1024).toFixed(1)} KiB`);let B;l&&(B=K(l).toString("base64"));let S,$;if(u){let n=K(u);S=n.toString("base64"),$=u.endsWith(".mp4")?"video/mp4":u.endsWith(".gif")?"image/gif":"video/webm",console.log(` attaching flow video: ${(n.byteLength/1024).toFixed(1)} KiB (${$})`)}let E=`${i.replace(/\/$/,"")}/api/preview/upload`;console.log(` uploading to ${E}`);let w=v();H({event:"preview_upload_started",identity:{userId:w?.user?.id??null},properties:{origin:i,hasAuth:!!w?.token,bundleBytes:d.byteLength,isTransformed:O,extraFiles:b.length,recordedFetches:a.length,hasEvents:!!B,hasVideo:!!S}}),w?.token||(console.error(" preview uploads require login."),console.error(" run `sootsim login` first."),await h(),process.exit(1));let V=(()=>{try{return new URL(o.bundleUrl).origin}catch{return null}})(),q=[...b.map(n=>({url:n.url,urlhash:n.urlhash,contentType:n.contentType,bodyBase64:G(n.bytes)})),...a.map(n=>({url:n.url,urlhash:n.urlhash,contentType:n.contentType,bodyBase64:n.bodyBase64}))],Y={bundleBase64:G(d),bundleContentType:ie(o.bundleUrl),bundleOrigin:V,entry:o.entry,deviceSpec:o.deviceSpec,eventsBase64:B,isTransformed:O,files:q,flowVideoBase64:S,flowVideoContentType:$},p=await fetch(E,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${w.token}`},body:JSON.stringify(Y)});if(!p.ok){let n=await p.text().catch(()=>"");p.status===401&&(console.error(" preview upload requires a valid login."),console.error(" run `sootsim login` and retry."),n&&console.error(` ${n}`),await h(),process.exit(1)),console.error(` upload failed: ${p.status} ${p.statusText}
|
|
50
|
-
${n}`),await h(),process.exit(1)}let k=await p.json(),C=`${i.replace(/\/$/,"")}${k.url}`;console.log(`
|
|
51
|
-
stored ${k.filesStored??0} extra files`),console.log(` preview: ${C}`),m&&await F(C),await h()}export{H as a,h as b,oe as c,ye as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{execFileSync as d,spawn as f}from"child_process";import{existsSync as p,readdirSync as g}from"fs";import{dirname as m,join as u,resolve as r}from"path";import{fileURLToPath as h}from"url";var s=m(h(import.meta.resolve("sootsim-engine/package.json"))),v="dev.sootsim.simulator";function k(){let t=s,n=u(t,"dist-electron/main.cjs");if(!p(n))return null;let e=x(t);return e?{path:e,platform:process.platform,kind:"dev-electron",engineDir:t}:null}function x(t){let n=t;for(let e=0;e<6;e++){let i=u(n,"node_modules/.bin/electron");if(p(i))return i;let o=m(n);if(o===n)break;n=o}return null}function I(){let n=["/Applications/sootsim.app",r(process.env.HOME||"","Applications/sootsim.app"),r(s,"app/sootsim.app")].find(e=>p(e));if(n)return{path:n,platform:"darwin",kind:"mac-app"};try{let e=d("mdfind",[`kMDItemCFBundleIdentifier == "${v}"`],{encoding:"utf8",timeout:3e3}).trim();if(e)return{path:e.split(`
|
|
3
|
-
`)[0],platform:"darwin",kind:"mac-app"}}catch{}return null}function l(t){if(!p(t))return null;let n=g(t).filter(e=>e.startsWith("sootsim")&&e.endsWith(".AppImage")).sort().reverse()[0];return n?u(t,n):null}function D(){let n=[r(process.env.HOME||"","Applications/sootsim.AppImage"),r(process.env.HOME||"",".local/bin/sootsim.AppImage"),"/opt/sootsim/sootsim.AppImage","/opt/sootsim/sootsim",r(s,"app/sootsim.AppImage"),r(s,"release/linux-unpacked/sootsim")].find(i=>p(i));if(n)return{path:n,platform:"linux",kind:n.endsWith(".AppImage")?"linux-appimage":"linux-binary"};let e=l(r(s,"app"))||l(r(s,"release"));return e?{path:e,platform:"linux",kind:"linux-appimage"}:null}function A(){if(process.env.SOOTSIM_PREFER_PACKAGED!=="1"){let t=k();if(t)return t}return process.platform==="darwin"?I():process.platform==="linux"?D():null}async function c(t,n){await new Promise((e,i)=>{let o=f(t,n,{detached:!0,stdio:"ignore"});o.once("error",i),o.once("spawn",()=>{o.unref(),e()})})}async function S(t,n=A(),e={}){if(!n)return{launched:!1};let i=e.device?["--device",e.device]:[];if(n.kind==="mac-app"){let a=["-g","-a",n.path];return t&&a.push(t),i.length>0&&a.push("--args",...i),await c("open",a),{launched:!0,via:"mac-app",target:n.path}}if(n.kind==="dev-electron"){let a=[n.engineDir||s];return t&&a.push(t),i.length>0&&a.push(...i),await c(n.path,a),{launched:!0,via:"dev-electron",target:n.path}}let o=[];return t&&o.push(t),i.length>0&&o.push(...i),await c(n.path,o),{launched:!0,via:n.kind,target:n.path}}export{A as a,S as b};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as h,b as S,d as k,f as T}from"./chunk-3C3ZH7PP.js";import{WebSocket as P}from"ws";S();var p=class extends Error{lock;constructor(n,t){super(n),this.name="BridgeTabLockedError",this.lock=t}};function A(e){return e==="flag"?"via --tab":e==="saved"?"saved via `sootsim use`":"primary fallback \u2014 no session pinned"}function E(e,n={}){let t=new Set,u=n.port??7668,c=n.commandTimeoutMs??15e3,a,g="none",f=new Set(n.stripBooleanFlags??[]),m=new Set(n.stripValueFlags??[]);for(let r=0;r<e.length;r++){let d=e[r];if(d==="--port"){t.add(r),r+1<e.length&&(t.add(r+1),u=Number(e[r+1])),r++;continue}if(d==="--timeout"){t.add(r),r+1<e.length&&(t.add(r+1),c=Number(e[r+1])),r++;continue}if(d==="--session"||d==="--id"||d==="--tab"){t.add(r),r+1<e.length&&(t.add(r+1),a=e[r+1],g="flag"),r++;continue}if(f.has(d)){t.add(r);continue}m.has(d)&&(t.add(r),r+1<e.length&&t.add(r+1),r++)}if(!a){let r=k();r&&(a=r,g="saved")}return{positional:e.filter((r,d)=>!t.has(d)),wsPort:u,browserId:a,browserIdSource:g,commandTimeoutMs:c}}function C(e,n={}){let t=1,u=n.commandTimeoutMs??15e3,c=new Map,a=new P(`ws://localhost:${e}`),g=n.browserId?{key:`browser:${n.browserId}`,source:"explicit-browser-id",stable:!0}:h(),f=new Promise((s,o)=>{a.on("open",()=>{try{a.send(JSON.stringify({type:"bridge:hello",id:0,cliSessionKey:g.key,cliSessionSource:g.source,cliLabel:n.cliLabel}))}catch{}s()}),a.on("error",i=>o(new Error(`could not connect to ws://localhost:${e}: ${i.message}`)))}),m=!1,r=!1;function d(s,o){if(r||process.env.SOOTSIM_QUIET_TARGET_NOTICE==="1"||s.startsWith("bridge:")||s==="focus"||s==="close")return;r=!0;let i=o??"primary",l=A(n.browserIdSource);process.stderr.write(` \u2192 ${i} (${l})
|
|
3
|
-
`)}return a.on("message",s=>{let o;try{o=JSON.parse(s.toString())}catch{return}if(o.id===0)return;let i=c.get(o.id);i&&(c.delete(o.id),o.i>0&&!m&&(m=!0,process.stderr.write(`
|
|
4
|
-
\u26A0 ${o.i} other CLI client(s) are also connected to this tab
|
|
5
|
-
commands from multiple agents may interfere with each other.
|
|
6
|
-
use sootsim open --new to get a dedicated session.
|
|
7
|
-
|
|
8
|
-
`)),o.error?o.s?i.reject(new p(o.error,o.s)):i.reject(new Error(o.error)):i.resolve(o.result))}),a.on("close",(s,o)=>{let i=o?.toString()||"connection closed";for(let[l,w]of c)c.delete(l),w.reject(new Error(`session disconnected: ${i} (code ${s})`))}),{async send(s){let o=async i=>{await f;let l=t++;return new Promise((w,I)=>{let B=setTimeout(()=>{c.delete(l),I(new Error(`command timed out after ${Math.round(u/1e3)}s`))},u);c.set(l,{resolve:y=>{clearTimeout(B),w(y)},reject:y=>{clearTimeout(B),I(y)}});let b={...s,id:l};b.browserId===void 0&&i&&(b.browserId=i),d(s.type??"",b.browserId),a.send(JSON.stringify(b))})};try{return await o(n.browserId)}catch(i){let l=i instanceof Error?i.message:String(i);if(n.fallbackOnMissingBrowserId&&n.browserId&&s.browserId===void 0&&l===`no browser connected with id ${n.browserId}`)return T(),process.stderr.write(` \u26A0 saved session ${n.browserId} is gone \u2014 falling back to primary
|
|
9
|
-
pin a tab with: sootsim use <tab-id>
|
|
10
|
-
`),r=!1,o(void 0);throw i}},async listBrowsers(){let s=await this.send({type:"bridge:list-browsers"});return Array.isArray(s)?s:[]},async openUrl(s){return this.send({type:"bridge:open",url:s})},async focusBrowser(s){return this.send({type:"focus",browserId:s})},async closeBrowser(s){return this.send({type:"close",browserId:s})},async claim(s,o={}){return await this.send({type:"bridge:claim",browserId:s,force:o.force===!0})},close(){try{a.readyState===P.OPEN&&a.send(JSON.stringify({type:"bridge:bye",id:0}))}catch{}a.close()}}}function L(e){return C(e.wsPort,{commandTimeoutMs:e.commandTimeoutMs,browserId:e.browserId,fallbackOnMissingBrowserId:e.browserIdSource==="saved",browserIdSource:e.browserIdSource})}async function W(e){try{return await e.send({type:"evaluate",code:"document.hidden"})===!0?(process.stderr.write(`
|
|
11
|
-
\u26A0 target tab is hidden (document.hidden = true)
|
|
12
|
-
animations and rAF callbacks are throttled \u2014 coordinates may be wrong
|
|
13
|
-
and launch/transition animations will not complete.
|
|
14
|
-
bring the tab to the foreground or use: sootsim debug eval "window.focus()"
|
|
15
|
-
|
|
16
|
-
`),{hidden:!0,warned:!0}):{hidden:!1,warned:!1}}catch{return{hidden:!1,warned:!1}}}async function $(e,n,t={}){let u={type:"evaluate",code:n};return t.acquireLock&&(u.acquireLock=!0),e.send(u)}async function F(e,n,...t){return e.send({type:"call",path:n,args:t})}async function N(e,n,...t){return e.send({type:"call",path:n,args:t,acquireLock:!0})}export{p as a,E as b,C as c,L as d,W as e,$ as f,F as g,N as h};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.1 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l}from"./chunk-HOIHCO7S.js";import"./chunk-KSB6MSZ4.js";import"./chunk-OROM7DZI.js";import"./chunk-MPSZ5EWF.js";import"./chunk-3C3ZH7PP.js";import"./chunk-E5UBZEYR.js";import"./chunk-X2U72K7X.js";import"./chunk-74XPLOV4.js";import"./chunk-MBFP2LVH.js";import"./chunk-E522F5JW.js";export{c as buildOpenUrl,b as buildShellUrl,e as printConnectedBrowsers,a as resolveBundleTarget,k as runClaimCommand,l as runCloseCommand,j as runFocusCommand,g as runListCommand,h as runOpenCommand,i as runUseCommand,d as summarizeBrowserUrl,f as waitForBrowserMatch};
|