sootsim 0.1.66 → 0.1.68

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.
Files changed (152) hide show
  1. package/dist-cli/bin.js +7 -28
  2. package/dist-cli/chunks/agent-RWWC5VLR.js +46 -0
  3. package/dist-cli/chunks/{agent-wrapper-5DJBERZP.js → agent-wrapper-AZ2TWUZV.js} +2 -2
  4. package/dist-cli/chunks/{assert-RHILK3WR.js → assert-YVADDYYY.js} +2 -2
  5. package/dist-cli/chunks/auto-bootstrap-E62IXD2G.js +2 -0
  6. package/dist-cli/chunks/beta-7MI67AHK.js +2 -0
  7. package/dist-cli/chunks/{chunk-XZ5SQJM2.js → chunk-2HVRBEOU.js} +128 -36
  8. package/dist-cli/chunks/chunk-2NFRZQ3K.js +73 -0
  9. package/dist-cli/chunks/{chunk-22CO2ZE3.js → chunk-3HF6BNSA.js} +2 -2
  10. package/dist-cli/chunks/{chunk-GDCMTHEU.js → chunk-3NNUNABL.js} +1 -1
  11. package/dist-cli/chunks/{chunk-BD76YSRN.js → chunk-3QA6YYSG.js} +2 -2
  12. package/dist-cli/chunks/{chunk-T4YLDM5C.js → chunk-52QFCYGQ.js} +3 -3
  13. package/dist-cli/chunks/chunk-5LDGAVAV.js +23 -0
  14. package/dist-cli/chunks/{chunk-LRBMW2WC.js → chunk-5QUYJKLU.js} +2 -2
  15. package/dist-cli/chunks/chunk-5SGAFI2M.js +23 -0
  16. package/dist-cli/chunks/{chunk-VRV2X4X2.js → chunk-6453CCSA.js} +1 -1
  17. package/dist-cli/chunks/{chunk-FXF2FHPI.js → chunk-6JGI2JVM.js} +2 -2
  18. package/dist-cli/chunks/chunk-6TQ2IBH6.js +2 -0
  19. package/dist-cli/chunks/chunk-72Y42WVX.js +186 -0
  20. package/dist-cli/chunks/{chunk-4LYNJPUM.js → chunk-BQLKO6NP.js} +2 -2
  21. package/dist-cli/chunks/{chunk-AYBGSHQK.js → chunk-C3R25CWY.js} +2 -2
  22. package/dist-cli/chunks/{chunk-TJEP4DBA.js → chunk-CFR6W2AH.js} +2 -2
  23. package/dist-cli/chunks/chunk-CMEWLMED.js +1 -0
  24. package/dist-cli/chunks/chunk-CZWZG7GL.js +2 -0
  25. package/dist-cli/chunks/chunk-D5LXWWGN.js +12 -0
  26. package/dist-cli/chunks/{chunk-EIQLQDKX.js → chunk-E7FCGYB5.js} +2 -2
  27. package/dist-cli/chunks/{chunk-DEQ7RED3.js → chunk-FBO7YRJM.js} +2 -2
  28. package/dist-cli/chunks/chunk-FITG7BVA.js +1 -0
  29. package/dist-cli/chunks/{chunk-BEQD2DSK.js → chunk-G3WXMB3Z.js} +1 -1
  30. package/dist-cli/chunks/chunk-GFXFPPNR.js +35 -0
  31. package/dist-cli/chunks/chunk-H6YUT7HX.js +372 -0
  32. package/dist-cli/chunks/{chunk-D4VEI6MI.js → chunk-HC43PTFD.js} +1 -1
  33. package/dist-cli/chunks/chunk-HPFXTPOD.js +1 -0
  34. package/dist-cli/chunks/{chunk-V4SZERWD.js → chunk-J7XCQWQI.js} +14 -14
  35. package/dist-cli/chunks/{chunk-HIN5TAAL.js → chunk-K6N6DEL5.js} +1 -1
  36. package/dist-cli/chunks/{chunk-6AP6LXVV.js → chunk-KKK4RTBP.js} +1 -1
  37. package/dist-cli/chunks/{chunk-NCSGLZRV.js → chunk-OFTI3N27.js} +2 -2
  38. package/dist-cli/chunks/{chunk-BTHB3PMG.js → chunk-QHAZOOK2.js} +3 -3
  39. package/dist-cli/chunks/{chunk-4NT6VRUU.js → chunk-QYFPV5YO.js} +1 -1
  40. package/dist-cli/chunks/chunk-TBVBPZRF.js +3 -0
  41. package/dist-cli/chunks/{chunk-LVFWALS4.js → chunk-TKDMCYGS.js} +2 -2
  42. package/dist-cli/chunks/{chunk-LCKLQSZX.js → chunk-TY5CBM3C.js} +2 -2
  43. package/dist-cli/chunks/{chunk-WAOLC7WV.js → chunk-TZYXNQHA.js} +1 -1
  44. package/dist-cli/chunks/chunk-U7KUAZJB.js +119 -0
  45. package/dist-cli/chunks/{chunk-M2Q4FXRE.js → chunk-WHJFB6AK.js} +1 -1
  46. package/dist-cli/chunks/{chunk-HWCZYW6M.js → chunk-WIW3G6HS.js} +2 -2
  47. package/dist-cli/chunks/chunk-WXISHMXL.js +2 -0
  48. package/dist-cli/chunks/{chunk-UMXVWFST.js → chunk-YSDIOWNN.js} +1 -1
  49. package/dist-cli/chunks/{chunk-EEMGSSWY.js → chunk-Z6BCORBY.js} +2 -2
  50. package/dist-cli/chunks/{chunk-UNSLXX7V.js → chunk-ZP7YYRHI.js} +2 -2
  51. package/dist-cli/chunks/cli-version-LM6OBGUK.js +2 -0
  52. package/dist-cli/chunks/{compat-I7JXYUJN.js → compat-Z3IFUQ73.js} +3 -3
  53. package/dist-cli/chunks/{config-3HR5RKVH.js → config-XBERIMLW.js} +2 -2
  54. package/dist-cli/chunks/control-SWOP3KB7.js +2 -0
  55. package/dist-cli/chunks/{cpu-profile-ZVHMTVAU.js → cpu-profile-SNX23Q5V.js} +2 -2
  56. package/dist-cli/chunks/daemon-QQPC4GOV.js +65 -0
  57. package/dist-cli/chunks/{debug-CQ6Y7GJ2.js → debug-WENYS45R.js} +5 -5
  58. package/dist-cli/chunks/demo-app-registry-QWOGX5C2.js +2 -0
  59. package/dist-cli/chunks/{detox-7ZKTGLDR.js → detox-P4N47V6P.js} +2 -2
  60. package/dist-cli/chunks/{device-4M6Z7E2N.js → device-5WWFV22H.js} +2 -2
  61. package/dist-cli/chunks/{diagnose-SMQLYGNX.js → diagnose-HJ4F3ER7.js} +2 -2
  62. package/dist-cli/chunks/drivers-GAEMIY75.js +2 -0
  63. package/dist-cli/chunks/{electron-6N2MIN5W.js → electron-JHFA2OGV.js} +3 -3
  64. package/dist-cli/chunks/flow-J67STV2Q.js +2 -0
  65. package/dist-cli/chunks/{hints-RJCZS2E3.js → hints-UHQ2T2RX.js} +2 -2
  66. package/dist-cli/chunks/{home-paths-DCUNA3CD.js → home-paths-NWDFFIX4.js} +2 -2
  67. package/dist-cli/chunks/inspect-O34RH4AE.js +970 -0
  68. package/dist-cli/chunks/install-ZB2AGO44.js +2 -0
  69. package/dist-cli/chunks/{install-desktop-C7424OSW.js → install-desktop-RYP35PHA.js} +3 -3
  70. package/dist-cli/chunks/{keys-TXUQOAZ3.js → keys-U5YI77TK.js} +2 -2
  71. package/dist-cli/chunks/{launch-MVA44QTC.js → launch-UFOGCQWO.js} +3 -3
  72. package/dist-cli/chunks/{login-NHO2WTHC.js → login-SPX6IK6Q.js} +4 -4
  73. package/dist-cli/chunks/{logout-SRRWADCE.js → logout-I6UE3XYL.js} +2 -2
  74. package/dist-cli/chunks/{maestro-UHNXEZAN.js → maestro-IPEULAUZ.js} +2 -2
  75. package/dist-cli/chunks/{preview-ETIUP7KC.js → preview-CE27FPGG.js} +2 -2
  76. package/dist-cli/chunks/{profile-MY5JFVIF.js → profile-JZSFMO2Y.js} +2 -2
  77. package/dist-cli/chunks/{react-KCMC4GL3.js → react-6IJQG4V3.js} +2 -2
  78. package/dist-cli/chunks/record-6WDKEBXL.js +70 -0
  79. package/dist-cli/chunks/runtime-P54OGI57.js +2 -0
  80. package/dist-cli/chunks/{runtime-delivery-LQZIWQU6.js → runtime-delivery-C4KG6ISS.js} +2 -2
  81. package/dist-cli/chunks/screenshot-VQTI6G32.js +33 -0
  82. package/dist-cli/chunks/{screenshot-mode-USPWASI3.js → screenshot-mode-JBDCHRSS.js} +2 -2
  83. package/dist-cli/chunks/{screenshots-EPEDNA6H.js → screenshots-HLMGN2OX.js} +2 -2
  84. package/dist-cli/chunks/{server-222QT33M.js → server-U3QLKQDX.js} +6 -6
  85. package/dist-cli/chunks/setup-repo-TZULA5RK.js +2 -0
  86. package/dist-cli/chunks/{skills-6XRREE2M.js → skills-SMML5DJP.js} +2 -2
  87. package/dist-cli/chunks/{start-YCAZBZEX.js → start-7SCU4I64.js} +4 -4
  88. package/dist-cli/chunks/store-WEIVIM3L.js +2 -0
  89. package/dist-cli/chunks/telemetry-U3BBVPLJ.js +2 -0
  90. package/dist-cli/chunks/{test-6TNRHSWC.js → test-UWFHFDN7.js} +3 -3
  91. package/dist-cli/chunks/{three-mode-MDOLHGXW.js → three-mode-CJUNGCIF.js} +2 -2
  92. package/dist-cli/chunks/{timeline-72MWE44G.js → timeline-DIRXVM6R.js} +3 -3
  93. package/dist-cli/chunks/{upgrade-IHZ4DFAE.js → upgrade-LQQU4GSZ.js} +2 -2
  94. package/dist-cli/chunks/upload-SSAFKJGF.js +2 -0
  95. package/dist-cli/chunks/web-AJU6QA43.js +2 -0
  96. package/dist-cli/chunks/what-happened-QFXDQ6VU.js +22 -0
  97. package/dist-cli/chunks/{whoami-2EYGCRDQ.js → whoami-HWXPDZEF.js} +2 -2
  98. package/dist-lib/agent-daemon-client.cjs +1 -1
  99. package/dist-lib/agent-events.cjs +1 -1
  100. package/dist-lib/agent-sessions.cjs +1 -1
  101. package/dist-lib/attached-projects.cjs +1 -1
  102. package/dist-lib/auth/shared-session.cjs +1 -1
  103. package/dist-lib/backend-origin.cjs +1 -1
  104. package/dist-lib/bridge-constants.cjs +1 -1
  105. package/dist-lib/cli-constants.cjs +1 -1
  106. package/dist-lib/config.cjs +1 -1
  107. package/dist-lib/dev-bundle-resolution.cjs +9 -2
  108. package/dist-lib/home-paths.cjs +1 -1
  109. package/dist-lib/host/bridge-host.cjs +23 -7
  110. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  111. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  112. package/dist-lib/index.cjs +1 -1
  113. package/dist-lib/metro.cjs +1 -1
  114. package/dist-lib/profiles.cjs +1 -1
  115. package/dist-lib/render-mode.cjs +1 -1
  116. package/dist-lib/vite-base.cjs +23 -7
  117. package/dist-lib/vite.cjs +1 -1
  118. package/package.json +1 -1
  119. package/dist-cli/chunks/agent-IW7CCSSI.js +0 -61
  120. package/dist-cli/chunks/auto-bootstrap-PS2UDBP7.js +0 -2
  121. package/dist-cli/chunks/beta-XLYWSKEA.js +0 -2
  122. package/dist-cli/chunks/chunk-5MVFADNH.js +0 -3
  123. package/dist-cli/chunks/chunk-7NYW73Q6.js +0 -2
  124. package/dist-cli/chunks/chunk-EMMX6RF7.js +0 -73
  125. package/dist-cli/chunks/chunk-FIIBCY5I.js +0 -3
  126. package/dist-cli/chunks/chunk-G4VWDOWB.js +0 -17
  127. package/dist-cli/chunks/chunk-GMKGJHVG.js +0 -1
  128. package/dist-cli/chunks/chunk-M3ZEZHOB.js +0 -34
  129. package/dist-cli/chunks/chunk-MWTMLNGM.js +0 -348
  130. package/dist-cli/chunks/chunk-NQKBIKUZ.js +0 -1
  131. package/dist-cli/chunks/chunk-QMRXLBPN.js +0 -11
  132. package/dist-cli/chunks/chunk-X4HQLK4V.js +0 -119
  133. package/dist-cli/chunks/chunk-XOTJSR4T.js +0 -2
  134. package/dist-cli/chunks/chunk-YSQV4D7P.js +0 -1
  135. package/dist-cli/chunks/chunk-Z6HSVZIO.js +0 -100
  136. package/dist-cli/chunks/cli-version-ESQ2S6N5.js +0 -2
  137. package/dist-cli/chunks/control-TDZXFNVT.js +0 -2
  138. package/dist-cli/chunks/daemon-VYRTYH55.js +0 -83
  139. package/dist-cli/chunks/demo-app-registry-JAYU7BBM.js +0 -2
  140. package/dist-cli/chunks/drivers-SIY6JBEM.js +0 -2
  141. package/dist-cli/chunks/flow-BZEWL7UQ.js +0 -2
  142. package/dist-cli/chunks/inspect-T5NC7HHB.js +0 -1025
  143. package/dist-cli/chunks/install-YTJI5RS7.js +0 -2
  144. package/dist-cli/chunks/record-DHDSXC2Y.js +0 -51
  145. package/dist-cli/chunks/runtime-AJP6V5LM.js +0 -2
  146. package/dist-cli/chunks/screenshot-4KPEEI6I.js +0 -28
  147. package/dist-cli/chunks/setup-repo-D56L3CEB.js +0 -2
  148. package/dist-cli/chunks/store-Z32KZ34K.js +0 -2
  149. package/dist-cli/chunks/telemetry-RFTX2BZK.js +0 -2
  150. package/dist-cli/chunks/upload-G5C7LJWG.js +0 -2
  151. package/dist-cli/chunks/web-JLJSJUS2.js +0 -2
  152. package/dist-cli/chunks/what-happened-BUXSJ3QS.js +0 -15
