sootsim 0.1.140 → 0.1.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cli/bin.js +3 -3
- package/dist-cli/chunks/{agent-N767ME6M.js → agent-BFN5TIRU.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-ELHIUFZZ.js → agent-wrapper-A4UNOJOD.js} +2 -2
- package/dist-cli/chunks/{app-fonts-OZ3OSNAJ.js → app-fonts-KEAMDLYZ.js} +2 -2
- package/dist-cli/chunks/{assert-GGFUQBNB.js → assert-BWBAKX5N.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-WJH44ZIE.js +2 -0
- package/dist-cli/chunks/beta-VFKZHKER.js +2 -0
- package/dist-cli/chunks/{camera-5PYEDLLB.js → camera-P5TTGC72.js} +2 -2
- package/dist-cli/chunks/{chunk-PBS47TD5.js → chunk-33EJL7CG.js} +2 -2
- package/dist-cli/chunks/{chunk-BLQBPN76.js → chunk-3LN2PP4L.js} +2 -2
- package/dist-cli/chunks/{chunk-MRQRJINW.js → chunk-4ISWLDJG.js} +1 -1
- package/dist-cli/chunks/{chunk-EMNVJOEL.js → chunk-53DRW635.js} +3 -3
- package/dist-cli/chunks/{chunk-7SMEXHWJ.js → chunk-7A7VFR2C.js} +1 -1
- package/dist-cli/chunks/{chunk-GL74P6NR.js → chunk-7SO2SJ4H.js} +1 -1
- package/dist-cli/chunks/{chunk-RAY2DLSK.js → chunk-A5W3HB44.js} +1 -1
- package/dist-cli/chunks/{chunk-SSZBFWV7.js → chunk-AJGTCVQX.js} +1 -1
- package/dist-cli/chunks/{chunk-R5F7XGAO.js → chunk-AMSIP5PD.js} +3 -3
- package/dist-cli/chunks/{chunk-ZGDJ5TFU.js → chunk-AQVB4G34.js} +2 -2
- package/dist-cli/chunks/{chunk-N2XPC4Z7.js → chunk-DM5KNA7Q.js} +2 -2
- package/dist-cli/chunks/{chunk-ZN4Z2W7F.js → chunk-EIZ6LJP2.js} +2 -2
- package/dist-cli/chunks/{chunk-5VTYMBUK.js → chunk-ETB6DHJM.js} +2 -2
- package/dist-cli/chunks/{chunk-WGDXZMKT.js → chunk-HDCTWR2Q.js} +2 -2
- package/dist-cli/chunks/chunk-I3JPJMJB.js +5 -0
- package/dist-cli/chunks/{chunk-QRRBQE6M.js → chunk-I6SWX7OI.js} +2 -2
- package/dist-cli/chunks/{chunk-BGXNYXBC.js → chunk-IILFDOSF.js} +1 -1
- package/dist-cli/chunks/{chunk-4FGNOWB6.js → chunk-IITPPGBS.js} +1 -1
- package/dist-cli/chunks/{chunk-QXOZB7WD.js → chunk-ITJLXD4X.js} +2 -2
- package/dist-cli/chunks/{chunk-BM7QWZRI.js → chunk-JJBNA2JO.js} +2 -2
- package/dist-cli/chunks/{chunk-AI65UVSN.js → chunk-JM5XCDBF.js} +2 -2
- package/dist-cli/chunks/{chunk-AOICEZCA.js → chunk-JQTHQOPS.js} +2 -2
- package/dist-cli/chunks/{chunk-X6AWKKL4.js → chunk-KMQWCYU7.js} +2 -2
- package/dist-cli/chunks/{chunk-XGYD25DJ.js → chunk-LHIPDN4B.js} +1 -1
- package/dist-cli/chunks/{chunk-6KUVOSFF.js → chunk-LHS4PEAA.js} +2 -2
- package/dist-cli/chunks/{chunk-ZVQOEMXS.js → chunk-M7S4VLEL.js} +54 -54
- package/dist-cli/chunks/{chunk-REIC7HRW.js → chunk-MENSR2TZ.js} +1 -1
- package/dist-cli/chunks/chunk-MHUNWWWS.js +412 -0
- package/dist-cli/chunks/chunk-MYKHUFW2.js +1 -0
- package/dist-cli/chunks/chunk-NOAONZTZ.js +119 -0
- package/dist-cli/chunks/{chunk-C3FURRBF.js → chunk-NQJD2WTM.js} +1 -1
- package/dist-cli/chunks/{chunk-QOZ2Q4FH.js → chunk-PVPWCA2K.js} +1 -1
- package/dist-cli/chunks/{chunk-GYZNLDBX.js → chunk-RBUJZXNR.js} +5 -5
- package/dist-cli/chunks/{chunk-AP2MOP44.js → chunk-RUXWU3UH.js} +1 -1
- package/dist-cli/chunks/{chunk-UHTE6FLK.js → chunk-SXHBK5IJ.js} +2 -2
- package/dist-cli/chunks/chunk-SYRS7NKN.js +1 -0
- package/dist-cli/chunks/chunk-TUZVZ5QS.js +1 -0
- package/dist-cli/chunks/{chunk-CQ3LV5VL.js → chunk-URPQTI2I.js} +2 -2
- package/dist-cli/chunks/{chunk-GI43DDEI.js → chunk-UYQDGXHQ.js} +1 -1
- package/dist-cli/chunks/{chunk-4FBFOWV3.js → chunk-WUQHVDJU.js} +2 -2
- package/dist-cli/chunks/{chunk-FYUDIUFX.js → chunk-XD7XHQUO.js} +2 -2
- package/dist-cli/chunks/{chunk-77TL74AM.js → chunk-XERRDQLM.js} +1 -1
- package/dist-cli/chunks/{chunk-O2SQNUDP.js → chunk-XQRCVSK3.js} +1 -1
- package/dist-cli/chunks/{chunk-HPTMLB7V.js → chunk-YOJ6BZCH.js} +1 -1
- package/dist-cli/chunks/chunk-ZBN3P5JE.js +2 -0
- package/dist-cli/chunks/cli-version-3G6HHMRW.js +2 -0
- package/dist-cli/chunks/{compat-U3772TUK.js → compat-3Z67EPSJ.js} +3 -3
- package/dist-cli/chunks/{config-6CZCIYKJ.js → config-SH3NTYZ2.js} +2 -2
- package/dist-cli/chunks/{control-NVA25O65.js → control-2XVEDKYZ.js} +2 -2
- package/dist-cli/chunks/{cpu-profile-WRLTZYO6.js → cpu-profile-FANLHU4S.js} +2 -2
- package/dist-cli/chunks/{daemon-QQPGLGS6.js → daemon-QGDVR4JT.js} +2 -2
- package/dist-cli/chunks/{debug-RKYLSDZV.js → debug-EIUEPLFN.js} +3 -3
- package/dist-cli/chunks/{detox-ZRUQQU22.js → detox-EV3KYFKR.js} +2 -2
- package/dist-cli/chunks/{device-HXTOLEWY.js → device-UC5DAVA6.js} +2 -2
- package/dist-cli/chunks/{diagnose-QN4E4WA6.js → diagnose-Q2M2AJBD.js} +2 -2
- package/dist-cli/chunks/drivers-VJIWLDTC.js +2 -0
- package/dist-cli/chunks/{electron-ZHRC4WQ5.js → electron-PXKF52Q6.js} +3 -3
- package/dist-cli/chunks/flow-RGMXGVLL.js +2 -0
- package/dist-cli/chunks/help-TBZZP4SA.js +2 -0
- package/dist-cli/chunks/{hints-HCHKMDUE.js → hints-HS7X2FIO.js} +2 -2
- package/dist-cli/chunks/{home-paths-3OHKRAE4.js → home-paths-KPMXMJQ7.js} +2 -2
- package/dist-cli/chunks/{inspect-QXUBDKJJ.js → inspect-ZUWEMCIG.js} +3 -3
- package/dist-cli/chunks/install-FPYDDDQ4.js +2 -0
- package/dist-cli/chunks/{install-desktop-QCX44BGL.js → install-desktop-H6ZTTVXC.js} +3 -3
- package/dist-cli/chunks/{keys-VEP2KPUF.js → keys-6OBZZLCJ.js} +2 -2
- package/dist-cli/chunks/{launch-K4BPQLTP.js → launch-7JASEDHP.js} +3 -3
- package/dist-cli/chunks/{login-UVC5XRKR.js → login-JWMB6JNS.js} +4 -4
- package/dist-cli/chunks/{logout-3VW34IBA.js → logout-LWVFUKF5.js} +2 -2
- package/dist-cli/chunks/maestro-WX22SLCR.js +94 -0
- package/dist-cli/chunks/optional-demo-registry-52MHQCYV.js +2 -0
- package/dist-cli/chunks/{preview-TZYJMLEJ.js → preview-SDMLCW3U.js} +2 -2
- package/dist-cli/chunks/{profile-HDJRF7YB.js → profile-MQVLCO7R.js} +2 -2
- package/dist-cli/chunks/{react-RLJR26M7.js → react-2JFP5W4W.js} +2 -2
- package/dist-cli/chunks/{record-2LDDHHUY.js → record-IJJ3SPXP.js} +2 -2
- package/dist-cli/chunks/runtime-JJMZ4AF3.js +2 -0
- package/dist-cli/chunks/{runtime-delivery-3F6O57E5.js → runtime-delivery-5M2P7LEI.js} +2 -2
- package/dist-cli/chunks/{screenshot-QAUSSEPK.js → screenshot-4QAGJCPZ.js} +2 -2
- package/dist-cli/chunks/{screenshot-mode-K6HEVK4K.js → screenshot-mode-PSAU7TH4.js} +2 -2
- package/dist-cli/chunks/{screenshots-TWMCGUBT.js → screenshots-73VI4UUL.js} +2 -2
- package/dist-cli/chunks/{server-ZPIZCBW5.js → server-BXD5WKQS.js} +3 -3
- package/dist-cli/chunks/setup-repo-F2P5RZ4R.js +2 -0
- package/dist-cli/chunks/{skills-NI3RH7CW.js → skills-IEJOURWM.js} +2 -2
- package/dist-cli/chunks/{start-G6CQL6HJ.js → start-CLBAJ4LJ.js} +4 -4
- package/dist-cli/chunks/store-7DIOVJNK.js +2 -0
- package/dist-cli/chunks/telemetry-3XHPQYOQ.js +2 -0
- package/dist-cli/chunks/{test-V47D6EPK.js → test-42YWJ5ZT.js} +3 -3
- package/dist-cli/chunks/{three-mode-G7N3LRHM.js → three-mode-5DU4IBF5.js} +2 -2
- package/dist-cli/chunks/{timeline-EBUOILTJ.js → timeline-WJYQRW5S.js} +2 -2
- package/dist-cli/chunks/{upgrade-OQJLTCQP.js → upgrade-F7ADMCLU.js} +2 -2
- package/dist-cli/chunks/upload-TJ2XKWDS.js +2 -0
- package/dist-cli/chunks/{version-3YJPPUE5.js → version-SLA5P34B.js} +2 -2
- package/dist-cli/chunks/{web-ZKUX5ICX.js → web-OGC6GSKM.js} +2 -2
- package/dist-cli/chunks/{what-happened-HOY3TA42.js → what-happened-VYXK3O2C.js} +2 -2
- package/dist-cli/chunks/{whoami-GOCSBVTG.js → whoami-QL2LTKOF.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +5 -2
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +2 -2
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +351 -80
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/src/config.ts +13 -0
- package/dist-cli/chunks/auto-bootstrap-L5E6XMCK.js +0 -2
- package/dist-cli/chunks/beta-D74SDA2L.js +0 -2
- package/dist-cli/chunks/chunk-5EP5RRNS.js +0 -381
- package/dist-cli/chunks/chunk-BEA3AO36.js +0 -5
- package/dist-cli/chunks/chunk-EH6YDCSN.js +0 -119
- package/dist-cli/chunks/chunk-NQG4R5K2.js +0 -1
- package/dist-cli/chunks/chunk-Q5Z7P54I.js +0 -2
- package/dist-cli/chunks/chunk-S7I6ZCT2.js +0 -1
- package/dist-cli/chunks/chunk-WN3WZEE5.js +0 -1
- package/dist-cli/chunks/cli-version-EZRTEUXF.js +0 -2
- package/dist-cli/chunks/drivers-EVK22AX5.js +0 -2
- package/dist-cli/chunks/flow-ICCRVJVX.js +0 -2
- package/dist-cli/chunks/help-QMZ35MIQ.js +0 -2
- package/dist-cli/chunks/install-JSDZIE2T.js +0 -2
- package/dist-cli/chunks/maestro-HTFXXMLR.js +0 -80
- package/dist-cli/chunks/optional-demo-registry-5YYEAL46.js +0 -2
- package/dist-cli/chunks/runtime-QPYF2WQX.js +0 -2
- package/dist-cli/chunks/setup-repo-VHOZJEIV.js +0 -2
- package/dist-cli/chunks/store-F6MJUJYW.js +0 -2
- package/dist-cli/chunks/telemetry-DM2Y7OQJ.js +0 -2
- package/dist-cli/chunks/upload-W3YCA65H.js +0 -2
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.140 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as Ae}from"./chunk-ZGDJ5TFU.js";import{a as _e}from"./chunk-CQ3LV5VL.js";import{a as Ee}from"./chunk-6KUVOSFF.js";import{a as V,b as ye,c as be,d as Z,e as ee,f as ve,g as te,i as ie,j as Se,k as xe}from"./chunk-ZVQOEMXS.js";import{g as ke,n as Me,p as Ie,t as Pe}from"./chunk-GYZNLDBX.js";import{e as Te}from"./chunk-BEA3AO36.js";import{m as ge}from"./chunk-WGDXZMKT.js";import{c as X,d as Q,e as he}from"./chunk-AOICEZCA.js";import{a as Fe}from"./chunk-AP2MOP44.js";import{a as $e}from"./chunk-SSZBFWV7.js";import{d as Y}from"./chunk-RAY2DLSK.js";import{a as pe,b as G}from"./chunk-QXOZB7WD.js";import{f as we}from"./chunk-C3FURRBF.js";import*as A from"fs";import{tmpdir as Re}from"os";import*as y from"path";import*as g from"fs";import*as w from"path";var L=1e4,B=393,D=852,De="__sootsimCliPerf",He="maestroCopiedText",Oe=new Map;function f(o){return new Promise(e=>setTimeout(e,o))}function qe(o){return o?w.basename(o)===".maestro"?w.dirname(o):o:process.cwd()}function ze(o,e,t){let i=e.endsWith(".png")?e:`${e}.png`;if(w.isAbsolute(i))return i;if(t.mode==="flow"&&/[\\/]/.test(i)){let r=i.startsWith("./")||i.startsWith("../")?t.flowDir??process.cwd():qe(t.flowDir);return w.resolve(r,i)}return w.join(o,i)}function Ge(o){if(typeof o=="string")return{path:o,withFrame:!1};let e=o.path?.trim()||o.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:o.withFrame===!0,layers:o.layers}}function re(o){let[e,t]=o.split(",").map(r=>r.trim()),i=(r,n)=>r.endsWith("%")?Number.parseFloat(r)/100*n:Number.parseFloat(r);return{x:i(e,B),y:i(t,D)}}function Ye(o){let e=o.split(/^---$/m),t=e.length>1?e[e.length-1]:o,i=be(ye.parse(t),Oe);return Array.isArray(i)?i:[]}var W=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingDurationMs=null;simRouteHint=null;lastFailedStep=null;get simId(){return this.opts.simId}setSimRouteHint(e){this.simRouteHint=this.normalizeSimRoute(e)}normalizeSimRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let i=t.searchParams.toString();return`${t.origin}${t.pathname}${i?`?${i}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(a=>a.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(a=>a.id===this.opts.simId&&a.readyState==="open")||!this.simRouteHint)return;let r=this.simRouteHint&&e.find(a=>a.readyState==="open"&&this.normalizeSimRoute(a.url||a.origin)===this.simRouteHint);if(!r)return;let n=e.find(a=>a.isPrimary&&a.readyState==="open"),s=e.find(a=>a.readyState==="open"),l=r??n??s;l&&(this.opts.simId=l.id,console.log(` [flow] sim rotated to ${l.id}`))}catch{}}async evaluate(e,t){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e},t?{timeoutMs:t}:void 0)}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async waitForTree(e=L){let t=Date.now()+e,i=Date.now(),r=null,n=0,s=0;for(;Date.now()<t;){try{let a=await this.evaluate(`(async () => {
|
|
3
|
-
const test = window.__sootsimTest
|
|
4
|
-
if (!test) return { count: 0, loading: true }
|
|
5
|
-
const count = (await test.getNodeCount?.()) || 0
|
|
6
|
-
const external = globalThis.__sootsimExternalAppState
|
|
7
|
-
if (external?.error) {
|
|
8
|
-
return { count, loading: false, error: String(external.error) }
|
|
9
|
-
}
|
|
10
|
-
if (external) {
|
|
11
|
-
return {
|
|
12
|
-
count,
|
|
13
|
-
loading: !external.ready,
|
|
14
|
-
error: null,
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const loadingNode = await test.findByText?.('loading')
|
|
18
|
-
const capturingNode = await test.findByText?.('capturing')
|
|
19
|
-
const openingAppNode = await test.findByText?.('opening app')
|
|
20
|
-
const isLoading = !!loadingNode || !!capturingNode || !!openingAppNode || count < 5
|
|
21
|
-
return { count, loading: isLoading, error: null }
|
|
22
|
-
})()`,8e3);if(n=0,a?.error)throw new Error(`app failed to load: ${a.error}`);if(a&&a.count>10&&!a.loading)return}catch(a){if(r=a instanceof Error?a:new Error(String(a)),r.message.startsWith("app failed to load:"))throw r;if(n++,n>=4)throw new Error(`target sim is not responding to the bridge (${r.message}). it is likely a stale orphan \u2014 run \`sootsim list\`, then close it with \`sootsim close <id>\` or start a fresh one with \`sootsim open --new <port>\`.`);await this.refreshSimId()}let l=Date.now()-i;l-s>=5e3&&(s=l,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(l/1e3)}s)`)),await f(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");this.recordingAccessChecked||(await _e("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
|
|
23
|
-
const rec = window.__sootsimRecorder
|
|
24
|
-
if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
|
|
25
|
-
const format = ${JSON.stringify(this.opts.recordingFormat??"webm")}
|
|
26
|
-
if (rec.state() === 'recording') return { ok: true, format }
|
|
27
|
-
return rec.start({ format, fps: 24 })
|
|
28
|
-
})()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}async stopRecording(){if(!this.recordingEnabled||!this.opts.recordingOutputDir)return null;this.recordingEnabled=!1;let e=Date.now(),t=await this.evaluate("window.__sootsimRecorder.stop()");if(!t?.ok)throw this.recordingStartedAtMs=null,new Error(t?.error||"recording stop failed");this.lastRecordingDurationMs=this.recordingStartedAtMs?Math.max(1,e-this.recordingStartedAtMs):null,this.recordingStartedAtMs=null;let i=[],r=0;for(;;){let a=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${r}, chunk: 2097152 })`);if(!a||(i.push(Buffer.from(a.data,"base64")),r=a.offset,a.done))break}if(i.length===0)throw new Error("recording requested but no video buffer was produced");g.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let s=(t.mime||this.opts.recordingFormat||"video/webm").includes("mp4")?"mp4":"webm",l=w.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.${s}`);return g.writeFileSync(l,Buffer.concat(i)),l}async waitForRecordingTail(e){if(!this.recordingEnabled)return;let t=Math.max(0,Math.round(e.maxMs));if(t<=0)return;if(!e.smart){await f(t);return}let i=await xe({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:80,stablePolls:6,strict:!0});await this.waitForVisualSettle(),console.log(i.settled?` [flow] recording tail settled in ${i.elapsed}ms`:` [flow] recording tail reached ${i.elapsed}ms budget`)}async findElement(e){return this.evaluate(`(async () => {
|
|
29
|
-
const test = window.__sootsimTest
|
|
30
|
-
if (!test) return null
|
|
31
|
-
let node = null
|
|
32
|
-
if (${JSON.stringify(!!e.text)}) node = await test.findByText(${JSON.stringify(e.text||"")})
|
|
33
|
-
if (!node && ${JSON.stringify(!!e.id)}) {
|
|
34
|
-
node = (await test.findByTestId(${JSON.stringify(e.id||"")})) || (await test.findById(${JSON.stringify(e.id||"")}))
|
|
35
|
-
}
|
|
36
|
-
if (!node || !node.absolutePosition || !node.layout) return null
|
|
37
|
-
return {
|
|
38
|
-
nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
|
|
39
|
-
id: node.id || null,
|
|
40
|
-
testID: node.testID || null,
|
|
41
|
-
text: node.text || null,
|
|
42
|
-
absolutePosition: node.absolutePosition,
|
|
43
|
-
layout: node.layout,
|
|
44
|
-
isTextInput: !!node.isTextInput,
|
|
45
|
-
}
|
|
46
|
-
})()`)}async resolveTapTarget(e){return this.evaluate(`(async () => {
|
|
47
|
-
const test = window.__sootsimTest
|
|
48
|
-
if (!test?.resolveTapTarget) return null
|
|
49
|
-
return await test.resolveTapTarget(${e})
|
|
50
|
-
})()`)}async activatePressTarget(e){let t=e.id?{id:e.id,testID:e.id,text:null}:{id:null,testID:null,text:e.text??null};return this.evaluate(`(async () => {
|
|
51
|
-
const test = window.__sootsimTest
|
|
52
|
-
if (!test) return null
|
|
53
|
-
const node = ${e.id?`(await test.findByTestId?.(${JSON.stringify(e.id)})) || (await test.findById?.(${JSON.stringify(e.id)}))`:`await test.findByText?.(${JSON.stringify(e.text||"")})`}
|
|
54
|
-
let point = null
|
|
55
|
-
if (node?.absolutePosition && node?.layout) {
|
|
56
|
-
point = {
|
|
57
|
-
x: node.absolutePosition.x + node.layout.width / 2,
|
|
58
|
-
y: node.absolutePosition.y + node.layout.height / 2,
|
|
59
|
-
}
|
|
60
|
-
if (typeof node.nodeId === 'number' && test.resolveTapTarget) {
|
|
61
|
-
const resolved = await test.resolveTapTarget(node.nodeId)
|
|
62
|
-
if (
|
|
63
|
-
resolved &&
|
|
64
|
-
Number.isFinite(resolved.cx) &&
|
|
65
|
-
Number.isFinite(resolved.cy)
|
|
66
|
-
) {
|
|
67
|
-
point = { x: resolved.cx, y: resolved.cy }
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
${e.id?`const direct = await test.activatePressById?.(${JSON.stringify(e.id)})`:`const direct = await test.activatePressByText?.(${JSON.stringify(e.text||"")})`}
|
|
72
|
-
if (direct?.ok && point) {
|
|
73
|
-
window.dispatchEvent(
|
|
74
|
-
new CustomEvent('sootsim:agentAction', {
|
|
75
|
-
detail: { type: 'tap', x: point.x, y: point.y, target: ${JSON.stringify(t)} },
|
|
76
|
-
}),
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
return direct || null
|
|
80
|
-
})()`)}async activatePressAt(e,t){return this.evaluate(`(async () => {
|
|
81
|
-
const test = window.__sootsimTest
|
|
82
|
-
if (!test?.activatePressAt) return null
|
|
83
|
-
const direct = await test.activatePressAt(${e}, ${t})
|
|
84
|
-
if (direct?.ok) {
|
|
85
|
-
window.dispatchEvent(
|
|
86
|
-
new CustomEvent('sootsim:agentAction', {
|
|
87
|
-
detail: { type: 'tap', x: ${e}, y: ${t} },
|
|
88
|
-
}),
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
return direct
|
|
92
|
-
})()`)}async tap(e,t,i){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t,target:i})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let a=re(t.point);(await this.activatePressAt(a.x,a.y))?.ok||await this.tap(a.x,a.y),await f(300);return}let i=5e3,r=150,n=Date.now()+i,s=await this.findElement({text:t.text,id:t.id});for(;!s&&Date.now()<n;)await f(r),s=await this.findElement({text:t.text,id:t.id});if(s){let a=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,m=a?.cx??s.absolutePosition.x+s.layout.width/2,p=a?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(m,p,{id:t.id??a?.target?.id??s.id??null,testID:t.id??a?.target?.testID??s.testID??null,text:t.text??a?.target?.text??a?.target?.accessibilityLabel??s.text??s.accessibilityLabel??null,type:a?.target?.type??s.type??null}))?.hit===!0){await f(300);return}}if((await this.activatePressTarget(t))?.ok){await f(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async tapAtCoords(e,t){await this.tap(e,t),await f(300)}async doubleTapAtCoords(e,t,i=80){let r=Math.max(0,Math.round(i));if(!await this.evaluate(`(async () => {
|
|
93
|
-
const interact = window.__sootsimInteract
|
|
94
|
-
if (interact?.doubleTap) {
|
|
95
|
-
return !!(await interact.doubleTap(${e}, ${t}, ${r}))
|
|
96
|
-
}
|
|
97
|
-
if (!interact?.tap) return false
|
|
98
|
-
const first = await interact.tap(${e}, ${t})
|
|
99
|
-
if (!first || first.hit === false) return false
|
|
100
|
-
await new Promise((resolve) => setTimeout(resolve, ${r}))
|
|
101
|
-
const second = await interact.tap(${e}, ${t})
|
|
102
|
-
return !!second && second.hit !== false
|
|
103
|
-
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let n=0;n<15;n++){if(await this.isElementVisible(t))return;await f(200)}let i=await this.findElement(t),r=i?` (matched node at y=${Math.round(i.absolutePosition.y)} h=${Math.round(i.layout.height)} \u2014 off-screen)`:" (no matching node in tree)";throw new Error(`assertVisible: ${JSON.stringify(t)} not visible${r}`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t)){let i=await this.findElement(t),r=i?` at (${Math.round(i.absolutePosition.x)},${Math.round(i.absolutePosition.y)})`:"";throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible${r}`)}}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<D)}async inputText(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await f(200)}async pressKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"press",text:e}),await f(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:e}),await f(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let t=await this.evaluate(`(() => {
|
|
104
|
-
const keyboard =
|
|
105
|
-
window.__sootsimKeyboard ??
|
|
106
|
-
window.SootSim?.bridges?.keyboard ??
|
|
107
|
-
null
|
|
108
|
-
const test = window.__sootsimTest
|
|
109
|
-
return {
|
|
110
|
-
visible: !!keyboard?.isVisible?.(),
|
|
111
|
-
focused: !!test?.isTextInputFocused?.(),
|
|
112
|
-
}
|
|
113
|
-
})()`);if(!t?.visible&&!t?.focused){await f(80);return}await f(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.pressKey("Backspace");await f(100)}async waitFor(e){let t=Date.now()+(e.timeout||L);for(;Date.now()<t;){if(await this.findElement(e))return;await f(200)}let i=await this.findElement(e),r=i?` (matched node y=${Math.round(i.absolutePosition.y)} \u2014 still off-screen at deadline)`:"";throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||L}ms${r}`)}async takeScreenshot(e){try{await this.waitForVisualSettle()}catch{}await f(250);let t=Ge(e),i=ze(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});g.mkdirSync(w.dirname(i),{recursive:!0});let r=t.layers??this.opts.screenshotLayers,n={type:"screenshot",simId:this.opts.simId};r&&r!=="full"&&(n.layers=r);let l=(await this.bridge.send(n)).replace(/^data:image\/png;base64,/,""),a=Buffer.from(l,"base64");if(t.withFrame){let m=await this.readCurrentDeviceModel();if(!m)throw new Error("could not read current device model for framed screenshot");let p=await Ae(a,m);g.writeFileSync(i,p),console.log(`[flow] screenshot: ${i} (frame: ${m})`);return}g.writeFileSync(i,a),console.log(`[flow] screenshot: ${i}`)}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",simId:this.opts.simId,path:"SootSim.bridges.settings.get",args:[]}),t=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!t||!(t in we)?null:t}async captureFailureScreenshot(e){g.mkdirSync(w.dirname(e),{recursive:!0});let i=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");g.writeFileSync(e,Buffer.from(i,"base64"))}async captureFailureBundle(e,t){g.mkdirSync(e,{recursive:!0});let i=(p,x)=>{try{g.writeFileSync(w.join(e,p),x)}catch{}},r=async p=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:p})}catch{return null}},n=await r(`(async () => {
|
|
114
|
-
const out = {
|
|
115
|
-
simId: window.__sootsimBridge?.id ?? window.SootSim?.state?.simId ?? null,
|
|
116
|
-
url: location.href,
|
|
117
|
-
title: document.title,
|
|
118
|
-
hidden: document.hidden,
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
const params = new URL(location.href).searchParams
|
|
122
|
-
const bundle = params.get('bundle')
|
|
123
|
-
if (bundle) {
|
|
124
|
-
const baseMatch = bundle.match(/^https?:\\/\\/[^/]+/)
|
|
125
|
-
if (baseMatch) {
|
|
126
|
-
const res = await fetch(baseMatch[0] + '/', {
|
|
127
|
-
headers: { 'expo-platform': 'ios' },
|
|
128
|
-
cache: 'no-store',
|
|
129
|
-
})
|
|
130
|
-
if (res.ok) {
|
|
131
|
-
out.manifest = await res.json().catch(() => null)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
} catch {}
|
|
136
|
-
return out
|
|
137
|
-
})()`);i("error.json",JSON.stringify({message:t.error.message,stack:t.error.stack,stepIndex:t.stepIndex,stepKind:t.stepKind,stepTarget:t.stepTarget,capturedAt:new Date().toISOString(),sim:n??null},null,2));try{let x=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");i("screenshot.png",Buffer.from(x,"base64"))}catch{}let s=await r(`(async () => {
|
|
138
|
-
const t = window.__sootsimTest
|
|
139
|
-
const mainShell = window.SootSim?.bridges?.mainShell
|
|
140
|
-
if (!t) return { error: 'no test bridge' }
|
|
141
|
-
let shell = null
|
|
142
|
-
try {
|
|
143
|
-
shell = typeof mainShell?.getState === 'function' ? await mainShell.getState() : null
|
|
144
|
-
} catch {}
|
|
145
|
-
const all = await t.queryAll({ pruneHidden: true })
|
|
146
|
-
return { shell, nodes: all, url: location.href, title: document.title }
|
|
147
|
-
})()`);s&&i("describe.json",JSON.stringify(s,null,2));let l=await r("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof l=="string"&&i("a11y.txt",l);let a=await r("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof a=="string"&&i("tree.txt",a);let m=await r(`(() => {
|
|
148
|
-
const c = window.__sootsimConsole
|
|
149
|
-
return {
|
|
150
|
-
errors: c?.getErrors?.() ?? [],
|
|
151
|
-
warnings: c?.getWarnings?.() ?? [],
|
|
152
|
-
requests: (window.__sootsimGetFailedRequests?.() ?? []),
|
|
153
|
-
}
|
|
154
|
-
})()`);return m&&i("console.json",JSON.stringify(m,null,2)),e}async swipe(e="UP",t=300){let i=B/2,r=D/2,n=200,s=i,l=r,a=i,m=r;switch(e.toUpperCase()){case"UP":l+=n,m-=n;break;case"DOWN":l-=n,m+=n;break;case"LEFT":s+=n,a-=n;break;case"RIGHT":s-=n,a+=n;break}let p=Math.max(10,Math.round(t/16));await this.drag(s,l,a,m,p,16)}async drag(e,t,i,r,n=12,s=16){if(!(await this.evaluate(`(async () => {
|
|
155
|
-
const interact = window.__sootsimInteract
|
|
156
|
-
if (!interact?.drag) return { ok: false }
|
|
157
|
-
const value = await interact.drag(${e}, ${t}, ${i}, ${r}, ${Math.max(1,Math.round(n))}, ${Math.max(0,Math.round(s))})
|
|
158
|
-
return { ok: !!value, value }
|
|
159
|
-
})()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,i=300){let r=re(e),n=re(t),s=Math.max(10,Math.round(i/16));await this.drag(r.x,r.y,n.x,n.y,s,16)}async swipeFrom(e,t="UP",i=300){let r=await this.findElement(e);if(!r)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let n=r.absolutePosition.x+r.layout.width/2,s=r.absolutePosition.y+r.layout.height/2,l=180,a=n,m=s;switch(t.toUpperCase()){case"UP":m-=l;break;case"DOWN":m+=l;break;case"LEFT":a-=l;break;case"RIGHT":a+=l;break}let p=Math.max(10,Math.round(i/16));await this.drag(n,s,a,m,p,16)}async scrollTo(e,t,i){let r=await this.callTest("scrollTo",e,t,i,!1);if(!r?.ok)throw new Error(`scrollTo failed: ${r?.reason||"unknown error"}`);await f(250)}async pinch(e){let t=await this.evaluate(`(async () => {
|
|
160
|
-
const interact = window.__sootsimInteract
|
|
161
|
-
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
162
|
-
const ok = await interact.pinch(
|
|
163
|
-
${e.from[0]}, ${e.from[1]}, ${e.from[2]}, ${e.from[3]},
|
|
164
|
-
${e.to[0]}, ${e.to[1]}, ${e.to[2]}, ${e.to[3]},
|
|
165
|
-
${e.steps||12}, ${e.stepMs||16}
|
|
166
|
-
)
|
|
167
|
-
return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
|
|
168
|
-
})()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"unknown error"}`);await f(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){await f(e)}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),i=e.direction?.toUpperCase()||"DOWN",r=i==="DOWN"?"UP":i==="UP"?"DOWN":i;for(;Date.now()<t;){let n=await this.findElement({text:e.element});if(n&&n.absolutePosition.y>=0&&n.absolutePosition.y+n.layout.height>0&&n.absolutePosition.y<D-50){if(e.centerElement){let s=D/2,l=n.absolutePosition.y-s;if(Math.abs(l)>100){let a=Math.min(150,Math.abs(l)*.5),m=l>0?s-a:s+a;await this.drag(B/2,s,B/2,m,10,16)}}return}await this.swipe(r,250),await f(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+(e.timeout||L);for(;Date.now()<t;){let i=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,r=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(i&&r)return;await f(200)}throw new Error("extendedWaitUntil timed out")}async launchApp(e){await this.refreshSimId();let t=!!(e&&typeof e=="object"&&e.clearState);if(t&&await this.evaluate(`(async () => {
|
|
169
|
-
await (${V})
|
|
170
|
-
try {
|
|
171
|
-
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
172
|
-
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
173
|
-
} catch {}
|
|
174
|
-
})()`),!this.firstLaunchDone&&!t)this.firstLaunchDone=!0,await this.waitForTree(3e4);else if(this.firstLaunchDone=!0,await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId(),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(i){console.warn(` warn: onAfterLaunch hook threw: ${i instanceof Error?i.message:i}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
|
|
175
|
-
requestAnimationFrame(() => {
|
|
176
|
-
requestAnimationFrame(() => {
|
|
177
|
-
requestAnimationFrame(() => {
|
|
178
|
-
setTimeout(resolve, 180)
|
|
179
|
-
})
|
|
180
|
-
})
|
|
181
|
-
})
|
|
182
|
-
})`)}catch{await f(180)}}async startProfile(){await this.evaluate(`((sessionKey) => {
|
|
183
|
-
const perf = window.__sootsimPerf
|
|
184
|
-
const a11y = window.__sootsimA11y
|
|
185
|
-
perf?.enableFrameStats?.(true)
|
|
186
|
-
perf?.resetFrameStats?.()
|
|
187
|
-
a11y?.resetProfile?.()
|
|
188
|
-
window[sessionKey] = {
|
|
189
|
-
active: true,
|
|
190
|
-
mode: window.__sootsimRenderHost ? 'render-worker' : 'main-thread',
|
|
191
|
-
lastSamples: [],
|
|
192
|
-
startedAt: performance.now(),
|
|
193
|
-
}
|
|
194
|
-
})(${JSON.stringify(De)})`),this.profilingEnabled=!0}async stopProfile(){let e=await this.evaluate(`(async (sessionKey) => {
|
|
195
|
-
const host = window.__sootsimRenderHost
|
|
196
|
-
if (host?.flushSamples) {
|
|
197
|
-
const perf = window.__sootsimPerf
|
|
198
|
-
const session = window[sessionKey] || {}
|
|
199
|
-
const priorSamples = session.active && Array.isArray(session.lastSamples)
|
|
200
|
-
? session.lastSamples
|
|
201
|
-
: []
|
|
202
|
-
const flushedSamples = await host.flushSamples()
|
|
203
|
-
await perf?.disableFrameStats?.()
|
|
204
|
-
const samples = priorSamples.concat(flushedSamples)
|
|
205
|
-
window[sessionKey] = {
|
|
206
|
-
...session,
|
|
207
|
-
active: false,
|
|
208
|
-
mode: 'render-worker',
|
|
209
|
-
lastSamples: samples,
|
|
210
|
-
stoppedAt: performance.now(),
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const frameTimes = samples.map((sample) => Number(sample?.[1]) || 0)
|
|
214
|
-
const sorted = [...frameTimes].sort((a, b) => a - b)
|
|
215
|
-
const worstFrames = samples
|
|
216
|
-
.slice()
|
|
217
|
-
.sort((a, b) => (Number(b?.[1]) || 0) - (Number(a?.[1]) || 0))
|
|
218
|
-
.slice(0, 10)
|
|
219
|
-
.map((sample) => [
|
|
220
|
-
Number(sample?.[0]) || 0,
|
|
221
|
-
Number(sample?.[1]) || 0,
|
|
222
|
-
Number(sample?.[2]) || 0,
|
|
223
|
-
Number(sample?.[3]) || 0,
|
|
224
|
-
Number(sample?.[4]) || 0,
|
|
225
|
-
])
|
|
226
|
-
|
|
227
|
-
return {
|
|
228
|
-
mode: 'render-worker',
|
|
229
|
-
frames: frameTimes.length,
|
|
230
|
-
totalMs: frameTimes.reduce((sum, value) => sum + value, 0),
|
|
231
|
-
avgMs: frameTimes.length ? frameTimes.reduce((sum, value) => sum + value, 0) / frameTimes.length : 0,
|
|
232
|
-
maxMs: sorted[sorted.length - 1] || 0,
|
|
233
|
-
layoutTotalMs: samples.reduce((sum, sample) => sum + (Number(sample?.[2]) || 0), 0),
|
|
234
|
-
renderTotalMs: samples.reduce((sum, sample) => sum + (Number(sample?.[3]) || 0), 0),
|
|
235
|
-
copyTotalMs: samples.reduce((sum, sample) => sum + (Number(sample?.[4]) || 0), 0),
|
|
236
|
-
layoutAvgMs: frameTimes.length ? samples.reduce((sum, sample) => sum + (Number(sample?.[2]) || 0), 0) / frameTimes.length : 0,
|
|
237
|
-
renderAvgMs: frameTimes.length ? samples.reduce((sum, sample) => sum + (Number(sample?.[3]) || 0), 0) / frameTimes.length : 0,
|
|
238
|
-
copyAvgMs: frameTimes.length ? samples.reduce((sum, sample) => sum + (Number(sample?.[4]) || 0), 0) / frameTimes.length : 0,
|
|
239
|
-
p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
|
|
240
|
-
p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
|
|
241
|
-
p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
|
|
242
|
-
jankFrames: frameTimes.filter((value) => value > 16.67).length,
|
|
243
|
-
sampleCount: frameTimes.length,
|
|
244
|
-
worstFrames,
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const perf = window.__sootsimPerf
|
|
249
|
-
const a11y = window.__sootsimA11y
|
|
250
|
-
if (!perf && !a11y) return { error: 'no perf globals available' }
|
|
251
|
-
|
|
252
|
-
const stoppedStats = await perf?.disableFrameStats?.()
|
|
253
|
-
const frameStats = stoppedStats || await perf?.getFrameStats?.() || {}
|
|
254
|
-
const profile = a11y?.profile?.() || {}
|
|
255
|
-
const recent = Array.isArray(frameStats.recentFrames) ? frameStats.recentFrames : []
|
|
256
|
-
const sorted = [...recent].sort((a, b) => a - b)
|
|
257
|
-
|
|
258
|
-
return {
|
|
259
|
-
mode: 'main-thread',
|
|
260
|
-
frames: frameStats.frames || profile.syncCount || 0,
|
|
261
|
-
totalMs: frameStats.totalMs || 0,
|
|
262
|
-
avgMs: frameStats.totalMs && frameStats.frames ? frameStats.totalMs / frameStats.frames : profile.avgSyncMs || 0,
|
|
263
|
-
maxMs: frameStats.maxMs || profile.maxSyncMs || 0,
|
|
264
|
-
layoutTotalMs: frameStats.layoutTotalMs || 0,
|
|
265
|
-
p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
|
|
266
|
-
p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
|
|
267
|
-
p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
|
|
268
|
-
jankFrames: recent.filter((value) => value > 16.67).length,
|
|
269
|
-
sampleCount: recent.length,
|
|
270
|
-
worstFrames: recent.slice().sort((a, b) => b - a).slice(0, 10),
|
|
271
|
-
}
|
|
272
|
-
})(${JSON.stringify(De)})`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.evaluate(`(async () => {
|
|
273
|
-
try { await (${V}) } catch {}
|
|
274
|
-
try {
|
|
275
|
-
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
276
|
-
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
277
|
-
} catch {}
|
|
278
|
-
})()`)}async clearState(){await this.evaluate(`(async () => {
|
|
279
|
-
await (${V})
|
|
280
|
-
})()`)}clearKeychain(){console.warn("[flow] clearKeychain: sootsim has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,i=await this.findElement(t);if(!i)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let r=i.text??i.testID??"";Oe.set(He,r),console.log(`[flow] copied text: ${JSON.stringify(r)}`)}async evalScript(e){let i=await this.evaluate(`(async () => {
|
|
281
|
-
try {
|
|
282
|
-
return { ok: true, value: await (async () => { ${e} })() }
|
|
283
|
-
} catch (err) {
|
|
284
|
-
return { ok: false, error: err && err.message ? err.message : String(err) }
|
|
285
|
-
}
|
|
286
|
-
})()`);if(!i.ok)throw new Error(`evalScript failed: ${i.error}`);i.value!==void 0&&console.log("[flow] evalScript ->",i.value)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(t)}`),await f(300),await this.refreshSimId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}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 i=Object.entries(e).find(([n])=>n!=="when"&&n!=="optional"),r=i?i[1]:void 0;return!!(r&&typeof r=="object"&&"optional"in r&&r.optional)}async runStep(e,t){let i=Object.keys(e).find(r=>r!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${t+1}: ${i}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let r=!!(e.extendedWaitUntil||e.waitFor||e.scrollUntilVisible||e.launchApp||e.runFlow),n=1e4,s=this.runStepInner(e);if(r)await s;else{let a=null,m=new Promise((p,x)=>{a=setTimeout(()=>{x(new Error(`step watchdog: ${i} made no progress in ${n}ms \u2014 bridge or bundle probably hung`))},n)});try{await Promise.race([s,m])}finally{a&&clearTimeout(a)}}let l=!!(e.assertVisible||e.assertNotVisible||e.extendedWaitUntil||e.waitFor);this.stepDelay>0&&!l&&await f(this.stepDelay)}catch(r){if(this.isOptional(e)){console.log(`[flow] (optional, skipped: ${r.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:i,target:e[i]},r}}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){let t=typeof e.scrollTo.nodeId=="number"?{nodeId:e.scrollTo.nodeId}:e.scrollTo.id;if(!t)throw new Error("scrollTo requires id or nodeId");await this.scrollTo(t,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 f(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 t=0;t<e.repeat.times;t++)for(let i=0;i<e.repeat.commands.length;i++)await this.runStep(e.repeat.commands[i],i);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 t=e.runFlow,i=typeof t=="string"?t:t.file,r=typeof t=="string"?void 0:t.when;if(r&&!await this.evaluateWhen(r)){console.log(`[flow] runFlow skipped (when predicate false): ${i}`);return}let n=w.resolve(this.opts.flowDir,i),s=g.readFileSync(n,"utf8"),l=this.opts.flowDir;this.opts.flowDir=w.dirname(n),await this.runFlow(Ye(s)),this.opts.flowDir=l}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let t=[],i=[],r=[];for(let s of e){let l=Object.keys(s);if(l.length===1&&l[0]==="onFlowStart"&&Array.isArray(s.onFlowStart)){t.push(...s.onFlowStart);continue}if(l.length===1&&l[0]==="onFlowComplete"&&Array.isArray(s.onFlowComplete)){i.push(...s.onFlowComplete);continue}r.push(s)}if(t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let s=0;s<t.length;s++)await this.runStep(t[s],s)}let n=null;try{await this.runFlowBody(r)}catch(s){n=s instanceof Error?s:new Error(String(s))}if(i.length>0){console.log(`[flow] onFlowComplete (${i.length} steps)`);for(let s=0;s<i.length;s++)try{await this.runStep(i[s],s)}catch(l){console.warn(`[flow] onFlowComplete step ${s+1} failed: ${l instanceof Error?l.message:l}`)}}if(n)throw n}async runFlowBody(e){for(let t=0;t<e.length;t++){let i=e[t],r=typeof i.wait=="number"?i.wait:0,n=typeof i.waitFor?.timeout=="number"?i.waitFor.timeout:0,s=Math.max(6e4,r+15e3,n+15e3);if(i.runFlow){await this.runStep(i,t);continue}await Promise.race([this.runStep(i,t),new Promise((l,a)=>setTimeout(()=>a(new Error(`step ${t+1} (${Object.keys(i)[0]}) exceeded ${s}ms deadline`)),s))])}}};async function Xe(o){if(!o)return"";let e=o.trim();if(!e)return"";if(/^\d+$/.test(e)||e.startsWith("http://")||e.startsWith("https://"))return e;let i=(await Fe()).find(r=>r.name.toLowerCase()===e.toLowerCase());return i?String(i.preferredPort):e}async function Qe(){let o=await Te(),e=o.find(i=>i.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=o[0];return t?`http://localhost:${t.port}/__soot/`:null}async function Ne(o){(o.length===0||o.includes("--help")||o.includes("-h"))&&(console.log(`
|
|
287
|
-
sootsim flow \u2014 run flows or manage a draft
|
|
288
|
-
|
|
289
|
-
usage:
|
|
290
|
-
sootsim flow <flow.yaml> [options]
|
|
291
|
-
sootsim flow start
|
|
292
|
-
sootsim flow keep
|
|
293
|
-
sootsim flow end [--output <path>] [--validate] [--video]
|
|
294
|
-
sootsim flow validate <path>
|
|
295
|
-
|
|
296
|
-
options:
|
|
297
|
-
--record record a webm artifact while the flow runs
|
|
298
|
-
--profile capture perf stats while the flow runs
|
|
299
|
-
--out <dir> output directory (default: /tmp/sootsim-recordings)
|
|
300
|
-
--device <model> override the flow frontmatter device for this run
|
|
301
|
-
--slow <ms> delay between steps for natural pacing
|
|
302
|
-
--tail-wait <ms> hold the recording open after the last step so the
|
|
303
|
-
final UI state is captured (default: smart idle up to
|
|
304
|
-
6000ms for --preview, fixed 2000ms for --record, 0 otherwise)
|
|
305
|
-
--url <url> load this target before running the flow
|
|
306
|
-
--screenshot-paths <mode>
|
|
307
|
-
screenshot path mode: dir (default) or flow
|
|
308
|
-
--no-shell capture every screenshot tenant-only (no status bar,
|
|
309
|
-
keyboard, notification center, or other shell overlays).
|
|
310
|
-
use for clean demo asset sets. per-step \`layers:\`
|
|
311
|
-
still wins over this default.
|
|
312
|
-
--shell-only inverse \u2014 capture shell chrome only
|
|
313
|
-
--replace <m>=<f> replace a Metro module with a local file for this run
|
|
314
|
-
--new open a fresh sim before running the flow
|
|
315
|
-
--driver <id> when paired with --new, launch through a specific
|
|
316
|
-
driver from the registry (e.g. playwright for
|
|
317
|
-
hermetic CI runs); see 'sootsim list --drivers'
|
|
318
|
-
--headless pass headless=true to the launch driver (useful
|
|
319
|
-
with --driver playwright)
|
|
320
|
-
--electron prefer opening the target in the desktop companion
|
|
321
|
-
--sim <id> target a specific current sim
|
|
322
|
-
--validate replay the drafted flow before clearing it
|
|
323
|
-
--video replay and record the drafted flow before clearing it
|
|
324
|
-
--preview record events+video, upload, and print /preview/<id>
|
|
325
|
-
--preview-open open the uploaded preview link after a successful run
|
|
326
|
-
--preview-origin <url>
|
|
327
|
-
upload target for --preview (default: auto)
|
|
328
|
-
--preview-public-origin <url>
|
|
329
|
-
public link origin for --preview (default: sootsim.com
|
|
330
|
-
for prod uploads)
|
|
331
|
-
--owner <org> associate preview upload with a linked org repo
|
|
332
|
-
--repo <repo> repo name for --owner; user must belong to the team
|
|
333
|
-
|
|
334
|
-
frontmatter (top of flow.yaml between --- markers):
|
|
335
|
-
app: 8081 load this target before the flow starts
|
|
336
|
-
device: iphone-14 set the live device model for this flow run
|
|
337
|
-
electron: true prefer the desktop companion sim for this flow
|
|
338
|
-
|
|
339
|
-
default runtime:
|
|
340
|
-
bridge-backed flow playback against the current sim
|
|
341
|
-
if no current sim exists, flow opens the discovered target first
|
|
342
|
-
recording and profiling both run on the same bridge-backed path
|
|
343
|
-
|
|
344
|
-
examples:
|
|
345
|
-
sootsim flow login.yaml
|
|
346
|
-
sootsim flow demo.yaml --url 8081 --record --slow 500 --out ./recordings
|
|
347
|
-
sootsim flow demo.yaml --sim a2
|
|
348
|
-
sootsim flow start
|
|
349
|
-
sootsim flow keep
|
|
350
|
-
sootsim flow end --output ./flows/draft.yaml
|
|
351
|
-
sootsim flow end --output ./flows/draft.yaml --validate
|
|
352
|
-
sootsim flow end --output ./flows/draft.yaml --video
|
|
353
|
-
sootsim flow validate ./flows/draft.yaml
|
|
354
|
-
|
|
355
|
-
flow extension:
|
|
356
|
-
takeScreenshot: hero
|
|
357
|
-
takeScreenshot:
|
|
358
|
-
path: marketing/hero
|
|
359
|
-
withFrame: true
|
|
360
|
-
`),process.exit(0));let e=o[0];A.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=u=>o.find((c,h)=>o[h-1]===u),i=o.includes("--profile"),r=o.includes("--new"),n=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||(t("--out")?n:"/tmp/sootsim-flow"),l=t("--screenshot-paths")==="flow"?"flow":"dir",a=o.includes("--no-shell")?"tenant":o.includes("--shell-only")?"shell":void 0,m=t("--device")?.trim()||"",p=o.includes("--slow")?+(t("--slow")||"500"):0,x=o.includes("--electron"),b=o.includes("--preview"),U=await Ee(t("--preview-origin")),oe=t("--preview-public-origin"),Ve=o.includes("--preview-open"),se=t("--owner")?.trim()||"",ne=t("--repo")?.trim()||"",Le=o.flatMap((u,c)=>o[c-1]==="--replace"?["--replace",u]:[]),F=o.includes("--record")||b,Be=o.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):F?b?6e3:2e3:0,We=A.readFileSync(e,"utf8"),{frontmatter:k,steps:M}=Z(We,{resolveEnv:!0});M.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let E=m||k.device||"",O=x||k.electron===!0,Ue=k.app===void 0||k.app===null?"":typeof k.app=="number"?String(k.app):k.app,j=await Xe(Ue),ae={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver"]},v=X(o,ae),je=t("--url")||"";O&&!$e()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let le=O?"desktop companion":"bridge",Ke=j?` | target: ${j}`:"";console.log(`
|
|
361
|
-
sootsim flow \u2014 ${y.basename(e)}
|
|
362
|
-
${M.length} steps | ${le}${Ke}${F?" | recording":""}${i?" | profiling":""}${p?` | ${p}ms delay`:""}
|
|
363
|
-
`),b&&pe({event:"preview_flow_started",properties:{flowName:y.basename(e),stepCount:M.length,mode:le,electron:O,record:F,profile:i,previewOrigin:U}});let T=je||j||"",K=r||O&&v.simIdSource!=="flag",ce=t("--driver")||"",J=!1,H=new Set,de=!1;if(!T&&!K&&v.simIdSource==="none"){let u=he(v);try{let c=await u.listSims(),h=c.find(N=>N.isPrimary&&N.readyState==="open"),R=c.find(N=>N.readyState==="open"),fe=h??R;fe&&(de=!0,console.log(` reusing active sim: ${fe.id}`))}catch{}finally{u.close()}}if(!T&&!de&&(K||v.simIdSource==="none")){let u=await Qe();u||(console.error(" error: no current sim and no sootsim target found"),await G(),process.exit(1)),T=u}if(T&&E){let u=new URL(await ke(T));u.searchParams.set("device",E),T=u.toString()}if(T){let u=[T];if(u.push(...Le),K&&u.push("--new"),v.simIdSource==="flag"&&v.simId&&u.push("--sim",v.simId),ce&&(u.push("--driver",ce),J=!0),o.includes("--headless")&&u.push("--headless"),await Ie(u,{port:v.wsPort,timeoutMs:v.commandTimeoutMs}),J){let c=Y();c&&H.add(c)}}let P=X(o,ae),q=P.simIdSource==="flag"?P.simId:Y()||P.simId,Je=P.simIdSource==="flag"?"flag":q?"saved":"none",$=Q(P.wsPort,{commandTimeoutMs:P.commandTimeoutMs,simId:q,simIdSource:Je}),d,ue=async()=>{if(!E)return!1;let u=await $.send({type:"evaluate",simId:d.simId,code:"window.location.href"});if(typeof u=="string"&&u.length>0){let c=new URL(u);c.searchParams.set("device",E),d.setSimRouteHint(c.toString())}return!!await $.send({type:"call",simId:d.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",E]})};d=new W($,{screenshotDir:s,flowDir:y.dirname(y.resolve(e)),screenshotPathMode:l,screenshotLayers:a,simId:q,recordingOutputDir:F?n:void 0,recordingFormat:b?"mp4":"webm",billingOriginOverride:b?U:void 0,allowGitHubRecording:F,onAfterLaunch:async()=>{await ue()&&await d.waitForTree(12e4),b&&await $.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
364
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
365
|
-
return r?.start?.() ?? false
|
|
366
|
-
})()`})}}),p&&(d.stepDelay=p);let I=null,S=null,_=null,z=null,C=0,me=!!M[0]?.launchApp;try{await d.waitForTree(12e4),await ue()&&await d.waitForTree(12e4),b&&!me&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await d.launchApp({clearState:!0}),F&&(me?d.prepareRecording():await d.startRecording()),i&&await d.startProfile(),b&&(await $.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
367
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
368
|
-
return r?.start?.() ?? false
|
|
369
|
-
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await d.runFlow(M),i&&(I=await d.stopProfile()),await d.waitForRecordingTail({maxMs:Be,smart:b}),F&&(S=await d.stopRecording(),_=d.getLastRecordingDurationMs()),b&&(z=await $.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
370
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
371
|
-
return r?.stop?.() ?? []
|
|
372
|
-
})()`}),console.log(` captured ${z.length} replay events`));let c=M.filter(h=>"takeScreenshot"in h).length;console.log(`
|
|
373
|
-
+ completed (${M.length} steps)`),c>0&&console.log(` screenshots: ${c} \u2192 ${s}`),I&&Ce(I),S&&console.log(` video: ${S}`),console.log()}catch(u){if(i&&!I)try{I=await d.stopProfile()}catch{}if(F&&!S)try{S=await d.stopRecording(),_=d.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}console.error(`
|
|
374
|
-
x failed: ${u.message}
|
|
375
|
-
`),I&&(console.log(" partial profile:"),Ce(I)),S&&console.log(` partial video: ${S}`);try{let c=d.lastFailedStep,h=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",R=y.join(s,h);await d.captureFailureBundle(R,{error:u,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),console.log(` failure bundle: ${R}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let h=y.join(s,"error.png");await d.captureFailureScreenshot(h),console.log(` error screenshot: ${h}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await ge($,{errorsCommand:`sootsim get errors 5${d.simId?` --sim ${d.simId}`:""}`,warningsCommand:`sootsim get warnings 5${d.simId?` --sim ${d.simId}`:""}`,requestsCommand:`sootsim get requests 5${d.simId?` --sim ${d.simId}`:""}`}),C=1}finally{$.close()}if(C===0&&b)try{let u=await et(z??[]),c=["--origin",U,"--events",u];oe&&c.push("--public-origin",oe),S&&c.push("--video",S),S&&_&&Number.isFinite(_)&&c.push("--video-duration-ms",String(Math.round(_))),d.simId&&c.push("--sim",d.simId),Ve&&c.push("--open"),se&&c.push("--owner",se),ne&&c.push("--repo",ne),console.log(`
|
|
376
|
-
preparing preview upload\u2026`);let{runUpload:h}=await import("./upload-W3YCA65H.js");await h(c,{})}catch(u){console.error(` preview upload failed: ${u?.message||u}`),C=1}return J&&(d.simId&&H.add(d.simId),await Ze(v.wsPort,v.commandTimeoutMs,[...H])),await G(),C}async function Ze(o,e,t){let i=[...new Set(t.filter(Boolean))];if(i.length===0)return;let r=Q(o,{commandTimeoutMs:e});try{let n=await r.listSims(),s=i.filter(a=>n.some(m=>m.id===a&&m.readyState==="open"));if(s.length===0)return;let l=await Pe(r,o,e,s);await Me(n,s),l.closed.length>0&&console.log(` closed flow sim(s): ${l.closed.join(", ")}`),l.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${l.remaining.join(", ")}`)}catch(n){console.warn(` warn: failed to close flow sim(s): ${n instanceof Error?n.message:String(n)}`)}finally{r.close()}}async function et(o){let{gzipSync:e}=await import("zlib"),t=o.map(n=>JSON.stringify(n)).join(`
|
|
377
|
-
`)+(o.length?`
|
|
378
|
-
`:""),i=e(Buffer.from(t,"utf8")),r=y.join(Re(),`sootsim-events-${Date.now()}.jsonl.gz`);return A.writeFileSync(r,i),console.log(` events: ${o.length} written to ${r} (${i.length} bytes gz)`),r}async function tt(o){let e=o[0],t=i=>o.find((r,n)=>o[n-1]===i);switch(e){case"start":{let{path:i,state:r}=ve();console.log(" flow draft started"),console.log(` session: ${i}`),console.log(` steps: ${r.steps.length}`);return}case"keep":case"good":{let i=ie();if(i.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!i.kept){console.log(" no pending action to keep");return}console.log(` kept: ${i.candidate.summary}`),console.log(` steps: ${i.stepCount}`);return}case"end":{let i=t("--output")||(o[1]&&!o[1].startsWith("-")?o[1]:void 0),r=o.includes("--validate")||o.includes("--video"),n=o.includes("--video"),s=ie();s.active&&s.kept&&console.log(` auto-kept trailing action: ${s.candidate.summary}`);let l=Se(i||(r?rt():void 0));if(l.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!l.valid){console.error(" flow draft is not valid:");for(let a of l.issues)console.error(` - ${a}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim flow start` to reset"),process.exit(1)}if(r){let a=ot(o,l.outputPath),m=await Ne(a);if(m!==0){console.error(`
|
|
379
|
-
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=m;return}te(),console.log(` flow draft validated (${l.stepCount} step${l.stepCount===1?"":"s"})`),l.outputPath&&console.log(` saved: ${l.outputPath}`),n&&console.log(" video: recorded during validation run");return}if(te(),console.log(` flow draft ended (${l.stepCount} step${l.stepCount===1?"":"s"})`),l.outputPath){console.log(` saved: ${l.outputPath}`),console.log(` next: sootsim flow ${l.outputPath} --record`);return}console.log(""),process.stdout.write(l.yaml);return}case"validate":{let i=o[1];(!i||i.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let r=ee(i);if(r.length>0){console.error(` x ${i} failed validation:`);for(let n of r)console.error(` - ${n}`);process.exit(1)}console.log(` + ${i} looks valid`);return}}}function it(o){return o[0]==="--sim"&&o.length>=2?[...o.slice(2),"--sim",o[1]]:o}async function kt(o){let e=it(o),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await tt(e),0;let i=await Ne(e);return i!==0&&(process.exitCode=i),i}function Ce(o){let e=o.avgMs>0?(1e3/o.avgMs).toFixed(1):"?",t=o.sampleCount>0?(o.jankFrames/o.sampleCount*100).toFixed(1):"0";console.log(`
|
|
380
|
-
profile:`),console.log(` frames: ${o.frames}`),console.log(` total: ${o.totalMs.toFixed(1)}ms`),console.log(` avg: ${o.avgMs.toFixed(2)}ms (${e} fps)`),console.log(` max: ${o.maxMs.toFixed(2)}ms`),o.layoutAvgMs!==void 0&&console.log(` breakdown: layout ${o.layoutAvgMs.toFixed(2)}ms | render ${o.renderAvgMs?.toFixed(2)||"0.00"}ms | copy ${o.copyAvgMs?.toFixed(2)||"0.00"}ms`),console.log(` p95: ${o.p95.toFixed(2)}ms`),console.log(` p99: ${o.p99.toFixed(2)}ms`),console.log(` jank: ${o.jankFrames}/${o.sampleCount} (${t}%) >16.67ms`);let i=Array.isArray(o.worstFrames)?o.worstFrames:[];if(i.length!==0){if(console.log(`
|
|
381
|
-
worst frames:`),o.mode==="render-worker"){console.log(" total layout render copy t+");for(let r of i){let[n,s,l,a,m]=r;console.log(` ${s.toFixed(2).padStart(7)} ${l.toFixed(2).padStart(7)} ${a.toFixed(2).padStart(7)} ${m.toFixed(2).padStart(7)} ${String(n).padStart(5)}`)}return}console.log(` ${i.map(r=>r.toFixed(2)).join(", ")}`)}}function rt(){return y.join(Re(),`sootsim-flow-draft-${Date.now()}.yaml`)}function ot(o,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let i=1;i<o.length;i++){let r=o[i];if(!(r==="--validate"||r==="--video")){if(r==="--output"){i+=1;continue}i===1&&!r.startsWith("-")||t.push(r)}}return!t.includes("--record")&&o.includes("--video")&&t.push("--record"),t}export{Qe as a,Ne as b,it as c,kt as d};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.1.140 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as R,b as C}from"./chunk-AP2MOP44.js";var x="sootsimConfig";function m(e){return!!e&&Object.keys(e).length>0}function _(e){return e?m(e.modules)||m(e.turboModules)||m(e.nativeModules)||m(e.env)||m(e.settings)||m(e.initialState):!1}function k(e,o){let t=new URL(e);return _(o)?t.searchParams.set(x,JSON.stringify(o)):t.searchParams.delete(x),t.toString()}import{exec as A}from"child_process";import N from"http";import L from"net";import{promisify as O}from"util";var ne="/index.bundle?platform=ios&dev=true&hot=true&minify=false";function D(e){return/^https?:\/\//i.test(e)}function T(e){return e.endsWith(".bundle")}function E(e){process.env.SOOTSIM_PREVIEW_PROD_BUNDLE&&(e.searchParams.set("dev","false"),e.searchParams.set("minify","true"),e.searchParams.has("hot")&&e.searchParams.set("hot","false"))}function M(e){try{let o=D(e),t=new URL(e,"http://soot.local");return t.pathname=t.pathname.replace(/\.\.bundle$/,".bundle"),T(t.pathname)?(t.searchParams.delete("transform.bytecode"),E(t),o?t.toString():`${t.pathname}${t.search}${t.hash}`):e}catch{return e}}var P=O(A);R();var $=250,I=1500,B=120;function H(e,o=B){return new Promise(t=>{let r=new L.Socket,s=!1,i=a=>{s||(s=!0,r.destroy(),t(a))};r.setTimeout(o),r.once("connect",()=>i(!0)),r.once("timeout",()=>i(!1)),r.once("error",()=>i(!1)),r.connect(e,"localhost")})}function h(e,o,t="GET",r=$,s={}){return new Promise(i=>{let a=N.request({hostname:"localhost",port:e,path:o,method:t,timeout:r,headers:s},n=>{let u="";n.on("data",l=>u+=l.toString());let c=(()=>{let l=n.headers["content-type"];if(typeof l=="string")return l;if(Array.isArray(l))return l[0]})();n.on("end",()=>i({statusCode:n.statusCode||0,body:u,contentType:c}))});a.on("error",()=>i(null)),a.setTimeout(r,()=>{a.destroy(),i(null)}),a.end()})}var j=[8081,8082,8083,8084,8085,8086,3e3,3001,19e3].map(e=>({port:e,pid:0}));function v(e,o){return!(e<=0||e>=2e4||o.has(e)||e>=5170&&e<=5200)}async function W(e=[]){let o=new Set(e);try{let{stdout:t}=await P("lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'",{encoding:"utf8",timeout:2e3});if(t.trim()){let r=new Map;for(let s of t.trim().split(`
|
|
3
|
-
`)){let i=s.trim().split(/\s+/);if(i.length<9)continue;let a=Number(i[1]),u=i[8].match(/:(\d+)$/);if(!u)continue;let c=Number(u[1]);v(c,o)&&(r.has(c)||r.set(c,a))}if(r.size>0)return[...r.entries()].map(([s,i])=>({port:s,pid:i}))}}catch{}try{let{stdout:t}=await P(`ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`,{encoding:"utf8",timeout:2e3});if(t.trim()){let r=new Map;for(let s of t.trim().split(`
|
|
4
|
-
`)){let i=s.match(/:(\d+)\s/),a=s.match(/pid=(\d+)/);if(!i)continue;let n=Number(i[1]),u=a?Number(a[1]):0;v(n,o)&&(r.has(n)||r.set(n,u))}if(r.size>0)return[...r.entries()].map(([s,i])=>({port:s,pid:i}))}}catch{}return j.filter(t=>v(t.port,o))}var y=new Map;async function F(e){if(e<=0)return null;let o=y.get(e);if(o)return o;try{let{stdout:t}=await P(`lsof -p ${e} -a -d cwd -Fn 2>/dev/null`,{encoding:"utf8",timeout:1500});for(let r of t.split(`
|
|
5
|
-
`))if(r.startsWith("n")&&r.length>1){let s=r.slice(1).trim();if(s)return y.set(e,s),s}}catch{}return null}function G(e,o){return{port:e,framework:o,bundleUrl:p(e,`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()}}function p(e,o){let t=C().find(s=>s.preferredPort===e),r=t?.runtimeConfig?k(o,t.runtimeConfig):o;return M(r)}function z(e){return e.includes("/node_modules/one/metro-entry.bundle")}function J(e){try{let o=JSON.parse(e);return o&&typeof o=="object"?o:null}catch{return null}}function b(e,o,t){if(!o)return e;try{let r=JSON.parse(o.body),s=r?.extra?.expoClient||r?.extra||{};s.name&&(e.projectName=s.name),s.ios?.bundleIdentifier&&(e.bundleId=s.ios.bundleIdentifier),e.framework==="metro"&&s.sdkVersion&&(e.framework="expo");let i=r?.launchAsset?.url;i&&!e.patched&&!z(e.bundleUrl)&&(e.bundleUrl=p(e.port,i));let a=s.iconUrl||s.ios?.iconUrl||s.icon||s.ios?.icon;if(a)if(e.iconPath=a,t)if(a.startsWith("http"))e.iconUrl=t(a);else{let n=a.replace(/^\.\//,"");e.iconUrl=t(`http://localhost:${e.port}/assets/${n}`)}else e.iconUrl=a.startsWith("http")?a:`http://localhost:${e.port}/assets/${a.replace(/^\.\//,"")}`}catch{}return e}var d=new Set,f=new Set,S=new Set;async function K(e,o){if(!await H(e))return null;let t="/node_modules/one/metro-entry.bundle?platform=ios&dev=true",[r,s,i,a]=await Promise.all([d.has(e)?Promise.resolve(null):h(e,"/__soot/"),h(e,"/status"),S.has(e)?Promise.resolve(null):h(e,"/","GET",I,{"expo-platform":"ios"}),f.has(e)?Promise.resolve(null):h(e,"/_expo/status")]);a&&a.statusCode===200?f.delete(e):f.has(e)||f.add(e);let n=i?J(i.body):null,u=typeof n?.launchAsset?.url=="string"?n.launchAsset.url:null,c=n?.extra?.expoClient||n?.extra||{};if(n&&(u||typeof c.name=="string")){d.add(e);let g=u||`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`,U=g.includes("/one/metro-entry.bundle")?"one":"expo";return b({port:e,framework:U,bundleUrl:p(e,g),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},i,o)}if(s&&s.body.includes("packager-status:running"))return d.add(e),b(G(e,a&&a.statusCode===200?"expo":"metro"),i,o);if(r&&r.statusCode===200&&r.body.includes("sootsim-patched"))return d.delete(e),b({port:e,framework:"one",bundleUrl:p(e,`http://localhost:${e}/__soot/bundle.js`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now(),patched:!0},i,o);let l=await h(e,t,"HEAD");return l&&l.statusCode>0&&l.statusCode<400&&/application\/javascript/i.test(l.contentType||"")?(d.add(e),S.add(e),b({port:e,framework:"one",bundleUrl:p(e,`http://localhost:${e}${t}&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},i,o)):(d.add(e),null)}function V(e){let o=e.projectName?.trim().toLowerCase();return!!(o==="soot"||o==="sootsim"||e.bundleId?.trim().toLowerCase()?.startsWith("dev.soot"))}var w=new Map,q=3e4,Q=1500;function Y(e){return!e||e.framework==="metro"||e.framework==="unknown"}function X(e){return e?p(e.port,e.bundleUrl)===e.bundleUrl:!0}function Z(e,o,t=Date.now()){if(o===0||e.pid!==o||!X(e.result))return!1;let r=t-e.cachedAt;return!(e.result===null&&r>=q||Y(e.result)&&r>=Q)}async function le(e={}){let o=await W(e.excludePorts),t=new Set(o.map(n=>n.port));for(let n of[...w.keys()])t.has(n)||w.delete(n);for(let n of[...d])t.has(n)||d.delete(n);for(let n of[...f])t.has(n)||f.delete(n);for(let n of[...S])t.has(n)||S.delete(n);let r=[],s=[];for(let{port:n,pid:u}of o){let c=w.get(n);if(c&&Z(c,u)){c.result&&r.push(c.result);continue}c&&c.pid!==u&&(d.delete(n),f.delete(n),S.delete(n)),s.push({port:n,pid:u})}s.length>0&&(await Promise.all(s.map(u=>K(u.port,e.buildIconProxyUrl)))).forEach((u,c)=>{let{port:l,pid:g}=s[c];g!==0&&w.set(l,{pid:g,result:u,cachedAt:Date.now()}),u&&r.push(u)});let i=new Map;for(let{port:n,pid:u}of o)u>0&&i.set(n,u);await Promise.all(r.map(async n=>{let u=i.get(n.port);if(!u)return;n.pid=u;let c=await F(u);c&&(n.cwd=c)}));let a=new Set(i.values());for(let n of[...y.keys()])a.has(n)||y.delete(n);return r.filter(n=>!V(n))}export{k as a,ne as b,M as c,K as d,le as e};
|