rnxsim 0.1.375 → 0.1.376

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 (193) hide show
  1. package/cli/commands/control.ts +18 -4
  2. package/dist-cli/bin.js +5 -5
  3. package/dist-cli/chunks/{agent-JJN7U6FR.js → agent-H42FCKFF.js} +2 -2
  4. package/dist-cli/chunks/{agent-wrapper-AVVUJ3WF.js → agent-wrapper-BBZKTZS6.js} +2 -2
  5. package/dist-cli/chunks/{app-fonts-QJ22CNAZ.js → app-fonts-43VXIKF4.js} +2 -2
  6. package/dist-cli/chunks/{assert-PZZKIY3K.js → assert-IXOLVO5Z.js} +2 -2
  7. package/dist-cli/chunks/{auth-5AVDJO33.js → auth-KFMFB6FU.js} +2 -2
  8. package/dist-cli/chunks/{beta-PFRGP266.js → beta-5AO3SJB7.js} +2 -2
  9. package/dist-cli/chunks/{box-ILC2O7ZO.js → box-ZHM66L6K.js} +44 -44
  10. package/dist-cli/chunks/{camera-J3V62PP7.js → camera-FNJVFCDQ.js} +2 -2
  11. package/dist-cli/chunks/{chunk-CCMZSHJB.js → chunk-37MCSPTE.js} +1 -1
  12. package/dist-cli/chunks/{chunk-FUTYK55H.js → chunk-3PEMSUAQ.js} +3 -3
  13. package/dist-cli/chunks/chunk-4TQ5HOK3.js +7 -0
  14. package/dist-cli/chunks/{chunk-25KRGDZT.js → chunk-5YZYDEMI.js} +1 -1
  15. package/dist-cli/chunks/{chunk-OJNKRIZF.js → chunk-6CV3R3XD.js} +2 -2
  16. package/dist-cli/chunks/{chunk-5HHWECGT.js → chunk-7LGK5XU6.js} +2 -2
  17. package/dist-cli/chunks/{chunk-K7QQWKGE.js → chunk-7R2TK2NY.js} +1 -1
  18. package/dist-cli/chunks/{chunk-EZXV6U2N.js → chunk-7VZZQQEE.js} +3 -3
  19. package/dist-cli/chunks/{chunk-XUBV77WH.js → chunk-AFOVILIL.js} +1 -1
  20. package/dist-cli/chunks/{chunk-S65CK3RI.js → chunk-BEU7CD7E.js} +1 -1
  21. package/dist-cli/chunks/{chunk-F5F7FIPM.js → chunk-CE4JQJ6Y.js} +2 -2
  22. package/dist-cli/chunks/{chunk-RLCQLMFF.js → chunk-CIE6CZXL.js} +2 -2
  23. package/dist-cli/chunks/{chunk-5PZVYF42.js → chunk-CSJ7L7ZL.js} +1 -1
  24. package/dist-cli/chunks/{chunk-7NCPUZ52.js → chunk-CWCQP53A.js} +2 -2
  25. package/dist-cli/chunks/{chunk-Z6LOIW46.js → chunk-DCS5FK5N.js} +1 -1
  26. package/dist-cli/chunks/{chunk-MXJ2UWRV.js → chunk-DEV3E3MV.js} +1 -1
  27. package/dist-cli/chunks/{chunk-H4MYYOYJ.js → chunk-DGJMIVZM.js} +2 -2
  28. package/dist-cli/chunks/{chunk-GEX7RVHY.js → chunk-DGX3MN65.js} +1 -1
  29. package/dist-cli/chunks/{chunk-FZDRA7Z4.js → chunk-DNPQMTW5.js} +2 -2
  30. package/dist-cli/chunks/{chunk-TPPVAA7Z.js → chunk-DOVBJBVD.js} +2 -2
  31. package/dist-cli/chunks/{chunk-FW6AN7I2.js → chunk-DPBJ3S3J.js} +1 -1
  32. package/dist-cli/chunks/{chunk-PBOWUNXO.js → chunk-FVZBGPCU.js} +2 -2
  33. package/dist-cli/chunks/{chunk-PNRJFHX4.js → chunk-GDKMOIUT.js} +1 -1
  34. package/dist-cli/chunks/{chunk-4IKE4YUS.js → chunk-GIF2NJCS.js} +2 -2
  35. package/dist-cli/chunks/{chunk-MP2GPO4T.js → chunk-GZE57ORL.js} +1 -1
  36. package/dist-cli/chunks/{chunk-LD7I266X.js → chunk-H3U56DKI.js} +2 -2
  37. package/dist-cli/chunks/{chunk-JOHJZUGG.js → chunk-HZLOYAPH.js} +2 -2
  38. package/dist-cli/chunks/{chunk-DSD2UBZI.js → chunk-J2IKAEU2.js} +2 -2
  39. package/dist-cli/chunks/{chunk-HEV7BAPE.js → chunk-JXAXYK7W.js} +2 -2
  40. package/dist-cli/chunks/{chunk-XYSDYGKC.js → chunk-KJE2O2GK.js} +2 -2
  41. package/dist-cli/chunks/{chunk-V7RGRZOL.js → chunk-KMNVDZZI.js} +1 -1
  42. package/dist-cli/chunks/{chunk-4ALPWIMP.js → chunk-LC3QRIRB.js} +2 -2
  43. package/dist-cli/chunks/{chunk-SXBFGGAM.js → chunk-LGFTAQYC.js} +1 -1
  44. package/dist-cli/chunks/{chunk-4CEZZKRY.js → chunk-LQMUA5IY.js} +1 -1
  45. package/dist-cli/chunks/{chunk-LAOKTKT4.js → chunk-MFIQTWC5.js} +2 -2
  46. package/dist-cli/chunks/{chunk-2IUMRRYV.js → chunk-MGALNF2F.js} +2 -2
  47. package/dist-cli/chunks/{chunk-HNPHODBD.js → chunk-MLBZZHOY.js} +2 -2
  48. package/dist-cli/chunks/{chunk-7OSIJCBR.js → chunk-NNRF7GIB.js} +2 -2
  49. package/dist-cli/chunks/{chunk-5CGJFU27.js → chunk-NORLYTTO.js} +2 -2
  50. package/dist-cli/chunks/{chunk-CX7VCKAT.js → chunk-P6KVGV3H.js} +11 -11
  51. package/dist-cli/chunks/chunk-PAJTUK33.js +4 -0
  52. package/dist-cli/chunks/{chunk-C6B5FOP3.js → chunk-QELIC5XP.js} +1 -1
  53. package/dist-cli/chunks/{chunk-HWDVC6YA.js → chunk-QRDF33WD.js} +1 -1
  54. package/dist-cli/chunks/{chunk-LSOGXSDV.js → chunk-R76BA7C7.js} +3 -3
  55. package/dist-cli/chunks/{chunk-SWBUNMQS.js → chunk-RVEB4CZ2.js} +2 -2
  56. package/dist-cli/chunks/{chunk-BQCEI37V.js → chunk-SK4M7NXT.js} +1 -1
  57. package/dist-cli/chunks/{chunk-JWUDT4QK.js → chunk-SKMG5DD7.js} +2 -2
  58. package/dist-cli/chunks/{chunk-AQ5TMOAI.js → chunk-TEESPOYR.js} +1 -1
  59. package/dist-cli/chunks/{chunk-T4ISWS5H.js → chunk-TH2UFGVP.js} +1 -1
  60. package/dist-cli/chunks/{chunk-4ZXR2M3D.js → chunk-TLP3T3VO.js} +1 -1
  61. package/dist-cli/chunks/{chunk-2BRBFLWA.js → chunk-TZUABDIJ.js} +2 -2
  62. package/dist-cli/chunks/{chunk-Z5O5H4O7.js → chunk-UB2W6OQM.js} +2 -2
  63. package/dist-cli/chunks/{chunk-HNDWYCND.js → chunk-UYVXALPB.js} +2 -2
  64. package/dist-cli/chunks/{chunk-ZXFVBYJY.js → chunk-VQDYFFIG.js} +2 -2
  65. package/dist-cli/chunks/{chunk-YNHRSDVG.js → chunk-VWCNJPCJ.js} +2 -2
  66. package/dist-cli/chunks/{chunk-2GXNAZHB.js → chunk-VZIK4WIS.js} +2 -2
  67. package/dist-cli/chunks/{chunk-LMHBU5LZ.js → chunk-W3FNXAQP.js} +1 -1
  68. package/dist-cli/chunks/{chunk-GDLE4NIV.js → chunk-XCDNVNP3.js} +1 -1
  69. package/dist-cli/chunks/{chunk-4EUKOIAV.js → chunk-XSVILA4Z.js} +2 -2
  70. package/dist-cli/chunks/{chunk-USM3P74H.js → chunk-XUTJ7ZWD.js} +2 -2
  71. package/dist-cli/chunks/{chunk-YX52RJKO.js → chunk-YTXY3MHW.js} +2 -2
  72. package/dist-cli/chunks/{chunk-QJQOK34O.js → chunk-ZF7PVX44.js} +2 -2
  73. package/dist-cli/chunks/{chunk-DQUPSAHE.js → chunk-ZSSG7OR7.js} +1 -1
  74. package/dist-cli/chunks/{cleanup-KPUW4SFK.js → cleanup-MLOK2OZA.js} +2 -2
  75. package/dist-cli/chunks/cli-version-OBNR366V.js +4 -0
  76. package/dist-cli/chunks/{compat-XXRFD2TW.js → compat-SHMFSKU7.js} +2 -2
  77. package/dist-cli/chunks/{config-DDMFDQ7F.js → config-TPEAEUJ2.js} +2 -2
  78. package/dist-cli/chunks/{connect-IPG47YXM.js → connect-3LEXWTE5.js} +2 -2
  79. package/dist-cli/chunks/control-Z3FWA6BO.js +4 -0
  80. package/dist-cli/chunks/daemon-RSVYSC65.js +4 -0
  81. package/dist-cli/chunks/{debug-MYIP46TM.js → debug-GUVAK2KR.js} +3 -3
  82. package/dist-cli/chunks/{desktop-ENFFBQAA.js → desktop-OOP2PTKP.js} +3 -3
  83. package/dist-cli/chunks/{detox-J5WVK6OH.js → detox-C2ILVBEC.js} +2 -2
  84. package/dist-cli/chunks/{device-RAVQVL75.js → device-NXIQQJWR.js} +2 -2
  85. package/dist-cli/chunks/{diagnose-PJMPXKJY.js → diagnose-2JBGYE5L.js} +2 -2
  86. package/dist-cli/chunks/{disk-cleanup-YLAY445J.js → disk-cleanup-VURWJYQV.js} +2 -2
  87. package/dist-cli/chunks/{do-chain-UBE7GIOU.js → do-chain-DJ4UQC7A.js} +2 -2
  88. package/dist-cli/chunks/drivers-JMA2OIKU.js +4 -0
  89. package/dist-cli/chunks/{env-Y5XJSNRD.js → env-KTNPKEZR.js} +2 -2
  90. package/dist-cli/chunks/{film-W3V6VURB.js → film-DCPS7EID.js} +3 -3
  91. package/dist-cli/chunks/flow-4DZ7B2OA.js +4 -0
  92. package/dist-cli/chunks/help-34CJMQY2.js +4 -0
  93. package/dist-cli/chunks/{hidden-runtime-alias-S5DJ7EDF.js → hidden-runtime-alias-HHT2C7WE.js} +2 -2
  94. package/dist-cli/chunks/{home-paths-5O4IZPYV.js → home-paths-KTPGCPMS.js} +2 -2
  95. package/dist-cli/chunks/inspect-JF5WYJRD.js +4 -0
  96. package/dist-cli/chunks/install-desktop-ZIC4CDXI.js +4 -0
  97. package/dist-cli/chunks/{login-V6TZ54ZH.js → login-TTJAOI2Q.js} +2 -2
  98. package/dist-cli/chunks/{logout-SPMLFWYA.js → logout-ERAQ6SKW.js} +2 -2
  99. package/dist-cli/chunks/{maestro-5ISTBAZE.js → maestro-W46QCF77.js} +3 -3
  100. package/dist-cli/chunks/{maestro-generate-WUI64NHR.js → maestro-generate-VBLM3MTU.js} +3 -3
  101. package/dist-cli/chunks/{mode-QPNBYXUF.js → mode-ZEDZK7R7.js} +2 -2
  102. package/dist-cli/chunks/{optional-demo-registry-CBSYF4CG.js → optional-demo-registry-ZUTPSVYQ.js} +2 -2
  103. package/dist-cli/chunks/{perf-T6N5PVYV.js → perf-YVT2WXT4.js} +2 -2
  104. package/dist-cli/chunks/{permissions-YZ7RRSZJ.js → permissions-L7VVDHFP.js} +2 -2
  105. package/dist-cli/chunks/{platform-XDQAA72X.js → platform-7TJOU2FB.js} +3 -3
  106. package/dist-cli/chunks/privacy-57UOTB5J.js +4 -0
  107. package/dist-cli/chunks/{record-QGYXRUKP.js → record-VXG37P7U.js} +3 -3
  108. package/dist-cli/chunks/{report-issue-VUUTGX7V.js → report-issue-WNNOBZHC.js} +2 -2
  109. package/dist-cli/chunks/reset-H5NBFE5U.js +4 -0
  110. package/dist-cli/chunks/resolve-target-57TK5WLE.js +4 -0
  111. package/dist-cli/chunks/runtime-QU2NIF2K.js +4 -0
  112. package/dist-cli/chunks/{screenshot-command-NZCMSJ4P.js → screenshot-command-AN56TTG7.js} +3 -3
  113. package/dist-cli/chunks/{screenshot-layers-VMTQ6XIU.js → screenshot-layers-3W5R7DB2.js} +2 -2
  114. package/dist-cli/chunks/{screenshots-capture-K3MWIDBK.js → screenshots-capture-6AWJY7XZ.js} +2 -2
  115. package/dist-cli/chunks/{serve-QJRIB2BV.js → serve-GLYO5Q7J.js} +2 -2
  116. package/dist-cli/chunks/setup-UA2HLD7S.js +4 -0
  117. package/dist-cli/chunks/{sim-client-5YUVL45C.js → sim-client-5C2RDQQO.js} +2 -2
  118. package/dist-cli/chunks/{skills-T3CS7CXK.js → skills-EYXWBRNQ.js} +2 -2
  119. package/dist-cli/chunks/{state-AJC3VK3G.js → state-REJ7W6K3.js} +2 -2
  120. package/dist-cli/chunks/{storage-KVGZKC3Y.js → storage-CFMDHI3V.js} +2 -2
  121. package/dist-cli/chunks/store-XMCUA45G.js +4 -0
  122. package/dist-cli/chunks/telemetry-FBL3NAKB.js +4 -0
  123. package/dist-cli/chunks/{timeline-DXDCAZUA.js → timeline-HMCHN5FO.js} +2 -2
  124. package/dist-cli/chunks/{upgrade-SRPTJACU.js → upgrade-2QSPAA3P.js} +2 -2
  125. package/dist-cli/chunks/upload-DUQBKZYV.js +4 -0
  126. package/dist-cli/chunks/{version-SOLPSBMG.js → version-IOA6QFGB.js} +2 -2
  127. package/dist-cli/chunks/{web-RT75LD7A.js → web-NCGUYVCJ.js} +2 -2
  128. package/dist-cli/chunks/welcome-QYGSQCWQ.js +5 -0
  129. package/dist-cli/chunks/{what-happened-CEIWJIWK.js → what-happened-YTOUK4LO.js} +2 -2
  130. package/dist-cli/chunks/{ws-bridge-YK5R3HOI.js → ws-bridge-OF4OZARG.js} +2 -2
  131. package/dist-lib/agent-daemon-client.cjs +1 -1
  132. package/dist-lib/agent-events.cjs +1 -1
  133. package/dist-lib/agent-identity.cjs +1 -1
  134. package/dist-lib/agent-sessions.cjs +1 -1
  135. package/dist-lib/attached-projects.cjs +1 -1
  136. package/dist-lib/auth/shared-session.cjs +1 -1
  137. package/dist-lib/backend-origin.cjs +1 -1
  138. package/dist-lib/beta.cjs +1 -1
  139. package/dist-lib/beta.mjs +1 -1
  140. package/dist-lib/bridge-constants.cjs +1 -1
  141. package/dist-lib/bridge-contract-input.cjs +1 -1
  142. package/dist-lib/bridge-contract-input.mjs +1 -1
  143. package/dist-lib/bridge-contract.cjs +1 -1
  144. package/dist-lib/bridge-contract.mjs +1 -1
  145. package/dist-lib/cli-constants.cjs +1 -1
  146. package/dist-lib/config.cjs +1 -1
  147. package/dist-lib/detox/index.cjs +1 -1
  148. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  149. package/dist-lib/home-paths.cjs +1 -1
  150. package/dist-lib/host/bridge-host.cjs +148 -134
  151. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  152. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  153. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  154. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  155. package/dist-lib/host/websocket-proxy.cjs +1 -1
  156. package/dist-lib/index.cjs +1 -1
  157. package/dist-lib/jump-to-source-babel.cjs +1 -1
  158. package/dist-lib/menu.cjs +1 -1
  159. package/dist-lib/menu.mjs +1 -1
  160. package/dist-lib/metro-production-bundle.cjs +1 -1
  161. package/dist-lib/metro-production-bundle.mjs +1 -1
  162. package/dist-lib/metro.cjs +1 -1
  163. package/dist-lib/profiles.cjs +1 -1
  164. package/dist-lib/public-brand.cjs +1 -1
  165. package/dist-lib/react-native-host-modules.cjs +1 -1
  166. package/dist-lib/react-native-host-modules.mjs +1 -1
  167. package/dist-lib/render-mode.cjs +1 -1
  168. package/dist-lib/scripts/dev-server-scanner.cjs +18 -4
  169. package/dist-lib/sdk.cjs +1 -1
  170. package/dist-lib/sdk.mjs +1 -1
  171. package/dist-lib/skills.cjs +217 -196
  172. package/dist-lib/vite.cjs +1 -1
  173. package/package.json +1 -1
  174. package/scripts/dev-server-scanner.ts +23 -5
  175. package/dist-cli/chunks/chunk-EWPAI4MO.js +0 -7
  176. package/dist-cli/chunks/chunk-V4EJJHF5.js +0 -4
  177. package/dist-cli/chunks/cli-version-APGT6GAT.js +0 -4
  178. package/dist-cli/chunks/control-O22Z3UJ5.js +0 -4
  179. package/dist-cli/chunks/daemon-PADUIMJV.js +0 -4
  180. package/dist-cli/chunks/drivers-ZFNX3T5Z.js +0 -4
  181. package/dist-cli/chunks/flow-VMLI7BYM.js +0 -4
  182. package/dist-cli/chunks/help-PKZCWHJJ.js +0 -4
  183. package/dist-cli/chunks/inspect-LT4MXK37.js +0 -4
  184. package/dist-cli/chunks/install-desktop-EXCFMXFS.js +0 -4
  185. package/dist-cli/chunks/privacy-54FIGXLT.js +0 -4
  186. package/dist-cli/chunks/reset-CGO52KBW.js +0 -4
  187. package/dist-cli/chunks/resolve-target-NNQCALDM.js +0 -4
  188. package/dist-cli/chunks/runtime-4EP6YJVL.js +0 -4
  189. package/dist-cli/chunks/setup-6XXEJQVF.js +0 -4
  190. package/dist-cli/chunks/store-AWUMOQUH.js +0 -4
  191. package/dist-cli/chunks/telemetry-W5ZDGWK6.js +0 -4
  192. package/dist-cli/chunks/upload-ZDV4BFED.js +0 -4
  193. package/dist-cli/chunks/welcome-IJ55EC7U.js +0 -5
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.376 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rnxsim",
3
- "version": "0.1.375",
3
+ "version": "0.1.376",
4
4
  "description": "rnx CLI, Vite and Metro plugins, and agent skills for driving React Native apps in the browser.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -17,6 +17,7 @@ import { exec } from 'child_process'
