sootsim 0.1.188 → 0.1.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist-cli/bin.js +7 -7
- package/dist-cli/chunks/{agent-BRLC23GZ.js → agent-XZWMKC4F.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-HDWSAABN.js → agent-wrapper-CFJYDDAY.js} +2 -2
- package/dist-cli/chunks/{app-fonts-KQHDDWAH.js → app-fonts-64UN5GRY.js} +2 -2
- package/dist-cli/chunks/{assert-BA3G3DLH.js → assert-A3MQH7ZB.js} +2 -2
- package/dist-cli/chunks/auth-CNKNHD6U.js +10 -0
- package/dist-cli/chunks/beta-CDL7U2RE.js +2 -0
- package/dist-cli/chunks/camera-YQPIDOEN.js +20 -0
- package/dist-cli/chunks/{chunk-I52NHG4X.js → chunk-24OZOK2K.js} +1 -1
- package/dist-cli/chunks/{chunk-OXB6RPMX.js → chunk-3JVMBXLH.js} +2 -2
- package/dist-cli/chunks/{chunk-GAP76GG5.js → chunk-5IM3DYTZ.js} +1 -1
- package/dist-cli/chunks/{chunk-DBOVJCG5.js → chunk-6EFMFMJB.js} +2 -2
- package/dist-cli/chunks/{chunk-DKOKNFWR.js → chunk-6UQKBGI7.js} +2 -3
- package/dist-cli/chunks/{chunk-ERHMPVNZ.js → chunk-7TSFDDU7.js} +2 -2
- package/dist-cli/chunks/chunk-AAQ6AYYW.js +2 -0
- package/dist-cli/chunks/chunk-CD3ARXZW.js +1 -0
- package/dist-cli/chunks/chunk-CTP3U4WV.js +13 -0
- package/dist-cli/chunks/{chunk-QDUHROO5.js → chunk-CVUAT6TO.js} +1 -1
- package/dist-cli/chunks/chunk-DHDV2I2T.js +1 -0
- package/dist-cli/chunks/{chunk-TAXDBR5N.js → chunk-EBBYYBYM.js} +3 -3
- package/dist-cli/chunks/chunk-F6GCSGBJ.js +8 -0
- package/dist-cli/chunks/{chunk-HIS4TFND.js → chunk-INRO26KS.js} +2 -2
- package/dist-cli/chunks/{install-desktop-F43JZSJO.js → chunk-IOJDFCGV.js} +7 -7
- package/dist-cli/chunks/{chunk-D6GYUATH.js → chunk-ITQV76PX.js} +1 -1
- package/dist-cli/chunks/chunk-IUVDM73R.js +140 -0
- package/dist-cli/chunks/{chunk-2MRFRROI.js → chunk-K5GLQDTG.js} +2 -2
- package/dist-cli/chunks/{chunk-FUZNRCAR.js → chunk-K7OCH4WY.js} +2 -2
- package/dist-cli/chunks/{chunk-NCENLBIL.js → chunk-KLGX6B46.js} +2 -2
- package/dist-cli/chunks/{chunk-AUQ7FZIX.js → chunk-LRJVY7SN.js} +2 -2
- package/dist-cli/chunks/{chunk-2T6Z4WCN.js → chunk-MH6BMKK5.js} +1 -1
- package/dist-cli/chunks/{chunk-Y3I43AUV.js → chunk-MJU4XNZ3.js} +1 -1
- package/dist-cli/chunks/{chunk-ZZ7FODQE.js → chunk-NAI6N6SN.js} +8 -7
- package/dist-cli/chunks/chunk-P7MW7S62.js +87 -0
- package/dist-cli/chunks/chunk-PGQHNKRL.js +119 -0
- package/dist-cli/chunks/chunk-PR3IKD6A.js +2 -0
- package/dist-cli/chunks/chunk-PSETHPMH.js +565 -0
- package/dist-cli/chunks/{chunk-BZNPGYJQ.js → chunk-QJVITDKU.js} +1 -1
- package/dist-cli/chunks/{chunk-SVSZFGNA.js → chunk-QNVY6BLP.js} +1 -1
- package/dist-cli/chunks/{chunk-YNY3WSH4.js → chunk-R3VO3MDO.js} +1 -1
- package/dist-cli/chunks/{chunk-5U22ZNDP.js → chunk-SJHC6HZH.js} +1 -1
- package/dist-cli/chunks/{chunk-ZZTGVTE3.js → chunk-SMDCNCVZ.js} +1 -1
- package/dist-cli/chunks/{chunk-TPHYWQB2.js → chunk-SPYRMNAJ.js} +5 -5
- package/dist-cli/chunks/{chunk-B272R3FA.js → chunk-TBFBGSRV.js} +1 -1
- package/dist-cli/chunks/chunk-UPN7Z5XZ.js +916 -0
- package/dist-cli/chunks/{chunk-KOEBHC3D.js → chunk-WHYPFQIZ.js} +2 -2
- package/dist-cli/chunks/{chunk-NDAGMI4C.js → chunk-WR5IDCCN.js} +1 -1
- package/dist-cli/chunks/{chunk-BJMQRL7V.js → chunk-WT74ZUKN.js} +1 -1
- package/dist-cli/chunks/{chunk-5XZN2C22.js → chunk-Y6CZ5N26.js} +2 -2
- package/dist-cli/chunks/{chunk-IULK4TUU.js → chunk-YWQH2KQJ.js} +1 -1
- package/dist-cli/chunks/cli-version-PVRNMRL7.js +2 -0
- package/dist-cli/chunks/{compat-6QHB5UPF.js → compat-AU7EW2AY.js} +3 -3
- package/dist-cli/chunks/config-TNZV6ASD.js +11 -0
- package/dist-cli/chunks/control-TKDPQACC.js +2 -0
- package/dist-cli/chunks/daemon-L57B7HBL.js +2 -0
- package/dist-cli/chunks/{debug-OTEVKM5L.js → debug-H5UHUDC4.js} +3 -3
- package/dist-cli/chunks/desktop-WYPCYR3Z.js +32 -0
- package/dist-cli/chunks/{detox-MISIYJRV.js → detox-36VI5PZ3.js} +2 -2
- package/dist-cli/chunks/{device-R3BORN7B.js → device-XPSGGSM5.js} +2 -2
- package/dist-cli/chunks/{diagnose-G7UE2PUJ.js → diagnose-CH3VYGFO.js} +10 -10
- package/dist-cli/chunks/drivers-XDAXVIZF.js +2 -0
- package/dist-cli/chunks/flow-Q24HN25I.js +2 -0
- package/dist-cli/chunks/help-OPVDM7BI.js +2 -0
- package/dist-cli/chunks/{home-paths-EJFFLJZR.js → home-paths-IT2LCG6O.js} +2 -2
- package/dist-cli/chunks/inspect-FEMU6KSY.js +2 -0
- package/dist-cli/chunks/install-desktop-NCMJNSW7.js +2 -0
- package/dist-cli/chunks/{login-3ZNZJ7P4.js → login-O6XRDK26.js} +5 -5
- package/dist-cli/chunks/{logout-34JBFFT4.js → logout-YK7BH4AK.js} +2 -2
- package/dist-cli/chunks/{maestro-JYCD7OQT.js → maestro-T52UBLSK.js} +6 -6
- package/dist-cli/chunks/mode-L4GR563F.js +93 -0
- package/dist-cli/chunks/optional-demo-registry-PDFLBZMQ.js +2 -0
- package/dist-cli/chunks/perf-7DYLYEBO.js +43 -0
- package/dist-cli/chunks/{record-L54OVMQQ.js → record-MNIFB5DJ.js} +7 -7
- package/dist-cli/chunks/runtime-E4KWRPBT.js +2 -0
- package/dist-cli/chunks/screenshot-command-D77AXBND.js +190 -0
- package/dist-cli/chunks/{serve-D6HGTNWI.js → serve-LFPZVOVA.js} +2 -2
- package/dist-cli/chunks/{setup-MR7SX23V.js → setup-6FX2KQP4.js} +3 -3
- package/dist-cli/chunks/skills-36CRDBMN.js +48 -0
- package/dist-cli/chunks/storage-N45XGOMV.js +35 -0
- package/dist-cli/chunks/store-USJP5W6S.js +2 -0
- package/dist-cli/chunks/telemetry-WQ7RK6NE.js +2 -0
- package/dist-cli/chunks/test-GCVW3U2P.js +69 -0
- package/dist-cli/chunks/{timeline-SBCWQHQT.js → timeline-4ALLBESW.js} +2 -2
- package/dist-cli/chunks/{upgrade-RGJVNFZO.js → upgrade-75XAVSMJ.js} +2 -2
- package/dist-cli/chunks/upload-34BCSEFZ.js +2 -0
- package/dist-cli/chunks/{version-23HGJOE3.js → version-MSFDAHVF.js} +2 -2
- package/dist-cli/chunks/{web-YMQPB45M.js → web-IS75NWAC.js} +2 -2
- package/dist-cli/chunks/{what-happened-3AJBD35R.js → what-happened-TW6SN7Z7.js} +2 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +53 -0
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1 -1
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +15 -7
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro.cjs +13 -5
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +121 -79
- package/dist-lib/vite.cjs +13 -5
- package/package.json +1 -1
- package/skills/{soot.md → soot/SKILL.md} +12 -25
- package/skills/{sootsim-debug.md → sootsim-debug/SKILL.md} +1 -1
- package/skills/sootsim-perf/SKILL.md +169 -0
- package/skills/{sootsim-test.md → sootsim-test/SKILL.md} +10 -7
- package/src/metro-plugin.ts +2 -2
- package/src/runtime-assets.ts +16 -2
- package/src/screenshots/orchestrate.ts +1 -1
- package/src/screenshots/org-deck.ts +1 -1
- package/src/vite-plugin-one.ts +2 -2
- package/dist-cli/chunks/beta-O43XI622.js +0 -2
- package/dist-cli/chunks/camera-22Q4QVTC.js +0 -20
- package/dist-cli/chunks/chunk-3ECPODR2.js +0 -382
- package/dist-cli/chunks/chunk-4JG6GDLB.js +0 -2
- package/dist-cli/chunks/chunk-5D6TXWZQ.js +0 -3
- package/dist-cli/chunks/chunk-6LAPS7RP.js +0 -3
- package/dist-cli/chunks/chunk-FHHOZTPI.js +0 -3
- package/dist-cli/chunks/chunk-FXHED7P5.js +0 -79
- package/dist-cli/chunks/chunk-HGER3AOP.js +0 -69
- package/dist-cli/chunks/chunk-HXEGZCLS.js +0 -118
- package/dist-cli/chunks/chunk-JOE4R2PO.js +0 -1
- package/dist-cli/chunks/chunk-MXYAGDBC.js +0 -24
- package/dist-cli/chunks/chunk-PCKWE63K.js +0 -987
- package/dist-cli/chunks/chunk-QCDWRDUC.js +0 -1
- package/dist-cli/chunks/chunk-SGZP6JCZ.js +0 -16
- package/dist-cli/chunks/chunk-V7V6WDIM.js +0 -13
- package/dist-cli/chunks/chunk-WST3QKHD.js +0 -180
- package/dist-cli/chunks/cli-version-74E3VGPF.js +0 -2
- package/dist-cli/chunks/control-A2KALMZE.js +0 -2
- package/dist-cli/chunks/cpu-profile-A3ST63G2.js +0 -2
- package/dist-cli/chunks/daemon-KBQK2QRU.js +0 -2
- package/dist-cli/chunks/drivers-4URQ5PMT.js +0 -2
- package/dist-cli/chunks/electron-DXMMDHR3.js +0 -19
- package/dist-cli/chunks/flow-OETRQOLM.js +0 -2
- package/dist-cli/chunks/help-FSZ5FRHV.js +0 -2
- package/dist-cli/chunks/hints-QJSWKWC5.js +0 -2
- package/dist-cli/chunks/inspect-EFTHNTN2.js +0 -2
- package/dist-cli/chunks/keys-P2HBCVAX.js +0 -19
- package/dist-cli/chunks/optional-demo-registry-MM6GWJNB.js +0 -2
- package/dist-cli/chunks/preview-PIEAC5MZ.js +0 -17
- package/dist-cli/chunks/profile-BTCKOPAU.js +0 -22
- package/dist-cli/chunks/react-UYKTFQZW.js +0 -30
- package/dist-cli/chunks/runtime-ZB7S4Z3H.js +0 -2
- package/dist-cli/chunks/screenshot-A5WQUFIQ.js +0 -35
- package/dist-cli/chunks/screenshot-mode-GBZSTZTV.js +0 -17
- package/dist-cli/chunks/screenshots-EHE2FKTA.js +0 -74
- package/dist-cli/chunks/screenshots-capture-MOZJ2RQV.js +0 -41
- package/dist-cli/chunks/skills-NHV2ZFOU.js +0 -48
- package/dist-cli/chunks/slides-WDFLQWCZ.js +0 -46
- package/dist-cli/chunks/store-7EYKU7RK.js +0 -2
- package/dist-cli/chunks/telemetry-MU23XMBJ.js +0 -2
- package/dist-cli/chunks/telemetry-NF6KAWA4.js +0 -2
- package/dist-cli/chunks/test-CVQHZHMJ.js +0 -31
- package/dist-cli/chunks/three-mode-UCOVUXVY.js +0 -58
- package/dist-cli/chunks/upload-GHIMBL2Y.js +0 -2
- package/dist-cli/chunks/whoami-ZM3TCPNU.js +0 -2
- /package/skills/{sootsim-setup.md → sootsim-setup/SKILL.md} +0 -0
- /package/skills/{sootsim-visual.md → sootsim-visual/SKILL.md} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*! sootsim v0.1.190 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{k as x}from"./chunk-UPN7Z5XZ.js";import"./chunk-IUVDM73R.js";import"./chunk-CTP3U4WV.js";import"./chunk-SPYRMNAJ.js";import"./chunk-CD3ARXZW.js";import"./chunk-R3VO3MDO.js";import"./chunk-WR5IDCCN.js";import"./chunk-MJU4XNZ3.js";import"./chunk-WHYPFQIZ.js";import"./chunk-QNVY6BLP.js";import{g as R,i as N,l as d,m as S}from"./chunk-Y6CZ5N26.js";import"./chunk-NAI6N6SN.js";import"./chunk-TBFBGSRV.js";import"./chunk-QJVITDKU.js";import"./chunk-PR3IKD6A.js";import"./chunk-6EFMFMJB.js";import"./chunk-PGQHNKRL.js";import"./chunk-7TSFDDU7.js";import"./chunk-CVUAT6TO.js";import"./chunk-SJHC6HZH.js";import"./chunk-MH6BMKK5.js";import"./chunk-ITQV76PX.js";import"./chunk-YWQH2KQJ.js";import{mkdirSync as W,writeFileSync as A}from"fs";import{dirname as J,resolve as B}from"path";import{WebSocket as E}from"ws";var C=e=>new Promise(o=>setTimeout(o,e)),v=class{ws;nextId=1;pending=new Map;listeners=new Set;ready;constructor(o){this.ws=new E(o,{maxPayload:1<<28}),this.ready=new Promise((r,t)=>{this.ws.once("open",()=>r()),this.ws.once("error",t)}),this.ws.on("message",r=>{let t=JSON.parse(r.toString());if(t.id&&this.pending.has(t.id)){let{res:n,rej:s}=this.pending.get(t.id);this.pending.delete(t.id),t.error?s(new Error(JSON.stringify(t.error))):n(t.result)}else if(t.method)for(let n of this.listeners)n(t.method,t.params)})}waitOpen(){return this.ready}on(o){this.listeners.add(o)}send(o,r={},t){let n=this.nextId++;return new Promise((s,l)=>{this.pending.set(n,{res:s,rej:l}),this.ws.send(JSON.stringify({id:n,method:o,params:r,...t?{sessionId:t}:{}}))})}close(){try{this.ws.close()}catch{}}};async function O(e,o){let r=Number(w(e,"--duration")??"5");if(!Number.isFinite(r)||r<=0)return console.error(" --duration must be a positive number (seconds)"),1;let t=Number(w(e,"--sample-interval")??"0.1"),n=Number(w(e,"--cdp-port")??process.env.SOOTSIM_CDP_PORT??"9222"),s=w(e,"--match")??"/rn/",l=w(e,"--output")??w(e,"-o"),i=B(process.cwd(),l??"/tmp/sootsim.cpuprofile"),a=[];try{a=await(await fetch(`http://localhost:${n}/json/list`)).json()}catch{return U(n),1}let f=a.find(m=>m.type==="page"&&m.url.includes(s));if(!f)return console.error(` no page target matching "${s}" on CDP :${n}`),console.error(` open targets: ${a.map(m=>m.url).join(", ")||"(none)"}`),1;let u=new v(f.webSocketDebuggerUrl);await u.waitOpen();try{let m=new Map;if(u.on((c,p)=>{c==="Target.attachedToTarget"&&p.targetInfo?.type==="worker"&&m.set(p.sessionId,p.targetInfo.url),c==="Target.detachedFromTarget"&&m.delete(p.sessionId)}),await u.send("Target.setAutoAttach",{autoAttach:!0,waitForDebuggerOnStart:!1,flatten:!0}),await C(500),m.size===0)return console.error(" no worker targets attached \u2014 is the app loaded in this tab?"),1;for(let c of m.keys())await u.send("Profiler.enable",{},c),await u.send("Profiler.setSamplingInterval",{interval:t*1e3},c),await u.send("Profiler.start",{},c);console.log(` recording ${r}s across ${m.size} worker(s) \u2014 interact now\u2026`),await C(r*1e3);let b=[];for(let[c,p]of m){let{profile:y}=await u.send("Profiler.stop",{},c);b.push({url:p,profile:y})}return b.sort((c,p)=>p.profile.samples.length-c.profile.samples.length),W(J(i),{recursive:!0}),b.forEach((c,p)=>{let y=p===0?i:i.replace(/(\.[^.]+)?$/,`.worker${p}$1`);if(A(y,JSON.stringify(c.profile)),console.log(` ${P(c.url)}: ${c.profile.samples.length} samples \u2192 ${y}`),o.verbose&&c.profile.samples.length>0)for(let $ of _(c.profile,12))console.log(` ${$.pct.toFixed(1).padStart(5)}% ${$.name} ${$.url}`)}),console.log(" open in chrome devtools \u2192 Performance \u2192 Load profile to inspect."),0}finally{u.close()}}function U(e){console.error(` perf cpu needs a CDP-enabled browser on :${e}.`),console.error(" the tenant worker can't be profiled via the JS Self-Profiler API (F28),"),console.error(" so the sim must expose Chrome remote debugging. easiest path \u2014"),console.error(" open the sim with a CDP port (it stays driveable over the bridge,"),console.error(" so you can scroll/navigate while profiling):"),console.error(""),console.error(` sootsim open <metro-port> --new --driver playwright --cdp-port ${e}`),console.error(` sootsim perf cpu --cdp-port ${e} --match <metro-port>`),console.error(""),console.error(" or launch a standalone CDP Chrome (not bridge-driveable):"),console.error(""),console.error(' "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \\'),console.error(` --remote-debugging-port=${e} --user-data-dir=/tmp/sootsim-cdp \\`),console.error(" --no-sandbox --disable-gpu-sandbox --in-process-gpu \\"),console.error(" --use-gl=angle --use-angle=swiftshader --enable-unsafe-swiftshader \\"),console.error(' "http://localhost:5173/rn/<metro-port>" &'),console.error(""),console.error(" override the port with --cdp-port or $SOOTSIM_CDP_PORT.")}function P(e){return e?e.replace(/^https?:\/\/[^/]+/,"").replace(/\?.*$/,"").slice(-50):"(native)"}function _(e,o){let r=e.samples.length||1,t=new Map;for(let n of e.nodes){let s=n.callFrame,l=`${s.functionName||"(anonymous)"}@${P(s.url)}:${s.lineNumber}`,i=t.get(l)??{self:0,name:s.functionName||"(anonymous)",url:`${P(s.url)}:${s.lineNumber}`};i.self+=n.hitCount??0,t.set(l,i)}return[...t.values()].map(n=>({...n,pct:n.self/r*100})).sort((n,s)=>s.self-n.self).slice(0,o)}function w(e,o){let r=e.indexOf(o);if(!(r<0||r===e.length-1))return e[r+1]}function j(){console.log(`
|
|
3
|
+
sootsim perf react \u2014 inspect React component render cost in the tenant worker
|
|
4
|
+
|
|
5
|
+
usage:
|
|
6
|
+
sootsim perf react profile start [--include-props] [--max-commits N]
|
|
7
|
+
sootsim perf react profile stop
|
|
8
|
+
sootsim perf react summary [--limit 10] [--json]
|
|
9
|
+
sootsim perf react slow [--limit 5] [--json]
|
|
10
|
+
sootsim perf react rerenders [--limit 5] [--json]
|
|
11
|
+
sootsim perf react tree [--depth 3] [--find <name>] [--json]
|
|
12
|
+
sootsim perf react why <fiber-id> [--json]
|
|
13
|
+
|
|
14
|
+
\`react summary\` is the demo-friendly shortcut: it runs both slow and
|
|
15
|
+
rerenders in one round-trip, prints them as a single table per side,
|
|
16
|
+
and surfaces the duration-zero warning prominently when the bundle is
|
|
17
|
+
running without React profiler timers.
|
|
18
|
+
|
|
19
|
+
examples:
|
|
20
|
+
sootsim perf react profile start
|
|
21
|
+
sootsim do tap-text Inbox
|
|
22
|
+
sootsim perf react profile stop
|
|
23
|
+
sootsim perf react summary --limit 10
|
|
24
|
+
sootsim perf react slow --limit 10
|
|
25
|
+
sootsim perf react rerenders --json
|
|
26
|
+
`)}function F(e,o){let r=e.indexOf(o);if(r>=0&&r+1<e.length)return e[r+1];let t=`${o}=`,n=e.find(s=>s.startsWith(t));return n?n.slice(t.length):void 0}function h(e,o,r){let t=F(e,o);if(t===void 0)return r;let n=Number(t);return Number.isFinite(n)&&n>0?Math.round(n):r}function M(e,o){let r=e.map((n,s)=>Math.max(n.length,...o.map(l=>l[s]?.length??0))),t=n=>n.map((s,l)=>s.padEnd(r[l])).join(" ").trimEnd();return[t(e),t(e.map(n=>"-".repeat(n.length))),...o.map(t)].map(n=>` ${n}`).join(`
|
|
27
|
+
`)}function g(e){console.log(JSON.stringify(e,null,2))}function T(e){e.error&&console.error(` warning: ${e.error}`),e.durationWarning&&console.error(` warning: ${e.durationWarning}`);let o=e.rows??[];if(o.length===0){console.log(` no React render samples yet (${e.commits??0} commit(s))`);return}console.log(M(["component","total","avg","commits","slowest"],o.map(r=>[r.displayName,`${r.totalMs.toFixed(2)}ms`,`${r.avgMs.toFixed(2)}ms`,String(r.commitCount),`#${r.slowestCommit} ${r.slowestMs.toFixed(2)}ms`])))}function k(e){e.error&&console.error(` warning: ${e.error}`);let o=e.rows??[];if(o.length===0){console.log(` no React render samples yet (${e.commits??0} commit(s))`);return}console.log(M(["component","renders","causes"],o.map(r=>{let t=Object.entries(r.causes??{}).filter(([,n])=>n>0).sort((n,s)=>s[1]-n[1]).slice(0,4).map(([n,s])=>`${n}:${s}`).join(", ");return[r.displayName,String(r.renders??r.count),t||"-"]})))}function z(e){e.error&&console.error(` warning: ${e.error}`);let o=e.rows??[];if(o.length===0){console.log(` no React tree data yet (${e.roots??0} root(s))`);return}for(let r of o){let t=" ".repeat(r.depth);console.log(` ${t}@${r.id} ${r.displayName} [${r.kind}] children=${r.childCount}`)}}function G(e){if(e.error){console.error(` ${e.error}`);return}let o=e.sample;if(!o){console.log(" no sample");return}if(console.log(` @${o.fiberId} ${o.displayName}`),console.log(` duration: ${Number(o.actualDuration??0).toFixed(2)}ms`),console.log(` causes: ${(o.causes??[]).join(", ")||"-"}`),o.propDiffs?.length){console.log(" props:");for(let r of o.propDiffs){let t="old"in r||"new"in r?` ${JSON.stringify(r.old)} \u2192 ${JSON.stringify(r.new)}`:"";console.log(` ${r.key}${t}`)}}o.parentChain?.length&&console.log(` parents: ${o.parentChain.join(" \u2190 ")}`)}async function I(e,o){let r=R(e,{port:o.port,stripBooleanFlags:["--json","--include-props","--help","-h"],stripValueFlags:["--limit","--depth","--find","--max-commits"]});if(e.includes("--help")||e.includes("-h"))return j(),0;let[t,n]=r.positional,s=e.includes("--json"),l=N(r);try{if(t==="profile"&&n==="start"){let i=await S(l,"SootSim.bridges.reactProfile.start",{includeProps:e.includes("--include-props"),maxCommits:h(e,"--max-commits",2e3)});return s?g(i):console.log(" React profile started"),0}if(t==="profile"&&n==="stop"){let i=await S(l,"SootSim.bridges.reactProfile.stop");return s?g(i):(console.log(` React profile stopped (${i.commits??0} commit(s))`),i.error&&console.error(` warning: ${i.error}`)),i.error?1:0}if(t==="summary"){let i=h(e,"--limit",10),[a,f]=await Promise.all([d(l,"SootSim.bridges.reactProfile.slow",{limit:i}),d(l,"SootSim.bridges.reactProfile.rerenders",{limit:i})]);if(s)return g({commits:a.commits??f.commits??0,slow:a,rerenders:f}),0;let u=a.commits??f.commits??0;console.log(` React profile summary (${u} commit(s)):`),a.error&&console.error(` warning: ${a.error}`),a.durationWarning&&console.error(` warning: ${a.durationWarning}`),f.error&&console.error(` warning: ${f.error}`),console.log(`
|
|
28
|
+
slowest renders:`),T(a),console.log(`
|
|
29
|
+
most rerenders:`),k(f);let m=a.rows?.[0];return(a.rows&&a.rows.length>0?a.rows.every(c=>c.totalMs<=0&&c.slowestMs<=0):!1)&&!a.durationWarning&&console.error(`
|
|
30
|
+
warning: every commit reports actualDuration=0ms \u2014 the React profiler timer is disabled in this bundle (rerender counts are still accurate; ${m?.displayName?`top-listed: ${m.displayName}`:"no slow signal"}).`),0}if(t==="slow"){let i=await d(l,"SootSim.bridges.reactProfile.slow",{limit:h(e,"--limit",10)});return s?g(i):T(i),0}if(t==="rerenders"){let i=await d(l,"SootSim.bridges.reactProfile.rerenders",{limit:h(e,"--limit",10)});return s?g(i):k(i),0}if(t==="tree"){let i=await d(l,"SootSim.bridges.reactProfile.tree",{depth:h(e,"--depth",3),find:F(e,"--find")});return s?g(i):z(i),0}if(t==="why"){let i=Number(n);if(!Number.isFinite(i)||i<=0)return console.error(" usage: sootsim perf react why <fiber-id>"),1;let a=await d(l,"SootSim.bridges.reactProfile.why",Math.round(i));return s?g(a):G(a),a.error?1:0}return j(),t?1:0}finally{l.close()}}var L=new Set(["--sim","--port","-p"]),H=new Set(["cpu","react","shell"]);function V(e){for(let o=0;o<e.length;o++){let r=e[o];if(r.startsWith("-")){L.has(r)&&o++;continue}return H.has(r)?{name:r,index:o}:null}return null}function Z(e,o){return[...e.slice(0,o),...e.slice(o+1)]}function D(){console.log(`
|
|
31
|
+
sootsim perf \u2014 performance profiling tools
|
|
32
|
+
|
|
33
|
+
usage:
|
|
34
|
+
sootsim perf cpu [options]
|
|
35
|
+
sootsim perf react <subcommand> [options]
|
|
36
|
+
sootsim perf shell <start|stop|transition> [options]
|
|
37
|
+
|
|
38
|
+
examples:
|
|
39
|
+
sootsim perf cpu --duration 5 --output /tmp/trace.cpuprofile
|
|
40
|
+
sootsim perf react summary --limit 10
|
|
41
|
+
sootsim perf shell start
|
|
42
|
+
sootsim perf shell stop --json
|
|
43
|
+
`)}async function ne(e,o){if(e.includes("--help")||e.includes("-h"))return D(),0;let r=V(e);if(!r)return D(),1;let t=Z(e,r.index);return r.name==="cpu"?O(t,o):r.name==="react"?I(t,o):(await x(["debug","perf",...t],{...o,internalShellPerf:!0}),typeof process.exitCode=="number"?process.exitCode:0)}export{ne as runPerf};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as P}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.190 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as P}from"./chunk-6UQKBGI7.js";import"./chunk-P7MW7S62.js";import{a as Z,c as ee}from"./chunk-AAQ6AYYW.js";import"./chunk-R3VO3MDO.js";import"./chunk-WR5IDCCN.js";import{g as b,i as v,j as Q}from"./chunk-Y6CZ5N26.js";import{d as Y}from"./chunk-QJVITDKU.js";import"./chunk-KLGX6B46.js";import"./chunk-K5GLQDTG.js";import"./chunk-CVUAT6TO.js";import{b as X}from"./chunk-SJHC6HZH.js";import"./chunk-MH6BMKK5.js";import"./chunk-YWQH2KQJ.js";import{existsSync as we,mkdirSync as E,readdirSync as he,readFileSync as be,rmSync as J,writeFileSync as I}from"fs";import{homedir as ve,tmpdir as ye}from"os";import{dirname as W,extname as oe,join as N,resolve as Se}from"path";var z=24e4,Re=9e4,$e=3e4;async function D(e,r,o,i){let t=Math.max(2e4,i+$e);try{return await e.send({type:"evaluate",code:r},{timeoutMs:t})}catch(n){let s=n instanceof Error?n.message:String(n);/^command timed out after \d+s$/.test(s)&&(console.error(` ${o} stalled \u2014 the render host did not finish within ${Math.round(t/1e3)}s; it is likely contended or wedged.
|
|
3
3
|
the capture lock auto-releases, so simply retry the recording.
|
|
4
4
|
if it persists, recover the sim with \`sootsim close --sim <id>\`.`),process.exit(1)),/render host not available|already streaming|already recording|lock already held/i.test(s)&&(console.error(` ${o} failed: ${s}
|
|
5
5
|
a prior recording was abandoned and its capture is still
|
|
6
6
|
releasing. the lock self-heals in ~${Math.round((i+2e4)/1e3)}s \u2014 retry then, or recover now with
|
|
7
|
-
\`sootsim close --sim <id>\` and reopen the sim.`),process.exit(1)),console.error(` ${o} failed: ${s}`),process.exit(1)}}var _e=new Set(["--sim","--port","-p","--mode","--duration","--fps","--format","--output","-o","--frames","--max-width","--origin","--owner","--repo"]),xe=new Set(["start","stop","cancel","status","prelude-start"]);function Oe(e){for(let r=0;r<e.length;r++){let o=e[r];if(o.startsWith("-")){_e.has(o)&&r++;continue}return xe.has(o)?{name:o,index:r}:null}return null}function ke(){let e=process.env,r=(e.SOOT_BRANCH||e.GITHUB_HEAD_REF||e.GITHUB_REF_NAME||"").trim(),o=(e.SOOT_SHA||e.GITHUB_SHA||"").trim(),i=(e.SOOT_PR_NUMBER||"").trim(),t=i?Number.parseInt(i,10):Number.NaN,n=(e.SOOT_PR_TITLE||"").trim();return{branch:r||void 0,commitSha:o||void 0,pullRequestNumber:Number.isFinite(t)&&t>0?t:void 0,pullRequestTitle:n||void 0}}function re(e){let r=l(e,"--owner")?.trim(),o=l(e,"--repo")?.trim();return(r&&!o||!r&&o)&&(console.error(" --owner and --repo must be provided together"),process.exit(1)),r&&o?{owner:r,repo:o}:null}async function qe(e,r){let o=Oe(e);if(o){let
|
|
7
|
+
\`sootsim close --sim <id>\` and reopen the sim.`),process.exit(1)),console.error(` ${o} failed: ${s}`),process.exit(1)}}var _e=new Set(["--sim","--port","-p","--mode","--duration","--fps","--format","--output","-o","--frames","--max-width","--origin","--owner","--repo"]),xe=new Set(["start","stop","cancel","status","prelude-start","upload"]);function Oe(e){for(let r=0;r<e.length;r++){let o=e[r];if(o.startsWith("-")){_e.has(o)&&r++;continue}return xe.has(o)?{name:o,index:r}:null}return null}function ke(){let e=process.env,r=(e.SOOT_BRANCH||e.GITHUB_HEAD_REF||e.GITHUB_REF_NAME||"").trim(),o=(e.SOOT_SHA||e.GITHUB_SHA||"").trim(),i=(e.SOOT_PR_NUMBER||"").trim(),t=i?Number.parseInt(i,10):Number.NaN,n=(e.SOOT_PR_TITLE||"").trim();return{branch:r||void 0,commitSha:o||void 0,pullRequestNumber:Number.isFinite(t)&&t>0?t:void 0,pullRequestTitle:n||void 0}}function re(e){let r=l(e,"--owner")?.trim(),o=l(e,"--repo")?.trim();return(r&&!o||!r&&o)&&(console.error(" --owner and --repo must be provided together"),process.exit(1)),r&&o?{owner:r,repo:o}:null}async function qe(e,r){let o=Oe(e);if(o){let d=[...e.slice(0,o.index),...e.slice(o.index+1)];if(o.name==="start"){await Ie(d,r);return}if(o.name==="prelude-start"){await Ne(d,r);return}if(o.name==="upload"){let{runUpload:y}=await import("./upload-34BCSEFZ.js");await y(d,r);return}if(o.name==="stop"){await Pe(d,r);return}if(o.name==="cancel"){await Fe(d,r);return}await Ae(d,r);return}let i=b(e,{port:r.port,stripBooleanFlags:["--no-shell","--shell-only","--open"],stripValueFlags:["--mode","--duration","--fps","--format","--output","--frames","--max-width","--origin","--owner","--repo"]}),t=ie(l(e,"--mode")),n=e.includes("--shell-only")?"shell":e.includes("--no-shell")?"tenant":void 0,s=l(e,"--format");s&&!["webm","mp4","gif","png"].includes(s)&&(console.error(` invalid --format "${s}" \u2014 expected webm | mp4 | gif | png`),process.exit(1));let c=l(e,"--output"),a=Number(l(e,"--duration")??"10");(!Number.isFinite(a)||a<=0)&&(console.error(` invalid --duration "${l(e,"--duration")}" \u2014 expected a positive number of seconds`),process.exit(1));let m=600;a>m&&(console.error(` invalid --duration "${l(e,"--duration")}" \u2014 exceeds the ${m}s (10m) maximum`),process.exit(1));let u=Number(l(e,"--fps")??"30"),p=l(e,"--frames");if(p!==void 0){let d=Number(p);(!Number.isInteger(d)||d<=0)&&(console.error(` invalid --frames "${p}" \u2014 expected a positive integer count`),process.exit(1))}let x=e.includes("--open"),j=l(e,"--max-width")?Number(l(e,"--max-width")):void 0,g=Math.max(100,Math.round(a*1e3)),K=l(e,"--origin"),pe=re(e);if(t==="live"||t==="combined"){c&&console.log(` note: --output is ignored for --mode ${t} \u2014 the recording uploads to /preview/<id>`),n&&t==="live"&&console.log(` note: --${n==="shell"?"shell-only":"no-shell"} is ignored for --mode live \u2014 live recordings capture events only, no video`),await P("record",{originOverride:K,allowGitHubAuth:!0});let d=v({...i,commandTimeoutMs:6e4});try{await q(d),await ae(d,t),t==="combined"&&await B(d),await de(d,K,pe);let y=await ce(d,t,t==="combined"?n:void 0);y.ok||(console.error(` start failed: recording store refused to start (${t})`+(y.error?`: ${y.error}`:"")),process.exit(1)),console.log(` recording ${t} for ${a}s`),await new Promise(_=>setTimeout(_,g)),await le(d);let O=await ue(d);me(O,x,t)}finally{d.close()}return}let C=p?Number(p):null,R=Te(s,c,C);x&&console.log(" note: --open is ignored for local-file capture \u2014 it applies to --mode live/combined");let h=v({...i,commandTimeoutMs:6e4});try{if(await te(h),await B(h),R==="png"){let $=C??10,w=U(c,`sootsim-frames-${M()}`);c&&oe(c)&&console.log(` note: --frames writes multiple pngs, so --output "${c}" is a directory \u2014 frame-NNN.png files land inside it`),E(w,{recursive:!0});for(let f of he(w))/^frame-\d+\.png$/.test(f)&&J(N(w,f),{force:!0});console.log(` sampling ${$} frames over ${a}s \u2192 ${w}`);let S=await h.send({type:"evaluate",code:`window.__sootsimRecorder.startFrameCapture({ count: ${$}, durationMs: ${g}${n?`, layers: ${JSON.stringify(n)}`:""} })`});(!S.ok||!S.requestId)&&(console.error(` frame capture start failed: ${S.error??"unknown error"}`),process.exit(1)),await new Promise(f=>setTimeout(f,g));let fe=Date.now()+Math.max(5e3,g),A=null;for(;;){let f=await h.send({type:"evaluate",code:`window.__sootsimRecorder.getFrameCaptureResult(${S.requestId})`});if(f||(console.error(" frame capture result missing"),process.exit(1)),f.done){f.ok||(console.error(` frame capture failed: ${f.error??"unknown error"}`),process.exit(1)),A=f.frames??[];break}Date.now()>=fe&&(console.error(" frame capture timed out"),process.exit(1)),await new Promise(F=>setTimeout(F,100))}A.forEach((f,F)=>{let ge=`${w}/frame-${String(F+1).padStart(3,"0")}.png`;I(ge,Buffer.from(f.data,"base64"))}),console.log(` saved ${A.length} frames`);return}if(R==="gif"){let $=C??Math.max(10,Math.round(a*u/3)),w=U(c,`sootsim-${M()}.gif`);E(W(w),{recursive:!0}),console.log(` encoding gif: ${$} frames over ${a}s \u2192 ${w}`);let S=await D(h,`window.__sootsimRecorder.captureGif({ frames: ${$}, durationMs: ${g}${j?`, maxWidth: ${j}`:""}${n?`, layers: ${JSON.stringify(n)}`:""} })`,"gif encode",g);S||(console.error(" gif capture returned no frames"),process.exit(1)),I(w,Buffer.from(S.data,"base64")),console.log(` saved: ${w} (${G(S.size)})`);return}let d=U(c,`sootsim-${M()}.${R}`);E(W(d),{recursive:!0});let y={format:R,fps:u,durationMs:g};n&&(y.layers=n);let O=await D(h,`window.__sootsimRecorder.start(${JSON.stringify(y)})`,`${R} start`,g);O.ok||(console.error(` start failed: ${O.error??"unknown error"}`),/render host not available|already streaming|already recording|lock already held/i.test(O.error??"")&&console.error(" a prior recording was abandoned and its capture is still\n releasing. retry in ~20s, or recover now with\n `sootsim close --sim <id>` then reopen the sim."),process.exit(1)),console.log(` recording ${R} for ${a}s \u2192 ${d}`),await new Promise($=>setTimeout($,g));let _=await D(h,"window.__sootsimRecorder.stop()",`${R} encode/flush`,g);_.ok||(console.error(` stop failed: ${_.error??"unknown error"}`),process.exit(1)),_.size||(console.error(" recorder returned an empty blob \u2014 nothing written"),process.exit(1)),await ne(h,d),console.log(` saved: ${d} (${G(_.size)})`)}finally{h.close()}}var Ee=6e3;async function L(e,r){try{return await e.send({type:"evaluate",code:r},{timeoutMs:Ee})}catch(o){let i=o instanceof Error?o.message:String(o);throw/^command timed out after \d+s$/.test(i)&&(console.error(" sim did not respond \u2014 it is connected to the bridge but has not\n loaded an app (or its page is unresponsive). run `sootsim list`\n and target a sim with a loaded app via --sim <id>."),process.exit(1)),o}}async function te(e){await L(e,'typeof window.__sootsimRecorder !== "undefined"')||(console.error(" window.__sootsimRecorder missing \u2014 is sootsim engine running in this sim?"),process.exit(1))}async function B(e){let{hidden:r}=await Q(e);r&&(console.error(` refusing to record: the sootsim tab is hidden, so frame capture
|
|
8
8
|
would be throttled to ~1fps and produce a frozen-looking file.
|
|
9
9
|
bring the chrome window to the foreground (un-minimize / switch to
|
|
10
10
|
its tab) or run the recording in headless playwright, then retry.`),process.exit(1))}async function ne(e,r){let o=[],i=0;for(;;){let t=await e.send({type:"evaluate",code:`window.__sootsimRecorder.getBlobBase64({ offset: ${i}, chunk: 2097152 })`});if(!t)throw new Error("no blob available on recorder");if(o.push(Buffer.from(t.data,"base64")),i=t.offset,t.done)break}I(r,Buffer.concat(o))}function l(e,r){let o=e.indexOf(r);if(!(o<0||o===e.length-1))return e[o+1]}function Be(e){if(!e)return;let r=oe(e).toLowerCase().replace(/^\./,"");if(r==="webm"||r==="mp4"||r==="gif")return r;if(r==="png")return"png"}function Te(e,r,o){return e||(o!=null?"png":Be(r)??"webm")}function M(){return new Date().toISOString().replace(/[:T]/g,"-").replace(/\..+/,"")}function Me(){let e=N(ve(),".sootsim","recordings");return E(e,{recursive:!0}),e}function U(e,r){return e?Se(process.cwd(),e):N(Me(),r)}function G(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(2)}MB`}function ie(e){if(!e)return"video";if(e==="video"||e==="live"||e==="combined")return e;console.error(` invalid --mode "${e}" \u2014 expected video | live | combined`),process.exit(1)}function H(){return N(ye(),`sootsim-recording-${X()}.json`)}function T(){let e=H();if(!we(e))return null;try{return{mode:"video",...JSON.parse(be(e,"utf8"))}}catch{return J(e,{force:!0}),null}}function Ue(e){I(H(),JSON.stringify(e,null,2))}function k(){J(H(),{force:!0})}function V(e,r){e&&r.simId&&e!==r.simId&&console.log(` note: the tracked recording session is on sim ${r.simId}, not the
|
|
11
11
|
requested sim ${e}. record state is global (not per-sim);
|
|
12
|
-
this command acts on that session regardless of --sim.`)}async function Ie(e,r){let o=T();o&&(console.error(` recording already in progress (started ${o.startedAt}, sim ${o.simId??"?"}). run \`sootsim record stop\` first, or \`sootsim record cancel\` to discard.`),process.exit(1));let i=b(e,{port:r.port,stripBooleanFlags:["--no-shell","--shell-only"],stripValueFlags:["--mode","--fps","--format","--max-width","--origin","--owner","--repo"]}),t=ie(l(e,"--mode")),n=e.includes("--shell-only")?"shell":e.includes("--no-shell")?"tenant":void 0,s=l(e,"--format"),
|
|
12
|
+
this command acts on that session regardless of --sim.`)}async function Ie(e,r){let o=T();o&&(console.error(` recording already in progress (started ${o.startedAt}, sim ${o.simId??"?"}). run \`sootsim record stop\` first, or \`sootsim record cancel\` to discard.`),process.exit(1));let i=b(e,{port:r.port,stripBooleanFlags:["--no-shell","--shell-only"],stripValueFlags:["--mode","--fps","--format","--max-width","--origin","--owner","--repo"]}),t=ie(l(e,"--mode")),n=e.includes("--shell-only")?"shell":e.includes("--no-shell")?"tenant":void 0,s=l(e,"--format"),c=s==="mp4"?"mp4":"webm";s&&c!==s&&(console.error(` record start only supports webm or mp4 (got: ${s}). for gif/png use atomic mode: sootsim record --format ${s} --duration <s>`),process.exit(1));let a=Number(l(e,"--fps")??"30"),m=re(e),u=v({...i,commandTimeoutMs:t==="live"||t==="combined"?Re:15e3});try{if(t==="live"||t==="combined"){n&&t==="live"&&console.log(` note: --${n==="shell"?"shell-only":"no-shell"} is ignored for --mode live \u2014 live recordings capture events only, no video`),await P("record",{originOverride:l(e,"--origin"),allowGitHubAuth:!0}),await q(u),await ae(u,t),t==="combined"&&await B(u),await de(u,l(e,"--origin"),m);let p=await ce(u,t,t==="combined"?n:void 0);p.ok||(console.error(` start failed: recording store refused to start (${t})`+(p.error?`: ${p.error}`:"")),process.exit(1))}else{await te(u),await B(u);let p={format:c,fps:a};n&&(p.layers=n);let x=await u.send({type:"evaluate",code:`window.__sootsimRecorder.start(${JSON.stringify(p)})`});x.ok||(console.error(` start failed: ${x.error??"unknown error"}`),process.exit(1))}Ue({simId:i.simId??null,mode:t,format:c,fps:a,layers:n,startedAt:new Date().toISOString()}),console.log(t==="video"?` recording ${c} @ ${a}fps${n?` (${n})`:""} \u2014 run \`sootsim record stop --output <path>\` when done`:` recording ${t} \u2014 run \`sootsim record stop\` when done (add --open to launch the preview URL)`)}finally{u.close()}}async function Ne(e,r){let o=T();o&&(console.error(` recording already in progress (started ${o.startedAt}, sim ${o.simId??"?"}). run \`sootsim record stop\` first, or \`sootsim record cancel\` to discard.`),process.exit(1));let i=b(e,{port:r.port,stripBooleanFlags:[],stripValueFlags:["--origin"]}),t=v({...i,commandTimeoutMs:15e3});try{if(await q(t),await B(t),!await t.send({type:"evaluate",code:`(() => {
|
|
13
13
|
const start = window.SootSim?.bridges?.startRecordingPrelude
|
|
14
14
|
if (typeof start !== 'function') return false
|
|
15
15
|
return Promise.resolve(start()).then((value) => value === true)
|
|
@@ -48,7 +48,7 @@ import{a as P}from"./chunk-DKOKNFWR.js";import"./chunk-FXHED7P5.js";import{d as
|
|
|
48
48
|
process; live/combined upload to /preview/<id>). if the run was
|
|
49
49
|
killed, the recording is abandoned and will NOT finish \u2014 reclaim
|
|
50
50
|
it now with \`sootsim record cancel\`, or it auto-reclaims when the
|
|
51
|
-
abandoned capture's deadline lapses.`)}else console.log(" no recording in progress")}finally{t.close()}}async function Fe(e,r){let o=T();if(!o){let s=b(e,{port:r.port}),
|
|
51
|
+
abandoned capture's deadline lapses.`)}else console.log(" no recording in progress")}finally{t.close()}}async function Fe(e,r){let o=T();if(!o){let s=b(e,{port:r.port}),c=v({...s,commandTimeoutMs:8e3});try{let a=await se(c);if(a==="recording"||a==="processing"||a==="prelude"){let m=await Ce(c);m.store&&a==="prelude"?console.log(" recording preview prelude cancelled"):m.store||m.headless?console.log(" reclaimed an abandoned recording (started by an atomic\n `record --duration` run or the record button whose owner is\n gone). the recorder is idle again \u2014 live/combined can start."):console.log(" a recording is in progress and still owned by a live atomic\n `record --duration` run or the in-browser record button \u2014 it\n will finish on its own and nothing was reclaimed.")}else console.log(" no recording in progress")}finally{c.close()}return}let i=b(e,{port:r.port});V(i.simId,o);let t=o.simId??i.simId??void 0,n=v({...i,simId:t,commandTimeoutMs:15e3});try{o.mode==="live"||o.mode==="combined"?await n.send({type:"evaluate",code:"void window.SootSim?.bridges?.cancelRecording?.()"}):await n.send({type:"evaluate",code:"window.__sootsimRecorder.stop()"})}catch{}finally{k(),n.close()}console.log(" recording cancelled")}async function Pe(e,r){let o=T();o||(console.error(" no recording in progress. start one with `sootsim record start`."),process.exit(1));let i=b(e,{port:r.port,stripBooleanFlags:["--open"],stripValueFlags:["--output"]});V(i.simId,o);let t=o.simId??i.simId??void 0,n=e.includes("--open"),s=v({...i,simId:t,commandTimeoutMs:o.mode==="live"||o.mode==="combined"?z:6e4});try{if(o.mode==="live"||o.mode==="combined"){await le(s);let u=await ue(s);k(),me(u,n,o.mode);return}let c=l(e,"--output"),a=U(c,`sootsim-${M()}.${o.format}`);E(W(a),{recursive:!0});let m=await s.send({type:"evaluate",code:"window.__sootsimRecorder.stop()"});m.ok||(console.error(` stop failed: ${m.error??"unknown error"}`),k(),process.exit(1)),m.size||(console.error(" recorder returned an empty blob \u2014 nothing written"),k(),process.exit(1)),await ne(s,a),k(),console.log(` saved: ${a} (${G(m.size)})`)}finally{s.close()}}async function q(e){await L(e,'typeof window.SootSim?.bridges?.startRecording === "function" && typeof window.SootSim?.bridges?.stopRecording === "function"')||(console.error(" SootSim.bridges.startRecording missing \u2014 is sootsim engine running in this sim?"),process.exit(1))}async function ae(e,r){await L(e,`(() => {
|
|
52
52
|
const fn = window.__sootsimCaptureBundle
|
|
53
53
|
if (typeof fn !== 'function') return false
|
|
54
54
|
const snap = fn()
|
|
@@ -56,13 +56,13 @@ import{a as P}from"./chunk-DKOKNFWR.js";import"./chunk-FXHED7P5.js";import{d as
|
|
|
56
56
|
})()`)||(console.error(` --mode ${r} needs a guest app bundle to upload to /preview/<id>,
|
|
57
57
|
but this sim has no bundle loaded (a built-in shell screen like
|
|
58
58
|
photos/settings/home has none). open a metro/guest app first, or
|
|
59
|
-
use \`--mode video\` for a local screen recording with no upload.`),process.exit(1))}async function de(e,r,o){let i=Z();if(!i)return;let t=i.kind==="api-key"?i.secret:i.token,n=ke(),s=i.kind==="github"?{...ee(i),owner:o?.owner,repo:o?.repo,...n}:o?{owner:o.owner,repo:o.repo,...n}:null,
|
|
59
|
+
use \`--mode video\` for a local screen recording with no upload.`),process.exit(1))}async function de(e,r,o){let i=Z();if(!i)return;let t=i.kind==="api-key"?i.secret:i.token,n=ke(),s=i.kind==="github"?{...ee(i),owner:o?.owner,repo:o?.repo,...n}:o?{owner:o.owner,repo:o.repo,...n}:null,c=r?r.replace(/\/$/,""):null;await e.send({type:"evaluate",code:`(() => {
|
|
60
60
|
const set = window.SootSim && window.SootSim.bridges && window.SootSim.bridges.setSession
|
|
61
61
|
if (typeof set !== 'function') return false
|
|
62
62
|
set({ token: ${JSON.stringify(t)}, user: null })
|
|
63
63
|
window.__sootsimPreviewUploadIdentity = ${JSON.stringify(s)}
|
|
64
64
|
window.__sootsimPreviewUseInjectedBearer = true
|
|
65
|
-
${
|
|
65
|
+
${c?`window.__sootsimUploadOrigin = ${JSON.stringify(c)}`:"delete window.__sootsimUploadOrigin"}
|
|
66
66
|
return true
|
|
67
67
|
})()`})||(console.error(" SootSim.bridges.setSession missing \u2014 this sim is running an engine\n build without CLI-injected preview auth. reload the sim or open a\n fresh one (`sootsim open --new`); if it persists, update sootsim."),process.exit(1))}async function ce(e,r,o){let i=o?JSON.stringify(o):"undefined";return await e.send({type:"evaluate",code:`window.SootSim.bridges.startRecording(${JSON.stringify(r)}, ${i}, { skipEntitlement: true })`})===!0?{ok:!0,error:null}:{ok:!1,error:await e.send({type:"evaluate",code:"(window.SootSim?.bridges?.getRecordingStartError?.() ?? null)"}).catch(()=>null)??null}}async function le(e){await e.send({type:"evaluate",code:"void window.SootSim.bridges.stopRecording()"})}async function ue(e){let r=Date.now()+z;for(;Date.now()<r;){let o=await e.send({type:"evaluate",code:"(() => { const s = window.SootSim?.bridges?.getRecordingState?.(); return s ? { state: s.state, lastUpload: s.lastUpload, uploadError: s.uploadError } : null })()"});if(o&&o.state==="idle"){if(o.uploadError)return{uploadError:o.uploadError};if(o.lastUpload?.previewUrl)return{previewUrl:o.lastUpload.previewUrl,eventCount:o.lastUpload.eventCount}}await new Promise(i=>setTimeout(i,300))}return{uploadError:`upload did not settle within ${z/1e3}s`}}function me(e,r,o){e.uploadError&&(console.error(` upload failed: ${e.uploadError}`),process.exit(1)),e.previewUrl||(console.error(" upload returned no preview URL"),process.exit(1)),console.log(` preview: ${e.previewUrl}`),console.log(` note: this URL is content-addressed \u2014 re-recording the same bundle
|
|
68
68
|
replaces this capture at the same /preview/<id>.`),(o==="live"||o==="combined")&&typeof e.eventCount=="number"&&console.log(` captured ${e.eventCount} event${e.eventCount===1?"":"s"}`),(o==="live"||o==="combined")&&e.eventCount===0&&console.log(o==="combined"?` note: this combined recording captured no events \u2014 the Live tab has
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! sootsim v0.1.190 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a}from"./chunk-EBBYYBYM.js";import"./chunk-3JVMBXLH.js";import"./chunk-Y6CZ5N26.js";import"./chunk-CVUAT6TO.js";import"./chunk-SJHC6HZH.js";import"./chunk-MH6BMKK5.js";import"./chunk-YWQH2KQJ.js";export{a as runRuntime};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*! sootsim v0.1.190 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as me,b as he,e as ge}from"./chunk-PSETHPMH.js";import{b as de}from"./chunk-UPN7Z5XZ.js";import{a as pe}from"./chunk-IUVDM73R.js";import"./chunk-6UQKBGI7.js";import"./chunk-P7MW7S62.js";import{a as j,b as fe}from"./chunk-AAQ6AYYW.js";import"./chunk-CTP3U4WV.js";import"./chunk-SPYRMNAJ.js";import"./chunk-CD3ARXZW.js";import"./chunk-R3VO3MDO.js";import"./chunk-WR5IDCCN.js";import"./chunk-MJU4XNZ3.js";import"./chunk-WHYPFQIZ.js";import{r as ae}from"./chunk-QNVY6BLP.js";import{g as _,h as ce,i as U,j as le,k as ue,l as F,m as M}from"./chunk-Y6CZ5N26.js";import"./chunk-NAI6N6SN.js";import"./chunk-TBFBGSRV.js";import"./chunk-QJVITDKU.js";import"./chunk-PR3IKD6A.js";import"./chunk-6EFMFMJB.js";import"./chunk-KLGX6B46.js";import"./chunk-K5GLQDTG.js";import"./chunk-PGQHNKRL.js";import"./chunk-7TSFDDU7.js";import"./chunk-CVUAT6TO.js";import"./chunk-SJHC6HZH.js";import"./chunk-MH6BMKK5.js";import{a as v,b as V,c as K,d as X,e as J,f as z,g as I}from"./chunk-ITQV76PX.js";import"./chunk-YWQH2KQJ.js";import{mkdirSync as be,writeFileSync as we}from"fs";import{dirname as Se,resolve as xe}from"path";async function ke(e,t){let o=st(e);(o.includes("--help")||o.includes("-h"))&&(console.log(`
|
|
3
|
+
sootsim screenshot \u2014 capture the canvas as a PNG
|
|
4
|
+
|
|
5
|
+
usage:
|
|
6
|
+
sootsim screenshot [output] [options]
|
|
7
|
+
sootsim screenshot [options] --output <path>
|
|
8
|
+
|
|
9
|
+
options:
|
|
10
|
+
--output <path> output file path (default: /tmp/sootsim-inspect.png)
|
|
11
|
+
first positional arg works too: \`screenshot /tmp/x.png\`
|
|
12
|
+
--with-frame wrap the captured screen in a tight device frame
|
|
13
|
+
--no-frame capture the raw screen bitmap (default)
|
|
14
|
+
--no-shell tenant-only capture (no status bar, keyboard, toasts,
|
|
15
|
+
notification center, or other shell overlays). use for
|
|
16
|
+
clean app screenshots when a shell surface is in the way.
|
|
17
|
+
--shell-only capture only the shell chrome, no tenant content
|
|
18
|
+
--area x,y,w,h crop to a logical sootsim rect
|
|
19
|
+
--id <testID> crop to a node's bounding box
|
|
20
|
+
--text <text> crop to a node found by text content
|
|
21
|
+
--gallery crawl and capture multiple screens as HTML gallery
|
|
22
|
+
--themes capture light and dark variants
|
|
23
|
+
|
|
24
|
+
examples:
|
|
25
|
+
sootsim screenshot
|
|
26
|
+
sootsim screenshot --no-shell --output app.png
|
|
27
|
+
sootsim screenshot --with-frame --output framed.png
|
|
28
|
+
sootsim screenshot --area 0,200,393,400 --output hero.png
|
|
29
|
+
sootsim screenshot --id loginButton --output button.png
|
|
30
|
+
`),process.exit(0));let s=it(o);if(s.length>0){for(let{flag:p,suggestion:y}of s)console.error(y?` unknown flag: ${p} (did you mean ${y}?)`:` unknown flag: ${p}`);console.error(" run `sootsim screenshot --help` for the list of supported flags"),process.exit(1)}let r=o.includes("--gallery"),i=o.includes("--themes"),n=tt(o),a=ot(o);if(r||i)return n&&(console.error(" --with-frame is not supported with --gallery / --themes"),process.exit(1)),ye(o,t);n&&o.some(p=>p==="--area"||p==="--id"||p==="--text")&&(console.error(" --with-frame only supports full-screen capture for now"),console.error(" remove --area / --id / --text, or capture raw and compose later"),process.exit(1));let c=_(o,{port:t.port,stripBooleanFlags:["--with-frame","--no-frame","--no-shell","--shell-only"],stripValueFlags:["--output","--area","--id","--text"]}),l=$e(o),u=await Ze(o);if(await Je(c.wsPort)){try{await Qe(c,l,u,n,a)}catch(p){console.error(` screenshot failed: ${p instanceof Error?p.message:String(p)}`),process.exit(1)}return}n&&(console.error(" --with-frame requires a running sootsim bridge"),console.error(" open the app in a live sim first, then rerun the command"),process.exit(1)),u&&(console.error(" --area / --id / --text require a running sootsim bridge"),console.error(" start one with `sootsim serve`, `sootsim desktop`, or your project dev server"),process.exit(1)),await ye(o,t)}async function Je(e){let t=ce(e,{commandTimeoutMs:1e3});try{return await t.listSims(),!0}catch{return!1}finally{t.close()}}async function Ze(e){let t=e.find((r,i)=>e[i-1]==="--area");if(t){let r=t.split(",").map(l=>Number(l.trim()));if(r.length!==4||r.some(l=>!Number.isFinite(l)))throw new Error(`--area expects x,y,w,h (got "${t}")`);let[i,n,a,c]=r;return{x:i,y:n,w:a,h:c}}let o=e.find((r,i)=>e[i-1]==="--id"),s=e.find((r,i)=>e[i-1]==="--text");return o||s?{__matcher:{id:o,text:s}}:null}async function Qe(e,t,o,s,r){let i=U({...e,commandTimeoutMs:45e3});try{(await le(i)).hidden&&process.stderr.write(` \u26A0 screenshot will capture the LAST PAINTED canvas \u2014 likely stale.
|
|
31
|
+
navigation/\`shell\` commands sent before this screenshot may not
|
|
32
|
+
have repainted yet. focus the tab manually or \`sootsim --sim <id>\`
|
|
33
|
+
to target a visible sim before capturing.
|
|
34
|
+
|
|
35
|
+
`);let a=Number(process.env.SOOT_SCREENSHOT_READY_MAX_MS)||9e4,c=await ae(i,a);if(!c.ready)throw new Error(`app not ready to capture after ${Math.round(c.elapsedMs/1e3)}s`+(c.loadingText?` (still showing "${c.loadingText}")`:"")+"; refusing to capture the boot/loading card. retry once the app paints.");let l=o,u=o?.__matcher;if(u){let m=await i.send({type:"evaluate",code:de(u)});if(!m)throw new Error(u.id?`no node with id "${u.id}"`:`no node matching text "${u.text}"`);l=m}let d=l?{x:l.x,y:l.y,w:l.w,h:l.h}:void 0,p={type:"screenshot"};r&&(p.layers=r),d&&(p.crop=d);let f=(await i.send(p)).replace(/^data:image\/png;base64,/,"");d&&console.log(` area: x=${d.x} y=${d.y} w=${d.w} h=${d.h}`),r&&console.log(` layers: ${r}`);let h=xe(process.cwd(),t||"/tmp/sootsim-inspect.png");be(Se(h),{recursive:!0});let S=Buffer.from(f,"base64");if(s){let m=await et(i);if(!m)throw new Error("could not read current device model from the target sim");let x=await me(S,m);we(h,x),console.log(` frame: ${m}`)}else we(h,S);console.log(` saved: ${h}`)}finally{i.close()}}async function et(e){let t=await F(e,"SootSim.bridges.settings.get")??{deviceModel:null},o=typeof t.deviceModel=="string"?t.deviceModel:null;return!o||!(o in I)?null:o}function tt(e){let t=!1;for(let o of e)o==="--with-frame"&&(t=!0),o==="--no-frame"&&(t=!1);return t}function ot(e){if(e.includes("--shell-only"))return"shell";if(e.includes("--no-shell"))return"tenant"}var rt=new Set(["--help","-h","--verbose","-v","--with-frame","--no-frame","--no-shell","--shell-only","--gallery","--themes"]),Pe=new Set(["--output","--area","--id","--text","--url","--port","--timeout","--sim"]),nt={"--rect":"--area","--crop":"--area","--region":"--area","--bounds":"--area","--box":"--area","--xywh":"--area","--out":"--output","-o":"--output","--file":"--output","--path":"--output","--testid":"--id","--test-id":"--id","--test_id":"--id"};function st(e){let t=[],o={"-o":"--output","--out":"--output","--file":"--output","--path":"--output","--testid":"--id","--test-id":"--id","--test_id":"--id","--rect":"--area","--crop":"--area","--region":"--area","--bounds":"--area","--box":"--area","--xywh":"--area"};for(let s of e){let r=o[s];t.push(r??s)}return t}function it(e){let t=[];for(let o=0;o<e.length;o++){let s=e[o];if(s.startsWith("-")){if(Pe.has(s)){o++;continue}rt.has(s)||t.push({flag:s,suggestion:nt[s]})}}return t}function $e(e){let t=e.find((o,s)=>e[s-1]==="--output");if(t)return t;for(let o=0;o<e.length;o++){let s=e[o];if(s.startsWith("-")){Pe.has(s)&&o++;continue}return s}}async function ye(e,t){let o=$e(e)||"sootsim-screenshot.png",s=e.includes("--gallery"),r=e.find((a,c)=>e[c-1]==="--url")||`http://localhost:${t.port||5173}`,{chromium:i}=await import("playwright"),n=await i.launch({channel:"chrome",headless:!0});try{if(s)console.log(" capturing gallery..."),console.log(" (gallery mode not yet implemented)");else{let a=await n.newPage({viewport:{width:500,height:900}});await a.goto(r,{waitUntil:"networkidle"}),await a.waitForTimeout(2e3);let c=xe(process.cwd(),o);be(Se(c),{recursive:!0}),await a.screenshot({path:c}),console.log(` saved: ${c}`),await a.close()}}catch(a){console.error(` screenshot failed: ${a.message}`),process.exitCode=1}finally{await n.close()}}import{mkdirSync as re,readFileSync as yt,writeFileSync as ze}from"fs";import{tmpdir as Lo}from"os";import H from"path";import{mkdirSync as Ce,readFileSync as at,writeFileSync as Me}from"fs";import Z from"path";function ve(e){return e.replace(/\\/g,"/").replace(/\.png$/i,"").trim().split("/").filter(Boolean).join("--").replace(/[^A-Za-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"slide"}function Q(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}function ct(e){let t=e.trim();return/^#[0-9a-f]{3}$/i.test(t)?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t}function L(e,t){let o=ct(e),s=Math.max(0,Math.min(1,t)),r=o.match(/^#([0-9a-f]{6})$/i);if(r){let i=r[1],n=Number.parseInt(i.slice(0,2),16),a=Number.parseInt(i.slice(2,4),16),c=Number.parseInt(i.slice(4,6),16);return`rgba(${n}, ${a}, ${c}, ${s})`}return o.startsWith("rgb(")?o.replace(/^rgb\((.+)\)$/i,`rgba($1, ${s})`):o}function lt(e){if(e.type==="solid")return e.color||"#000000";let t=e.direction??180,o=e.stops?.map(s=>`${s.color} ${s.offset}%`).join(", ")||"#000000 0%, #111111 100%";return`linear-gradient(${t}deg, ${o})`}function ut(e){let t=e.glow;return t?`radial-gradient(circle at 50% 24%, ${L(t,.46)} 0%, ${L(t,.2)} 24%, rgba(0,0,0,0) 62%)`:"none"}function ee(e){switch(e){case"tilted-left":return"perspective(2400px) rotateY(10deg) rotateZ(-2deg)";case"tilted-right":return"perspective(2400px) rotateY(-10deg) rotateZ(2deg)";case"cut-bottom":return"translateY(10%) scale(1.08)";case"cut-top":return"translateY(-16%) scale(1.08)";case"straight":default:return"none"}}function Re(...e){let t=e.map(o=>o.trim()).filter(o=>o.length>0&&o!=="none");return t.length>0?t.join(" "):"none"}function te(e){let t=L(e.color,e.opacity),o=L(e.color,e.opacity*.52);return`drop-shadow(0 34px ${e.spread}px ${o}) drop-shadow(0 0 ${e.blur}px ${t})`}function oe(e,t){return!t.glow||e.color&&e.color!==v.color?e:{...e,color:t.glow}}function dt(e,t){if(e==="editorial-left"){let r=Math.round(t.height*.056),i=Math.round(t.height*.022);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.12)}px`,`left:${Math.round(t.width*.085)}px`,`width:${Math.round(t.width*.42)}px`,"text-align:left","z-index:3"].join(";"),titleStyle:`font-size:${r}px;line-height:0.92;`,subStyle:`font-size:${i}px;line-height:1.36;max-width:${Math.round(t.width*.36)}px;`,eyebrowStyle:"align-items:flex-start;",deviceStyle:(n,a,c)=>{let l=Math.round(t.width*.68*(a.scale??n.scale)),u=Math.round(t.height*(.03+n.offsetY+(a.offsetY??0))),d=a.pose||n.pose||"tilted-right",p=oe(n.shadow,c);return["position:absolute",`top:${Math.round(t.height*.18)+u}px`,`left:${Math.round(t.width*.56)}px`,`width:${l}px`,"transform-origin:center center",`transform:${ee(d)}`,`filter:${te(p)}`,"z-index:2"].join(";")}}}if(e==="minimal-bottom"){let r=Math.round(t.height*.041),i=Math.round(t.height*.019);return{copyStyle:["position:absolute",`left:${Math.round(t.width*.12)}px`,`right:${Math.round(t.width*.12)}px`,`bottom:${Math.round(t.height*.085)}px`,"text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${r}px;line-height:0.96;`,subStyle:`font-size:${i}px;line-height:1.34;max-width:${Math.round(t.width*.56)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(n,a,c)=>{let l=Math.round(t.width*.84*(a.scale??n.scale)),u=Math.round(t.height*(n.offsetY+(a.offsetY??0))),d=a.pose||n.pose,p=oe(n.shadow,c);return["position:absolute",`top:${Math.round(t.height*.075)+u}px`,"left:50%",`width:${l}px`,"transform-origin:center center",`transform:${Re("translateX(-50%)",ee(d))}`,`filter:${te(p)}`,"z-index:2"].join(";")}}}let o=Math.round(t.height*.04),s=Math.round(t.height*.019);return{copyStyle:["position:absolute",`top:${Math.round(t.height*.084)}px`,"left:50%",`width:${Math.round(t.width*.88)}px`,"transform:translateX(-50%)","text-align:center","z-index:3"].join(";"),titleStyle:`font-size:${o}px;line-height:0.92;`,subStyle:`font-size:${s}px;line-height:1.34;max-width:${Math.round(t.width*.6)}px;margin:0 auto;`,eyebrowStyle:"align-items:center;",deviceStyle:(r,i,n)=>{let a=Math.round(t.width*.64*(i.scale??r.scale)),c=Math.round(t.height*(r.offsetY+(i.offsetY??0))),l=i.pose||r.pose,u=oe(r.shadow,n);return["position:absolute",`top:${Math.round(t.height*.28)+c}px`,"left:50%",`width:${a}px`,"transform-origin:center top",`transform:${Re("translateX(-50%)",ee(l))}`,`filter:${te(u)}`,"z-index:2"].join(";")}}}function pt({canvas:e,compose:t,slide:o,imageDataUrl:s}){let r=o.background??t.background,i=dt(t.text.preset,e),n=t.text.preset!=="none"&&!!(o.eyebrow||o.headline||o.subheadline),a=i.deviceStyle(t.frame,o,r),c=o.headline?`<div style="font-weight:780;white-space:pre-line;text-wrap:balance;${i.titleStyle}">${Q(o.headline)}</div>`:"",l=o.subheadline?`<div style="margin-top:${Math.round(e.height*.018)}px;color:${t.text.subColor};white-space:pre-line;text-wrap:balance;${i.subStyle}">${Q(o.subheadline)}</div>`:"",u=o.eyebrow?`<div style="display:flex;${i.eyebrowStyle}margin-bottom:${Math.round(e.height*.016)}px;"><div style="font-size:${Math.round(e.height*.014)}px;font-weight:700;letter-spacing:0.18em;text-transform:uppercase;color:${t.text.eyebrowColor};">${Q(o.eyebrow)}</div></div>`:"";return`<!doctype html>
|
|
36
|
+
<html>
|
|
37
|
+
<head>
|
|
38
|
+
<meta charset="utf-8" />
|
|
39
|
+
<style>
|
|
40
|
+
html, body {
|
|
41
|
+
margin: 0;
|
|
42
|
+
width: ${e.width}px;
|
|
43
|
+
height: ${e.height}px;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
background: transparent;
|
|
46
|
+
}
|
|
47
|
+
body {
|
|
48
|
+
font-family: "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
|
|
49
|
+
}
|
|
50
|
+
#canvas {
|
|
51
|
+
position: relative;
|
|
52
|
+
width: ${e.width}px;
|
|
53
|
+
height: ${e.height}px;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
background: ${lt(r)};
|
|
56
|
+
color: ${t.text.color};
|
|
57
|
+
isolation: isolate;
|
|
58
|
+
}
|
|
59
|
+
#glow {
|
|
60
|
+
position: absolute;
|
|
61
|
+
inset: 0;
|
|
62
|
+
background: ${ut(r)};
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
#copy {
|
|
66
|
+
${i.copyStyle};
|
|
67
|
+
}
|
|
68
|
+
#device {
|
|
69
|
+
${a};
|
|
70
|
+
}
|
|
71
|
+
#device img {
|
|
72
|
+
display: block;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: auto;
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
77
|
+
</head>
|
|
78
|
+
<body>
|
|
79
|
+
<div id="canvas">
|
|
80
|
+
<div id="glow"></div>
|
|
81
|
+
${n?`<div id="copy">${u}${c}${l}</div>`:""}
|
|
82
|
+
<div id="device"><img src="${s}" alt="" /></div>
|
|
83
|
+
</div>
|
|
84
|
+
</body>
|
|
85
|
+
</html>`}async function Fe(e,t,o){let s=[],r=o??await(async()=>{let{chromium:n}=await import("playwright");return n.launch({headless:!0})})();try{let n=await r.newContext({viewport:{width:1280,height:720}});try{for(let a of t){let l=`data:image/png;base64,${at(a.imagePath).toString("base64")}`;for(let u of e.canvases){let d=await n.newPage();try{await d.setViewportSize({width:u.width,height:u.height}),await d.setContent(pt({canvas:u,compose:e,slide:a.slide,imageDataUrl:l}),{waitUntil:"load"}),await d.waitForTimeout(20);let p=Z.join(e.outDir,u.name,e.locale);Ce(p,{recursive:!0});let y=Z.join(p,`${a.slide.assetKey}.png`),f=await d.screenshot({type:"png",clip:{x:0,y:0,width:u.width,height:u.height}});Me(y,f),s.push({slideId:a.slide.id,canvas:u.name,locale:e.locale,outputPath:y,sourcePath:a.imagePath})}finally{await d.close()}}}}finally{await n.close()}}finally{!o&&typeof r.close=="function"&&await r.close()}Ce(e.outDir,{recursive:!0});let i=Z.join(e.outDir,"manifest.json");return Me(i,JSON.stringify({generatedAt:new Date().toISOString(),locale:e.locale,outputs:s},null,2)),{manifestPath:i,outputs:s.map(n=>n.outputPath),entries:s}}function A(e){return typeof e=="string"&&e.length>0?e:void 0}async function Ne(e){let o=`${e.origin.replace(/\/$/,"")}/api/sootsim/screenshot-decks?org=${encodeURIComponent(e.org)}&repo=${encodeURIComponent(e.repo)}`,s=await fetch(o,{headers:{Authorization:e.authHeader}});if(!s.ok){let a=await s.text().catch(()=>"");throw new Error(`org deck fetch failed (${s.status} ${s.statusText}) for ${e.org}/${e.repo}${a?` \u2014 ${a.slice(0,200)}`:""}`)}let i=(await s.json()).decks?.[0];if(!i||!i.config||typeof i.config!="object")return null;let n=i.config.frames;return Array.isArray(n)?n.map(a=>{let c=a??{};return{title:A(c.title),subtitle:A(c.subtitle),bgTop:A(c.bgTop),bgBottom:A(c.bgBottom),titleColor:A(c.titleColor)}}):null}function De(e,t){e.compose.slides.forEach((o,s)=>{let r=t[s];if(r&&(r.title!=null&&(o.headline=r.title),r.subtitle!=null&&(o.subheadline=r.subtitle),r.bgTop&&r.bgBottom)){let i={type:"gradient",direction:180,stops:[{offset:0,color:K(r.bgTop)},{offset:1,color:K(r.bgBottom)}]};o.background=i}})}import{readFileSync as mt}from"fs";import C from"path";function w(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function G(e,t){if(!w(e))throw new Error(`${t} must be an object`);return e}function k(e,t=""){return typeof e=="string"?e:t}function P(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Ae(e,t){return typeof e=="boolean"?e:t}function R(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function Te(e,t){return typeof e!="string"||e.trim().length===0?t:Object.prototype.hasOwnProperty.call(I,e)?e:null}function Ee(e,t){if(typeof e=="string"){let r=z(e);if(!r)throw new Error(`unknown background preset: ${e}`);return r}if(!w(e))return J(t);let o=e.type==="solid"||e.type==="gradient"?e.type:t.type;if(o==="solid")return{type:o,color:k(e.color,t.color??"#000000"),glow:P(e.glow)??t.glow};let s=Array.isArray(e.stops)?e.stops.map(r=>{if(!w(r))return null;let i=R(r.offset,Number.NaN),n=P(r.color);return!Number.isFinite(i)||!n?null:{offset:i,color:n}}).filter(r=>!!r):t.stops?.map(r=>({...r}))??[];return{type:o,direction:R(e.direction,t.direction??180),glow:P(e.glow)??t.glow,stops:s.length>0?s:t.stops?.map(r=>({...r}))??[]}}function ht(e){let o=(Array.isArray(e)?e:["iphone-6-9"]).map(s=>{if(typeof s!="string")throw new Error("compose.canvases entries must be strings");let r=X(s);if(!r)throw new Error(`unknown canvas preset: ${s}`);return r});if(o.length===0)throw new Error("compose.canvases must include at least one preset");return o}function ft(e){switch(e){case"editorial-left":case"minimal-bottom":case"none":case"bold-top":return e;default:return"bold-top"}}function gt(e){switch(e){case"plan":case"flow":case"auto":return e;default:return"auto"}}function Be(e){switch(e){case"straight":case"tilted-left":case"tilted-right":case"cut-bottom":case"cut-top":return e;default:return}}function T(e,t){return C.isAbsolute(t)?t:C.resolve(e,t)}function wt(e,t){if(!Array.isArray(e)||e.length===0)throw new Error("compose.slides must be a non-empty array");return e.map((o,s)=>{let r=G(o,`compose.slides[${s}]`),i=P(r.screenshot);if(!i)throw new Error(`compose.slides[${s}].screenshot is required`);let n=P(r.id),a=ve(n||i);return{id:n||a,assetKey:a,screenshot:i,headline:k(r.headline),subheadline:k(r.subheadline),eyebrow:k(r.eyebrow),pose:Be(r.pose),scale:typeof r.scale=="number"&&Number.isFinite(r.scale)?r.scale:void 0,offsetY:typeof r.offsetY=="number"&&Number.isFinite(r.offsetY)?r.offsetY:void 0,background:r.theme||r.background?Ee(r.theme??r.background,t):void 0}})}function Oe(e){let t=C.resolve(e),o=C.dirname(t),s=pe.parse(mt(t,"utf8")),r=G(s,"screenshots plan"),i=G(r.capture??{},"capture"),n=G(r.compose??{},"compose"),a=typeof r.app=="number"?String(r.app):P(r.app),c=Te(r.device,null),l=T(o,k(i.out,C.join(".sootsim","screenshots","capture"))),u=P(i.from),d=P(i.flow);if(!u&&!d)throw new Error("capture.flow or capture.from is required");let p=i.mode==="raw"||i.mode==="framed"||i.mode==="raw+framed"?i.mode:"raw+framed",y=gt(i.pathMode),f=Ee(n.background??"cyan",z("cyan")),h={show:Ae(n.frame&&w(n.frame)?n.frame.show:void 0,!0),style:Te(n.frame&&w(n.frame)?n.frame.style:null,null)||c||V,pose:Be(n.frame&&w(n.frame)?n.frame.pose:void 0)||"straight",scale:R(n.frame&&w(n.frame)?n.frame.scale:void 0,1),offsetY:R(n.frame&&w(n.frame)?n.frame.offsetY:void 0,0),shadow:{color:k(n.frame&&w(n.frame)&&w(n.frame.shadow)?n.frame.shadow.color:void 0,v.color),blur:R(n.frame&&w(n.frame)&&w(n.frame.shadow)?n.frame.shadow.blur:void 0,v.blur),spread:R(n.frame&&w(n.frame)&&w(n.frame.shadow)?n.frame.shadow.spread:void 0,v.spread),opacity:R(n.frame&&w(n.frame)&&w(n.frame.shadow)?n.frame.shadow.opacity:void 0,v.opacity)}};return{planPath:t,planDir:o,appTarget:a,deviceModel:c,capture:{flowPath:d?T(o,d):null,fromDir:u?T(o,u):null,outDir:l,rawDir:u?T(o,u):C.join(l,"raw"),framedDir:C.join(l,"framed"),mode:p,pathMode:y,simId:P(i.sim),openInNewSim:Ae(i.new,!1)},compose:{outDir:T(o,k(n.out,C.join(".sootsim","screenshots","exports"))),locale:k(n.locale,"en"),canvases:ht(n.canvases),frame:h,background:f,text:{preset:ft(n.text&&w(n.text)?n.text.preset:void 0),color:k(n.text&&w(n.text)?n.text.color:void 0,"#ffffff"),subColor:k(n.text&&w(n.text)?n.text.subColor:void 0,"rgba(232,240,247,0.86)"),eyebrowColor:k(n.text&&w(n.text)?n.text.eyebrowColor:void 0,"rgba(229,242,255,0.72)")},slides:wt(n.slides,f)}}}function bt(e){return e.capture.pathMode==="plan"||e.capture.pathMode==="flow"?e.capture.pathMode:e.capture.fromDir?"flow":"plan"}function St(e,t){if(!e.capture.flowPath)throw new Error("capture flow path is required to build flow args");let o=[e.capture.flowPath],s=bt(e);o.push("--screenshots",e.capture.rawDir),s==="flow"&&o.push("--screenshot-paths","flow");let r=t.appTarget??e.appTarget,i=t.deviceModel??e.deviceModel,n=t.simId??e.capture.simId;return r&&o.push("--url",r),i&&o.push("--device",i),n&&o.push("--sim",n),e.capture.openInNewSim&&o.push("--new"),o}function Y(e,t){return H.isAbsolute(t)?t:H.join(e.capture.rawDir,t)}function xt(e){return H.join(e.capture.outDir,"manifest.json")}async function kt(e,t){if(!e.capture.flowPath)return;re(e.capture.rawDir,{recursive:!0});let o=St(e,t),s=await ge(o);if(s!==0)throw new Error(`flow capture failed with exit code ${s}`)}async function Pt(e,t){let o=new Map;re(e.capture.framedDir,{recursive:!0});let s=t??await(async()=>{let{chromium:r}=await import("playwright");return r.launch({headless:!0})})();try{let r=await he(s);try{for(let i of e.compose.slides){let n=Y(e,i.screenshot),a=yt(n),c=await r.compose(a,e.compose.frame.style),l=H.join(e.capture.framedDir,`${i.assetKey}.png`);ze(l,c),o.set(i.id,l)}}finally{await r.close()}}finally{!t&&typeof s.close=="function"&&await s.close()}return o}function $t(e,t,o){let s=[],r=[];re(e.capture.outDir,{recursive:!0});let i=xt(e),n=e.compose.slides.map(a=>{let c=Y(e,a.screenshot),l=t.get(a.id)??null;return s.push(c),l&&r.push(l),{id:a.id,screenshot:a.screenshot,rawPath:c,framedPath:l}});return ze(i,JSON.stringify({generatedAt:new Date().toISOString(),deviceModel:o,mode:e.capture.mode,rawDir:e.capture.rawDir,framedDir:e.capture.framedDir,slides:n},null,2)),{manifestPath:i,rawDir:e.capture.rawDir,framedDir:e.capture.framedDir,rawFiles:s,framedFiles:r}}function vt(e,t){return e.compose.slides.map(o=>({slide:o,imagePath:e.compose.frame.show===!0?t.get(o.id)??Y(e,o.screenshot):Y(e,o.screenshot)}))}async function Ie(e,t={}){let o=Oe(e);t.orgDeckFrames&&t.orgDeckFrames.length>0&&De(o,t.orgDeckFrames);let s=t.deviceModel??o.deviceModel;t.composeOnly||await kt(o,t);let r=o.capture.mode!=="raw"||!t.captureOnly&&o.compose.frame.show===!0,n=r||!t.captureOnly?await(async()=>{let{chromium:a}=await import("playwright");return a.launch({headless:!0})})():null;try{let a=r?await Pt(o,n??void 0):new Map,c=$t(o,a,s);if(t.captureOnly)return{plan:o,capture:c,compose:null};let l=vt(o,a),u=await Fe(o.compose,l,n??void 0);return{plan:o,capture:c,compose:u}}finally{n&&typeof n.close=="function"&&await n.close()}}async function _e(e,t={}){if(e.includes("--help")||e.includes("-h"))return console.log(`
|
|
86
|
+
sootsim screenshot appstore \u2014 capture and compose app-store screenshot sets
|
|
87
|
+
|
|
88
|
+
usage:
|
|
89
|
+
sootsim screenshot appstore --plan <plan.yaml> [options]
|
|
90
|
+
|
|
91
|
+
options:
|
|
92
|
+
--plan <path> screenshot plan yaml
|
|
93
|
+
--sim <id> reuse a live sim for capture
|
|
94
|
+
--app <target> override plan app target (port, url, or shell url)
|
|
95
|
+
--device <model> override plan capture device for this run
|
|
96
|
+
--org <slug> overlay copy/colors from a team's org screenshot deck
|
|
97
|
+
--repo <name> repo for --org (both required to pull the org deck)
|
|
98
|
+
--api-origin <url> sootbean origin to fetch the deck from (default: the
|
|
99
|
+
signed-in session origin, else https://sootbean.com)
|
|
100
|
+
--capture-only stop after raw/framed intermediates
|
|
101
|
+
--compose-only skip flow capture, reuse existing raw screenshots
|
|
102
|
+
|
|
103
|
+
examples:
|
|
104
|
+
sootsim screenshot appstore --plan app-store.yaml
|
|
105
|
+
sootsim screenshot appstore --plan app-store.yaml --sim a9
|
|
106
|
+
sootsim screenshot appstore --plan app-store.yaml --org acme --repo mobile
|
|
107
|
+
`),0;let o=h=>e.find((S,m)=>e[m-1]===h),s=new Set(["--plan","--sim","--app","--device","--org","--repo","--api-origin"]),r=e.filter((h,S)=>{if(h.startsWith("-"))return!1;let m=e[S-1];return!m||!s.has(m)}),i=o("--plan")||r[0];if(!i)return console.error(" error: screenshots plan path is required (`--plan <path>`)."),1;let n=o("--sim")?.trim()||null,a=o("--app")?.trim()||null,c=o("--device")?.trim()||null,l=o("--org")?.trim()||null,u=o("--repo")?.trim()||null,d=o("--api-origin")?.trim()||null,p=e.includes("--capture-only"),y=e.includes("--compose-only"),f=null;if(l||u){if(!l||!u)return console.error(" error: --org and --repo must be passed together."),1;let h=j();if(!h)return console.error(" error: --org/--repo needs auth \u2014 run `sootsim login` or set SOOTSIM_API_KEY."),1;let S=d||(h.kind==="session"?h.origin:"https://sootbean.com");try{f=await Ne({org:l,repo:u,origin:S,authHeader:fe(h)})}catch(m){return console.error(` ${m.message}`),1}!f||f.length===0?console.log(` note: no org deck for ${l}/${u} \u2014 composing with the plan's copy/colors.`):console.log(` org deck: ${f.length} slide(s) from ${l}/${u}`)}try{let h=await Ie(i,{simId:n,appTarget:a,deviceModel:c,captureOnly:p,composeOnly:y,orgDeckFrames:f});return console.log(` capture manifest: ${h.capture.manifestPath}`),h.compose?(console.log(` compose manifest: ${h.compose.manifestPath}`),console.log(` exports: ${h.compose.outputs.length}`)):console.log(" compose skipped"),0}catch(h){return console.error(` screenshots failed: ${h.message}`),1}}import{execSync as Ye}from"node:child_process";import{mkdirSync as Rt,mkdtempSync as Ft,rmSync as Nt,writeFileSync as Dt}from"node:fs";import{tmpdir as At}from"node:os";import{dirname as Tt,isAbsolute as Et,join as Ge,resolve as Bt}from"node:path";import{chromium as Ot}from"playwright-core";import{execSync as Ct}from"node:child_process";function je(e){let t=e;if(t&&typeof t.process=="function")try{let o=t.process();if(o&&typeof o.pid=="number"&&o.pid>0)return o.pid}catch{}if(t&&typeof t.browser=="function")try{let o=t.browser();if(o)return je(o)}catch{}return null}function ne(e){let t=[];try{t=Ct(`pgrep -P ${e} || true`).toString().split(`
|
|
108
|
+
`).filter(Boolean)}catch{}for(let o of t)ne(Number(o));try{process.kill(e,"SIGKILL")}catch{}}var W=new Set,Ue=!1;function Mt(){if(Ue)return;Ue=!0;let e=()=>{for(let t of W)ne(t)};process.on("SIGTERM",()=>{e(),process.exit(0)}),process.on("SIGINT",()=>{e(),process.exit(0)}),process.on("exit",e)}async function Le(e){let t=await e(),o=je(t),s=new Set;o!=null&&(s.add(o),W.add(o),Mt());let r=t;return typeof r.on=="function"&&r.on("disconnected",()=>{for(let n of s)W.delete(n)}),{browser:t,reapNow:()=>{for(let n of s)ne(n),W.delete(n);s.clear()}}}var zt=`
|
|
109
|
+
sootsim screenshot appstore capture \u2014 headlessly capture + upload App Store slides
|
|
110
|
+
|
|
111
|
+
usage:
|
|
112
|
+
sootsim screenshot appstore capture --org <org> --repo <repo> [options]
|
|
113
|
+
|
|
114
|
+
what it does:
|
|
115
|
+
boots the org-mode build shell in headless GPU Chrome (authed via your
|
|
116
|
+
\`sootsim login\` session), captures each slide through the live screenshot
|
|
117
|
+
composer so every slide gets editable layers (captureRef + cleanRef +
|
|
118
|
+
screenRef), and lets the shell auto-upload them to your org deck.
|
|
119
|
+
|
|
120
|
+
options:
|
|
121
|
+
--org <org> github org slug (required)
|
|
122
|
+
--repo <repo> repo name (required)
|
|
123
|
+
--branch <branch> build branch to boot (default: main)
|
|
124
|
+
--platform <p> ios | android (default: ios)
|
|
125
|
+
--slides <list> 1-based indices to capture, e.g. 1,3,5 (default: all)
|
|
126
|
+
--dry-run capture + report refs, do NOT upload (PUTs aborted)
|
|
127
|
+
--force allow overwriting a NON-EMPTY existing deck
|
|
128
|
+
--out <dir> also write composed App-Store PNGs locally
|
|
129
|
+
--shell-origin <url> origin serving /build (default: your session origin)
|
|
130
|
+
--api-origin <url> origin for deck/capture APIs (default: session origin)
|
|
131
|
+
--timeout <ms> per-step bridge timeout (default: 45000)
|
|
132
|
+
--json machine-readable summary
|
|
133
|
+
|
|
134
|
+
examples:
|
|
135
|
+
sootsim screenshot appstore capture --org acme --repo my-app --dry-run
|
|
136
|
+
sootsim screenshot appstore capture --org acme --repo my-app --branch main --force
|
|
137
|
+
`;function It(e){let t=i=>{let n=e.indexOf(i);return n>=0?e[n+1]:void 0},o=i=>e.includes(i),s=t("--slides"),r=s?s.split(",").map(i=>Number(i.trim())).filter(i=>Number.isInteger(i)&&i>0):null;return{org:t("--org")??"",repo:t("--repo")??"",branch:t("--branch")??"main",platform:t("--platform")??"ios",slides:r&&r.length?r:null,dryRun:o("--dry-run"),force:o("--force"),out:t("--out")??null,shellOrigin:t("--shell-origin")??null,apiOrigin:t("--api-origin")??null,timeoutMs:Number(t("--timeout")??"45000")||45e3,json:o("--json")}}function _t(){let e=j();if(e&&e.kind==="session")return{token:e.token,origin:e.origin};process.stderr.write(`
|
|
138
|
+
sootsim screenshot appstore capture needs a logged-in session.
|
|
139
|
+
run \`sootsim login\` first (the captured slides upload to that account).
|
|
140
|
+
|
|
141
|
+
`),process.exit(1)}function Ut(e){let t=e.replace(/^\[|\]$/g,"").toLowerCase();return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t)}function jt(e){let t=new URL(e);if(Ut(t.hostname)){let s=(Number(t.port)||3e3)-3e3;if(s>=0&&s<=1e3)return t.port=String(5173+s),t.origin}return t.hostname==="sootbean.com"||t.hostname.endsWith(".sootbean.com")?"https://sootsim.com":e}function Lt(){try{return Number(Ye("sysctl -n vm.loadavg").toString().trim().split(/\s+/)[1])||0}catch{return 0}}async function Gt(e,t,o,s){let r=await fetch(`${e}/api/sootsim/screenshot-decks?org=${encodeURIComponent(o)}&repo=${encodeURIComponent(s)}`,{headers:{authorization:`Bearer ${t}`}});if(!r.ok)return[];let i=await r.json().catch(()=>null),n=[];for(let a of i?.decks??[])Array.isArray(a.config?.frames)&&n.push(...a.config.frames);return n}async function Ht(e,t,o,s){let r=await fetch(`${e}/api/sootsim/screenshot-capture?ref=${encodeURIComponent(s)}&org=${encodeURIComponent(o)}`,{headers:{authorization:`Bearer ${t}`}});return r.ok?`data:image/png;base64,${Buffer.from(await r.arrayBuffer()).toString("base64")}`:null}async function Yt(e,t){let o=Date.now()+t;for(;Date.now()<o;){for(let s of e.frames())if(await s.evaluate(()=>!!globalThis.SootSim?.bridges?.screenshotControl).catch(()=>!1))return s;await e.waitForTimeout(250)}throw new Error("screenshot bridge never appeared \u2014 the build shell did not boot screenshot mode (check --branch/--platform has a ready build, and you are logged in)")}async function He(e){return e.evaluate(async()=>{let o=globalThis.SootSim?.bridges?.screenshotControl;if(!o)throw new Error("screenshotControl missing");return o.getState()})}async function Wt(e){await e.evaluate(async()=>{let t=globalThis.SootSim?.bridges?.settings,o=Date.now()+3e3;for(;Date.now()<o;){if(t?.get?.()?.screenshotMode)return;await new Promise(s=>setTimeout(s,50))}t&&!t.get().screenshotMode&&(t.set("screenshotMode",!0),t.get().showFrame||t.set("showFrame",!0))})}async function qt(e,t,o,s){await e.evaluate(async([r,i,n])=>{let a=globalThis.SootSim,c=a?.bridges?.screenshotControl;if(!c)throw new Error("screenshotControl missing");let l=u=>new Promise(d=>setTimeout(d,u));if(i){c.focusSlide(r);let u=Date.now()+3e4,d=a?.bridges?.threeMode;for(;Date.now()<u&&(d=a?.bridges?.threeMode,!(d?.setScreenImage&&d?.captureStage&&d?.getState?.()?.ready));)await l(150);await l(1e3);let p=i;d?.configure?.({colorway:p.colorway,background:p.background,...p.customGradient?{customGradient:p.customGradient}:{},room:!!p.room,bokeh:!!p.bokeh,environment:p.environmentActive?{pins:p.environmentPins??{},effects:p.environmentEffects??{}}:!1,pose:{phonePosition:p.phonePosition,phoneRotation:p.phoneRotation,cameraPosition:p.cameraPosition,target:p.target}}),await l(900),n&&d?.setScreenImage&&(d.setScreenImage(n),await l(1200))}await c.capture(r)},[t,o,s])}async function We(e){if(e.includes("--help")||e.includes("-h"))return console.log(zt),0;let t=It(e);if(!t.org||!t.repo)return process.stderr.write(` --org and --repo are required (see --help)
|
|
142
|
+
`),1;let{token:o,origin:s}=_t(),r=(t.apiOrigin??s).replace(/\/$/,""),i=(t.shellOrigin??jt(r)).replace(/\/$/,""),n=await Gt(r,o,t.org,t.repo);if(!t.dryRun&&!t.force&&n.length>0)return process.stderr.write(` refusing to overwrite the existing ${t.org}/${t.repo} deck (${n.length} slide(s)). re-run with --force to replace it, or --dry-run to preview.
|
|
143
|
+
`),1;let a=Lt(),c=Number(Ye("sysctl -n hw.ncpu").toString().trim())||8;if(a>c)return process.stderr.write(` load average ${a.toFixed(1)} exceeds ${c} cores \u2014 tear down other work first.
|
|
144
|
+
`),1;let l=`${i}/build/${encodeURIComponent(t.org)}/${encodeURIComponent(t.repo)}/${encodeURIComponent(t.branch)}?platform=${encodeURIComponent(t.platform)}&ssMode=1`,u=Ft(Ge(At(),"sootsim-capture-")),{browser:d,reapNow:p}=await Le(()=>Ot.launchPersistentContext(u,{headless:!0,channel:"chrome",viewport:{width:393,height:852},deviceScaleFactor:3,args:["--enable-unsafe-webgpu","--enable-features=Vulkan,WebGPU","--hide-scrollbars"]}));await d.addInitScript(m=>{try{localStorage.setItem("sootsim.session.token",m)}catch{}},o);let y=[],f=d.pages()[0]??await d.newPage();t.dryRun?await f.route(/\/api\/sootsim\/screenshot-(decks|capture)/,m=>m.request().method()==="PUT"?m.abort():m.continue()):f.on("response",m=>{let x=m.url();m.request().method()==="PUT"&&(x.includes("/api/sootsim/screenshot-decks")?y.push({kind:"deck",status:m.status()}):x.includes("/api/sootsim/screenshot-capture")&&y.push({kind:"capture",status:m.status()}))});let h=[];f.on("pageerror",m=>h.push(m.message));let S=f.waitForResponse(m=>m.url().includes("/api/sootsim/screenshot-decks")&&m.request().method()==="GET",{timeout:t.timeoutMs}).catch(()=>null);try{await f.goto(l,{waitUntil:"domcontentloaded",timeout:t.timeoutMs});let m=await Yt(f,t.timeoutMs);await Wt(m),await S,await f.waitForTimeout(800);let x=await He(m);if(x.slides.length===0)return process.stderr.write(` the deck has no slides to capture \u2014 add slides in the composer first.
|
|
145
|
+
`),1;let E=t.slides?x.slides.filter(g=>t.slides.includes(g.index)):x.slides;console.log(` ${x.projectName} on ${x.deviceModel} \u2014 capturing ${E.length}/${x.slides.length} slide(s)${t.dryRun?" (dry-run, no upload)":""}`);for(let g of E)try{let b=n[g.index-1],$=b?.threeScene??null,O=$&&b?.screenRef?await Ht(r,o,t.org,b.screenRef):null;await qt(m,g.index,$,O),console.log(` \u2713 slide ${g.index} "${g.title.slice(0,40)}"`)}catch(b){console.log(` \u2717 slide ${g.index} "${g.title.slice(0,40)}" \u2014 ${b.message}`)}t.dryRun||await f.waitForTimeout(2500);let N=(await He(m)).slides.filter(g=>E.some(b=>b.id===g.id)),B=[];if(t.out){let g=Et(t.out)?t.out:Bt(process.cwd(),t.out);for(let b of N){if(!b.captureRef)continue;let $=await m.evaluate(async D=>{let ie=globalThis.SootSim?.bridges?.screenshotControl;if(!ie)throw new Error("screenshotControl missing");return ie.exportSlide(D)},b.index),O=$.dataUrl.match(/^data:[^;]+;base64,(.+)$/);if(O){let D=Ge(g,$.name);Rt(Tt(D),{recursive:!0}),Dt(D,Buffer.from(O[1],"base64")),B.push(D)}}}let se=N.filter(g=>g.captureRef&&g.cleanRef),Xe={org:t.org,repo:t.repo,branch:t.branch,dryRun:t.dryRun,slides:N.map(g=>({index:g.index,title:g.title,captureRef:!!g.captureRef,cleanRef:!!g.cleanRef,screenRef:!!g.screenRef,captureMode:g.captureMode})),editableCount:se.length,uploads:t.dryRun?"skipped (dry-run)":y,written:B,pageErrors:h.slice(0,5)};if(t.json)console.log(JSON.stringify(Xe,null,2));else{console.log(`
|
|
146
|
+
${se.length}/${N.length} slide(s) now have editable layers (captureRef + cleanRef)`);let g=N.filter(b=>b.captureRef&&!b.cleanRef);if(g.length&&console.log(` \u26A0 ${g.length} slide(s) baked a flat capture only (no cleanRef) \u2014 typically 3d slides whose scene didn't restore for a re-bake.`),!t.dryRun){let b=y.filter($=>$.status>=200&&$.status<300).length;console.log(` uploads: ${b}/${y.length} PUT(s) succeeded`)}B.length&&console.log(` wrote ${B.length} local PNG(s) to ${t.out}`),h.length&&console.log(` \u26A0 ${h.length} page error(s) during capture`)}return 0}finally{await d.close().catch(()=>{}),p(),Nt(u,{recursive:!0,force:!0})}}import{mkdirSync as Vt,writeFileSync as Kt}from"node:fs";import{dirname as Xt,isAbsolute as Jt,join as qe,resolve as Zt}from"node:path";var Qt=`
|
|
147
|
+
sootsim screenshot slides \u2014 compose App Store screenshots in the live sim
|
|
148
|
+
|
|
149
|
+
usage:
|
|
150
|
+
sootsim screenshot slides list slides (alias: slides list)
|
|
151
|
+
sootsim screenshot slides set <n> [fields] patch a slide's copy/colors
|
|
152
|
+
sootsim screenshot slides add append a blank slide (focuses it)
|
|
153
|
+
sootsim screenshot slides remove <n> delete a slide
|
|
154
|
+
sootsim screenshot slides focus <n> open a slide (device flips into it)
|
|
155
|
+
sootsim screenshot slides overview back to the gallery
|
|
156
|
+
sootsim screenshot slides capture [<n>] capture the live frame into a slide
|
|
157
|
+
sootsim screenshot slides export [<n>] [--out <dir>]
|
|
158
|
+
write composed App-Store PNG(s)
|
|
159
|
+
|
|
160
|
+
set fields:
|
|
161
|
+
--title <text> headline
|
|
162
|
+
--subtitle <text> subheadline
|
|
163
|
+
--bg-top <color> gradient top (white gray slate black cyan blue
|
|
164
|
+
--bg-bottom <color> gradient bottom teal green lime gold orange coral
|
|
165
|
+
--title-color <color> copy color override, or "auto" red berry magenta
|
|
166
|
+
--title-size <s> sm | md | lg | none gray-light
|
|
167
|
+
--underlay <s> black | white | none gray-dark \u2026)
|
|
168
|
+
--shadow <s> light | medium | strong | none
|
|
169
|
+
|
|
170
|
+
notes:
|
|
171
|
+
slides are addressed by 1-based index. screenshot mode is auto-enabled.
|
|
172
|
+
capture shoots whatever the sim currently shows \u2014 navigate the app first
|
|
173
|
+
(sootsim do tap-id \u2026), then capture.
|
|
174
|
+
|
|
175
|
+
examples:
|
|
176
|
+
sootsim screenshot slides set 1 --title "The ultimate MMA community." --bg-top cyan --bg-bottom black
|
|
177
|
+
sootsim screenshot slides capture 1
|
|
178
|
+
sootsim screenshot slides export --out ./exports
|
|
179
|
+
`,eo={"--title":"title","--subtitle":"subtitle","--bg-top":"bgTop","--bg-bottom":"bgBottom","--title-color":"titleColor","--title-size":"titleSize","--underlay":"titleUnderlay","--shadow":"titleShadow","--out":"out"};function to(e){let t=[],o={},s=!1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i==="--json"){s=!0;continue}let n=i.indexOf("="),a=n>0?i.slice(0,n):i,c=eo[a];if(c){n>0?o[c]=i.slice(n+1):(o[c]=e[r+1]??"",r+=1);continue}t.push(i)}return{rest:t,values:o,json:s}}function oo(e){if(!e)return;let t=Number(e);return Number.isInteger(t)&&t>0?t:e}async function ro(e){if(!await ue(e,`(async () => {
|
|
180
|
+
if (window.SootSim?.bridges?.settings?.get?.()?.screenshotMode) return true
|
|
181
|
+
window.dispatchEvent(new CustomEvent('sootsim:shell-command', {
|
|
182
|
+
detail: { type: 'fire-action', id: 'toggle-screenshot-mode' },
|
|
183
|
+
}))
|
|
184
|
+
const deadline = Date.now() + 2000
|
|
185
|
+
while (Date.now() < deadline) {
|
|
186
|
+
if (window.SootSim?.bridges?.settings?.get?.()?.screenshotMode) return true
|
|
187
|
+
await new Promise((r) => setTimeout(r, 40))
|
|
188
|
+
}
|
|
189
|
+
return false
|
|
190
|
+
})()`,{acquireLock:!0}))throw new Error("could not enable screenshot mode \u2014 is this a browser sim with the screenshot plugin? (electron has no screenshot mode)")}function no(e){console.log(` ${e.projectName} \u2014 canvas ${e.canvas} (${e.exportSize.width}\xD7${e.exportSize.height}), device ${e.deviceModel}`);for(let t of e.slides){let o=[t.focused?"focused":t.active?"active":null,t.captured?`captured${t.captureMode==="3d"?" 3d":""}`:"no capture"].filter(Boolean).join(", "),s=t.title?`"${t.title}"`:"(no title)",r=[`bg ${t.bgTop}\u2192${t.bgBottom}`,t.titleColor?`color ${t.titleColor}`:null,t.titleSize?`size ${t.titleSize}`:null,t.titleUnderlay?`underlay ${t.titleUnderlay}`:null,t.titleShadow?`shadow ${t.titleShadow}`:null].filter(Boolean).join(", ");console.log(` ${t.index}. ${s} \u2014 ${r} [${o}]`),t.subtitle&&console.log(` ${t.subtitle}`)}}function so(e){let t=e.match(/^data:[^;]+;base64,(.+)$/);if(!t)throw new Error("export returned an unexpected payload");return Buffer.from(t[1],"base64")}async function Ve(e,t){if(e.includes("--help")||e.includes("-h")){console.log(Qt);return}let{rest:o,values:s,json:r}=to(e),i=_(o,{port:t.port,commandTimeoutMs:45e3}),n=i.positional[0]??"list",a=oo(i.positional[1]),c=U(i),l=u=>{r?console.log(JSON.stringify(u,null,2)):no(u)};try{switch(await ro(c),n){case"list":{l(await F(c,"SootSim.bridges.screenshotControl.getState"));break}case"set":{if(a==null)throw new Error("usage: sootsim screenshot slides set <n> --title \u2026 (see --help)");let u={};for(let d of["title","subtitle","bgTop","bgBottom","titleColor","titleSize","titleUnderlay","titleShadow"])s[d]!=null&&(u[d]=s[d]);if(Object.keys(u).length===0)throw new Error("nothing to set \u2014 pass at least one field (see --help)");l(await M(c,"SootSim.bridges.screenshotControl.setSlide",a,u));break}case"add":{l(await M(c,"SootSim.bridges.screenshotControl.addSlide"));break}case"remove":{if(a==null)throw new Error("usage: sootsim screenshot slides remove <n>");l(await M(c,"SootSim.bridges.screenshotControl.removeSlide",a));break}case"focus":{if(a==null)throw new Error("usage: sootsim screenshot slides focus <n>");l(await M(c,"SootSim.bridges.screenshotControl.focusSlide",a));break}case"overview":{l(await M(c,"SootSim.bridges.screenshotControl.overview"));break}case"capture":{let u=await M(c,"SootSim.bridges.screenshotControl.capture",...a!=null?[a]:[]);l(u);break}case"export":{let u=s.out?Jt(s.out)?s.out:Zt(process.cwd(),s.out):qe(process.cwd(),"screenshots"),d=await F(c,"SootSim.bridges.screenshotControl.getState"),p=a!=null?d.slides.filter(f=>f.index===a||f.id===a):d.slides.filter(f=>f.captured);if(p.length===0)throw new Error(a!=null?`no slide ${a}`:"no captured slides to export \u2014 capture first");let y=[];for(let f of p){let h=await F(c,"SootSim.bridges.screenshotControl.exportSlide",f.index),S=qe(u,h.name);Vt(Xt(S),{recursive:!0}),Kt(S,so(h.dataUrl)),y.push(S),console.log(` saved: ${S} (${h.width}\xD7${h.height})`)}r&&console.log(JSON.stringify({written:y},null,2));break}default:throw new Error(`unknown subcommand "${n}" \u2014 see sootsim screenshot slides --help`)}}finally{c.close()}}var io=new Set(["--sim","--port","-p","--output","-o","--out","--plan","--app","--device","--org","--repo","--api-origin","--branch","--platform","--slides","--shell-origin","--timeout"]),ao=new Set(["capture","slides","appstore"]);function Ke(e){for(let t=0;t<e.length;t++){let o=e[t];if(o.startsWith("-")){io.has(o)&&t++;continue}return ao.has(o)?{name:o,index:t}:null}return null}function q(e,t){return[...e.slice(0,t),...e.slice(t+1)]}function co(e){let t=[];for(let o=0;o<e.length;o++){if(e[o]==="--sim"){o++;continue}t.push(e[o])}return t}async function yr(e,t){let o=Ke(e);if(!o||o.name==="capture"){await ke(o?q(e,o.index):e,t);return}if(o.name==="slides"){await Ve(q(e,o.index),t);return}let s=q(e,o.index),r=Ke(s);return r?.name==="capture"?We(co(q(s,r.index))):_e(s,t)}export{yr as runScreenshotCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{b as ce,c as H,d as le,e as F,f as de,h as ue,i as C,j as pe,k as me,l as he,p as fe,s as v,t as ge,u as Se,v as ye,w as ve}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.190 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{b as ce,c as H,d as le,e as F,f as de,h as ue,i as C,j as pe,k as me,l as he,p as fe,s as v,t as ge,u as Se,v as ye,w as ve}from"./chunk-K7OCH4WY.js";import"./chunk-5IM3DYTZ.js";import{a as ae}from"./chunk-P7MW7S62.js";import"./chunk-AAQ6AYYW.js";import{g as oe}from"./chunk-3JVMBXLH.js";import{f as P,g as ne}from"./chunk-SPYRMNAJ.js";import"./chunk-R3VO3MDO.js";import"./chunk-WR5IDCCN.js";import"./chunk-MJU4XNZ3.js";import"./chunk-Y6CZ5N26.js";import{d as se}from"./chunk-QJVITDKU.js";import{a as Q,b as ee}from"./chunk-KLGX6B46.js";import"./chunk-K5GLQDTG.js";import{a as ie,b as re}from"./chunk-CVUAT6TO.js";import"./chunk-SJHC6HZH.js";import{C as E,D as J,E as K,F as D,H as V,I as G,K as q,M as z,N as X,O as Y,P as U,Q as Z,y as M,z as j}from"./chunk-MH6BMKK5.js";import{a as te}from"./chunk-WT74ZUKN.js";import"./chunk-YWQH2KQJ.js";import{spawn as dt}from"child_process";import I from"fs";import{createServer as ut}from"http";import S from"path";import{WebSocket as h,WebSocketServer as pt}from"ws";import ke from"node:fs";import _ from"node:path";import{spawn as Ne}from"node:child_process";import Me from"node:fs";import De from"node:os";import Ue from"node:path";var be=/^[A-Za-z0-9._:-]{1,160}$/;function W(o){if(!o?.startsWith("AGENTBUS_SESSION:"))return null;let e=o.slice(17).trim();return be.test(e)?e:null}function we(o){return be.test(o)}function He(o){return typeof o.text=="string"?o.text.trim():""}function Fe(o){let e=o?.trim();if(e)return e;let t=process.env.AGENTBUS_COMMAND?.trim();if(t)return t;let i=Ue.join(De.homedir(),".local","bin","agentbus");return Me.existsSync(i)?i:"agentbus"}async function Ae(o){let e=o.sessionId.trim();if(!we(e))throw new Error(`invalid agentbus session id: ${e||"<empty>"}`);let t=He(o.prompt);if(!t)throw new Error("prompt text is empty");let i=Fe(o.command),s=o.timeoutMs??15e3;await new Promise((n,a)=>{let r=Ne(i,["send",e,t],{stdio:["ignore","ignore","pipe"],env:process.env}),c="",d=setTimeout(()=>{try{r.kill("SIGTERM")}catch{}a(new Error(`agentbus send timed out after ${Math.round(s/1e3)}s`))},s);r.stderr?.setEncoding("utf8"),r.stderr?.on("data",l=>{c.length<4e3&&(c+=String(l))}),r.on("error",l=>{clearTimeout(d),a(l)}),r.on("exit",(l,u)=>{if(clearTimeout(d),l===0){n();return}let p=c.trim();a(new Error(p||`agentbus send exited with ${u?`signal ${u}`:`code ${l??"unknown"}`}`))})})}var R=1;function We(){return[Number(process.env.VITE_PORT_WEB||process.env.PORT||3e3),Number(process.env.VITE_PORT_ZERO||7849),Number(process.env.VITE_PORT_POSTGRES||7432),Number(process.env.VITE_PORT_R2||9500)].filter(o=>Number.isFinite(o)&&o>0)}var x=class{subscriptions=new Map;sessionsBySocket=new Map;allSockets=new Set;pendingPromptEchoes=new Map;pendingTurns=new Map;opts;constructor(e={}){this.opts=e}registerSocket(e){this.allSockets.add(e)}unregisterSocket(e){let t=this.sessionsBySocket.get(e);if(t){for(let i of t)this.decrementSubscription(i);this.sessionsBySocket.delete(e)}this.allSockets.delete(e)}async handleMessage(e,t){let i=t?.type;if(typeof i!="string"||!i.startsWith("agent:"))return!1;let s=t.id;try{let n=await this.dispatch(e,i,t);this.respond(e,s,n)}catch(n){n instanceof v?this.respondError(e,s,n.message,n.code):this.respondError(e,s,n instanceof Error?n.message:String(n))}return!0}async seedOnBoot(){try{await he()}catch(e){process.stderr.write(`[sootsim-agent] seedFromDemoAppRegistry failed: ${e instanceof Error?e.message:String(e)}
|
|
3
3
|
`)}}close(){for(let e of this.subscriptions.values())try{e.unsubscribe()}catch{}this.subscriptions.clear(),this.sessionsBySocket.clear(),this.allSockets.clear()}async dispatch(e,t,i){switch(t){case"agent:list-projects":return F();case"agent:upsert-project":return H(i.input??{});case"agent:delete-project":return ue(String(i.projectId)),{ok:!0};case"agent:auto-attach-for-url":return this.autoAttachForUrl(i.input??{});case"agent:list-sessions":return pe(i.projectId?String(i.projectId):void 0);case"agent:start-session":return this.doStartSession(i.input??{});case"agent:send-claimed-prompt":return this.sendClaimedPrompt(i);case"agent:send-prompt":{let n=String(i.sessionId),a=C(n);if(!a)throw new v("NO_SESSION",`no session: ${n}`);let r=this.normalizePromptEnvelope(i);return await Se(n,r),this.notePromptAccepted(n,r,a.status==="working")}case"agent:end-session":this.dropSessionFanout(String(i.sessionId)),await ye(String(i.sessionId));let s=C(String(i.sessionId));return s&&this.broadcastSessionStatus(s),{ok:!0};case"agent:get-transcript":return this.getTranscript(String(i.sessionId));case"agent:get-paths":return this.getPaths();case"agent:subscribe-events":return this.subscribeSocket(e,String(i.sessionId));case"agent:unsubscribe-events":return this.unsubscribeSocket(e,String(i.sessionId));default:throw new v("UNKNOWN_AGENT_MSG",`unknown agent message: ${t}`)}}async sendClaimedPrompt(e){let t=typeof e.simId=="string"?e.simId.trim():"";if(!t)throw new v("NO_SIM","agent:send-claimed-prompt requires simId");let i=this.opts.resolveCliLease?.(t)??null;if(!i||i.kind!=="cli"||i.expiresAt<=Date.now())throw new v("NO_CLAIM",`sim ${t} has no active CLI claim`);let s=W(i.cliIdentityKey);if(!s)throw new v("UNSUPPORTED_CLAIM",`sim ${t} is claimed by a CLI identity that is not promptable`);return await Ae({sessionId:s,prompt:this.normalizePromptEnvelope(e)}),{ok:!0,routed:"agentbus",sessionId:s}}async doStartSession(e){if(!le(e.projectId))throw new v("NO_PROJECT",`no project: ${e.projectId}`);let i=await ge(e);return this.broadcastSessionStatus(i.session),i}async autoAttachForUrl(e){let t=e.bundleUrl??"",i=(()=>{try{return new URL(t).port||null}catch{return null}})();if(!i)return{project:null};let s=this.opts.getExcludePorts?.()??We(),a=(await P({excludePorts:s})).find(l=>String(l.port)===i);if(!a||!a.cwd)return{project:null};let r=F().find(l=>l.cwd===a.cwd)??null,c=Array.from(new Set([...r?.knownBundleUrls??[],a.bundleUrl,t]));return{project:H({cwd:a.cwd,name:a.projectName??_.basename(a.cwd),preferredProvider:e.provider??r?.preferredProvider,sourceRoots:r?.sourceRoots??[a.cwd],knownBundleUrls:c,framework:r?.framework??$e(a.framework),bundleId:a.bundleId??r?.bundleId})}}getTranscript(e){let t=fe(e);return ke.existsSync(t)?ke.readFileSync(t,"utf8"):{error:"transcript not found",code:"NO_TRANSCRIPT"}}getPaths(){let e=ce();return{userDataDir:e,storeFile:_.join(e,"attached-projects.json"),sessionsDir:_.join(e,"sessions"),transcriptsDir:_.join(e,"transcripts")}}subscribeSocket(e,t){let i=this.sessionsBySocket.get(e);if(i||(i=new Set,this.sessionsBySocket.set(e,i)),i.has(t))return{ok:!0,refCount:this.subscriptions.get(t)?.refCount??1};i.add(t);let s=this.subscriptions.get(t);if(s)return s.refCount++,{ok:!0,refCount:s.refCount};let n=ve(t,a=>{let r=this.coalescePromptEcho(t,a);if(r&&(this.applySessionEvent(t,r),this.fanOutEvent(t,r)),a.type==="turn-completed"){let c=C(t);if(c)try{de(c.projectId,{usd:a.costUsd,ts:a.ts})}catch(d){process.stderr.write(`[sootsim-agent] recordTurnTelemetry failed: ${d instanceof Error?d.message:String(d)}
|
|
4
4
|
`)}}});return this.subscriptions.set(t,{unsubscribe:n,refCount:1}),{ok:!0,refCount:1}}unsubscribeSocket(e,t){let i=this.sessionsBySocket.get(e);return!i||!i.has(t)?{ok:!0,refCount:0}:(i.delete(t),this.decrementSubscription(t))}decrementSubscription(e){let t=this.subscriptions.get(e);if(!t)return{ok:!0,refCount:0};if(t.refCount--,t.refCount<=0){try{t.unsubscribe()}catch{}return this.subscriptions.delete(e),{ok:!0,refCount:0}}return{ok:!0,refCount:t.refCount}}dropSessionFanout(e){let t=this.subscriptions.get(e);if(t){try{t.unsubscribe()}catch{}this.subscriptions.delete(e)}for(let i of this.sessionsBySocket.values())i.delete(e);this.clearPromptTracking(e)}normalizePromptEnvelope(e){if(e?.prompt&&typeof e.prompt=="object"){let t=e.prompt;return{text:String(t.text??""),...typeof t.displayText=="string"?{displayText:t.displayText}:{},...typeof t.inspectSummary=="string"?{inspectSummary:t.inspectSummary}:{},...typeof t.inspectTrace=="string"?{inspectTrace:t.inspectTrace}:{}}}return{text:String(e?.text??""),...typeof e?.displayText=="string"?{displayText:e.displayText}:{},...typeof e?.inspectSummary=="string"?{inspectSummary:e.inspectSummary}:{},...typeof e?.inspectTrace=="string"?{inspectTrace:e.inspectTrace}:{}}}notePromptAccepted(e,t,i){let s=Date.now(),n=this.pendingPromptEchoes.get(e)??[];n.push({sentAt:s}),this.pendingPromptEchoes.set(e,n);let a=Math.max(this.pendingTurns.get(e)??0,i?1:0)+1;this.pendingTurns.set(e,a);let r=t.displayText??t.text;return this.patchSession(e,{lastPrompt:r,status:"working",needsAttention:!1}),this.fanOutEvent(e,{type:"prompt-received",text:r,...t.inspectSummary?{inspectSummary:t.inspectSummary}:{},...t.inspectTrace?{inspectTrace:t.inspectTrace}:{},ts:s}),{ok:!0,queued:a>1,pendingTurns:a,queueDepth:Math.max(0,a-1)}}applySessionEvent(e,t){switch(t.type){case"prompt-received":case"turn-started":this.patchSession(e,{status:"working",needsAttention:!1});return;case"turn-completed":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"idle",needsAttention:!1,lastTurnFiles:t.filesTouched,currentlyEditing:void 0});return}case"approval-needed":this.patchSession(e,{status:"needs-attention",needsAttention:!0});return;case"error":{let i=this.consumeSettledTurn(e);this.patchSession(e,{status:i>0?"working":"needs-attention",needsAttention:i<=0,currentlyEditing:void 0});return}case"exited":this.clearPromptTracking(e),this.patchSession(e,{status:"ended",needsAttention:!1,wrapperPid:void 0,currentlyEditing:void 0});return;case"ready":case"turn-reasoning":case"turn-message":case"turn-plan":case"tool-call":case"file-edited":case"file-diff-delta":return}}patchSession(e,t){me(e,t);let i=C(e);i&&this.broadcastSessionStatus(i)}coalescePromptEcho(e,t){if(t.type!=="prompt-received")return t;let i=this.pendingPromptEchoes.get(e);if(!i||i.length===0)return t;for(;i.length>0&&Date.now()-i[0].sentAt>15e3;)i.shift();return i.length===0?(this.pendingPromptEchoes.delete(e),t):(i.shift(),i.length===0?this.pendingPromptEchoes.delete(e):this.pendingPromptEchoes.set(e,i),null)}consumeSettledTurn(e){let t=Math.max(0,(this.pendingTurns.get(e)??1)-1);return t>0?this.pendingTurns.set(e,t):this.pendingTurns.delete(e),t}clearPromptTracking(e){this.pendingPromptEchoes.delete(e),this.pendingTurns.delete(e)}fanOutEvent(e,t){let i=JSON.stringify({type:"agent:event",sessionId:e,event:t});for(let[s,n]of this.sessionsBySocket)if(n.has(e)&&s.readyState===R)try{s.send(i)}catch{}}broadcastSessionStatus(e){let t=JSON.stringify({type:"agent:session-status",session:e});for(let i of this.allSockets)if(i.readyState===R)try{i.send(t)}catch{}}respond(e,t,i){if(e.readyState===R)try{e.send(JSON.stringify({id:t,result:i}))}catch{}}respondError(e,t,i,s){if(e.readyState===R)try{e.send(JSON.stringify({id:t,error:i,...s?{code:s}:{}}))}catch{}}};function $e(o){return o==="expo"?"expo":o==="one"||o==="vxrn"?"one":"unknown"}import Ke from"http";import Ve from"https";var $="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",je=[{hostSuffix:"uniswap.org",headers:{origin:"https://app.uniswap.org",referer:"https://app.uniswap.org/"},suppressBrowserUserAgent:!0}];function Je(o){let e=o.toLowerCase();for(let t of je)if(e===t.hostSuffix||e.endsWith(`.${t.hostSuffix}`))return t}function Ie(o){let e=Je(o.hostname);return{"accept-encoding":"identity",...e?.suppressBrowserUserAgent?{}:{"user-agent":$},...e?.headers}}var Ge=new Set(["host","origin","referer","user-agent","accept-encoding","cookie","connection","keep-alive","transfer-encoding","upgrade","content-length","sec-fetch-site","sec-fetch-mode","sec-fetch-dest","sec-ch-ua","sec-ch-ua-mobile","sec-ch-ua-platform"]),qe={"access-control-allow-origin":"*","access-control-allow-methods":"GET,POST,PUT,DELETE,PATCH,OPTIONS","access-control-allow-headers":"*","access-control-expose-headers":"*","access-control-max-age":"3600"},ze=new Set(["host","origin","referer","sec-fetch-site","sec-fetch-mode","sec-fetch-dest"]);function T(o){for(let[e,t]of Object.entries(qe))o.setHeader(e,t)}function Xe(o,e){let t=[],i=e;i?.code&&t.push(i.code),i?.message&&t.push(i.message),i?.cause?.code&&t.push(i.cause.code),i?.cause?.message&&t.push(i.cause.message);let n=[...new Set(t.filter(Boolean))].join(" | ")||String(e);return o.includes("stored-in-.env.local")?`${n} | upstream url still contains placeholder env values`:n}function Ye(o){let t=(Array.isArray(o)?o[0]:o)?.split(";",1)[0]?.trim().toLowerCase();return t?t.startsWith("text/")||t==="application/json"||t.endsWith("+json")||t==="application/x-www-form-urlencoded"||t==="application/xml"||t.endsWith("+xml")||t==="application/javascript"||t==="application/graphql":!1}function Ze(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(Ge.has(i.toLowerCase())||(t[i]=Array.isArray(s)?s.join(", "):s));return Object.assign(t,e?Ie(e):{"user-agent":$}),t}function Qe(o,e){let t={};for(let[i,s]of Object.entries(o))s&&(ze.has(i.toLowerCase())||(t[i]=s));return t.host=e.host,t.origin=e.origin,t.referer=`${e.origin}/`,t}function Ce(o){return o?.startsWith("/__fetch-proxy?")||o?.startsWith("/__proxy?")||!1}function Te(o){return o?!!(o.startsWith("/__app-api?")||o.startsWith("/__app-api/")):!1}async function Ee(o,e){if(o.method==="OPTIONS"){T(e),e.writeHead(204),e.end();return}let i=new URLSearchParams((o.url||"").split("?")[1]||"").get("url");if(!i){T(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("missing url param");return}let s;try{s=new URL(i)}catch{T(e),e.writeHead(400,{"Content-Type":"text/plain"}),e.end("invalid url param");return}let n=Ze(o.headers,s),a;if(o.method!=="GET"&&o.method!=="HEAD"){let l=[];for await(let u of o)l.push(Buffer.isBuffer(u)?u:Buffer.from(u));if(l.length>0){let u=Buffer.concat(l);a=Ye(o.headers["content-type"])?u.toString("utf8"):u}}let r;try{r=await fetch(s.href,{method:o.method,headers:n,body:a,redirect:"follow"})}catch(l){T(e),e.writeHead(502,{"Content-Type":"text/plain"}),e.end(`fetch proxy error: ${Xe(s.href,l)}`);return}r.headers.forEach((l,u)=>{let p=u.toLowerCase();p==="content-encoding"||p==="transfer-encoding"||p==="content-length"||p==="set-cookie"||p.startsWith("access-control-")||e.setHeader(u,l)}),T(e);let c=r.headers.getSetCookie?.()??[];c.length>0&&e.setHeader("x-sootsim-set-cookie",c.join(", ")),e.statusCode=r.status;let d=Buffer.from(await r.arrayBuffer());e.end(d)}function Pe(o,e){let t=o.url||"",i="",s="";if(t.startsWith("/__app-api?")){let d=new URL(t,"http://sootsim.local");i=d.searchParams.get("path")||"",s=d.searchParams.get("origin")?.trim()||""}else if(t.startsWith("/__app-api/"))i=t.slice(10);else return!1;if(!s)return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: missing origin query param"),!0;if(o.method==="OPTIONS")return e.writeHead(204,{"Access-Control-Allow-Origin":o.headers.origin||"*","Access-Control-Allow-Methods":"GET,POST,PUT,PATCH,DELETE,OPTIONS","Access-Control-Allow-Headers":o.headers["access-control-request-headers"]||"*","Access-Control-Allow-Credentials":"true","Access-Control-Max-Age":"86400"}),e.end(),!0;let n;try{n=new URL(i,s)}catch{return e.writeHead(400,{"Content-Type":"text/plain"}),e.end("app-api: invalid origin or path"),!0}let a=n.protocol==="https:"?Ve:Ke,r=Qe(o.headers,n),c=a.request({hostname:n.hostname,port:n.port||(n.protocol==="https:"?443:80),path:n.pathname+n.search,method:o.method,headers:r},d=>{let l=Object.keys(d.headers).filter(u=>{let p=u.toLowerCase();return!p.startsWith("access-control-")&&p!=="set-cookie"}).join(", ");e.writeHead(d.statusCode??502,{...d.headers,"access-control-allow-origin":o.headers.origin||"*","access-control-allow-credentials":"true","access-control-expose-headers":l}),d.pipe(e)});return c.on("error",d=>{e.statusCode=502,e.end(`app proxy error: ${d.message}`)}),o.pipe(c),!0}import{WebSocket as k,WebSocketServer as et}from"ws";var tt="/__websocket-proxy",it=new Set(["host","connection","upgrade","transfer-encoding","content-length","sec-websocket-accept","sec-websocket-extensions","sec-websocket-key","sec-websocket-protocol","sec-websocket-version"]);function A(o,e,t){try{o.write(`HTTP/1.1 ${e} ${t}\r
|
|
5
5
|
Connection: close\r
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
2
|
-
import{a as g,b as k}from"./chunk-
|
|
1
|
+
/*! sootsim v0.1.190 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
import{a as g,b as k}from"./chunk-SMDCNCVZ.js";import{b as S,c as x}from"./chunk-INRO26KS.js";import{a as w}from"./chunk-KLGX6B46.js";import"./chunk-K5GLQDTG.js";import"./chunk-F6GCSGBJ.js";import"./chunk-LRJVY7SN.js";import"./chunk-PGQHNKRL.js";import"./chunk-7TSFDDU7.js";import"./chunk-CVUAT6TO.js";import"./chunk-SJHC6HZH.js";import{D as v,I as f,K as m,l as b}from"./chunk-MH6BMKK5.js";import"./chunk-WT74ZUKN.js";import"./chunk-24OZOK2K.js";import"./chunk-ITQV76PX.js";import"./chunk-YWQH2KQJ.js";import{existsSync as r,mkdirSync as j,readFileSync as d,readdirSync as I,writeFileSync as D}from"fs";import{basename as p,dirname as y,join as i,relative as c,resolve as h}from"path";var T=["bun","pnpm","npm"];async function pe(n){(n.includes("--help")||n.includes("-h"))&&(console.log(`
|
|
3
3
|
sootsim setup \u2014 set up this machine for SootSim
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -94,4 +94,4 @@ module.exports = {
|
|
|
94
94
|
4. inspect and drive it:
|
|
95
95
|
sootsim describe
|
|
96
96
|
sootsim do tap-text "Sign in"
|
|
97
|
-
`)}function N(n,e){switch(n){case"bun":return`bunx ${e}`;case"pnpm":return`pnpm exec ${e}`;case"npm":return`npx ${e}`}}function ne(n,e){switch(n){case"bun":return`bun run ${e}`;case"pnpm":return`pnpm run ${e}`;case"npm":return`npm run ${e}`}}function oe(n){switch(n){case"bun":return"bun add -g sootsim";case"pnpm":return"pnpm add -g sootsim";case"npm":return"npm i -g sootsim"}}async function te(n,e){if(!e||n.dryRun)return;if(console.log(" last step:"),!process.stdin.isTTY){console.log(" run `sootsim open` after your Metro/Expo/One server is up");return}if(!await g("I'll run `sootsim open` for you now?",!0)){console.log(" later: sootsim open");return}let{runOpenCommand:o}=await import("./control-
|
|
97
|
+
`)}function N(n,e){switch(n){case"bun":return`bunx ${e}`;case"pnpm":return`pnpm exec ${e}`;case"npm":return`npx ${e}`}}function ne(n,e){switch(n){case"bun":return`bun run ${e}`;case"pnpm":return`pnpm run ${e}`;case"npm":return`npm run ${e}`}}function oe(n){switch(n){case"bun":return"bun add -g sootsim";case"pnpm":return"pnpm add -g sootsim";case"npm":return"npm i -g sootsim"}}async function te(n,e){if(!e||n.dryRun)return;if(console.log(" last step:"),!process.stdin.isTTY){console.log(" run `sootsim open` after your Metro/Expo/One server is up");return}if(!await g("I'll run `sootsim open` for you now?",!0)){console.log(" later: sootsim open");return}let{runOpenCommand:o}=await import("./control-TKDPQACC.js");await o([],{port:7668})}async function R(n,e,o){return o.yes?!0:process.stdin.isTTY?g(n,e):(console.log(` ${n} ${e?"[Y/n]":"[y/N]"} n (non-interactive; pass --yes to accept)`),!1)}export{J as detectConfigScaffoldExt,M as detectNodeVersionPins,W as detectPreferredPackageManager,E as readMachineSetupStatus,pe as runSetup,de as shouldRunSetupForBareCommand};
|