@@ -0,0 +1,372 @@
1
+ /*! sootsim v0.1.68 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as Me}from"./chunk-TKDMCYGS.js";import{a as Pe}from"./chunk-BQLKO6NP.js";import{a as Ie}from"./chunk-2NFRZQ3K.js";import{a as R,b as we,c as he,d as Q,e as Z,f as ge,g as ee,i as te,j as ye,k as ke}from"./chunk-2HVRBEOU.js";import{f as xe,m as Te,o as Fe,s as $e}from"./chunk-D5LXWWGN.js";import{e as ve}from"./chunk-WIW3G6HS.js";import{l as pe}from"./chunk-GFXFPPNR.js";import{a as be}from"./chunk-TY5CBM3C.js";import{a as Se}from"./chunk-3NNUNABL.js";import{a as me,b as q}from"./chunk-FBO7YRJM.js";import{f as ue}from"./chunk-6JGI2JVM.js";import{c as Y,d as X,e as fe}from"./chunk-5LDGAVAV.js";import{c as G}from"./chunk-6453CCSA.js";import*as P from"fs";import{tmpdir as Ce}from"os";import*as y from"path";import*as g from"fs";import*as w from"path";var V=1e4,B=393,_=852,Ae="__sootsimCliPerf",je="maestroCopiedText",Ee=new Map;function f(o){return new Promise(e=>setTimeout(e,o))}function Ke(o){return o?w.basename(o)===".maestro"?w.dirname(o):o:process.cwd()}function Je(o,e,t){let i=e.endsWith(".png")?e:`${e}.png`;if(w.isAbsolute(i))return i;if(t.mode==="flow"&&/[\\/]/.test(i)){let r=i.startsWith("./")||i.startsWith("../")?t.flowDir??process.cwd():Ke(t.flowDir);return w.resolve(r,i)}return w.join(o,i)}function He(o){if(typeof o=="string")return{path:o,withFrame:!1};let e=o.path?.trim()||o.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:o.withFrame===!0}}function ie(o){let[e,t]=o.split(",").map(r=>r.trim()),i=(r,s)=>r.endsWith("%")?Number.parseFloat(r)/100*s:Number.parseFloat(r);return{x:i(e,B),y:i(t,_)}}function ze(o){let e=o.split(/^---$/m),t=e.length>1?e[e.length-1]:o,i=he(we.parse(t),Ee);return Array.isArray(i)?i:[]}var L=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingDurationMs=null;simRouteHint=null;lastFailedStep=null;get simId(){return this.opts.simId}setSimRouteHint(e){this.simRouteHint=this.normalizeSimRoute(e)}normalizeSimRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let i=t.searchParams.toString();return`${t.origin}${t.pathname}${i?`?${i}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(a=>a.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(a=>a.id===this.opts.simId&&a.readyState==="open")||!this.simRouteHint)return;let r=this.simRouteHint&&e.find(a=>a.readyState==="open"&&this.normalizeSimRoute(a.url||a.origin)===this.simRouteHint);if(!r)return;let s=e.find(a=>a.isPrimary&&a.readyState==="open"),n=e.find(a=>a.readyState==="open"),l=r??s??n;l&&(this.opts.simId=l.id,console.log(` [flow] sim rotated to ${l.id}`))}catch{}}async evaluate(e,t){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e},t?{timeoutMs:t}:void 0)}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async waitForTree(e=V){let t=Date.now()+e,i=Date.now(),r=null,s=0,n=0;for(;Date.now()<t;){try{let a=await this.evaluate(`(async () => {
3
+ const test = window.__sootsimTest
4
+ if (!test) return { count: 0, loading: true }
5
+ const count = (await test.getNodeCount?.()) || 0
6
+ const external = globalThis.__sootsimExternalAppState
7
+ if (external?.error) {
8
+ return { count, loading: false, error: String(external.error) }
9
+ }
10
+ if (external) {
11
+ return {
12
+ count,
13
+ loading: !external.ready,
14
+ error: null,
15
+ }
16
+ }
17
+ const loadingNode = await test.findByText?.('loading')
18
+ const capturingNode = await test.findByText?.('capturing')
19
+ const openingAppNode = await test.findByText?.('opening app')
20
+ const isLoading = !!loadingNode || !!capturingNode || !!openingAppNode || count < 5
21
+ return { count, loading: isLoading, error: null }
22
+ })()`,8e3);if(s=0,a?.error)throw new Error(`app failed to load: ${a.error}`);if(a&&a.count>10&&!a.loading)return}catch(a){if(r=a instanceof Error?a:new Error(String(a)),r.message.startsWith("app failed to load:"))throw r;if(s++,s>=4)throw new Error(`target sim is not responding to the bridge (${r.message}). it is likely a stale orphan \u2014 run \`sootsim list\`, then close it with \`sootsim close <id>\` or start a fresh one with \`sootsim open --new <port>\`.`);await this.refreshSimId()}let l=Date.now()-i;l-n>=5e3&&(n=l,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(l/1e3)}s)`)),await f(500)}throw r?.message.startsWith("app failed to load:")?r:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(await Pe("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
23
+ const rec = window.__sootsimRecorder
24
+ if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
25
+ 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 i=[],r=0;for(;;){let n=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${r}, chunk: 2097152 })`);if(!n||(i.push(Buffer.from(n.data,"base64")),r=n.offset,n.done))break}if(i.length===0)throw new Error("recording requested but no video buffer was produced");g.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let s=w.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.webm`);return g.writeFileSync(s,Buffer.concat(i)),s}async waitForRecordingTail(e){if(!this.recordingEnabled)return;let t=Math.max(0,Math.round(e.maxMs));if(t<=0)return;if(!e.smart){await f(t);return}let i=await ke({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:80,stablePolls:6,strict:!0});await this.waitForVisualSettle(),console.log(i.settled?` [flow] recording tail settled in ${i.elapsed}ms`:` [flow] recording tail reached ${i.elapsed}ms budget`)}async findElement(e){return this.evaluate(`(async () => {
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){let t=e.id?{id:e.id,testID:e.id,text:null}:{id:null,testID:null,text:e.text??null};return this.evaluate(`(async () => {
50
+ const test = window.__sootsimTest
51
+ if (!test) return null
52
+ const node = ${e.id?`(await test.findByTestId?.(${JSON.stringify(e.id)})) || (await test.findById?.(${JSON.stringify(e.id)}))`:`await test.findByText?.(${JSON.stringify(e.text||"")})`}
53
+ let point = null
54
+ if (node?.absolutePosition && node?.layout) {
55
+ point = {
56
+ x: node.absolutePosition.x + node.layout.width / 2,
57
+ y: node.absolutePosition.y + node.layout.height / 2,
58
+ }
59
+ if (typeof node.nodeId === 'number' && test.resolveTapTarget) {
60
+ const resolved = await test.resolveTapTarget(node.nodeId)
61
+ if (
62
+ resolved &&
63
+ Number.isFinite(resolved.cx) &&
64
+ Number.isFinite(resolved.cy)
65
+ ) {
66
+ point = { x: resolved.cx, y: resolved.cy }
67
+ }
68
+ }
69
+ }
70
+ ${e.id?`const direct = await test.activatePressById?.(${JSON.stringify(e.id)})`:`const direct = await test.activatePressByText?.(${JSON.stringify(e.text||"")})`}
71
+ if (direct?.ok && point) {
72
+ window.dispatchEvent(
73
+ new CustomEvent('sootsim:agentAction', {
74
+ detail: { type: 'tap', x: point.x, y: point.y, target: ${JSON.stringify(t)} },
75
+ }),
76
+ )
77
+ }
78
+ return direct || null
79
+ })()`)}async activatePressAt(e,t){return this.evaluate(`(async () => {
80
+ const test = window.__sootsimTest
81
+ if (!test?.activatePressAt) return null
82
+ const direct = await test.activatePressAt(${e}, ${t})
83
+ if (direct?.ok) {
84
+ window.dispatchEvent(
85
+ new CustomEvent('sootsim:agentAction', {
86
+ detail: { type: 'tap', x: ${e}, y: ${t} },
87
+ }),
88
+ )
89
+ }
90
+ return direct
91
+ })()`)}async tap(e,t,i){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t,target:i})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let a=ie(t.point);(await this.activatePressAt(a.x,a.y))?.ok||await this.tap(a.x,a.y),await f(300);return}let i=5e3,r=150,s=Date.now()+i,n=await this.findElement({text:t.text,id:t.id});for(;!n&&Date.now()<s;)await f(r),n=await this.findElement({text:t.text,id:t.id});if(n){let a=typeof n.nodeId=="number"?await this.resolveTapTarget(n.nodeId):null,m=a?.cx??n.absolutePosition.x+n.layout.width/2,h=a?.cy??n.absolutePosition.y+n.layout.height/2;if((await this.tap(m,h,{id:t.id??a?.target?.id??n.id??null,testID:t.id??a?.target?.testID??n.testID??null,text:t.text??a?.target?.text??a?.target?.accessibilityLabel??n.text??n.accessibilityLabel??null,type:a?.target?.type??n.type??null}))?.hit===!0){await f(300);return}}if((await this.activatePressTarget(t))?.ok){await f(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async tapAtCoords(e,t){await this.tap(e,t),await f(300)}async doubleTapAtCoords(e,t,i=80){let r=Math.max(0,Math.round(i));if(!await this.evaluate(`(async () => {
92
+ const interact = window.__sootsimInteract
93
+ if (interact?.doubleTap) {
94
+ return !!(await interact.doubleTap(${e}, ${t}, ${r}))
95
+ }
96
+ if (!interact?.tap) return false
97
+ const first = await interact.tap(${e}, ${t})
98
+ if (!first || first.hit === false) return false
99
+ await new Promise((resolve) => setTimeout(resolve, ${r}))
100
+ const second = await interact.tap(${e}, ${t})
101
+ return !!second && second.hit !== false
102
+ })()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await f(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let s=0;s<15;s++){if(await this.isElementVisible(t))return;await f(200)}let i=await this.findElement(t),r=i?` (matched node at y=${Math.round(i.absolutePosition.y)} h=${Math.round(i.layout.height)} \u2014 off-screen)`:" (no matching node in tree)";throw new Error(`assertVisible: ${JSON.stringify(t)} not visible${r}`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t)){let i=await this.findElement(t),r=i?` at (${Math.round(i.absolutePosition.x)},${Math.round(i.absolutePosition.y)})`:"";throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible${r}`)}}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<_)}async inputText(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await f(200)}async pressKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"press",text:e}),await f(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:e}),await f(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let t=await this.evaluate(`(() => {
103
+ const keyboard =
104
+ window.__sootsimKeyboard ??
105
+ window.SootSim?.bridges?.keyboard ??
106
+ null
107
+ const test = window.__sootsimTest
108
+ return {
109
+ visible: !!keyboard?.isVisible?.(),
110
+ focused: !!test?.isTextInputFocused?.(),
111
+ }
112
+ })()`);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)}let i=await this.findElement(e),r=i?` (matched node y=${Math.round(i.absolutePosition.y)} \u2014 still off-screen at deadline)`:"";throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||V}ms${r}`)}async takeScreenshot(e){try{await this.waitForVisualSettle()}catch{}await f(250);let t=He(e),i=Je(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});g.mkdirSync(w.dirname(i),{recursive:!0});let s=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,""),n=Buffer.from(s,"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 Me(n,l);g.writeFileSync(i,a),console.log(`[flow] screenshot: ${i} (frame: ${l})`);return}g.writeFileSync(i,n),console.log(`[flow] screenshot: ${i}`)}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",simId:this.opts.simId,path:"SootSim.bridges.settings.get",args:[]}),t=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!t||!(t in ue)?null:t}async captureFailureScreenshot(e){g.mkdirSync(w.dirname(e),{recursive:!0});let i=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");g.writeFileSync(e,Buffer.from(i,"base64"))}async captureFailureBundle(e,t){g.mkdirSync(e,{recursive:!0});let i=(h,p)=>{try{g.writeFileSync(w.join(e,h),p)}catch{}},r=async h=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:h})}catch{return null}},s=await r(`(async () => {
113
+ const out = {
114
+ simId: window.__sootsimBridge?.id ?? window.SootSim?.state?.simId ?? null,
115
+ url: location.href,
116
+ title: document.title,
117
+ hidden: document.hidden,
118
+ }
119
+ try {
120
+ const params = new URL(location.href).searchParams
121
+ const bundle = params.get('bundle')
122
+ if (bundle) {
123
+ const baseMatch = bundle.match(/^https?:\\/\\/[^/]+/)
124
+ if (baseMatch) {
125
+ const res = await fetch(baseMatch[0] + '/', {
126
+ headers: { 'expo-platform': 'ios' },
127
+ cache: 'no-store',
128
+ })
129
+ if (res.ok) {
130
+ out.manifest = await res.json().catch(() => null)
131
+ }
132
+ }
133
+ }
134
+ } catch {}
135
+ return out
136
+ })()`);i("error.json",JSON.stringify({message:t.error.message,stack:t.error.stack,stepIndex:t.stepIndex,stepKind:t.stepKind,stepTarget:t.stepTarget,capturedAt:new Date().toISOString(),sim:s??null},null,2));try{let p=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");i("screenshot.png",Buffer.from(p,"base64"))}catch{}let n=await r(`(async () => {
137
+ const t = window.__sootsimTest
138
+ const mainShell = window.SootSim?.bridges?.mainShell
139
+ if (!t) return { error: 'no test bridge' }
140
+ let shell = null
141
+ try {
142
+ shell = typeof mainShell?.getState === 'function' ? await mainShell.getState() : null
143
+ } catch {}
144
+ const all = await t.queryAll({ pruneHidden: true })
145
+ return { shell, nodes: all, url: location.href, title: document.title }
146
+ })()`);n&&i("describe.json",JSON.stringify(n,null,2));let l=await r("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof l=="string"&&i("a11y.txt",l);let a=await r("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof a=="string"&&i("tree.txt",a);let m=await r(`(() => {
147
+ const c = window.__sootsimConsole
148
+ return {
149
+ errors: c?.getErrors?.() ?? [],
150
+ warnings: c?.getWarnings?.() ?? [],
151
+ requests: (window.__sootsimGetFailedRequests?.() ?? []),
152
+ }
153
+ })()`);return m&&i("console.json",JSON.stringify(m,null,2)),e}async swipe(e="UP",t=300){let i=B/2,r=_/2,s=200,n=i,l=r,a=i,m=r;switch(e.toUpperCase()){case"UP":l+=s,m-=s;break;case"DOWN":l-=s,m+=s;break;case"LEFT":n+=s,a-=s;break;case"RIGHT":n-=s,a+=s;break}let h=Math.max(10,Math.round(t/16));await this.drag(n,l,a,m,h,16)}async drag(e,t,i,r,s=12,n=16){if(!(await this.evaluate(`(async () => {
154
+ const interact = window.__sootsimInteract
155
+ if (!interact?.drag) return { ok: false }
156
+ const value = await interact.drag(${e}, ${t}, ${i}, ${r}, ${Math.max(1,Math.round(s))}, ${Math.max(0,Math.round(n))})
157
+ return { ok: !!value, value }
158
+ })()`))?.ok)throw new Error("drag failed");await f(300)}async swipeCoords(e,t,i=300){let r=ie(e),s=ie(t),n=Math.max(10,Math.round(i/16));await this.drag(r.x,r.y,s.x,s.y,n,16)}async swipeFrom(e,t="UP",i=300){let r=await this.findElement(e);if(!r)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let s=r.absolutePosition.x+r.layout.width/2,n=r.absolutePosition.y+r.layout.height/2,l=180,a=s,m=n;switch(t.toUpperCase()){case"UP":m-=l;break;case"DOWN":m+=l;break;case"LEFT":a-=l;break;case"RIGHT":a+=l;break}let h=Math.max(10,Math.round(i/16));await this.drag(s,n,a,m,h,16)}async scrollTo(e,t,i){let r=await this.callTest("scrollTo",e,t,i,!1);if(!r?.ok)throw new Error(`scrollTo failed: ${r?.reason||"unknown error"}`);await f(250)}async pinch(e){let t=await this.evaluate(`(async () => {
159
+ const interact = window.__sootsimInteract
160
+ if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
161
+ const ok = await interact.pinch(
162
+ ${e.from[0]}, ${e.from[1]}, ${e.from[2]}, ${e.from[3]},
163
+ ${e.to[0]}, ${e.to[1]}, ${e.to[2]}, ${e.to[3]},
164
+ ${e.steps||12}, ${e.stepMs||16}
165
+ )
166
+ return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
167
+ })()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"unknown error"}`);await f(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){await f(e)}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),i=e.direction?.toUpperCase()||"DOWN",r=i==="DOWN"?"UP":i==="UP"?"DOWN":i;for(;Date.now()<t;){let s=await this.findElement({text:e.element});if(s&&s.absolutePosition.y>=0&&s.absolutePosition.y+s.layout.height>0&&s.absolutePosition.y<_-50){if(e.centerElement){let n=_/2,l=s.absolutePosition.y-n;if(Math.abs(l)>100){let a=Math.min(150,Math.abs(l)*.5),m=l>0?n-a:n+a;await this.drag(B/2,n,B/2,m,10,16)}}return}await this.swipe(r,250),await f(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+(e.timeout||V);for(;Date.now()<t;){let i=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,r=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(i&&r)return;await f(200)}throw new Error("extendedWaitUntil timed out")}async launchApp(e){await this.refreshSimId();let t=!!(e&&typeof e=="object"&&e.clearState);if(t&&await this.evaluate(`(async () => {
168
+ await (${R})
169
+ try {
170
+ const regs = await navigator.serviceWorker?.getRegistrations?.()
171
+ await Promise.all((regs || []).map((reg) => reg.unregister()))
172
+ } catch {}
173
+ })()`),!this.firstLaunchDone&&!t)this.firstLaunchDone=!0,await this.waitForTree(3e4);else if(this.firstLaunchDone=!0,await this.evaluate("window.location.reload()").catch(()=>{}),await f(500),await this.refreshSimId(),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(i){console.warn(` warn: onAfterLaunch hook threw: ${i instanceof Error?i.message:i}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
174
+ requestAnimationFrame(() => {
175
+ requestAnimationFrame(() => {
176
+ requestAnimationFrame(() => {
177
+ setTimeout(resolve, 180)
178
+ })
179
+ })
180
+ })
181
+ })`)}catch{await f(180)}}async startProfile(){await this.evaluate(`((sessionKey) => {
182
+ const host = window.__sootsimRenderHost
183
+ if (host?.startPerfSession) {
184
+ host.startPerfSession(sessionKey)
185
+ window[sessionKey] = {
186
+ active: true,
187
+ mode: 'render-worker',
188
+ startedAt: performance.now(),
189
+ }
190
+ return
191
+ }
192
+
193
+ const perf = window.__sootsimPerf
194
+ const a11y = window.__sootsimA11y
195
+ perf?.enableFrameStats?.()
196
+ perf?.resetFrameStats?.()
197
+ a11y?.resetProfile?.()
198
+ window[sessionKey] = {
199
+ active: true,
200
+ mode: 'main-thread',
201
+ startedAt: performance.now(),
202
+ }
203
+ })(${JSON.stringify(Ae)})`),this.profilingEnabled=!0}async stopProfile(){let e=await this.evaluate(`(async (sessionKey) => {
204
+ const host = window.__sootsimRenderHost
205
+ if (host?.stopPerfSession) {
206
+ const stopped = await host.stopPerfSession(sessionKey)
207
+ if (!stopped || !Array.isArray(stopped.samples)) {
208
+ return { error: 'no render-worker perf samples available' }
209
+ }
210
+ const samples = stopped.samples
211
+ const frameTimes = samples.map((sample) => Number(sample?.[1]) || 0).filter((value) => value > 0)
212
+ const sorted = [...frameTimes].sort((a, b) => a - b)
213
+ const worstFrames = samples
214
+ .slice()
215
+ .sort((a, b) => (Number(b?.[1]) || 0) - (Number(a?.[1]) || 0))
216
+ .slice(0, 10)
217
+ .map((sample) => [
218
+ Number(sample?.[0]) || 0,
219
+ Number(sample?.[1]) || 0,
220
+ Number(sample?.[2]) || 0,
221
+ Number(sample?.[3]) || 0,
222
+ Number(sample?.[4]) || 0,
223
+ ])
224
+
225
+ return {
226
+ mode: 'render-worker',
227
+ frames: Number(stopped.frameCount) || frameTimes.length,
228
+ totalMs: Number(stopped.totalMs) || frameTimes.reduce((sum, value) => sum + value, 0),
229
+ avgMs: Number(stopped.avgMs) || (frameTimes.length ? frameTimes.reduce((sum, value) => sum + value, 0) / frameTimes.length : 0),
230
+ maxMs: Number(stopped.maxMs) || (sorted[sorted.length - 1] || 0),
231
+ layoutTotalMs: Number(stopped.layoutTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[2]) || 0), 0),
232
+ renderTotalMs: Number(stopped.renderTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[3]) || 0), 0),
233
+ copyTotalMs: Number(stopped.copyTotalMs) || samples.reduce((sum, sample) => sum + (Number(sample?.[4]) || 0), 0),
234
+ layoutAvgMs: Number(stopped.layoutAvgMs) || 0,
235
+ renderAvgMs: Number(stopped.renderAvgMs) || 0,
236
+ copyAvgMs: Number(stopped.copyAvgMs) || 0,
237
+ p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
238
+ p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
239
+ p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
240
+ jankFrames: frameTimes.filter((value) => value > 16.67).length,
241
+ sampleCount: frameTimes.length,
242
+ worstFrames,
243
+ }
244
+ }
245
+
246
+ const perf = window.__sootsimPerf
247
+ const a11y = window.__sootsimA11y
248
+ if (!perf && !a11y) return { error: 'no perf globals available' }
249
+
250
+ const frameStats = perf?.getFrameStats?.() || {}
251
+ const profile = a11y?.profile?.() || {}
252
+ const recent = Array.isArray(frameStats.recentFrames) ? frameStats.recentFrames : []
253
+ const sorted = [...recent].sort((a, b) => a - b)
254
+ perf?.disableFrameStats?.()
255
+
256
+ return {
257
+ mode: 'main-thread',
258
+ frames: frameStats.frames || profile.syncCount || 0,
259
+ totalMs: frameStats.totalMs || 0,
260
+ avgMs: frameStats.totalMs && frameStats.frames ? frameStats.totalMs / frameStats.frames : profile.avgSyncMs || 0,
261
+ maxMs: frameStats.maxMs || profile.maxSyncMs || 0,
262
+ layoutTotalMs: frameStats.layoutTotalMs || 0,
263
+ p50: sorted[Math.floor(sorted.length * 0.5)] || 0,
264
+ p95: sorted[Math.floor(sorted.length * 0.95)] || 0,
265
+ p99: sorted[Math.floor(sorted.length * 0.99)] || 0,
266
+ jankFrames: recent.filter((value) => value > 16.67).length,
267
+ sampleCount: recent.length,
268
+ worstFrames: recent.slice().sort((a, b) => b - a).slice(0, 10),
269
+ }
270
+ })(${JSON.stringify(Ae)})`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.evaluate(`(async () => {
271
+ try { await (${R}) } catch {}
272
+ try {
273
+ const regs = await navigator.serviceWorker?.getRegistrations?.()
274
+ await Promise.all((regs || []).map((reg) => reg.unregister()))
275
+ } catch {}
276
+ })()`)}async clearState(){await this.evaluate(`(async () => {
277
+ await (${R})
278
+ })()`)}clearKeychain(){console.warn("[flow] clearKeychain: sootsim has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,i=await this.findElement(t);if(!i)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let r=i.text??i.testID??"";Ee.set(je,r),console.log(`[flow] copied text: ${JSON.stringify(r)}`)}async evalScript(e){let i=await this.evaluate(`(async () => {
279
+ try {
280
+ return { ok: true, value: await (async () => { ${e} })() }
281
+ } catch (err) {
282
+ return { ok: false, error: err && err.message ? err.message : String(err) }
283
+ }
284
+ })()`);if(!i.ok)throw new Error(`evalScript failed: ${i.error}`);i.value!==void 0&&console.log("[flow] evalScript ->",i.value)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");await this.evaluate(`window.location.href = ${JSON.stringify(t)}`),await f(300),await this.refreshSimId(),await this.waitForTree(3e4)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()==="ios":e.true!==void 0?e.true.toLowerCase()!=="false":!0}isOptional(e){if(e.optional===!0)return!0;let i=Object.entries(e).find(([s])=>s!=="when"&&s!=="optional"),r=i?i[1]:void 0;return!!(r&&typeof r=="object"&&"optional"in r&&r.optional)}async runStep(e,t){let i=Object.keys(e).find(r=>r!=="when")||Object.keys(e)[0];if(console.log(`[flow] step ${t+1}: ${i}`),e.when&&!await this.evaluateWhen(e.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let r=!!(e.extendedWaitUntil||e.waitFor||e.scrollUntilVisible||e.launchApp||e.runFlow),s=1e4,n=this.runStepInner(e);if(r)await n;else{let a=null,m=new Promise((h,p)=>{a=setTimeout(()=>{p(new Error(`step watchdog: ${i} made no progress in ${s}ms \u2014 bridge or bundle probably hung`))},s)});try{await Promise.race([n,m])}finally{a&&clearTimeout(a)}}let l=!!(e.assertVisible||e.assertNotVisible||e.extendedWaitUntil||e.waitFor);this.stepDelay>0&&!l&&await f(this.stepDelay)}catch(r){if(this.isOptional(e)){console.log(`[flow] (optional, skipped: ${r.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:i,target:e[i]},r}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else if(e.takeScreenshot)await this.takeScreenshot(e.takeScreenshot);else if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo){let t=typeof e.scrollTo.nodeId=="number"?{nodeId:e.scrollTo.nodeId}:e.scrollTo.id;if(!t)throw new Error("scrollTo requires id or nodeId");await this.scrollTo(t,e.scrollTo.x,e.scrollTo.y)}else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd)await this.waitForAnimationToEnd(typeof e.waitForAnimationToEnd=="number"?e.waitForAnimationToEnd:2e3);else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await f(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat)for(let t=0;t<e.repeat.times;t++)for(let i=0;i<e.repeat.commands.length;i++)await this.runStep(e.repeat.commands[i],i);else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")await this.evalScript(e.evalScript);else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,i=typeof t=="string"?t:t.file,r=typeof t=="string"?void 0:t.when;if(r&&!await this.evaluateWhen(r)){console.log(`[flow] runFlow skipped (when predicate false): ${i}`);return}let s=w.resolve(this.opts.flowDir,i),n=g.readFileSync(s,"utf8"),l=this.opts.flowDir;this.opts.flowDir=w.dirname(s),await this.runFlow(ze(n)),this.opts.flowDir=l}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let t=[],i=[],r=[];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)){i.push(...n.onFlowComplete);continue}r.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 s=null;try{await this.runFlowBody(r)}catch(n){s=n instanceof Error?n:new Error(String(n))}if(i.length>0){console.log(`[flow] onFlowComplete (${i.length} steps)`);for(let n=0;n<i.length;n++)try{await this.runStep(i[n],n)}catch(l){console.warn(`[flow] onFlowComplete step ${n+1} failed: ${l instanceof Error?l.message:l}`)}}if(s)throw s}async runFlowBody(e){for(let t=0;t<e.length;t++){let i=e[t],r=typeof i.wait=="number"?i.wait:0,s=typeof i.waitFor?.timeout=="number"?i.waitFor.timeout:0,n=Math.max(6e4,r+15e3,s+15e3);if(i.runFlow){await this.runStep(i,t);continue}await Promise.race([this.runStep(i,t),new Promise((l,a)=>setTimeout(()=>a(new Error(`step ${t+1} (${Object.keys(i)[0]}) exceeded ${n}ms deadline`)),n))])}}};function qe(o){if(!o)return"";let e=o.trim();if(!e)return"";if(/^\d+$/.test(e)||e.startsWith("http://")||e.startsWith("https://"))return e;let t=be.find(i=>i.name.toLowerCase()===e.toLowerCase());return t?String(t.preferredPort):e}async function Ge(){let o=await ve(),e=o.find(i=>i.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=o[0];return t?`http://localhost:${t.port}/__soot/`:null}async function De(o){(o.length===0||o.includes("--help")||o.includes("-h"))&&(console.log(`
285
+ sootsim flow \u2014 run flows or manage a draft
286
+
287
+ usage:
288
+ sootsim flow <flow.yaml> [options]
289
+ sootsim flow start
290
+ sootsim flow keep
291
+ sootsim flow end [--output <path>] [--validate] [--video]
292
+ sootsim flow validate <path>
293
+
294
+ options:
295
+ --record record a webm artifact while the flow runs
296
+ --profile capture perf stats while the flow runs
297
+ --out <dir> output directory (default: /tmp/sootsim-recordings)
298
+ --device <model> override the flow frontmatter device for this run
299
+ --slow <ms> delay between steps for natural pacing
300
+ --tail-wait <ms> hold the recording open after the last step so the
301
+ final UI state is captured (default: smart idle up to
302
+ 6000ms for --preview, fixed 2000ms for --record, 0 otherwise)
303
+ --url <url> load this target before running the flow
304
+ --screenshot-paths <mode>
305
+ screenshot path mode: dir (default) or flow
306
+ --replace <m>=<f> replace a Metro module with a local file for this run
307
+ --new open a fresh sim before running the flow
308
+ --driver <id> when paired with --new, launch through a specific
309
+ driver from the registry (e.g. playwright for
310
+ hermetic CI runs); see 'sootsim list --drivers'
311
+ --headless pass headless=true to the launch driver (useful
312
+ with --driver playwright)
313
+ --electron prefer opening the target in the desktop companion
314
+ --sim <id> target a specific current sim
315
+ --validate replay the drafted flow before clearing it
316
+ --video replay and record the drafted flow before clearing it
317
+ --preview record events+video, upload, and print /preview/<id>
318
+ --preview-open open the uploaded preview link after a successful run
319
+ --preview-origin <url>
320
+ upload target for --preview (default: auto)
321
+ --preview-public-origin <url>
322
+ public link origin for --preview (default: sootsim.com
323
+ for prod uploads)
324
+
325
+ frontmatter (top of flow.yaml between --- markers):
326
+ app: 8081 load this target before the flow starts
327
+ device: iphone-14 set the live device model for this flow run
328
+ electron: true prefer the desktop companion sim for this flow
329
+
330
+ default runtime:
331
+ bridge-backed flow playback against the current sim
332
+ if no current sim exists, flow opens the discovered target first
333
+ recording and profiling both run on the same bridge-backed path
334
+
335
+ examples:
336
+ sootsim flow login.yaml
337
+ sootsim flow demo.yaml --url 8081 --record --slow 500 --out ./recordings
338
+ sootsim flow demo.yaml --sim a2
339
+ sootsim flow start
340
+ sootsim flow keep
341
+ sootsim flow end --output ./flows/draft.yaml
342
+ sootsim flow end --output ./flows/draft.yaml --validate
343
+ sootsim flow end --output ./flows/draft.yaml --video
344
+ sootsim flow validate ./flows/draft.yaml
345
+
346
+ flow extension:
347
+ takeScreenshot: hero
348
+ takeScreenshot:
349
+ path: marketing/hero
350
+ withFrame: true
351
+ `),process.exit(0));let e=o[0];P.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=c=>o.find((u,S)=>o[S-1]===c),i=o.includes("--profile"),r=o.includes("--new"),s=t("--out")||"/tmp/sootsim-recordings",n=t("--screenshots")||"/tmp/sootsim-flow",l=t("--screenshot-paths")==="flow"?"flow":"dir",a=t("--device")?.trim()||"",m=o.includes("--slow")?+(t("--slow")||"500"):0,h=o.includes("--electron"),p=o.includes("--preview"),W=await Ie(t("--preview-origin")),re=t("--preview-public-origin"),Oe=o.includes("--preview-open"),Ne=o.flatMap((c,u)=>o[u-1]==="--replace"?["--replace",c]:[]),x=o.includes("--record")||p,Re=o.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):x?p?6e3:2e3:0,Ve=P.readFileSync(e,"utf8"),{frontmatter:$,steps:M}=Q(Ve,{resolveEnv:!0});M.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let A=a||$.device||"",C=h||$.electron===!0,Be=$.app===void 0||$.app===null?"":typeof $.app=="number"?String($.app):$.app,U=qe(Be),oe={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver"]},b=Y(o,oe),Le=t("--url")||"";C&&!Se()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let ne=C?"desktop companion":"bridge",We=U?` | target: ${U}`:"";console.log(`
352
+ sootsim flow \u2014 ${y.basename(e)}
353
+ ${M.length} steps | ${ne}${We}${x?" | recording":""}${i?" | profiling":""}${m?` | ${m}ms delay`:""}
354
+ `),p&&me({event:"preview_flow_started",properties:{flowName:y.basename(e),stepCount:M.length,mode:ne,electron:C,record:x,profile:i,previewOrigin:W}});let T=Le||U||"",j=r||C&&b.simIdSource!=="flag",se=t("--driver")||"",K=!1,J=new Set,ae=!1;if(!T&&!j&&b.simIdSource==="none"){let c=fe(b);try{let u=await c.listSims(),S=u.find(N=>N.isPrimary&&N.readyState==="open"),O=u.find(N=>N.readyState==="open"),ce=S??O;ce&&(ae=!0,console.log(` reusing active sim: ${ce.id}`))}catch{}finally{c.close()}}if(!T&&!ae&&(j||b.simIdSource==="none")){let c=await Ge();c||(console.error(" error: no current sim and no sootsim target found"),await q(),process.exit(1)),T=c}if(T&&A){let c=new URL(await xe(T));c.searchParams.set("device",A),T=c.toString()}if(T){let c=[T];if(c.push(...Ne),j&&c.push("--new"),b.simIdSource==="flag"&&b.simId&&c.push("--sim",b.simId),se&&(c.push("--driver",se),K=!0),o.includes("--headless")&&c.push("--headless"),await Fe(c,{port:b.wsPort,timeoutMs:b.commandTimeoutMs}),K){let u=G();u&&J.add(u)}}let I=Y(o,oe),H=I.simIdSource==="flag"?I.simId:G()||I.simId,Ue=I.simIdSource==="flag"?"flag":H?"saved":"none",F=X(I.wsPort,{commandTimeoutMs:I.commandTimeoutMs,simId:H,simIdSource:Ue}),d,le=async()=>{if(!A)return!1;let c=await F.send({type:"evaluate",simId:d.simId,code:"window.location.href"});if(typeof c=="string"&&c.length>0){let u=new URL(c);u.searchParams.set("device",A),d.setSimRouteHint(u.toString())}return!!await F.send({type:"call",simId:d.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",A]})};d=new L(F,{screenshotDir:n,flowDir:y.dirname(y.resolve(e)),screenshotPathMode:l,simId:H,recordingOutputDir:x?s:void 0,billingOriginOverride:p?W:void 0,allowGitHubRecording:x,onAfterLaunch:async()=>{await le()&&await d.waitForTree(12e4),p&&await F.send({type:"evaluate",simId:d.simId,code:`(() => {
355
+ const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
356
+ return r?.start?.() ?? false
357
+ })()`})}}),m&&(d.stepDelay=m);let k=null,v=null,E=null,z=null,D=0,de=!!M[0]?.launchApp;try{await d.waitForTree(12e4),await le()&&await d.waitForTree(12e4),p&&!de&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await d.launchApp({clearState:!0}),x&&(de?d.prepareRecording():await d.startRecording()),i&&await d.startProfile(),p&&(await F.send({type:"evaluate",simId:d.simId,code:`(() => {
358
+ const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
359
+ return r?.start?.() ?? false
360
+ })()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await d.runFlow(M),i&&(k=await d.stopProfile()),await d.waitForRecordingTail({maxMs:Re,smart:p}),x&&(v=await d.stopRecording(),E=d.getLastRecordingDurationMs()),p&&(z=await F.send({type:"evaluate",simId:d.simId,code:`(() => {
361
+ const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
362
+ return r?.stop?.() ?? []
363
+ })()`}),console.log(` captured ${z.length} replay events`)),console.log(`
364
+ + completed (${M.length} steps)`),k&&_e(k),v&&console.log(` video: ${v}`),console.log()}catch(c){if(i&&!k)try{k=await d.stopProfile()}catch{}if(x&&!v)try{v=await d.stopRecording(),E=d.getLastRecordingDurationMs()}catch(u){console.warn(` recording stop failed: ${u?.message||String(u)}`)}console.error(`
365
+ x failed: ${c.message}
366
+ `),k&&(console.log(" partial profile:"),_e(k)),v&&console.log(` partial video: ${v}`);try{let u=d.lastFailedStep,S=u?`step-${String(u.index+1).padStart(2,"0")}-${u.kind}`:"unstaged",O=y.join(n,S);await d.captureFailureBundle(O,{error:c,stepIndex:u?.index,stepKind:u?.kind,stepTarget:u?.target}),console.log(` failure bundle: ${O}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(u){try{let S=y.join(n,"error.png");await d.captureFailureScreenshot(S),console.log(` error screenshot: ${S}`)}catch{}console.log(` (failure bundle capture failed: ${u instanceof Error?u.message:String(u)})`)}await pe(F,{errorsCommand:`sootsim get errors 5${d.simId?` --sim ${d.simId}`:""}`,warningsCommand:`sootsim get warnings 5${d.simId?` --sim ${d.simId}`:""}`,requestsCommand:`sootsim get requests 5${d.simId?` --sim ${d.simId}`:""}`}),D=1}finally{F.close()}if(D===0&&p)try{let c=await Xe(z??[]),u=["--origin",W,"--events",c];re&&u.push("--public-origin",re),v&&u.push("--video",v),v&&E&&Number.isFinite(E)&&u.push("--video-duration-ms",String(Math.round(E))),d.simId&&u.push("--sim",d.simId),Oe&&u.push("--open"),console.log(`
367
+ preparing preview upload\u2026`);let{runUpload:S}=await import("./upload-SSAFKJGF.js");await S(u,{})}catch(c){console.error(` preview upload failed: ${c?.message||c}`),D=1}return K&&(d.simId&&J.add(d.simId),await Ye(b.wsPort,b.commandTimeoutMs,[...J])),await q(),D}async function Ye(o,e,t){let i=[...new Set(t.filter(Boolean))];if(i.length===0)return;let r=X(o,{commandTimeoutMs:e});try{let s=await r.listSims(),n=i.filter(a=>s.some(m=>m.id===a&&m.readyState==="open"));if(n.length===0)return;let l=await $e(r,o,e,n);await Te(s,n),l.closed.length>0&&console.log(` closed flow sim(s): ${l.closed.join(", ")}`),l.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${l.remaining.join(", ")}`)}catch(s){console.warn(` warn: failed to close flow sim(s): ${s instanceof Error?s.message:String(s)}`)}finally{r.close()}}async function Xe(o){let{gzipSync:e}=await import("zlib"),t=o.map(s=>JSON.stringify(s)).join(`
368
+ `)+(o.length?`
369
+ `:""),i=e(Buffer.from(t,"utf8")),r=y.join(Ce(),`sootsim-events-${Date.now()}.jsonl.gz`);return P.writeFileSync(r,i),console.log(` events: ${o.length} written to ${r} (${i.length} bytes gz)`),r}async function Qe(o){let e=o[0],t=i=>o.find((r,s)=>o[s-1]===i);switch(e){case"start":{let{path:i,state:r}=ge();console.log(" flow draft started"),console.log(` session: ${i}`),console.log(` steps: ${r.steps.length}`);return}case"keep":case"good":{let i=te();if(i.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!i.kept){console.log(" no pending action to keep");return}console.log(` kept: ${i.candidate.summary}`),console.log(` steps: ${i.stepCount}`);return}case"end":{let i=t("--output")||(o[1]&&!o[1].startsWith("-")?o[1]:void 0),r=o.includes("--validate")||o.includes("--video"),s=o.includes("--video"),n=te();n.active&&n.kept&&console.log(` auto-kept trailing action: ${n.candidate.summary}`);let l=ye(i||(r?et():void 0));if(l.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!l.valid){console.error(" flow draft is not valid:");for(let a of l.issues)console.error(` - ${a}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim flow start` to reset"),process.exit(1)}if(r){let a=tt(o,l.outputPath),m=await De(a);if(m!==0){console.error(`
370
+ validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=m;return}ee(),console.log(` flow draft validated (${l.stepCount} step${l.stepCount===1?"":"s"})`),l.outputPath&&console.log(` saved: ${l.outputPath}`),s&&console.log(" video: recorded during validation run");return}if(ee(),console.log(` flow draft ended (${l.stepCount} step${l.stepCount===1?"":"s"})`),l.outputPath){console.log(` saved: ${l.outputPath}`),console.log(` next: sootsim flow ${l.outputPath} --record`);return}console.log(""),process.stdout.write(l.yaml);return}case"validate":{let i=o[1];(!i||i.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let r=Z(i);if(r.length>0){console.error(` x ${i} failed validation:`);for(let s of r)console.error(` - ${s}`);process.exit(1)}console.log(` + ${i} looks valid`);return}}}function Ze(o){return o[0]==="--sim"&&o.length>=2?[...o.slice(2),"--sim",o[1]]:o}async function Tt(o){let e=Ze(o),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await Qe(e),0;let i=await De(e);return i!==0&&(process.exitCode=i),i}function _e(o){let e=o.avgMs>0?(1e3/o.avgMs).toFixed(1):"?",t=o.sampleCount>0?(o.jankFrames/o.sampleCount*100).toFixed(1):"0";console.log(`
371
+ profile:`),console.log(` frames: ${o.frames}`),console.log(` total: ${o.totalMs.toFixed(1)}ms`),console.log(` avg: ${o.avgMs.toFixed(2)}ms (${e} fps)`),console.log(` max: ${o.maxMs.toFixed(2)}ms`),o.layoutAvgMs!==void 0&&console.log(` breakdown: layout ${o.layoutAvgMs.toFixed(2)}ms | render ${o.renderAvgMs?.toFixed(2)||"0.00"}ms | copy ${o.copyAvgMs?.toFixed(2)||"0.00"}ms`),console.log(` p95: ${o.p95.toFixed(2)}ms`),console.log(` p99: ${o.p99.toFixed(2)}ms`),console.log(` jank: ${o.jankFrames}/${o.sampleCount} (${t}%) >16.67ms`);let i=Array.isArray(o.worstFrames)?o.worstFrames:[];if(i.length!==0){if(console.log(`
372
+ worst frames:`),o.mode==="render-worker"){console.log(" total layout render copy t+");for(let r of i){let[s,n,l,a,m]=r;console.log(` ${n.toFixed(2).padStart(7)} ${l.toFixed(2).padStart(7)} ${a.toFixed(2).padStart(7)} ${m.toFixed(2).padStart(7)} ${String(s).padStart(5)}`)}return}console.log(` ${i.map(r=>r.toFixed(2)).join(", ")}`)}}function et(){return y.join(Ce(),`sootsim-flow-draft-${Date.now()}.yaml`)}function tt(o,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let i=1;i<o.length;i++){let r=o[i];if(!(r==="--validate"||r==="--video")){if(r==="--output"){i+=1;continue}i===1&&!r.startsWith("-")||t.push(r)}}return!t.includes("--record")&&o.includes("--video")&&t.push("--record"),t}export{Ge as a,De as b,Ze as c,Tt as d};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.66 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.68 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  var d=Object.defineProperty;var e=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var f=(a,b)=>{for(var c in b)d(a,c,{get:b[c],enumerable:!0})};export{e as a,f as b};
@@ -0,0 +1 @@
1
+ /*! sootsim v0.1.68 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.66 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- function T(e,t){let n=["--max-ms","--maxMs","--maxms","--max_ms"];for(let r of n){let s=e.indexOf(r);if(s>=0&&e[s+1]){let i=Number(e[s+1]);if(Number.isFinite(i))return Math.max(100,i)}}return t}async function v(e){let t=await e.send({type:"evaluate",code:"(async () => await window.__sootsimTest.getNodeCount())()"});return{nodes:typeof t=="number"?t:0}}async function I(e,t=5){let n=await e.send({type:"evaluate",code:`(async () => await window.__sootsimTest.dumpTree(${t}))()`});return{depth:t,tree:n}}async function _(e){let t=await e.send({type:"evaluate",code:"window.location.href"});return{url:typeof t=="string"?t:""}}async function k(e,t){let n=`(async () => {
1
+ /*! sootsim v0.1.68 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ function k(e,t){let n=["--max-ms","--maxMs","--maxms","--max_ms"];for(let r of n){let s=e.indexOf(r);if(s>=0&&e[s+1]){let a=Number(e[s+1]);if(Number.isFinite(a))return Math.max(100,a)}}return t}async function E(e){let t=await e.send({type:"evaluate",code:"(async () => await window.__sootsimTest.getNodeCount())()"});return{nodes:typeof t=="number"?t:0}}async function P(e,t=5){let n=await e.send({type:"evaluate",code:`(async () => await window.__sootsimTest.dumpTree(${t}))()`});return{depth:t,tree:n}}async function A(e){let t=await e.send({type:"evaluate",code:"window.location.href"});return{url:typeof t=="string"?t:""}}async function L(e,t){let n=`(async () => {
3
3
  const t = window.__sootsimTest
4
4
  const mainShell = window.SootSim?.bridges?.mainShell
5
5
  const kb = window.__sootsimKeyboard
@@ -14,7 +14,7 @@ function T(e,t){let n=["--max-ms","--maxMs","--maxms","--max_ms"];for(let r of n
14
14
  const nodeCount = (await t.getNodeCount?.()) || 0
15
15
  const keyboard = kb && typeof kb.getLayout === 'function' ? kb.getLayout() : null
16
16
  return { tree, shell, nodeCount, keyboard }
17
- })()`;return await e.send({type:"evaluate",code:n})??{}}var y=`(async () => {
17
+ })()`;return await e.send({type:"evaluate",code:n})??{}}var m=`(async () => {
18
18
  const t = window.__sootsimTest
19
19
  if (!t) return []
20
20
 
@@ -87,7 +87,7 @@ function T(e,t){let n=["--max-ms","--maxMs","--maxms","--max_ms"];for(let r of n
87
87
  return all
88
88
  .filter(n => isVisibleTarget(n) && hasAccessibleSignal(n))
89
89
  .map(normalize)
90
- })()`;async function E(e){let t=await e.send({type:"evaluate",code:y});return Array.isArray(t)?t:[]}var l=`
90
+ })()`;async function D(e){let t=await e.send({type:"evaluate",code:m});return Array.isArray(t)?t:[]}var y=`
91
91
  const fromInspectable = async () => {
92
92
  if (typeof t.listInspectable !== 'function') return null
93
93
  const list = await t.listInspectable({})
@@ -159,19 +159,19 @@ function T(e,t){let n=["--max-ms","--maxMs","--maxms","--max_ms"];for(let r of n
159
159
  abs.y < screenH
160
160
  )
161
161
  }
162
- `;function p(e){return e.testId?{mode:"testid",code:`(async () => {
162
+ `;function f(e){return e.testId?{mode:"testid",code:`(async () => {
163
163
  const t = window.__sootsimTest
164
164
  return (await t.findByTestId(${JSON.stringify(e.testId)})) || (await t.findById(${JSON.stringify(e.testId)}))
165
165
  })()`}:e.role?{mode:"role",code:`(async () => await window.__sootsimTest.queryAll({ hasRole: ${JSON.stringify(e.role)}, pruneHidden: true }))()`}:e.type?{mode:"type",code:`(async () => await window.__sootsimTest.queryAll({ type: ${JSON.stringify(e.type)}, pruneHidden: true }))()`}:e.pressable?{mode:"pressable",code:`(async () => {
166
166
  const t = window.__sootsimTest
167
- ${l}
167
+ ${y}
168
168
  const inspectable = await fromInspectable()
169
169
  if (inspectable) return inspectable.filter(n => n.pressable && isVisibleTarget(n))
170
170
  const all = await t.queryAll({ pruneHidden: true })
171
171
  return all.filter(n => n.pressable && isVisibleTarget(n))
172
172
  })()`}:e.interactive?{mode:"interactive-targets",code:`(async () => {
173
173
  const t = window.__sootsimTest
174
- ${l}
174
+ ${y}
175
175
  const inspectable = await fromInspectable()
176
176
  if (inspectable) {
177
177
  return inspectable.filter(n => n.pressable && isVisibleTarget(n))
@@ -181,7 +181,7 @@ ${l}
181
181
  })()`}:e.visible?{mode:"visible",code:`(async () => {
182
182
  const all = await window.__sootsimTest.queryAll({ pruneHidden: true })
183
183
  return all.filter(n => n.layout && n.layout.width > 0 && n.layout.height > 0)
184
- })()`}:e.text?{mode:"text",code:`(async () => await window.__sootsimTest.findByText(${JSON.stringify(e.text)}))()`}:null}async function R(e,t){let n=p(t);if(!n)return null;let r=await e.send({type:"evaluate",code:n.code});return{mode:n.mode,result:r}}function P(e){return[...e].sort((t,n)=>c(n)-c(t))}function c(e){let t=0;e.testID&&(t+=100),typeof e.text=="string"&&e.text.trim().length>0&&(t+=60),typeof e.accessibilityLabel=="string"&&e.accessibilityLabel.trim().length>0&&(t+=30),e.accessibilityRole&&(t+=15);let n=e.layout?.width??0,r=e.layout?.height??0,s=n*r;return s>=400&&s<=6e4?t+=25:s>6e4&&(t-=20),(e.absolutePosition?.y??0)<0&&(t-=30),t}function A(e){if(e.testID)return`sootsim do tap-id ${u(e.testID)}`;let t=typeof e.text=="string"?e.text.trim():"";if(t.length>0&&t.length<=80)return`sootsim do tap-text ${u(t)}`;let n=Math.round(((e.absolutePosition?.x??0)+(e.layout?.width??0)/2)*10)/10,r=Math.round(((e.absolutePosition?.y??0)+(e.layout?.height??0)/2)*10)/10;return`sootsim do tap ${n} ${r}`}function u(e){return/^[A-Za-z0-9_./@:-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var b=`(async () => {
184
+ })()`}:e.text?{mode:"text",code:`(async () => await window.__sootsimTest.findByText(${JSON.stringify(e.text)}))()`}:null}async function N(e,t){let n=f(t);if(!n)return null;let r=await e.send({type:"evaluate",code:n.code});return{mode:n.mode,result:r}}function H(e){return[...e].sort((t,n)=>p(n)-p(t))}function p(e){let t=0;e.testID&&(t+=100),typeof e.text=="string"&&e.text.trim().length>0&&(t+=60),typeof e.accessibilityLabel=="string"&&e.accessibilityLabel.trim().length>0&&(t+=30),e.accessibilityRole&&(t+=15);let n=e.layout?.width??0,r=e.layout?.height??0,s=n*r;return s>=400&&s<=6e4?t+=25:s>6e4&&(t-=20),(e.absolutePosition?.y??0)<0&&(t-=30),t}function B(e){if(e.testID)return`sootsim do tap-id ${g(e.testID)}`;let t=typeof e.text=="string"?e.text.trim():"";if(t.length>0&&t.length<=80)return`sootsim do tap-text ${g(t)}`;let n=Math.round(((e.absolutePosition?.x??0)+(e.layout?.width??0)/2)*10)/10,r=Math.round(((e.absolutePosition?.y??0)+(e.layout?.height??0)/2)*10)/10;return`sootsim do tap ${n} ${r}`}function g(e){return/^[A-Za-z0-9_./@:-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var w=`(async () => {
185
185
  const t = window.__sootsimTest
186
186
  let nodes = 0
187
187
  try { nodes = (await t?.getNodeCount?.()) || 0 } catch {}
@@ -276,7 +276,7 @@ ${l}
276
276
  externalStatus,
277
277
  externalError,
278
278
  }
279
- })()`,g=50,m=100,f=750;function w(e){return e.targets>0||e.nodes>=m}async function L(e,t=2e4){let n=Date.now(),r=n+t,s=-1,i=n,o={flag:void 0,at:0,nodes:0,targets:0,errors:0,loadingText:"",externalReady:null,externalStatus:"",externalError:""};for(;Date.now()<r;){try{o=await e.send({type:"evaluate",code:b})??o}catch{}let a=Date.now();if(o.nodes!==s&&(s=o.nodes,i=a),o.flag===!0&&o.externalReady!==!1&&!o.externalError&&!o.loadingText&&o.nodes>=g&&w(o)&&a-i>=f)return{ready:!0,elapsedMs:a-n,nodes:o.nodes,targets:o.targets,flag:o.flag,loadingText:o.loadingText,externalReady:o.externalReady,externalStatus:o.externalStatus,externalError:o.externalError,errors:o.errors};await new Promise(d=>setTimeout(d,150))}return{ready:!1,elapsedMs:Date.now()-n,nodes:o.nodes,targets:o.targets,flag:o.flag,loadingText:o.loadingText,externalReady:o.externalReady,externalStatus:o.externalStatus,externalError:o.externalError,errors:o.errors}}async function D(e,t,n=5e3){return await e.send({type:"evaluate",code:`(async () => {
279
+ })()`,h=50,x=100,S=750,T=2e3;function v(e){return e.targets>0||e.nodes>=x}function C(e){return e.externalError?`guest app errored: ${e.externalError}`:e.loadingText?`still showing "${e.loadingText}"`:e.externalReady===!1?"guest app is still loading":e.flag!==!0?"guest app has not emitted sootsim:externalAppReady":e.targets<=0?"ready flag emitted but no visible app content is inspectable yet":"node tree is still changing"}async function M(e,t=2e4,n={}){let r=Date.now(),s=r+t,a=n.progressIntervalMs??T,l=r+a,c=-1,u=r,o={flag:void 0,at:0,nodes:0,targets:0,errors:0,loadingText:"",externalReady:null,externalStatus:"",externalError:""};for(;Date.now()<s;){try{o=await e.send({type:"evaluate",code:w})??o}catch{}let i=Date.now(),d={ready:!1,elapsedMs:i-r,nodes:o.nodes,targets:o.targets,flag:o.flag,loadingText:o.loadingText,externalReady:o.externalReady,externalStatus:o.externalStatus,externalError:o.externalError,errors:o.errors};if(o.nodes!==c&&(c=o.nodes,u=i),o.flag===!0&&o.externalReady!==!1&&!o.externalError&&!o.loadingText&&o.nodes>=h&&v(o)&&i-u>=S)return{...d,ready:!0};if(n.onProgress&&a>0&&i>=l){n.onProgress(d);do l+=a;while(i>=l)}await new Promise(b=>setTimeout(b,150))}return{ready:!1,elapsedMs:Date.now()-r,nodes:o.nodes,targets:o.targets,flag:o.flag,loadingText:o.loadingText,externalReady:o.externalReady,externalStatus:o.externalStatus,externalError:o.externalError,errors:o.errors}}async function $(e,t,n=5e3){return await e.send({type:"evaluate",code:`(async () => {
280
280
  const start = Date.now()
281
281
  const deadline = start + ${n}
282
282
  const t = window.__sootsimTest
@@ -295,17 +295,17 @@ ${l}
295
295
  await new Promise((r) => setTimeout(r, 80))
296
296
  }
297
297
  return { found: false, elapsed: Date.now() - start }
298
- })()`})??{found:!1,elapsed:n}}async function N(e,t=20){let n=await e.send({type:"evaluate",code:`window.__sootsimConsole?.getErrors(${t}) || []`});return Array.isArray(n)?n:[]}async function H(e,t=20){let n=await e.send({type:"evaluate",code:`window.__sootsimConsole?.getWarnings(${t}) || []`});return Array.isArray(n)?n:[]}async function B(e){await e.send({type:"evaluate",code:'window.__sootsimConsole?.clear(); "cleared"'})}async function C(e,t={}){let n=t.limit??20,r=t.failed===!1?"getRequests":"getFailedRequests",s=await e.send({type:"call",path:`__sootsimTest.${r}`,args:[n]});return Array.isArray(s)?s:[]}async function M(e){await e.send({type:"call",path:"__sootsimTest.clearRequests",args:[]})}async function $(e){let t=await e.send({type:"evaluate",code:`(() => {
298
+ })()`})??{found:!1,elapsed:n}}async function O(e,t=20){let n=await e.send({type:"evaluate",code:`window.__sootsimConsole?.getErrors(${t}) || []`});return Array.isArray(n)?n:[]}async function W(e,t=20){let n=await e.send({type:"evaluate",code:`window.__sootsimConsole?.getWarnings(${t}) || []`});return Array.isArray(n)?n:[]}async function F(e){await e.send({type:"evaluate",code:'window.__sootsimConsole?.clear(); "cleared"'})}async function z(e,t={}){let n=t.limit??20,r=t.failed===!1?"getRequests":"getFailedRequests",s=await e.send({type:"call",path:`__sootsimTest.${r}`,args:[n]});return Array.isArray(s)?s:[]}async function K(e){await e.send({type:"call",path:"__sootsimTest.clearRequests",args:[]})}async function J(e){let t=await e.send({type:"evaluate",code:`(() => {
299
299
  const obs = window.__sootsimObservability;
300
300
  if (!obs) return { ok: false };
301
301
  return { ok: true, entries: obs.logs.getSnapshot() };
302
- })()`});if(!t||!t.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return t.entries??[]}async function O(e){await e.send({type:"evaluate",code:'window.__sootsimObservability?.logs.clear(); "cleared"'})}function h(e,t){if(e.source===t.source||e.level!==t.level||Math.abs(e.ts-t.ts)>1e3||e.args.length!==t.args.length)return!1;let n=new Set([e.source,t.source]);return!n.has("sootsim-worker")||!n.has("render-worker")&&!n.has("forwarded-render-worker")?!1:e.args.every((r,s)=>r===t.args[s])}function F(e,t={}){let n=[];for(let r of e)n.some(s=>h(s,r))||n.push(r);if(t.showInternal||(n=n.filter(r=>{let s=r.args[0];return!(typeof s=="string"&&s.startsWith("[sootsim]"))})),t.level&&(n=n.filter(r=>t.level.has(r.level))),t.filter){let r=t.filter.toLowerCase();n=n.filter(s=>s.args.join(" ").toLowerCase().includes(r))}return n}async function W(e,t){return await e.send({type:"call",path:"SootSim.bridges.timeline.summary",args:[t]})}async function z(e,t){return await e.send({type:"call",path:"SootSim.bridges.timeline.recent",args:[t]})}async function K(e,t,n){await e.send({type:"call",path:"SootSim.bridges.timeline.cursorAdvance",args:[t,n]})}async function J(e){return await e.send({type:"evaluate",code:`(() => {
302
+ })()`});if(!t||!t.ok)throw new Error("observability bridge not installed \u2014 is the engine running?");return t.entries??[]}async function V(e){await e.send({type:"evaluate",code:'window.__sootsimObservability?.logs.clear(); "cleared"'})}function I(e,t){if(e.source===t.source||e.level!==t.level||Math.abs(e.ts-t.ts)>1e3||e.args.length!==t.args.length)return!1;let n=new Set([e.source,t.source]);return!n.has("sootsim-worker")||!n.has("render-worker")&&!n.has("forwarded-render-worker")?!1:e.args.every((r,s)=>r===t.args[s])}function j(e,t={}){let n=[];for(let r of e)n.some(s=>I(s,r))||n.push(r);if(t.showInternal||(n=n.filter(r=>{let s=r.args[0];return!(typeof s=="string"&&s.startsWith("[sootsim]"))})),t.level&&(n=n.filter(r=>t.level.has(r.level))),t.filter){let r=t.filter.toLowerCase();n=n.filter(s=>s.args.join(" ").toLowerCase().includes(r))}return n}async function Q(e,t){return await e.send({type:"call",path:"SootSim.bridges.timeline.summary",args:[t]})}async function Y(e,t){return await e.send({type:"call",path:"SootSim.bridges.timeline.recent",args:[t]})}async function q(e,t,n){await e.send({type:"call",path:"SootSim.bridges.timeline.cursorAdvance",args:[t,n]})}async function G(e){return await e.send({type:"evaluate",code:`(() => {
303
303
  const kb = window.__sootsimKeyboard
304
304
  if (!kb || typeof kb.getLayout !== 'function') {
305
305
  return { error: 'keyboard bridge getLayout() not available' }
306
306
  }
307
307
  return kb.getLayout()
308
- })()`})??{error:"keyboard bridge returned no result"}}function x(e){let t=e instanceof Error?e.message:String(e);return t.includes("call target not found: SootSim.bridges.mainShell")||t.includes("test bridge unavailable before app-in-worker boot")}async function S(e,t=0){let n=Date.now()+Math.max(0,t);for(;;)try{return await e.send({type:"call",path:"SootSim.bridges.mainShell.getState",args:[]})}catch(r){if(!x(r)||Date.now()>=n)throw r;await new Promise(s=>setTimeout(s,50))}}async function V(e){let t=await e.send({type:"evaluate",code:`(async () => {
308
+ })()`})??{error:"keyboard bridge returned no result"}}function _(e){let t=e instanceof Error?e.message:String(e);return t.includes("call target not found: SootSim.bridges.mainShell")||t.includes("test bridge unavailable before app-in-worker boot")}async function R(e,t=0){let n=Date.now()+Math.max(0,t);for(;;)try{return await e.send({type:"call",path:"SootSim.bridges.mainShell.getState",args:[]})}catch(r){if(!_(r)||Date.now()>=n)throw r;await new Promise(s=>setTimeout(s,50))}}async function U(e){let t=await e.send({type:"evaluate",code:`(async () => {
309
309
  const test = window.__sootsimTest
310
310
  const kb = window.__sootsimKeyboard
311
311
  const navSnap =
@@ -329,7 +329,7 @@ ${l}
329
329
  })()
330
330
  : null
331
331
  return { nav: navSnap, keyboard }
332
- })()`});return{shell:await S(e,500).catch(()=>null),nav:t?.nav??null,keyboard:t?.keyboard??null}}async function j(e){return e.send({type:"evaluate",code:"window.__sootsimDebug.status()"})}async function Q(e){return e.send({type:"evaluate",code:"window.__sootsimDebug.flags()"})}async function Y(e,t){let n=t==="sheets"?"findSheets":"findPortals";return e.send({type:"evaluate",code:`window.__sootsimDebug.${n}()`})}async function q(e,t,n=50){let r=t&&t!=="all"?`window.__sootsimDebug.recent(${JSON.stringify(t)}, ${n})`:`window.__sootsimDebug.recent(undefined, ${n})`;return e.send({type:"evaluate",code:r})}async function U(e,t,n){let r=n.length>0?n.map(s=>JSON.stringify(s)).join(", "):t==="disable"?"'all'":"";return e.send({type:"evaluate",code:`window.__sootsimDebug.${t}(${r})`})}async function G(e){return await e.send({type:"evaluate",code:`(async () => {
332
+ })()`});return{shell:await R(e,500).catch(()=>null),nav:t?.nav??null,keyboard:t?.keyboard??null}}async function X(e){return e.send({type:"evaluate",code:"window.__sootsimDebug.status()"})}async function Z(e){return e.send({type:"evaluate",code:"window.__sootsimDebug.flags()"})}async function ee(e,t){let n=t==="sheets"?"findSheets":"findPortals";return e.send({type:"evaluate",code:`window.__sootsimDebug.${n}()`})}async function te(e,t,n=50){let r=t&&t!=="all"?`window.__sootsimDebug.recent(${JSON.stringify(t)}, ${n})`:`window.__sootsimDebug.recent(undefined, ${n})`;return e.send({type:"evaluate",code:r})}async function ne(e,t,n){let r=n.length>0?n.map(s=>JSON.stringify(s)).join(", "):t==="disable"?"'all'":"";return e.send({type:"evaluate",code:`window.__sootsimDebug.${t}(${r})`})}async function re(e){return await e.send({type:"evaluate",code:`(async () => {
333
333
  const host = window.__sootsimRenderHost
334
334
  const stats = host?.queryStats ? await host.queryStats() : null
335
335
  const hostMem = performance.memory
@@ -344,4 +344,4 @@ ${l}
344
344
  workerHeap: stats?.memory?.workerHeap ?? null,
345
345
  hostHeap: hostMem,
346
346
  }
347
- })()`})??{imageLoader:null,workerHeap:null,hostHeap:null}}function X(e){if(e.total===0)return"nothing recorded";let t=[],n=["error","warning","console","fetch","toast","alert","actionsheet","picker","notification","screen","route","keyboard","app-launch","shell","scroll","gesture","text-input","react-commit","animation","reanimated"],r=new Set;for(let s of n){let i=e.byKind[s];i&&(t.push(`${i} ${s}${i===1?"":"s"}`),r.add(s))}for(let[s,i]of Object.entries(e.byKind))!r.has(s)&&i&&t.push(`${i} ${s}${i===1?"":"s"}`);return t.join(" \xB7 ")}export{T as a,v as b,I as c,_ as d,k as e,E as f,R as g,P as h,A as i,b as j,g as k,f as l,w as m,L as n,D as o,N as p,H as q,B as r,C as s,M as t,$ as u,O as v,F as w,W as x,z as y,K as z,J as A,x as B,S as C,V as D,j as E,Q as F,Y as G,q as H,U as I,G as J,X as K};
347
+ })()`})??{imageLoader:null,workerHeap:null,hostHeap:null}}function se(e){if(e.total===0)return"nothing recorded";let t=[],n=["error","warning","console","fetch","toast","alert","actionsheet","picker","notification","screen","route","keyboard","app-launch","shell","scroll","gesture","text-input","react-commit","animation","reanimated"],r=new Set;for(let s of n){let a=e.byKind[s];a&&(t.push(`${a} ${s}${a===1?"":"s"}`),r.add(s))}for(let[s,a]of Object.entries(e.byKind))!r.has(s)&&a&&t.push(`${a} ${s}${a===1?"":"s"}`);return t.join(" \xB7 ")}export{k as a,E as b,P as c,A as d,L as e,D as f,N as g,H as h,B as i,w as j,h as k,S as l,v as m,C as n,M as o,$ as p,O as q,W as r,F as s,z as t,K as u,J as v,V as w,j as x,Q as y,Y as z,q as A,G as B,_ as C,R as D,U as E,X as F,Z as G,ee as H,te as I,ne as J,re as K,se as L};
@@ -1,2 +1,2 @@
1
- /*! sootsim v0.1.66 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.68 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import{execFileSync as p,spawn as l}from"child_process";import{existsSync as s}from"fs";import{homedir as u}from"os";import{join as d}from"path";var g=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","~/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium","~/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","~/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","~/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Arc.app/Contents/MacOS/Arc","~/Applications/Arc.app/Contents/MacOS/Arc"],f=["/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser","/usr/bin/microsoft-edge","/usr/bin/brave-browser","/snap/bin/chromium"],h=["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe","C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe","C:\\Program Files\\BraveSoftware\\Brave-Browser\\Application\\brave.exe","C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe"],C=["google-chrome","chromium","chromium-browser","microsoft-edge","brave-browser"],O=["chrome","msedge","brave"];function w(r){return r.startsWith("~/")?d(u(),r.slice(2)):r}function a(r){for(let n of r){let o=w(n);if(s(o))return o}return null}function U(r,n){try{let e=p(n==="win32"?"where":"which",[r],{encoding:"utf8",timeout:1500,stdio:["ignore","pipe","ignore"]}).trim();return e?e.split(/\r?\n/)[0]:null}catch{return null}}function M(r=process.platform){let n=process.env.CHROME_PATH||process.env.CHROMIUM_PATH;if(n&&s(n))return n;let o=a(r==="darwin"?g:r==="win32"?h:f);if(o)return o;let e=r==="win32"?O:C;for(let t of e){let i=U(t,r);if(i)return i}return null}function A(r,n={}){if(!r)throw new Error("openUrl requires a url");let o=n.platform??process.platform;return n.newWindow?c(r,{...n,platform:o,newWindow:!0}):o==="darwin"?{command:"open",args:n.background===!1?[r]:["-g",r],via:"system"}:o==="win32"?{command:"cmd",args:["/c","start","",r],via:"system"}:{command:"xdg-open",args:[r],via:"system"}}function c(r,n={}){if(!r)throw new Error("openUrl requires a url");let o=n.platform??process.platform,e="chromiumBinary"in n?n.chromiumBinary:M(o);if(!e)throw new Error("browser launch requires Chrome, Chromium, Edge, Brave, or Arc");let t=[];return n.newWindow!==!1&&t.push("--new-window"),t.push(r),{command:e,args:t,via:"chromium",target:e}}async function m(r,n,o){return new Promise((e,t)=>{let i=l(r,n,{detached:o,stdio:"ignore"});i.once("error",t),i.once("spawn",()=>{o&&i.unref(),e(i.pid)})})}async function x(r,n={}){let o=A(r,n),e=await m(o.command,o.args,n.detached??!0);return{...o,pid:e,attachUrl:r}}async function y(r,n={}){let o=c(r,n),e=await m(o.command,o.args,n.detached??!0);return{...o,pid:e,attachUrl:r}}async function E(r,n={}){await x(r,n)}export{M as a,x as b,y as c,E as d};
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.66 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! sootsim v0.1.68 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  import{createInterface as i}from"readline";var c=()=>i({input:process.stdin,output:process.stdout});function s(o){return new Promise(n=>{let r=c();r.question(o,t=>{r.close(),n(t.trim())})})}async function u(o,n=!0){let r=n?"[Y/n]":"[y/N]";if(!process.stdin.isTTY)return console.log(` ${o} ${r} ${n?"y":"n"} (non-interactive)`),n;let t=await s(` ${o} ${r} `);return t===""?n:t.toLowerCase().startsWith("y")}async function a(o,n){console.log(`
3
3
  ${o}
4
4
  `);for(let e=0;e<n.length;e++)console.log(` ${e+1}. ${n[e]}`);if(console.log(),!process.stdin.isTTY)return console.log(` choose [1-${n.length}]: 1 (non-interactive)`),0;let r=await s(` choose [1-${n.length}]: `),t=parseInt(r,10);return t>=1&&t<=n.length?t-1:0}export{u as a,a as b};
@@ -1,4 +1,4 @@
1
- /*! sootsim v0.1.66 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{A as R,C as w,i as p,r as S,t as O,y as v,z as f}from"./chunk-BEQD2DSK.js";import{spawn as I}from"child_process";import C from"crypto";import s from"fs";import l from"path";import{Readable as k}from"stream";import{pipeline as M}from"stream/promises";var N="https://sootbean.com",D="SOOTSIM_CDN_ORIGIN",E="SOOTSIM_RUNTIME_CHANNEL";function $(){try{let e=JSON.parse(s.readFileSync(O(),"utf8"));return e&&typeof e=="object"?e:{}}catch{return{}}}function d(e){let t=$();return(e||process.env[D]||t.cdnOrigin||N).replace(/\/+$/,"")}function x(e){let t=$();return e||process.env[E]||t.runtimeChannel||"stable"}function T(e){let t=new URL(`${d(e)}/runtimes/manifest.json`);return t.searchParams.set("t",String(Date.now())),t.toString()}function P(e,t){return`${d(t)}/runtimes/sootsim-runtime-${e}.tar.gz`}async function y(e){let t=T(e),r=await fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`manifest fetch failed: ${r.status} ${r.statusText} (${t})`);return await r.json()}function U(e,t={}){let r=x(t.channel),n=t.version||e.channels[r]?.latest;if(!n)throw new Error(`no version specified and channel '${r}' has no latest entry in the manifest`);let i=e.versions[n];if(!i)throw new Error(`version ${n} not found in manifest; available: ${Object.keys(e.versions).slice(-10).join(", ")||"(none)"}`);return{version:n,channel:r,entry:i}}async function V(e={}){v();let t=d(e.cdnOrigin),r=await y(t),{version:n,channel:i,entry:o}=U(r,e),a=p(n),c=e.setActive!==!1;if(!e.force&&s.existsSync(l.join(a,"index.html")))return c&&R(n),{version:n,channel:i,cdnOrigin:t,runtimeDir:a,installed:!1,activated:c,manifest:r};let g=o.tarball||P(n,t),m=l.join(S(),`sootsim-runtime-${n}.tar.gz`);process.stderr.write(`sootsim: downloading runtime ${n}\u2026
1
+ /*! sootsim v0.1.68 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{A as R,C as w,i as p,r as S,t as O,y as v,z as f}from"./chunk-G3WXMB3Z.js";import{spawn as I}from"child_process";import C from"crypto";import s from"fs";import l from"path";import{Readable as k}from"stream";import{pipeline as M}from"stream/promises";var N="https://sootbean.com",D="SOOTSIM_CDN_ORIGIN",E="SOOTSIM_RUNTIME_CHANNEL";function $(){try{let e=JSON.parse(s.readFileSync(O(),"utf8"));return e&&typeof e=="object"?e:{}}catch{return{}}}function d(e){let t=$();return(e||process.env[D]||t.cdnOrigin||N).replace(/\/+$/,"")}function x(e){let t=$();return e||process.env[E]||t.runtimeChannel||"stable"}function T(e){let t=new URL(`${d(e)}/runtimes/manifest.json`);return t.searchParams.set("t",String(Date.now())),t.toString()}function P(e,t){return`${d(t)}/runtimes/sootsim-runtime-${e}.tar.gz`}async function y(e){let t=T(e),r=await fetch(t,{headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`manifest fetch failed: ${r.status} ${r.statusText} (${t})`);return await r.json()}function U(e,t={}){let r=x(t.channel),n=t.version||e.channels[r]?.latest;if(!n)throw new Error(`no version specified and channel '${r}' has no latest entry in the manifest`);let i=e.versions[n];if(!i)throw new Error(`version ${n} not found in manifest; available: ${Object.keys(e.versions).slice(-10).join(", ")||"(none)"}`);return{version:n,channel:r,entry:i}}async function V(e={}){v();let t=d(e.cdnOrigin),r=await y(t),{version:n,channel:i,entry:o}=U(r,e),a=p(n),c=e.setActive!==!1;if(!e.force&&s.existsSync(l.join(a,"index.html")))return c&&R(n),{version:n,channel:i,cdnOrigin:t,runtimeDir:a,installed:!1,activated:c,manifest:r};let g=o.tarball||P(n,t),m=l.join(S(),`sootsim-runtime-${n}.tar.gz`);process.stderr.write(`sootsim: downloading runtime ${n}\u2026
3
3
  `),await _(g,m),process.stderr.write(`sootsim: extracting runtime ${n}\u2026
4
4
  `);let h=await j(m);if(h!==o.sha256)throw s.rmSync(m,{force:!0}),new Error(`sha256 mismatch for runtime ${n}: expected ${o.sha256}, actual ${h}`);let u=l.join(l.dirname(a),`.installing-${n}-${process.pid}`);s.rmSync(u,{recursive:!0,force:!0}),s.mkdirSync(u,{recursive:!0});try{if(await A(m,u),!s.existsSync(l.join(u,"index.html")))throw new Error(`extracted tarball for runtime ${n} is missing index.html`);s.rmSync(a,{recursive:!0,force:!0}),s.renameSync(u,a)}catch(b){throw s.rmSync(u,{recursive:!0,force:!0}),b}return c&&R(n),{version:n,channel:i,cdnOrigin:t,runtimeDir:a,installed:!0,activated:c,manifest:r}}async function q(e={}){v();let t=d(e.cdnOrigin),r=x(e.channel),n=await y(t),i=n.channels[r]?.latest;if(!i)return{checked:!0,updated:!1,reason:`channel '${r}' has no latest runtime`,activeVersion:f()};if(!n.versions[i])return{checked:!0,updated:!1,reason:`manifest is missing version ${i}`,activeVersion:f(),latestVersion:i};let a=f(),c=a?p(a):null,g=c?s.existsSync(l.join(c,"index.html")):!1;if(!(!a||!g||w(i,a)>0))return{checked:!0,updated:!1,reason:"active runtime is current",activeVersion:a,latestVersion:i};let h=await V({version:i,channel:r,cdnOrigin:t,setActive:!1});return{checked:!0,updated:!0,activeVersion:i,latestVersion:i,install:h}}async function B(e={}){let t=f();try{let r=await y(d(e.cdnOrigin)),n=x(e.channel),i=r.channels[n]?.latest??null,o=!!(i&&(!t||w(i,t)>0));return{active:t,latest:i,outdated:o}}catch{return{active:t,latest:null,outdated:!1}}}async function _(e,t){let r=await fetch(e);if(!r.ok||!r.body)throw new Error(`download failed: ${r.status} ${r.statusText} (${e})`);s.mkdirSync(l.dirname(t),{recursive:!0});let n=`${t}.partial`;try{await M(k.fromWeb(r.body),s.createWriteStream(n)),s.renameSync(n,t)}catch(i){try{s.unlinkSync(n)}catch{}throw i}}function j(e){return new Promise((t,r)=>{let n=C.createHash("sha256"),i=s.createReadStream(e);i.on("data",o=>n.update(o)),i.on("error",r),i.on("end",()=>t(n.digest("hex")))})}function A(e,t){return new Promise((r,n)=>{let i=I("tar",["-xzf",e,"-C",t],{stdio:["ignore","inherit","inherit"]});i.on("error",n),i.on("exit",o=>{o===0?r():n(new Error(`tar exited with code ${o}`))})})}export{N as a,D as b,E as c,d,x as e,T as f,P as g,y as h,U as i,V as j,q as k,B as l};