sootsim 0.1.223 → 0.1.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cli/bin.js +4 -4
- package/dist-cli/chunks/{agent-JTBPXPZB.js → agent-IXTIVO4B.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-WEO4D6BU.js → agent-wrapper-37QGL7LZ.js} +2 -2
- package/dist-cli/chunks/{app-fonts-PQALCHI6.js → app-fonts-CMNA7ZLB.js} +2 -2
- package/dist-cli/chunks/{assert-TE5XSGOD.js → assert-VE7DZN64.js} +2 -2
- package/dist-cli/chunks/{auth-FQOUDDAS.js → auth-BEI6S5AK.js} +2 -2
- package/dist-cli/chunks/beta-ZAFAH443.js +2 -0
- package/dist-cli/chunks/{camera-2JF3JBFK.js → camera-WGDO6BS4.js} +2 -2
- package/dist-cli/chunks/{chunk-3OXBUNZ7.js → chunk-24QLCYJG.js} +2 -2
- package/dist-cli/chunks/{chunk-SAYQL3WS.js → chunk-2QIGZP7G.js} +1 -1
- package/dist-cli/chunks/{chunk-MXPLCLFQ.js → chunk-2VBAA7XJ.js} +2 -2
- package/dist-cli/chunks/{chunk-MBUECXHD.js → chunk-4CO7SKSJ.js} +2 -2
- package/dist-cli/chunks/{chunk-TY4DBS2V.js → chunk-4WQ36IZO.js} +35 -35
- package/dist-cli/chunks/{chunk-PO7YGLL3.js → chunk-5FPSA6T3.js} +2 -2
- package/dist-cli/chunks/{chunk-TXEBAC22.js → chunk-6UJEQVPW.js} +2 -2
- package/dist-cli/chunks/{chunk-55X6DXUL.js → chunk-7KD7SO3A.js} +1 -1
- package/dist-cli/chunks/{chunk-NGTAJP33.js → chunk-AHA4PLGQ.js} +2 -2
- package/dist-cli/chunks/{chunk-XP3F6XJE.js → chunk-CCW5EYIU.js} +1 -1
- package/dist-cli/chunks/{chunk-DC2MHBNU.js → chunk-CE7KFLTO.js} +1 -1
- package/dist-cli/chunks/{chunk-SERRTOE3.js → chunk-CEBMTKID.js} +2 -2
- package/dist-cli/chunks/chunk-EVRV7ZEQ.js +1 -0
- package/dist-cli/chunks/{chunk-2CGWBBFX.js → chunk-FB4YNNHB.js} +2 -2
- package/dist-cli/chunks/chunk-FKMYICRL.js +1 -0
- package/dist-cli/chunks/{chunk-J3RS3XBX.js → chunk-FR2ZFWG2.js} +1 -1
- package/dist-cli/chunks/{chunk-2NBT5ZZN.js → chunk-FVZQMYUJ.js} +1 -1
- package/dist-cli/chunks/{chunk-AK6YMM67.js → chunk-GVK4Q3BA.js} +1 -1
- package/dist-cli/chunks/{chunk-POJFZN3G.js → chunk-HCA46V4W.js} +2 -2
- package/dist-cli/chunks/{chunk-GZKQNLWJ.js → chunk-HFTFALJY.js} +2 -2
- package/dist-cli/chunks/{chunk-DGDSYUMX.js → chunk-HYSKRSBW.js} +1 -1
- package/dist-cli/chunks/{chunk-KCYOZXSI.js → chunk-K7FLRWXM.js} +1 -1
- package/dist-cli/chunks/{chunk-5IBYQVY5.js → chunk-KIZV52CA.js} +3 -3
- package/dist-cli/chunks/{chunk-AXOMJURJ.js → chunk-KRZ5WWPA.js} +2 -2
- package/dist-cli/chunks/{chunk-KJIA6JJA.js → chunk-MF4YHHL4.js} +1 -1
- package/dist-cli/chunks/{chunk-R72ZTZUE.js → chunk-NLTKRAPS.js} +3 -3
- package/dist-cli/chunks/{chunk-4SQX6LJI.js → chunk-NWLTJUCZ.js} +1 -1
- package/dist-cli/chunks/{chunk-OA3DUO5F.js → chunk-NWN2GQ36.js} +1 -1
- package/dist-cli/chunks/{chunk-NHSZM43H.js → chunk-OOJ5OXYG.js} +2 -2
- package/dist-cli/chunks/{chunk-JWRSJISF.js → chunk-OPI6PLWA.js} +1 -1
- package/dist-cli/chunks/{chunk-RTJYTJSK.js → chunk-OYPMYSMY.js} +2 -2
- package/dist-cli/chunks/{chunk-W3CGOYQV.js → chunk-PFYMU6QF.js} +3 -3
- package/dist-cli/chunks/{chunk-TIYTNRKP.js → chunk-QJ2UUEBC.js} +2 -2
- package/dist-cli/chunks/{chunk-CXKBY6TK.js → chunk-QS4PGGDS.js} +1 -1
- package/dist-cli/chunks/{chunk-PJRZQXEB.js → chunk-RQHZYDRX.js} +2 -2
- package/dist-cli/chunks/{chunk-PBLGWJRA.js → chunk-S6LVSOND.js} +1 -1
- package/dist-cli/chunks/{chunk-3THE4AI3.js → chunk-SQ2QXZ4N.js} +2 -2
- package/dist-cli/chunks/{chunk-ZU66XAUT.js → chunk-VR5W6I6B.js} +2 -2
- package/dist-cli/chunks/{chunk-EPU5KR2V.js → chunk-WZAF6VH6.js} +2 -2
- package/dist-cli/chunks/{chunk-64URMR7J.js → chunk-X4623KU6.js} +2 -2
- package/dist-cli/chunks/{chunk-RJPPLDZY.js → chunk-ZTCF4L5T.js} +1 -1
- package/dist-cli/chunks/{chunk-NOQIMQQY.js → chunk-ZTYPCXG2.js} +2 -2
- package/dist-cli/chunks/{chunk-JJX4VJT2.js → chunk-ZVNBKS5H.js} +2 -2
- package/dist-cli/chunks/cli-version-EEQU4RHG.js +2 -0
- package/dist-cli/chunks/{compat-7CIYZ4VL.js → compat-6R6UR3NV.js} +3 -3
- package/dist-cli/chunks/{config-XNFTUYV2.js → config-IWITGWOX.js} +2 -2
- package/dist-cli/chunks/{control-PNXRV2KW.js → control-NN6KYHZ7.js} +2 -2
- package/dist-cli/chunks/daemon-OOS5GYH3.js +2 -0
- package/dist-cli/chunks/{debug-LKTQPN4Z.js → debug-AVD27HN2.js} +3 -3
- package/dist-cli/chunks/{desktop-QJKH3KAI.js → desktop-ARRS4W7G.js} +3 -3
- package/dist-cli/chunks/{detox-V3MFKEZE.js → detox-7ZVE4SEU.js} +2 -2
- package/dist-cli/chunks/{device-7KRVW5JT.js → device-KCAXPE2J.js} +2 -2
- package/dist-cli/chunks/{diagnose-2N3EZ7GZ.js → diagnose-NN2P4YHG.js} +2 -2
- package/dist-cli/chunks/drivers-WKXM4KAQ.js +2 -0
- package/dist-cli/chunks/{film-WJNMG7WL.js → film-YYDHQCIK.js} +3 -3
- package/dist-cli/chunks/flow-RLO6T7NN.js +2 -0
- package/dist-cli/chunks/help-QGPISENF.js +2 -0
- package/dist-cli/chunks/{home-paths-JT5DDNVD.js → home-paths-P5BF26CV.js} +2 -2
- package/dist-cli/chunks/inspect-CCH3ID2P.js +2 -0
- package/dist-cli/chunks/install-desktop-SD2XL3QE.js +2 -0
- package/dist-cli/chunks/{login-M3DMCRVO.js → login-3C6WS5WJ.js} +4 -4
- package/dist-cli/chunks/{logout-6ACWVMBO.js → logout-N7NHSAJ6.js} +2 -2
- package/dist-cli/chunks/{maestro-PBEHMFNX.js → maestro-72YHMDN3.js} +3 -3
- package/dist-cli/chunks/{maestro-generate-U5AZPHGP.js → maestro-generate-N6WRP4JB.js} +3 -3
- package/dist-cli/chunks/{mode-37QIFEWU.js → mode-HTGZVPBB.js} +2 -2
- package/dist-cli/chunks/optional-demo-registry-CUXZZ2PW.js +2 -0
- package/dist-cli/chunks/{perf-5DMSH2HP.js → perf-G3LOBGFB.js} +2 -2
- package/dist-cli/chunks/{record-BEJTPXPU.js → record-UCC52HPB.js} +3 -3
- package/dist-cli/chunks/runtime-RCOICIJ4.js +2 -0
- package/dist-cli/chunks/{screenshot-command-LQOZU4RT.js → screenshot-command-UERRRDTX.js} +3 -3
- package/dist-cli/chunks/{screenshots-capture-IQF22ATL.js → screenshots-capture-RBBJE7EF.js} +2 -2
- package/dist-cli/chunks/{serve-WC433RO4.js → serve-YYYACL4G.js} +2 -2
- package/dist-cli/chunks/{setup-XVAD2NQA.js → setup-DOQ3CNWU.js} +3 -3
- package/dist-cli/chunks/{skills-O5WBT33I.js → skills-TY7JP5HL.js} +2 -2
- package/dist-cli/chunks/{storage-2CHJQ4E5.js → storage-5G6MYKIR.js} +2 -2
- package/dist-cli/chunks/store-SVH7YFQP.js +2 -0
- package/dist-cli/chunks/telemetry-Z6SP2WSB.js +2 -0
- package/dist-cli/chunks/{timeline-KY4JHIIO.js → timeline-TEZJY6OI.js} +2 -2
- package/dist-cli/chunks/{upgrade-IBAVKCUD.js → upgrade-2VHEHNNM.js} +2 -2
- package/dist-cli/chunks/upload-WXQKH3QR.js +2 -0
- package/dist-cli/chunks/{version-2BCOACVD.js → version-LPLQL5Y2.js} +2 -2
- package/dist-cli/chunks/{web-P5MGQXDB.js → web-3O74TBQP.js} +2 -2
- package/dist-cli/chunks/{what-happened-BUIYQ725.js → what-happened-SHAO2WXX.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1 -1
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +10 -5
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/dist-cli/chunks/beta-UOBKQ5D2.js +0 -2
- package/dist-cli/chunks/chunk-DBQEQGNL.js +0 -1
- package/dist-cli/chunks/chunk-JDDF5AUO.js +0 -1
- package/dist-cli/chunks/cli-version-H7ZLVRWR.js +0 -2
- package/dist-cli/chunks/daemon-PNQ5COGX.js +0 -2
- package/dist-cli/chunks/drivers-3JUVJC4B.js +0 -2
- package/dist-cli/chunks/flow-SMUA7TK6.js +0 -2
- package/dist-cli/chunks/help-E5FXFXU2.js +0 -2
- package/dist-cli/chunks/inspect-BBH6XUJ4.js +0 -2
- package/dist-cli/chunks/install-desktop-J3FW24ZB.js +0 -2
- package/dist-cli/chunks/optional-demo-registry-6EMH4Q4R.js +0 -2
- package/dist-cli/chunks/runtime-GCVKSC6T.js +0 -2
- package/dist-cli/chunks/store-MHKDMCCF.js +0 -2
- package/dist-cli/chunks/telemetry-6CE24V3C.js +0 -2
- package/dist-cli/chunks/upload-2BA3T6GS.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as me,c as ge,d as we,e as
|
|
1
|
+
/*! sootsim v0.1.224 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as me,c as ge,d as we,e as et,f as ye,g as be,h as tt,i as Se,j as nt}from"./chunk-KIZV52CA.js";import{a as Qe}from"./chunk-FB4YNNHB.js";import{a as rt}from"./chunk-4CO7SKSJ.js";import{a as it}from"./chunk-ZTYPCXG2.js";import{h as qe,p as Ye,r as Ze,v as Xe}from"./chunk-OYPMYSMY.js";import{f as Ue}from"./chunk-SQ2QXZ4N.js";import{a as He}from"./chunk-QS4PGGDS.js";import{h as fe,m as ze}from"./chunk-OOJ5OXYG.js";import{I as J,m as We,n as je,o as Ve,p as Je}from"./chunk-7KD7SO3A.js";import{g as pe,h as he,i as Ge}from"./chunk-RQHZYDRX.js";import{a as Ke}from"./chunk-GVK4Q3BA.js";import{a as Be,b as de}from"./chunk-VR5W6I6B.js";import{d as ue,e as Ne}from"./chunk-ZTCF4L5T.js";import{g as Le,h as Ce}from"./chunk-NWLTJUCZ.js";import*as $ from"fs";import{createHash as Jt,randomUUID as Gt}from"node:crypto";import{tmpdir as K}from"os";import*as w from"path";import*as S from"fs";import*as b from"path";var Ft="inset 0 0 0 0.5px #000, inset 0 0 0 2px #757575, inset 0 0 0 5px #212121",st=1;function $t(r){let e=Ce(r),t=e.scale,n=e.statusBarHeight>0&&!e.dynamicIsland&&e.homeIndicatorHeight===0&&e.cornerRadius===0,i=e.width,o=e.height,a=n?e.width+58:e.width+e.bezelWidth*2,s=n?e.height+111+111:e.height+e.bezelWidth*2,l=9.5,u=st,p=a+l*2,g=s+st*2,I=l+(n?29:e.bezelWidth),m=n?111:e.bezelWidth,P=n?52:e.cornerRadius+e.bezelWidth,k=[{side:"right",top:e.hardwareButtons.lock.top,height:e.hardwareButtons.lock.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.ringToggle.top,height:e.hardwareButtons.ringToggle.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeUp.top,height:e.hardwareButtons.volumeUp.height,width:e.hardwareButtons.width},{side:"left",top:e.hardwareButtons.volumeDown.top,height:e.hardwareButtons.volumeDown.height,width:e.hardwareButtons.width}];return{model:r,renderScale:t,outerWidth:Math.round(p*t),outerHeight:Math.round(g*t),logicalOuterWidth:p,logicalOuterHeight:g,logicalFrameWidth:a,logicalFrameHeight:s,logicalFrameLeft:l,logicalFrameTop:u,logicalScreenWidth:i,logicalScreenHeight:o,logicalScreenLeft:I,logicalScreenTop:m,logicalScreenRadius:n?0:e.cornerRadius,logicalFrameRadius:P,frameBackground:n?"linear-gradient(180deg, #1b1c20 0%, #0f1012 42%, #050608 100%)":"#000000",frameOutline:n?"0 0 0 1px #1f2125":"0 0 0 1px #333",metallicRingShadow:n?null:Ft,buttons:k,legacyHomeButton:n?{top:111+e.height+47/2,left:e.width/2-64/2+29,size:64,ring:1.5}:null,showHomeIndicator:e.homeIndicatorHeight>0,logicalHomeIndicatorStripHeight:e.homeIndicatorHeight}}function Pt(r){let e=r.side==="right",t=e?"inset(-3px -3px -3px 0)":"inset(-3px 0 -3px -3px)";return`
|
|
3
3
|
<div
|
|
4
4
|
aria-hidden="true"
|
|
5
5
|
style="
|
|
@@ -24,7 +24,7 @@ import{a as me,c as ge,d as we,e as Qe,f as ye,g as be,h as et,i as Se,j as tt}f
|
|
|
24
24
|
z-index:2;
|
|
25
25
|
"
|
|
26
26
|
></div>
|
|
27
|
-
`}function
|
|
27
|
+
`}function kt(r,e){let t=r.buttons.map(Pt).join(""),n=r.metallicRingShadow?`
|
|
28
28
|
<div
|
|
29
29
|
aria-hidden="true"
|
|
30
30
|
style="
|
|
@@ -36,7 +36,7 @@ import{a as me,c as ge,d as we,e as Qe,f as ye,g as be,h as et,i as Se,j as tt}f
|
|
|
36
36
|
z-index:10;
|
|
37
37
|
"
|
|
38
38
|
></div>
|
|
39
|
-
`:"",
|
|
39
|
+
`:"",i=r.legacyHomeButton?`
|
|
40
40
|
<div
|
|
41
41
|
aria-hidden="true"
|
|
42
42
|
style="
|
|
@@ -155,8 +155,8 @@ import{a as me,c as ge,d as we,e as Qe,f as ye,g as be,h as et,i as Se,j as tt}f
|
|
|
155
155
|
"
|
|
156
156
|
>
|
|
157
157
|
${t}
|
|
158
|
-
${i}
|
|
159
158
|
${n}
|
|
159
|
+
${i}
|
|
160
160
|
<div
|
|
161
161
|
id="screen"
|
|
162
162
|
style="
|
|
@@ -177,7 +177,7 @@ import{a as me,c as ge,d as we,e as Qe,f as ye,g as be,h as et,i as Se,j as tt}f
|
|
|
177
177
|
</div>
|
|
178
178
|
</div>
|
|
179
179
|
</body>
|
|
180
|
-
</html>`}async function
|
|
180
|
+
</html>`}async function at(r,e){let{chromium:t}=await import("playwright"),n=await t.launch({headless:!0});try{let i=await At(n);try{return await i.compose(r,e)}finally{await i.close()}}finally{await n.close()}}async function At(r){let e=new Map;async function t(n){let i=e.get(n);if(i)return i;let o=$t(n),a=await r.newContext({viewport:{width:o.outerWidth,height:o.outerHeight},deviceScaleFactor:1}),s=await a.newPage(),l={layout:o,context:a,page:s};return e.set(n,l),l}return{async compose(n,i){let o=await t(i),a=`data:image/png;base64,${n.toString("base64")}`;return await o.page.setContent(kt(o.layout,a),{waitUntil:"load"}),await o.page.waitForTimeout(20),await o.page.screenshot({type:"png",clip:{x:0,y:0,width:o.layout.outerWidth,height:o.layout.outerHeight},omitBackground:!0})},async close(){for(let n of e.values())await n.context.close();e.clear()}}}import{spawnSync as Mt}from"child_process";import*as C from"vm";var Rt=3e5,Ot=`
|
|
181
181
|
let input = '';
|
|
182
182
|
process.stdin.on('data', (c) => { input += c });
|
|
183
183
|
process.stdin.on('end', async () => {
|
|
@@ -199,7 +199,7 @@ process.stdin.on('end', async () => {
|
|
|
199
199
|
process.exitCode = 1;
|
|
200
200
|
}
|
|
201
201
|
});
|
|
202
|
-
`;function G(r,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by sootsim yet");let
|
|
202
|
+
`;function G(r,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by sootsim yet");let n={...process.env};for(let s of Object.keys(n))(s.startsWith("BUN_INSPECT")||s==="NODE_OPTIONS")&&delete n[s];let i=Mt(process.execPath,["-e",Ot],{input:JSON.stringify({url:r,method:e,headers:t?.headers,body:t?.body}),encoding:"utf8",timeout:Rt,maxBuffer:64*1024*1024,env:n});if(i.error)throw new Error(`http ${e} ${r} failed: ${i.error.message}`);let o;try{o=JSON.parse(i.stdout||"")}catch{throw new Error(`http ${e} ${r} failed: no response (${(i.stderr||"").trim().slice(0,200)})`)}let a=o;if(a.__error)throw new Error(`http ${e} ${r} failed: ${a.__error}`);return a}var _t=/(?<!\\)\$\{([^$]*)\}/g,Dt=/\\(\$\{[^$]*\})/g,Bt=/^[A-Za-z_$][A-Za-z0-9_$]*$/,X=class{context;envBinding=new Map;envScopeStack=[];syncedEnvKeys=new Set;output={};maestro;constructor(e={}){this.maestro={copiedText:null,platform:e.platform??"ios"};let t=e.onLog??(i=>console.log(`[flow] js: ${i}`)),n={output:this.output,maestro:this.maestro,http:{get:(i,o)=>G(i,"GET",o),post:(i,o)=>G(i,"POST",o),put:(i,o)=>G(i,"PUT",o),delete:(i,o)=>G(i,"DELETE",o),request:(i,o)=>G(i,(o?.method??"GET").toUpperCase(),o)},console:{log:(...i)=>t(i.map(o=>typeof o=="string"?o:lt(o)).join(" "))}};this.context=C.createContext(n),C.runInContext(`
|
|
203
203
|
globalThis.__maestroScope = new Proxy(globalThis, {
|
|
204
204
|
has() { return true },
|
|
205
205
|
get(target, key) { return target[key] },
|
|
@@ -210,13 +210,13 @@ process.stdin.on('end', async () => {
|
|
|
210
210
|
var yPercent = Math.ceil(y * 100) + '%'
|
|
211
211
|
return xPercent + ',' + yPercent
|
|
212
212
|
}
|
|
213
|
-
`,this.context);for(let[
|
|
213
|
+
`,this.context);for(let[i,o]of Object.entries(process.env))o!==void 0&&this.envBinding.set(i,o)}putEnv(e,t){this.envBinding.set(e,t)}setCopiedText(e){this.maestro.copiedText=e}enterEnvScope(){this.envScopeStack.push(new Map(this.envBinding))}leaveEnvScope(){let e=this.envScopeStack.pop();if(e){this.envBinding.clear();for(let[t,n]of e)this.envBinding.set(t,n)}}evaluate(e,t={}){let n=t.env;if(n&&Object.keys(n).length>0){this.enterEnvScope();try{for(let[i,o]of Object.entries(n))this.envBinding.set(i,o);return this.evalRaw(e)}finally{this.leaveEnvScope()}}return this.evalRaw(e)}evalRaw(e){this.syncEnvToContext();let t=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${");return C.runInContext(`(function(){ with(__maestroScope){ return eval(\`${t}\`) } })()`,this.context)}syncEnvToContext(){let e=C.runInContext("globalThis",this.context);for(let t of this.syncedEnvKeys)this.envBinding.has(t)||delete e[t];this.syncedEnvKeys=new Set;for(let[t,n]of this.envBinding)try{e[t]=n,this.syncedEnvKeys.add(t)}catch{}}evaluateStringTemplate(e){return e.replace(_t,(n,i)=>{if(i.trim().length===0)return"";let o=this.evaluate(i);if(o===void 0&&Bt.test(i.trim()))throw new Error(`missing variable for flow placeholder: ${i.trim()}`);return lt(o)}).replace(Dt,(n,i)=>i)}interpolateStep(e){return this.interpolateValue(e,null)}interpolateValue(e,t){return typeof e=="string"?t==="evalScript"?e:this.evaluateStringTemplate(e):Array.isArray(e)?t==="commands"||t==="onFlowStart"||t==="onFlowComplete"?e:e.map(n=>this.interpolateValue(n,t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,i])=>[n,this.interpolateValue(i,n)])):e}};function lt(r){if(r===void 0)return"undefined";if(r===null)return"null";if(typeof r=="object")try{return JSON.stringify(r)}catch{return String(r)}return String(r)}function ct(r){if(r==null)return!1;if(typeof r=="boolean")return r;let e=String(r);if(e.trim().length===0||e.toLowerCase()==="false"||e==="undefined"||e==="null")return!1;let t=Number(e);return!(!Number.isNaN(t)&&t===0)}var Q=1e4,Lt=Math.min(10,Math.max(1,Number(process.env.SOOTSIM_FLOW_TIMEOUT_SCALE)||1)),Ee=r=>Math.round(r*Lt),te=393,N=852;function f(r){return new Promise(e=>setTimeout(e,r))}function Ie(r){return!!(r&&typeof r=="object"&&!Array.isArray(r))}function z(r,e){if(!Ie(r))return null;let t=r[e];return typeof t=="string"&&t.length>0?t:null}function Ct(r,e){return Ie(r)?r[e]===!0:!1}function Nt(r){if(!r)return null;let e=r.recentApps;if(Array.isArray(e))for(let n of e){let i=z(n,"id");if(i)return i}let t=r.surfaceBindings;return z(t,"app:one")||z(t,"app:two")||null}function Ht(r){return r?b.basename(r)===".maestro"?b.dirname(r):r:process.cwd()}function Ut(r,e,t){let n=e.endsWith(".png")?e:`${e}.png`;if(b.isAbsolute(n))return n;if(t.mode==="flow"&&/[\\/]/.test(n)){let i=n.startsWith("./")||n.startsWith("../")?t.flowDir??process.cwd():Ht(t.flowDir);return b.resolve(i,n)}return b.join(r,n)}function Wt(r){if(typeof r=="string")return{path:r,withFrame:!1};let e=r.path?.trim()||r.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:r.withFrame===!0,layers:r.layers}}function ee(r,e){let[t,n]=r.split(",").map(s=>s.trim()),i=(s,l)=>s.endsWith("%")?Number.parseFloat(s)/100*l:Number.parseFloat(s),o=e?.x??0,a=e?.y??0;return{x:o+i(t,e?.width??te),y:a+i(n,e?.height??N)}}function dt(r){switch(r){case"back":return{back:!0};case"hideKeyboard":return{hideKeyboard:!0};case"waitForAnimationToEnd":return{waitForAnimationToEnd:!0};case"stopApp":return{stopApp:!0};case"clearState":return{clearState:!0};case"clearKeychain":return{clearKeychain:!0};case"eraseText":return{eraseText:50};case"scroll":case"scrollDown":return{scroll:{direction:"DOWN"}};case"scrollUp":return{scroll:{direction:"UP"}};default:return{[r]:!0}}}function jt(r){let e=r.split(/^---$/m),t=e.length>1?e[e.length-1]:r,n=Qe.parse(t);return Array.isArray(n)?n:[]}var ne=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;js=new X({platform:"ios",onLog:e=>console.log(`[flow] js: ${e}`)});firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingStartedAtMs=null;lastRecordingDurationMs=null;lastRecordingFrameStats=null;flowTraceSteps=[];lastVisualSettledAtMs=0;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 n=t.searchParams.toString();return`${t.origin}${t.pathname}${n?`?${n}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(l=>l.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(l=>l.id===this.opts.simId&&l.readyState==="open")||!this.simRouteHint)return;let i=this.simRouteHint&&e.find(l=>l.readyState==="open"&&this.normalizeSimRoute(l.url||l.origin)===this.simRouteHint);if(!i)return;let o=e.find(l=>l.isPrimary&&l.readyState==="open"),a=e.find(l=>l.readyState==="open"),s=i??o??a;s&&(this.opts.simId=s.id,console.log(` [flow] sim rotated to ${s.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=Q){let t=Date.now()+Ee(e),n=Date.now(),i=null,o=0,a=0,s=-1,l=n;for(;Date.now()<t;){try{let p=await this.evaluate(We,8e3);if(o=0,p?.externalError)throw new Error(`app failed to load: ${p.externalError}`);if(p){let g=Date.now();p.nodes!==s&&(s=p.nodes,l=g);let I=p.flag===!0&&Ve(p),m=p.flag!==!0&&Je(p);if((I||m)&&p.externalReady!==!1&&!p.externalError&&!p.loadingText&&g-l>=je)return}}catch(p){if(i=p instanceof Error?p:new Error(String(p)),i.message.startsWith("app failed to load:"))throw i;if(o++,o>=4)throw new Error(`target sim is not responding to the bridge (${i.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 u=Date.now()-n;u-a>=5e3&&(a=u,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(u/1e3)}s)`)),await f(500)}throw i?.message.startsWith("app failed to load:")?i:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(this.opts.requireRecordingEntitlement&&await rt("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
|
|
214
214
|
const rec = window.__sootsimRecorder
|
|
215
215
|
if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
|
|
216
216
|
const format = ${JSON.stringify(this.opts.recordingFormat??"webm")}
|
|
217
217
|
if (rec.state() === 'recording') return { ok: true, format }
|
|
218
218
|
return rec.start({ format, fps: 24 })
|
|
219
|
-
})()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=typeof t.startedAtMs=="number"&&Number.isFinite(t.startedAtMs)?t.startedAtMs:e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}getLastRecordingStartedAtMs(){return this.lastRecordingStartedAtMs}getLastRecordingFrameStats(){return this.lastRecordingFrameStats}getFlowTraceSteps(){return[...this.flowTraceSteps]}flowStepTargetLabel(e,t){if(t==="inputText"||t==="runScript"||t==="evalScript")return;let
|
|
219
|
+
})()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=typeof t.startedAtMs=="number"&&Number.isFinite(t.startedAtMs)?t.startedAtMs:e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}getLastRecordingStartedAtMs(){return this.lastRecordingStartedAtMs}getLastRecordingFrameStats(){return this.lastRecordingFrameStats}getFlowTraceSteps(){return[...this.flowTraceSteps]}flowStepTargetLabel(e,t){if(t==="inputText"||t==="runScript"||t==="evalScript")return;let n=e[t];if(typeof n=="string")return n.slice(0,80);if(typeof n=="number"||typeof n=="boolean")return String(n);if(!n||typeof n!="object")return;let i=n,o=i.id??i.text??i.name??i.path;if(typeof o=="string"&&o)return o.slice(0,80);if(i.point&&typeof i.point=="string")return i.point.slice(0,80);if(typeof i.x=="number"&&typeof i.y=="number")return`${Math.round(i.x)}, ${Math.round(i.y)}`}recordFlowTraceStep(e){let t=Date.now(),n={stepIndex:e.stepIndex,stepName:e.stepName,...e.targetLabel?{targetLabel:e.targetLabel}:{},startedAtMs:e.startedAtMs,endedAtMs:t,durationMs:Math.max(0,t-e.startedAtMs),status:e.status};e.error!=null&&(n.error=e.error instanceof Error?e.error.message:String(e.error)),e.screenshotPath&&(n.screenshotPath=e.screenshotPath),this.flowTraceSteps.push(n)}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,this.lastRecordingFrameStats=null,new Error(t?.error||"recording stop failed");this.lastRecordingStartedAtMs=this.recordingStartedAtMs,this.lastRecordingDurationMs=this.recordingStartedAtMs?Math.max(1,e-this.recordingStartedAtMs):null,this.lastRecordingFrameStats=t.frameStats??null,this.recordingStartedAtMs=null;let n=[],i=0;for(;;){let l=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${i}, chunk: 2097152 })`);if(!l||(n.push(Buffer.from(l.data,"base64")),i=l.offset,l.done))break}if(n.length===0)throw new Error("recording requested but no video buffer was produced");S.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let a=(t.mime||this.opts.recordingFormat||"video/webm").includes("mp4")?"mp4":"webm",s=b.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.${a}`);return S.writeFileSync(s,Buffer.concat(n)),s}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 n=await Se({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:80,stablePolls:6,strict:!0});await this.waitForVisualSettle(),console.log(n.settled?` [flow] recording tail settled in ${n.elapsed}ms`:` [flow] recording tail reached ${n.elapsed}ms budget`)}async findElement(e){if(e.childOf!=null||typeof e.index=="number")return this.findElementScoped(e);let t=!!e.text&&/[.*+?^$()[\]{}|\\]/.test(e.text);return this.evaluate(`(async () => {
|
|
220
220
|
const test = window.__sootsimTest
|
|
221
221
|
if (!test) return null
|
|
222
222
|
let node = null
|
|
@@ -293,7 +293,7 @@ process.stdin.on('end', async () => {
|
|
|
293
293
|
// resolves a target that needs scrolling into view.
|
|
294
294
|
const onScreen = candidates.filter((n) => {
|
|
295
295
|
const cy = n.absolutePosition.y + n.layout.height / 2
|
|
296
|
-
return cy > 0 && cy < ${
|
|
296
|
+
return cy > 0 && cy < ${N}
|
|
297
297
|
})
|
|
298
298
|
if (onScreen.length > 0) candidates = onScreen
|
|
299
299
|
${e.childOf?`
|
|
@@ -365,18 +365,18 @@ process.stdin.on('end', async () => {
|
|
|
365
365
|
)
|
|
366
366
|
}
|
|
367
367
|
return direct
|
|
368
|
-
})()`)}async tap(e,t,
|
|
368
|
+
})()`)}async tap(e,t,n){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t,target:n})}async longPress(e,t,n,i){return await this.bridge.send({type:"longPress",simId:this.opts.simId,x:e,y:t,durationMs:n,target:i})}async waitForElement(e,t=5e3){let n=Date.now()+t,i=await this.findElement(e);for(;!i&&Date.now()<n;)await f(150),i=await this.findElement(e);if(!i)return i;let o=Date.now()+1200,a=i;for(;Date.now()<o;){await f(120);let s=await this.findElement(e);if(!s)break;let l=Math.abs(s.absolutePosition.x-a.absolutePosition.x)>.5||Math.abs(s.absolutePosition.y-a.absolutePosition.y)>.5||Math.abs(s.layout.width-a.layout.width)>.5||Math.abs(s.layout.height-a.layout.height)>.5;if(i=s,!l)return i;a=s}return i}replayTargetForElement(e,t,n){return{id:e.id??n?.target?.id??t.id??null,testID:e.id??n?.target?.testID??t.testID??null,text:e.text??n?.target?.text??n?.target?.accessibilityLabel??t.text??t.accessibilityLabel??null,type:n?.target?.type??t.type??null}}async resolveInteractionPoint(e){if(e.point&&!e.id&&!e.text&&e.index===void 0&&!e.childOf)return{...ee(e.point),element:null,target:void 0};let t=await this.waitForElement(e);if(!t)return null;let n=typeof t.nodeId=="number"?await this.resolveTapTarget(t.nodeId):null,i=this.replayTargetForElement(e,t,n);return e.point?{...ee(e.point,{x:t.absolutePosition.x,y:t.absolutePosition.y,width:t.layout.width,height:t.layout.height}),element:t,target:i}:{x:n?.cx??t.absolutePosition.x+t.layout.width/2,y:n?.cy??t.absolutePosition.y+t.layout.height/2,element:t,target:i}}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let o=await this.resolveInteractionPoint(t);if(!o)throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`);(await this.activatePressAt(o.x,o.y))?.ok||await this.tap(o.x,o.y,o.target),await f(300);return}let n=await this.waitForElement(t);if(n){let o=n.isTextInput?4:1;for(let a=0;a<o;a++){let s=a===0?n:await this.findElement({text:t.text,id:t.id});if(!s)break;let l=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,u=l?.cx??s.absolutePosition.x+s.layout.width/2,p=l?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(u,p,this.replayTargetForElement(t,s,l)))?.hit===!0){if(await f(300),!s.isTextInput||await this.waitForFocusedTextInput(600,s))return;continue}break}}if((await this.activatePressTarget(t))?.ok){await f(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async longPressOn(e){let t=typeof e=="string"?{text:e}:e,n=await this.resolveInteractionPoint(t);if(!n)throw new Error(`longPressOn: element not found: ${JSON.stringify(t)}`);let i=await this.longPress(n.x,n.y,3e3,n.target);if(i?.ok===!1||i?.value===!1)throw new Error(`longPressOn: long press missed: ${JSON.stringify(t)}`);await f(300)}async tapAtCoords(e,t){await this.tap(e,t),await f(300)}async doubleTapAtCoords(e,t,n=80){let i=Math.max(0,Math.round(n));if(!await this.evaluate(`(async () => {
|
|
369
369
|
const interact = window.__sootsimInteract
|
|
370
370
|
if (interact?.doubleTap) {
|
|
371
|
-
return !!(await interact.doubleTap(${e}, ${t}, ${
|
|
371
|
+
return !!(await interact.doubleTap(${e}, ${t}, ${i}))
|
|
372
372
|
}
|
|
373
373
|
if (!interact?.tap) return false
|
|
374
374
|
const first = await interact.tap(${e}, ${t})
|
|
375
375
|
if (!first || first.hit === false) return false
|
|
376
|
-
await new Promise((resolve) => setTimeout(resolve, ${
|
|
376
|
+
await new Promise((resolve) => setTimeout(resolve, ${i}))
|
|
377
377
|
const second = await interact.tap(${e}, ${t})
|
|
378
378
|
return !!second && second.hit !== false
|
|
379
|
-
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let o=0;o<15;o++){if(await this.isElementVisible(t))return;await f(200)}let
|
|
379
|
+
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let o=0;o<15;o++){if(await this.isElementVisible(t))return;await f(200)}let n=await this.findElement(t),i=n?` (matched node at y=${Math.round(n.absolutePosition.y)} h=${Math.round(n.layout.height)} \u2014 off-screen)`:" (no matching node in tree)";throw new Error(`assertVisible: ${JSON.stringify(t)} not visible${i}`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t)){let n=await this.findElement(t),i=n?` at (${Math.round(n.absolutePosition.x)},${Math.round(n.absolutePosition.y)})`:"";throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible${i}`)}}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<N)}async inputText(e){if(!await this.waitForFocusedTextInput())throw new Error("inputText: no focused TextInput; tap the input and wait for focus before typing");await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await f(200)}focusedTextInputMatches(e,t){if(!t||typeof t.nodeId=="number"&&typeof e.nodeId=="number"&&t.nodeId===e.nodeId)return!0;let n=t.testID??null,i=e.testID??null;if(n&&i&&n===i)return!0;let o=t.id??null,a=e.id??null;return!!(o&&a&&o===a)}async waitForFocusedTextInput(e=1500,t){let n=Date.now()+e;for(;Date.now()<n;){try{let i=await this.callTest("getFocusedNode");if(i&&this.focusedTextInputMatches(i,t))return!0}catch{}await f(50)}return!1}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(`(() => {
|
|
380
380
|
const keyboard =
|
|
381
381
|
window.__sootsimKeyboard ??
|
|
382
382
|
window.SootSim?.bridges?.keyboard ??
|
|
@@ -386,7 +386,7 @@ process.stdin.on('end', async () => {
|
|
|
386
386
|
visible: !!keyboard?.isVisible?.(),
|
|
387
387
|
focused: !!test?.isTextInputFocused?.(),
|
|
388
388
|
}
|
|
389
|
-
})()`);if(!t?.visible&&!t?.focused){await f(80);return}await f(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:"Backspace"});await f(100)}async waitFor(e){let t=Date.now()+(e.timeout||Q);for(;Date.now()<t;){if(await this.findElement(e))return;await f(200)}let
|
|
389
|
+
})()`);if(!t?.visible&&!t?.focused){await f(80);return}await f(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:"Backspace"});await f(100)}async waitFor(e){let t=Date.now()+Ee(e.timeout||Q);for(;Date.now()<t;){if(await this.findElement(e))return;await f(200)}let n=await this.findElement(e),i=n?` (matched node y=${Math.round(n.absolutePosition.y)} \u2014 still off-screen at deadline)`:"";throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||Q}ms${i}`)}async takeScreenshot(e){if(!this.hasFreshVisualSettle())try{await this.waitForVisualSettle(),await f(250)}catch{}let t=Wt(e),n=Ut(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});S.mkdirSync(b.dirname(n),{recursive:!0});let i=t.layers??this.opts.screenshotLayers,o={type:"screenshot",simId:this.opts.simId};i&&i!=="full"&&(o.layers=i);let s=(await this.bridge.send(o)).replace(/^data:image\/png;base64,/,""),l=Buffer.from(s,"base64");if(t.withFrame){let u=await this.readCurrentDeviceModel();if(!u)throw new Error("could not read current device model for framed screenshot");let p=await at(l,u);return S.writeFileSync(n,p),console.log(`[flow] screenshot: ${n} (frame: ${u})`),n}return S.writeFileSync(n,l),console.log(`[flow] screenshot: ${n}`),n}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 Le)?null:t}async captureScreenshot(e){S.mkdirSync(b.dirname(e),{recursive:!0});let n=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");S.writeFileSync(e,Buffer.from(n,"base64"))}async captureFailureBundle(e,t){S.mkdirSync(e,{recursive:!0});let n=(p,g)=>{try{S.writeFileSync(b.join(e,p),g)}catch{}},i=async p=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:p})}catch{return null}},o=await i(`(async () => {
|
|
390
390
|
const out = {
|
|
391
391
|
simId: window.__sootsimBridge?.id ?? window.SootSim?.state?.simId ?? null,
|
|
392
392
|
url: location.href,
|
|
@@ -410,7 +410,7 @@ process.stdin.on('end', async () => {
|
|
|
410
410
|
}
|
|
411
411
|
} catch {}
|
|
412
412
|
return out
|
|
413
|
-
})()`);
|
|
413
|
+
})()`);n("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:o??null},null,2));try{let g=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");n("screenshot.png",Buffer.from(g,"base64"))}catch{}let a=await i(`(async () => {
|
|
414
414
|
const t = window.__sootsimTest
|
|
415
415
|
const mainShell = window.SootSim?.bridges?.mainShell
|
|
416
416
|
if (!t) return { error: 'no test bridge' }
|
|
@@ -420,19 +420,19 @@ process.stdin.on('end', async () => {
|
|
|
420
420
|
} catch {}
|
|
421
421
|
const all = await t.queryAll({ pruneHidden: true })
|
|
422
422
|
return { shell, nodes: all, url: location.href, title: document.title }
|
|
423
|
-
})()`);a&&
|
|
423
|
+
})()`);a&&n("describe.json",JSON.stringify(a,null,2));let s=await i("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof s=="string"&&n("a11y.txt",s);let l=await i("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof l=="string"&&n("tree.txt",l);let u=await i(`(() => {
|
|
424
424
|
const c = window.__sootsimConsole
|
|
425
425
|
return {
|
|
426
426
|
errors: c?.getErrors?.() ?? [],
|
|
427
427
|
warnings: c?.getWarnings?.() ?? [],
|
|
428
428
|
requests: (window.__sootsimGetFailedRequests?.() ?? []),
|
|
429
429
|
}
|
|
430
|
-
})()`);return u&&
|
|
430
|
+
})()`);return u&&n("console.json",JSON.stringify(u,null,2)),e}async swipe(e="UP",t=300){let n=te/2,i=N/2,o=200,a=n,s=i,l=n,u=i;switch(e.toUpperCase()){case"UP":s+=o,u-=o;break;case"DOWN":s-=o,u+=o;break;case"LEFT":a+=o,l-=o;break;case"RIGHT":a-=o,l+=o;break}let p=Math.max(10,Math.round(t/16));await this.drag(a,s,l,u,p,16)}async drag(e,t,n,i,o=12,a=16){if(!(await this.evaluate(`(async () => {
|
|
431
431
|
const interact = window.__sootsimInteract
|
|
432
432
|
if (!interact?.drag) return { ok: false }
|
|
433
|
-
const value = await interact.drag(${e}, ${t}, ${
|
|
433
|
+
const value = await interact.drag(${e}, ${t}, ${n}, ${i}, ${Math.max(1,Math.round(o))}, ${Math.max(0,Math.round(a))})
|
|
434
434
|
return { ok: !!value, value }
|
|
435
|
-
})()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,
|
|
435
|
+
})()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,n=300){let i=ee(e),o=ee(t),a=Math.max(10,Math.round(n/16));await this.drag(i.x,i.y,o.x,o.y,a,16)}async swipeFrom(e,t="UP",n=300){let i=await this.findElement(e);if(!i)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let o=i.absolutePosition.x+i.layout.width/2,a=i.absolutePosition.y+i.layout.height/2,s=180,l=o,u=a;switch(t.toUpperCase()){case"UP":u-=s;break;case"DOWN":u+=s;break;case"LEFT":l-=s;break;case"RIGHT":l+=s;break}let p=Math.max(10,Math.round(n/16));await this.drag(o,a,l,u,p,16)}async scrollTo(e,t,n){let i=await this.callTest("scrollTo",e,t,n,!1);if(!i?.ok)throw new Error(`scrollTo failed: ${i?.reason||"unknown error"}`);await f(250)}async pinch(e){let t=await this.evaluate(`(async () => {
|
|
436
436
|
const interact = window.__sootsimInteract
|
|
437
437
|
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
438
438
|
const ok = await interact.pinch(
|
|
@@ -441,7 +441,7 @@ process.stdin.on('end', async () => {
|
|
|
441
441
|
${e.steps||12}, ${e.stepMs||16}
|
|
442
442
|
)
|
|
443
443
|
return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
|
|
444
|
-
})()`);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){let t=Math.max(0,Math.round(e));if(t<=0)return;(await Se({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:32,stablePolls:2,strict:!0})).settled&&this.markVisualSettled()}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),
|
|
444
|
+
})()`);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){let t=Math.max(0,Math.round(e));if(t<=0)return;(await Se({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:32,stablePolls:2,strict:!0})).settled&&this.markVisualSettled()}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),n=e.direction?.toUpperCase()||"DOWN",i=n==="DOWN"?"UP":n==="UP"?"DOWN":n;for(;Date.now()<t;){let o=await this.findElement({text:e.element});if(o&&o.absolutePosition.y>=0&&o.absolutePosition.y+o.layout.height>0&&o.absolutePosition.y<N-50){if(e.centerElement){let a=N/2,s=o.absolutePosition.y-a;if(Math.abs(s)>100){let l=Math.min(150,Math.abs(s)*.5),u=s>0?a-l:a+l;await this.drag(te/2,a,te/2,u,10,16)}}return}await this.swipe(i,250),await f(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+Ee(e.timeout||Q);for(;Date.now()<t;){let n=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,i=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(n&&i)return;await f(200)}throw new Error("extendedWaitUntil timed out")}async reloadGuestApp(e){if(e){let i=!1;for(let o=0;o<3&&!i;o++)try{i=await this.evaluate(me(!0),2e4)}catch{await f(1e3)}i||console.warn(" warn: tenant storage clear did not ack \u2014 hard-reloading anyway (worker reset follows)")}await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId()}async softReloadGuestApp(e){if(!await this.evaluate(me(e),12e4))throw new Error("guest app soft reload bridge unavailable")}async rearmCaptureAfterRuntimeReload(){if(!this.recordingEnabled&&!this.profilingEnabled)return;let e=Date.now()+1e4,t=null;for(;Date.now()<e;){await this.refreshSimId();try{this.recordingEnabled&&await this.ensureRecordingStarted(),this.profilingEnabled&&await this.startProfile();return}catch(n){t=n,await f(250)}}throw new Error(`capture re-arm failed after app reload: ${t instanceof Error?t.message:String(t)}`)}async launchApp(e){await this.refreshSimId(),e&&typeof e=="object"&&e.arguments&&console.log("[flow] launchApp.arguments ignored (sootsim has no native process)");let t=!!(e&&typeof e=="object"&&e.clearState),n=Ct(e,"resetRuntime");if(!this.firstLaunchDone&&!t){if(this.firstLaunchDone=!0,n){let i=await J(this.bridge).catch(()=>null),o=i?.state==="home"&&i.activeApp==null;await this.softReloadGuestApp(!1),await this.waitForTree(12e4),o&&(await fe(this.bridge,"goHome",1e3),await this.waitForShellHome(1e3)),await this.launchShellAppFromHomeIfNeeded(e,o?{...i??{},state:"home",activeApp:null}:null)}else await this.launchShellAppFromHomeIfNeeded(e);await this.waitForTree(3e4)}else if(this.firstLaunchDone=!0,await this.reloadGuestApp(t),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) => {
|
|
445
445
|
requestAnimationFrame(() => {
|
|
446
446
|
requestAnimationFrame(() => {
|
|
447
447
|
requestAnimationFrame(() => {
|
|
@@ -449,7 +449,7 @@ process.stdin.on('end', async () => {
|
|
|
449
449
|
})
|
|
450
450
|
})
|
|
451
451
|
})
|
|
452
|
-
})`),this.markVisualSettled()}catch{await f(180),this.markVisualSettled()}}markVisualSettled(){this.lastVisualSettledAtMs=Date.now()}hasFreshVisualSettle(){return Date.now()-this.lastVisualSettledAtMs<750}resolveShellLaunchAppId(e,t){if(typeof e=="string"&&e.length>0)return e;if(
|
|
452
|
+
})`),this.markVisualSettled()}catch{await f(180),this.markVisualSettled()}}markVisualSettled(){this.lastVisualSettledAtMs=Date.now()}hasFreshVisualSettle(){return Date.now()-this.lastVisualSettledAtMs<750}resolveShellLaunchAppId(e,t){if(typeof e=="string"&&e.length>0)return e;if(Ie(e)){let n=z(e,"appId")||z(e,"id");if(n)return n}return Nt(t)||"connect"}async waitForShellAppLaunched(e,t){let n=Date.now()+t,i=null;for(;Date.now()<n;){try{i=await J(this.bridge)}catch{i=null}if(i?.state==="app"&&i.activeApp===e&&i.showSwitcher===!1&&typeof i.launchProgress=="number"&&i.launchProgress>=.98)return;await f(16)}}async waitForShellHome(e){let t=Date.now()+e;for(;Date.now()<t;){let n=await J(this.bridge).catch(()=>null);if(n?.state==="home"&&n.activeApp==null&&n.showSwitcher===!1)return;await f(16)}}async launchShellAppFromHomeIfNeeded(e,t){let n=null;if(t)n=t;else try{n=await J(this.bridge)}catch{return!1}if(n?.state!=="home"||n.activeApp!=null)return!1;let i=this.resolveShellLaunchAppId(e,n);return this.recordingEnabled&&await this.ensureRecordingStarted(),await fe(this.bridge,"launchApp",1e3,i),await this.waitForShellAppLaunched(i,1e3),!0}async startProfile(){let e=await this.evaluate(`(() => {
|
|
453
453
|
if (!window.__sootsimShellPerf) {
|
|
454
454
|
return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
|
|
455
455
|
}
|
|
@@ -460,7 +460,7 @@ process.stdin.on('end', async () => {
|
|
|
460
460
|
return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
|
|
461
461
|
}
|
|
462
462
|
return await window.__sootsimShellPerf.stop()
|
|
463
|
-
})()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(!1),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.reloadGuestApp(!0),await this.rearmCaptureAfterRuntimeReload()}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 n=i.text??i.testID??"";this.js.setCopiedText(n),this.js.putEnv("maestroCopiedText",n),console.log(`[flow] copied text: ${JSON.stringify(n)}`)}evalScript(e){let i=/(?<!\\)\$\{[^$]*\}/.test(e)?this.js.evaluateStringTemplate(e):this.js.evaluate(e);i!==void 0&&i!==""&&console.log("[flow] evalScript ->",i)}runScript(e){let t=typeof e=="string"?{file:e}:e;if(!t.file)throw new Error("runScript requires a file");let i=b.resolve(this.opts.flowDir,t.file),n=S.readFileSync(i,"utf8");this.js.evaluate(n,{env:t.env}),console.log(`[flow] runScript: ${t.file} done`)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");let i=await this.callTest("openDeepLink",t);if(!i?.ok)throw new Error(`openLink failed: ${i?.error||"no test bridge"}`);await f(300)}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()===this.js.maestro.platform.toLowerCase():e.true!==void 0?lt(e.true):!0}isOptional(e){if(e.optional===!0)return!0;let i=Object.entries(e).find(([o])=>o!=="when"&&o!=="optional"),n=i?i[1]:void 0;return!!(n&&typeof n=="object"&&"optional"in n&&n.optional)}async runStep(e,t){let i=typeof e=="string"?ct(e):e,n=Object.keys(i).find(l=>l!=="when")||Object.keys(i)[0];console.log(`[flow] step ${t+1}: ${n}`);let o=Date.now(),a=this.flowStepTargetLabel(i,n),s;try{s=this.js.interpolateStep(i),a=this.flowStepTargetLabel(s,n)??a}catch(l){if(this.isOptional(i)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:n,target:i[n]},this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}if(s.when&&!await this.evaluateWhen(s.when)){console.log("[flow] (when: predicate false, skipped)"),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"skipped"});return}try{let l=!!(s.extendedWaitUntil||s.waitFor||s.scrollUntilVisible||s.launchApp||s.runFlow||s.runScript),u=1e4,p=this.runStepInner(s),g;if(l){let m=await p;typeof m=="string"&&(g=m)}else{let m=null,P=new Promise((k,re)=>{m=setTimeout(()=>{re(new Error(`step watchdog: ${n} made no progress in ${u}ms \u2014 bridge or bundle probably hung`))},u)});try{let k=await Promise.race([p,P]);typeof k=="string"&&(g=k)}finally{m&&clearTimeout(m)}}let F=!!(s.assertVisible||s.assertNotVisible||s.extendedWaitUntil||s.waitFor);this.stepDelay>0&&!F&&await f(this.stepDelay),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"success",screenshotPath:g})}catch(l){if(this.isOptional(s)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:n,target:s[n]},this.recordFlowTraceStep({stepIndex:t,stepName:n,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.longPressOn)await this.longPressOn(e.longPressOn);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)return this.takeScreenshot(e.takeScreenshot);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){let t=e.waitForAnimationToEnd;await this.waitForAnimationToEnd(typeof t=="number"?t:typeof t=="object"&&typeof t.timeout=="number"?t.timeout: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&&Array.isArray(e.repeat.commands)){let t=e.repeat.times,i=t==null||t===""?Number.MAX_SAFE_INTEGER:Number(t);if(!Number.isFinite(i))throw new Error(`repeat.times is not a number: ${t}`);let n=e.repeat.when??e.repeat.condition,o=async()=>n?this.evaluateWhen(n):!0,a=n?i:Math.min(i,1e3),s=0;for(;s<a&&await o();){for(let l=0;l<e.repeat.commands.length;l++)await this.runStep(e.repeat.commands[l],l);s++}}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")this.evalScript(e.evalScript);else if(e.runScript){let t=e.runScript,i=typeof t=="string"?void 0:t.when;if(i&&!await this.evaluateWhen(i)){console.log("[flow] runScript skipped (when predicate false)");return}this.runScript(t)}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,n=typeof t=="string"?void 0:t.commands,o=typeof t=="string"?void 0:t.env,a=typeof t=="string"?void 0:t.when;if(a&&!await this.evaluateWhen(a)){console.log(`[flow] runFlow skipped (when predicate false): ${i??"inline commands"}`);return}if(!i&&!n)throw new Error("runFlow requires either file or commands");this.js.enterEnvScope();try{if(o)for(let[s,l]of Object.entries(o))this.js.putEnv(s,l);if(i){let s=b.resolve(this.opts.flowDir,i),l=S.readFileSync(s,"utf8"),u=this.opts.flowDir;this.opts.flowDir=b.dirname(s);try{await this.runFlow(jt(l))}finally{this.opts.flowDir=u}}else if(n)for(let s=0;s<n.length;s++)await this.runStep(n[s],s)}finally{this.js.leaveEnvScope()}}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}}liveStatus=null;async runFlow(e){let t=[],i=[],n=[];for(let a of e){let s=Object.keys(a);if(s.length===1&&s[0]==="onFlowStart"&&Array.isArray(a.onFlowStart)){t.push(...a.onFlowStart);continue}if(s.length===1&&s[0]==="onFlowComplete"&&Array.isArray(a.onFlowComplete)){i.push(...a.onFlowComplete);continue}n.push(a)}if(this.liveStatus&&await this.liveStatus.plan(n.map((a,s)=>{let l=typeof a=="string"?ct(a):a,u=Object.keys(l).find(p=>p!=="when")??Object.keys(l)[0];return{index:s,name:u,target:this.flowStepTargetLabel(l,u)}})),t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let a=0;a<t.length;a++)await this.runStep(t[a],a)}let o=null;try{await this.runFlowBody(n)}catch(a){o=a instanceof Error?a:new Error(String(a))}if(i.length>0){console.log(`[flow] onFlowComplete (${i.length} steps)`);for(let a=0;a<i.length;a++)try{await this.runStep(i[a],a)}catch(s){console.warn(`[flow] onFlowComplete step ${a+1} failed: ${s instanceof Error?s.message:s}`)}}if(o)throw o}async runFlowBody(e){for(let t=0;t<e.length;t++){let i=e[t],n=typeof i.wait=="number"?i.wait:0,o=typeof i.waitFor?.timeout=="number"?i.waitFor.timeout:0,a=Math.max(6e4,n+15e3,o+15e3);this.liveStatus&&(await this.liveStatus.waitWhilePaused(),await this.liveStatus.step(t,"running"));let s=Date.now(),l=async(u,p)=>{if(!this.liveStatus)return;let g=this.flowTraceSteps[this.flowTraceSteps.length-1],F=g&&g.stepIndex===t&&g.startedAtMs>=s;await this.liveStatus.step(t,u?"failure":F&&g.status==="skipped"?"skipped":"success",{durationMs:Date.now()-s,error:u?p instanceof Error?p.message.slice(0,300):String(p).slice(0,300):F&&g.error||void 0})};try{i.runFlow||i.launchApp?await this.runStep(i,t):await Promise.race([this.runStep(i,t),new Promise((u,p)=>setTimeout(()=>p(new Error(`step ${t+1} (${Object.keys(i)[0]}) exceeded ${a}ms deadline`)),a))])}catch(u){throw await l(!0,u),u}await l(!1)}}};function Ut(r){if(typeof r!="object"||r==null||!("control"in r))return!1;let e=r.control;return typeof e=="object"&&e!=null&&"paused"in e&&e.paused===!0}var ne=class{constructor(e,t,i){this.bridge=e;this.flowName=t;this.getSimId=i}disabled=!1;paused=!1;lastSimId;plannedSteps=null;completedSteps=new Map;runId=`flr_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;async send(e,t){let i=await this.bridge.send({type:"flowStatus",simId:t,status:{runId:this.runId,flowName:this.flowName,...e}});this.paused=Ut(i)}async push(e){if(!this.disabled)try{let t=this.getSimId?.();if(t!==this.lastSimId&&this.lastSimId!=null&&this.plannedSteps&&e.phase!=="plan"){await this.send({phase:"plan",state:"running",steps:this.plannedSteps},t);for(let i of this.completedSteps.values())await this.send({phase:"step",state:"running",step:i},t)}this.lastSimId=t,await this.send(e,t)}catch(t){this.disabled=!0,console.log(`[flow] live status unavailable (${t instanceof Error?t.message.slice(0,120):t}) \u2014 continuing without the devtools rail`)}}async plan(e){this.plannedSteps=e.map(t=>({...t})),this.completedSteps.clear(),await this.push({phase:"plan",state:"running",steps:e})}async step(e,t,i){let n={index:e,status:t,...i};await this.push({phase:"step",state:"running",step:n}),this.completedSteps.set(e,n)}async end(e){await this.push({phase:"end",state:e})}async waitWhilePaused(){if(!this.disabled)for(;this.paused;){for(console.log("[flow] paused from devtools \u2014 waiting\u2026");this.paused&&!this.disabled;)await new Promise(e=>setTimeout(e,400)),await this.push({phase:"heartbeat",state:"paused"});this.disabled||console.log("[flow] resumed")}}};var Fe=null;function Di(){return Fe}var Ie=[];function Bi(){return Ie}async function Jt(r){if(!r)return"";let e=r.trim();if(!e)return"";if(/^\d+$/.test(e)||e.startsWith("http://")||e.startsWith("https://"))return e;let i=(await Ce()).find(n=>n.name.toLowerCase()===e.toLowerCase());return i?String(i.preferredPort):e}async function Gt(){let r=await He(),e=r.find(i=>i.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=r[0];return t?`http://localhost:${t.port}/__soot/`:null}async function ut(r){Fe=null,Ie=[],(r.length===0||r.includes("--help")||r.includes("-h"))&&(console.log(`
|
|
463
|
+
})()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(!1),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.reloadGuestApp(!0),await this.rearmCaptureAfterRuntimeReload()}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,n=await this.findElement(t);if(!n)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let i=n.text??n.testID??"";this.js.setCopiedText(i),this.js.putEnv("maestroCopiedText",i),console.log(`[flow] copied text: ${JSON.stringify(i)}`)}evalScript(e){let n=/(?<!\\)\$\{[^$]*\}/.test(e)?this.js.evaluateStringTemplate(e):this.js.evaluate(e);n!==void 0&&n!==""&&console.log("[flow] evalScript ->",n)}runScript(e){let t=typeof e=="string"?{file:e}:e;if(!t.file)throw new Error("runScript requires a file");let n=b.resolve(this.opts.flowDir,t.file),i=S.readFileSync(n,"utf8");this.js.evaluate(i,{env:t.env}),console.log(`[flow] runScript: ${t.file} done`)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");let n=await this.callTest("openDeepLink",t);if(!n?.ok)throw new Error(`openLink failed: ${n?.error||"no test bridge"}`);await f(300)}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()===this.js.maestro.platform.toLowerCase():e.true!==void 0?ct(e.true):!0}isOptional(e){if(e.optional===!0)return!0;let n=Object.entries(e).find(([o])=>o!=="when"&&o!=="optional"),i=n?n[1]:void 0;return!!(i&&typeof i=="object"&&"optional"in i&&i.optional)}async runStep(e,t){let n=typeof e=="string"?dt(e):e,i=Object.keys(n).find(l=>l!=="when")||Object.keys(n)[0];console.log(`[flow] step ${t+1}: ${i}`);let o=Date.now(),a=this.flowStepTargetLabel(n,i),s;try{s=this.js.interpolateStep(n),a=this.flowStepTargetLabel(s,i)??a}catch(l){if(this.isOptional(n)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:i,target:n[i]},this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}if(s.when&&!await this.evaluateWhen(s.when)){console.log("[flow] (when: predicate false, skipped)"),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped"});return}try{let l=!!(s.extendedWaitUntil||s.waitFor||s.scrollUntilVisible||s.launchApp||s.runFlow||s.runScript),u=1e4,p=this.runStepInner(s),g;if(l){let m=await p;typeof m=="string"&&(g=m)}else{let m=null,P=new Promise((k,re)=>{m=setTimeout(()=>{re(new Error(`step watchdog: ${i} made no progress in ${u}ms \u2014 bridge or bundle probably hung`))},u)});try{let k=await Promise.race([p,P]);typeof k=="string"&&(g=k)}finally{m&&clearTimeout(m)}}let I=!!(s.assertVisible||s.assertNotVisible||s.extendedWaitUntil||s.waitFor);this.stepDelay>0&&!I&&await f(this.stepDelay),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"success",screenshotPath:g})}catch(l){if(this.isOptional(s)){console.log(`[flow] (optional, skipped: ${l.message.slice(0,80)})`),this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"skipped",error:l});return}throw this.lastFailedStep={index:t,kind:i,target:s[i]},this.recordFlowTraceStep({stepIndex:t,stepName:i,targetLabel:a,startedAtMs:o,status:"failure",error:l}),l}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.longPressOn)await this.longPressOn(e.longPressOn);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)return this.takeScreenshot(e.takeScreenshot);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){let t=e.waitForAnimationToEnd;await this.waitForAnimationToEnd(typeof t=="number"?t:typeof t=="object"&&typeof t.timeout=="number"?t.timeout: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&&Array.isArray(e.repeat.commands)){let t=e.repeat.times,n=t==null||t===""?Number.MAX_SAFE_INTEGER:Number(t);if(!Number.isFinite(n))throw new Error(`repeat.times is not a number: ${t}`);let i=e.repeat.when??e.repeat.condition,o=async()=>i?this.evaluateWhen(i):!0,a=i?n:Math.min(n,1e3),s=0;for(;s<a&&await o();){for(let l=0;l<e.repeat.commands.length;l++)await this.runStep(e.repeat.commands[l],l);s++}}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")this.evalScript(e.evalScript);else if(e.runScript){let t=e.runScript,n=typeof t=="string"?void 0:t.when;if(n&&!await this.evaluateWhen(n)){console.log("[flow] runScript skipped (when predicate false)");return}this.runScript(t)}else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,n=typeof t=="string"?t:t.file,i=typeof t=="string"?void 0:t.commands,o=typeof t=="string"?void 0:t.env,a=typeof t=="string"?void 0:t.when;if(a&&!await this.evaluateWhen(a)){console.log(`[flow] runFlow skipped (when predicate false): ${n??"inline commands"}`);return}if(!n&&!i)throw new Error("runFlow requires either file or commands");this.js.enterEnvScope();try{if(o)for(let[s,l]of Object.entries(o))this.js.putEnv(s,l);if(n){let s=b.resolve(this.opts.flowDir,n),l=S.readFileSync(s,"utf8"),u=this.opts.flowDir;this.opts.flowDir=b.dirname(s);try{await this.runFlow(jt(l))}finally{this.opts.flowDir=u}}else if(i)for(let s=0;s<i.length;s++)await this.runStep(i[s],s)}finally{this.js.leaveEnvScope()}}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}}liveStatus=null;async runFlow(e){let t=[],n=[],i=[];for(let a of e){let s=Object.keys(a);if(s.length===1&&s[0]==="onFlowStart"&&Array.isArray(a.onFlowStart)){t.push(...a.onFlowStart);continue}if(s.length===1&&s[0]==="onFlowComplete"&&Array.isArray(a.onFlowComplete)){n.push(...a.onFlowComplete);continue}i.push(a)}if(this.liveStatus&&await this.liveStatus.plan(i.map((a,s)=>{let l=typeof a=="string"?dt(a):a,u=Object.keys(l).find(p=>p!=="when")??Object.keys(l)[0];return{index:s,name:u,target:this.flowStepTargetLabel(l,u)}})),t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let a=0;a<t.length;a++)await this.runStep(t[a],a)}let o=null;try{await this.runFlowBody(i)}catch(a){o=a instanceof Error?a:new Error(String(a))}if(n.length>0){console.log(`[flow] onFlowComplete (${n.length} steps)`);for(let a=0;a<n.length;a++)try{await this.runStep(n[a],a)}catch(s){console.warn(`[flow] onFlowComplete step ${a+1} failed: ${s instanceof Error?s.message:s}`)}}if(o)throw o}async runFlowBody(e){for(let t=0;t<e.length;t++){let n=e[t],i=typeof n.wait=="number"?n.wait:0,o=typeof n.waitFor?.timeout=="number"?n.waitFor.timeout:0,a=Math.max(6e4,i+15e3,o+15e3);this.liveStatus&&(await this.liveStatus.waitWhilePaused(),await this.liveStatus.step(t,"running"));let s=Date.now(),l=async(u,p)=>{if(!this.liveStatus)return;let g=this.flowTraceSteps[this.flowTraceSteps.length-1],I=g&&g.stepIndex===t&&g.startedAtMs>=s;await this.liveStatus.step(t,u?"failure":I&&g.status==="skipped"?"skipped":"success",{durationMs:Date.now()-s,error:u?p instanceof Error?p.message.slice(0,300):String(p).slice(0,300):I&&g.error||void 0})};try{n.runFlow||n.launchApp?await this.runStep(n,t):await Promise.race([this.runStep(n,t),new Promise((u,p)=>setTimeout(()=>p(new Error(`step ${t+1} (${Object.keys(n)[0]}) exceeded ${a}ms deadline`)),a))])}catch(u){throw await l(!0,u),u}await l(!1)}}};function Vt(r){if(typeof r!="object"||r==null||!("control"in r))return!1;let e=r.control;return typeof e=="object"&&e!=null&&"paused"in e&&e.paused===!0}var ie=class{constructor(e,t,n){this.bridge=e;this.flowName=t;this.getSimId=n}disabled=!1;paused=!1;lastSimId;plannedSteps=null;completedSteps=new Map;runId=`flr_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;async send(e,t){let n=await this.bridge.send({type:"flowStatus",simId:t,status:{runId:this.runId,flowName:this.flowName,...e}});this.paused=Vt(n)}async push(e){if(!this.disabled)try{let t=this.getSimId?.();if(t!==this.lastSimId&&this.lastSimId!=null&&this.plannedSteps&&e.phase!=="plan"){await this.send({phase:"plan",state:"running",steps:this.plannedSteps},t);for(let n of this.completedSteps.values())await this.send({phase:"step",state:"running",step:n},t)}this.lastSimId=t,await this.send(e,t)}catch(t){this.disabled=!0,console.log(`[flow] live status unavailable (${t instanceof Error?t.message.slice(0,120):t}) \u2014 continuing without the devtools rail`)}}async plan(e){this.plannedSteps=e.map(t=>({...t})),this.completedSteps.clear(),await this.push({phase:"plan",state:"running",steps:e})}async step(e,t,n){let i={index:e,status:t,...n};await this.push({phase:"step",state:"running",step:i}),this.completedSteps.set(e,i)}async end(e){await this.push({phase:"end",state:e})}async waitWhilePaused(){if(!this.disabled)for(;this.paused;){for(console.log("[flow] paused from devtools \u2014 waiting\u2026");this.paused&&!this.disabled;)await new Promise(e=>setTimeout(e,400)),await this.push({phase:"heartbeat",state:"paused"});this.disabled||console.log("[flow] resumed")}}};var Fe=null;function Cn(){return Fe}var $e=[];function Nn(){return $e}async function zt(r){if(!r)return"";let e=r.trim();if(!e)return"";if(/^\d+$/.test(e)||e.startsWith("http://")||e.startsWith("https://"))return e;let n=(await He()).find(i=>i.name.toLowerCase()===e.toLowerCase());return n?String(n.preferredPort):e}async function Kt(){let r=await Ue(),e=r.find(n=>n.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=r[0];return t?`http://localhost:${t.port}/__soot/`:null}async function pt(r){Fe=null,$e=[],(r.length===0||r.includes("--help")||r.includes("-h"))&&(console.log(`
|
|
464
464
|
sootsim maestro \u2014 author and run Maestro YAML flows
|
|
465
465
|
|
|
466
466
|
usage:
|
|
@@ -540,28 +540,28 @@ flow extension:
|
|
|
540
540
|
takeScreenshot:
|
|
541
541
|
path: marketing/hero
|
|
542
542
|
withFrame: true
|
|
543
|
-
`),process.exit(0));let e=r[0];$.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=h=>r.find((c,y)=>r[y-1]===h),
|
|
543
|
+
`),process.exit(0));let e=r[0];$.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=h=>r.find((c,y)=>r[y-1]===h),n=r.includes("--profile"),i=r.includes("--headed"),o=r.includes("--new")||i,a=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||(t("--out")?a:"/tmp/sootsim-flow"),l=t("--screenshot-paths")==="flow"?"flow":"dir",u=r.includes("--no-shell")?"tenant":r.includes("--shell-only")?"shell":void 0,p=t("--device")?.trim()||"",g=r.includes("--slow")?+(t("--slow")||"500"):0,I=r.includes("--electron"),m=r.includes("--preview"),P=await it(t("--preview-origin")),k=t("--preview-public-origin"),re=r.includes("--preview-open"),Pe=t("--owner")?.trim()||"",ke=t("--repo")?.trim()||"",H=t("--billing-kind")?.trim()||"",ht=m?`maestro:${process.env.GITHUB_RUN_ID?`github:${process.env.GITHUB_RUN_ID}:attempt:${process.env.GITHUB_RUN_ATTEMPT||"1"}:job:${process.env.GITHUB_JOB||"preview"}`:`local:${Gt()}`}:flow:${Jt("sha256").update(w.relative(process.cwd(),w.resolve(e))).digest("hex").slice(0,16)}`:"";H&&H!=="test_run"&&(console.error(` error: invalid --billing-kind: ${H}`),process.exit(1));let ft=r.flatMap((h,c)=>r[c-1]==="--replace"?["--replace",h]:[]),mt=r.flatMap((h,c)=>r[c-1]==="--remap"?["--remap",h]:[]),M=r.includes("--record")||m,gt=r.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):M?m?6e3:2e3:0,wt=$.readFileSync(e,"utf8"),{frontmatter:x,steps:R}=ge(wt);R.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let U=p||x.device||"",Ae=x.theme||"",q=I||x.electron===!0,yt=x.app===void 0||x.app===null?"":typeof x.app=="number"?String(x.app):x.app,oe=await zt(yt),Me={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless","--headed"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--remap","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver","--billing-kind","--owner","--repo"]},v=pe(r,Me),bt=t("--url")||"";q&&!Ke()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let Re=q?"desktop companion":"bridge",St=oe?` | target: ${oe}`:"";console.log(`
|
|
544
544
|
sootsim maestro \u2014 ${w.basename(e)}
|
|
545
|
-
${R.length} steps | ${
|
|
546
|
-
`),m&&
|
|
545
|
+
${R.length} steps | ${Re}${St}${M?" | recording":""}${n?" | profiling":""}${g?` | ${g}ms delay`:""}
|
|
546
|
+
`),m&&Be({event:"preview_flow_started",properties:{flowName:w.basename(e),stepCount:R.length,mode:Re,electron:q,record:M,profile:n,previewOrigin:P}});let A=bt||oe||"",se=o||q&&v.simIdSource!=="flag",Oe=t("--driver")||"",ae=!1,le=new Set,_e=!1;if(!A&&!se&&v.simIdSource==="none"){let h=Ge(v);try{let c=await h.listSims(),y=c.find(D=>D.isPrimary&&D.readyState==="open"),F=c.find(D=>D.readyState==="open"),V=y??F;V&&(_e=!0,console.log(` reusing active sim: ${V.id}`))}catch{}finally{h.close()}}if(!A&&!_e&&(se||v.simIdSource==="none")){let h=await Kt();h||(console.error(" error: no current sim and no sootsim target found"),await de(),process.exit(1)),A=h}if(A&&U){let h=new URL(await qe(A));h.searchParams.set("device",U),A=h.toString()}if(A){let h=[A];if(h.push(...ft),h.push(...mt),se&&h.push("--new"),h.push("--no-describe"),v.simIdSource==="flag"&&v.simId&&h.push("--sim",v.simId),Oe&&(h.push("--driver",Oe),ae=!0),r.includes("--headless")&&!i&&h.push("--headless"),await Ze(h,{port:v.wsPort,timeoutMs:v.commandTimeoutMs}),ae){let c=ue();c&&le.add(c)}}let B=pe(r,Me),Y=B.simIdSource==="flag"?B.simId:ue()||B.simId,vt=B.simIdSource==="flag"?"flag":Y?"saved":"none",T=he(B.wsPort,{commandTimeoutMs:B.commandTimeoutMs,simId:Y,simIdSource:vt}),d,De=async()=>{if(Ae&&await T.send({type:"call",simId:d.simId,path:"SootSim.bridges.settings.set",args:["colorScheme",Ae]}),!U)return!1;let h=await T.send({type:"evaluate",simId:d.simId,code:"window.location.href"});if(typeof h=="string"&&h.length>0){let c=new URL(h);c.searchParams.set("device",U),d.setSimRouteHint(c.toString())}return!!await T.send({type:"call",simId:d.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",U]})};if(d=new ne(T,{screenshotDir:s,flowDir:w.dirname(w.resolve(e)),screenshotPathMode:l,screenshotLayers:u,simId:Y,recordingOutputDir:M?a:void 0,recordingFormat:m?"mp4":"webm",billingOriginOverride:m?P:void 0,allowGitHubRecording:m,requireRecordingEntitlement:m,onAfterLaunch:async()=>{await De()&&await d.waitForTree(12e4),m&&await T.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
547
547
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
548
548
|
return r?.start?.() ?? false
|
|
549
|
-
})()`})}}),g&&(d.stepDelay=g),d.liveStatus=new
|
|
549
|
+
})()`})}}),g&&(d.stepDelay=g),d.liveStatus=new ie(T,w.basename(e),()=>d.simId),d.js.putEnv("MAESTRO_FILENAME",w.basename(e,w.extname(e))),x.env&&typeof x.env=="object")for(let[h,c]of Object.entries(x.env))d.js.putEnv(h,c);let O=null,E=null,L=null,_=null,W=null,ce=null,j=0,Z=!!R[0]?.launchApp;try{Z||await d.waitForTree(12e4),await De()&&!Z&&await d.waitForTree(12e4),m&&!Z&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await d.launchApp({clearState:!0}),M&&(Z?d.prepareRecording():await d.startRecording()),n&&await d.startProfile(),m&&(await T.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
550
550
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
551
551
|
return r?.start?.() ?? false
|
|
552
|
-
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await d.runFlow(R),
|
|
552
|
+
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await d.runFlow(R),n&&(O=await d.stopProfile()),await d.waitForRecordingTail({maxMs:gt,smart:m}),M&&(E=await d.stopRecording(),L=d.getLastRecordingDurationMs()),m&&(_=await T.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
553
553
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
554
554
|
return r?.stop?.() ?? []
|
|
555
|
-
})()`}),console.log(` captured ${_.length} replay events`),
|
|
556
|
-
+ completed (${R.length} steps)`),c>0&&console.log(` screenshots: ${c} \u2192 ${s}`),O&&
|
|
555
|
+
})()`}),console.log(` captured ${_.length} replay events`),W=w.join(s,"preview-final.png"),await d.captureScreenshot(W),console.log(` final screenshot: ${W}`));let c=R.filter(y=>y&&typeof y=="object"&&"takeScreenshot"in y).length;console.log(`
|
|
556
|
+
+ completed (${R.length} steps)`),c>0&&console.log(` screenshots: ${c} \u2192 ${s}`),O&&ut(O),E&&console.log(` video: ${E}`),console.log()}catch(h){if(n&&!O)try{O=await d.stopProfile()}catch{}if(M&&!E)try{E=await d.stopRecording(),L=d.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}if(m&&!_)try{_=await T.send({type:"evaluate",simId:d.simId,code:`(() => {
|
|
557
557
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
558
558
|
return r?.stop?.() ?? []
|
|
559
559
|
})()`}),console.log(` captured ${_.length} partial replay events`)}catch(c){console.warn(` event recorder stop failed: ${c?.message||String(c)}`)}console.error(`
|
|
560
560
|
x failed: ${h.message}
|
|
561
|
-
`),O&&(console.log(" partial profile:"),
|
|
562
|
-
preparing preview upload\u2026`);let
|
|
561
|
+
`),O&&(console.log(" partial profile:"),ut(O)),E&&console.log(` partial video: ${E}`);try{let c=d.lastFailedStep,y=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",F=w.join(s,y);await d.captureFailureBundle(F,{error:h,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),ce=F,console.log(` failure bundle: ${F}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let y=w.join(s,"error.png");await d.captureScreenshot(y),console.log(` error screenshot: ${y}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await ze(T,{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}`:""}`}),j=1}if(await d.liveStatus?.end(j===0?"passed":"failed"),m&&(j===0||E||_))try{let h=await Yt(_??[]),c=["--origin",P,"--events",h];k&&c.push("--public-origin",k),E&&c.push("--video",E),W&&c.push("--screenshot",W),E&&L&&Number.isFinite(L)&&(c.push("--video-duration-ms",String(Math.round(L))),c.push("--recorded-duration-ms",String(Math.round(L))));let y=d.getLastRecordingStartedAtMs();y&&Number.isFinite(y)&&c.push("--recording-started-at-ms",String(Math.round(y))),v.wsPort&&c.push("--port",String(v.wsPort)),d.simId&&c.push("--sim",d.simId),re&&c.push("--open"),Pe&&c.push("--owner",Pe),ke&&c.push("--repo",ke),c.push("--run-scope",ht),H&&c.push("--billing-kind",H),console.log(`
|
|
562
|
+
preparing preview upload\u2026`);let F=d.getFlowTraceSteps();F.length>0&&c.push("--timeline-events",await Zt(F));let V=await Xt(F,y);V&&c.push("--snapshot-manifest",V),ce&&c.push("--failure-bundle",ce);let D=d.getLastRecordingFrameStats();D&&c.push("--trace-frame-stats",await Qt(D));let{runUpload:xt}=await import("./upload-WXQKH3QR.js");Fe=await xt(c,{})}catch(h){console.error(` preview upload failed: ${h?.message||h}`),j=1}return $e=d.getFlowTraceSteps(),T.close(),ae?(d.simId&&le.add(d.simId),await qt(v.wsPort,v.commandTimeoutMs,[...le])):d.simId&&d.simId!==Y&&Ne(d.simId),await de(),j}async function qt(r,e,t){let n=[...new Set(t.filter(Boolean))];if(n.length===0)return;let i=he(r,{commandTimeoutMs:e});try{let o=await i.listSims(),a=n.filter(l=>o.some(u=>u.id===l&&u.readyState==="open"));if(a.length===0)return;let s=await Xe(i,r,e,a);await Ye(o,a),s.closed.length>0&&console.log(` closed flow sim(s): ${s.closed.join(", ")}`),s.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${s.remaining.join(", ")}`)}catch(o){console.warn(` warn: failed to close flow sim(s): ${o instanceof Error?o.message:String(o)}`)}finally{i.close()}}async function Yt(r){let{gzipSync:e}=await import("zlib"),t=r.map(o=>JSON.stringify(o)).join(`
|
|
563
563
|
`)+(r.length?`
|
|
564
|
-
`:""),
|
|
564
|
+
`:""),n=e(Buffer.from(t,"utf8")),i=w.join(K(),`sootsim-events-${Date.now()}.jsonl.gz`);return $.writeFileSync(i,n),console.log(` events: ${r.length} written to ${i} (${n.length} bytes gz)`),i}async function Zt(r){let{gzipSync:e}=await import("zlib"),t=r.map((a,s)=>({schemaVersion:1,t:a.endedAtMs,seq:1e6+s,context:"host",kind:"flow-step",id:`flow-step-${a.stepIndex}`,data:{stepIndex:a.stepIndex,stepNumber:a.stepIndex+1,stepName:a.stepName,...a.targetLabel?{targetLabel:a.targetLabel}:{},status:a.status,durationMs:a.durationMs,startedAtMs:a.startedAtMs,endedAtMs:a.endedAtMs,...a.error?{error:a.error}:{}}})),n=t.map(a=>JSON.stringify(a)).join(`
|
|
565
565
|
`)+`
|
|
566
|
-
`,
|
|
567
|
-
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=u;return}ye(),console.log(` flow draft validated (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath&&console.log(` saved: ${s.outputPath}`),o&&console.log(" video: recorded during validation run");return}if(ye(),console.log(` flow draft ended (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath){console.log(` saved: ${s.outputPath}`),console.log(` next: sootsim maestro test ${s.outputPath} --record`);return}console.log(""),process.stdout.write(s.yaml);return}case"validate":{let
|
|
566
|
+
`,i=e(Buffer.from(n,"utf8")),o=w.join(K(),`sootsim-flow-steps-${Date.now()}.jsonl.gz`);return $.writeFileSync(o,i),console.log(` flow trace: ${t.length} step events written to ${o} (${i.length} bytes gz)`),o}async function Xt(r,e){if(!e)return null;let t=r.flatMap(i=>i.screenshotPath?[{id:`flow-step-${i.stepIndex}`,label:i.targetLabel??`Step ${i.stepIndex+1}`,kind:"interaction",t:Math.max(0,i.endedAtMs-e),path:i.screenshotPath}]:[]);if(t.length===0)return null;let n=w.join(K(),`sootsim-flow-snapshots-${Date.now()}.json`);return $.writeFileSync(n,JSON.stringify(t)),console.log(` flow snapshots: ${t.length} written to ${n}`),n}async function Qt(r){let e=w.join(K(),`sootsim-frame-stats-${Date.now()}.json`);return $.writeFileSync(e,JSON.stringify(r)),console.log(` frame stats: written to ${e}`),e}async function en(r){let e=r[0],t=n=>r.find((i,o)=>r[o-1]===n);switch(e){case"start":{let{path:n,state:i}=et();console.log(" flow draft started"),console.log(` session: ${n}`),console.log(` steps: ${i.steps.length}`);return}case"keep":case"good":{let n=be();if(n.active||(console.error(" no active flow draft \u2014 run `sootsim maestro start` first"),process.exit(1)),!n.kept){console.log(" no pending action to keep");return}console.log(` kept: ${n.candidate.summary}`),console.log(` steps: ${n.stepCount}`);return}case"end":{let n=t("--output")||(r[1]&&!r[1].startsWith("-")?r[1]:void 0),i=r.includes("--validate")||r.includes("--video"),o=r.includes("--video"),a=be();a.active&&a.kept&&console.log(` auto-kept trailing action: ${a.candidate.summary}`);let s=tt(n||(i?nn():void 0));if(s.active||(console.error(" no active flow draft \u2014 run `sootsim maestro start` first"),process.exit(1)),!s.valid){console.error(" flow draft is not valid:");for(let l of s.issues)console.error(` - ${l}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim maestro start` to reset"),process.exit(1)}if(i){let l=rn(r,s.outputPath),u=await pt(l);if(u!==0){console.error(`
|
|
567
|
+
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=u;return}ye(),console.log(` flow draft validated (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath&&console.log(` saved: ${s.outputPath}`),o&&console.log(" video: recorded during validation run");return}if(ye(),console.log(` flow draft ended (${s.stepCount} step${s.stepCount===1?"":"s"})`),s.outputPath){console.log(` saved: ${s.outputPath}`),console.log(` next: sootsim maestro test ${s.outputPath} --record`);return}console.log(""),process.stdout.write(s.yaml);return}case"validate":{let n=r[1];(!n||n.startsWith("-"))&&(console.error(" usage: sootsim maestro validate <path>"),process.exit(1));let i=we(n);if(i.length>0){console.error(` x ${n} failed validation:`);for(let o of i)console.error(` - ${o}`);process.exit(1)}console.log(` + ${n} looks valid`);return}}}function tn(r){return r[0]==="--sim"&&r.length>=2?[...r.slice(2),"--sim",r[1]]:r}async function Hn(r){let e=tn(r),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await en(e),0;let n=await pt(e);return n!==0&&(process.exitCode=n),n}function ut(r){console.log(""),nt(r)}function nn(){return w.join(K(),`sootsim-flow-draft-${Date.now()}.yaml`)}function rn(r,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let n=1;n<r.length;n++){let i=r[n];if(!(i==="--validate"||i==="--video")){if(i==="--output"){n+=1;continue}n===1&&!i.startsWith("-")||t.push(i)}}return!t.includes("--record")&&r.includes("--video")&&t.push("--record"),t}export{at as a,At as b,Cn as c,Nn as d,Kt as e,pt as f,tn as g,Hn as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{h as w,j as u,k as m,l}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.224 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{h as w,j as u,k as m,l}from"./chunk-NWLTJUCZ.js";var p="sootsim:settings",v=["errorReporting","colorScheme","a11yMode","a11yDepth","screenshotCanvas","screenshotBackground","screenshotText","screenshotPose","screenshotDynamicSize","alwaysShowLiveWebViews","agentProvider","onboardingComplete","betaConsentVersion","detailedTelemetry"];function S(){if(typeof window>"u")return null;let e=window.sootsimElectron;return e&&typeof e=="object"?e:null}function g(e){let t={};for(let n of v){if(!(n in e))continue;let r=e[n],o=u[n];o.validate&&!o.validate(r)||o.options&&!o.options.includes(r)||(t[n]=r)}return t}function h(e){let t={};for(let n of v)t[n]=e[n];return t}function _(){if(typeof localStorage>"u")return{};try{let e=localStorage.getItem(p);return e?g(JSON.parse(e)):{}}catch{return{}}}function V(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(p,JSON.stringify(h(e)))}catch{}}function E(){let t=S()?.sharedConfig?.settings;return!t||typeof t!="object"?{}:g(t)}function K(e){let t=S();if(t?.writeSharedConfig)try{t.writeSharedConfig({settings:h(e)})}catch{}}function b(){if(typeof window>"u")return null;let e=window.__sootsimSharedConfig;return e&&typeof e=="object"?e:null}function j(){let e=b()?.settings;return!e||typeof e!="object"?{}:g(e)}function D(e){if(!b())return;let t={settings:h(e)};try{if(globalThis.__sootsimBridgeRequest?.writeSharedConfig?.(t))return}catch{}if(!(typeof fetch>"u"))try{fetch("/__sootsim/shared-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}function k(){let e=_(),t=j(),n=E();return{...e,...t,...n}}function R(e){V(e),K(e),D(e)}function C(e){if(typeof window>"u")return()=>{};let t=i=>{if(!(i.key!==p||i.newValue==null))try{e(g(JSON.parse(i.newValue)))}catch{}};window.addEventListener("storage",t);let n=S(),r;n?.onSharedConfigChanged&&(r=n.onSharedConfigChanged(i=>{let d=i?.settings;!d||typeof d!="object"||e(g(d))}));let c=globalThis.__sootsimBridgeRequest?.subscribeSharedConfig?.(i=>{let d=i?.settings;!d||typeof d!="object"||e(g(d))});return()=>{window.removeEventListener("storage",t),r?.(),c?.()}}var M=l(),P=k();for(let e of Object.keys(m()))delete P[e];var s={...M,...P},f=[],a=null;function y(){for(let e of f)e();R(s)}C(e=>{let t={...s},n=!1;for(let[r,o]of Object.entries(e)){let c=r;t[c]!==o&&(t[c]=o,n=!0)}if(n){s=t,a=null;for(let r of f)r()}});var L={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"&&(a=null),y())},getAll(){return s},apply(e){let t=!1,n={...s};for(let[r,o]of Object.entries(e)){if(o===void 0)continue;let c=r,i=u[c];i&&(i.validate&&!i.validate(o)||i.options&&!i.options.includes(o)||n[c]!==o&&(n[c]=o,t=!0))}t&&(s=n,a=null,y())},reset(){s=l(),a=null,y()},subscribe(e){return f.push(e),()=>{f=f.filter(t=>t!==e)}},getDeviceSpec(){return a||(a=w(s.deviceModel)),a},getA11yMode(){return s.a11yMode},setA11yMode(e){this.set("a11yMode",e)},getInspectMode(){return s.inspectMode},setInspectMode(e){this.set("inspectMode",e)}};export{L as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{H as t,N as n,P as l,j as r}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.224 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{H as t,N as n,P as l,j as r}from"./chunk-K7FLRWXM.js";function m(){let e=t(),i=r()?n():null;return i&&l(i)?{primary:`engine dev source (:${i.bridgePort})`,installedRuntime:e?`installed runtime v${e}`:null,isDevBridge:!0}:{primary:e?`runtime v${e}`:"runtime not installed",installedRuntime:null,isDevBridge:!1}}export{m as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.224 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
function C(t,e){let r=["--max-ms","--maxMs","--maxms","--max_ms"];for(let n of r){let s=t.indexOf(n);if(s>=0&&t[s+1]){let o=Number(t[s+1]);if(Number.isFinite(o))return Math.max(100,o)}}return e}var w=new Set(["tap","double-tap","tap-text","tap-id","long-press","touch"]);function S(t){return typeof t=="string"&&w.has(t)}async function v(t){return await t.send({type:"evaluate",code:"window.__sootsimEngineState?.inspectActive === true"})===!0}async function H(t,e){if(!S(e))return!1;try{return await v(t)}catch{return!1}}async function W(t){let e=await t.send({type:"evaluate",code:"(async () => await window.__sootsimTest.getNodeCount())()"});return{nodes:typeof e=="number"?e:0}}async function B(t,e=5,r){let n=r?.format?`, ${JSON.stringify(r)}`:"",s=await t.send({type:"evaluate",code:`(async () => await window.__sootsimTest.dumpTree(${e}${n}))()`});if(r?.format==="boxes"&&typeof s=="string")try{return{depth:e,tree:JSON.parse(s)}}catch{return{depth:e,tree:s}}return{depth:e,tree:s}}async function F(t){let e=await t.send({type:"evaluate",code:"window.location.href"});return{url:typeof e=="string"?e:""}}async function j(t,e){let r=`(async () => {
|
|
3
3
|
const t = window.__sootsimTest
|
|
4
4
|
const mainShell = window.SootSim?.bridges?.mainShell
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as m,b as I}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.224 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as m,b as I}from"./chunk-GVK4Q3BA.js";import{a as w,b as _,c as E}from"./chunk-NWN2GQ36.js";import{c as O}from"./chunk-ZTCF4L5T.js";import{G as k,o as D,q as f}from"./chunk-K7FLRWXM.js";import h from"fs";import v from"path";var c="default",$="profiles.json",a=1;function s(e){let r=e.trim();if(!r)throw new Error("profile id is required");if(!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(r))throw new Error("profile ids must start with a letter or number and contain only letters, numbers, dot, dash, or underscore");if(r==="."||r==="..")throw new Error(`invalid profile id: ${r}`);return r}function g(){return v.join(f(),$)}function F(e){return`sootsim-profile-${s(e)}`}function B(e){return v.join(D(),"Partitions",F(e))}function b(e){return v.join(f(),"playwright",s(e))}function y(){try{let e=JSON.parse(h.readFileSync(g(),"utf8"));if(!e||e.version!==a)return{version:a,profiles:[]};let r=Array.isArray(e.profiles)?e.profiles.filter(t=>!!t&&typeof t.id=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string").map(t=>({id:s(t.id),createdAt:t.createdAt,updatedAt:t.updatedAt})):[];return{version:a,profiles:r}}catch{return{version:a,profiles:[]}}}function T(e){return[...e].sort((r,t)=>r.id===c?-1:t.id===c?1:r.id.localeCompare(t.id))}function P(e){if(e.profiles.some(t=>t.id===c))return{...e,profiles:T(e.profiles)};let r=new Date().toISOString();return{version:a,profiles:T([{id:c,createdAt:r,updatedAt:r},...e.profiles])}}function S(e){k();let r=P(e),t=`${g()}.tmp`;return h.writeFileSync(t,`${JSON.stringify(r,null,2)}
|
|
3
3
|
`,"utf8"),h.renameSync(t,g()),r}function q(){return S(y()).profiles}function j(e){let r=s(e);return q().find(t=>t.id===r)??null}function C(e=c){let r=s(e),t=j(r);return t||H(r)}function H(e){let r=s(e),t=P(y());if(t.profiles.some(i=>i.id===r))throw new Error(`profile already exists: ${r}`);let n=new Date().toISOString(),o={id:r,createdAt:n,updatedAt:n};return S({version:a,profiles:[...t.profiles,o]}),o}function pe(e){let r=s(e);if(r===c)throw new Error("the default profile cannot be deleted; clear it instead");let t=P(y()),n=t.profiles.find(o=>o.id===r);if(!n)throw new Error(`profile not found: ${r}`);return S({version:a,profiles:t.profiles.filter(o=>o.id!==r)}),z(r),n}function z(e){let r=s(e);for(let t of[B(r),b(r)])try{h.rmSync(t,{recursive:!0,force:!0})}catch{}}function K(){let e=w();return e?{available:!0,reason:null,detail:e}:{available:!1,reason:"no chromium-family browser found (chrome, chromium, edge, brave, arc)"}}async function Y(e){if(e.headless)return{launched:!1,message:"the chromium driver launches a visible browser window and cannot run headless \u2014 a headless `chrome --headless=new` process exits immediately and the sim never connects. for headless automation use `--driver playwright`."};let r=w();if(!r)return{launched:!1,message:"chromium not found \u2014 install chrome or run `sootsim list --drivers`"};if(!e.url)return{launched:!1,message:"chromium driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current Chrome profile"};try{let t=await E(e.url,{detached:e.detached??!0});return{launched:!0,message:`chromium launched \u2192 ${e.url}`,pid:t.pid,target:t.target??r,attachUrl:e.url}}catch(t){return{launched:!1,message:`chromium spawn failed: ${t instanceof Error?t.message:String(t)}`}}}var A={id:"chromium",name:"chromium",description:"system chrome / chromium / edge \u2014 visible window (headless: use playwright)",kind:"browser",availability:K,launch:Y};function V(){let e=m();return e?{available:!0,reason:null,detail:`${e.kind} @ ${e.path}`}:{available:!1,reason:"sootsim desktop app not installed (run `sootsim desktop install`)"}}async function J(e){let r=m();if(!r)return{launched:!1,message:"sootsim desktop app not installed"};try{let t=await I(e.url,r,{device:e.device,profileId:e.profileId,ephemeralProfile:e.ephemeralProfile});return t.launched?{launched:!0,message:e.url?`electron launched via ${t.via} \u2192 ${e.url}`:`electron launched via ${t.via}`,target:t.target,attachUrl:e.url}:{launched:!1,message:"desktop companion failed to start"}}catch(t){return{launched:!1,message:`electron launch failed: ${t instanceof Error?t.message:String(t)}`}}}var M={id:"electron",name:"electron",description:"sootsim desktop companion app (native window, menu bar)",kind:"native",availability:V,launch:J};import{spawn as X}from"child_process";import{closeSync as Z,mkdtempSync as Q,openSync as ee,readFileSync as re}from"fs";import{createRequire as te}from"module";import{tmpdir as L}from"os";import{join as R}from"path";var ne=`
|
|
4
4
|
const modulePath = process.env.SOOTSIM_PW_MODULE;
|
|
5
5
|
const url = process.env.SOOTSIM_PW_URL;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.224 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import{createHash as b}from"node:crypto";import g from"node:fs";import{createRequire as S}from"node:module";import u from"node:path";var y=/\.(ttf|otf|woff|woff2)$/i;function P(t,n,r){if(!t||typeof t!="object")return;let o=t.fonts;if(Array.isArray(o))for(let i of o)typeof i=="string"&&r.push(i);let e=t[n];if(!e||typeof e!="object")return;let s=e.fonts;if(Array.isArray(s))for(let i of s){if(typeof i=="string"){r.push(i);continue}if(!i||typeof i!="object")continue;let c=i.fontDefinitions;if(Array.isArray(c))for(let a of c){if(!a||typeof a!="object")continue;let p=a.path;typeof p=="string"&&r.push(p)}}}function m(t,n){if(!Array.isArray(t))return[];let r=[];for(let o of t){let e=Array.isArray(o)?o[0]:o;if(typeof e!="string"||!/(^|\/)expo-font$/.test(e))continue;let s=Array.isArray(o)?o[1]??{}:{};P(s,n,r)}return r}function C(t){return t.slice(t.lastIndexOf("/")+1).replace(y,"")}function h(t,n){let r=n.replace(/\/+$/,""),o=new Set,e=[];for(let s of t){let i=s.replace(/^\.\//,"").replace(/^\/+/,"");!i||o.has(i)||(o.add(i),y.test(i)&&e.push({family:C(i),url:`${r}/assets/${i}`}))}return e}var d=S(import.meta.url);function x(t){try{let n=new URL(t),r=n.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(r==="localhost"||r.endsWith(".localhost")||r==="0.0.0.0"||r==="::1"||/^127(?:\.\d{1,3}){3}$/.test(r))return n.origin}catch{}return null}var R=["app.config.js","app.config.ts","app.config.cjs","app.config.mjs","app.json"];function w(t){for(let n of R)try{if(g.statSync(u.join(t,n)).isFile())return!0}catch{}return!1}var j=new Set(["node_modules","artifacts","dist","build","out","coverage","tmp","public","ios","android","macos","windows","__fixtures__","__tests__","examples","example"]);function F(t,n){w(t)&&n.push(t);let r;try{r=g.readdirSync(t,{withFileTypes:!0})}catch{return}for(let o of r)o.isDirectory()&&(o.name.startsWith(".")||j.has(o.name)||F(u.join(t,o.name),n))}function _(t){try{return g.statSync(u.join(t,"package.json")).isFile()}catch{return!1}}function I(t){let n=x(t.bundleUrl);if(!n)return[];let r=t.repoDir||process.env.SOOT_REPO_DIR,o=r?u.resolve(r):process.cwd();if(!r&&!_(o))return[];let e=[];if(r)F(o,e),e.includes(o)||e.push(o);else{if(!w(o))return[];e.push(o)}if(e.length===0)return[];let s=(t.platform||process.env.SOOT_PLATFORM||"ios").toLowerCase(),i=null;try{let l=d.resolve("@expo/config",{paths:[...e,o]}),f=d(l);typeof f.getConfig=="function"&&(i=f.getConfig)}catch{}if(!i)return[];let c;for(let l of e)try{let f=i(l,{skipSDKVersionRequirement:!0});if(f?.exp&&typeof f.exp=="object"){let A=f.exp.plugins;if(Array.isArray(A)){c=f.exp;break}}}catch{}if(!c||typeof c!="object")return[];let a=c.plugins;if(!Array.isArray(a))return[];let p=m(a,s==="android"?"android":"ios");return h(p,n)}async function L(t,n){let r=x(t);if(!r)return null;let o=new AbortController,e=setTimeout(()=>o.abort(),n?.timeoutMs??1500);try{let s=await fetch(`${r}/`,{headers:{"expo-platform":"ios",Accept:"application/json"},signal:o.signal});if(!s.ok)return null;let c=(await s.json())?.extra?.expoClient?._internal?.projectRoot;return typeof c=="string"&&c.length>0?c:null}catch{return null}finally{clearTimeout(e)}}function M(t){return t.map(n=>`${encodeURIComponent(n.url)}::${encodeURIComponent(n.family)}`).join(",")}function k(t){let n=[];for(let r of t.split(",")){let o=r.trim();if(!o)continue;let e=o.indexOf("::"),s=e===-1?o:o.slice(0,e);try{n.push(decodeURIComponent(s))}catch{n.push(s)}}return n.filter(Boolean)}function D(t){let n=(t.split("?")[0].split(".").pop()||"").toLowerCase();return n==="ttf"?"font/ttf":n==="otf"?"font/otf":n==="woff"?"font/woff":n==="woff2"?"font/woff2":"application/octet-stream"}async function G(t,n){let r=[],o=new Set;for(let e of k(t)){let s=b("sha256").update(e).digest("hex");if(!o.has(s)){o.add(s);try{let i=await fetch(e);if(!i.ok){n?.onError?.(e,new Error(`${i.status} ${i.statusText}`));continue}let c=new Uint8Array(await i.arrayBuffer());r.push({url:e,urlhash:s,contentType:D(e),bytes:c}),n?.onStaged?.({url:e,byteLength:c.byteLength})}catch(i){n?.onError?.(e,i)}}}return r}export{I as a,L as b,M as c,G as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.224 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var m={"--help":{type:"boolean",short:"-h"},"--version":{type:"boolean",short:"-V"},"--verbose":{type:"boolean",short:"-v"},"--port":{type:"number",short:"-p"},"--device":{type:"string",short:"-d"},"--theme":{type:"string",short:"-t"},"--headless":{type:"boolean"},"--driver":{type:"string"},"--sim":{type:"string"},"--session":{type:"string"},"--tab":{type:"string"}},p=new Set(["list","describe","find","get","do","wait","network","logs","shell"]),b=new Set(["do","get","wait","shell","debug"]),d=new Set(["detox","maestro","record","film","storage","perf","screenshot","mode","inspect","debug","timeline","what-happened","shell","assert","device","open","list","use","claim","close","compat","desktop","login","logout","auth","setup","serve","daemon","runtime","upgrade","version","skill","config","app-fonts","agent-wrapper","agent",...p]);function h(c){let r=c.slice(2),e={command:null,commandArgs:[],globalFlags:{},help:!1,version:!1,verbose:!1},s=0;for(;s<r.length;){let o=r[s];if(o==="--"){e.commandArgs.push(...r.slice(s+1));break}let i=Object.entries(m).find(([l,t])=>l===o||t.short===o);if(i){let[l,t]=i,a=l.replace(/^--/,"");if(t.type==="boolean")e.globalFlags[a]=!0,s++;else{let n=r[s+1];if(n===void 0||n.startsWith("-")){console.error(` warning: ${o} requires a value`),s++;continue}if(t.type==="number"){let g=Number(n);if(Number.isNaN(g)){console.error(` warning: ${o} requires a number, got "${n}"`),s+=2;continue}e.globalFlags[a]=g}else e.globalFlags[a]=n;s+=2}continue}if(!e.command&&!o.startsWith("-")){let l=o.indexOf("-");if(l>0){let t=o.slice(0,l),a=o.slice(l+1);if(b.has(t)&&a.length>0){e.command=t;let n=r.slice(s+1);e.commandArgs=[a,...n[0]==="--"?n.slice(1):n];break}}if(d.has(o)){e.command=o;let t=r.slice(s+1);e.commandArgs=t[0]==="--"?t.slice(1):t;break}e.commandArgs=r.slice(s);break}e.commandArgs.push(o),s++}return e.help=!!e.globalFlags.help,e.version=!!e.globalFlags.version,e.verbose=!!e.globalFlags.verbose,e}export{p as a,h as b};
|