17
17
  import { readlink } from 'fs/promises'
18
18
  import http from 'http'
19
19
  import net from 'net'
20
+ import { realpathSync } from 'node:fs'
20
21
  import { resolve } from 'node:path'
21
22
  import {
22
23
  buildLoopbackProbeBaseUrl,
@@ -547,11 +548,28 @@ function makeResult(
547
548
  }
548
549
 
549
550
  function withRuntimeConfig(port: number, bundleUrl: string, projectCwd?: string): string {
550
- const knownApp = projectCwd
551
- ? optionalDemoAppsSync().find(
552
- (app) => app.preferredPort === port && resolve(app.dir) === resolve(projectCwd),
553
- )
554
- : undefined
551
+ let physicalProjectCwd: string | undefined
552
+ if (projectCwd) {
553
+ try {
554
+ physicalProjectCwd = realpathSync(resolve(projectCwd))
555
+ } catch {}
556
+ }
557
+ const knownApps = physicalProjectCwd
558
+ ? optionalDemoAppsSync().filter((app) => {
559
+ try {
560
+ return realpathSync(resolve(app.dir)) === physicalProjectCwd
561
+ } catch {
562
+ return false
563
+ }
564
+ })
565
+ : []
566
+ const exactKnownApps = knownApps.filter((app) => app.preferredPort === port)
567
+ const knownApp =
568
+ exactKnownApps.length === 1
569
+ ? exactKnownApps[0]
570
+ : exactKnownApps.length === 0 && knownApps.length === 1
571
+ ? knownApps[0]
572
+ : undefined
555
573
  const configured = knownApp?.runtimeConfig
556
574
  ? applySootSimConfigToUrl(bundleUrl, knownApp.runtimeConfig)
557
575
  : bundleUrl
@@ -1,7 +0,0 @@
1
- /*! rnx v0.1.375 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import { createRequire as __sootsimCreateRequire } from 'node:module'
3
- var require = __sootsimCreateRequire(import.meta.url)
4
- import{a as fe,b as Ge}from"./chunk-XYSDYGKC.js";import{e as rt}from"./chunk-HNDWYCND.js";import{c as Ve}from"./chunk-YNHRSDVG.js";import{a as Ze,b as et,d as ot}from"./chunk-USM3P74H.js";import{a as Ne,c as Fe,d as k,e as de,f as A,g as me,h as He,i as pe,j as je,k as We,m as Qe,n as Ye,o as Xe}from"./chunk-CX7VCKAT.js";import{m as L}from"./chunk-2BRBFLWA.js";import{a as Ke,b as qe}from"./chunk-C6B5FOP3.js";import{h as tt,p as nt}from"./chunk-5PZVYF42.js";import{a as Je}from"./chunk-PBOWUNXO.js";import{a as ze}from"./chunk-MP2GPO4T.js";import{b as le,e as Me}from"./chunk-H4MYYOYJ.js";import{b as Oe,f as Be,g as B,h as P,i as D,n as De,o as ce,p as ue,r as Ae,s as Le,t as T,u as I,v as E}from"./chunk-7NCPUZ52.js";import{b as G,c as d}from"./chunk-T4ISWS5H.js";import{f as _e}from"./chunk-F5F7FIPM.js";import{a as Ee}from"./chunk-LMHBU5LZ.js";import{D as Re,M as se,P as ae,R as O,T as Te,l as ie}from"./chunk-HWDVC6YA.js";import{a as oe}from"./chunk-25KRGDZT.js";import{spawn as mt,spawnSync as pt}from"node:child_process";import _ from"node:fs";import Kt from"node:os";import U from"node:path";import{WebSocket as ge}from"ws";function it(e){return new Error(`could not resolve a native bundle for ${e}. pass an explicit bundle URL or open Connect and choose the app there.`)}function Ot(e,n){return e?.includes("/one/metro-entry.bundle")?"one":typeof n=="string"&&n?"expo":"unknown"}function Bt(e,n,t){return`${e}//${n}:${t}`}function Dt(e){if(typeof window>"u")return!1;try{let n=new URL(e);return k(n.hostname)&&k(window.location.hostname)&&n.origin!==window.location.origin}catch{return!1}}async function lt(e,n){let t={...n,cache:n?.cache??"no-store"};return Dt(e)?fetch(`/__fetch-proxy?url=${encodeURIComponent(e)}`,t):fetch(e,t)}function At(e){return e==="https:"?443:80}function Lt(e){let n=e.pathname||"/";return(n==="/"||n==="")&&!e.search&&!e.hash}async function ct(e){try{let n=await fetch("/__server-scan",{cache:"no-store"});if(!n.ok||!(n.headers.get("content-type")||"").toLowerCase().includes("json"))return null;let t=await n.json();if(!Array.isArray(t))return null;let r=t.find(o=>!!o&&typeof o=="object"&&o.port===e&&typeof o.bundleUrl=="string");return!r||r.bundleUrlProvisional?null:{bundleUrl:pe(r.bundleUrl),port:e,framework:typeof r.framework=="string"?r.framework:"unknown",projectName:typeof r.projectName=="string"?r.projectName:void 0}}catch{return null}}var Nt=5e3,Ft=3e4,Ht=1e3;async function st(e,n){let t,r=lt(`${e}/`,{headers:{"expo-platform":"ios"}}).then(async c=>c.ok?{ok:!0,body:await c.text()}:null,()=>{}),o=await Promise.race([r,new Promise(c=>setTimeout(()=>c("timeout"),Nt).unref?.())]);if(o==="timeout"||o===void 0)return{state:"no-answer"};if(o===null)return{state:"no-manifest"};if(t=o.body,!t.trim())return{state:"no-answer"};let i;try{i=JSON.parse(t)}catch{return{state:"no-manifest"}}let a=i?.extra?.expoClient||i?.extra||{},s=typeof i?.launchAsset?.url=="string"?i.launchAsset.url:void 0,l=s?He(s,e):void 0;return!l&&!a.name?{state:"no-manifest"}:{state:"resolved",bundle:{bundleUrl:pe(l||`${e}${me}`),port:n,framework:Ot(l,a.sdkVersion),projectName:a.name}}}async function at(e){try{let n=await lt(`${e}/status`);return n.ok?(await n.text()).includes("packager-status:running"):!1}catch{return!1}}async function ut(e,n){let t=e.replace(/\/+$/,""),r=await st(t,n),o=!1;if(r.state==="no-answer"){if(o=await at(t),!o)return null;let i=Date.now()+Ft;for(;r.state==="no-answer"&&Date.now()<i;)await new Promise(a=>setTimeout(a,Ht)),r=await st(t,n)}return r.state==="resolved"?r.bundle:r.state==="no-answer"||!o&&!await at(t)?null:{bundleUrl:`${t}${me}`,port:n,framework:"metro"}}async function jt(e,n){try{if(k(new URL(e).hostname)){let t=await ct(n);if(t)return t}}catch{}return ut(e,n)}async function Wt(e){let n=await ct(e);return n||((await Promise.all(Ne.map(r=>ut(Fe("http:",r,e),e)))).find(r=>r!==null)??null)}async function dt(e){let n=e.trim();if(/^\d+$/.test(n)){let s=parseInt(n,10),l=await Wt(s);if(l)return l;throw it(`localhost:${s}`)}let t=n.startsWith("http")?n:`http://${n}`,r;try{r=new URL(t)}catch{throw new Error(`could not parse "${e}". pass a dev-server port, a dev-server base URL, or a full bundle URL.`)}let o=r.protocol||"http:",i=r.port?parseInt(r.port,10):At(o),a=Bt(o,r.hostname,i);if(Lt(r)){let s=await jt(a,i);if(s)return s;throw it(a)}return{bundleUrl:r.toString(),port:i,framework:"unknown"}}var qt=12e4,ft=100,Vt=5e3,gt=1e4,Gt={rn:"/rn",connectrn:"/rn","connect-rn":"/rn",clock:"/app/clock","native-ui":"/app/native-ui",tamagui:"/app/tamagui",settings:"/app/settings",photos:"/app/photos",camera:"/app/camera"};function $(e){return new Promise(n=>setTimeout(n,e))}function ht(e){let n=process.env[e]?.trim();if(!n)return null;let t=Number(n);return Number.isInteger(t)&&t>0?t:null}function zt(){let e=ht("SOOTSIM_DRIVER_CONNECT_TIMEOUT_MS")??ht("SOOTSIM_PW_CONNECT_TIMEOUT_MS")??qt;return{timeoutMs:e,hostTimeoutMs:e+Vt,intervalMs:ft,attempts:Math.max(1,Math.ceil(e/ft))}}function wt(e){return e==="electron"||e==="playwright"}function he(e,n){return n==="playwright"?e.meta?.sootsimHostDriver==="playwright":e.userAgent?.includes("Electron/")===!0}function Jt(e,n){return e.includes("--headless")?!0:e.includes("--headed")?!1:n==="playwright"&&process.platform==="linux"&&!process.env.DISPLAY&&!process.env.WAYLAND_DISPLAY?(console.error(" no display detected \u2192 running playwright headless (override with --headed)"),!0):!1}function J(e){return e.trim()}async function Qt(e,n=!1){let t=ae();bt(e,n,t);let r=ce(e);if((n||r!==null)&&await we(e,250))return e;if(t&&O(t)&&await we(t.bridgePort,500))return t.bridgePort;if(t&&O(t))throw new Error(`rnx bridge lockfile is fresh (port ${t.bridgePort}) but the bridge is not reachable. run \`rnx daemon restart\` or \`rnx daemon uninstall\`.`);await Yt();let o=Xt(["serve","--quiet","--port",String(e)]),i=null;o.once("exit",(s,l)=>{i=String(s??l??"unknown")}),o.unref();let a=Date.now()+gt;for(;Date.now()<a;){let s=ae();if(bt(e,n,s),s&&O(s)&&await we(s.bridgePort,250))return console.error(` Started a local bridge on port ${s.bridgePort}. Run \`rnx daemon install\` to keep it ready between commands.`),s.bridgePort;if(i)throw new Error(`rnx bridge exited before becoming ready (exit ${i})`);await $(150)}throw new Error(`rnx bridge did not start within ${Math.round(gt/1e3)}s`)}function bt(e,n,t){if(!(!n||!t||!O(t)||t.bridgePort===e))throw new Error(`${oe.commandName} open: requested bridge port ${e}, but the active daemon owns port ${t.bridgePort}. explicit --port never selects another bridge; stop that daemon or use an isolated SOOTSIM_HOME.`)}async function Yt(){let e=se();if(e&&_.existsSync(ie(e)))return;console.error(" installing rnx engine runtime...");let{runRuntime:n}=await import("./runtime-4EP6YJVL.js");await n(["install"],{})}function Xt(e){let n=process.argv[1];return n&&_.existsSync(n)?mt(process.execPath,[n,...e],{detached:!0,stdio:"ignore",env:process.env}):mt(oe.commandName,e,{detached:!0,stdio:"ignore",env:process.env})}function we(e,n){return new Promise(t=>{let r=new ge(`ws://127.0.0.1:${e}`,{handshakeTimeout:n}),o=!1,i=a=>{o||(o=!0,r.readyState===ge.OPEN?r.close():r.readyState===ge.CONNECTING&&r.terminate(),t(a))};r.once("open",()=>i(!0)),r.on("error",()=>i(!1)),setTimeout(()=>i(!1),n)})}function ve(e){try{let n=new URL(e),t=n.pathname.replace(/\/+$/,"")||"/";return n.searchParams.has("open")||n.searchParams.has("port")||n.searchParams.has("bundle")||n.searchParams.has("demo")||n.pathname.includes("/sootsim/index.html")||t==="/sootsim"||n.pathname==="/__soot"||n.pathname==="/__soot/"||t==="/rn"||/^\/rn\/[^/]+$/i.test(t)||/^\/app\/[^/]+$/i.test(t)||t==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(t)||/^\/__soot\/app\/[^/]+$/i.test(t)}catch{return!1}}function Zt(e){try{let n=new URL(e,"http://sootsim.local");if(n.origin!=="http://sootsim.local")return!1;let t=n.pathname.replace(/\/+$/,"")||"/";return t==="/rn"||/^\/rn\/[^/]+$/i.test(t)||/^\/app\/[^/]+$/i.test(t)||t==="/__soot/rn"||/^\/__soot\/rn\/[^/]+$/i.test(t)||/^\/__soot\/app\/[^/]+$/i.test(t)}catch{return!1}}function en(e,n){let t=new URL(e,"http://sootsim.local"),r=new URL(n),o=Q(r.pathname),i=t.pathname.startsWith("/__soot/")?t.pathname.slice(7):t.pathname;return r.pathname=`${o}${i}`,r.search=t.search,r.hash=t.hash,r.toString()}function tn(e){try{let n=new URL(e).pathname.replace(/\/+$/,"")||"/";return/^\/preview\/[^/]+$/.test(n)||/^\/build\/.+/.test(n)}catch{return!1}}async function mr(e){let n=J(e);return(await Se(n)).bundleUrl}function nn(e){try{let n=new URL(e.startsWith("http")?e:`http://${e}`),t=n.pathname||"/";if(t!=="/"&&t!==""||n.search||n.hash||!k(n.hostname))return null;let r=n.port?Number(n.port):n.protocol==="https:"?443:80;return Number.isFinite(r)&&r>0?r:null}catch{return null}}async function Se(e){let n=J(e),t=/^\d+$/.test(n)?Number(n):nn(n);if(t&&t>0){let r=await We(t);if(r&&!r.bundleUrlProvisional)return{bundleUrl:r.bundleUrl,port:r.port,framework:r.framework,projectName:r.projectName}}return dt(n)}function Q(e){let n=e.replace(/\/+$/,"")||"/";return n==="/__soot"||n.startsWith("/__soot/")?"/__soot":""}function rn(e,n){let t=J(e),r=new URL(n),o=Q(r.pathname);return r.pathname=`${o}/rn`,r.searchParams.delete("bundle"),r.searchParams.delete("demo"),r.searchParams.delete("app"),r.searchParams.delete("open"),r.searchParams.delete("port"),/^\d+$/.test(t)?r.pathname=`${o}/rn/${t}`:(r.pathname=`${o}/rn`,r.searchParams.set("open",t)),r.toString()}function Pt(e){let n=J(e);return/^\d+$/.test(n)||/^https?:\/\//i.test(n)?!0:/^(localhost|127\.0\.0\.1|\[::1\]|[^/]+\.localhost):\d+(?:\/.*)?$/i.test(n)}async function on(e,n,t={}){let r=t.resolvedBundle??await Se(e),o=new URL(n),i=Q(o.pathname);o.pathname=`${i}/rn`,o.searchParams.delete("open"),o.searchParams.delete("port"),o.searchParams.delete("demo"),o.searchParams.delete("app");let a=t.hot===void 0?r.bundleUrl:je(r.bundleUrl,t.hot);return o.searchParams.set("bundle",a),o.toString()}function sn(e){return e.startsWith("~/")?U.join(Kt.homedir(),e.slice(2)):U.isAbsolute(e)?e:U.resolve(process.cwd(),e)}function an(e){let n={},t={};for(let o=0;o<e.length;o++){if(e[o]==="--replace"){let i=e[o+1];i||(console.error(" rnx open: --replace expects <module>=<file>"),d(1));let a=i.indexOf("=");(a<=0||a===i.length-1)&&(console.error(" rnx open: --replace expects <module>=<file>"),d(1));let s=i.slice(0,a).trim(),l=sn(i.slice(a+1).trim());_.existsSync(l)||(console.error(` rnx open: replacement file not found: ${l}`),d(1)),n[s]={file:l},o++;continue}if(e[o]==="--remap"){let i=e[o+1],a=i?i.indexOf("="):-1;(!i||a<=0||a===i.length-1)&&(console.error(" rnx open: --remap expects <host:port>=<host:port>"),d(1)),t[i.slice(0,a).trim()]=i.slice(a+1).trim(),o++;continue}}let r={};return Object.keys(n).length>0&&(r.modules=n),Object.keys(t).length>0&&(r.network={remap:t}),r.modules||r.network?r:void 0}async function ln(e){if(!e)return null;let n=await Ye(e.bundleUrl);return n?ze(n):null}async function cn(e){if(_.existsSync(U.join(ie(e),"index.html")))return;console.error(` installing configured engine runtime ${e}...`);let n=await _e.install({version:e,setActive:!1,protectVersions:Te()});console.error(` installed engine runtime ${n.version}`)}function un(e,n){let t=n??(fe()?void 0:se()??void 0);if(!t)return e;let r=new URL(e);if(!k(r.hostname)){if(!n)return e;throw new Error(`runtimeVersion ${t} requires a local rnx host; got ${r.origin}`)}return r.hostname=Ge(t),r.toString()}function It(){return De().shellBaseUrl}function dn(e){return ce(e)?.shellBaseUrl??Oe(e)??It()}async function mn(e,n){try{let t=new URL(e),r=t.searchParams.get("bundle")||"";if(!r||!n)return e;let o=Qe({bundleUrl:r,projectDir:n.appDir});if(o.length===0)return e;let i=await pn(o);return i.length===0?e:(t.searchParams.set("appFonts",Xe(i)),t.toString())}catch{return e}}async function pn(e){let n=await Promise.all(e.map(async r=>{let o=new AbortController,i=setTimeout(()=>o.abort(),1500);try{let a=await fetch(r.url,{method:"HEAD",signal:o.signal});return a.status>=200&&a.status<400?r:null}catch{return null}finally{clearTimeout(i)}})),t=[];for(let r of n)r!==null&&t.push(r);return t}async function fn(e,n,t={}){if(!e)return new URL(n).toString();if(ve(e))return new URL(e).toString();if(Zt(e))return en(e,n);let r=Gt[e.toLowerCase()];if(r){let o=new URL(n),i=Q(o.pathname);return o.pathname=`${i}${r}`,o.toString()}return Pt(e)?on(e,n,t):rn(e,n)}async function gn(e,n){try{let t=new URL(e),r=t.searchParams.get("bundle")||"";if(!r||!n)return e;let o=Ze({bundleUrl:r,projectDir:n.appDir});return!o||o.imageUrl&&!await hn(o.imageUrl)?e:(t.searchParams.set("appSplash",et(o)),t.toString())}catch{return e}}async function hn(e){let n=new AbortController,t=setTimeout(()=>n.abort(),1500);try{let r=await fetch(e,{method:"HEAD",signal:n.signal});return r.status>=200&&r.status<400}catch{return!1}finally{clearTimeout(t)}}async function z(e,n=It(),t={}){let r=await fn(e,n,t),o=await gn(await mn(r,t.project),t.project);if(!t.device)return o;let i=new URL(o);return i.searchParams.set("device",t.device),i.toString()}function vt(e,n){let t=e?.url||e?.origin||n;try{let r=new URL(t);return r.searchParams.delete("bundle"),r.searchParams.delete("demo"),r.searchParams.delete("app"),r.searchParams.delete("open"),r.searchParams.delete("port"),r.searchParams.delete("inspectOpen"),r.searchParams.delete("appFonts"),r.searchParams.delete("appSplash"),r.toString()}catch{return n}}async function wn(e,n,t,r={}){let o=new URL(await z(e,n,r));return o.searchParams.set("inspectOpen",t),o.toString()}async function bn(e,n,t,r={}){let o=r.attempts??30,i=r.intervalMs??500,a=r.minNodeCount??10;for(let s=0;s<o;s++){let l=I(e,{commandTimeoutMs:n,simId:t,simIdSource:"flag"});try{let c=await l.send({type:"evaluate",code:"(async () => (await window.__sootsimTest?.getNodeCount()) || 0)()"});if(typeof c=="number"&&c>a)return{bridge:l,count:c}}catch{}l.close(),await $(i)}return null}function vn(e){if(!e)return null;try{let n=new URL(e);if(n.searchParams.has("bundle")){let t=n.searchParams.get("bundle")||"";try{let r=new URL(t),o=r.pathname.length>36?`...${r.pathname.slice(-36)}`:r.pathname;return`bundle ${r.host}${o}`}catch{return"bundle"}}return n.searchParams.has("port")?`connect :${n.searchParams.get("port")||""}`:n.searchParams.has("open")?`connect ${n.searchParams.get("open")||""}`:n.searchParams.has("demo")?`demo ${n.searchParams.get("demo")||"default"}`:n.pathname.includes("/sootsim/index.html")||n.pathname==="/sootsim/"||n.pathname==="/sootsim"?"embedded rnx":null}catch{return null}}function yn(e){let n=e.indexOf(":");if(n<=0)return e.length>24?`${e.slice(0,21)}\u2026`:e;let t=e.slice(0,n),r=e.slice(n+1),o=r.length>12?`${r.slice(0,8)}\u2026`:r;return t==="TM_SESSION"||t==="CLAUDE_CODE_SESSION_ID"||t==="CODEX_THREAD_ID"?`agent ${o}`:`${t} ${o}`}function pr(e,n){if(e.length===0){console.log(" no sims connected");return}console.log(` connected sims (${e.length}):
5
- `);for(let t of e){let r=t.lockedBy&&t.lockExpiresAt?`locked by ${yn(t.lockedBy)} (${Math.max(0,Math.round((t.lockExpiresAt-Date.now())/1e3))}s)`:"",o=[t.isPrimary?"primary":"",t.id===n?"selected":"",t.readyState,t.userVisible===!1?"hidden":t.userVisible===!0?"visible":"",t.attachedCliCount&&t.attachedCliCount>0?"in use":"",t.userFocused?"focused":"",r].filter(Boolean);console.log(` ${t.id}${o.length?` [${o.join(", ")}]`:""}`);let i=vn(t.url);if(i)console.log(` loaded: ${i}`);else if(t.url){let s=t.url.length>96?`${t.url.slice(0,93)}\u2026`:t.url;console.log(` url: ${s}`)}else t.origin&&console.log(` origin: ${t.origin}`);let a=Sn(t);a&&console.log(` engine: ${a}`),t.title&&console.log(` title: ${t.title}`),t.visibilityState&&t.visibilityState!=="visible"&&console.log(` visibility: ${t.visibilityState}`),console.log(` connected: ${yt(Date.now()-t.connectedAt)}`),t.lastActiveAt&&t.lastActiveAt>0&&console.log(` last active: ${yt(Date.now()-t.lastActiveAt)}`)}}function Sn(e){let n=e.url||e.origin||"";if(!n)return null;try{let t=new URL(n).port;return t==="5173"?"dev \u2014 local source (:5173)":t==="3000"?"Contrast app embedded (:3000)":fe()?`dev \u2014 local build (:${t||"?"})`:`runtime \u2014 published engine (:${t||"?"})`}catch{return null}}function yt(e){let n=Math.max(0,Math.round(e/1e3));return n<60?`${n}s ago`:n<3600?`${Math.round(n/60)}m ago`:n<86400?`${Math.round(n/3600)}h ago`:`${Math.round(n/86400)}d ago`}async function fr(e,n,t,r={}){let o=r.attempts??30,i=r.intervalMs??500;for(let a=0;a<o;a++){let s=I(e,{commandTimeoutMs:n});try{let c=(await s.listSims()).find(t);if(c)return c}catch{}finally{s.close()}await $(i)}return null}async function $n(e,n,t,r,o={}){let i=o.attempts??30,a=o.intervalMs??500,s=!!r&&Number.isInteger(r)&&r>1,l=()=>s&&r!==void 0&&!ye(r);for(let c=0;c<i;c++){if(l())return{kind:"host-exit"};let m=I(e,{commandTimeoutMs:n});try{let h=(await m.listSims()).find(t);if(h)return l()?{kind:"host-exit"}:{kind:"match",sim:h}}catch{}finally{m.close()}if(l())return{kind:"host-exit"};await $(a)}return{kind:"timeout"}}async function xn(e,n,t,r={}){let o=r.attempts??20,i=r.intervalMs??250;for(let a=0;a<o;a++){let s=I(e,{commandTimeoutMs:n});try{let c=(await s.listSims()).find(m=>m.id===t);if(!c||c.readyState!=="open")return!0}catch{return!0}finally{s.close()}await $(i)}return!1}function Pn(e){let n=e.meta;if(!n||n.sootsimHostDriver!=="playwright")return null;let t=Number(n.sootsimHostPid);return!Number.isInteger(t)||t<=1||t===process.pid?null:t}function In(e){if(!e.connectAckFile)return!1;try{return _.writeFileSync(e.connectAckFile,`${JSON.stringify({connectedAt:Date.now(),pid:e.pid??null})}
6
- `,{flag:"w"}),!0}catch{return!1}}function St(e){if(e.diagnosticLogPath)try{let n=_.readFileSync(e.diagnosticLogPath,"utf8").trim();if(!n){console.error(` ${U.basename(e.diagnosticLogPath)} was empty`);return}let t=n.length>4e3?`\u2026
7
- ${n.slice(-4e3)}`:n;console.error(` ${U.basename(e.diagnosticLogPath)}:`),console.error(t)}catch(n){let t=n instanceof Error?n.message:String(n);console.error(` failed to read ${U.basename(e.diagnosticLogPath)}: ${t}`)}}function ye(e){try{return process.kill(e,0),!0}catch(n){return n?.code==="EPERM"}}async function kn(e,n=2500){let t=Date.now()+n;for(;Date.now()<t;){if(!ye(e))return!0;await $(100)}return!ye(e)}function Cn(e){let n=pt("ps",["-o","command=","-p",String(e)],{encoding:"utf8",stdio:["ignore","pipe","pipe"]}),t=pt("ps",["eww","-o","command=","-p",String(e)],{encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(n.status!==0||t.status!==0)return!1;let r=(n.stdout||"").trimEnd(),o=(t.stdout||"").trimEnd();return(o.startsWith(r)?o.slice(r.length):o).includes("SOOTSIM_PW_URL=")}async function be(e,n){let t=new Set(n),r=new Set;for(let o of e){if(!t.has(o.id))continue;let i=Pn(o);i&&r.add(i)}for(let o of r){if(!Cn(o)){console.log(` skipped pid ${o}: not a rnx playwright host (stale sim record)`);continue}try{process.kill(o,"SIGTERM")}catch{}if(await kn(o)){console.log(` closed playwright host process ${o}`);continue}try{process.kill(o,"SIGKILL"),console.log(` force-closed playwright host process ${o}`)}catch{}}}function Y(e,n){if(n){let o=n.trim(),i=e.find(a=>a.id===o);if(!i)throw new Error(`no sim connected with id ${o}`);return i}let t=e.find(o=>o.isPrimary&&o.readyState==="open");if(t)return t;let r=e.find(o=>o.readyState==="open");if(r)return r;throw new Error("no sim connected")}function $t(e,n,t,r=!1){let[o,i]=[e,n.url].map(a=>{if(!a)return a;try{let s=new URL(a);if(s.searchParams.has("sootsimConfig"))return s.searchParams.set("sootsimConfig","[redacted]"),s.toString()}catch{}return a});if(r){console.log(` Opened ConnectRN [${t}]`);return}console.log(` ${t==="current sim"?"loaded":"opened"}: ${o} [${t}]`),console.log(` current sim: ${n.id}`),console.log(JSON.stringify({simId:n.id,url:i},null,2))}async function xt(e,n,t){if(t.includes("--no-describe"))return;let r=process.env.SOOTSIM_QUIET_TARGET_NOTICE;process.env.SOOTSIM_QUIET_TARGET_NOTICE="1";try{await Un(e,n,{stableMs:150,maxMs:400});let o=I(e,{commandTimeoutMs:3e3,simId:n,cliLabel:"open --describe",simIdSource:"flag"});try{let i=null;try{i=await nt(o,1)}catch{}if(i&&!i.ready){let s=i.loadingText?`still showing "${i.loadingText}"`:i.flag!==!0?"guest ready event has not fired":i.targets<=0?"no visible app content is inspectable yet":"app tree is still stabilizing";console.log(` app still loading: ${s} (nodes: ${i.nodes}, targets: ${i.targets})`),console.log(" before interacting, run: rnx wait ready --max-ms 120000")}let a=await tt(o,{describe:!0,verbose:!1,filter:"",compact:!0,hideXy:!1,maxDepth:12});if(!a?.tree)return;console.log(""),console.log(a.tree)}finally{o.close()}}catch{}finally{r===void 0?delete process.env.SOOTSIM_QUIET_TARGET_NOTICE:process.env.SOOTSIM_QUIET_TARGET_NOTICE=r}}async function Un(e,n,t){let r=Date.now()+t.maxMs,o="(async () => (await window.__sootsimTest?.getNodeCount?.()) || 0)()",i=I(e,{commandTimeoutMs:2e3,simId:n,simIdSource:"flag"});try{let a=-1,s=0;for(;Date.now()<r;){let l=-1;try{let c=await i.send({type:"evaluate",code:o});typeof c=="number"&&(l=c)}catch{}if(l>=0&&l===a){if(Date.now()-s>=t.stableMs)return}else a=l,s=Date.now();await $(50)}}finally{i.close()}}async function Rn(e,n={}){let t=T(e,{port:n.port,commandTimeoutMs:n.timeoutMs});t.positional.length!==1&&(console.error(" rnx open: expected exactly one <url-or-route>"),console.error(" examples: rnx open /settings | rnx open myapp://settings"),d(1));let r=E(t),o=t.simId?` --sim ${t.simId}`:"";try{let i=await qe(r,t.positional[0]??"");console.log(` opened deep link: ${i}`)}catch(i){console.error(` link failed: ${i instanceof Error?i.message:String(i)}`),await L(r,{errorsCommand:`rnx get errors 5${o}`,warningsCommand:`rnx get warnings 5${o}`,requestsCommand:`rnx get requests 5${o}`}),d(1)}finally{r.close()}}async function gr(e,n={}){let t=T(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--new","--headless","--headed","--ephemeral","--hot","--no-hmr","--no-describe","--quiet"],stripValueFlags:["--base-url","--replace","--driver","--profile","--cdp-port","--device","--viewport"]}),r=e.find((f,p)=>e[p-1]==="--profile"),o=e.includes("--quiet"),i=e.includes("--ephemeral"),a=e.find((f,p)=>e[p-1]==="--cdp-port"),s=a?Number(a):void 0;a&&(!Number.isFinite(s)||s<=0)&&(console.error(` rnx open: --cdp-port must be a positive port number, got "${a}"`),d(1)),r&&i&&(console.error(" rnx open: --profile cannot be combined with --ephemeral"),d(1));let l=r?Ve(r).id:void 0,c=e.includes("--new")||!!l||i,m=an(e);c&&t.simIdSource==="flag"&&(console.error(" rnx open: --new, --profile, and --ephemeral cannot be combined with --sim"),d(1));let u=t.positional[0]||"";if(Ke(u)){c&&(console.error(" rnx open: deep links target the current app; remove --new, --profile, or --ephemeral"),d(1)),await Rn(e,n);return}if(tn(u)){let f=(()=>{try{return k(new URL(u).hostname)}catch{return!1}})();console.log(" that\u2019s an rnx preview/build link \u2014 a full player page, not a driveable sim."),console.log(" opening it in your browser for viewing\u2026");try{await ot(u,{background:!1})}catch(p){console.error(` could not launch a browser: ${p instanceof Error?p.message:String(p)}`),console.error(` open it yourself: ${u}`),d(1)}console.log(f?" to drive it under the CLI, point `rnx open` at the app\u2019s dev port instead (e.g. `rnx open 8081`).":" the CLI can\u2019t drive a remote preview (the engine only attaches to the local bridge from localhost). to drive the app, run it locally and `rnx open <port>`.");return}let h=Pt(u)?await Se(u):void 0,N=await ln(h),X=await Je(N),F=X?.runtimeVersion,H=de(de(X?{...X,runtimeVersion:void 0}:void 0,n.runtimeConfig),m);F&&await cn(F);let Z=e.find((f,p)=>e[p-1]==="--base-url");if(Z&&!t.explicitPort){let f=ue(Z);f&&(t.wsPort=f)}t.wsPort=await Qt(t.wsPort,t.explicitPort);let M=e.find((f,p)=>e[p-1]==="--driver")||"";M&&!wt(M)&&(console.error(` unknown driver "${M}" \u2014 run \`rnx list --drivers\``),d(1));let v=wt(M)?M:process.env.CI==="1"||process.env.CI==="true"||process.env.GITHUB_ACTIONS==="true"||Ee()||!process.stdin.isTTY?"playwright":Re()||"playwright",Ct=Jt(e,v);s&&v!=="playwright"&&(console.error(" rnx open: --cdp-port is only honored by the playwright driver"),d(1));let $e=e.includes("--hot"),xe=e.includes("--no-hmr");$e&&xe&&(console.error(" rnx open: --hot and --no-hmr cannot be combined"),d(1));let Ut=$e?!0:xe?!1:v!=="playwright",C=e.find((f,p)=>e[p-1]==="--device");C&&!(C in le)&&(console.error(` rnx open: unknown device "${C}"`),console.error(` known devices: ${Me().join(", ")}`),d(1));let ee=C?le[C]:void 0,j=e.find((f,p)=>e[p-1]==="--viewport"),W=j?/^(\d+)x(\d+)$/.exec(j):null;j&&!W&&(console.error(` rnx open: --viewport must be <width>x<height>, got "${j}"`),d(1));let Rt=W?{width:Number(W[1]),height:Number(W[2])}:void 0,K={hot:Ut,device:C,resolvedBundle:h,project:N},Tt=F?`http://localhost:${t.wsPort}/`:Z||dn(t.wsPort),x=un(Tt,F),Pe=e.includes("--base-url");Ae(t.wsPort,x);let Et=B();if(!c){let f=E(t),p=t.simId?` --sim ${t.simId}`:"",re=!1;try{let g=null,V=null;try{let w=await f.listSims();if(t.simIdSource==="saved")g=w.find(b=>b.id===Et&&b.readyState==="open"&&he(b,v))??null,g||D();else if(t.simIdSource==="flag"&&(g=Y(w,t.simId),!he(g,v)))throw new Error(`sim ${g.id} is not managed by the ${v} driver`);if(!g&&t.simIdSource!=="flag"){V=await z(u,A(x,H),K);let b=new URL(V);b.searchParams.delete("inspectOpen"),g=w.find(S=>{if(S.readyState!=="open"||!S.url||!he(S,v))return!1;try{let Ue=new URL(S.url);return Ue.searchParams.delete("inspectOpen"),Ue.toString()===b.toString()}catch{return!1}})??null}if(!g)if(t.simIdSource!=="flag")re=!0;else throw new Error("no sim connected");if(!re&&g){let b=Pe||ve(u)?x:vt(g,x),S=V??await z(u,A(b,H),K);f.send({type:"evaluate",simId:g.id,code:`window.location.href = ${JSON.stringify(S)}`}).catch(()=>{})}}catch(w){console.error(` open failed: ${w instanceof Error?w.message:String(w)}`),await L(f,{errorsCommand:`rnx get errors 5${p}`,warningsCommand:`rnx get warnings 5${p}`,requestsCommand:`rnx get requests 5${p}`}),d(1)}if(!re&&g){await $(1500);let w=await bn(t.wsPort,t.commandTimeoutMs,g.id);w||(console.error(" timed out waiting for current sim to load target"),d(1)),w.bridge.close(),P(g.id);let b=Pe||ve(u)?x:vt(g,x),S=V??await z(u,A(b,H),K);return $t(S,{...g,url:S},"current sim",o),await xt(t.wsPort,g.id,e),t.wsPort}}finally{f.close()}}let _t=A(x,H),Ie=`cli-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,ke=await wn(u,_t,Ie,K),Ce=Be();Ce||(console.error(" could not resolve a stable owning process; refusing unsupervised sim host"),d(1));let Mt=f=>f.url?.includes(`inspectOpen=${Ie}`)??!1,R=rt(v);R||(console.error(` unknown driver "${v}" \u2014 run \`rnx list --drivers\``),d(1));let q=zt(),y=await R.launch({url:ke,bridgePort:ue(x)??t.wsPort,headless:Ct,profileId:l,ephemeralProfile:i,cdpPort:s,device:C,ownerPid:Ce,viewport:Rt??(ee?{width:ee.width+120,height:ee.height+60}:void 0),connectTimeoutMs:q.hostTimeoutMs});y.launched||(console.error(` ${R.name} driver: ${y.message}`),d(1));let te=await $n(t.wsPort,t.commandTimeoutMs,Mt,y.pid,{attempts:q.attempts,intervalMs:q.intervalMs});if(te.kind==="host-exit"&&(St(y),console.error(` ${R.name} host crashed \u2014 sim is no longer attached`),d(1)),te.kind==="timeout"){if(y.pid)try{process.kill(y.pid,"SIGTERM"),console.error(` closed ${R.name} host process ${y.pid}`)}catch{}St(y),console.error(` timed out after ${q.timeoutMs}ms waiting for opened sim to connect`),d(1)}let ne=te.sim;return P(ne.id),In(y),$t(ke,ne,`${R.name} driver`,o),await xt(t.wsPort,ne.id,e),t.wsPort}async function kt(e,n={}){let t=T(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--force"]}),r=e.includes("--force"),o=E(t),i=t.simId?` --sim ${t.simId}`:"";try{try{let a=await o.listSims(),s=Y(a,t.positional[0]||t.simId);if(s.lockedBy&&s.lockExpiresAt&&s.lockExpiresAt>Date.now()){let l=Math.max(0,Math.round((s.lockExpiresAt-Date.now())/1e3));s.lockedByKind==="user-active"&&(console.error(` refused: ${s.id} is locked by the active user (${l}s) \u2014 that's a live human tab`),console.error(" run `rnx open --new` for a fresh investigation sim"),d(1)),r||(console.error(` refused: ${s.id} is leased by ${s.lockedBy} (${l}s)`),console.error(` \`sootsim use ${s.id} --force\` to take it, or \`rnx open --new\` for a fresh sim`),d(1))}await o.focusSim(s.id),P(s.id),console.log(` using: ${s.id}`)}catch(a){G(a),console.error(` use failed: ${a instanceof Error?a.message:String(a)}`),await L(o,{errorsCommand:`rnx get errors 5${i}`,warningsCommand:`rnx get warnings 5${i}`,requestsCommand:`rnx get requests 5${i}`}),d(1)}}finally{o.close()}}async function hr(e,n={}){await kt(e,n)}async function wr(e,n={}){await kt(e,n)}async function br(e,n={}){let t=T(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--force"]}),r=e.includes("--force"),o=E(t);try{try{let i=await o.listSims(),a=Y(i,t.positional[0]||t.simId),s=r&&a.lockedBy&&a.lockedByKind!=="user-active"?a.lockedBy:null,l=await o.claim(a.id,{force:r});P(a.id);let c=Math.max(0,Math.round((l.lockExpiresAt-Date.now())/1e3)),m=l.bootedCount>0?` (booted ${l.bootedCount})`:"";console.log(` claimed: ${l.simId} [${c}s]${m}`),s&&console.log(` took over from: ${s}`)}catch(i){if(i instanceof Le){let a=Math.max(0,Math.round(i.lock.expiresInMs/1e3));console.error(` claim failed: locked by ${i.lock.by} for ${a}s more`),console.error(" use --force to take it, or `rnx open --new` for a fresh sim"),d(1)}console.error(` claim failed: ${i instanceof Error?i.message:String(i)}`),d(1)}}finally{o.close()}}async function Tn(e,n,t,r){if(r.length===0)return{closed:[],remaining:[]};await Promise.all(r.map(i=>e.closeSim(i).catch(()=>{})));let o=new Set(r);for(let i=0;i<40;i++){let a=[];try{let s=I(n,{commandTimeoutMs:t});try{a=(await s.listSims()).filter(c=>o.has(c.id)&&c.readyState==="open").map(c=>c.id)}finally{s.close()}}catch{a=[]}if(a.length===0)return{closed:[...o],remaining:[]};if(i===39)return{closed:[...o].filter(s=>!a.includes(s)),remaining:a};await $(250)}return{closed:[...o],remaining:[]}}function En(e,n){let t=e.filter(u=>u.readyState==="open"),r=t.map(u=>u.id),o=n.explicitKeepId?.trim()||"",i=n.savedKeepId?.trim()||"",a=i?t.some(u=>u.id===i):!1,s=i&&!a?i:null,l=null,c=null,m=null;if(n.closeOthers)if(o){let u=t.find(h=>h.id===o);u?l=u.id:c=o}else if(i&&a)l=i;else{let u=t.find(h=>h.isPrimary)??t[0]??null;u&&(l=u.id,i&&!a&&(m=u.id))}return{openIds:r,keepId:l,targets:c?[]:r.filter(u=>u!==l),staleSavedId:s,missingExplicitKeepId:c,fallbackKeepId:m}}async function vr(e,n={}){let t=T(e,{port:n.port,commandTimeoutMs:n.timeoutMs,stripBooleanFlags:["--all","--others"]}),r=E(t),o=t.simId?` --sim ${t.simId}`:"",i=e.includes("--all"),a=e.includes("--others");if(i||a){try{let s=await r.listSims(),l=B(),c=t.positional[0]||(t.simIdSource==="flag"?t.simId:void 0),m=En(s,{closeOthers:a,explicitKeepId:c,savedKeepId:l});if(m.staleSavedId&&D(),m.fallbackKeepId&&(P(m.fallbackKeepId),console.log(` saved sim ${m.staleSavedId} is gone \u2014 keeping primary ${m.fallbackKeepId}`)),m.missingExplicitKeepId&&(console.error(` close failed: keep sim ${m.missingExplicitKeepId} is not connected; not closing other sims`),d(1)),m.targets.length===0){console.log(m.keepId?` nothing to close \u2014 only the kept sim ${m.keepId} is connected`:m.staleSavedId?` nothing to close \u2014 no sims connected (cleared stale current sim ${m.staleSavedId})`:" nothing to close \u2014 no sims connected");return}let u=await Tn(r,t.wsPort,t.commandTimeoutMs,m.targets);await be(s,m.targets);let h=B();h&&u.closed.includes(h)&&(m.keepId?P(m.keepId):D());let N=` closed ${u.closed.length} sim(s)${m.keepId?` (kept ${m.keepId})`:""}`;console.log(N),u.remaining.length>0&&(console.error(` close failed: still connected: ${u.remaining.join(", ")}`),d(1))}catch(s){G(s),console.error(` close failed: ${s instanceof Error?s.message:String(s)}`),d(1)}finally{r.close()}return}try{try{let s=await r.listSims(),l=Y(s,t.positional[0]||t.simId),c=s.find(u=>u.id!==l.id&&u.readyState==="open");await r.closeSim(l.id),await xn(t.wsPort,t.commandTimeoutMs,l.id)||(await be(s,[l.id]),console.error(` close failed: ${l.id} is still connected`),d(1)),await be(s,[l.id]),B()===l.id&&(c?P(c.id):D()),console.log(` closed: ${l.id}`)}catch(s){G(s),console.error(` close failed: ${s instanceof Error?s.message:String(s)}`),await L(r,{errorsCommand:`rnx get errors 5${o}`,warningsCommand:`rnx get warnings 5${o}`,requestsCommand:`rnx get requests 5${o}`}),d(1)}}finally{r.close()}}export{zt as a,Qt as b,mr as c,un as d,It as e,dn as f,z as g,wn as h,vn as i,pr as j,fr as k,$n as l,Pn as m,In as n,be as o,Rn as p,gr as q,hr as r,wr as s,br as t,Tn as u,En as v,vr as w};