sootsim 0.0.4 → 0.1.37
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/LICENSE +21 -0
- package/README.md +24 -9
- package/dist-cli/bin.js +15 -20
- package/dist-cli/chunks/{agent-PJAOF4JS.js → agent-EQRQGSBL.js} +4 -4
- package/dist-cli/chunks/agent-wrapper-AWKZ67GN.js +15 -0
- package/dist-cli/chunks/{assert-P47NW4AF.js → assert-ZVGELUZB.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-UEOLNAWJ.js +2 -0
- package/dist-cli/chunks/beta-4MD7WSI4.js +2 -0
- package/dist-cli/chunks/chunk-2ZPJHSIJ.js +11 -0
- package/dist-cli/chunks/chunk-4IO3D5XG.js +2 -0
- package/dist-cli/chunks/chunk-4OHVCGMF.js +2 -0
- package/dist-cli/chunks/chunk-56BIMCDH.js +2 -0
- package/dist-cli/chunks/chunk-5FLDI6CV.js +66 -0
- package/dist-cli/chunks/{chunk-WWDJCKMI.js → chunk-B3RAGRK6.js} +1 -1
- package/dist-cli/chunks/chunk-BGAPLYMS.js +61 -0
- package/dist-cli/chunks/chunk-CX3ZIPD3.js +3 -0
- package/dist-cli/chunks/{chunk-I6XGFZPA.js → chunk-DSTV2VJT.js} +2 -2
- package/dist-cli/chunks/chunk-EDBFYOQB.js +2 -0
- package/dist-cli/chunks/chunk-ERLA3F77.js +1 -0
- package/dist-cli/chunks/chunk-FCQLQ7NA.js +117 -0
- package/dist-cli/chunks/chunk-H2HSOHXN.js +7 -0
- package/dist-cli/chunks/chunk-HYYMBXIX.js +2 -0
- package/dist-cli/chunks/chunk-JMGDVXAV.js +3 -0
- package/dist-cli/chunks/chunk-JMU5IGIU.js +1 -0
- package/dist-cli/chunks/chunk-KA5JJCWL.js +1 -0
- package/dist-cli/chunks/chunk-L4F4JRKJ.js +348 -0
- package/dist-cli/chunks/chunk-LDWXH43L.js +4 -0
- package/dist-cli/chunks/chunk-PERKPZ7T.js +4 -0
- package/dist-cli/chunks/chunk-PN6FWLD4.js +5 -0
- package/dist-cli/chunks/chunk-QD7YIVPS.js +64 -0
- package/dist-cli/chunks/chunk-QWKO62QM.js +2 -0
- package/dist-cli/chunks/{chunk-6SZMLFCR.js → chunk-QXMZNJV5.js} +1 -1
- package/dist-cli/chunks/chunk-R77F5J3X.js +4 -0
- package/dist-cli/chunks/chunk-RLNIKWFO.js +27 -0
- package/dist-cli/chunks/chunk-RX6RHGSI.js +2 -0
- package/dist-cli/chunks/chunk-S74RCIVB.js +2 -0
- package/dist-cli/chunks/chunk-SK4SOISL.js +1 -0
- package/dist-cli/chunks/{chunk-AFQBSK2J.js → chunk-T5L73GJB.js} +1 -1
- package/dist-cli/chunks/{chunk-432TMHBG.js → chunk-UIQ3536J.js} +1 -1
- package/dist-cli/chunks/chunk-URSEYCC5.js +16 -0
- package/dist-cli/chunks/chunk-WFXYY3DU.js +3 -0
- package/dist-cli/chunks/{chunk-DQKQYPIG.js → chunk-WHLHA5R5.js} +4 -4
- package/dist-cli/chunks/chunk-WLIVBPPY.js +3 -0
- package/dist-cli/chunks/{chunk-UQ3N6FZF.js → chunk-X6BP5JFC.js} +4 -4
- package/dist-cli/chunks/chunk-YFXTO4QX.js +5 -0
- package/dist-cli/chunks/{chunk-4XBPZQLW.js → chunk-Z5SVSAZO.js} +2 -2
- package/dist-cli/chunks/{chunk-5TTQKPGH.js → chunk-Z5X3PITK.js} +3 -3
- package/dist-cli/chunks/chunk-ZBOIGEGO.js +5 -0
- package/dist-cli/chunks/chunk-ZERYEI3L.js +17 -0
- package/dist-cli/chunks/{compat-ILLJ7VDL.js → compat-QQ3OJDBI.js} +2 -2
- package/dist-cli/chunks/{config-CDIAJIIT.js → config-LT27SC25.js} +2 -2
- package/dist-cli/chunks/control-3BO54QMO.js +2 -0
- package/dist-cli/chunks/cpu-profile-XEO3JCVB.js +22 -0
- package/dist-cli/chunks/daemon-3J2SAVQZ.js +83 -0
- package/dist-cli/chunks/{debug-6SMCTPMC.js → debug-OGQLIH4U.js} +4 -4
- package/dist-cli/chunks/demo-app-registry-5RZCXLWB.js +2 -0
- package/dist-cli/chunks/detox-Z2OSCIQU.js +49 -0
- package/dist-cli/chunks/device-RPTVD25S.js +16 -0
- package/dist-cli/chunks/diagnose-LAEXBNOQ.js +41 -0
- package/dist-cli/chunks/drivers-PSQUUAYC.js +2 -0
- package/dist-cli/chunks/electron-S2463O3P.js +18 -0
- package/dist-cli/chunks/flow-34YCVQDB.js +2 -0
- package/dist-cli/chunks/hints-E5PXPWFT.js +2 -0
- package/dist-cli/chunks/home-paths-F5SGBTRZ.js +2 -0
- package/dist-cli/chunks/inspect-EVGMEZ3G.js +1101 -0
- package/dist-cli/chunks/install-AM5PTJT3.js +2 -0
- package/dist-cli/chunks/install-desktop-ZNWYKTWQ.js +23 -0
- package/dist-cli/chunks/{keys-OWQ7SOTM.js → keys-5ETF6DYO.js} +2 -2
- package/dist-cli/chunks/{launch-WUEDHSO5.js → launch-DHUCNFX6.js} +3 -3
- package/dist-cli/chunks/login-KDR34JIP.js +26 -0
- package/dist-cli/chunks/logout-R6WIJYCW.js +2 -0
- package/dist-cli/chunks/maestro-ZOOJ2YVH.js +80 -0
- package/dist-cli/chunks/{preview-4RVHA2PP.js → preview-YFADHNBD.js} +2 -2
- package/dist-cli/chunks/profile-CQSC32HB.js +22 -0
- package/dist-cli/chunks/react-QSQD6CJE.js +30 -0
- package/dist-cli/chunks/{record-KEWLM5JR.js → record-IWLEYATN.js} +5 -5
- package/dist-cli/chunks/runtime-WKMNKYTN.js +25 -0
- package/dist-cli/chunks/screenshot-VJXHV57I.js +28 -0
- package/dist-cli/chunks/screenshot-mode-FA4VQ76K.js +17 -0
- package/dist-cli/chunks/screenshots-U4FQXHVK.js +70 -0
- package/dist-cli/chunks/server-7WZLM5NQ.js +35 -0
- package/dist-cli/chunks/setup-repo-3BXLAX5E.js +2 -0
- package/dist-cli/chunks/{skills-DJA6QEVR.js → skills-KO7RCY24.js} +2 -2
- package/dist-cli/chunks/start-EBD7T2GW.js +23 -0
- package/dist-cli/chunks/store-ONX3EBS4.js +2 -0
- package/dist-cli/chunks/telemetry-MFR7TUW7.js +2 -0
- package/dist-cli/chunks/{test-IWUHNFXV.js → test-OSVUG54G.js} +3 -3
- package/dist-cli/chunks/three-mode-MDBXZQG4.js +39 -0
- package/dist-cli/chunks/timeline-UJOKZKQR.js +22 -0
- package/dist-cli/chunks/upload-H2SMWP6T.js +2 -0
- package/dist-cli/chunks/what-happened-LFWH74FR.js +15 -0
- package/dist-cli/chunks/whoami-CUF56TLP.js +2 -0
- package/dist-lib/agent-daemon-client.cjs +6 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +42 -39
- package/dist-lib/attached-projects.cjs +30 -28
- package/dist-lib/auth/shared-session.cjs +35 -27
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +6 -2
- package/dist-lib/dev-bundle-resolution.cjs +7 -21
- package/dist-lib/home-paths.cjs +112 -30
- package/dist-lib/host/bridge-host.cjs +1817 -579
- package/dist-lib/host/fetch-proxy-handler.cjs +248 -0
- package/dist-lib/index.cjs +22 -22
- package/dist-lib/metro.cjs +22 -22
- package/dist-lib/profiles.cjs +246 -0
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/vite-base.cjs +3224 -764
- package/dist-lib/vite.cjs +1 -1
- package/package.json +11 -3
- package/dist-cli/chunks/agent-wrapper-STO7PLQD.js +0 -15
- package/dist-cli/chunks/auto-bootstrap-SC2LMI2H.js +0 -2
- package/dist-cli/chunks/chunk-47S5DXXX.js +0 -11
- package/dist-cli/chunks/chunk-4VXB2DBA.js +0 -119
- package/dist-cli/chunks/chunk-AUR2LTNX.js +0 -3
- package/dist-cli/chunks/chunk-BQRM4E66.js +0 -4
- package/dist-cli/chunks/chunk-C3QLIYCS.js +0 -16
- package/dist-cli/chunks/chunk-EHMSE3Q3.js +0 -2
- package/dist-cli/chunks/chunk-F4ARVCRR.js +0 -1
- package/dist-cli/chunks/chunk-HAKR72LJ.js +0 -2
- package/dist-cli/chunks/chunk-HGFIS26A.js +0 -2
- package/dist-cli/chunks/chunk-MQDPKSCK.js +0 -308
- package/dist-cli/chunks/chunk-MZPAJ5PQ.js +0 -1
- package/dist-cli/chunks/chunk-OAHMYSMD.js +0 -2
- package/dist-cli/chunks/chunk-QIP7LYQI.js +0 -5
- package/dist-cli/chunks/chunk-QQOBLF7O.js +0 -22
- package/dist-cli/chunks/chunk-SY74J6F4.js +0 -5
- package/dist-cli/chunks/chunk-UKYK63H6.js +0 -3
- package/dist-cli/chunks/chunk-UNFERMZ3.js +0 -27
- package/dist-cli/chunks/chunk-VGXARPIH.js +0 -3
- package/dist-cli/chunks/chunk-W3TYN64D.js +0 -62
- package/dist-cli/chunks/chunk-W7CYWXRZ.js +0 -4
- package/dist-cli/chunks/chunk-WRF43M33.js +0 -4
- package/dist-cli/chunks/chunk-WVBPATRA.js +0 -2
- package/dist-cli/chunks/chunk-XJF46GU2.js +0 -2
- package/dist-cli/chunks/chunk-ZF5FCFLD.js +0 -2
- package/dist-cli/chunks/chunk-ZKNI5MRD.js +0 -1
- package/dist-cli/chunks/control-7QGKUCAX.js +0 -2
- package/dist-cli/chunks/daemon-4BLYGM5N.js +0 -49
- package/dist-cli/chunks/demo-app-registry-HLI5UGGI.js +0 -2
- package/dist-cli/chunks/detox-R4G5INNB.js +0 -49
- package/dist-cli/chunks/device-YSLCWS4E.js +0 -16
- package/dist-cli/chunks/drivers-YIXRFFBQ.js +0 -2
- package/dist-cli/chunks/electron-JZOFO37G.js +0 -15
- package/dist-cli/chunks/flow-L7X5FGIN.js +0 -2
- package/dist-cli/chunks/hints-O4QR6UGI.js +0 -2
- package/dist-cli/chunks/home-paths-4YJJYGR6.js +0 -2
- package/dist-cli/chunks/inspect-DRFAUJUH.js +0 -1030
- package/dist-cli/chunks/install-BATRTWRI.js +0 -65
- package/dist-cli/chunks/install-desktop-6X474IQ3.js +0 -23
- package/dist-cli/chunks/install-dev-desktop-CAJHPRNP.js +0 -100
- package/dist-cli/chunks/login-54YJ2KH6.js +0 -26
- package/dist-cli/chunks/logout-XECXLEXW.js +0 -2
- package/dist-cli/chunks/maestro-PMHK6EHI.js +0 -75
- package/dist-cli/chunks/profile-3IVNHUS6.js +0 -22
- package/dist-cli/chunks/runtime-PJKHEB36.js +0 -25
- package/dist-cli/chunks/screenshot-BXRAQERZ.js +0 -26
- package/dist-cli/chunks/screenshot-mode-5IXEDIUS.js +0 -17
- package/dist-cli/chunks/screenshots-T4MQF3TB.js +0 -70
- package/dist-cli/chunks/server-CIP3LH45.js +0 -29
- package/dist-cli/chunks/store-SPC247DB.js +0 -2
- package/dist-cli/chunks/upload-UPD2RSYF.js +0 -2
- package/dist-cli/chunks/whoami-MCXFWKIH.js +0 -2
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as he}from"./chunk-QIP7LYQI.js";import{a as be}from"./chunk-UNFERMZ3.js";import{a as ge}from"./chunk-DQKQYPIG.js";import{a as ye,b as q,c as ve}from"./chunk-W3TYN64D.js";import{f as ne}from"./chunk-EHMSE3Q3.js";import{a as B,b as A,c as de,d as H,f as ue,g as fe}from"./chunk-I6XGFZPA.js";import{e as we,k as me}from"./chunk-47S5DXXX.js";import{b as ce}from"./chunk-5TTQKPGH.js";import{c as z,d as ae,e as le}from"./chunk-C3QLIYCS.js";import{d as ie}from"./chunk-W7CYWXRZ.js";import{a as pe}from"./chunk-SY74J6F4.js";import*as $ from"fs";import{tmpdir as Te}from"os";import*as g from"path";import*as m from"fs";import*as w from"path";var V=1e4,U=393,E=852,Se="__sootsimCliPerf",Ce="maestroCopiedText",X=new Map;function f(s){return new Promise(e=>setTimeout(e,s))}function Oe(s){return s?w.basename(s)===".maestro"?w.dirname(s):s:process.cwd()}function De(s,e,t){let r=e.endsWith(".png")?e:`${e}.png`;if(w.isAbsolute(r))return r;if(t.mode==="flow"&&/[\\/]/.test(r)){let o=r.startsWith("./")||r.startsWith("../")?t.flowDir??process.cwd():Oe(t.flowDir);return w.resolve(o,r)}return w.join(s,r)}function Ne(s){if(typeof s=="string")return{path:s,withFrame:!1};let e=s.path?.trim()||s.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:s.withFrame===!0}}function Y(s){let[e,t]=s.split(",").map(o=>o.trim()),r=(o,i)=>o.endsWith("%")?Number.parseFloat(o)/100*i:Number.parseFloat(o);return{x:r(e,U),y:r(t,E)}}function G(s){return typeof s=="string"?s.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>{if(X.has(t))return X.get(t);let r=process.env[t];if(r===void 0)throw new Error(`missing environment variable for flow placeholder: ${t}`);return r}):Array.isArray(s)?s.map(e=>G(e)):s&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,G(t)])):s}function Re(s){let e=s.split(/^---$/m),t=e.length>1?e[e.length-1]:s,r=G(A.parse(t));return Array.isArray(r)?r:[]}var W=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingDurationMs=null;browserRouteHint=null;lastFailedStep=null;get browserId(){return this.opts.browserId}setBrowserRouteHint(e){this.browserRouteHint=this.normalizeBrowserRoute(e)}normalizeBrowserRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let r=t.searchParams.toString();return`${t.origin}${t.pathname}${r?`?${r}`:""}`}catch{return e}}async refreshBrowserId(){if(this.opts.browserId)try{let e=await this.bridge.listBrowsers(),t=e.find(a=>a.id===this.opts.browserId);if(t&&(this.browserRouteHint=this.normalizeBrowserRoute(t.url||t.origin)),e.find(a=>a.id===this.opts.browserId&&a.readyState==="open")||!this.browserRouteHint)return;let o=this.browserRouteHint&&e.find(a=>a.readyState==="open"&&this.normalizeBrowserRoute(a.url||a.origin)===this.browserRouteHint);if(!o)return;let i=e.find(a=>a.isPrimary&&a.readyState==="open"),n=e.find(a=>a.readyState==="open"),l=o??i??n;l&&(this.opts.browserId=l.id,console.log(` [flow] session rotated to ${l.id}`))}catch{}}async evaluate(e){return this.bridge.send({type:"evaluate",browserId:this.opts.browserId,code:e})}async callTest(e,...t){return this.bridge.send({type:"call",browserId:this.opts.browserId,path:`__sootsimTest.${e}`,args:t})}async waitForTree(e=V){let t=Date.now()+e,r=null;for(;Date.now()<t;){try{let o=await this.evaluate(`(async () => {
|
|
3
|
-
const test = window.__sootsimTest
|
|
4
|
-
if (!test) return { count: 0, loading: true }
|
|
5
|
-
const count = (await test.getNodeCount?.()) || 0
|
|
6
|
-
const external = globalThis.__sootsimExternalAppState
|
|
7
|
-
if (external?.error) {
|
|
8
|
-
return { count, loading: false, error: String(external.error) }
|
|
9
|
-
}
|
|
10
|
-
if (external) {
|
|
11
|
-
return {
|
|
12
|
-
count,
|
|
13
|
-
loading: !external.ready,
|
|
14
|
-
error: null,
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const loadingNode = await test.findByText?.('loading')
|
|
18
|
-
const capturingNode = await test.findByText?.('capturing')
|
|
19
|
-
const openingAppNode = await test.findByText?.('opening app')
|
|
20
|
-
const isLoading = !!loadingNode || !!capturingNode || !!openingAppNode || count < 5
|
|
21
|
-
return { count, loading: isLoading, error: null }
|
|
22
|
-
})()`);if(o?.error)throw new Error(`app failed to load: ${o.error}`);if(o&&o.count>10&&!o.loading)return}catch(o){r=o instanceof Error?o:new Error(String(o)),await this.refreshBrowserId()}await f(500)}throw r?.message.startsWith("app failed to load:")?r:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(await be("flow --video",{originOverride:this.opts.billingOriginOverride}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
|
|
23
|
-
const rec = window.__sootsimRecorder
|
|
24
|
-
if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
|
|
25
|
-
if (rec.state() === 'recording') return { ok: true, format: 'webm' }
|
|
26
|
-
return rec.start({ format: 'webm', fps: 24 })
|
|
27
|
-
})()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}async stopRecording(){if(!this.recordingEnabled||!this.opts.recordingOutputDir)return null;this.recordingEnabled=!1;let e=Date.now(),t=await this.evaluate("window.__sootsimRecorder.stop()");if(!t?.ok)throw this.recordingStartedAtMs=null,new Error(t?.error||"recording stop failed");this.lastRecordingDurationMs=this.recordingStartedAtMs?Math.max(1,e-this.recordingStartedAtMs):null,this.recordingStartedAtMs=null;let r=[],o=0;for(;;){let n=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${o}, chunk: 2097152 })`);if(!n||(r.push(Buffer.from(n.data,"base64")),o=n.offset,n.done))break}if(r.length===0)throw new Error("recording requested but no video buffer was produced");m.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let i=w.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.webm`);return m.writeFileSync(i,Buffer.concat(r)),i}async findElement(e){return this.evaluate(`(async () => {
|
|
28
|
-
const test = window.__sootsimTest
|
|
29
|
-
if (!test) return null
|
|
30
|
-
let node = null
|
|
31
|
-
if (${JSON.stringify(!!e.text)}) node = await test.findByText(${JSON.stringify(e.text||"")})
|
|
32
|
-
if (!node && ${JSON.stringify(!!e.id)}) {
|
|
33
|
-
node = (await test.findByTestId(${JSON.stringify(e.id||"")})) || (await test.findById(${JSON.stringify(e.id||"")}))
|
|
34
|
-
}
|
|
35
|
-
if (!node || !node.absolutePosition || !node.layout) return null
|
|
36
|
-
return {
|
|
37
|
-
nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
|
|
38
|
-
id: node.id || null,
|
|
39
|
-
testID: node.testID || null,
|
|
40
|
-
text: node.text || null,
|
|
41
|
-
absolutePosition: node.absolutePosition,
|
|
42
|
-
layout: node.layout,
|
|
43
|
-
isTextInput: !!node.isTextInput,
|
|
44
|
-
}
|
|
45
|
-
})()`)}async resolveTapTarget(e){return this.evaluate(`(async () => {
|
|
46
|
-
const test = window.__sootsimTest
|
|
47
|
-
if (!test?.resolveTapTarget) return null
|
|
48
|
-
return await test.resolveTapTarget(${e})
|
|
49
|
-
})()`)}async activatePressTarget(e){return this.evaluate(`(async () => {
|
|
50
|
-
const test = window.__sootsimTest
|
|
51
|
-
if (!test) return null
|
|
52
|
-
${e.id?`const direct = await test.activatePressById?.(${JSON.stringify(e.id)})`:`const direct = await test.activatePressByText?.(${JSON.stringify(e.text||"")})`}
|
|
53
|
-
return direct || null
|
|
54
|
-
})()`)}async activatePressAt(e,t){return this.evaluate(`(async () => {
|
|
55
|
-
const test = window.__sootsimTest
|
|
56
|
-
if (!test?.activatePressAt) return null
|
|
57
|
-
return await test.activatePressAt(${e}, ${t})
|
|
58
|
-
})()`)}async tap(e,t){return await this.bridge.send({type:"tap",browserId:this.opts.browserId,x:e,y:t})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let a=Y(t.point);(await this.activatePressAt(a.x,a.y))?.ok||await this.tap(a.x,a.y),await f(300);return}let r=5e3,o=150,i=Date.now()+r,n=await this.findElement({text:t.text,id:t.id});for(;!n&&Date.now()<i;)await f(o),n=await this.findElement({text:t.text,id:t.id});if(n&&!n.isTextInput&&(await this.activatePressTarget(t))?.ok){await f(300);return}if(n){let a=typeof n.nodeId=="number"?await this.resolveTapTarget(n.nodeId):null,p=a?.cx??n.absolutePosition.x+n.layout.width/2,h=a?.cy??n.absolutePosition.y+n.layout.height/2;if((await this.tap(p,h))?.hit!==!1){await f(300);return}}if((await this.activatePressTarget(t))?.ok){await f(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async tapAtCoords(e,t){await this.tap(e,t),await f(300)}async doubleTapAtCoords(e,t,r=80){let o=Math.max(0,Math.round(r));if(!await this.evaluate(`(async () => {
|
|
59
|
-
const interact = window.__sootsimInteract
|
|
60
|
-
if (interact?.doubleTap) {
|
|
61
|
-
return !!(await interact.doubleTap(${e}, ${t}, ${o}))
|
|
62
|
-
}
|
|
63
|
-
if (!interact?.tap) return false
|
|
64
|
-
const first = await interact.tap(${e}, ${t})
|
|
65
|
-
if (!first || first.hit === false) return false
|
|
66
|
-
await new Promise((resolve) => setTimeout(resolve, ${o}))
|
|
67
|
-
const second = await interact.tap(${e}, ${t})
|
|
68
|
-
return !!second && second.hit !== false
|
|
69
|
-
})()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let r=0;r<15;r++){let o=await this.findElement(t);if(o&&o.absolutePosition.y+o.layout.height>0&&o.absolutePosition.y<E)return;await f(200)}throw new Error(`assertVisible: ${JSON.stringify(t)} not found or off-screen`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e,r=await this.findElement(t);if(r&&r.absolutePosition.y+r.layout.height>0&&r.absolutePosition.y<E)throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible`)}async inputText(e){await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"type",text:e}),await f(200)}async pressKey(e){await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"press",text:e}),await f(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"dispatchKey",text:e}),await f(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",browserId:this.opts.browserId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let t=await this.evaluate(`(() => {
|
|
70
|
-
const keyboard =
|
|
71
|
-
window.__sootsimKeyboard ??
|
|
72
|
-
window.SootSim?.bridges?.keyboard ??
|
|
73
|
-
null
|
|
74
|
-
const test = window.__sootsimTest
|
|
75
|
-
return {
|
|
76
|
-
visible: !!keyboard?.isVisible?.(),
|
|
77
|
-
focused: !!test?.isTextInputFocused?.(),
|
|
78
|
-
}
|
|
79
|
-
})()`);if(!t?.visible&&!t?.focused){await f(80);return}await f(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.pressKey("Backspace");await f(100)}async waitFor(e){let t=Date.now()+(e.timeout||V);for(;Date.now()<t;){if(await this.findElement(e))return;await f(200)}throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||V}ms`)}async takeScreenshot(e){await f(250);let t=Ne(e),r=De(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});m.mkdirSync(w.dirname(r),{recursive:!0});let i=(await this.bridge.send({type:"screenshot",browserId:this.opts.browserId})).replace(/^data:image\/png;base64,/,""),n=Buffer.from(i,"base64");if(t.withFrame){let l=await this.readCurrentDeviceModel();if(!l)throw new Error("could not read current device model for framed screenshot");let a=await ge(n,l);m.writeFileSync(r,a),console.log(`[flow] screenshot: ${r} (frame: ${l})`);return}m.writeFileSync(r,n),console.log(`[flow] screenshot: ${r}`)}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",browserId:this.opts.browserId,path:"SootSim.bridges.settings.get",args:[]}),t=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!t||!(t in ne)?null:t}async captureFailureScreenshot(e){m.mkdirSync(w.dirname(e),{recursive:!0});let r=(await this.bridge.send({type:"screenshot",browserId:this.opts.browserId})).replace(/^data:image\/png;base64,/,"");m.writeFileSync(e,Buffer.from(r,"base64"))}async captureFailureBundle(e,t){m.mkdirSync(e,{recursive:!0});let r=(p,h)=>{try{m.writeFileSync(w.join(e,p),h)}catch{}},o=async p=>{try{return await this.bridge.send({type:"evaluate",browserId:this.opts.browserId,code:p})}catch{return null}};r("error.json",JSON.stringify({message:t.error.message,stack:t.error.stack,stepIndex:t.stepIndex,stepKind:t.stepKind,stepTarget:t.stepTarget,capturedAt:new Date().toISOString()},null,2));try{let h=(await this.bridge.send({type:"screenshot",browserId:this.opts.browserId})).replace(/^data:image\/png;base64,/,"");r("screenshot.png",Buffer.from(h,"base64"))}catch{}let i=await o(`(async () => {
|
|
80
|
-
const t = window.__sootsimTest
|
|
81
|
-
const mainShell = window.SootSim?.bridges?.mainShell
|
|
82
|
-
if (!t) return { error: 'no test bridge' }
|
|
83
|
-
let shell = null
|
|
84
|
-
try {
|
|
85
|
-
shell = typeof mainShell?.getState === 'function' ? await mainShell.getState() : null
|
|
86
|
-
} catch {}
|
|
87
|
-
const all = await t.queryAll({ pruneHidden: true })
|
|
88
|
-
return { shell, nodes: all, url: location.href, title: document.title }
|
|
89
|
-
})()`);i&&r("describe.json",JSON.stringify(i,null,2));let n=await o("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof n=="string"&&r("a11y.txt",n);let l=await o("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof l=="string"&&r("tree.txt",l);let a=await o(`(() => {
|
|
90
|
-
const c = window.__sootsimConsole
|
|
91
|
-
return {
|
|
92
|
-
errors: c?.getErrors?.() ?? [],
|
|
93
|
-
warnings: c?.getWarnings?.() ?? [],
|
|
94
|
-
requests: (window.__sootsimGetFailedRequests?.() ?? []),
|
|
95
|
-
}
|
|
96
|
-
})()`);return a&&r("console.json",JSON.stringify(a,null,2)),e}async swipe(e="UP",t=300){let r=U/2,o=E/2,i=200,n=r,l=o,a=r,p=o;switch(e.toUpperCase()){case"UP":l+=i,p-=i;break;case"DOWN":l-=i,p+=i;break;case"LEFT":n+=i,a-=i;break;case"RIGHT":n-=i,a+=i;break}let h=Math.max(10,Math.round(t/16));await this.drag(n,l,a,p,h,16)}async drag(e,t,r,o,i=12,n=16){if(!(await this.evaluate(`(async () => {
|
|
97
|
-
const interact = window.__sootsimInteract
|
|
98
|
-
if (!interact?.drag) return { ok: false }
|
|
99
|
-
const value = await interact.drag(${e}, ${t}, ${r}, ${o}, ${Math.max(1,Math.round(i))}, ${Math.max(0,Math.round(n))})
|
|
100
|
-
return { ok: !!value, value }
|
|
101
|
-
})()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,r=300){let o=Y(e),i=Y(t),n=Math.max(10,Math.round(r/16));await this.drag(o.x,o.y,i.x,i.y,n,16)}async swipeFrom(e,t="UP",r=300){let o=await this.findElement(e);if(!o)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let i=o.absolutePosition.x+o.layout.width/2,n=o.absolutePosition.y+o.layout.height/2,l=180,a=i,p=n;switch(t.toUpperCase()){case"UP":p-=l;break;case"DOWN":p+=l;break;case"LEFT":a-=l;break;case"RIGHT":a+=l;break}let h=Math.max(10,Math.round(r/16));await this.drag(i,n,a,p,h,16)}async scrollTo(e,t,r){let o=await this.callTest("scrollTo",e,t,r,!1);if(!o?.ok)throw new Error(`scrollTo failed: ${o?.reason||"unknown error"}`);await f(250)}async pinch(e){let t=await this.evaluate(`(async () => {
|
|
102
|
-
const interact = window.__sootsimInteract
|
|
103
|
-
if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
|
|
104
|
-
const ok = await interact.pinch(
|
|
105
|
-
${e.from[0]}, ${e.from[1]}, ${e.from[2]}, ${e.from[3]},
|
|
106
|
-
${e.to[0]}, ${e.to[1]}, ${e.to[2]}, ${e.to[3]},
|
|
107
|
-
${e.steps||12}, ${e.stepMs||16}
|
|
108
|
-
)
|
|
109
|
-
return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
|
|
110
|
-
})()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"unknown error"}`);await f(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",browserId:this.opts.browserId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){await f(e)}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),r=e.direction?.toUpperCase()||"DOWN",o=r==="DOWN"?"UP":r==="UP"?"DOWN":r;for(;Date.now()<t;){let i=await this.findElement({text:e.element});if(i&&i.absolutePosition.y>=0&&i.absolutePosition.y+i.layout.height>0&&i.absolutePosition.y<E-50){if(e.centerElement){let n=E/2,l=i.absolutePosition.y-n;if(Math.abs(l)>100){let a=Math.min(150,Math.abs(l)*.5),p=l>0?n-a:n+a;await this.drag(U/2,n,U/2,p,10,16)}}return}await this.swipe(o,250),await f(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+(e.timeout||V);for(;Date.now()<t;){let r=e.visible?!!await this.findElement(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,o=e.notVisible?!await this.findElement(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(r&&o)return;await f(200)}throw new Error("extendedWaitUntil timed out")}async launchApp(e){await this.refreshBrowserId();let t=!!(e&&typeof e=="object"&&e.clearState);if(t&&await this.evaluate(`(async () => {
|
|
111
|
-
await (${B})
|
|
112
|
-
try {
|
|
113
|
-
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
114
|
-
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
115
|
-
} catch {}
|
|
116
|
-
})()`),!this.firstLaunchDone&&!t)this.firstLaunchDone=!0,await this.waitForTree(3e4);else if(this.firstLaunchDone=!0,await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshBrowserId(),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(r){console.warn(` warn: onAfterLaunch hook threw: ${r instanceof Error?r.message:r}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
|
|
117
|
-
requestAnimationFrame(() => {
|
|
118
|
-
requestAnimationFrame(() => {
|
|
119
|
-
requestAnimationFrame(() => {
|
|
120
|
-
setTimeout(resolve, 180)
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
})
|
|
124
|
-
})`)}catch{await f(180)}}async startProfile(){await this.evaluate(`((sessionKey) => {
|
|
125
|
-
const host = window.__sootsimRenderHost
|
|
126
|
-
if (host?.startPerfSession) {
|
|
127
|
-
host.startPerfSession(sessionKey)
|
|
128
|
-
window[sessionKey] = {
|
|
129
|
-
active: true,
|
|
130
|
-
mode: 'render-worker',
|
|
131
|
-
startedAt: performance.now(),
|
|
132
|
-
}
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const perf = window.__sootsimPerf
|
|
137
|
-
const a11y = window.__sootsimA11y
|
|
138
|
-
perf?.enableFrameStats?.()
|
|
139
|
-
perf?.resetFrameStats?.()
|
|
140
|
-
a11y?.resetProfile?.()
|
|
141
|
-
window[sessionKey] = {
|
|
142
|
-
active: true,
|
|
143
|
-
mode: 'main-thread',
|
|
144
|
-
startedAt: performance.now(),
|
|
145
|
-
}
|
|
146
|
-
})(${JSON.stringify(Se)})`),this.profilingEnabled=!0}async stopProfile(){let e=await this.evaluate(`(async (sessionKey) => {
|
|
147
|
-
const host = window.__sootsimRenderHost
|
|
148
|
-
if (host?.stopPerfSession) {
|
|
149
|
-
const stopped = await host.stopPerfSession(sessionKey)
|
|
150
|
-
if (!stopped || !Array.isArray(stopped.samples)) {
|
|
151
|
-
return { error: 'no render-worker perf samples available' }
|
|
152
|
-
}
|
|
153
|
-
const samples = stopped.samples
|
|
154
|
-
const frameTimes = samples.map((sample) => Number(sample?.[1]) || 0).filter((value) => value > 0)
|
|
155
|
-
const sorted = [...frameTimes].sort((a, b) => a - b)
|
|
156
|
-
const worstFrames = samples
|
|
157
|
-
.slice()
|
|
158
|
-
.sort((a, b) => (Number(b?.[1]) || 0) - (Number(a?.[1]) || 0))
|
|
159
|
-
.slice(0, 10)
|
|
160
|
-
.map((sample) => [
|
|
161
|
-
Number(sample?.[0]) || 0,
|
|
162
|
-
Number(sample?.[1]) || 0,
|
|
163
|
-
Number(sample?.[2]) || 0,
|
|
164
|
-
Number(sample?.[3]) || 0,
|
|
165
|
-
Number(sample?.[4]) || 0,
|
|
166
|
-
])
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
mode: 'render-worker',
|
|
170
|
-
frames: Number(stopped.frameCount) || frameTimes.length,
|
|
171
|
-
totalMs: Number(stopped.totalMs) || frameTimes.reduce((sum, value) => sum + value, 0),
|
|
172
|
-
avgMs: Number(stopped.avgMs) || (frameTimes.length ? frameTimes.reduce((sum, value) => sum + value, 0) / frameTimes.length : 0),
|
|
173
|
-
maxMs: Number(stopped.maxMs) || (sorted[sorted.length - 1] || 0),
|
|
174
|
-
layoutTotalMs: Number(stopped.layoutTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[2]) || 0), 0),
|
|
175
|
-
renderTotalMs: Number(stopped.renderTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[3]) || 0), 0),
|
|
176
|
-
copyTotalMs: Number(stopped.copyTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[4]) || 0), 0),
|
|
177
|
-
layoutAvgMs: Number(stopped.layoutAvgMs) || 0,
|
|
178
|
-
renderAvgMs: Number(stopped.renderAvgMs) || 0,
|
|
179
|
-
copyAvgMs: Number(stopped.copyAvgMs) || 0,
|
|
180
|
-
p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
|
|
181
|
-
p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
|
|
182
|
-
p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
|
|
183
|
-
jankFrames: frameTimes.filter((value) => value > 16.67).length,
|
|
184
|
-
sampleCount: frameTimes.length,
|
|
185
|
-
worstFrames,
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const perf = window.__sootsimPerf
|
|
190
|
-
const a11y = window.__sootsimA11y
|
|
191
|
-
if (!perf && !a11y) return { error: 'no perf globals available' }
|
|
192
|
-
|
|
193
|
-
const frameStats = perf?.getFrameStats?.() || {}
|
|
194
|
-
const profile = a11y?.profile?.() || {}
|
|
195
|
-
const recent = Array.isArray(frameStats.recentFrames) ? frameStats.recentFrames : []
|
|
196
|
-
const sorted = [...recent].sort((a, b) => a - b)
|
|
197
|
-
perf?.disableFrameStats?.()
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
mode: 'main-thread',
|
|
201
|
-
frames: frameStats.frames || profile.syncCount || 0,
|
|
202
|
-
totalMs: frameStats.totalMs || 0,
|
|
203
|
-
avgMs: frameStats.totalMs && frameStats.frames ? frameStats.totalMs / frameStats.frames : profile.avgSyncMs || 0,
|
|
204
|
-
maxMs: frameStats.maxMs || profile.maxSyncMs || 0,
|
|
205
|
-
layoutTotalMs: frameStats.layoutTotalMs || 0,
|
|
206
|
-
p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
|
|
207
|
-
p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
|
|
208
|
-
p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
|
|
209
|
-
jankFrames: recent.filter((value) => value > 16.67).length,
|
|
210
|
-
sampleCount: recent.length,
|
|
211
|
-
worstFrames: recent.slice().sort((a, b) => b - a).slice(0, 10),
|
|
212
|
-
}
|
|
213
|
-
})(${JSON.stringify(Se)})`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.evaluate(`(async () => {
|
|
214
|
-
try { await (${B}) } catch {}
|
|
215
|
-
try {
|
|
216
|
-
const regs = await navigator.serviceWorker?.getRegistrations?.()
|
|
217
|
-
await Promise.all((regs || []).map((reg) => reg.unregister()))
|
|
218
|
-
} catch {}
|
|
219
|
-
})()`)}async clearState(){await this.evaluate(`(async () => {
|
|
220
|
-
await (${B})
|
|
221
|
-
})()`)}clearKeychain(){console.warn("[flow] clearKeychain: sootsim has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,r=await this.findElement(t);if(!r)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let o=r.text??r.testID??"";X.set(Ce,o),console.log(`[flow] copied text: ${JSON.stringify(o)}`)}async evalScript(e){let r=await this.evaluate(`(async () => {
|
|
222
|
-
try {
|
|
223
|
-
return { ok: true, value: await (async () => { ${e} })() }
|
|
224
|
-
} catch (err) {
|
|
225
|
-
return { ok: false, error: err && err.message ? err.message : String(err) }
|
|
226
|
-
}
|
|
227
|
-
})()`);if(!r.ok)throw new Error(`evalScript failed: ${r.error}`);r.value!==void 0&&console.log("[flow] evalScript ->",r.value)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(t)}`),await f(300),await this.refreshBrowserId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()==="ios":e.true!==void 0?e.true.toLowerCase()!=="false":!0}isOptional(e){if(e.optional===!0)return!0;let r=Object.entries(e).find(([i])=>i!=="when"&&i!=="optional"),o=r?r[1]:void 0;return!!(o&&typeof o=="object"&&"optional"in o&&o.optional)}async runStep(e,t){let r=Object.keys(e).find(o=>o!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${t+1}: ${r}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let o=!!(e.extendedWaitUntil||e.waitFor||e.launchApp||e.runFlow),i=1e4,n=this.runStepInner(e);if(o)await n;else{let a=null,p=new Promise((h,b)=>{a=setTimeout(()=>{b(new Error(`step watchdog: ${r} made no progress in ${i}ms \u2014 bridge or bundle probably hung`))},i)});try{await Promise.race([n,p])}finally{a&&clearTimeout(a)}}let l=!!(e.assertVisible||e.assertNotVisible||e.extendedWaitUntil||e.waitFor);this.stepDelay>0&&!l&&await f(this.stepDelay)}catch(o){if(this.isOptional(e)){console.log(`[flow] (optional, skipped: ${o.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:r,target:e[r]},o}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else if(e.takeScreenshot)await this.takeScreenshot(e.takeScreenshot);else if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo)await this.scrollTo(e.scrollTo.id,e.scrollTo.x,e.scrollTo.y);else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd)await this.waitForAnimationToEnd(typeof e.waitForAnimationToEnd=="number"?e.waitForAnimationToEnd:2e3);else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await f(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat)for(let t=0;t<e.repeat.times;t++)for(let r=0;r<e.repeat.commands.length;r++)await this.runStep(e.repeat.commands[r],r);else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")await this.evalScript(e.evalScript);else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,r=typeof t=="string"?t:t.file,o=typeof t=="string"?void 0:t.when;if(o&&!await this.evaluateWhen(o)){console.log(`[flow] runFlow skipped (when predicate false): ${r}`);return}let i=w.resolve(this.opts.flowDir,r),n=m.readFileSync(i,"utf8"),l=this.opts.flowDir;this.opts.flowDir=w.dirname(i),await this.runFlow(Re(n)),this.opts.flowDir=l}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let t=[],r=[],o=[];for(let n of e){let l=Object.keys(n);if(l.length===1&&l[0]==="onFlowStart"&&Array.isArray(n.onFlowStart)){t.push(...n.onFlowStart);continue}if(l.length===1&&l[0]==="onFlowComplete"&&Array.isArray(n.onFlowComplete)){r.push(...n.onFlowComplete);continue}o.push(n)}if(t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let n=0;n<t.length;n++)await this.runStep(t[n],n)}let i=null;try{await this.runFlowBody(o)}catch(n){i=n instanceof Error?n:new Error(String(n))}if(r.length>0){console.log(`[flow] onFlowComplete (${r.length} steps)`);for(let n=0;n<r.length;n++)try{await this.runStep(r[n],n)}catch(l){console.warn(`[flow] onFlowComplete step ${n+1} failed: ${l instanceof Error?l.message:l}`)}}if(i)throw i}async runFlowBody(e){for(let t=0;t<e.length;t++){let r=e[t],o=typeof r.wait=="number"?r.wait:0,i=typeof r.waitFor?.timeout=="number"?r.waitFor.timeout:0,n=Math.max(6e4,o+15e3,i+15e3);if(r.runFlow){await this.runStep(r,t);continue}await Promise.race([this.runStep(r,t),new Promise((l,a)=>setTimeout(()=>a(new Error(`step ${t+1} (${Object.keys(r)[0]}) exceeded ${n}ms deadline`)),n))])}}};function $e(s){let e={},t=s,r=s.match(/^---\n([\s\S]*?)\n---\n?/);if(r){try{e=A.parse(r[1])??{}}catch(n){console.warn(` warn: could not parse frontmatter: ${n.message}`)}t=s.slice(r[0].length);let i=A.parse(t);return{frontmatter:e,steps:Array.isArray(i)?i:[]}}if(/\n---\s*\n/.test(s))try{let i=A.parseAllDocuments(s);if(i.length>=2){let n=i[0].toJS(),l=i[i.length-1].toJS();return{frontmatter:n&&typeof n=="object"?n:{},steps:Array.isArray(l)?l:[]}}}catch(i){console.warn(` warn: could not parse multi-doc flow: ${i.message}`)}let o=A.parse(t);return{frontmatter:e,steps:Array.isArray(o)?o:[]}}async function Be(){let s=await he(),e=s.find(r=>r.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=s[0];return t?`http://localhost:${t.port}/__soot/`:null}async function ke(s){(s.length===0||s.includes("--help")||s.includes("-h"))&&(console.log(`
|
|
228
|
-
sootsim flow \u2014 run flows or manage a draft session
|
|
229
|
-
|
|
230
|
-
usage:
|
|
231
|
-
sootsim flow <flow.yaml> [options]
|
|
232
|
-
sootsim flow start
|
|
233
|
-
sootsim flow keep
|
|
234
|
-
sootsim flow end [--output <path>] [--validate] [--video]
|
|
235
|
-
sootsim flow validate <path>
|
|
236
|
-
|
|
237
|
-
options:
|
|
238
|
-
--record record a webm artifact while the flow runs
|
|
239
|
-
--profile capture perf stats while the flow runs
|
|
240
|
-
--out <dir> output directory (default: /tmp/sootsim-recordings)
|
|
241
|
-
--device <model> override the flow frontmatter device for this run
|
|
242
|
-
--slow <ms> delay between steps for natural pacing
|
|
243
|
-
--tail-wait <ms> hold the recording open after the last step so the
|
|
244
|
-
final UI state is captured (default 2000ms when --record
|
|
245
|
-
is on, 0 otherwise)
|
|
246
|
-
--url <url> load this target before running the flow
|
|
247
|
-
--screenshot-paths <mode>
|
|
248
|
-
screenshot path mode: dir (default) or flow
|
|
249
|
-
--replace <m>=<f> replace a Metro module with a local file for this run
|
|
250
|
-
--new open a fresh session before running the flow
|
|
251
|
-
--driver <id> when paired with --new, launch through a specific
|
|
252
|
-
driver from the registry (e.g. playwright for
|
|
253
|
-
hermetic CI runs); see 'sootsim list --drivers'
|
|
254
|
-
--headless pass headless=true to the launch driver (useful
|
|
255
|
-
with --driver playwright)
|
|
256
|
-
--electron prefer opening the target in the desktop companion
|
|
257
|
-
--session <id> target a specific current session
|
|
258
|
-
--validate replay the drafted flow before clearing it
|
|
259
|
-
--video replay and record the drafted flow before clearing it
|
|
260
|
-
|
|
261
|
-
frontmatter (top of flow.yaml between --- markers):
|
|
262
|
-
app: 8081 load this target before the flow starts
|
|
263
|
-
device: iphone-14 set the live device model for this flow run
|
|
264
|
-
electron: true prefer the desktop companion session for this flow
|
|
265
|
-
|
|
266
|
-
default runtime:
|
|
267
|
-
bridge-backed flow playback against the current sootsim session
|
|
268
|
-
if no current session exists, flow opens the discovered target first
|
|
269
|
-
recording and profiling both run on the same bridge-backed path
|
|
270
|
-
|
|
271
|
-
examples:
|
|
272
|
-
sootsim flow login.yaml
|
|
273
|
-
sootsim flow demo.yaml --url 8081 --record --slow 500 --out ./recordings
|
|
274
|
-
sootsim flow demo.yaml --session tab-2
|
|
275
|
-
sootsim flow start
|
|
276
|
-
sootsim flow keep
|
|
277
|
-
sootsim flow end --output ./flows/draft.yaml
|
|
278
|
-
sootsim flow end --output ./flows/draft.yaml --validate
|
|
279
|
-
sootsim flow end --output ./flows/draft.yaml --video
|
|
280
|
-
sootsim flow validate ./flows/draft.yaml
|
|
281
|
-
|
|
282
|
-
flow extension:
|
|
283
|
-
takeScreenshot: hero
|
|
284
|
-
takeScreenshot:
|
|
285
|
-
path: marketing/hero
|
|
286
|
-
withFrame: true
|
|
287
|
-
`),process.exit(0));let e=s[0];$.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=d=>s.find((c,v)=>s[v-1]===d),r=s.includes("--profile"),o=s.includes("--new"),i=t("--out")||"/tmp/sootsim-recordings",n=t("--screenshots")||"/tmp/sootsim-flow",l=t("--screenshot-paths")==="flow"?"flow":"dir",a=t("--device")?.trim()||"",p=s.includes("--slow")?+(t("--slow")||"500"):0,h=s.includes("--electron"),b=s.includes("--preview"),j=await ve(t("--preview-origin")),Me=s.includes("--preview-open"),Ae=s.flatMap((d,c)=>s[c-1]==="--replace"?["--replace",d]:[]),F=s.includes("--record")||b,Z=s.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):F?2e3:0,Pe=$.readFileSync(e,"utf8"),{frontmatter:k,steps:P}=$e(Pe);P.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let I=a||k.device||"",O=h||k.electron===!0,L=k.app===void 0||k.app===null?"":typeof k.app=="number"?String(k.app):k.app,Q={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--screenshots","--screenshot-paths","--preview-origin","--driver"]},S=z(s,Q),Ee=t("--url")||"";O&&!pe()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let ee=O?"desktop companion":"bridge",Ie=L?` | target: ${L}`:"";console.log(`
|
|
288
|
-
sootsim flow \u2014 ${g.basename(e)}
|
|
289
|
-
${P.length} steps | ${ee}${Ie}${F?" | recording":""}${r?" | profiling":""}${p?` | ${p}ms delay`:""}
|
|
290
|
-
`),b&&ye({event:"preview_flow_started",properties:{flowName:g.basename(e),stepCount:P.length,mode:ee,electron:O,record:F,profile:r,previewOrigin:j}});let x=Ee||L||"",K=o||O&&S.browserIdSource!=="flag",te=!1;if(!x&&!K&&S.browserIdSource==="none"){let d=le(S);try{let c=await d.listBrowsers(),v=c.find(R=>R.isPrimary&&R.readyState==="open"),N=c.find(R=>R.readyState==="open"),se=v??N;se&&(te=!0,console.log(` reusing active session: ${se.id}`))}catch{}finally{d.close()}}if(!x&&!te&&(K||S.browserIdSource==="none")){let d=await Be();d||(console.error(" error: no current session and no sootsim target found"),await q(),process.exit(1)),x=d}if(x&&I){let d=new URL(await we(x));d.searchParams.set("device",I),x=d.toString()}if(x){let d=[x];d.push(...Ae),K&&d.push("--new"),S.browserIdSource==="flag"&&S.browserId&&d.push("--session",S.browserId);let c=t("--driver");c&&d.push("--driver",c),s.includes("--headless")&&d.push("--headless"),await me(d,{port:S.wsPort,timeoutMs:S.commandTimeoutMs})}let _=z(s,Q),re=_.browserIdSource==="flag"?_.browserId:ie()||_.browserId,T=ae(_.wsPort,{commandTimeoutMs:_.commandTimeoutMs,browserId:re,fallbackOnMissingBrowserId:!1}),u,oe=async()=>{if(!I)return!1;let d=await T.send({type:"evaluate",browserId:u.browserId,code:"window.location.href"});if(typeof d=="string"&&d.length>0){let c=new URL(d);c.searchParams.set("device",I),u.setBrowserRouteHint(c.toString())}return!!await T.send({type:"call",browserId:u.browserId,path:"SootSim.bridges.settings.set",args:["deviceModel",I]})};u=new W(T,{screenshotDir:n,flowDir:g.dirname(g.resolve(e)),screenshotPathMode:l,browserId:re,recordingOutputDir:F?i:void 0,billingOriginOverride:b?j:void 0,onAfterLaunch:async()=>{await oe()&&await u.waitForTree(12e4),b&&await T.send({type:"evaluate",browserId:u.browserId,code:`(() => {
|
|
291
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
292
|
-
return r?.start?.() ?? false
|
|
293
|
-
})()`})}}),p&&(u.stepDelay=p);let M=null,y=null,C=null,J=null,D=0,_e=!!P[0]?.launchApp;try{await u.waitForTree(12e4),await oe()&&await u.waitForTree(12e4),F&&(_e?u.prepareRecording():await u.startRecording()),r&&await u.startProfile(),b&&(await T.send({type:"evaluate",browserId:u.browserId,code:`(() => {
|
|
294
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
295
|
-
return r?.start?.() ?? false
|
|
296
|
-
})()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await u.runFlow(P),r&&(M=await u.stopProfile()),F&&Z>0&&await new Promise(c=>setTimeout(c,Z)),F&&(y=await u.stopRecording(),C=u.getLastRecordingDurationMs()),b&&(J=await T.send({type:"evaluate",browserId:u.browserId,code:`(() => {
|
|
297
|
-
const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
|
|
298
|
-
return r?.stop?.() ?? []
|
|
299
|
-
})()`}),console.log(` captured ${J.length} replay events`)),console.log(`
|
|
300
|
-
+ completed (${P.length} steps)`),M&&xe(M),y&&console.log(` video: ${y}`),console.log()}catch(d){if(r&&!M)try{M=await u.stopProfile()}catch{}if(F&&!y)try{y=await u.stopRecording(),C=u.getLastRecordingDurationMs()}catch(c){console.warn(` recording stop failed: ${c?.message||String(c)}`)}console.error(`
|
|
301
|
-
x failed: ${d.message}
|
|
302
|
-
`),M&&(console.log(" partial profile:"),xe(M)),y&&console.log(` partial video: ${y}`);try{let c=u.lastFailedStep,v=c?`step-${String(c.index+1).padStart(2,"0")}-${c.kind}`:"unstaged",N=g.join(n,v);await u.captureFailureBundle(N,{error:d,stepIndex:c?.index,stepKind:c?.kind,stepTarget:c?.target}),console.log(` failure bundle: ${N}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(c){try{let v=g.join(n,"error.png");await u.captureFailureScreenshot(v),console.log(` error screenshot: ${v}`)}catch{}console.log(` (failure bundle capture failed: ${c instanceof Error?c.message:String(c)})`)}await ce(T,{errorsCommand:`sootsim get errors 5${u.browserId?` --session ${u.browserId}`:""}`,warningsCommand:`sootsim get warnings 5${u.browserId?` --session ${u.browserId}`:""}`,requestsCommand:`sootsim get requests 5${u.browserId?` --session ${u.browserId}`:""}`}),D=1}finally{T.close()}if(D===0&&b)try{let d=await Ve(J??[]),c=["--origin",j,"--events",d];y&&c.push("--video",y),y&&C&&Number.isFinite(C)&&c.push("--video-duration-ms",String(Math.round(C))),u.browserId&&c.push("--session",u.browserId),Me&&c.push("--open"),console.log(`
|
|
303
|
-
preparing preview upload\u2026`);let{runUpload:v}=await import("./upload-UPD2RSYF.js");await v(c,{})}catch(d){console.error(` preview upload failed: ${d?.message||d}`),D=1}return await q(),D}async function Ve(s){let{gzipSync:e}=await import("zlib"),t=s.map(i=>JSON.stringify(i)).join(`
|
|
304
|
-
`)+(s.length?`
|
|
305
|
-
`:""),r=e(Buffer.from(t,"utf8")),o=g.join(Te(),`sootsim-events-${Date.now()}.jsonl.gz`);return $.writeFileSync(o,r),console.log(` events: ${s.length} written to ${o} (${r.length} bytes gz)`),o}async function Ue(s){let e=s[0],t=r=>s.find((o,i)=>s[i-1]===r);switch(e){case"start":{let{path:r,state:o}=de();console.log(" flow draft started"),console.log(` session: ${r}`),console.log(` steps: ${o.steps.length}`);return}case"keep":case"good":{let r=ue();if(r.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!r.kept){console.log(" no pending action to keep");return}console.log(` kept: ${r.candidate.summary}`),console.log(` steps: ${r.stepCount}`);return}case"end":{let r=t("--output")||(s[1]&&!s[1].startsWith("-")?s[1]:void 0),o=s.includes("--validate")||s.includes("--video"),i=s.includes("--video"),n=fe(r||(o?je():void 0));if(n.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),o){let l=Le(s,n.outputPath),a=await ke(l);if(a!==0){console.error(`
|
|
306
|
-
validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=a;return}H(),console.log(` flow draft validated (${n.stepCount} step${n.stepCount===1?"":"s"})`),n.outputPath&&console.log(` saved: ${n.outputPath}`),i&&console.log(" video: recorded during validation run");return}if(H(),console.log(` flow draft ended (${n.stepCount} step${n.stepCount===1?"":"s"})`),n.outputPath){console.log(` saved: ${n.outputPath}`),console.log(` next: sootsim flow ${n.outputPath} --record`);return}console.log(""),process.stdout.write(n.yaml);return}case"validate":{let r=s[1];(!r||r.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let o=We(r);if(o.length>0){console.error(` x ${r} failed validation:`);for(let i of o)console.error(` - ${i}`);process.exit(1)}console.log(` + ${r} looks valid`);return}}}var Fe=new Set(["tapOn","inputText","pressKey","dispatchKey","hideKeyboard","swipe","pinch","scroll","scrollUntilVisible"]);function We(s){let e=[];if(!$.existsSync(s))return[`file not found: ${s}`];let t;try{t=$.readFileSync(s,"utf8")}catch(i){return[`cannot read file: ${i.message}`]}if(t.trim().length===0)return["file is empty"];let r;try{r=$e(t)}catch(i){return[`yaml parse error: ${i.message}`]}if(!Array.isArray(r.steps)||r.steps.length===0)return e.push("flow body must be a non-empty YAML array of steps"),e;let o=0;for(let i=0;i<r.steps.length;i++){let n=r.steps[i];n&&typeof n=="object"?Object.keys(n).some(a=>Fe.has(a))&&(o+=1):typeof n=="string"&&Fe.has(n)&&(o+=1)}return o===0&&e.push("no interaction steps found (expected at least one tapOn / inputText / pressKey / swipe / scroll)"),e}async function lt(s){let e=s[0];if(e==="start"||e==="keep"||e==="good"||e==="end"||e==="validate")return await Ue(s),0;let t=await ke(s);return t!==0&&(process.exitCode=t),t}function xe(s){let e=s.avgMs>0?(1e3/s.avgMs).toFixed(1):"?",t=s.sampleCount>0?(s.jankFrames/s.sampleCount*100).toFixed(1):"0";console.log(`
|
|
307
|
-
profile:`),console.log(` frames: ${s.frames}`),console.log(` total: ${s.totalMs.toFixed(1)}ms`),console.log(` avg: ${s.avgMs.toFixed(2)}ms (${e} fps)`),console.log(` max: ${s.maxMs.toFixed(2)}ms`),s.layoutAvgMs!==void 0&&console.log(` breakdown: layout ${s.layoutAvgMs.toFixed(2)}ms | render ${s.renderAvgMs?.toFixed(2)||"0.00"}ms | copy ${s.copyAvgMs?.toFixed(2)||"0.00"}ms`),console.log(` p95: ${s.p95.toFixed(2)}ms`),console.log(` p99: ${s.p99.toFixed(2)}ms`),console.log(` jank: ${s.jankFrames}/${s.sampleCount} (${t}%) >16.67ms`);let r=Array.isArray(s.worstFrames)?s.worstFrames:[];if(r.length!==0){if(console.log(`
|
|
308
|
-
worst frames:`),s.mode==="render-worker"){console.log(" total layout render copy t+");for(let o of r){let[i,n,l,a,p]=o;console.log(` ${n.toFixed(2).padStart(7)} ${l.toFixed(2).padStart(7)} ${a.toFixed(2).padStart(7)} ${p.toFixed(2).padStart(7)} ${String(i).padStart(5)}`)}return}console.log(` ${r.map(o=>o.toFixed(2)).join(", ")}`)}}function je(){return g.join(Te(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Le(s,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let r=1;r<s.length;r++){let o=s[r];if(!(o==="--validate"||o==="--video")){if(o==="--output"){r+=1;continue}r===1&&!o.startsWith("-")||t.push(o)}}return!t.includes("--record")&&s.includes("--video")&&t.push("--record"),t}export{$e as a,Be as b,ke as c,lt as d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
var o="sootsimConfig";function e(n){return!!n&&Object.keys(n).length>0}function s(n){return n?e(n.modules)||e(n.turboModules)||e(n.env)||e(n.settings)||e(n.initialState):!1}function u(n,i){let t=new URL(n);return s(i)?t.searchParams.set(o,JSON.stringify(i)):t.searchParams.delete(o),t.toString()}var d="/node_modules/one/metro-entry.bundle?platform=ios&dev=true&minify=false",S="/index.bundle?platform=ios&dev=true&hot=true&minify=false";function r(n){return/^https?:\/\//i.test(n)}function a(n){return n.endsWith(".bundle")}function f(n){try{let i=r(n),t=new URL(n,"http://soot.local");return a(t.pathname)?(t.searchParams.has("dev")||t.searchParams.set("dev","true"),t.searchParams.has("minify")||t.searchParams.set("minify","false"),i?t.toString():`${t.pathname}${t.search}${t.hash}`):n}catch{return n}}export{u as a,d as b,S as c,f as d};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as x}from"./chunk-QQOBLF7O.js";import{a as P,d as C}from"./chunk-OAHMYSMD.js";import{exec as U}from"child_process";import D from"http";import _ from"net";import{promisify as k}from"util";var S=k(U),y=250,E=120;function T(e,o=E){return new Promise(s=>{let n=new _.Socket,r=!1,i=c=>{r||(r=!0,n.destroy(),s(c))};n.setTimeout(o),n.once("connect",()=>i(!0)),n.once("timeout",()=>i(!1)),n.once("error",()=>i(!1)),n.connect(e,"localhost")})}function m(e,o,s="GET",n=y,r={}){return new Promise(i=>{let c=D.request({hostname:"localhost",port:e,path:o,method:s,timeout:n,headers:r},t=>{let a="";t.on("data",u=>a+=u.toString()),t.on("end",()=>i({statusCode:t.statusCode||0,body:a}))});c.on("error",()=>i(null)),c.setTimeout(n,()=>{c.destroy(),i(null)}),c.end()})}var A=[8081,8082,8083,8084,8085,8086,3e3,3001,19e3].map(e=>({port:e,pid:0}));function g(e,o){return!(e<=0||e>=2e4||o.has(e)||e>=5170&&e<=5200)}async function M(e=[]){let o=new Set(e);try{let{stdout:s}=await S("lsof -iTCP -sTCP:LISTEN -P -n 2>/dev/null | grep -E '^(node|bun)'",{encoding:"utf8",timeout:2e3});if(s.trim()){let n=new Map;for(let r of s.trim().split(`
|
|
3
|
-
`)){let i=r.trim().split(/\s+/);if(i.length<9)continue;let c=Number(i[1]),a=i[8].match(/:(\d+)$/);if(!a)continue;let u=Number(a[1]);g(u,o)&&(n.has(u)||n.set(u,c))}if(n.size>0)return[...n.entries()].map(([r,i])=>({port:r,pid:i}))}}catch{}try{let{stdout:s}=await S(`ss -tlnp 2>/dev/null | grep -E '"(node|bun)"'`,{encoding:"utf8",timeout:2e3});if(s.trim()){let n=new Map;for(let r of s.trim().split(`
|
|
4
|
-
`)){let i=r.match(/:(\d+)\s/),c=r.match(/pid=(\d+)/);if(!i)continue;let t=Number(i[1]),a=c?Number(c[1]):0;g(t,o)&&(n.has(t)||n.set(t,a))}if(n.size>0)return[...n.entries()].map(([r,i])=>({port:r,pid:i}))}}catch{}return A.filter(s=>g(s.port,o))}var b=new Map;async function N(e){if(e<=0)return null;let o=b.get(e);if(o)return o;try{let{stdout:s}=await S(`lsof -p ${e} -a -d cwd -Fn 2>/dev/null`,{encoding:"utf8",timeout:1500});for(let n of s.split(`
|
|
5
|
-
`))if(n.startsWith("n")&&n.length>1){let r=n.slice(1).trim();if(r)return b.set(e,r),r}}catch{}return null}function R(e,o){return{port:e,framework:o,bundleUrl:d(e,`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()}}function d(e,o){let s=x.find(r=>r.preferredPort===e),n=s?.runtimeConfig?P(o,s.runtimeConfig):o;return C(n)}function $(e){return e.includes("/node_modules/one/metro-entry.bundle")}function p(e,o,s){if(!o)return e;try{let n=JSON.parse(o.body),r=n?.extra?.expoClient||n?.extra||{};r.name&&(e.projectName=r.name),r.ios?.bundleIdentifier&&(e.bundleId=r.ios.bundleIdentifier),e.framework==="metro"&&r.sdkVersion&&(e.framework="expo");let i=n?.launchAsset?.url;i&&!e.patched&&!$(e.bundleUrl)&&(e.bundleUrl=d(e.port,i));let c=r.iconUrl||r.ios?.iconUrl||r.icon||r.ios?.icon;if(c)if(e.iconPath=c,s)if(c.startsWith("http"))e.iconUrl=s(c);else{let t=c.replace(/^\.\//,"");e.iconUrl=s(`http://localhost:${e.port}/assets/${t}`)}else e.iconUrl=c.startsWith("http")?c:`http://localhost:${e.port}/assets/${c.replace(/^\.\//,"")}`}catch{}return e}var l=new Set,f=new Set;async function L(e,o){if(!await T(e))return null;let s="/node_modules/one/metro-entry.bundle?platform=ios&dev=true",[n,r,i,c,t]=await Promise.all([l.has(e)?Promise.resolve(null):m(e,"/__soot/"),m(e,"/status"),m(e,s,"HEAD"),m(e,"/","GET",y,{"expo-platform":"ios"}),f.has(e)?Promise.resolve(null):m(e,"/_expo/status")]);if(t&&t.statusCode===200?f.delete(e):f.has(e)||f.add(e),i&&i.statusCode>0&&i.statusCode<400)return l.add(e),p({port:e,framework:"one",bundleUrl:d(e,`http://localhost:${e}${s}&minify=false`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},c,o);if(r&&r.body.includes("packager-status:running"))return l.add(e),p(R(e,t&&t.statusCode===200?"expo":"metro"),c,o);if(c)try{let a=JSON.parse(c.body);if((a?.extra?.expoClient||{}).name){let w=a?.launchAsset?.url||`http://localhost:${e}/index.bundle?platform=ios&dev=true&hot=true&minify=false`;return l.add(e),p({port:e,framework:"one",bundleUrl:d(e,w),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now()},c,o)}}catch{}return n&&n.statusCode===200&&n.body.includes("sootsim-patched")?(l.delete(e),p({port:e,framework:"one",bundleUrl:d(e,`http://localhost:${e}/__soot/bundle.js`),hmrUrl:`ws://localhost:${e}/hot`,lastSeen:Date.now(),patched:!0},c,o)):(l.add(e),null)}function I(e){let o=e.projectName?.trim().toLowerCase();return!!(o==="soot"||o==="sootsim"||e.bundleId?.trim().toLowerCase()?.startsWith("dev.soot"))}var h=new Map,H=3e4,O=1500;function B(e){return!e||e.framework==="metro"||e.framework==="unknown"}function G(e){return e?d(e.port,e.bundleUrl)===e.bundleUrl:!0}function W(e,o,s=Date.now()){if(o===0||e.pid!==o||!G(e.result))return!1;let n=s-e.cachedAt;return!(e.result===null&&n>=H||B(e.result)&&n>=O)}async function Q(e={}){let o=await M(e.excludePorts),s=new Set(o.map(t=>t.port));for(let t of[...h.keys()])s.has(t)||h.delete(t);for(let t of[...l])s.has(t)||l.delete(t);for(let t of[...f])s.has(t)||f.delete(t);let n=[],r=[];for(let{port:t,pid:a}of o){let u=h.get(t);if(u&&W(u,a)){u.result&&n.push(u.result);continue}u&&u.pid!==a&&(l.delete(t),f.delete(t)),r.push({port:t,pid:a})}r.length>0&&(await Promise.all(r.map(a=>L(a.port,e.buildIconProxyUrl)))).forEach((a,u)=>{let{port:w,pid:v}=r[u];v!==0&&h.set(w,{pid:v,result:a,cachedAt:Date.now()}),a&&n.push(a)});let i=new Map;for(let{port:t,pid:a}of o)a>0&&i.set(t,a);await Promise.all(n.map(async t=>{let a=i.get(t.port);if(!a)return;t.pid=a;let u=await N(a);u&&(t.cwd=u)}));let c=new Set(i.values());for(let t of[...b.keys()])c.has(t)||b.delete(t);return n.filter(t=>!I(t))}export{Q as a};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{a as C}from"./chunk-WWDJCKMI.js";import{existsSync as i,readFileSync as _,writeFileSync as E}from"node:fs";import{homedir as D}from"node:os";import{dirname as L,join as s,resolve as R}from"node:path";var f=D();function b(e){let n=e;for(;;){if(i(s(n,"pnpm-workspace.yaml"))||i(s(n,"turbo.json"))||i(s(n,"nx.json"))||i(s(n,"lerna.json")))return n;let t=s(n,"package.json");if(i(t))try{if(JSON.parse(_(t,"utf8")).workspaces)return n}catch{}let r=L(n);if(r===n)return null;n=r}}function k(e,n){let t=b(process.cwd()),r=[t?R(t,e):null,R(process.cwd(),e),R(process.cwd(),n)].filter(o=>!!o);for(let o of r)if(i(o))return o;return r[0]??R(process.cwd(),e)}var x=()=>k("packages/sootsim-engine/scripts/expensify-web-proxy.ts","scripts/expensify-web-proxy.ts"),S={USE_NGROK:"true",NGROK_URL:"http://localhost:9000/",SECURE_NGROK_URL:"http://localhost:9000/"},A=s(f,"github/uniswap-interface"),K=s(A,"apps/mobile"),m=s(A,".env.defaults.local"),W="stored-in-.env.local",T="# sootsim demo env overrides",Y=s(A,"packages/uniswap/src/features/forceUpgrade/hooks/useForceUpgradeStatus.ts"),M=s(A,"apps/mobile/src/notification-service/data-sources/createForceUpgradeNotificationDataSource.ts"),N="SOOTSIM_DEMO_DISABLE_FORCE_UPGRADE";function y(e){if(!i(e))return{};let n={},t=_(e,"utf8");for(let r of t.split(/\r?\n/)){let o=r.trim();if(!o||o.startsWith("#"))continue;let d=o.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);if(!d)continue;let c=d[2].trim();(c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),n[d[1]]=c}return n}function O(e){if(!e)return!1;let n=e.trim();return!(!n||n.includes(W)||n==="TRADING_API_KEY"||n==="UNISWAP_API_KEY")}function v(e,n){for(let t of e)for(let r of n){let o=t[r];if(O(o))return o.trim()}}function U(){let e=y(m),n=y(s(A,"apps/web/.env")),t=[process.env,e,n],r={},o=[["AMPLITUDE_PROXY_URL_OVERRIDE",["REACT_APP_AMPLITUDE_PROXY_URL"]],["QUICKNODE_ENDPOINT_NAME",["REACT_APP_QUICKNODE_ENDPOINT_NAME"]],["QUICKNODE_ENDPOINT_TOKEN",["REACT_APP_QUICKNODE_ENDPOINT_TOKEN"]],["INFURA_KEY",["REACT_APP_INFURA_KEY"]],["STATSIG_API_KEY",["REACT_APP_STATSIG_API_KEY"]],["STATSIG_PROXY_URL_OVERRIDE",["REACT_APP_STATSIG_PROXY_URL"]],["WALLETCONNECT_PROJECT_ID",["REACT_APP_WALLET_CONNECT_PROJECT_ID"]],["WALLETCONNECT_PROJECT_ID_BETA",["REACT_APP_WALLET_CONNECT_PROJECT_ID"]],["WALLETCONNECT_PROJECT_ID_DEV",["REACT_APP_WALLET_CONNECT_PROJECT_ID"]],["TRADING_API_KEY",["REACT_APP_TRADING_API_KEY"]],["UNISWAP_API_KEY",[]]];for(let[c,u]of o){let p=v(t,[c,...u]);if(p){r[c]=p;for(let g of u)r[g]=p}}if(!(O(r.TRADING_API_KEY)&&O(r.UNISWAP_API_KEY))){let c=v(t,["GRAPHQL_URL_OVERRIDE","REACT_APP_AWS_API_ENDPOINT"])||"https://interface.gateway.uniswap.org/v1/graphql";r.API_BASE_URL_OVERRIDE="https://interface.gateway.uniswap.org",r.API_BASE_URL_V2_OVERRIDE="https://interface.gateway.uniswap.org/v2",r.GRAPHQL_URL_OVERRIDE=c,r.TRADING_API_URL_OVERRIDE="https://trading-api-labs.interface.gateway.uniswap.org",r.FOR_API_URL_OVERRIDE="https://for.interface.gateway.uniswap.org/v2/FOR.v1.FORService"}return r}function F(){let e=i(m)?_(m,"utf8"):"";if(e&&!e.includes(T))return;let n=U(),t=[T];for(let[r,o]of Object.entries(n).sort(([d],[c])=>d.localeCompare(c)))t.push(`${r}=${JSON.stringify(o)}`);t.push(""),E(m,`${t.join(`
|
|
3
|
-
`)}
|
|
4
|
-
`)}function G(){let e=`export function useForceUpgradeStatus(): ForceUpgradeStatus {
|
|
5
|
-
`,n=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
6
|
-
return 'not-required'
|
|
7
|
-
|
|
8
|
-
`,t=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
9
|
-
if (process.env.${N} === 'true') {
|
|
10
|
-
return 'not-required'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
`,r=` const getForceUpgradeStatus = (): ForceUpgradeStatus => {
|
|
14
|
-
`,o=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
15
|
-
return 'not-required'
|
|
16
|
-
|
|
17
|
-
`,d=` // sootsim demo: bypass the force-upgrade gate during local engine demos.
|
|
18
|
-
if (process.env.${N} === 'true') {
|
|
19
|
-
return 'not-required'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
`,c=(u,p,g,I)=>{let l=_(u,"utf8");if(!l.includes(g)){if(l.includes(I)){E(u,l.replace(I,g));return}if(!l.includes(p))throw new Error(`uniswap demo patch failed: expected snippet not found in ${u}`);E(u,l.replace(p,`${p}${g}`))}};c(Y,e,n,t),c(M,r,o,d)}var a=s(f,"github/eigen"),P=s(a,"keys.shared.json"),h=s(a,"metaflags.json"),w=s(a,"src/__generated__/.relay-complete");function V(){if(i(P))try{let e=JSON.parse(_(P,"utf8"));if(!e||typeof e!="object")return;let n=e.secure&&typeof e.secure=="object"?e.secure:void 0,t=e.public&&typeof e.public=="object"?e.public:void 0;return!n&&!t?void 0:{secure:n,public:t}}catch{return}}function j(){let e=process.env.SOOTSIM_ARTSY_EMAIL??process.env.MAESTRO_TEST_EMAIL,n=process.env.SOOTSIM_ARTSY_PASSWORD??process.env.MAESTRO_TEST_PASSWORD,t=V(),r={};if(e&&n&&(r.SOOTSIM_LAUNCH_ARGUMENTS=JSON.stringify({email:e,password:n,useMaestroInit:!0})),t&&(r.SOOTSIM_REACT_NATIVE_KEYS_JSON=JSON.stringify(t)),Object.keys(r).length!==0)return{env:r}}function J(){if(!i(a))return;let{execSync:e}=C("node:child_process"),n=s(a,".yarn/releases/yarn-4.10.3.cjs");if(i(n)){let r=_(n,"utf8"),o='["clone","-c core.autocrlf=false",';r.includes(o)&&E(n,r.replace(o,'["clone","-c","core.autocrlf=false",'))}if(i(s(a,"node_modules/.yarn-state.yml"))||e("yarn install",{cwd:a,stdio:"inherit",env:{...process.env,YARN_CHECKSUM_BEHAVIOR:"update"}}),!i(P)||!i(h))try{e("yarn setup:oss",{cwd:a,stdio:"inherit"})}catch{if(!i(P)||!i(h))throw new Error("artsy demo: setup:oss did not create keys/metaflags")}let t=s(a,"node_modules/react-native-launch-arguments/package.json");if(i(t)){let r=_(t,"utf8");r.includes('"dist/index.js"')&&E(t,r.replace('"dist/index.js"','"src/index.ts"'))}i(w)||(e("yarn relay",{cwd:a,stdio:"inherit"}),E(w,""))}var q=[{name:"bluesky",label:"Bluesky",dir:s(f,"github/bluesky"),preferredPort:8082,framework:"expo",command:e=>({cmd:`npx expo start --port ${e}`}),credentials:{envVars:["SOOTSIM_BLUESKY_PASSWORD"],known:{HANDLE:"natew.bsky.social"}}},{name:"3pc",label:"3PunchConvo",dir:s(f,"lightstrike-labs/three-punch-convo-app/apps/one"),preferredPort:8081,framework:"one",command:e=>({cmd:"npx one dev",env:{ONE_PORT:String(e)}})},{name:"uniswap",label:"Uniswap",dir:K,preferredPort:8085,framework:"expo",prepare:()=>{F(),G()},command:e=>({cmd:`npx expo start --clear --port ${e}`,env:U()})},{name:"takeout",label:"Takeout",dir:s(f,"takeout"),preferredPort:8086,framework:"one",command:e=>({cmd:"npx one dev",env:{ONE_PORT:String(e)}})},{name:"expensify",label:"Expensify",dir:s(f,"github/expensify"),preferredPort:8087,framework:"rock",runtimeConfig:{env:S},sidecars:[{name:"web-proxy",port:9e3,readyPath:"/api/Ping",command:()=>({cmd:`bun ${JSON.stringify(x())}`,env:S})}],command:e=>({cmd:`fnm exec --using=20.20.0 npx rock start --port ${e} --no-interactive`,env:S})},{name:"artsy",label:"Artsy",dir:a,preferredPort:8088,framework:"expo",runtimeConfig:j(),prepare:()=>{J()},command:e=>({cmd:`npx react-native start --port ${e}`}),credentials:{envVars:["SOOTSIM_ARTSY_EMAIL","SOOTSIM_ARTSY_PASSWORD"],note:"auto-login reuses Artsy\u2019s built-in Maestro launch-arguments hook"}}];export{q as a};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{execFileSync as g,spawn as h}from"child_process";import{existsSync as s,readdirSync as k}from"fs";import{dirname as f,join as u,resolve as a}from"path";import{fileURLToPath as v}from"url";var c;function p(){if(c!==void 0)return c;try{c=f(v(import.meta.resolve("sootsim-engine/package.json")))}catch{c=null}return c}var x="dev.sootsim.simulator";function D(){let n=p();if(!n)return null;let e=u(n,"dist-electron/main.cjs");if(!s(e))return null;let t=b(n);return t?{path:t,platform:process.platform,kind:"dev-electron",engineDir:n}:null}function I(){let n=p();return n?s(u(n,"src-electron/main.ts")):!1}function b(n){let e=n;for(let t=0;t<6;t++){let i=u(e,"node_modules/.bin/electron");if(s(i))return i;let o=f(e);if(o===e)break;e=o}return null}function C(){let n=p(),t=["/Applications/sootsim.app",a(process.env.HOME||"","Applications/sootsim.app"),...n?[a(n,"app/sootsim.app")]:[]].find(i=>s(i));if(t)return{path:t,platform:"darwin",kind:"mac-app"};try{let i=g("mdfind",[`kMDItemCFBundleIdentifier == "${x}"`],{encoding:"utf8",timeout:3e3}).trim();if(i)return{path:i.split(`
|
|
3
|
-
`)[0],platform:"darwin",kind:"mac-app"}}catch{}return null}function m(n){if(!s(n))return null;let e=k(n).filter(t=>t.startsWith("sootsim")&&t.endsWith(".AppImage")).sort().reverse()[0];return e?u(n,e):null}function w(){let n=p(),t=[a(process.env.HOME||"","Applications/sootsim.AppImage"),a(process.env.HOME||"",".local/bin/sootsim.AppImage"),"/opt/sootsim/sootsim.AppImage","/opt/sootsim/sootsim",...n?[a(n,"app/sootsim.AppImage"),a(n,"release/linux-unpacked/sootsim")]:[]].find(o=>s(o));if(t)return{path:t,platform:"linux",kind:t.endsWith(".AppImage")?"linux-appimage":"linux-binary"};let i=n?m(a(n,"app"))||m(a(n,"release")):null;return i?{path:i,platform:"linux",kind:"linux-appimage"}:null}function A(){let n=D();if(n)return n;if(I()){let e=p(),t=u(e,"dist-electron/main.cjs");return s(t)?console.error(` no node_modules/.bin/electron found near ${e}. run \`bun install\`.`):console.error(` dist-electron/main.cjs missing in ${e}.
|
|
4
|
-
run: bun run --cwd packages/sootsim-engine build:electron-main
|
|
5
|
-
(or keep it fresh with: bun run watch:sootsim:electron-main)`),null}return process.platform==="darwin"?C():process.platform==="linux"?w():null}async function d(n,e,t={}){let i=t.inheritStdio?["ignore","inherit","inherit"]:"ignore";await new Promise((o,r)=>{let l=h(n,e,{detached:!0,stdio:i});l.once("error",r),l.once("spawn",()=>{l.unref(),o()})})}async function O(n,e=A(),t={}){if(!e)return{launched:!1};let i=t.device?["--device",t.device]:[];if(e.kind==="mac-app"){let r=["-g","-a",e.path];return n&&r.push(n),i.length>0&&r.push("--args",...i),await d("open",r),{launched:!0,via:"mac-app",target:e.path}}if(e.kind==="dev-electron"){let r=["--no-sandbox",e.engineDir||p()];return n&&r.push(n),i.length>0&&r.push(...i),await d(e.path,r,{inheritStdio:!0}),{launched:!0,via:"dev-electron",target:e.path}}let o=[];return n&&o.push(n),i.length>0&&o.push(...i),await d(e.path,o),{launched:!0,via:e.kind,target:e.path}}export{A as a,O as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{chmodSync as m,existsSync as g,mkdirSync as A,readFileSync as k,rmSync as s,writeFileSync as y}from"node:fs";import{homedir as D,platform as w}from"node:os";import{dirname as l,join as n,resolve as p}from"node:path";var u=1,f="SOOTSIM_SHARED_AUTH_FILE",a="https://sootbean.com";function v(){let t=process.env[f];if(t?.trim())return l(p(t));let e=D();if(!e)throw new Error("could not determine home directory for sootsim auth storage");switch(w()){case"darwin":return n(e,"Library","Application Support","sootsim");case"win32":return n(process.env.APPDATA||n(e,"AppData","Roaming"),"sootsim");default:return n(process.env.XDG_CONFIG_HOME||n(e,".config"),"sootsim")}}function c(){let t=process.env[f];return t?.trim()?p(t):n(v(),"desktop-auth.json")}function h(t){if(!t||typeof t!="object")return null;let e=t;return typeof e.id!="string"||!e.id.trim()?null:{id:e.id.trim(),name:typeof e.name=="string"?e.name:void 0,email:typeof e.email=="string"?e.email:void 0,image:typeof e.image=="string"?e.image:void 0}}function O(t){if(!t||typeof t!="object")return null;let e=t;if(e.version!==u||typeof e.token!="string"||!e.token.trim())return null;let r=typeof e.origin=="string"&&e.origin.trim()?e.origin.trim():a,o=e.source==="cli"||e.source==="electron"||e.source==="browser"||e.source==="unknown"?e.source:"unknown",i=typeof e.updatedAt=="string"&&e.updatedAt?e.updatedAt:new Date().toISOString(),S=typeof e.validatedAt=="string"&&e.validatedAt?e.validatedAt:void 0;return{version:u,token:e.token.trim(),user:h(e.user),origin:r,source:o,updatedAt:i,validatedAt:S}}function x(){let t=c();if(!g(t))return null;try{let e=JSON.parse(k(t,"utf8")),r=O(e);return r||(s(t,{force:!0}),null)}catch{return s(t,{force:!0}),null}}function I(t){let e=c();A(l(e),{recursive:!0});let r={version:u,token:t.token.trim(),user:t.user?h(t.user):null,origin:t.origin?.trim()||a,source:t.source,updatedAt:t.updatedAt||new Date().toISOString(),validatedAt:t.validatedAt};y(e,JSON.stringify(r,null,2)+`
|
|
3
|
-
`);try{m(e,384)}catch{}return r}function d(){s(c(),{force:!0})}async function N(t){let e=x();if(!e?.token)return null;let r=t||e.origin||a;try{let o=await fetch(`${r.replace(/\/$/,"")}/api/auth/me`,{headers:{authorization:`Bearer ${e.token}`}});if(o.status===401)return d(),null;if(!o.ok)return e;let i=await o.json();return i.user?.id?I({token:e.token,user:i.user,origin:r,source:e.source,validatedAt:new Date().toISOString()}):(d(),null)}catch{return e}}export{x as a,I as b,d as c,N as d};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{d as p,e as g}from"./chunk-AUR2LTNX.js";import{a as l}from"./chunk-UKYK63H6.js";var a="https://sootbean.com";function d(e){let n=e.replace(/^\[|\]$/g,"").toLowerCase();return n==="localhost"||n.endsWith(".localhost")||n==="0.0.0.0"||n==="::1"||/^127(?:\.\d{1,3}){3}$/.test(n)}function f(e){let{currentOrigin:n,search:i="",explicitOrigin:s}=e;if(s)return s;let c=new URLSearchParams(i).get("sootbean");if(c)return c;try{let r=new URL(n);if(d(r.hostname)){if(r.port==="3000")return r.origin;let t=new URL(r.origin);return t.port="3000",t.origin}if(r.hostname==="sootbean.com"||r.hostname.endsWith(".sootbean.com"))return r.origin}catch{return a}return a}function h(){return typeof window>"u"?a:f({currentOrigin:window.location.origin,search:window.location.search,explicitOrigin:window.__sootsimSootbeanOrigin})}var u=h();function m(e,n){if(n)return n.replace(/\/$/,"");if(e.kind==="session"&&e.origin)return e.origin.replace(/\/$/,"");let i=l();return i?.origin?i.origin.replace(/\/$/,""):u.replace(/\/$/,"")}async function _(e,n={}){let i=p();i||(process.stderr.write(`
|
|
3
|
-
sootsim ${e} needs auth before it can check recording access.
|
|
4
|
-
|
|
5
|
-
pick one:
|
|
6
|
-
\u2022 run \`sootsim login\`
|
|
7
|
-
\u2022 set SOOTSIM_API_KEY=sk_sootsim_... (recommended for CI)
|
|
8
|
-
\u2022 save a personal key with \`sootsim keys use sk_sootsim_...\`
|
|
9
|
-
|
|
10
|
-
`),process.exit(1));let s=m(i,n.originOverride),o;try{o=await fetch(`${s}/api/sootsim/billing/subscription`,{headers:{authorization:g(i)}})}catch(t){process.stderr.write(`
|
|
11
|
-
sootsim ${e} couldn't verify recording access.
|
|
12
|
-
${t instanceof Error?t.message:String(t)}
|
|
13
|
-
|
|
14
|
-
`),process.exit(1)}if(o.status===401&&(process.stderr.write(`
|
|
15
|
-
sootsim ${e} couldn't verify recording access with the current auth against ${s}.
|
|
16
|
-
sign in again for that origin, or provide a valid SOOTSIM_API_KEY.
|
|
17
|
-
|
|
18
|
-
`),process.exit(1)),!o.ok){let t=await o.text().catch(()=>"");process.stderr.write(`
|
|
19
|
-
sootsim ${e} couldn't verify recording access (${o.status}).
|
|
20
|
-
${t||"unexpected billing response"}
|
|
21
|
-
|
|
22
|
-
`),process.exit(1)}let c=await o.json();if(c.entitlements?.desktopRecording===!0)return;let r=c.plan??"free";process.stderr.write(`
|
|
23
|
-
sootsim ${e} recording requires Personal, Team, or an active trial.
|
|
24
|
-
current plan: ${r}.
|
|
25
|
-
free keeps basic 3d mode; the trial unlocks the full Personal surface.
|
|
26
|
-
|
|
27
|
-
`),process.exit(1)}export{_ as a};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{c as m}from"./chunk-W7CYWXRZ.js";import{existsSync as S,mkdirSync as h,readFileSync as b,writeFileSync as H,rmSync as w}from"fs";import{tmpdir as d}from"os";import{dirname as v,join as p}from"path";var y=new Map;function i(e,r){y.set(e,r)}var a=1;function s(){return p(d(),`sootsim-cli-hints-${m()}.json`)}function l(){return p(d(),"sootsim-cli-hints-global.json")}function u(e){if(!S(e))return{version:a,shown:{}};try{let r=JSON.parse(b(e,"utf8"));return r?.version!==a||!r?.shown?{version:a,shown:{}}:r}catch{return{version:a,shown:{}}}}function f(e,r){try{h(v(e),{recursive:!0}),H(e,JSON.stringify(r)+`
|
|
3
|
-
`)}catch{}}function F(){let e=(process.env.SOOTSIM_HINTS||"").toLowerCase();return e==="off"||e==="0"||e==="false"?"off":e==="always"||e==="verbose"?"always":"normal"}function x(e,r){let o=F();if(o==="off")return!1;if(o==="always"||r==="always")return!0;let t=Date.now();if(r==="once-per-session"){let n=u(s());return n.shown[e]?!1:(n.shown[e]=t,f(s(),n),!0)}if(r==="once-ever"){let n=u(l());return n.shown[e]?!1:(n.shown[e]=t,f(l(),n),!0)}if(typeof r=="object"&&"cooldownMs"in r){let n=u(s()),c=n.shown[e]??0;return t-c<r.cooldownMs?!1:(n.shown[e]=t,f(s(),n),!0)}return!0}function M(e,...r){let o=y.get(e);if(!o)return process.env.SOOTSIM_HINTS_DEBUG&&console.error(` [hints] no hint registered for id "${e}"`),!1;if(!x(e,o.frequency))return!1;let t=o.render(...r);if(t==null)return!1;let n=Array.isArray(t)?t:[t],c=o.stream==="error"?console.error:console.log;for(let g of n)c(` hint: ${g}`);return!0}function O(){w(s(),{force:!0})}function k(){w(l(),{force:!0})}function T(){return Array.from(y.entries()).map(([e,r])=>({id:e,frequency:r.frequency}))}i("app-still-loading",{frequency:{cooldownMs:6e4},render:e=>`app may still be loading (${e} nodes). run \`sootsim wait ready\` first.`});i("wait-selector-for-missing-testid",{frequency:"once-per-session",render:e=>`sootsim wait selector ${e}`,stream:"error"});i("prefer-cli-over-eval",{frequency:"once-per-session",render:e=>e.length?["try the CLI shortcut instead:",...e.map(r=>` ${r}`)]:null,stream:"error"});i("describe-use-filters",{frequency:"once-per-session",render:()=>["describe output is long. narrow it with:"," sootsim describe --only '*Bottom Sheet*'"," sootsim describe --testid-like 'swap-*'"," sootsim describe --subtree <testID>"]});i("subtree-root-not-found",{frequency:"always",render:e=>`no node with testID/id "${e}" \u2014 try \`sootsim find --testid ${e}\` to discover available ids.`,stream:"error"});export{M as a,O as b,k as c,T as d};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{d as V,e as q}from"./chunk-AUR2LTNX.js";import{a as U}from"./chunk-UKYK63H6.js";import{a as W}from"./chunk-WVBPATRA.js";import{c as G,e as J,g as m}from"./chunk-C3QLIYCS.js";import{createHash as Pe}from"crypto";import{readFileSync as ee}from"fs";import{gzipSync as te}from"zlib";function Y(e){let t=(e||"").toLowerCase().split(";")[0].trim();return t?!(t.startsWith("image/")||t.startsWith("video/")||t.startsWith("audio/")||t==="font/woff2"||t==="application/font-woff2"||t==="application/zip"||t==="application/gzip"):!0}async function me(e){let t=await fetch(e.url,{method:"PUT",headers:{"content-type":e.contentType},body:e.bytes});if(!t.ok){let r=await t.text().catch(()=>"");throw new Error(`PUT ${t.status}: ${r.slice(0,200)}`)}}async function be(e,t=8,r){let s=0,o=0,l=e.length;await Promise.all(Array.from({length:Math.min(t,l)},async()=>{for(;s<l;){let a=e[s++];await me(a),o++,r?.(o,l)}}))}function we(e,t,r,s){let o=[];o.push({url:e.bundle.putUrl,contentType:e.bundle.contentType,bytes:t});for(let l of e.files){let a=r.get(l.urlhash);a&&o.push({url:l.putUrl,contentType:l.contentType,bytes:a})}return e.events&&s?.eventsBytes&&o.push({url:e.events.putUrl,contentType:e.events.contentType,bytes:s.eventsBytes}),e.flowVideo&&s?.videoBytes&&o.push({url:e.flowVideo.putUrl,contentType:e.flowVideo.contentType,bytes:s.videoBytes}),e.storage&&s?.storageBytes&&o.push({url:e.storage.putUrl,contentType:e.storage.contentType,bytes:s.storageBytes}),o}function ve(e){return e.replace(/\/+$/,"")}var $=class extends Error{constructor(r,s,o){super(r);this.status=s;this.phase=o;this.name="PresignedUploadError"}};async function Q(e){let t=ve(e.originBase),r={"content-type":"application/json"};e.authHeader&&(r.authorization=e.authHeader);let s=await fetch(`${t}/api/preview/upload/init`,{method:"POST",headers:r,body:JSON.stringify(e.initBody)});if(!s.ok){let h=await s.text().catch(()=>"");throw new $(`init failed: ${s.status} ${h.slice(0,200)}`,s.status,"init")}let o=await s.json(),l=we(o,e.bundleBytes,e.filesByHash,e.extras);await be(l,e.concurrency??8,e.onPutProgress);let a=await fetch(`${t}/api/preview/upload/finalize`,{method:"POST",headers:r,body:JSON.stringify({token:o.token})});if(!a.ok){let h=await a.text().catch(()=>"");throw new $(`finalize failed: ${a.status} ${h.slice(0,200)}`,a.status,"finalize")}let z=await a.json();return{init:o,finalize:z}}function Ie(){let e=process.env.SOOT_POSTHOG_API_KEY||process.env.VITE_POSTHOG_API_KEY||"";if(!e)return null;let t=process.env.SOOT_POSTHOG_HOST||process.env.VITE_POSTHOG_HOST||"https://us.i.posthog.com";return{apiKey:e,host:t.replace(/\/+$/,"")}}function Be(e){return e?e.userId?e.userId:e.installationId!=null?`install:${e.installationId}`:e.repoId?`repo:${e.repoId}`:e.shareId?`share:${e.shareId}`:"anonymous-cli":"anonymous-cli"}function xe(e){let t=e.identity??{},r={$lib:"soot-cli",source:t.source??"cli",...e.properties};return t.userId&&(r.userId=t.userId),t.repoId&&(r.repoId=t.repoId),t.installationId!=null&&(r.installationId=String(t.installationId)),t.shareId&&(r.shareId=t.shareId),t.plan&&(r.plan=t.plan),{event:e.event,distinct_id:Be(t),properties:r,timestamp:new Date().toISOString()}}var I=[],X=!1;async function L(){if(I.length===0)return;let e=Ie();if(!e){I.length=0;return}let t=I.splice(0,I.length).map(xe);try{await fetch(`${e.host}/batch/`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({api_key:e.apiKey,batch:t}),keepalive:!0})}catch{}}function Te(){X||(X=!0,process.on("beforeExit",()=>{L()}),process.on("exit",()=>{L()}))}function Z(e){Te();let t=null;try{t=U()?.user?.id??null}catch{t=null}I.push({...e,identity:{source:"cli",userId:t,...e.identity}})}async function b(){await L()}var oe=process.env.SOOTSIM_UPLOAD_ORIGIN||"https://sootbean.com",F="http://localhost:3000";async function Se(e){if(e)return e;if(process.env.SOOTSIM_UPLOAD_ORIGIN)return process.env.SOOTSIM_UPLOAD_ORIGIN;try{let t=await fetch(`${F}/api/preview/upload/init`,{method:"OPTIONS"});if(t.ok||t.status===204||t.status===405)return F}catch{}return oe}function Ue(){console.log(`
|
|
3
|
-
sootsim upload \u2014 publish the current bundle as a /preview/<id> link
|
|
4
|
-
|
|
5
|
-
usage:
|
|
6
|
-
sootsim upload [--origin <url>] [--events <path>] [--session <tab-id>] [--open] [--assets-only]
|
|
7
|
-
|
|
8
|
-
options:
|
|
9
|
-
--origin <url> upload target (default: auto)
|
|
10
|
-
prefers ${F} when available, otherwise
|
|
11
|
-
falls back to ${oe}
|
|
12
|
-
override with SOOTSIM_UPLOAD_ORIGIN env var
|
|
13
|
-
--events <path> path to a gzipped events .jsonl.gz file to attach
|
|
14
|
-
--video <path> path to a webm/mp4/gif flow recording. embedded inline
|
|
15
|
-
in the pr sticky comment served at
|
|
16
|
-
/api/preview/flow-video?id=<share-id>
|
|
17
|
-
--video-duration-ms <ms>
|
|
18
|
-
duration hint for attached flow video
|
|
19
|
-
--session <tab-id> target a specific sootsim tab (see: sootsim list)
|
|
20
|
-
--open open the resulting /preview/<id> url in the browser
|
|
21
|
-
--assets-only drop API/JSON/HTML records before upload; keep images,
|
|
22
|
-
fonts, css, js, and binary blobs. live-data demos hit
|
|
23
|
-
the real network at replay time instead of serving
|
|
24
|
-
recorded API snapshots
|
|
25
|
-
-h, --help
|
|
26
|
-
|
|
27
|
-
examples:
|
|
28
|
-
sootsim upload
|
|
29
|
-
sootsim upload --origin http://localhost:3000 --open
|
|
30
|
-
sootsim upload --events ./my-session.jsonl.gz
|
|
31
|
-
sootsim upload --video /tmp/soot-flow.webm
|
|
32
|
-
`)}function O(e,t){let r=e.findIndex(o=>o===t);if(r<0)return;let s=e[r+1];return e.splice(r,2),s}function ne(e,t){let r=e.findIndex(s=>s===t);return r<0?!1:(e.splice(r,1),!0)}function re(e){let t=(e||"").toLowerCase().split(";")[0].trim();return t?!!(t.startsWith("image/")||t.startsWith("font/")||t.startsWith("video/")||t.startsWith("audio/")||t.startsWith("model/")||t==="text/css"||t==="application/javascript"||t==="text/javascript"||t==="application/wasm"||t==="application/font-woff"||t==="application/font-woff2"||t==="application/octet-stream"):!1}async function se(e){let t=await fetch(e);if(!t.ok)throw new Error(`fetch ${e} -> ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}function $e(e){return/\.bundle($|\?)/.test(e)||/\.js($|\?)/.test(e)?"application/javascript":/\.zip($|\?)/.test(e)?"application/zip":"application/javascript"}function Oe(e){try{let t=new URL(e);return t.searchParams.get("lazy")==="true"?(t.searchParams.set("lazy","false"),t.toString()):e}catch{return e}}async function ze(e,t){let s=[];for(let o=0;o<t;o+=15e5){let l=Math.min(o+15e5,t),a=await m(e,`(window.__sootsimLastTransformedBundle?.text || "").slice(${o}, ${l})`);if(typeof a!="string")return null;s.push(a)}return s.join("")}async function Je(e,t){(e.includes("--help")||e.includes("-h"))&&(Ue(),process.exit(0));let r=[...e],s=await Se(O(r,"--origin")),o=O(r,"--events"),l=O(r,"--video"),a=O(r,"--video-duration-ms"),z=ne(r,"--open"),h=ne(r,"--assets-only"),ie=G(r,{stripBooleanFlags:[],stripValueFlags:[]}),y=J(ie),u,C=[],p=[],A=null;try{if(u=await m(y,'(typeof window.__sootsimCaptureBundle === "function") ? window.__sootsimCaptureBundle() : null'),u?.bundleUrl){let n=new URL(u.bundleUrl).origin;C=(await m(y,`(window.__sootsimPreviewRecorder?.list?.(${JSON.stringify(n)}) || [])`)).filter(w=>{try{return!new URL(w.url).pathname.startsWith("/api/")}catch{return!0}});let i=await m(y,`(() => {
|
|
33
|
-
const rec = window.__sootsimPreviewRecorder
|
|
34
|
-
if (!rec?.list) return null
|
|
35
|
-
const all = rec.list()
|
|
36
|
-
const cross = all.filter((e) => {
|
|
37
|
-
try { return new URL(e.url).origin !== ${JSON.stringify(n)} } catch { return false }
|
|
38
|
-
})
|
|
39
|
-
return {
|
|
40
|
-
count: cross.length,
|
|
41
|
-
totalBytes: cross.reduce((n, e) => n + (e.size || 0), 0),
|
|
42
|
-
}
|
|
43
|
-
})()`);if(i&&i.count>0&&(console.log(` ${i.count} recorded cross-origin responses (${(i.totalBytes/1024).toFixed(1)} KiB)`),p=await m(y,`(() => {
|
|
44
|
-
const rec = window.__sootsimPreviewRecorder
|
|
45
|
-
if (!rec?.dump) return []
|
|
46
|
-
const bundleUrl = ${JSON.stringify(u.bundleUrl)}
|
|
47
|
-
return rec.dump().filter((r) => {
|
|
48
|
-
try {
|
|
49
|
-
const u = new URL(r.url)
|
|
50
|
-
if (u.origin !== ${JSON.stringify(n)}) return true
|
|
51
|
-
// bundle-origin api responses came from the rewritten
|
|
52
|
-
// /__app-api proxy at record time (re-keyed by the
|
|
53
|
-
// recorder's unwrap step). they need bodies attached the
|
|
54
|
-
// same way as cross-origin records \u2014 direct re-fetch from
|
|
55
|
-
// the dev server lacks the bundle's session cookies.
|
|
56
|
-
if (r.url !== bundleUrl && u.pathname.startsWith('/api/')) return true
|
|
57
|
-
return false
|
|
58
|
-
} catch { return false }
|
|
59
|
-
})
|
|
60
|
-
})()`),h)){let w=p.length;p=p.filter(v=>re(v.contentType));let E=i.totalBytes-p.reduce((v,S)=>v+(S.size||0),0);console.log(` --assets-only: kept ${p.length}/${w} records (dropped ${(E/1024).toFixed(1)} KiB of API responses)`)}}u?.transformedBundle&&(A=await ze(y,u.transformedBundle.byteLength))}finally{y.close()}u||(console.error(" could not read bundle snapshot \u2014 is sootsim running and is the bundle loaded?"),process.exit(2)),u.bundleUrl||(console.error(` no ?bundle= URL on the current sootsim tab.
|
|
61
|
-
open the app you want to share first (e.g. sootsim open 8082), then run upload.`),process.exit(2));let c,R=!1;if(A!==null)c=new TextEncoder().encode(A),R=!0,console.log(` using post-transform bundle: ${(c.byteLength/1024).toFixed(1)} KiB`);else{let n=Oe(u.bundleUrl);n!==u.bundleUrl&&console.log(" forcing lazy=false for self-contained bundle"),console.log(` capturing: ${n}`),c=await se(n),console.log(` main bundle: ${(c.byteLength/1024).toFixed(1)} KiB`)}let B=C.filter(n=>n.url!==u.bundleUrl);h&&(B=B.filter(n=>re(n.contentType))),console.log(` fetching ${B.length} extra files\u2026`);let x=(await Promise.all(B.map(async n=>{try{let i=await se(n.url);return{...n,bytes:i}}catch(i){return console.error(` warning: failed to re-fetch ${n.url}: ${i instanceof Error?i.message:i}`),null}}))).filter(n=>!!n),ae=x.reduce((n,i)=>n+i.bytes.byteLength,0);console.log(` ${x.length} extra files: ${(ae/1024).toFixed(1)} KiB`);let g;o&&(g=ee(o));let f,T,N;if(l){if(f=ee(l),T=l.endsWith(".mp4")?"video/mp4":l.endsWith(".gif")?"image/gif":"video/webm",a){let n=Number(a);(!Number.isFinite(n)||n<=0)&&(console.error(` invalid --video-duration-ms: ${a}`),await b(),process.exit(1)),N=Math.round(n)}console.log(` attaching flow video: ${(f.byteLength/1024).toFixed(1)} KiB (${T})`)}let d=V(),le=U();Z({event:"preview_upload_started",identity:{userId:d?.kind==="session"?le?.user?.id??null:null,repoId:d?.kind==="github"?d.repoId:null,installationId:d?.kind==="github"?d.installationId??null:null},properties:{origin:s,hasAuth:!!d,authMode:d?.kind??"none",bundleBytes:c.byteLength,isTransformed:R,extraFiles:x.length,recordedFetches:p.length,hasEvents:!!g,hasVideo:!!f}}),d||(console.error(" preview uploads need auth."),console.error(" set SOOTSIM_API_KEY=sk_sootsim_..., run `sootsim login`, or use the soot github runner."),await b(),process.exit(1));let ue=q(d),de=(()=>{try{return new URL(u.bundleUrl).origin}catch{return null}})(),K=(n,i,w,E,v,S,he)=>{let D=Y(S),ye=D?te(n):n;return{url:i,urlhash:w,method:E,bodyHash:v,contentType:S,responseHeaders:he,bytes:ye,encoding:D?"gzip":void 0}},_=[...x.map(n=>K(n.bytes,n.url,n.urlhash,"GET","-",n.contentType,n.responseHeaders)),...p.map(n=>K(Buffer.from(n.bodyBase64,"base64"),n.url,n.urlhash,n.method||"GET",n.bodyHash||"-",n.contentType,n.responseHeaders))],H=te(c),ce=Pe("sha256").update(c).digest("hex");console.log(` bundle raw=${(c.byteLength/1024).toFixed(1)} KiB gz=${(H.byteLength/1024).toFixed(1)} KiB`);let pe={contentHash:ce,bundleSizeBytes:c.byteLength,bundleContentType:$e(u.bundleUrl),bundleEncoding:"gzip",bundleOrigin:de,entry:u.entry,isTransformed:R,deviceSpec:u.deviceSpec,installationId:d.kind==="github"?d.installationId??void 0:void 0,repoId:d.kind==="github"?d.repoId:void 0,files:_.map(n=>({url:n.url,urlhash:n.urlhash,method:n.method,bodyHash:n.bodyHash,contentType:n.contentType,responseHeaders:n.responseHeaders,encoding:n.encoding,sizeBytes:n.bytes.byteLength})),events:g?{sizeBytes:g.byteLength}:void 0,flowVideo:f&&T?{sizeBytes:f.byteLength,contentType:T,durationMs:N}:void 0},M=new Map;for(let n of _)M.set(n.urlhash,n.bytes);let fe=Date.now(),P=H.byteLength;for(let n of _)P+=n.bytes.byteLength;g&&(P+=g.byteLength),f&&(P+=f.byteLength);let ge=`${s.replace(/\/$/,"")}/api/preview/upload/init`;console.log(` init: ${ge}`);let k;try{let n=await Q({originBase:s,initBody:pe,bundleBytes:H,filesByHash:M,extras:{eventsBytes:g,videoBytes:f},authHeader:ue,concurrency:16});k=n.finalize;let i=1+n.init.files.length+(n.init.events?1:0)+(n.init.flowVideo?1:0);console.log(` PUT ${i} objects in ${Date.now()-fe}ms (${(P/1024).toFixed(1)} KiB)`)}catch(n){let i=n;i.phase==="init"&&i.status===401&&(console.error(" preview upload requires a valid login."),console.error(" run `sootsim login` and retry."),i.message&&console.error(` ${i.message}`),await b(),process.exit(1)),console.error(` ${i.phase??"upload"} failed: ${i.message??String(n)}`),await b(),process.exit(1)}let j=`${s.replace(/\/$/,"")}${k.url}`;console.log(`
|
|
62
|
-
stored ${k.filesStored??0} extra files`),console.log(` preview: ${j}`),z&&await W(j),await b()}export{Z as a,b,Se as c,Je as d};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import{existsSync as m,mkdirSync as A,readFileSync as w,readdirSync as x,rmSync as o,writeFileSync as _}from"fs";import{tmpdir as l}from"os";import{dirname as L,join as p,resolve as h}from"path";import{execFileSync as y}from"child_process";import{readFileSync as N}from"fs";import{createRequire as E}from"module";var s=null;function u(r){s||(s=O());try{return s(r)}catch{return null}}function O(){let r=Number(process.env.PPID);if(Number.isFinite(r)&&r>1&&r!==process.ppid)return()=>r;if(process.platform==="linux")return g();if(process.platform==="darwin"){let t=T();return t||P()}return()=>null}function g(){return r=>{try{let t=N(`/proc/${r}/stat`,"utf8"),e=t.lastIndexOf(")");if(e<0)return null;let i=t.slice(e+1).trim().split(/\s+/),n=Number(i[1]);return Number.isFinite(n)&&n>0?n:null}catch{return null}}}var C=3,a=216,D=16;function T(){if(!process.versions?.bun)return null;try{let r=E(import.meta.url),{dlopen:t,FFIType:e}=r("bun:ffi"),i=t("/usr/lib/libproc.dylib",{proc_pidinfo:{args:[e.i32,e.i32,e.u64,e.ptr,e.i32],returns:e.i32}}),n=Buffer.alloc(a);return b=>{if(Number(i.symbols.proc_pidinfo(b,C,0n,n,a))<=0)return null;let d=n.readUInt32LE(D);return d>0?d:null}}catch{return null}}function P(){return r=>{try{let e=y("lsof",["-R","-p",String(r),"-d","cwd","-a"],{encoding:"utf8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(`
|
|
3
|
-
`)[1];if(!e)return null;let i=e.trim().split(/\s+/),n=Number(i[2]);return Number.isFinite(n)&&n>1?n:null}catch{return null}}}var c=1,S="SOOTSIM_CLI_SESSION_PATH",v=["SOOTSIM_SESSION_ID","CLAUDE_CODE_SESSION_ID","CODEX_THREAD_ID","TERM_SESSION_ID","ITERM_SESSION_ID","TMUX_PANE","STY","KITTY_WINDOW_ID","WEZTERM_PANE","ALACRITTY_WINDOW_ID","WINDOWID","VSCODE_INJECTION"];function F(r,t=20){let e=u(r);if(!e||e<=1)return null;for(let i=0;i<t;i++){let n=u(e);if(!n||n<=1)return e;e=n}return e}function R(){for(let t of v){let e=process.env[t];if(e&&e.trim())return{key:`${t}:${e.trim()}`,source:t,stable:!0}}let r=F(process.ppid);return r&&r>1?{key:`gppid-${r}`,source:"grand-ppid",stable:!0}:{key:`pid-${process.ppid}`,source:"ppid",stable:!1}}var I=p(l(),"sootsim-legacy-gc-done");function j(){if(!m(I)){try{_(I,String(Date.now()))}catch{return}try{let r=l();for(let t of x(r))if(t.startsWith("sootsim-gppid-"))try{o(p(r,t),{force:!0})}catch{}}catch{}}}function k(){return R().key}function f(){if(process.env[S])return h(process.env[S]);let r=k();return p(l(),`sootsim-cli-session-${r}.json`)}function W(){let r=f();if(!m(r))return null;try{let t=JSON.parse(w(r,"utf8"));return t.version!==c||typeof t.browserId!="string"||!t.browserId.trim()||typeof t.updatedAt!="string"?(o(r,{force:!0}),null):{version:c,browserId:t.browserId.trim(),updatedAt:t.updatedAt}}catch{return o(r,{force:!0}),null}}function G(){return W()?.browserId||null}function X(r){let t=r.trim();if(!t)return;let e=f();A(L(e),{recursive:!0}),_(e,JSON.stringify({version:c,browserId:t,updatedAt:new Date().toISOString()},null,2)+`
|
|
4
|
-
`)}function Z(){o(f(),{force:!0})}export{R as a,j as b,k as c,G as d,X as e,Z as f};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! sootsim v0.0.4 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
-
import r from"fs";import{homedir as h}from"os";import o from"path";var L="SOOTSIM_HOME",v="active",k="daemon.json",E="config.json",I=3e4;function u(){let t=process.env[L];return t&&t.length>0?o.resolve(t):o.join(h(),".sootsim")}function s(){return o.join(u(),"runtimes")}function O(t){return o.join(s(),t)}function S(){return o.join(s(),v)}function A(){return o.join(u(),"electron")}function H(t){return o.join(A(),t)}function _(){return o.join(u(),"cache")}function m(){return o.join(u(),k)}function C(){return o.join(u(),E)}function b(){r.mkdirSync(u(),{recursive:!0}),r.mkdirSync(s(),{recursive:!0}),r.mkdirSync(_(),{recursive:!0})}function F(){try{let t=r.readFileSync(S(),"utf8").trim();return t.length>0?t:null}catch{return null}}function V(t){r.mkdirSync(s(),{recursive:!0}),r.writeFileSync(S(),`${t}
|
|
3
|
-
`,"utf8")}function B(){try{return r.readdirSync(s(),{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).sort(N)}catch{return[]}}function N(t,e){let a=i=>{let c=i.indexOf("-"),f=c>=0?i.slice(0,c):i,D=c>=0?i.slice(c+1):"",g=f.split(".").map(y=>Number.parseInt(y,10));return g.some(y=>!Number.isFinite(y))?[[Number.POSITIVE_INFINITY],i]:[g,D]},[l,n]=a(t),[d,p]=a(e);for(let i=0;i<Math.max(l.length,d.length);i++){let c=l[i]??0,f=d[i]??0;if(c!==f)return c-f}return n===p?0:n?p?n<p?-1:1:-1:1}function J(){let t=F();if(!t)return null;let e=O(t);try{if(r.statSync(e).isDirectory())return e}catch{}return null}var x=16*1024;function j(){try{let t=r.openSync(m(),"r");try{let e=Buffer.alloc(x),a=r.readSync(t,e,0,x,0),l=e.subarray(0,a).toString("utf8"),n=JSON.parse(l);return n&&n.schema===1&&typeof n.pid=="number"&&typeof n.bridgePort=="number"&&typeof n.runtimePort=="number"&&typeof n.startedAt=="number"&&typeof n.heartbeatAt=="number"?n:null}finally{r.closeSync(t)}}catch{return null}}function M(t,e=Date.now()){if(!t||e-t.heartbeatAt>I)return!1;try{return process.kill(t.pid,0),!0}catch{return!1}}function T(t){b();let e=`${m()}.tmp`;r.writeFileSync(e,`${JSON.stringify(t,null,2)}
|
|
4
|
-
`,"utf8"),r.renameSync(e,m())}function $(t){b();let e=j();return e&&M(e)&&e.pid!==t.pid?!1:(T(t),!0)}function K(){try{r.unlinkSync(m())}catch{}}export{L as a,v as b,k as c,E as d,I as e,u as f,s as g,O as h,S as i,A as j,H as k,_ as l,m,C as n,b as o,F as p,V as q,B as r,N as s,J as t,j as u,M as v,T as w,$ as x,K as y};
|