sootsim 0.1.51 → 0.1.53
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 +7 -7
- package/dist-cli/chunks/{agent-RLBVAUCW.js → agent-PA7ZGTHU.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-TWLPNETE.js → agent-wrapper-CVZFXQKJ.js} +2 -2
- package/dist-cli/chunks/{assert-JLQSBZPM.js → assert-6LHIY63B.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-SVBAUCSM.js +2 -0
- package/dist-cli/chunks/beta-YEBFYYIB.js +2 -0
- package/dist-cli/chunks/{chunk-DBHV5S2L.js → chunk-2ZBZCRN6.js} +1 -1
- package/dist-cli/chunks/{chunk-L4OPPOPY.js → chunk-5Q3XBH5M.js} +2 -2
- package/dist-cli/chunks/{chunk-IEYPDVW2.js → chunk-5U2BN4IU.js} +2 -2
- package/dist-cli/chunks/{chunk-265YGINI.js → chunk-6A4CZMPO.js} +6 -3
- package/dist-cli/chunks/{chunk-LMINUIAR.js → chunk-6JZNIGOQ.js} +1 -1
- package/dist-cli/chunks/{chunk-VDUWPVZT.js → chunk-7IYYIF5B.js} +2 -2
- package/dist-cli/chunks/{chunk-SPMHQKNI.js → chunk-7ZHWA3WD.js} +78 -78
- package/dist-cli/chunks/{chunk-ET5NKJVL.js → chunk-AFXPU7YQ.js} +29 -29
- package/dist-cli/chunks/{chunk-DBYZF6KL.js → chunk-AYU6WUNF.js} +1 -1
- package/dist-cli/chunks/{chunk-67AZW4HJ.js → chunk-AZYLZGRV.js} +1 -1
- package/dist-cli/chunks/{chunk-ZT7672XM.js → chunk-BPXSSZJS.js} +3 -3
- package/dist-cli/chunks/chunk-CKZSGUTE.js +2 -0
- package/dist-cli/chunks/{chunk-M7HK7MWE.js → chunk-CRUPWYHV.js} +3 -3
- package/dist-cli/chunks/{chunk-P2IC3VRD.js → chunk-CTDDR7HW.js} +2 -2
- package/dist-cli/chunks/{chunk-54IIO5BV.js → chunk-CTGH5SFH.js} +1 -1
- package/dist-cli/chunks/{chunk-IENPCJTB.js → chunk-CW2X4KRW.js} +4 -4
- package/dist-cli/chunks/{chunk-FSTOUA6L.js → chunk-E3S6U2QR.js} +1 -1
- package/dist-cli/chunks/{chunk-CLSZB5BN.js → chunk-E4JTYQVY.js} +2 -2
- package/dist-cli/chunks/chunk-ELEP2COQ.js +3 -0
- package/dist-cli/chunks/{chunk-ZEIDKF3M.js → chunk-ERC46HTZ.js} +1 -1
- package/dist-cli/chunks/{chunk-PTW5KT4I.js → chunk-FDA2NX2E.js} +2 -2
- package/dist-cli/chunks/{chunk-BKXH674Z.js → chunk-GWGF4J4Y.js} +2 -2
- package/dist-cli/chunks/chunk-H4C3WE3C.js +1 -0
- package/dist-cli/chunks/{chunk-6NR6NFDC.js → chunk-IS5ORPFW.js} +2 -2
- package/dist-cli/chunks/{chunk-3BUWCNVX.js → chunk-LELB2PV3.js} +1 -1
- package/dist-cli/chunks/chunk-LL3XAMKC.js +16 -0
- package/dist-cli/chunks/{chunk-HATEGE6O.js → chunk-LYHVX7TD.js} +4 -4
- package/dist-cli/chunks/{chunk-AQN3BB3D.js → chunk-MX5HFYST.js} +1 -1
- package/dist-cli/chunks/{chunk-VR2UDTSA.js → chunk-N3RWXMD3.js} +2 -2
- package/dist-cli/chunks/chunk-NIHI6NXE.js +1 -0
- package/dist-cli/chunks/chunk-QTVGSFY6.js +305 -0
- package/dist-cli/chunks/{chunk-AWQGGSDW.js → chunk-R3VVVXF3.js} +2 -2
- package/dist-cli/chunks/{chunk-FUHHRW7G.js → chunk-R5XV3WIE.js} +2 -2
- package/dist-cli/chunks/{chunk-P45EZ2VW.js → chunk-RBXJA2PW.js} +2 -2
- package/dist-cli/chunks/{chunk-VXLRXQER.js → chunk-SQZXAKBL.js} +2 -2
- package/dist-cli/chunks/{chunk-5PKYORP6.js → chunk-STWL7EXR.js} +1 -1
- package/dist-cli/chunks/{chunk-45XEBYVX.js → chunk-WBAIONOO.js} +2 -2
- package/dist-cli/chunks/{chunk-SLAAAEUZ.js → chunk-WXOAHKCZ.js} +1 -1
- package/dist-cli/chunks/{chunk-RSEV5NWY.js → chunk-XBP7BBSF.js} +2 -2
- package/dist-cli/chunks/{chunk-EOYTPHOU.js → chunk-XC3T7UDH.js} +1 -1
- package/dist-cli/chunks/chunk-XO4UV6EO.js +1 -0
- package/dist-cli/chunks/chunk-YCPH4ZTS.js +2 -0
- package/dist-cli/chunks/{chunk-BGZRRNK4.js → chunk-YEE4EO2P.js} +1 -1
- package/dist-cli/chunks/{chunk-XWHWPFBE.js → chunk-ZYITMTYD.js} +1 -1
- package/dist-cli/chunks/cli-version-NMWGV7OU.js +2 -0
- package/dist-cli/chunks/{compat-WUI6VQPS.js → compat-CHBJ7TDK.js} +3 -3
- package/dist-cli/chunks/{config-XCFL4A6Z.js → config-XTZOLM5E.js} +2 -2
- package/dist-cli/chunks/control-XAZGNLFM.js +2 -0
- package/dist-cli/chunks/{cpu-profile-CPOEDK5W.js → cpu-profile-EQHKYVOF.js} +2 -2
- package/dist-cli/chunks/{daemon-NFZOWPYN.js → daemon-K42MZR2E.js} +2 -2
- package/dist-cli/chunks/{debug-G6FBH3B4.js → debug-ULTTL5L2.js} +3 -3
- package/dist-cli/chunks/demo-app-registry-SO43B5HW.js +2 -0
- package/dist-cli/chunks/{detox-PUCPDKAO.js → detox-LU3G3EBC.js} +2 -2
- package/dist-cli/chunks/{device-IUUKTF7R.js → device-RYW4ZE4R.js} +2 -2
- package/dist-cli/chunks/diagnose-5YQAXWFB.js +41 -0
- package/dist-cli/chunks/drivers-SXP44QNY.js +2 -0
- package/dist-cli/chunks/{electron-HGY5WSFG.js → electron-ORBIXXTP.js} +3 -3
- package/dist-cli/chunks/flow-GP7GAXLT.js +2 -0
- package/dist-cli/chunks/{hints-H7IVKEWB.js → hints-V4SHPWCI.js} +2 -2
- package/dist-cli/chunks/{home-paths-U5CDMYH5.js → home-paths-UYEDTYXU.js} +2 -2
- package/dist-cli/chunks/{inspect-6WSCE3W3.js → inspect-K2FN4JPL.js} +105 -130
- package/dist-cli/chunks/install-R4H47HDX.js +2 -0
- package/dist-cli/chunks/{install-desktop-QTZ3IBQW.js → install-desktop-BDDNVONK.js} +3 -3
- package/dist-cli/chunks/{keys-DCQXAY66.js → keys-QH5VOSUK.js} +2 -2
- package/dist-cli/chunks/{launch-FTHBNATG.js → launch-K2LP5XFZ.js} +3 -3
- package/dist-cli/chunks/{login-4GUBAGPQ.js → login-5AJTPRVD.js} +4 -4
- package/dist-cli/chunks/{logout-N25HFETU.js → logout-45VCRSXX.js} +2 -2
- package/dist-cli/chunks/{maestro-WQBZZDTR.js → maestro-5LDII3YE.js} +9 -9
- package/dist-cli/chunks/{preview-6MWJ6BSM.js → preview-IA2UUMLO.js} +2 -2
- package/dist-cli/chunks/{profile-UXJEGF4I.js → profile-ZALUAYTJ.js} +2 -2
- package/dist-cli/chunks/{react-MHPIWH3F.js → react-KJBOHVG7.js} +2 -2
- package/dist-cli/chunks/record-UI226Z7F.js +41 -0
- package/dist-cli/chunks/runtime-JNHCYB5L.js +2 -0
- package/dist-cli/chunks/{runtime-delivery-IIDHK55K.js → runtime-delivery-Y4QVOPLO.js} +2 -2
- package/dist-cli/chunks/{screenshot-MDE5ZSST.js → screenshot-SV5S4UGU.js} +2 -2
- package/dist-cli/chunks/{screenshot-mode-7W7L7IN3.js → screenshot-mode-NCISGI6W.js} +2 -2
- package/dist-cli/chunks/{screenshots-24LEZPD7.js → screenshots-MQZDYKF5.js} +2 -2
- package/dist-cli/chunks/{server-52HFHX3S.js → server-RLDTPMHN.js} +11 -11
- package/dist-cli/chunks/setup-repo-F4RNWTDL.js +2 -0
- package/dist-cli/chunks/{skills-3DGYETTU.js → skills-NECP76E4.js} +2 -2
- package/dist-cli/chunks/{start-NFVPQX74.js → start-K4ASMK7D.js} +4 -4
- package/dist-cli/chunks/store-TLB2YDDQ.js +2 -0
- package/dist-cli/chunks/telemetry-EXCKYRZL.js +2 -0
- package/dist-cli/chunks/{test-THI53N25.js → test-YJLRC3IE.js} +3 -3
- package/dist-cli/chunks/three-mode-NAAIMEHL.js +54 -0
- package/dist-cli/chunks/{timeline-KAJ6PR4S.js → timeline-BJXCTH7E.js} +2 -2
- package/dist-cli/chunks/{upgrade-APDFMQCW.js → upgrade-NRJOML2W.js} +2 -2
- package/dist-cli/chunks/upload-BQTZTOJL.js +2 -0
- package/dist-cli/chunks/web-P3IP7M5Q.js +2 -0
- package/dist-cli/chunks/{what-happened-4VMBEL5Z.js → what-happened-5Q2RBX5R.js} +2 -2
- package/dist-cli/chunks/{whoami-NJOQICNO.js → whoami-7W6WPTVA.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.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 +63 -7
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/metro.cjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/vite-base.cjs +67 -7
- package/dist-lib/vite.cjs +1 -1
- package/package.json +1 -1
- package/dist-cli/chunks/auto-bootstrap-UKUFJBJA.js +0 -2
- package/dist-cli/chunks/beta-4OEWPO5F.js +0 -2
- package/dist-cli/chunks/chunk-2ZCJFJJN.js +0 -37
- package/dist-cli/chunks/chunk-3HO4Q25D.js +0 -1
- package/dist-cli/chunks/chunk-4D7Z64YQ.js +0 -2
- package/dist-cli/chunks/chunk-4QM4J2UK.js +0 -108
- package/dist-cli/chunks/chunk-ACQXOAQI.js +0 -2
- package/dist-cli/chunks/chunk-DV3SI64Q.js +0 -1
- package/dist-cli/chunks/chunk-EWSS4C2R.js +0 -1
- package/dist-cli/chunks/chunk-JZ65NOXB.js +0 -16
- package/dist-cli/chunks/control-KE4VM2BN.js +0 -2
- package/dist-cli/chunks/demo-app-registry-U4FCHIYP.js +0 -2
- package/dist-cli/chunks/diagnose-6RY4YXSP.js +0 -41
- package/dist-cli/chunks/drivers-2FY62QZA.js +0 -2
- package/dist-cli/chunks/flow-HEYPRCST.js +0 -2
- package/dist-cli/chunks/install-NPNUNOL6.js +0 -2
- package/dist-cli/chunks/record-K5DRP3G7.js +0 -18
- package/dist-cli/chunks/runtime-UVFYTDXE.js +0 -2
- package/dist-cli/chunks/setup-repo-ZHEBGISP.js +0 -2
- package/dist-cli/chunks/store-R2RI4XAS.js +0 -2
- package/dist-cli/chunks/telemetry-KGU6DBN6.js +0 -2
- package/dist-cli/chunks/three-mode-HUI4SESE.js +0 -39
- package/dist-cli/chunks/upload-K7OWH74D.js +0 -2
- package/dist-cli/chunks/web-XDGC5KGT.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as ve}from"./chunk-R3VVVXF3.js";import{a as Se}from"./chunk-FDA2NX2E.js";import{a as Fe}from"./chunk-5U2BN4IU.js";import{a as xe}from"./chunk-CW2X4KRW.js";import{a as R,b as fe,c as q,d as G,e as we,f as Y,h as X,i as he}from"./chunk-7ZHWA3WD.js";import{f as ye,l as be}from"./chunk-BPXSSZJS.js";import{b as pe}from"./chunk-6JZNIGOQ.js";import{a as ge}from"./chunk-AYU6WUNF.js";import{a as ce,b as H}from"./chunk-SQZXAKBL.js";import{f as le}from"./chunk-AZYLZGRV.js";import{c as z,d as ue,e as me}from"./chunk-GWGF4J4Y.js";import{c as de}from"./chunk-STWL7EXR.js";import*as P from"fs";import{tmpdir as ke}from"os";import*as g from"path";import*as w from"fs";import*as f from"path";var V=1e4,B=393,_=852,Te="__sootsimCliPerf",Ne="maestroCopiedText",Q=new Map;function p(i){return new Promise(e=>setTimeout(e,i))}function De(i){return i?f.basename(i)===".maestro"?f.dirname(i):i:process.cwd()}function Re(i,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(f.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let o=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():De(t.flowDir);return f.resolve(o,r)}return f.join(i,r)}function Ve(i){if(typeof i=="string")return{path:i,withFrame:!1};let e=i.path?.trim()||i.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:i.withFrame===!0}}function Z(i){let[e,t]=i.split(",").map(o=>o.trim()),r=(o,n)=>o.endsWith("%")?Number.parseFloat(o)/100*n:Number.parseFloat(o);return{x:r(e,B),y:r(t,_)}}function ee(i){return typeof i=="string"?i.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>{if(Q.has(t))return Q.get(t);let r=process.env[t];if(r===void 0)throw new Error(`missing environment variable for flow placeholder: ${t}`);return r}):Array.isArray(i)?i.map(e=>ee(e)):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).map(([e,t])=>[e,ee(t)])):i}function Be(i){let e=i.split(/^---$/m),t=e.length>1?e[e.length-1]:i,r=ee(fe.parse(t));return Array.isArray(r)?r:[]}var U=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingDurationMs=null;simRouteHint=null;lastFailedStep=null;get simId(){return this.opts.simId}setSimRouteHint(e){this.simRouteHint=this.normalizeSimRoute(e)}normalizeSimRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let r=t.searchParams.toString();return`${t.origin}${t.pathname}${r?`?${r}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(a=>a.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(a=>a.id===this.opts.simId&&a.readyState==="open")||!this.simRouteHint)return;let o=this.simRouteHint&&e.find(a=>a.readyState==="open"&&this.normalizeSimRoute(a.url||a.origin)===this.simRouteHint);if(!o)return;let n=e.find(a=>a.isPrimary&&a.readyState==="open"),s=e.find(a=>a.readyState==="open"),l=o??n??s;l&&(this.opts.simId=l.id,console.log(` [flow] sim rotated to ${l.id}`))}catch{}}async evaluate(e,t){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e},t?{timeoutMs:t}:void 0)}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async waitForTree(e=V){let t=Date.now()+e,r=Date.now(),o=null,n=0,s=0;for(;Date.now()<t;){try{let a=await this.evaluate(`(async () => {
|
|
3
3
|
const test = window.__sootsimTest
|
|
4
4
|
if (!test) return { count: 0, loading: true }
|
|
5
5
|
const count = (await test.getNodeCount?.()) || 0
|
|
@@ -19,7 +19,7 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
19
19
|
const openingAppNode = await test.findByText?.('opening app')
|
|
20
20
|
const isLoading = !!loadingNode || !!capturingNode || !!openingAppNode || count < 5
|
|
21
21
|
return { count, loading: isLoading, error: null }
|
|
22
|
-
})()`,8e3);if(n=0,
|
|
22
|
+
})()`,8e3);if(n=0,a?.error)throw new Error(`app failed to load: ${a.error}`);if(a&&a.count>10&&!a.loading)return}catch(a){if(o=a instanceof Error?a:new Error(String(a)),o.message.startsWith("app failed to load:"))throw o;if(n++,n>=4)throw new Error(`target sim is not responding to the bridge (${o.message}). it is likely a stale orphan \u2014 run \`sootsim list\`, then close it with \`sootsim close <id>\` or start a fresh one with \`sootsim open --new <port>\`.`);await this.refreshSimId()}let l=Date.now()-r;l-s>=5e3&&(s=l,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(l/1e3)}s)`)),await p(500)}throw o?.message.startsWith("app failed to load:")?o:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(await Fe("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
|
|
23
23
|
const rec = window.__sootsimRecorder
|
|
24
24
|
if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
|
|
25
25
|
if (rec.state() === 'recording') return { ok: true, format: 'webm' }
|
|
@@ -88,7 +88,7 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
88
88
|
)
|
|
89
89
|
}
|
|
90
90
|
return direct
|
|
91
|
-
})()`)}async tap(e,t){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let
|
|
91
|
+
})()`)}async tap(e,t){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let a=Z(t.point);(await this.activatePressAt(a.x,a.y))?.ok||await this.tap(a.x,a.y),await p(300);return}let r=5e3,o=150,n=Date.now()+r,s=await this.findElement({text:t.text,id:t.id});for(;!s&&Date.now()<n;)await p(o),s=await this.findElement({text:t.text,id:t.id});if(s&&!s.isTextInput&&(await this.activatePressTarget(t))?.ok){await p(300);return}if(s){let a=typeof s.nodeId=="number"?await this.resolveTapTarget(s.nodeId):null,m=a?.cx??s.absolutePosition.x+s.layout.width/2,h=a?.cy??s.absolutePosition.y+s.layout.height/2;if((await this.tap(m,h))?.hit!==!1){await p(300);return}}if((await this.activatePressTarget(t))?.ok){await p(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async tapAtCoords(e,t){await this.tap(e,t),await p(300)}async doubleTapAtCoords(e,t,r=80){let o=Math.max(0,Math.round(r));if(!await this.evaluate(`(async () => {
|
|
92
92
|
const interact = window.__sootsimInteract
|
|
93
93
|
if (interact?.doubleTap) {
|
|
94
94
|
return !!(await interact.doubleTap(${e}, ${t}, ${o}))
|
|
@@ -99,7 +99,7 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
99
99
|
await new Promise((resolve) => setTimeout(resolve, ${o}))
|
|
100
100
|
const second = await interact.tap(${e}, ${t})
|
|
101
101
|
return !!second && second.hit !== false
|
|
102
|
-
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await p(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let r=0;r<15;r++){if(await this.isElementVisible(t))return;await p(200)}throw new Error(`assertVisible: ${JSON.stringify(t)} not found or off-screen`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t))throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible`)}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<
|
|
102
|
+
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await p(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let r=0;r<15;r++){if(await this.isElementVisible(t))return;await p(200)}throw new Error(`assertVisible: ${JSON.stringify(t)} not found or off-screen`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t))throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible`)}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<_)}async inputText(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await p(200)}async pressKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"press",text:e}),await p(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:e}),await p(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(`(() => {
|
|
103
103
|
const keyboard =
|
|
104
104
|
window.__sootsimKeyboard ??
|
|
105
105
|
window.SootSim?.bridges?.keyboard ??
|
|
@@ -109,7 +109,7 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
109
109
|
visible: !!keyboard?.isVisible?.(),
|
|
110
110
|
focused: !!test?.isTextInputFocused?.(),
|
|
111
111
|
}
|
|
112
|
-
})()`);if(!t?.visible&&!t?.focused){await p(80);return}await p(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.pressKey("Backspace");await p(100)}async waitFor(e){let t=Date.now()+(e.timeout||
|
|
112
|
+
})()`);if(!t?.visible&&!t?.focused){await p(80);return}await p(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.pressKey("Backspace");await p(100)}async waitFor(e){let t=Date.now()+(e.timeout||V);for(;Date.now()<t;){if(await this.findElement(e))return;await p(200)}throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||V}ms`)}async takeScreenshot(e){await p(250);let t=Ve(e),r=Re(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});w.mkdirSync(f.dirname(r),{recursive:!0});let n=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,""),s=Buffer.from(n,"base64");if(t.withFrame){let l=await this.readCurrentDeviceModel();if(!l)throw new Error("could not read current device model for framed screenshot");let a=await Se(s,l);w.writeFileSync(r,a),console.log(`[flow] screenshot: ${r} (frame: ${l})`);return}w.writeFileSync(r,s),console.log(`[flow] screenshot: ${r}`)}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 captureFailureScreenshot(e){w.mkdirSync(f.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");w.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){w.mkdirSync(e,{recursive:!0});let r=(m,h)=>{try{w.writeFileSync(f.join(e,m),h)}catch{}},o=async m=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:m})}catch{return null}};r("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()},null,2));try{let h=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");r("screenshot.png",Buffer.from(h,"base64"))}catch{}let n=await o(`(async () => {
|
|
113
113
|
const t = window.__sootsimTest
|
|
114
114
|
const mainShell = window.SootSim?.bridges?.mainShell
|
|
115
115
|
if (!t) return { error: 'no test bridge' }
|
|
@@ -119,19 +119,19 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
119
119
|
} catch {}
|
|
120
120
|
const all = await t.queryAll({ pruneHidden: true })
|
|
121
121
|
return { shell, nodes: all, url: location.href, title: document.title }
|
|
122
|
-
})()`);n&&r("describe.json",JSON.stringify(n,null,2));let s=await o("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof s=="string"&&r("a11y.txt",s);let
|
|
122
|
+
})()`);n&&r("describe.json",JSON.stringify(n,null,2));let s=await o("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof s=="string"&&r("a11y.txt",s);let l=await o("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof l=="string"&&r("tree.txt",l);let a=await o(`(() => {
|
|
123
123
|
const c = window.__sootsimConsole
|
|
124
124
|
return {
|
|
125
125
|
errors: c?.getErrors?.() ?? [],
|
|
126
126
|
warnings: c?.getWarnings?.() ?? [],
|
|
127
127
|
requests: (window.__sootsimGetFailedRequests?.() ?? []),
|
|
128
128
|
}
|
|
129
|
-
})()`);return
|
|
129
|
+
})()`);return a&&r("console.json",JSON.stringify(a,null,2)),e}async swipe(e="UP",t=300){let r=B/2,o=_/2,n=200,s=r,l=o,a=r,m=o;switch(e.toUpperCase()){case"UP":l+=n,m-=n;break;case"DOWN":l-=n,m+=n;break;case"LEFT":s+=n,a-=n;break;case"RIGHT":s-=n,a+=n;break}let h=Math.max(10,Math.round(t/16));await this.drag(s,l,a,m,h,16)}async drag(e,t,r,o,n=12,s=16){if(!(await this.evaluate(`(async () => {
|
|
130
130
|
const interact = window.__sootsimInteract
|
|
131
131
|
if (!interact?.drag) return { ok: false }
|
|
132
132
|
const value = await interact.drag(${e}, ${t}, ${r}, ${o}, ${Math.max(1,Math.round(n))}, ${Math.max(0,Math.round(s))})
|
|
133
133
|
return { ok: !!value, value }
|
|
134
|
-
})()`))?.ok)throw new Error("drag failed");await p(300)}async swipeCoords(e,t,r=300){let o=
|
|
134
|
+
})()`))?.ok)throw new Error("drag failed");await p(300)}async swipeCoords(e,t,r=300){let o=Z(e),n=Z(t),s=Math.max(10,Math.round(r/16));await this.drag(o.x,o.y,n.x,n.y,s,16)}async swipeFrom(e,t="UP",r=300){let o=await this.findElement(e);if(!o)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let n=o.absolutePosition.x+o.layout.width/2,s=o.absolutePosition.y+o.layout.height/2,l=180,a=n,m=s;switch(t.toUpperCase()){case"UP":m-=l;break;case"DOWN":m+=l;break;case"LEFT":a-=l;break;case"RIGHT":a+=l;break}let h=Math.max(10,Math.round(r/16));await this.drag(n,s,a,m,h,16)}async scrollTo(e,t,r){let o=await this.callTest("scrollTo",e,t,r,!1);if(!o?.ok)throw new Error(`scrollTo failed: ${o?.reason||"unknown error"}`);await p(250)}async pinch(e){let t=await this.evaluate(`(async () => {
|
|
135
135
|
const interact = window.__sootsimInteract
|
|
136
136
|
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
137
137
|
const ok = await interact.pinch(
|
|
@@ -140,8 +140,8 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
140
140
|
${e.steps||12}, ${e.stepMs||16}
|
|
141
141
|
)
|
|
142
142
|
return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
|
|
143
|
-
})()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"unknown error"}`);await p(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){await p(e)}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),r=e.direction?.toUpperCase()||"DOWN",o=r==="DOWN"?"UP":r==="UP"?"DOWN":r;for(;Date.now()<t;){let n=await this.findElement({text:e.element});if(n&&n.absolutePosition.y>=0&&n.absolutePosition.y+n.layout.height>0&&n.absolutePosition.y<
|
|
144
|
-
await (${
|
|
143
|
+
})()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"unknown error"}`);await p(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){await p(e)}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),r=e.direction?.toUpperCase()||"DOWN",o=r==="DOWN"?"UP":r==="UP"?"DOWN":r;for(;Date.now()<t;){let n=await this.findElement({text:e.element});if(n&&n.absolutePosition.y>=0&&n.absolutePosition.y+n.layout.height>0&&n.absolutePosition.y<_-50){if(e.centerElement){let s=_/2,l=n.absolutePosition.y-s;if(Math.abs(l)>100){let a=Math.min(150,Math.abs(l)*.5),m=l>0?s-a:s+a;await this.drag(B/2,s,B/2,m,10,16)}}return}await this.swipe(o,250),await p(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+(e.timeout||V);for(;Date.now()<t;){let r=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,o=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(r&&o)return;await p(200)}throw new Error("extendedWaitUntil timed out")}async launchApp(e){await this.refreshSimId();let t=!!(e&&typeof e=="object"&&e.clearState);if(t&&await this.evaluate(`(async () => {
|
|
144
|
+
await (${R})
|
|
145
145
|
try {
|
|
146
146
|
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
147
147
|
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
@@ -176,7 +176,7 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
176
176
|
mode: 'main-thread',
|
|
177
177
|
startedAt: performance.now(),
|
|
178
178
|
}
|
|
179
|
-
})(${JSON.stringify(
|
|
179
|
+
})(${JSON.stringify(Te)})`),this.profilingEnabled=!0}async stopProfile(){let e=await this.evaluate(`(async (sessionKey) => {
|
|
180
180
|
const host = window.__sootsimRenderHost
|
|
181
181
|
if (host?.stopPerfSession) {
|
|
182
182
|
const stopped = await host.stopPerfSession(sessionKey)
|
|
@@ -243,21 +243,21 @@ import{a as ye}from"./chunk-AWQGGSDW.js";import{a as be}from"./chunk-PTW5KT4I.js
|
|
|
243
243
|
sampleCount: recent.length,
|
|
244
244
|
worstFrames: recent.slice().sort((a, b) => b - a).slice(0, 10),
|
|
245
245
|
}
|
|
246
|
-
})(${JSON.stringify(
|
|
247
|
-
try { await (${
|
|
246
|
+
})(${JSON.stringify(Te)})`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.evaluate(`(async () => {
|
|
247
|
+
try { await (${R}) } catch {}
|
|
248
248
|
try {
|
|
249
249
|
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
250
250
|
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
251
251
|
} catch {}
|
|
252
252
|
})()`)}async clearState(){await this.evaluate(`(async () => {
|
|
253
|
-
await (${
|
|
254
|
-
})()`)}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,r=await this.findElement(t);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let o=r.text??r.testID??"";
|
|
253
|
+
await (${R})
|
|
254
|
+
})()`)}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,r=await this.findElement(t);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let o=r.text??r.testID??"";Q.set(Ne,o),console.log(`[flow] copied text: ${JSON.stringify(o)}`)}async evalScript(e){let r=await this.evaluate(`(async () => {
|
|
255
255
|
try {
|
|
256
256
|
return { ok: true, value: await (async () => { ${e} })() }
|
|
257
257
|
} catch (err) {
|
|
258
258
|
return { ok: false, error: err && err.message ? err.message : String(err) }
|
|
259
259
|
}
|
|
260
|
-
})()`);if(!r.ok)throw new Error(`evalScript failed: ${r.error}`);r.value!==void 0&&console.log("[flow] evalScript ->",r.value)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(t)}`),await p(300),await this.refreshSimId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()==="ios":e.true!==void 0?e.true.toLowerCase()!=="false":!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([n])=>n!=="when"&&n!=="optional"),o=r?r[1]:void 0;return!!(o&&typeof o=="object"&&"optional"in o&&o.optional)}async runStep(e,t){let r=Object.keys(e).find(o=>o!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${t+1}: ${r}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let o=!!(e.extendedWaitUntil||e.waitFor||e.scrollUntilVisible||e.launchApp||e.runFlow),n=1e4,s=this.runStepInner(e);if(o)await s;else{let
|
|
260
|
+
})()`);if(!r.ok)throw new Error(`evalScript failed: ${r.error}`);r.value!==void 0&&console.log("[flow] evalScript ->",r.value)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(t)}`),await p(300),await this.refreshSimId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()==="ios":e.true!==void 0?e.true.toLowerCase()!=="false":!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([n])=>n!=="when"&&n!=="optional"),o=r?r[1]:void 0;return!!(o&&typeof o=="object"&&"optional"in o&&o.optional)}async runStep(e,t){let r=Object.keys(e).find(o=>o!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${t+1}: ${r}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let o=!!(e.extendedWaitUntil||e.waitFor||e.scrollUntilVisible||e.launchApp||e.runFlow),n=1e4,s=this.runStepInner(e);if(o)await s;else{let a=null,m=new Promise((h,y)=>{a=setTimeout(()=>{y(new Error(`step watchdog: ${r} made no progress in ${n}ms \u2014 bridge or bundle probably hung`))},n)});try{await Promise.race([s,m])}finally{a&&clearTimeout(a)}}let l=!!(e.assertVisible||e.assertNotVisible||e.extendedWaitUntil||e.waitFor);this.stepDelay>0&&!l&&await p(this.stepDelay)}catch(o){if(this.isOptional(e)){console.log(`[flow] (optional, skipped: ${o.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:r,target:e[r]},o}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else if(e.takeScreenshot)await this.takeScreenshot(e.takeScreenshot);else if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo)await this.scrollTo(e.scrollTo.id,e.scrollTo.x,e.scrollTo.y);else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd)await this.waitForAnimationToEnd(typeof e.waitForAnimationToEnd=="number"?e.waitForAnimationToEnd:2e3);else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await p(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat)for(let t=0;t<e.repeat.times;t++)for(let r=0;r<e.repeat.commands.length;r++)await this.runStep(e.repeat.commands[r],r);else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")await this.evalScript(e.evalScript);else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,r=typeof t=="string"?t:t.file,o=typeof t=="string"?void 0:t.when;if(o&&!await this.evaluateWhen(o)){console.log(`[flow] runFlow skipped (when predicate false): ${r}`);return}let n=f.resolve(this.opts.flowDir,r),s=w.readFileSync(n,"utf8"),l=this.opts.flowDir;this.opts.flowDir=f.dirname(n),await this.runFlow(Be(s)),this.opts.flowDir=l}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let t=[],r=[],o=[];for(let s of e){let l=Object.keys(s);if(l.length===1&&l[0]==="onFlowStart"&&Array.isArray(s.onFlowStart)){t.push(...s.onFlowStart);continue}if(l.length===1&&l[0]==="onFlowComplete"&&Array.isArray(s.onFlowComplete)){r.push(...s.onFlowComplete);continue}o.push(s)}if(t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let s=0;s<t.length;s++)await this.runStep(t[s],s)}let n=null;try{await this.runFlowBody(o)}catch(s){n=s instanceof Error?s:new Error(String(s))}if(r.length>0){console.log(`[flow] onFlowComplete (${r.length} steps)`);for(let s=0;s<r.length;s++)try{await this.runStep(r[s],s)}catch(l){console.warn(`[flow] onFlowComplete step ${s+1} failed: ${l instanceof Error?l.message:l}`)}}if(n)throw n}async runFlowBody(e){for(let t=0;t<e.length;t++){let r=e[t],o=typeof r.wait=="number"?r.wait:0,n=typeof r.waitFor?.timeout=="number"?r.waitFor.timeout:0,s=Math.max(6e4,o+15e3,n+15e3);if(r.runFlow){await this.runStep(r,t);continue}await Promise.race([this.runStep(r,t),new Promise((l,a)=>setTimeout(()=>a(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${s}ms deadline`)),s))])}}};async function Ue(){let i=await ve(),e=i.find(r=>r.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=i[0];return t?`http://localhost:${t.port}/__soot/`:null}async function Me(i){(i.length===0||i.includes("--help")||i.includes("-h"))&&(console.log(`
|
|
261
261
|
sootsim flow \u2014 run flows or manage a draft
|
|
262
262
|
|
|
263
263
|
usage:
|
|
@@ -324,25 +324,25 @@ flow extension:
|
|
|
324
324
|
takeScreenshot:
|
|
325
325
|
path: marketing/hero
|
|
326
326
|
withFrame: true
|
|
327
|
-
`),process.exit(0));let e=i[0]
|
|
327
|
+
`),process.exit(0));let e=i[0];P.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=d=>i.find((c,v)=>i[v-1]===d),r=i.includes("--profile"),o=i.includes("--new"),n=t("--out")||"/tmp/sootsim-recordings",s=t("--screenshots")||"/tmp/sootsim-flow",l=t("--screenshot-paths")==="flow"?"flow":"dir",a=t("--device")?.trim()||"",m=i.includes("--slow")?+(t("--slow")||"500"):0,h=i.includes("--electron"),y=i.includes("--preview"),W=await xe(t("--preview-origin")),te=t("--preview-public-origin"),Ae=i.includes("--preview-open"),Pe=i.flatMap((d,c)=>i[c-1]==="--replace"?["--replace",d]:[]),S=i.includes("--record")||y,re=i.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):S?2e3:0,Ie=P.readFileSync(e,"utf8"),{frontmatter:$,steps:M}=q(Ie);M.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let I=a||$.device||"",C=h||$.electron===!0,L=$.app===void 0||$.app===null?"":typeof $.app=="number"?String($.app):$.app,ie={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver"]},x=z(i,ie),Ee=t("--url")||"";C&&!ge()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let oe=C?"desktop companion":"bridge",_e=L?` | target: ${L}`:"";console.log(`
|
|
328
328
|
sootsim flow \u2014 ${g.basename(e)}
|
|
329
|
-
${
|
|
330
|
-
`),y&&
|
|
329
|
+
${M.length} steps | ${oe}${_e}${S?" | recording":""}${r?" | profiling":""}${m?` | ${m}ms delay`:""}
|
|
330
|
+
`),y&&ce({event:"preview_flow_started",properties:{flowName:g.basename(e),stepCount:M.length,mode:oe,electron:C,record:S,profile:r,previewOrigin:W}});let F=Ee||L||"",j=o||C&&x.simIdSource!=="flag",se=!1;if(!F&&!j&&x.simIdSource==="none"){let d=me(x);try{let c=await d.listSims(),v=c.find(D=>D.isPrimary&&D.readyState==="open"),N=c.find(D=>D.readyState==="open"),ae=v??N;ae&&(se=!0,console.log(` reusing active sim: ${ae.id}`))}catch{}finally{d.close()}}if(!F&&!se&&(j||x.simIdSource==="none")){let d=await Ue();d||(console.error(" error: no current sim and no sootsim target found"),await H(),process.exit(1)),F=d}if(F&&I){let d=new URL(await ye(F));d.searchParams.set("device",I),F=d.toString()}if(F){let d=[F];d.push(...Pe),j&&d.push("--new"),x.simIdSource==="flag"&&x.simId&&d.push("--sim",x.simId);let c=t("--driver");c&&d.push("--driver",c),i.includes("--headless")&&d.push("--headless"),await be(d,{port:x.wsPort,timeoutMs:x.commandTimeoutMs})}let A=z(i,ie),K=A.simIdSource==="flag"?A.simId:de()||A.simId,Ce=A.simIdSource==="flag"?"flag":K?"saved":"none",T=ue(A.wsPort,{commandTimeoutMs:A.commandTimeoutMs,simId:K,simIdSource:Ce,fallbackOnMissingSimId:!1}),u,ne=async()=>{if(!I)return!1;let d=await T.send({type:"evaluate",simId:u.simId,code:"window.location.href"});if(typeof d=="string"&&d.length>0){let c=new URL(d);c.searchParams.set("device",I),u.setSimRouteHint(c.toString())}return!!await T.send({type:"call",simId:u.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",I]})};u=new U(T,{screenshotDir:s,flowDir:g.dirname(g.resolve(e)),screenshotPathMode:l,simId:K,recordingOutputDir:S?n:void 0,billingOriginOverride:y?W:void 0,allowGitHubRecording:S,onAfterLaunch:async()=>{await ne()&&await u.waitForTree(12e4),y&&await T.send({type:"evaluate",simId:u.simId,code:`(() => {
|
|
331
331
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
332
332
|
return r?.start?.() ?? false
|
|
333
|
-
})()`})}}),m&&(u.stepDelay=m);let
|
|
333
|
+
})()`})}}),m&&(u.stepDelay=m);let k=null,b=null,E=null,J=null,O=0,Oe=!!M[0]?.launchApp;try{await u.waitForTree(12e4),await ne()&&await u.waitForTree(12e4),S&&(Oe?u.prepareRecording():await u.startRecording()),r&&await u.startProfile(),y&&(await T.send({type:"evaluate",simId:u.simId,code:`(() => {
|
|
334
334
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
335
335
|
return r?.start?.() ?? false
|
|
336
|
-
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await u.runFlow(
|
|
336
|
+
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await u.runFlow(M),r&&(k=await u.stopProfile()),S&&re>0&&await new Promise(c=>setTimeout(c,re)),S&&(b=await u.stopRecording(),E=u.getLastRecordingDurationMs()),y&&(J=await T.send({type:"evaluate",simId:u.simId,code:`(() => {
|
|
337
337
|
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
338
338
|
return r?.stop?.() ?? []
|
|
339
|
-
})()`}),console.log(` captured ${
|
|
340
|
-
+ completed (${
|
|
339
|
+
})()`}),console.log(` captured ${J.length} replay events`)),console.log(`
|
|
340
|
+
+ completed (${M.length} steps)`),k&&$e(k),b&&console.log(` video: ${b}`),console.log()}catch(d){if(r&&!k)try{k=await u.stopProfile()}catch{}if(S&&!b)try{b=await u.stopRecording(),E=u.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}console.error(`
|
|
341
341
|
x failed: ${d.message}
|
|
342
|
-
`),
|
|
343
|
-
preparing preview upload\u2026`);let{runUpload:v}=await import("./upload-
|
|
342
|
+
`),k&&(console.log(" partial profile:"),$e(k)),b&&console.log(` partial video: ${b}`);try{let c=u.lastFailedStep,v=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",N=g.join(s,v);await u.captureFailureBundle(N,{error:d,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),console.log(` failure bundle: ${N}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let v=g.join(s,"error.png");await u.captureFailureScreenshot(v),console.log(` error screenshot: ${v}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await pe(T,{errorsCommand:`sootsim get errors 5${u.simId?` --sim ${u.simId}`:""}`,warningsCommand:`sootsim get warnings 5${u.simId?` --sim ${u.simId}`:""}`,requestsCommand:`sootsim get requests 5${u.simId?` --sim ${u.simId}`:""}`}),O=1}finally{T.close()}if(O===0&&y)try{let d=await We(J??[]),c=["--origin",W,"--events",d];te&&c.push("--public-origin",te),b&&c.push("--video",b),b&&E&&Number.isFinite(E)&&c.push("--video-duration-ms",String(Math.round(E))),u.simId&&c.push("--sim",u.simId),Ae&&c.push("--open"),console.log(`
|
|
343
|
+
preparing preview upload\u2026`);let{runUpload:v}=await import("./upload-BQTZTOJL.js");await v(c,{})}catch(d){console.error(` preview upload failed: ${d?.message||d}`),O=1}return await H(),O}async function We(i){let{gzipSync:e}=await import("zlib"),t=i.map(n=>JSON.stringify(n)).join(`
|
|
344
344
|
`)+(i.length?`
|
|
345
|
-
`:""),r=e(Buffer.from(t,"utf8")),o=g.join(
|
|
346
|
-
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=m;return}Y(),console.log(` flow draft validated (${
|
|
345
|
+
`:""),r=e(Buffer.from(t,"utf8")),o=g.join(ke(),`sootsim-events-${Date.now()}.jsonl.gz`);return P.writeFileSync(o,r),console.log(` events: ${i.length} written to ${o} (${r.length} bytes gz)`),o}async function Le(i){let e=i[0],t=r=>i.find((o,n)=>i[n-1]===r);switch(e){case"start":{let{path:r,state:o}=we();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${o.steps.length}`);return}case"keep":case"good":{let r=X();if(r.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!r.kept){console.log(" no pending action to keep");return}console.log(` kept: ${r.candidate.summary}`),console.log(` steps: ${r.stepCount}`);return}case"end":{let r=t("--output")||(i[1]&&!i[1].startsWith("-")?i[1]:void 0),o=i.includes("--validate")||i.includes("--video"),n=i.includes("--video"),s=X();s.active&&s.kept&&console.log(` auto-kept trailing action: ${s.candidate.summary}`);let l=he(r||(o?Ke():void 0));if(l.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!l.valid){console.error(" flow draft is not valid:");for(let a of l.issues)console.error(` - ${a}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim flow start` to reset"),process.exit(1)}if(o){let a=Je(i,l.outputPath),m=await Me(a);if(m!==0){console.error(`
|
|
346
|
+
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=m;return}Y(),console.log(` flow draft validated (${l.stepCount} step${l.stepCount===1?"":"s"})`),l.outputPath&&console.log(` saved: ${l.outputPath}`),n&&console.log(" video: recorded during validation run");return}if(Y(),console.log(` flow draft ended (${l.stepCount} step${l.stepCount===1?"":"s"})`),l.outputPath){console.log(` saved: ${l.outputPath}`),console.log(` next: sootsim flow ${l.outputPath} --record`);return}console.log(""),process.stdout.write(l.yaml);return}case"validate":{let r=i[1];(!r||r.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let o=G(r);if(o.length>0){console.error(` x ${r} failed validation:`);for(let n of o)console.error(` - ${n}`);process.exit(1)}console.log(` + ${r} looks valid`);return}}}function je(i){return i[0]==="--sim"&&i.length>=2?[...i.slice(2),"--sim",i[1]]:i}async function dt(i){let e=je(i),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await Le(e),0;let r=await Me(e);return r!==0&&(process.exitCode=r),r}function $e(i){let e=i.avgMs>0?(1e3/i.avgMs).toFixed(1):"?",t=i.sampleCount>0?(i.jankFrames/i.sampleCount*100).toFixed(1):"0";console.log(`
|
|
347
347
|
profile:`),console.log(` frames: ${i.frames}`),console.log(` total: ${i.totalMs.toFixed(1)}ms`),console.log(` avg: ${i.avgMs.toFixed(2)}ms (${e} fps)`),console.log(` max: ${i.maxMs.toFixed(2)}ms`),i.layoutAvgMs!==void 0&&console.log(` breakdown: layout ${i.layoutAvgMs.toFixed(2)}ms | render ${i.renderAvgMs?.toFixed(2)||"0.00"}ms | copy ${i.copyAvgMs?.toFixed(2)||"0.00"}ms`),console.log(` p95: ${i.p95.toFixed(2)}ms`),console.log(` p99: ${i.p99.toFixed(2)}ms`),console.log(` jank: ${i.jankFrames}/${i.sampleCount} (${t}%) >16.67ms`);let r=Array.isArray(i.worstFrames)?i.worstFrames:[];if(r.length!==0){if(console.log(`
|
|
348
|
-
worst frames:`),i.mode==="render-worker"){console.log(" total layout render copy t+");for(let o of r){let[n,s,a,
|
|
348
|
+
worst frames:`),i.mode==="render-worker"){console.log(" total layout render copy t+");for(let o of r){let[n,s,l,a,m]=o;console.log(` ${s.toFixed(2).padStart(7)} ${l.toFixed(2).padStart(7)} ${a.toFixed(2).padStart(7)} ${m.toFixed(2).padStart(7)} ${String(n).padStart(5)}`)}return}console.log(` ${r.map(o=>o.toFixed(2)).join(", ")}`)}}function Ke(){return g.join(ke(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Je(i,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let r=1;r<i.length;r++){let o=i[r];if(!(o==="--validate"||o==="--video")){if(o==="--output"){r+=1;continue}r===1&&!o.startsWith("-")||t.push(o)}}return!t.includes("--record")&&i.includes("--video")&&t.push("--record"),t}export{Ue as a,Me as b,je as c,dt as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import{execFileSync as h,spawn as g}from"child_process";import{existsSync as s,readdirSync as k}from"fs";import{dirname as m,join as l,resolve as a}from"path";import{fileURLToPath as v}from"url";var c;function p(){if(c!==void 0)return c;try{c=m(v(import.meta.resolve("sootsim-engine/package.json")))}catch{c=null}return c}var I="dev.sootsim.simulator";function x(){let n=p();if(!n)return null;let e=l(n,"dist-electron/main.cjs");if(!s(e))return null;let i=D(n);return i?{path:i,platform:process.platform,kind:"dev-electron",engineDir:n}:null}function b(){let n=p();return n?s(l(n,"src-electron/main.ts")):!1}function D(n){let e=n;for(let i=0;i<6;i++){let t=l(e,"node_modules/.bin/electron");if(s(t))return t;let r=m(e);if(r===e)break;e=r}return null}function C(){let n=p(),i=["/Applications/sootsim.app",a(process.env.HOME||"","Applications/sootsim.app"),...n?[a(n,"app/sootsim.app")]:[]].find(t=>s(t));if(i)return{path:i,platform:"darwin",kind:"mac-app"};try{let t=h("mdfind",[`kMDItemCFBundleIdentifier == "${I}"`],{encoding:"utf8",timeout:3e3}).trim();if(t)return{path:t.split(`
|
|
3
3
|
`)[0],platform:"darwin",kind:"mac-app"}}catch{}return null}function f(n){if(!s(n))return null;let e=k(n).filter(i=>i.startsWith("sootsim")&&i.endsWith(".AppImage")).sort().reverse()[0];return e?l(n,e):null}function w(){let n=p(),i=[a(process.env.HOME||"","Applications/sootsim.AppImage"),a(process.env.HOME||"",".local/bin/sootsim.AppImage"),"/opt/sootsim/sootsim.AppImage","/opt/sootsim/sootsim",...n?[a(n,"app/sootsim.AppImage"),a(n,"release/linux-unpacked/sootsim")]:[]].find(r=>s(r));if(i)return{path:i,platform:"linux",kind:i.endsWith(".AppImage")?"linux-appimage":"linux-binary"};let t=n?f(a(n,"app"))||f(a(n,"release")):null;return t?{path:t,platform:"linux",kind:"linux-appimage"}:null}function A(){let n=x();if(n)return n;if(b()){let e=p(),i=l(e,"dist-electron/main.cjs");return s(i)?console.error(` no node_modules/.bin/electron found near ${e}. run \`bun install\`.`):console.error(` dist-electron/main.cjs missing in ${e}.
|
|
4
4
|
run: bun run --cwd packages/sootsim-engine build:electron-main
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var o={width:3,lock:{top:253,height:103},ringToggle:{top:152,height:32},volumeUp:{top:214,height:61},volumeDown:{top:290,height:61}},m={width:2.5,lock:{top:130,height:78},ringToggle:{top:94,height:22},volumeUp:{top:126,height:48},volumeDown:{top:188,height:48}},d={width:3,lock:{top:238,height:78},ringToggle:{top:-1e3,height:0},volumeUp:{top:336,height:62},volumeDown:{top:408,height:62}},c={width:3,lock:{top:248,height:72},ringToggle:{top:-1e3,height:0},volumeUp:{top:144,height:62},volumeDown:{top:216,height:62}},a=48;function t(e){return{...e,platform:"ios",navigationBarHeight:0,navigationBarMode:e.homeIndicatorHeight>0?"gesture":"none",displayCutout:{top:e.dynamicIsland?e.statusBarHeight:0,bottom:0,left:0,right:0},cameraCutout:null,osVersion:e.iosVersion,androidApiLevel:null,systemName:"iOS",manufacturer:"Apple",brand:"Apple",modelName:e.name}}var h={"iphone-se":t({name:"iPhone SE",width:375,height:667,scale:2,statusBarHeight:20,homeIndicatorHeight:0,cornerRadius:0,dynamicIsland:null,safeAreaInsets:{top:20,bottom:0,left:0,right:0},iosVersion:"15.8",physicalPPI:326,hardwareButtons:m}),"iphone-14":t({name:"iPhone 14",width:390,height:844,scale:3,statusBarHeight:47,homeIndicatorHeight:34,cornerRadius:55,dynamicIsland:null,safeAreaInsets:{top:47,bottom:34,left:0,right:0},iosVersion:"17.6",physicalPPI:460,hardwareButtons:o}),"iphone-15":t({name:"iPhone 15",width:393,height:852,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:37.3},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"17.6",physicalPPI:460,hardwareButtons:o}),"iphone-15-plus":t({name:"iPhone 15 Plus",width:430,height:932,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:37.3},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"17.6",physicalPPI:460,hardwareButtons:o}),"iphone-15-pro":t({name:"iPhone 15 Pro",width:393,height:852,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:38},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"18.2",physicalPPI:460,hardwareButtons:o}),"iphone-15-pro-max":t({name:"iPhone 15 Pro Max",width:430,height:932,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:38},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"18.2",physicalPPI:460,hardwareButtons:o}),"iphone-16":t({name:"iPhone 16",width:393,height:852,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:37.3},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"iphone-16-plus":t({name:"iPhone 16 Plus",width:430,height:932,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:37.3},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"iphone-16-pro":t({name:"iPhone 16 Pro",width:402,height:874,scale:3,statusBarHeight:62,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:38},safeAreaInsets:{top:62,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"iphone-16-pro-max":t({name:"iPhone 16 Pro Max",width:440,height:956,scale:3,statusBarHeight:62,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:38},safeAreaInsets:{top:62,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"iphone-17":t({name:"iPhone 17",width:402,height:874,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:37.3},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"iphone-17-air":t({name:"iPhone 17 Air",width:430,height:932,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:38},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"iphone-17-pro":t({name:"iPhone 17 Pro",width:402,height:874,scale:3,statusBarHeight:59,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:38},safeAreaInsets:{top:59,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"iphone-17-pro-max":t({name:"iPhone 17 Pro Max",width:440,height:956,scale:3,statusBarHeight:62,homeIndicatorHeight:34,cornerRadius:58,dynamicIsland:{width:126,height:38},safeAreaInsets:{top:62,bottom:34,left:0,right:0},iosVersion:"26.4",physicalPPI:460,hardwareButtons:o}),"ipad-pro-13":t({name:'iPad Pro 13"',width:1032,height:1376,scale:2,statusBarHeight:24,homeIndicatorHeight:20,cornerRadius:18,dynamicIsland:null,safeAreaInsets:{top:24,bottom:20,left:0,right:0},iosVersion:"18.2",physicalPPI:264,hardwareButtons:o}),"pixel-8":{platform:"android",name:"Pixel 8",width:412,height:915,scale:2.625,statusBarHeight:40,homeIndicatorHeight:0,navigationBarHeight:a,navigationBarMode:"gesture",displayCutout:{top:40,bottom:0,left:0,right:0},cornerRadius:39,dynamicIsland:null,cameraCutout:{diameter:24},safeAreaInsets:{top:40,bottom:a,left:0,right:0},osVersion:"15",iosVersion:"",androidApiLevel:35,systemName:"Android",manufacturer:"Google",brand:"google",modelName:"Pixel 8",physicalPPI:428,hardwareButtons:d},"pixel-8-three-button":{platform:"android",name:"Pixel 8 (3-button)",width:412,height:915,scale:2.625,statusBarHeight:40,homeIndicatorHeight:0,navigationBarHeight:48,navigationBarMode:"three-button",displayCutout:{top:40,bottom:0,left:0,right:0},cornerRadius:39,dynamicIsland:null,cameraCutout:{diameter:24},safeAreaInsets:{top:40,bottom:48,left:0,right:0},osVersion:"15",iosVersion:"",androidApiLevel:35,systemName:"Android",manufacturer:"Google",brand:"google",modelName:"Pixel 8",physicalPPI:428,hardwareButtons:d},"pixel-9-pro-xl":{platform:"android",name:"Pixel 9 Pro XL",width:448,height:997,scale:3,statusBarHeight:40,homeIndicatorHeight:0,navigationBarHeight:a,navigationBarMode:"gesture",displayCutout:{top:40,bottom:0,left:0,right:0},cornerRadius:41,dynamicIsland:null,cameraCutout:{diameter:24},safeAreaInsets:{top:40,bottom:a,left:0,right:0},osVersion:"15",iosVersion:"",androidApiLevel:35,systemName:"Android",manufacturer:"Google",brand:"google",modelName:"Pixel 9 Pro XL",physicalPPI:486,hardwareButtons:d},"galaxy-s24":{platform:"android",name:"Galaxy S24",width:360,height:780,scale:3,statusBarHeight:36,homeIndicatorHeight:0,navigationBarHeight:a,navigationBarMode:"gesture",displayCutout:{top:36,bottom:0,left:0,right:0},cornerRadius:36,dynamicIsland:null,cameraCutout:{diameter:18},safeAreaInsets:{top:36,bottom:a,left:0,right:0},osVersion:"15",iosVersion:"",androidApiLevel:35,systemName:"Android",manufacturer:"Samsung",brand:"samsung",modelName:"SM-S921B",physicalPPI:416,hardwareButtons:c},"galaxy-s24-ultra":{platform:"android",name:"Galaxy S24 Ultra",width:384,height:824,scale:3.75,statusBarHeight:36,homeIndicatorHeight:0,navigationBarHeight:a,navigationBarMode:"gesture",displayCutout:{top:36,bottom:0,left:0,right:0},cornerRadius:24,dynamicIsland:null,cameraCutout:{diameter:18},safeAreaInsets:{top:36,bottom:a,left:0,right:0},osVersion:"15",iosVersion:"",androidApiLevel:35,systemName:"Android",manufacturer:"Samsung",brand:"samsung",modelName:"SM-S928B",physicalPPI:505,hardwareButtons:c}},u="iphone-17-pro";function b(e){return h[e]}function g(){return Object.keys(h)}var n={"iphone-6-9":{name:"iphone-6-9",label:'iPhone 6.7"',width:1284,height:2778,store:"apple"},"iphone-6-1":{name:"iphone-6-1",label:'iPhone 6.5"',width:1242,height:2688,store:"apple"},"ipad-13":{name:"ipad-13",label:'iPad 13"',width:2064,height:2752,store:"apple"},"android-phone":{name:"android-phone",label:"Google Play phone",width:1080,height:1920,store:"google"},"android-tablet-7":{name:"android-tablet-7",label:'Google Play 7" tablet',width:1200,height:1920,store:"google"},"android-tablet-10":{name:"android-tablet-10",label:'Google Play 10" tablet',width:1600,height:2560,store:"google"}},s={dark:{type:"gradient",direction:180,glow:"#4caeff",stops:[{offset:0,color:"#111827"},{offset:40,color:"#101725"},{offset:100,color:"#06080d"}]},cyan:{type:"gradient",direction:180,glow:"#25c3ec",stops:[{offset:0,color:"#1b465c"},{offset:32,color:"#122336"},{offset:100,color:"#05070b"}]},gold:{type:"gradient",direction:180,glow:"#ffc25a",stops:[{offset:0,color:"#3b2f1a"},{offset:34,color:"#18140d"},{offset:100,color:"#050505"}]},red:{type:"gradient",direction:180,glow:"#ff6178",stops:[{offset:0,color:"#3e1018"},{offset:35,color:"#17080c"},{offset:100,color:"#050405"}]}},P={color:"#25c3ec",blur:120,spread:52,opacity:.34},S="iphone-17-pro";function v(e){return Object.prototype.hasOwnProperty.call(n,e)?n[e]:null}function f(e){return{type:e.type,color:e.color,direction:e.direction,glow:e.glow,stops:e.stops?.map(r=>({...r}))}}function B(e){return Object.prototype.hasOwnProperty.call(s,e)?f(s[e]):null}var p={deviceModel:{type:"enum",default:u,description:"device model to simulate",cliFlag:"device",cliFlagShort:"d",options:g(),group:"device"},orientation:{type:"enum",default:"portrait",description:"screen orientation",cliFlag:"orientation",options:["portrait","landscape"],group:"device"},colorScheme:{type:"enum",default:"auto",description:"color scheme (auto follows system preference)",cliFlag:"theme",cliFlagShort:"t",options:["light","dark","auto"],group:"appearance"},reduceMotion:{type:"boolean",default:!1,description:"reduce motion",group:"appearance"},boldText:{type:"boolean",default:!1,description:"bold text",group:"appearance"},fontSize:{type:"number",default:1,description:"font size multiplier (1.0 = default)",group:"appearance",validate:e=>e>=.5&&e<=2},networkCondition:{type:"enum",default:"wifi",description:"simulated network condition",cliFlag:"network",options:["wifi","lte","fast-3g","slow-3g","offline"],group:"network"},language:{type:"string",default:"en",description:"language code (ISO 639-1)",cliFlag:"language",group:"locale"},region:{type:"string",default:"US",description:"region code (ISO 3166-1)",cliFlag:"region",group:"locale"},showTouches:{type:"boolean",default:!1,description:"show touch indicators",group:"simulator"},showFrame:{type:"boolean",default:!0,description:"show device frame",cliFlag:"frame",group:"simulator"},showTopBar:{type:"boolean",default:!0,description:"show simulator top bar",group:"simulator"},screenshotMode:{type:"boolean",default:!1,description:"show screenshot composition mode in the browser shell",group:"simulator"},threeMode:{type:"boolean",default:!1,description:"show the experimental 3d device stage in the browser shell",group:"simulator"},screenshotCanvas:{type:"enum",default:"iphone-6-9",description:"target app-store canvas preset for screenshot mode",options:Object.keys(n),group:"simulator"},screenshotBackground:{type:"enum",default:"dark",description:"background preset rendered inside the screenshot canvas",options:Object.keys(s),group:"simulator"},screenshotText:{type:"enum",default:"bold-top",description:"text layout preset for the screenshot canvas",options:["bold-top","editorial-left","minimal-bottom","none"],group:"simulator"},screenshotPose:{type:"enum",default:"straight",description:"device pose preset inside the screenshot canvas",options:["straight","tilted-left","tilted-right","cut-bottom","cut-top"],group:"simulator"},screenshotDynamicSize:{type:"boolean",default:!1,description:"let the screenshot canvas rect fit available space (off = pin to exact preset pixels)",group:"simulator"},showStatusBar:{type:"boolean",default:!0,description:"show status bar",group:"simulator"},showHomeIndicator:{type:"boolean",default:!0,description:"show home indicator",group:"simulator"},a11yMode:{type:"enum",default:"delayed",description:"accessibility tree sync mode (off, delayed=100ms, active=30ms)",options:["off","delayed","active"],group:"simulator"},a11yDepth:{type:"enum",default:"deep",description:"accessibility tree structure depth (shallow or deep)",options:["shallow","deep"],group:"simulator"},inspectMode:{type:"boolean",default:!1,description:"inspect mode",group:"simulator"},errorReporting:{type:"boolean",default:!1,description:"send anonymous crash reports",group:"privacy"},agentProvider:{type:"enum",default:"codex",description:"ai agent used by the sootsim agent prompt bar",options:["codex","claude"],group:"agent"},onboardingComplete:{type:"boolean",default:!1,description:"first-run onboarding completed",group:"beta"},betaConsentVersion:{type:"number",default:0,description:"last accepted beta telemetry policy version",group:"beta"},detailedTelemetry:{type:"boolean",default:!0,description:"send detailed usage telemetry (sessions, perf samples)",group:"beta"}};function y(){if(typeof window>"u")return{};let e={};try{let r=new URLSearchParams(window.location.search),i=r.get("device");i&&p.deviceModel.options?.includes(i)&&(e.deviceModel=i);let l=r.get("colorScheme")??r.get("theme");l&&p.colorScheme.options?.includes(l)&&(e.colorScheme=l)}catch{}return e}function H(){let e={};for(let[r,i]of Object.entries(p))e[r]=i.default;return Object.assign(e,y()),e}export{P as a,S as b,v as c,f as d,B as e,h as f,b as g,g as h,p as i,y as j,H as k};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as D,b as
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as D,b as j,c as se}from"./chunk-WXOAHKCZ.js";import{b as L}from"./chunk-6JZNIGOQ.js";import{g as W}from"./chunk-6A4CZMPO.js";import{a as k,b as q}from"./chunk-AYU6WUNF.js";import{c as ie}from"./chunk-7IYYIF5B.js";import{d as ne}from"./chunk-YEE4EO2P.js";import{a as ee}from"./chunk-CKZSGUTE.js";import{b as re,c as x,d as b,e as C}from"./chunk-GWGF4J4Y.js";import{c as I,d as g,e as E}from"./chunk-STWL7EXR.js";import{E as te,F as oe}from"./chunk-E3S6U2QR.js";import xe from"node:fs";import Ce from"node:os";import J from"node:path";function he(t){return t.replace(/^\[|\]$/g,"").toLowerCase()}function G(t){let o=he(t);return o==="localhost"||o.endsWith(".localhost")||o==="0.0.0.0"||o==="::1"||/^127(?:\.\d{1,3}){3}$/.test(o)}function ae(t){return new Error(`could not resolve a native bundle for ${t}. pass an explicit bundle URL or open Connect and choose the app there.`)}function we(t,o){return t?.includes("/one/metro-entry.bundle")?"one":typeof o=="string"&&o?"expo":"unknown"}function le(t,o,e){return`${t}//${o}:${e}`}function ye(t){if(typeof window>"u")return!1;try{let o=new URL(t);return G(o.hostname)&&G(window.location.hostname)&&o.origin!==window.location.origin}catch{return!1}}async function ce(t,o){let e={...o,cache:o?.cache??"no-store"};return ye(t)?fetch(`/__fetch-proxy?url=${encodeURIComponent(t)}`,e):fetch(t,e)}function be(t){return t==="https:"?443:80}function Se(t){let o=t.pathname||"/";return(o==="/"||o==="")&&!t.search&&!t.hash}async function me(t,o){let e=t.replace(/\/+$/,"");try{let n=await ce(`${e}/`,{headers:{"expo-platform":"ios"}});if(n.ok){let r=await n.json(),i=r?.extra?.expoClient||r?.extra||{},s=typeof r?.launchAsset?.url=="string"?r.launchAsset.url:void 0;if(s||i.name)return{bundleUrl:se(s||`${e}${j}`),port:o,framework:we(s,i.sdkVersion),projectName:i.name}}}catch{}try{let n=await ce(`${e}/status`);if(n.ok&&(await n.text()).includes("packager-status:running"))return{bundleUrl:`${e}${j}`,port:o,framework:"metro"}}catch{}return null}async function $e(t){return me(le("http:","localhost",t),t)}async function Q(t){let o=t.trim();if(/^\d+$/.test(o)){let a=parseInt(o,10),l=await $e(a);if(l)return l;throw ae(`localhost:${a}`)}let e=o.startsWith("http")?o:`http://${o}`,n;try{n=new URL(e)}catch{throw new Error(`could not parse "${t}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let r=n.protocol||"http:",i=n.port?parseInt(n.port,10):be(r),s=le(r,n.hostname,i);if(Se(n)){let a=await me(s,i);if(a)return a;throw ae(s)}return{bundleUrl:n.toString(),port:i,framework:"unknown"}}function qe(){console.error(" no sootsim desktop companion found."),console.error(""),console.error(" install the desktop app:"),console.error(" sootsim install-desktop"),console.error(""),console.error(" or wire sootsim into your own project so your dev server hosts the bridge:"),console.error(" sootsim setup-repo"),console.error("")}function de(t){let o=k();if(console.log(` note: no sootsim bridge detected on port ${t}`),o){console.log(" launch the installed companion with:"),console.log(" sootsim electron");return}console.log(""),console.log(" to get a bridge running, either:"),console.log(" sootsim install-desktop # download the electron app"),console.log(" sootsim setup-repo # wire sootsim into your own project")}function ve(t){console.error(""),console.error(` no sim is connected to the sootsim bridge on port ${t}.`),console.error(""),console.error(" start your app dev server, then open it in sootsim:"),console.error(" npx expo start --localhost --port 8081"),console.error(" sootsim open 8081"),console.error(""),console.error(" then inspect the live app:"),console.error(" sootsim describe")}async function We(t,o,e){let n=[];try{n=await t.listSims()}catch{}if(console.error(""),n.length===0){ve(o);return}console.error(` no sim with id "${e}" is connected to the bridge on port ${o}.`),console.error(""),console.error(" connected sims:");for(let r of n){let i=[r.isPrimary?"primary":null,r.readyState].filter(Boolean).join(", ");console.error(` ${r.id} (${i})`)}console.error(""),console.error(" pass a valid --sim id, or run `sootsim list` to see all sessions.")}var Pe={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function P(t){return new Promise(o=>setTimeout(o,t))}function V(t){return t.trim()}function K(t){try{let o=new URL(t),e=o.pathname.replace(/\/+$/,"")||"/";return o.searchParams.has("open")||o.searchParams.has("port")||o.searchParams.has("bundle")||o.searchParams.has("demo")||o.pathname.includes("/sootsim/index.html")||e==="/sootsim"||o.pathname==="/__soot"||o.pathname==="/__soot/"||e==="/rn"||/^\/rn\/[^/]+$/i.test(e)||/^\/app\/[^/]+$/i.test(e)||e==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(e)||/^\/__soot\/app\/[^/]+$/i.test(e)}catch{return!1}}async function ct(t){let o=V(t);return(await Q(o)).bundleUrl}function X(t){let o=t.replace(/\/+$/,"")||"/";return o==="/__soot"||o.startsWith("/__soot/")?"/__soot":""}function Ie(t,o){let e=V(t),n=new URL(o),r=X(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),/^\d+$/.test(e)?n.pathname=`${r}/rn/${e}`:(n.pathname=`${r}/rn`,n.searchParams.set("open",e)),n.toString()}function ke(t){let o=V(t);return/^\d+$/.test(o)||/^https?:\/\//i.test(o)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(o)}async function Me(t,o){let e=await Q(t),n=new URL(o),r=X(n.pathname);return n.pathname=`${r}/rn`,n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.set("bundle",e.bundleUrl),n.toString()}function Te(t){return t.startsWith("~/")?J.join(Ce.homedir(),t.slice(2)):J.isAbsolute(t)?t:J.resolve(process.cwd(),t)}function Ue(t){let o={};for(let e=0;e<t.length;e++){if(t[e]!=="--replace")continue;let n=t[e+1];n||(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let r=n.indexOf("=");(r<=0||r===n.length-1)&&(console.error(" sootsim open: --replace expects <module>=<file>"),process.exit(1));let i=n.slice(0,r).trim(),s=Te(n.slice(r+1).trim());xe.existsSync(s)||(console.error(` sootsim open: replacement file not found: ${s}`),process.exit(1)),o[i]={file:s},e++}return Object.keys(o).length>0?{modules:o}:void 0}function pe(){let t=te();return oe(t)&&t.runtimePort>0?`http://localhost:${t.runtimePort}/`:ee}async function N(t,o=pe()){if(!t)return new URL(o).toString();if(K(t))return new URL(t).toString();let e=Pe[t.toLowerCase()];if(e){let n=new URL(o),r=X(n.pathname);return n.pathname=`${r}${e}`,n.toString()}return ke(t)?Me(t,o):Ie(t,o)}function ue(t,o){let e=t?.url||t?.origin||o;try{let n=new URL(e);return n.searchParams.delete("bundle"),n.searchParams.delete("demo"),n.searchParams.delete("app"),n.searchParams.delete("open"),n.searchParams.delete("port"),n.searchParams.delete("inspectOpen"),n.toString()}catch{return o}}async function Be(t,o,e){let n=new URL(await N(t,o));return n.searchParams.set("inspectOpen",e),n.toString()}async function Oe(t,o,e,n={}){let r=n.attempts??30,i=n.intervalMs??500,s=n.minNodeCount??10;for(let a=0;a<r;a++){let l=b(t,{commandTimeoutMs:o,simId:e,simIdSource:"flag"});try{let c=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>s)return{bridge:l,count:c}}catch{}l.close(),await P(i)}return null}function _e(t){if(!t)return null;try{let o=new URL(t);if(o.searchParams.has("bundle")){let e=o.searchParams.get("bundle")||"";try{let n=new URL(e),r=n.pathname.length>36?`...${n.pathname.slice(-36)}`:n.pathname;return`bundle ${n.host}${r}`}catch{return"bundle"}}return o.searchParams.has("port")?`connect :${o.searchParams.get("port")||""}`:o.searchParams.has("open")?`connect ${o.searchParams.get("open")||""}`:o.searchParams.has("demo")?`demo ${o.searchParams.get("demo")||"default"}`:o.pathname.includes("/sootsim/index.html")||o.pathname==="/sootsim/"||o.pathname==="/sootsim"?"embedded sootsim":null}catch{return null}}function Re(t,o){if(t.length===0){console.log(" no sims connected");return}console.log(` connected sims (${t.length}):
|
|
3
3
|
`);for(let e of t){let n=e.lockedBy&&e.lockExpiresAt?`locked by ${e.lockedBy} (${Math.max(0,Math.round((e.lockExpiresAt-Date.now())/1e3))}s)`:"",r=[e.isPrimary?"primary":"",e.id===o?"selected":"",e.readyState,e.attachedCliCount&&e.attachedCliCount>0?"in use":"",e.userFocused?"focused":"",n].filter(Boolean);console.log(` ${e.id}${r.length?` [${r.join(", ")}]`:""}`);let i=_e(e.url);if(i&&console.log(` loaded: ${i}`),e.url?console.log(` url: ${e.url}`):e.origin&&console.log(` origin: ${e.origin}`),e.title&&console.log(` title: ${e.title}`),console.log(` connected: ${new Date(e.connectedAt).toISOString()}`),e.lastActiveAt&&e.lastActiveAt>0){let s=Math.round((Date.now()-e.lastActiveAt)/1e3),a=s<60?`${s}s ago`:s<3600?`${Math.round(s/60)}m ago`:`${Math.round(s/3600)}h ago`;console.log(` last active: ${a}`)}}}async function A(t,o,e,n={}){let r=n.attempts??30,i=n.intervalMs??500;for(let s=0;s<r;s++){let a=b(t,{commandTimeoutMs:o});try{let c=(await a.listSims()).find(e);if(c)return c}catch{}finally{a.close()}await P(i)}return null}async function Ee(t,o,e,n={}){let r=n.attempts??20,i=n.intervalMs??250;for(let s=0;s<r;s++){let a=b(t,{commandTimeoutMs:o});try{let c=(await a.listSims()).find(f=>f.id===e);if(!c||c.readyState!=="open")return!0}catch{return!0}finally{a.close()}await P(i)}return!1}function U(t,o){if(o){let r=o.trim(),i=t.find(s=>s.id===r);if(!i)throw new Error(`no sim connected with id ${r}`);return i}let e=t.find(r=>r.isPrimary&&r.readyState==="open");if(e)return e;let n=t.find(r=>r.readyState==="open");if(n)return n;throw new Error("no sim connected")}function M(t,o,e){console.log(` ${e==="current sim"?"loaded":"opened"}: ${t} [${e}]`),console.log(` current sim: ${o.id}`),console.log(JSON.stringify({simId:o.id,url:o.url},null,2))}async function T(t,o,e){if(e.includes("--no-describe"))return;let n=process.env.SOOTSIM_QUIET_TARGET_NOTICE;process.env.SOOTSIM_QUIET_TARGET_NOTICE="1";try{await Le(t,o,{stableMs:150,maxMs:400});let r=b(t,{commandTimeoutMs:3e3,simId:o,cliLabel:"open --describe",simIdSource:"flag"});try{let s=`(async () => {
|
|
4
4
|
const t = window.__sootsimTest
|
|
5
5
|
const ms = window.SootSim?.bridges?.mainShell
|
|
@@ -8,4 +8,4 @@ import{a as D,b as q,c as se}from"./chunk-SLAAAEUZ.js";import{b as L}from"./chun
|
|
|
8
8
|
try { shell = ms?.getState ? await ms.getState() : null } catch {}
|
|
9
9
|
const tree = await t.dumpTree(12, ${JSON.stringify({describe:!0,verbose:!1,filter:""})})
|
|
10
10
|
return { tree, shell }
|
|
11
|
-
})()`,a=await r.send({type:"evaluate",code:s});if(!a?.tree)return;if(console.log(""),a.shell?.state){let l=[`state=${a.shell.state}`,a.shell.activeApp?`app=${a.shell.activeApp}`:null].filter(Boolean);console.log(` shell: ${l.join(" ")}`)}console.log(a.tree)}finally{r.close()}}catch{}finally{n===void 0?delete process.env.SOOTSIM_QUIET_TARGET_NOTICE:process.env.SOOTSIM_QUIET_TARGET_NOTICE=n}}async function Le(t,o,e){let n=Date.now()+e.maxMs,r="(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()",i=b(t,{commandTimeoutMs:2e3,simId:o,simIdSource:"flag"});try{let s=-1,a=0;for(;Date.now()<n;){let l=-1;try{let c=await i.send({type:"evaluate",code:r});typeof c=="number"&&(l=c)}catch{}if(l>=0&&l===s){if(Date.now()-a>=e.stableMs)return}else s=l,a=Date.now();await P(50)}}finally{i.close()}}async function lt(t,o={}){let e=x(t,{port:o.port,commandTimeoutMs:o.timeoutMs}),n=C(e);try{let r=await n.listSims();Re(r,e.simId)}finally{n.close()}}async function mt(t,o={}){let e=x(t,{port:o.port,commandTimeoutMs:o.timeoutMs,stripBooleanFlags:["--new","--headless","--ephemeral"],stripValueFlags:["--base-url","--replace","--driver","--profile"]}),n=t.find((m,d)=>t[d-1]==="--profile"),r=t.includes("--ephemeral");n&&r&&(console.error(" sootsim open: --profile cannot be combined with --ephemeral"),process.exit(1));let i=n?ie(n).id:void 0,s=!!i||r,a=t.includes("--new")||s,l=Ue(t);a&&e.simIdSource==="flag"&&(console.error(" sootsim open: --new, --profile, and --ephemeral cannot be combined with --sim"),process.exit(1));let c=e.positional[0]||"",f=t.find((m,d)=>t[d-1]==="--driver")||"",h=t.includes("--headless"),S=t.find((m,d)=>t[d-1]==="--base-url")||pe(),B=t.includes("--base-url"),$=I();if(!a&&(e.simIdSource==="flag"||e.simIdSource==="saved"&&!!$)){let m=C(e),d=e.simId?` --sim ${e.simId}`:"",u=!1;try{let p=null;try{let y=await m.listSims();if(e.simIdSource==="saved"?(p=y.find(v=>v.id===$&&v.readyState==="open")??null,p||E()):p=U(y,e.simId),!p)if(e.simIdSource==="saved")u=!0;else throw new Error("no sim connected");if(!u&&p){let v=B||K(c)?S:ue(p,S),R=await N(c,D(v,l));m.send({type:"evaluate",simId:p.id,code:`window.location.href = ${JSON.stringify(R)}`}).catch(()=>{})}}catch(y){console.error(` open failed: ${y instanceof Error?y.message:String(y)}`),await L(m,{errorsCommand:`sootsim get errors 5${d}`,warningsCommand:`sootsim get warnings 5${d}`,requestsCommand:`sootsim get requests 5${d}`}),process.exit(1)}if(!u&&p){await P(1500);let y=await Oe(e.wsPort,e.commandTimeoutMs,p.id);y||(console.error(" timed out waiting for current sim to load target"),process.exit(1)),y.bridge.close(),g(p.id);let v=B||K(c)?S:ue(p,S),R=await N(c,D(v,l));M(R,{...p,url:R},"current sim"),await T(e.wsPort,p.id,t);return}}finally{m.close()}}let Y=D(S,l),ge=await N(c,Y),Z=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,w=await Be(c,Y,Z),F={newWindow:!0},O=m=>m.url?.includes(`inspectOpen=${Z}`)??!1;if(f){let m=W(f);m||(console.error(` unknown driver "${f}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let d=await m.launch({url:w,headless:h,newWindow:F.newWindow,profileId:i,ephemeralProfile:r});d.launched||(console.error(` ${m.name} driver: ${d.message}`),process.exit(1));let u=await A(e.wsPort,e.commandTimeoutMs,O,{attempts:60,intervalMs:500});u||(console.error(" timed out waiting for opened sim to connect"),process.exit(1)),g(u.id),M(w,u,`${m.name} driver`),await T(e.wsPort,u.id,t);return}if(s){let m=k();m||(console.error(" profiles require electron or playwright; install the desktop companion or use `--driver playwright`"),process.exit(1));try{(await
|
|
11
|
+
})()`,a=await r.send({type:"evaluate",code:s});if(!a?.tree)return;if(console.log(""),a.shell?.state){let l=[`state=${a.shell.state}`,a.shell.activeApp?`app=${a.shell.activeApp}`:null].filter(Boolean);console.log(` shell: ${l.join(" ")}`)}console.log(a.tree)}finally{r.close()}}catch{}finally{n===void 0?delete process.env.SOOTSIM_QUIET_TARGET_NOTICE:process.env.SOOTSIM_QUIET_TARGET_NOTICE=n}}async function Le(t,o,e){let n=Date.now()+e.maxMs,r="(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()",i=b(t,{commandTimeoutMs:2e3,simId:o,simIdSource:"flag"});try{let s=-1,a=0;for(;Date.now()<n;){let l=-1;try{let c=await i.send({type:"evaluate",code:r});typeof c=="number"&&(l=c)}catch{}if(l>=0&&l===s){if(Date.now()-a>=e.stableMs)return}else s=l,a=Date.now();await P(50)}}finally{i.close()}}async function lt(t,o={}){let e=x(t,{port:o.port,commandTimeoutMs:o.timeoutMs}),n=C(e);try{let r=await n.listSims();Re(r,e.simId)}finally{n.close()}}async function mt(t,o={}){let e=x(t,{port:o.port,commandTimeoutMs:o.timeoutMs,stripBooleanFlags:["--new","--headless","--ephemeral"],stripValueFlags:["--base-url","--replace","--driver","--profile"]}),n=t.find((m,d)=>t[d-1]==="--profile"),r=t.includes("--ephemeral");n&&r&&(console.error(" sootsim open: --profile cannot be combined with --ephemeral"),process.exit(1));let i=n?ie(n).id:void 0,s=!!i||r,a=t.includes("--new")||s,l=Ue(t);a&&e.simIdSource==="flag"&&(console.error(" sootsim open: --new, --profile, and --ephemeral cannot be combined with --sim"),process.exit(1));let c=e.positional[0]||"",f=t.find((m,d)=>t[d-1]==="--driver")||"",h=t.includes("--headless"),S=t.find((m,d)=>t[d-1]==="--base-url")||pe(),B=t.includes("--base-url"),$=I();if(!f&&!a&&(e.simIdSource==="flag"||e.simIdSource==="saved"&&!!$)){let m=C(e),d=e.simId?` --sim ${e.simId}`:"",u=!1;try{let p=null;try{let y=await m.listSims();if(e.simIdSource==="saved"?(p=y.find(v=>v.id===$&&v.readyState==="open")??null,p||E()):p=U(y,e.simId),!p)if(e.simIdSource==="saved")u=!0;else throw new Error("no sim connected");if(!u&&p){let v=B||K(c)?S:ue(p,S),R=await N(c,D(v,l));m.send({type:"evaluate",simId:p.id,code:`window.location.href = ${JSON.stringify(R)}`}).catch(()=>{})}}catch(y){console.error(` open failed: ${y instanceof Error?y.message:String(y)}`),await L(m,{errorsCommand:`sootsim get errors 5${d}`,warningsCommand:`sootsim get warnings 5${d}`,requestsCommand:`sootsim get requests 5${d}`}),process.exit(1)}if(!u&&p){await P(1500);let y=await Oe(e.wsPort,e.commandTimeoutMs,p.id);y||(console.error(" timed out waiting for current sim to load target"),process.exit(1)),y.bridge.close(),g(p.id);let v=B||K(c)?S:ue(p,S),R=await N(c,D(v,l));M(R,{...p,url:R},"current sim"),await T(e.wsPort,p.id,t);return}}finally{m.close()}}let Y=D(S,l),ge=await N(c,Y),Z=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,w=await Be(c,Y,Z),F={newWindow:!0},O=m=>m.url?.includes(`inspectOpen=${Z}`)??!1;if(f){let m=W(f);m||(console.error(` unknown driver "${f}" \u2014 run \`sootsim list --drivers\``),process.exit(1));let d=await m.launch({url:w,headless:h,newWindow:F.newWindow,profileId:i,ephemeralProfile:r});d.launched||(console.error(` ${m.name} driver: ${d.message}`),process.exit(1));let u=await A(e.wsPort,e.commandTimeoutMs,O,{attempts:60,intervalMs:500});u||(console.error(" timed out waiting for opened sim to connect"),process.exit(1)),g(u.id),M(w,u,`${m.name} driver`),await T(e.wsPort,u.id,t);return}if(s){let m=k();m||(console.error(" profiles require electron or playwright; install the desktop companion or use `--driver playwright`"),process.exit(1));try{(await q(w,m,{profileId:i,ephemeralProfile:r})).launched||(console.error(" desktop companion failed to start"),process.exit(1))}catch(u){console.error(` desktop companion failed: ${u instanceof Error?u.message:String(u)}`),process.exit(1)}let d=await A(e.wsPort,e.commandTimeoutMs,O,{attempts:40,intervalMs:500});d||(console.error(" timed out waiting for profiled sim to connect"),process.exit(1)),g(d.id),M(w,d,"desktop companion"),await T(e.wsPort,d.id,t);return}let H=!1,z=!1;try{let m=b(e.wsPort,{commandTimeoutMs:2e3});try{await m.listSims(),H=!0}finally{m.close()}}catch{}if(H)try{let m=b(e.wsPort,{commandTimeoutMs:3e3});try{await m.openUrl(w,F),z=!0}finally{m.close()}}catch{}if(!z){let m=k();if(m)try{if((await q(w,m)).launched){let u=await A(e.wsPort,e.commandTimeoutMs,O,{attempts:20,intervalMs:500});if(u){g(u.id),M(w,u,"desktop companion"),await T(e.wsPort,u.id,t);return}}}catch{}try{await ne(w,F)}catch(d){console.error(` open failed: ${d instanceof Error?d.message:String(d)}`),W("playwright")?.availability().available?console.error(" no system browser found \u2014 retry with `sootsim open \u2026 --driver playwright` for a headless sim."):console.error(" run `sootsim list --drivers` to see available drivers."),process.exit(1)}if(!H){console.log(` opened: ${ge}`),de(e.wsPort);return}}let _=await A(e.wsPort,e.commandTimeoutMs,O,{attempts:30,intervalMs:500});_||(console.error(" timed out waiting for opened sim to connect"),process.exit(1)),g(_.id),M(w,_,z?"bridge":"direct shell open"),await T(e.wsPort,_.id,t)}async function fe(t,o={}){let e=x(t,{port:o.port,commandTimeoutMs:o.timeoutMs}),n=C(e),r=e.simId?` --sim ${e.simId}`:"";try{try{let i=await n.listSims(),s=U(i,e.positional[0]||e.simId);await n.focusSim(s.id),g(s.id),console.log(` using: ${s.id}`)}catch(i){console.error(` use failed: ${i instanceof Error?i.message:String(i)}`),await L(n,{errorsCommand:`sootsim get errors 5${r}`,warningsCommand:`sootsim get warnings 5${r}`,requestsCommand:`sootsim get requests 5${r}`}),process.exit(1)}}finally{n.close()}}async function dt(t,o={}){await fe(t,o)}async function ut(t,o={}){await fe(t,o)}async function pt(t,o={}){let e=x(t,{port:o.port,commandTimeoutMs:o.timeoutMs,stripBooleanFlags:["--force"]}),n=t.includes("--force"),r=C(e);try{try{let i=await r.listSims(),s=U(i,e.positional[0]||e.simId),a=n&&s.lockedBy&&s.lockedByKind!=="user-active"?s.lockedBy:null,l=await r.claim(s.id,{force:n});g(s.id);let c=Math.max(0,Math.round((l.lockExpiresAt-Date.now())/1e3)),f=l.bootedCount>0?` (booted ${l.bootedCount})`:"";console.log(` claimed: ${l.simId} [${c}s]${f}`),a&&console.log(` took over from: ${a}`)}catch(i){if(i instanceof re){let s=Math.max(0,Math.round(i.lock.expiresInMs/1e3));console.error(` claim failed: locked by ${i.lock.by} for ${s}s more`),console.error(" use --force to take it, or `sootsim open --new` for a fresh sim"),process.exit(1)}console.error(` claim failed: ${i instanceof Error?i.message:String(i)}`),process.exit(1)}}finally{r.close()}}async function De(t,o,e,n){if(n.length===0)return{closed:[],remaining:[]};await Promise.all(n.map(i=>t.closeSim(i).catch(()=>{})));let r=new Set(n);for(let i=0;i<40;i++){let s=[];try{let a=b(o,{commandTimeoutMs:e});try{s=(await a.listSims()).filter(c=>r.has(c.id)&&c.readyState==="open").map(c=>c.id)}finally{a.close()}}catch{s=[]}if(s.length===0)return{closed:[...r],remaining:[]};if(i===39)return{closed:[...r].filter(a=>!s.includes(a)),remaining:s};await P(250)}return{closed:[...r],remaining:[]}}async function ft(t,o={}){let e=x(t,{port:o.port,commandTimeoutMs:o.timeoutMs,stripBooleanFlags:["--all","--others"]}),n=C(e),r=e.simId?` --sim ${e.simId}`:"",i=t.includes("--all"),s=t.includes("--others");if(i||s){try{let a=await n.listSims(),l=a.filter($=>$.readyState==="open"),c=null;if(s)try{c=U(a,e.positional[0]||e.simId||I()||void 0).id}catch{c=null}let f=l.map($=>$.id).filter($=>$!==c);if(f.length===0){console.log(c?` nothing to close \u2014 only the kept sim ${c} is connected`:" nothing to close \u2014 no sims connected");return}let h=await De(n,e.wsPort,e.commandTimeoutMs,f),S=I();S&&h.closed.includes(S)&&(c?g(c):E());let B=` closed ${h.closed.length} sim(s)${c?` (kept ${c})`:""}`;console.log(B),h.remaining.length>0&&(console.error(` close failed: still connected: ${h.remaining.join(", ")}`),process.exit(1))}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),process.exit(1)}finally{n.close()}return}try{try{let a=await n.listSims(),l=U(a,e.positional[0]||e.simId),c=a.find(h=>h.id!==l.id&&h.readyState==="open");await n.closeSim(l.id),await Ee(e.wsPort,e.commandTimeoutMs,l.id)||(console.error(` close failed: ${l.id} is still connected`),process.exit(1)),I()===l.id&&(c?g(c.id):E()),console.log(` closed: ${l.id}`)}catch(a){console.error(` close failed: ${a instanceof Error?a.message:String(a)}`),await L(n,{errorsCommand:`sootsim get errors 5${r}`,warningsCommand:`sootsim get warnings 5${r}`,requestsCommand:`sootsim get requests 5${r}`}),process.exit(1)}}finally{n.close()}}export{qe as a,ve as b,We as c,ct as d,pe as e,N as f,Be as g,_e as h,Re as i,A as j,lt as k,mt as l,dt as m,ut as n,pt as o,ft as p};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as d}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as d}from"./chunk-GWGF4J4Y.js";import{a as p,d as w,h as $,j as y}from"./chunk-E4JTYQVY.js";import{A as g,B as f,i as h,y as m,z as a}from"./chunk-E3S6U2QR.js";import b from"fs";import{WebSocket as D}from"ws";async function P(n,e={}){let[o,...t]=n;if(!o||o==="--help"||o==="-h"){R();return}switch(o){case"install":return O(t,e);case"list":case"ls":return S(t);case"use":return T(t);case"remove":case"rm":return N(t);case"which":case"active":return F();default:console.error(` unknown runtime subcommand: ${o}`),R(),process.exit(1)}}function R(){console.log(`
|
|
3
3
|
sootsim runtime \u2014 manage engine runtimes under ~/.sootsim/runtimes/
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -22,4 +22,4 @@ examples:
|
|
|
22
22
|
sootsim runtime install 1.2.3
|
|
23
23
|
sootsim runtime install --channel beta
|
|
24
24
|
sootsim runtime use 1.2.3
|
|
25
|
-
`)}async function O(n,e){let{version:o,flags:t}=_(n),s=t.channel??e.channel??"stable",l=t.force===!0,c=t.setActive!==!1;m(),console.log("sootsim runtime install"),console.log(` cdn: ${w()}`);try{let i=await y({version:o,channel:s,force:l,setActive:c});console.log(` version: ${i.version} (channel: ${i.channel})`),i.installed?console.log(` installed ${i.version}`):console.log(` already installed at ${i.runtimeDir}`),c&&await k(i.version)}catch(i){console.error(` ${I(i)}`),process.exit(1)}}async function k(n){g(n),console.log(` active: ${n}`),await A(n)||console.log(` (no daemon running \u2014 next sootsim/electron launch will pick up ${n})`)}async function A(n){let{isDaemonLockfileFresh:e,readDaemonLockfile:o}=await import("./home-paths-
|
|
25
|
+
`)}async function O(n,e){let{version:o,flags:t}=_(n),s=t.channel??e.channel??"stable",l=t.force===!0,c=t.setActive!==!1;m(),console.log("sootsim runtime install"),console.log(` cdn: ${w()}`);try{let i=await y({version:o,channel:s,force:l,setActive:c});console.log(` version: ${i.version} (channel: ${i.channel})`),i.installed?console.log(` installed ${i.version}`):console.log(` already installed at ${i.runtimeDir}`),c&&await k(i.version)}catch(i){console.error(` ${I(i)}`),process.exit(1)}}async function k(n){g(n),console.log(` active: ${n}`),await A(n)||console.log(` (no daemon running \u2014 next sootsim/electron launch will pick up ${n})`)}async function A(n){let{isDaemonLockfileFresh:e,readDaemonLockfile:o}=await import("./home-paths-UYEDTYXU.js"),t=o();if(!e(t))return!1;let s=d();return new Promise(l=>{let c=!1,i=!1,u=x=>{c||(c=!0,l(x))},r=new D(`ws://127.0.0.1:${s}`,{handshakeTimeout:800}),v=setTimeout(()=>{try{r.close()}catch{}u(i)},1500);r.on("open",()=>{try{r.send(JSON.stringify({type:"runtime:use",version:n,id:0})),i=!0}catch{}setTimeout(()=>{try{r.close()}catch{}},100)}),r.on("close",()=>{clearTimeout(v),u(i)}),r.on("error",()=>{clearTimeout(v),u(!1)})})}async function S(n){m();let e=f(),o=a();if(console.log("installed:"),e.length===0)console.log(" (none)");else for(let t of e)console.log(` ${t===o?"*":" "} ${t}`);try{let t=await $();console.log("available (latest per channel):");for(let[s,l]of Object.entries(t.channels))console.log(` ${s.padEnd(8)} ${l.latest}`)}catch(t){console.log(`available: (could not fetch manifest: ${I(t)})`)}}async function T(n){let e=n[0];e||(console.error(" usage: sootsim runtime use <version>"),process.exit(1));let o=f();o.includes(e)||(console.error(` version ${e} is not installed`),console.error(` installed: ${o.join(", ")||"(none)"}`),console.error(` run \`sootsim runtime install ${e}\` first`),process.exit(1)),await k(e)}async function N(n){let e=n[0];e||(console.error(" usage: sootsim runtime remove <version>"),process.exit(1)),a()===e&&(console.error(` cannot remove active runtime ${e}`),console.error(" switch with `sootsim runtime use <other>` first, or install another version"),process.exit(1));let t=h(e);if(!b.existsSync(t)){console.error(` ${e} is not installed`);return}b.rmSync(t,{recursive:!0,force:!0}),console.log(` removed ${e}`)}async function F(){let n=a();if(!n){console.log(" no active runtime");return}console.log(n)}function _(n){let e={},o=[];for(let t=0;t<n.length;t++){let s=n[t];if(s==="--channel"&&t+1<n.length){e.channel=n[t+1],t++;continue}if(s.startsWith("--channel=")){e.channel=s.slice(10);continue}if(s==="--force"){e.force=!0;continue}if(s==="--set-active=false"||s==="--no-set-active"){e.setActive=!1;continue}o.push(s)}return{version:o[0]??null,flags:e}}function I(n){return n instanceof Error?n.message:String(n)}export{P as a};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{l as c}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{l as c}from"./chunk-E3S6U2QR.js";import{chmodSync as m,existsSync as g,mkdirSync as k,readFileSync as A,rmSync as i,writeFileSync as y}from"node:fs";import{dirname as l,join as D,resolve as p}from"node:path";var s=1,S="SOOTSIM_SHARED_AUTH_FILE",u="https://sootbean.com";function v(){let t=process.env[S];return t?.trim()?l(p(t)):c()}function a(){let t=process.env[S];return t?.trim()?p(t):D(v(),"desktop-auth.json")}function f(t){if(!t||typeof t!="object")return null;let e=t;return typeof e.id!="string"||!e.id.trim()?null:{id:e.id.trim(),name:typeof e.name=="string"?e.name:void 0,email:typeof e.email=="string"?e.email:void 0,image:typeof e.image=="string"?e.image:void 0}}function w(t){if(!t||typeof t!="object")return null;let e=t;if(e.version!==s||typeof e.token!="string"||!e.token.trim())return null;let r=typeof e.origin=="string"&&e.origin.trim()?e.origin.trim():u,n=e.source==="cli"||e.source==="electron"||e.source==="browser"||e.source==="unknown"?e.source:"unknown",o=typeof e.updatedAt=="string"&&e.updatedAt?e.updatedAt:new Date().toISOString(),h=typeof e.validatedAt=="string"&&e.validatedAt?e.validatedAt:void 0;return{version:s,token:e.token.trim(),user:f(e.user),origin:r,source:n,updatedAt:o,validatedAt:h}}function O(){let t=a();if(!g(t))return null;try{let e=JSON.parse(A(t,"utf8")),r=w(e);return r||(i(t,{force:!0}),null)}catch{return i(t,{force:!0}),null}}function I(t){let e=a();k(l(e),{recursive:!0});let r={version:s,token:t.token.trim(),user:t.user?f(t.user):null,origin:t.origin?.trim()||u,source:t.source,updatedAt:t.updatedAt||new Date().toISOString(),validatedAt:t.validatedAt};y(e,JSON.stringify(r,null,2)+`
|
|
3
3
|
`);try{m(e,384)}catch{}return r}function d(){i(a(),{force:!0})}async function N(t){let e=O();if(!e?.token)return null;let r=t||e.origin||u;try{let n=await fetch(`${r.replace(/\/$/,"")}/api/auth/me`,{headers:{authorization:`Bearer ${e.token}`}});if(n.status===401)return d(),null;if(!n.ok)return e;let o=await n.json();return o.user?.id?I({token:e.token,user:o.user,origin:r,source:e.source,validatedAt:new Date().toISOString()}):(d(),null)}catch{return e}}export{O as a,I as b,d as c,N as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
import{readFileSync as i}from"node:fs";import{fileURLToPath as e}from"node:url";var r=null;function l(){if(r!=null)return r;let o=[()=>e(import.meta.resolve("sootsim/package.json")),()=>e(new URL("../package.json",import.meta.url))];for(let n of o)try{let t=JSON.parse(i(n(),"utf8")).version;if(typeof t=="string"&&t)return r=t,r}catch{}return r="0.0.0",r}export{l as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{d as Q,e as X}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.53 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{d as Q,e as X}from"./chunk-IS5ORPFW.js";import{d as K}from"./chunk-YEE4EO2P.js";import{a as J,b as m}from"./chunk-SQZXAKBL.js";import{a as D}from"./chunk-CTDDR7HW.js";import{c as q,e as Y,g as v}from"./chunk-GWGF4J4Y.js";import{createHash as Te}from"crypto";import{readFileSync as te}from"fs";import{gzipSync as ne}from"zlib";function Z(e){let t=(e||"").toLowerCase().split(";")[0].trim();return t?!(t.startsWith("image/")||t.startsWith("video/")||t.startsWith("audio/")||t==="font/woff2"||t==="application/font-woff2"||t==="application/zip"||t==="application/gzip"):!0}function H(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(new Error(`${t} timed out after ${e/1e3}s`)),e);return{signal:r.signal,cancel:()=>clearTimeout(s)}}async function be(e){let t=H(12e4,`PUT ${e.url}`),r;try{r=await fetch(e.url,{method:"PUT",headers:{"content-type":e.contentType},body:e.bytes,signal:t.signal})}finally{t.cancel()}if(!r.ok){let s=await r.text().catch(()=>"");throw new Error(`PUT ${r.status}: ${s.slice(0,200)}`)}}async function we(e,t=8,r){let s=0,o=0,a=e.length;await Promise.all(Array.from({length:Math.min(t,a)},async()=>{for(;s<a;){let u=e[s++];await be(u),o++,r?.(o,a)}}))}function ve(e,t,r,s){let o=[];o.push({url:e.bundle.putUrl,contentType:e.bundle.contentType,bytes:t});for(let a of e.files){let u=r.get(a.urlhash);u&&o.push({url:a.putUrl,contentType:a.contentType,bytes:u})}return e.events&&s?.eventsBytes&&o.push({url:e.events.putUrl,contentType:e.events.contentType,bytes:s.eventsBytes}),e.flowVideo&&s?.videoBytes&&o.push({url:e.flowVideo.putUrl,contentType:e.flowVideo.contentType,bytes:s.videoBytes}),e.storage&&s?.storageBytes&&o.push({url:e.storage.putUrl,contentType:e.storage.contentType,bytes:s.storageBytes}),o}function Be(e){return e.replace(/\/+$/,"")}var _=class extends Error{constructor(r,s,o,a=""){super(r);this.status=s;this.phase=o;this.responseText=a;this.name="PresignedUploadError"}};async function ee(e){let t=Be(e.originBase),r={"content-type":"application/json"};e.authHeader&&(r.authorization=e.authHeader),e.adminBypassToken&&(r["x-soot-admin-upload-bypass"]=e.adminBypassToken);let s=H(3e4,"init"),o;try{o=await fetch(`${t}/api/preview/upload/init`,{method:"POST",headers:r,body:JSON.stringify(e.initBody),signal:s.signal})}finally{s.cancel()}if(!o.ok){let h=await o.text().catch(()=>"");throw new _(`init failed: ${o.status} ${h.slice(0,200)}`,o.status,"init",h)}let a=await o.json(),u=ve(a,e.bundleBytes,e.filesByHash,e.extras);await we(u,e.concurrency??8,e.onPutProgress);let b=H(3e4,"finalize"),p;try{p=await fetch(`${t}/api/preview/upload/finalize`,{method:"POST",headers:r,body:JSON.stringify({token:a.token}),signal:b.signal})}finally{b.cancel()}if(!p.ok){let h=await p.text().catch(()=>"");throw new _(`finalize failed: ${p.status} ${h.slice(0,200)}`,p.status,"finalize",h)}let P=await p.json();return{init:a,finalize:P}}function Ie(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t.message=="string"&&t.message?t.message:null}catch{return null}}var ie=process.env.SOOTSIM_UPLOAD_ORIGIN||"https://sootbean.com",ae=process.env.SOOTSIM_PREVIEW_ORIGIN||"https://sootsim.com",M="http://localhost:3000";async function Ue(e){if(e)return e;if(process.env.SOOTSIM_UPLOAD_ORIGIN)return process.env.SOOTSIM_UPLOAD_ORIGIN;try{let t=await fetch(`${M}/api/preview/upload/init`,{method:"OPTIONS"});if(t.ok||t.status===204||t.status===405)return M}catch{}return ie}function B(e){return e.replace(/\/$/,"")}function Pe(e){try{let r=new URL(e).hostname.replace(/^\[|\]$/g,"").toLowerCase();return r==="localhost"||r.endsWith(".localhost")||r==="0.0.0.0"||r==="::1"||/^127(?:\.\d{1,3}){3}$/.test(r)}catch{return!1}}function xe(e){try{let t=new URL(e).hostname.toLowerCase();return t==="sootbean.com"||t.endsWith(".sootbean.com")}catch{return!1}}function Se(e,t){return t?B(t):process.env.SOOTSIM_PREVIEW_ORIGIN?B(process.env.SOOTSIM_PREVIEW_ORIGIN):Pe(e)?B(e):xe(e)?B(ae):B(e)}function Oe(){console.log(`
|
|
3
3
|
sootsim upload \u2014 publish the current bundle as a /preview/<id> link
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -62,5 +62,5 @@ examples:
|
|
|
62
62
|
} catch { return false }
|
|
63
63
|
})
|
|
64
64
|
})()`),P)){let T=g.length;g=g.filter(I=>se(I.contentType));let F=i.totalBytes-g.reduce((I,R)=>I+(R.size||0),0);console.log(` --assets-only: kept ${g.length}/${T} records (dropped ${(F/1024).toFixed(1)} KiB of API responses)`)}}l?.transformedBundle&&(z=await _e(w,l.transformedBundle.byteLength))}finally{w.close()}l||(console.error(" could not read bundle snapshot \u2014 is sootsim running and is the bundle loaded?"),process.exit(2)),l.bundleUrl||(console.error(` no ?bundle= URL on the current sootsim tab.
|
|
65
|
-
open the app you want to share first (e.g. sootsim open 8082), then run upload.`),process.exit(2));let d,A=!1;if(z!==null)d=new TextEncoder().encode(z),A=!0,console.log(` using post-transform bundle: ${(d.byteLength/1024).toFixed(1)} KiB`);else{let n=Re(l.bundleUrl);n!==l.bundleUrl&&console.log(" forcing lazy=false for self-contained bundle"),console.log(` capturing: ${n}`),d=await oe(n),console.log(` main bundle: ${(d.byteLength/1024).toFixed(1)} KiB`)}let x=C.filter(n=>n.url!==l.bundleUrl);P&&(x=x.filter(n=>se(n.contentType))),console.log(` fetching ${x.length} extra files\u2026`);let S=(await Promise.all(x.map(async n=>{try{let i=await oe(n.url);return{...n,bytes:i}}catch(i){return console.error(` warning: failed to re-fetch ${n.url}: ${i instanceof Error?i.message:i}`),null}}))).filter(n=>!!n),le=S.reduce((n,i)=>n+i.bytes.byteLength,0);console.log(` ${S.length} extra files: ${(le/1024).toFixed(1)} KiB`);let y;a&&(y=te(a));let f,O,N;if(u){if(f=te(u),O=u.endsWith(".mp4")?"video/mp4":u.endsWith(".gif")?"image/gif":"video/webm",b){let n=Number(b);(!Number.isFinite(n)||n<=0)&&(console.error(` invalid --video-duration-ms: ${b}`),await m(),process.exit(1)),N=Math.round(n)}console.log(` attaching flow video: ${(f.byteLength/1024).toFixed(1)} KiB (${O})`)}let c=Q(),ue=
|
|
66
|
-
stored ${k.filesStored??0} extra files`),console.log(` preview: ${G}`),p&&await
|
|
65
|
+
open the app you want to share first (e.g. sootsim open 8082), then run upload.`),process.exit(2));let d,A=!1;if(z!==null)d=new TextEncoder().encode(z),A=!0,console.log(` using post-transform bundle: ${(d.byteLength/1024).toFixed(1)} KiB`);else{let n=Re(l.bundleUrl);n!==l.bundleUrl&&console.log(" forcing lazy=false for self-contained bundle"),console.log(` capturing: ${n}`),d=await oe(n),console.log(` main bundle: ${(d.byteLength/1024).toFixed(1)} KiB`)}let x=C.filter(n=>n.url!==l.bundleUrl);P&&(x=x.filter(n=>se(n.contentType))),console.log(` fetching ${x.length} extra files\u2026`);let S=(await Promise.all(x.map(async n=>{try{let i=await oe(n.url);return{...n,bytes:i}}catch(i){return console.error(` warning: failed to re-fetch ${n.url}: ${i instanceof Error?i.message:i}`),null}}))).filter(n=>!!n),le=S.reduce((n,i)=>n+i.bytes.byteLength,0);console.log(` ${S.length} extra files: ${(le/1024).toFixed(1)} KiB`);let y;a&&(y=te(a));let f,O,N;if(u){if(f=te(u),O=u.endsWith(".mp4")?"video/mp4":u.endsWith(".gif")?"image/gif":"video/webm",b){let n=Number(b);(!Number.isFinite(n)||n<=0)&&(console.error(` invalid --video-duration-ms: ${b}`),await m(),process.exit(1)),N=Math.round(n)}console.log(` attaching flow video: ${(f.byteLength/1024).toFixed(1)} KiB (${O})`)}let c=Q(),ue=D();J({event:"preview_upload_started",identity:{userId:c?.kind==="session"?ue?.user?.id??null:null,repoId:c?.kind==="github"?c.repoId:null,installationId:c?.kind==="github"?c.installationId??null:null},properties:{origin:s,hasAuth:!!c,authMode:c?.kind??"none",bundleBytes:d.byteLength,isTransformed:A,extraFiles:S.length,recordedFetches:g.length,hasEvents:!!y,hasVideo:!!f}}),c||(console.error(" preview uploads need auth."),console.error(" set SOOTSIM_API_KEY=sk_sootsim_..., run `sootsim login`, or use the soot github runner."),await m(),process.exit(1));let ce=X(c),de=(()=>{try{return new URL(l.bundleUrl).origin}catch{return null}})(),W=(n,i,T,F,I,R,ye)=>{let V=Z(R),me=V?ne(n):n;return{url:i,urlhash:T,method:F,bodyHash:I,contentType:R,responseHeaders:ye,bytes:me,encoding:V?"gzip":void 0}},E=[...S.map(n=>W(n.bytes,n.url,n.urlhash,"GET","-",n.contentType,n.responseHeaders)),...g.map(n=>W(Buffer.from(n.bodyBase64,"base64"),n.url,n.urlhash,n.method||"GET",n.bodyHash||"-",n.contentType,n.responseHeaders))],L=ne(d),pe=Te("sha256").update(d).digest("hex");console.log(` bundle raw=${(d.byteLength/1024).toFixed(1)} KiB gz=${(L.byteLength/1024).toFixed(1)} KiB`);let ge={contentHash:pe,bundleSizeBytes:d.byteLength,bundleContentType:$e(l.bundleUrl),bundleEncoding:"gzip",bundleOrigin:de,entry:l.entry,isTransformed:A,deviceSpec:l.deviceSpec,installationId:c.kind==="github"?c.installationId??void 0:void 0,repoId:c.kind==="github"?c.repoId:void 0,files:E.map(n=>({url:n.url,urlhash:n.urlhash,method:n.method,bodyHash:n.bodyHash,contentType:n.contentType,responseHeaders:n.responseHeaders,encoding:n.encoding,sizeBytes:n.bytes.byteLength})),events:y?{sizeBytes:y.byteLength}:void 0,flowVideo:f&&O?{sizeBytes:f.byteLength,contentType:O,durationMs:N}:void 0},j=new Map;for(let n of E)j.set(n.urlhash,n.bytes);let fe=Date.now(),$=L.byteLength;for(let n of E)$+=n.bytes.byteLength;y&&($+=y.byteLength),f&&($+=f.byteLength);let he=`${B(s)}/api/preview/upload/init`;console.log(` init: ${he}`);let k;try{let n=await ee({originBase:s,initBody:ge,bundleBytes:L,filesByHash:j,extras:{eventsBytes:y,videoBytes:f},authHeader:ce,concurrency:16});k=n.finalize;let i=1+n.init.files.length+(n.init.events?1:0)+(n.init.flowVideo?1:0);console.log(` PUT ${i} objects in ${Date.now()-fe}ms (${($/1024).toFixed(1)} KiB)`)}catch(n){let i=n;i.phase==="init"&&i.status===401&&(console.error(" preview upload requires a valid login."),console.error(" run `sootsim login` and retry."),await m(),process.exit(1)),i.status===402&&(console.error(` ${Ie(i.responseText)??"preview uploads require Personal, Team, or an active trial \u2014 upgrade from the billing dialog."}`),await m(),process.exit(1)),console.error(` ${i.message??`${i.phase??"upload"} failed: ${String(n)}`}`),await m(),process.exit(1)}let G=`${o}${k.url}`;console.log(`
|
|
66
|
+
stored ${k.filesStored??0} extra files`),console.log(` preview: ${G}`),p&&await K(G),await m()}export{Ue as a,Se as b,Ve as c};
|