@roxybrowser/playwright 2.0.2-beta.0

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 (424) hide show
  1. package/README.md +115 -0
  2. package/dist/apiRequestContext.d.ts +52 -0
  3. package/dist/apiRequestContext.d.ts.map +1 -0
  4. package/dist/apiRequestContext.js +632 -0
  5. package/dist/apiRequestContext.js.map +1 -0
  6. package/dist/ariaSnapshot.d.ts +38 -0
  7. package/dist/ariaSnapshot.d.ts.map +1 -0
  8. package/dist/ariaSnapshot.js +1137 -0
  9. package/dist/ariaSnapshot.js.map +1 -0
  10. package/dist/assertions.d.ts +2 -0
  11. package/dist/assertions.d.ts.map +1 -0
  12. package/dist/assertions.js +6 -0
  13. package/dist/assertions.js.map +1 -0
  14. package/dist/bin/roxybrowser-mcp.d.ts +3 -0
  15. package/dist/bin/roxybrowser-mcp.d.ts.map +1 -0
  16. package/dist/bin/roxybrowser-mcp.js +7 -0
  17. package/dist/bin/roxybrowser-mcp.js.map +1 -0
  18. package/dist/browser.d.ts +15 -0
  19. package/dist/browser.d.ts.map +1 -0
  20. package/dist/browser.js +67 -0
  21. package/dist/browser.js.map +1 -0
  22. package/dist/browserContext.d.ts +156 -0
  23. package/dist/browserContext.d.ts.map +1 -0
  24. package/dist/browserContext.js +1129 -0
  25. package/dist/browserContext.js.map +1 -0
  26. package/dist/browserContextClock.d.ts +54 -0
  27. package/dist/browserContextClock.d.ts.map +1 -0
  28. package/dist/browserContextClock.js +147 -0
  29. package/dist/browserContextClock.js.map +1 -0
  30. package/dist/browserType.d.ts +16 -0
  31. package/dist/browserType.d.ts.map +1 -0
  32. package/dist/browserType.js +68 -0
  33. package/dist/browserType.js.map +1 -0
  34. package/dist/bundle.d.ts +20 -0
  35. package/dist/bundle.d.ts.map +1 -0
  36. package/dist/bundle.js +20 -0
  37. package/dist/bundle.js.map +1 -0
  38. package/dist/clock.d.ts +43 -0
  39. package/dist/clock.d.ts.map +1 -0
  40. package/dist/clock.js +70 -0
  41. package/dist/clock.js.map +1 -0
  42. package/dist/elementHandle.d.ts +100 -0
  43. package/dist/elementHandle.d.ts.map +1 -0
  44. package/dist/elementHandle.js +423 -0
  45. package/dist/elementHandle.js.map +1 -0
  46. package/dist/errors.d.ts +10 -0
  47. package/dist/errors.d.ts.map +1 -0
  48. package/dist/errors.js +19 -0
  49. package/dist/errors.js.map +1 -0
  50. package/dist/evaluation.d.ts +4 -0
  51. package/dist/evaluation.d.ts.map +1 -0
  52. package/dist/evaluation.js +9 -0
  53. package/dist/evaluation.js.map +1 -0
  54. package/dist/frame.d.ts +139 -0
  55. package/dist/frame.d.ts.map +1 -0
  56. package/dist/frame.js +451 -0
  57. package/dist/frame.js.map +1 -0
  58. package/dist/httpHeaders.d.ts +6 -0
  59. package/dist/httpHeaders.d.ts.map +1 -0
  60. package/dist/httpHeaders.js +23 -0
  61. package/dist/httpHeaders.js.map +1 -0
  62. package/dist/human/controller.d.ts +15 -0
  63. package/dist/human/controller.d.ts.map +1 -0
  64. package/dist/human/controller.js +67 -0
  65. package/dist/human/controller.js.map +1 -0
  66. package/dist/human/profile.d.ts +5 -0
  67. package/dist/human/profile.d.ts.map +1 -0
  68. package/dist/human/profile.js +50 -0
  69. package/dist/human/profile.js.map +1 -0
  70. package/dist/human/types.d.ts +28 -0
  71. package/dist/human/types.d.ts.map +1 -0
  72. package/dist/human/types.js +2 -0
  73. package/dist/human/types.js.map +1 -0
  74. package/dist/index.d.ts +7 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +3 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/inputFiles.d.ts +18 -0
  79. package/dist/inputFiles.d.ts.map +1 -0
  80. package/dist/inputFiles.js +192 -0
  81. package/dist/inputFiles.js.map +1 -0
  82. package/dist/jsHandle.d.ts +32 -0
  83. package/dist/jsHandle.d.ts.map +1 -0
  84. package/dist/jsHandle.js +148 -0
  85. package/dist/jsHandle.js.map +1 -0
  86. package/dist/locator.d.ts +190 -0
  87. package/dist/locator.d.ts.map +1 -0
  88. package/dist/locator.js +883 -0
  89. package/dist/locator.js.map +1 -0
  90. package/dist/locatorSelectors.d.ts +11 -0
  91. package/dist/locatorSelectors.d.ts.map +1 -0
  92. package/dist/locatorSelectors.js +50 -0
  93. package/dist/locatorSelectors.js.map +1 -0
  94. package/dist/mcp/backend/common.d.ts +4 -0
  95. package/dist/mcp/backend/common.d.ts.map +1 -0
  96. package/dist/mcp/backend/common.js +40 -0
  97. package/dist/mcp/backend/common.js.map +1 -0
  98. package/dist/mcp/backend/connect.d.ts +10 -0
  99. package/dist/mcp/backend/connect.d.ts.map +1 -0
  100. package/dist/mcp/backend/connect.js +30 -0
  101. package/dist/mcp/backend/connect.js.map +1 -0
  102. package/dist/mcp/backend/console.d.ts +13 -0
  103. package/dist/mcp/backend/console.d.ts.map +1 -0
  104. package/dist/mcp/backend/console.js +36 -0
  105. package/dist/mcp/backend/console.js.map +1 -0
  106. package/dist/mcp/backend/context.d.ts +27 -0
  107. package/dist/mcp/backend/context.d.ts.map +1 -0
  108. package/dist/mcp/backend/context.js +33 -0
  109. package/dist/mcp/backend/context.js.map +1 -0
  110. package/dist/mcp/backend/dialogs.d.ts +7 -0
  111. package/dist/mcp/backend/dialogs.d.ts.map +1 -0
  112. package/dist/mcp/backend/dialogs.js +24 -0
  113. package/dist/mcp/backend/dialogs.js.map +1 -0
  114. package/dist/mcp/backend/evaluate.d.ts +9 -0
  115. package/dist/mcp/backend/evaluate.d.ts.map +1 -0
  116. package/dist/mcp/backend/evaluate.js +31 -0
  117. package/dist/mcp/backend/evaluate.js.map +1 -0
  118. package/dist/mcp/backend/files.d.ts +9 -0
  119. package/dist/mcp/backend/files.d.ts.map +1 -0
  120. package/dist/mcp/backend/files.js +39 -0
  121. package/dist/mcp/backend/files.js.map +1 -0
  122. package/dist/mcp/backend/keyboard.d.ts +22 -0
  123. package/dist/mcp/backend/keyboard.d.ts.map +1 -0
  124. package/dist/mcp/backend/keyboard.js +67 -0
  125. package/dist/mcp/backend/keyboard.js.map +1 -0
  126. package/dist/mcp/backend/navigate.d.ts +4 -0
  127. package/dist/mcp/backend/navigate.d.ts.map +1 -0
  128. package/dist/mcp/backend/navigate.js +82 -0
  129. package/dist/mcp/backend/navigate.js.map +1 -0
  130. package/dist/mcp/backend/network.d.ts +17 -0
  131. package/dist/mcp/backend/network.d.ts.map +1 -0
  132. package/dist/mcp/backend/network.js +144 -0
  133. package/dist/mcp/backend/network.js.map +1 -0
  134. package/dist/mcp/backend/response.d.ts +26 -0
  135. package/dist/mcp/backend/response.d.ts.map +1 -0
  136. package/dist/mcp/backend/response.js +109 -0
  137. package/dist/mcp/backend/response.js.map +1 -0
  138. package/dist/mcp/backend/runCode.d.ts +6 -0
  139. package/dist/mcp/backend/runCode.d.ts.map +1 -0
  140. package/dist/mcp/backend/runCode.js +20 -0
  141. package/dist/mcp/backend/runCode.js.map +1 -0
  142. package/dist/mcp/backend/screenshot.d.ts +13 -0
  143. package/dist/mcp/backend/screenshot.d.ts.map +1 -0
  144. package/dist/mcp/backend/screenshot.js +37 -0
  145. package/dist/mcp/backend/screenshot.js.map +1 -0
  146. package/dist/mcp/backend/snapshot.d.ts +70 -0
  147. package/dist/mcp/backend/snapshot.d.ts.map +1 -0
  148. package/dist/mcp/backend/snapshot.js +185 -0
  149. package/dist/mcp/backend/snapshot.js.map +1 -0
  150. package/dist/mcp/backend/tab.d.ts +72 -0
  151. package/dist/mcp/backend/tab.d.ts.map +1 -0
  152. package/dist/mcp/backend/tab.js +99 -0
  153. package/dist/mcp/backend/tab.js.map +1 -0
  154. package/dist/mcp/backend/tabs.d.ts +13 -0
  155. package/dist/mcp/backend/tabs.d.ts.map +1 -0
  156. package/dist/mcp/backend/tabs.js +44 -0
  157. package/dist/mcp/backend/tabs.js.map +1 -0
  158. package/dist/mcp/backend/tool.d.ts +52 -0
  159. package/dist/mcp/backend/tool.d.ts.map +1 -0
  160. package/dist/mcp/backend/tool.js +28 -0
  161. package/dist/mcp/backend/tool.js.map +1 -0
  162. package/dist/mcp/backend/tools.d.ts +4 -0
  163. package/dist/mcp/backend/tools.d.ts.map +1 -0
  164. package/dist/mcp/backend/tools.js +30 -0
  165. package/dist/mcp/backend/tools.js.map +1 -0
  166. package/dist/mcp/connectedBrowser.d.ts +3 -0
  167. package/dist/mcp/connectedBrowser.d.ts.map +1 -0
  168. package/dist/mcp/connectedBrowser.js +2153 -0
  169. package/dist/mcp/connectedBrowser.js.map +1 -0
  170. package/dist/mcp/errors.d.ts +6 -0
  171. package/dist/mcp/errors.d.ts.map +1 -0
  172. package/dist/mcp/errors.js +12 -0
  173. package/dist/mcp/errors.js.map +1 -0
  174. package/dist/mcp/format.d.ts +12 -0
  175. package/dist/mcp/format.d.ts.map +1 -0
  176. package/dist/mcp/format.js +48 -0
  177. package/dist/mcp/format.js.map +1 -0
  178. package/dist/mcp/index.d.ts +6 -0
  179. package/dist/mcp/index.d.ts.map +1 -0
  180. package/dist/mcp/index.js +5 -0
  181. package/dist/mcp/index.js.map +1 -0
  182. package/dist/mcp/output.d.ts +7 -0
  183. package/dist/mcp/output.d.ts.map +1 -0
  184. package/dist/mcp/output.js +39 -0
  185. package/dist/mcp/output.js.map +1 -0
  186. package/dist/mcp/runtime.d.ts +122 -0
  187. package/dist/mcp/runtime.d.ts.map +1 -0
  188. package/dist/mcp/runtime.js +524 -0
  189. package/dist/mcp/runtime.js.map +1 -0
  190. package/dist/mcp/schemas.d.ts +61 -0
  191. package/dist/mcp/schemas.d.ts.map +1 -0
  192. package/dist/mcp/schemas.js +41 -0
  193. package/dist/mcp/schemas.js.map +1 -0
  194. package/dist/mcp/server.d.ts +3 -0
  195. package/dist/mcp/server.d.ts.map +1 -0
  196. package/dist/mcp/server.js +117 -0
  197. package/dist/mcp/server.js.map +1 -0
  198. package/dist/mcp/snapshot.d.ts +3 -0
  199. package/dist/mcp/snapshot.d.ts.map +1 -0
  200. package/dist/mcp/snapshot.js +3 -0
  201. package/dist/mcp/snapshot.js.map +1 -0
  202. package/dist/mcp/tool.d.ts +19 -0
  203. package/dist/mcp/tool.d.ts.map +1 -0
  204. package/dist/mcp/tool.js +10 -0
  205. package/dist/mcp/tool.js.map +1 -0
  206. package/dist/mcp/tools/common.d.ts +6 -0
  207. package/dist/mcp/tools/common.d.ts.map +1 -0
  208. package/dist/mcp/tools/common.js +34 -0
  209. package/dist/mcp/tools/common.js.map +1 -0
  210. package/dist/mcp/tools/connect.d.ts +6 -0
  211. package/dist/mcp/tools/connect.d.ts.map +1 -0
  212. package/dist/mcp/tools/connect.js +28 -0
  213. package/dist/mcp/tools/connect.js.map +1 -0
  214. package/dist/mcp/tools/console.d.ts +6 -0
  215. package/dist/mcp/tools/console.d.ts.map +1 -0
  216. package/dist/mcp/tools/console.js +36 -0
  217. package/dist/mcp/tools/console.js.map +1 -0
  218. package/dist/mcp/tools/dialog.d.ts +6 -0
  219. package/dist/mcp/tools/dialog.d.ts.map +1 -0
  220. package/dist/mcp/tools/dialog.js +22 -0
  221. package/dist/mcp/tools/dialog.js.map +1 -0
  222. package/dist/mcp/tools/evaluate.d.ts +6 -0
  223. package/dist/mcp/tools/evaluate.d.ts.map +1 -0
  224. package/dist/mcp/tools/evaluate.js +31 -0
  225. package/dist/mcp/tools/evaluate.js.map +1 -0
  226. package/dist/mcp/tools/form.d.ts +6 -0
  227. package/dist/mcp/tools/form.d.ts.map +1 -0
  228. package/dist/mcp/tools/form.js +129 -0
  229. package/dist/mcp/tools/form.js.map +1 -0
  230. package/dist/mcp/tools/index.d.ts +3 -0
  231. package/dist/mcp/tools/index.d.ts.map +1 -0
  232. package/dist/mcp/tools/index.js +7 -0
  233. package/dist/mcp/tools/index.js.map +1 -0
  234. package/dist/mcp/tools/keyboard.d.ts +3 -0
  235. package/dist/mcp/tools/keyboard.d.ts.map +1 -0
  236. package/dist/mcp/tools/keyboard.js +44 -0
  237. package/dist/mcp/tools/keyboard.js.map +1 -0
  238. package/dist/mcp/tools/mouse.d.ts +3 -0
  239. package/dist/mcp/tools/mouse.d.ts.map +1 -0
  240. package/dist/mcp/tools/mouse.js +89 -0
  241. package/dist/mcp/tools/mouse.js.map +1 -0
  242. package/dist/mcp/tools/navigate.d.ts +6 -0
  243. package/dist/mcp/tools/navigate.d.ts.map +1 -0
  244. package/dist/mcp/tools/navigate.js +74 -0
  245. package/dist/mcp/tools/navigate.js.map +1 -0
  246. package/dist/mcp/tools/network.d.ts +6 -0
  247. package/dist/mcp/tools/network.d.ts.map +1 -0
  248. package/dist/mcp/tools/network.js +142 -0
  249. package/dist/mcp/tools/network.js.map +1 -0
  250. package/dist/mcp/tools/runCode.d.ts +6 -0
  251. package/dist/mcp/tools/runCode.d.ts.map +1 -0
  252. package/dist/mcp/tools/runCode.js +24 -0
  253. package/dist/mcp/tools/runCode.js.map +1 -0
  254. package/dist/mcp/tools/screenshot.d.ts +6 -0
  255. package/dist/mcp/tools/screenshot.d.ts.map +1 -0
  256. package/dist/mcp/tools/screenshot.js +46 -0
  257. package/dist/mcp/tools/screenshot.js.map +1 -0
  258. package/dist/mcp/tools/snapshot.d.ts +6 -0
  259. package/dist/mcp/tools/snapshot.d.ts.map +1 -0
  260. package/dist/mcp/tools/snapshot.js +56 -0
  261. package/dist/mcp/tools/snapshot.js.map +1 -0
  262. package/dist/mcp/tools/tabs.d.ts +6 -0
  263. package/dist/mcp/tools/tabs.d.ts.map +1 -0
  264. package/dist/mcp/tools/tabs.js +34 -0
  265. package/dist/mcp/tools/tabs.js.map +1 -0
  266. package/dist/mcp/transports/http.d.ts +3 -0
  267. package/dist/mcp/transports/http.d.ts.map +1 -0
  268. package/dist/mcp/transports/http.js +134 -0
  269. package/dist/mcp/transports/http.js.map +1 -0
  270. package/dist/mcp/transports/inMemory.d.ts +3 -0
  271. package/dist/mcp/transports/inMemory.d.ts.map +1 -0
  272. package/dist/mcp/transports/inMemory.js +18 -0
  273. package/dist/mcp/transports/inMemory.js.map +1 -0
  274. package/dist/mcp/transports/stdio.d.ts +3 -0
  275. package/dist/mcp/transports/stdio.d.ts.map +1 -0
  276. package/dist/mcp/transports/stdio.js +16 -0
  277. package/dist/mcp/transports/stdio.js.map +1 -0
  278. package/dist/mcp/types.d.ts +193 -0
  279. package/dist/mcp/types.d.ts.map +1 -0
  280. package/dist/mcp/types.js +2 -0
  281. package/dist/mcp/types.js.map +1 -0
  282. package/dist/navigationResult.d.ts +10 -0
  283. package/dist/navigationResult.d.ts.map +1 -0
  284. package/dist/navigationResult.js +15 -0
  285. package/dist/navigationResult.js.map +1 -0
  286. package/dist/page.d.ts +907 -0
  287. package/dist/page.d.ts.map +1 -0
  288. package/dist/page.js +6385 -0
  289. package/dist/page.js.map +1 -0
  290. package/dist/pageApiReport.d.ts +31 -0
  291. package/dist/pageApiReport.d.ts.map +1 -0
  292. package/dist/pageApiReport.js +218 -0
  293. package/dist/pageApiReport.js.map +1 -0
  294. package/dist/pageResponse.d.ts +18 -0
  295. package/dist/pageResponse.d.ts.map +1 -0
  296. package/dist/pageResponse.js +23 -0
  297. package/dist/pageResponse.js.map +1 -0
  298. package/dist/processCleanup.d.ts +8 -0
  299. package/dist/processCleanup.d.ts.map +1 -0
  300. package/dist/processCleanup.js +413 -0
  301. package/dist/processCleanup.js.map +1 -0
  302. package/dist/protocol/adapter.d.ts +406 -0
  303. package/dist/protocol/adapter.d.ts.map +1 -0
  304. package/dist/protocol/adapter.js +8 -0
  305. package/dist/protocol/adapter.js.map +1 -0
  306. package/dist/protocol/bidi/backend.d.ts +8 -0
  307. package/dist/protocol/bidi/backend.d.ts.map +1 -0
  308. package/dist/protocol/bidi/backend.js +3616 -0
  309. package/dist/protocol/bidi/backend.js.map +1 -0
  310. package/dist/protocol/bidi/client.d.ts +104 -0
  311. package/dist/protocol/bidi/client.d.ts.map +1 -0
  312. package/dist/protocol/bidi/client.js +228 -0
  313. package/dist/protocol/bidi/client.js.map +1 -0
  314. package/dist/protocol/capabilities.d.ts +11 -0
  315. package/dist/protocol/capabilities.d.ts.map +1 -0
  316. package/dist/protocol/capabilities.js +2 -0
  317. package/dist/protocol/capabilities.js.map +1 -0
  318. package/dist/protocol/cdp/backend.d.ts +24 -0
  319. package/dist/protocol/cdp/backend.d.ts.map +1 -0
  320. package/dist/protocol/cdp/backend.js +8428 -0
  321. package/dist/protocol/cdp/backend.js.map +1 -0
  322. package/dist/protocol/evaluate.d.ts +2 -0
  323. package/dist/protocol/evaluate.d.ts.map +1 -0
  324. package/dist/protocol/evaluate.js +14 -0
  325. package/dist/protocol/evaluate.js.map +1 -0
  326. package/dist/protocol/evaluationSerializer.d.ts +6 -0
  327. package/dist/protocol/evaluationSerializer.d.ts.map +1 -0
  328. package/dist/protocol/evaluationSerializer.js +234 -0
  329. package/dist/protocol/evaluationSerializer.js.map +1 -0
  330. package/dist/protocol/keyboardInput.d.ts +34 -0
  331. package/dist/protocol/keyboardInput.d.ts.map +1 -0
  332. package/dist/protocol/keyboardInput.js +246 -0
  333. package/dist/protocol/keyboardInput.js.map +1 -0
  334. package/dist/protocol/routing.d.ts +40 -0
  335. package/dist/protocol/routing.d.ts.map +1 -0
  336. package/dist/protocol/routing.js +2 -0
  337. package/dist/protocol/routing.js.map +1 -0
  338. package/dist/protocol/selectorRuntime.d.ts +30 -0
  339. package/dist/protocol/selectorRuntime.d.ts.map +1 -0
  340. package/dist/protocol/selectorRuntime.js +1814 -0
  341. package/dist/protocol/selectorRuntime.js.map +1 -0
  342. package/dist/protocol/webdriver-classic/backend.d.ts +6 -0
  343. package/dist/protocol/webdriver-classic/backend.d.ts.map +1 -0
  344. package/dist/protocol/webdriver-classic/backend.js +158 -0
  345. package/dist/protocol/webdriver-classic/backend.js.map +1 -0
  346. package/dist/routeHandler.d.ts +15 -0
  347. package/dist/routeHandler.d.ts.map +1 -0
  348. package/dist/routeHandler.js +2 -0
  349. package/dist/routeHandler.js.map +1 -0
  350. package/dist/roxybrowser.bundle.js +78236 -0
  351. package/dist/roxybrowser.bundle.js.map +1 -0
  352. package/dist/screencast.d.ts +57 -0
  353. package/dist/screencast.d.ts.map +1 -0
  354. package/dist/screencast.js +155 -0
  355. package/dist/screencast.js.map +1 -0
  356. package/dist/screencastActions.d.ts +2 -0
  357. package/dist/screencastActions.d.ts.map +1 -0
  358. package/dist/screencastActions.js +183 -0
  359. package/dist/screencastActions.js.map +1 -0
  360. package/dist/screencastOverlay.d.ts +3 -0
  361. package/dist/screencastOverlay.d.ts.map +1 -0
  362. package/dist/screencastOverlay.js +119 -0
  363. package/dist/screencastOverlay.js.map +1 -0
  364. package/dist/screenshotOptions.d.ts +26 -0
  365. package/dist/screenshotOptions.d.ts.map +1 -0
  366. package/dist/screenshotOptions.js +171 -0
  367. package/dist/screenshotOptions.js.map +1 -0
  368. package/dist/screenshotPreparation.d.ts +21 -0
  369. package/dist/screenshotPreparation.d.ts.map +1 -0
  370. package/dist/screenshotPreparation.js +199 -0
  371. package/dist/screenshotPreparation.js.map +1 -0
  372. package/dist/selectOptionValues.d.ts +10 -0
  373. package/dist/selectOptionValues.d.ts.map +1 -0
  374. package/dist/selectOptionValues.js +60 -0
  375. package/dist/selectOptionValues.js.map +1 -0
  376. package/dist/selectors.d.ts +3 -0
  377. package/dist/selectors.d.ts.map +1 -0
  378. package/dist/selectors.js +287 -0
  379. package/dist/selectors.js.map +1 -0
  380. package/dist/types/api.d.ts +2164 -0
  381. package/dist/types/api.d.ts.map +1 -0
  382. package/dist/types/api.js +2 -0
  383. package/dist/types/api.js.map +1 -0
  384. package/dist/types/events.d.ts +158 -0
  385. package/dist/types/events.d.ts.map +1 -0
  386. package/dist/types/events.js +2 -0
  387. package/dist/types/events.js.map +1 -0
  388. package/dist/types/options.d.ts +263 -0
  389. package/dist/types/options.d.ts.map +1 -0
  390. package/dist/types/options.js +2 -0
  391. package/dist/types/options.js.map +1 -0
  392. package/dist/urlMatch.d.ts +19 -0
  393. package/dist/urlMatch.d.ts.map +1 -0
  394. package/dist/urlMatch.js +183 -0
  395. package/dist/urlMatch.js.map +1 -0
  396. package/dist/utilityScriptSerializers.d.ts +61 -0
  397. package/dist/utilityScriptSerializers.d.ts.map +1 -0
  398. package/dist/utilityScriptSerializers.js +297 -0
  399. package/dist/utilityScriptSerializers.js.map +1 -0
  400. package/dist/vendor/playwright/ariaSnapshotEvaluate.d.ts +2 -0
  401. package/dist/vendor/playwright/ariaSnapshotEvaluate.d.ts.map +1 -0
  402. package/dist/vendor/playwright/ariaSnapshotEvaluate.js +207 -0
  403. package/dist/vendor/playwright/ariaSnapshotEvaluate.js.map +1 -0
  404. package/dist/vendor/playwright/generated/clockSource.d.ts +9 -0
  405. package/dist/vendor/playwright/generated/clockSource.d.ts.map +1 -0
  406. package/dist/vendor/playwright/generated/clockSource.js +9 -0
  407. package/dist/vendor/playwright/generated/clockSource.js.map +1 -0
  408. package/dist/vendor/playwright/generated/injectedScriptSource.d.ts +9 -0
  409. package/dist/vendor/playwright/generated/injectedScriptSource.d.ts.map +1 -0
  410. package/dist/vendor/playwright/generated/injectedScriptSource.js +9 -0
  411. package/dist/vendor/playwright/generated/injectedScriptSource.js.map +1 -0
  412. package/dist/video.d.ts +39 -0
  413. package/dist/video.d.ts.map +1 -0
  414. package/dist/video.js +235 -0
  415. package/dist/video.js.map +1 -0
  416. package/dist/waitForSelector.d.ts +7 -0
  417. package/dist/waitForSelector.d.ts.map +1 -0
  418. package/dist/waitForSelector.js +23 -0
  419. package/dist/waitForSelector.js.map +1 -0
  420. package/dist/worker.d.ts +45 -0
  421. package/dist/worker.d.ts.map +1 -0
  422. package/dist/worker.js +192 -0
  423. package/dist/worker.js.map +1 -0
  424. package/package.json +82 -0
@@ -0,0 +1,1137 @@
1
+ import { TimeoutError } from "./errors.js";
2
+ export const ARIA_SNAPSHOT_EVALUATE_SOURCE = String.raw `(payload) => {
3
+ const options = payload && payload.options ? payload.options : {};
4
+ const target = payload && payload.target ? payload.target : undefined;
5
+ const maxDepth = typeof options.depth === "number" ? options.depth : undefined;
6
+ const includeBoxes = Boolean(options.boxes);
7
+ const mode = options.mode === "ai" ? "ai" : "default";
8
+ const rootDocument = document;
9
+ if (!rootDocument.body || rootDocument.readyState === "loading") {
10
+ return { notReady: true, refs: {}, text: "", title: String(rootDocument.title || ""), url: String(globalThis.location?.href || "") };
11
+ }
12
+ const previousState = globalThis.__roxyMcpState ?? {
13
+ elements: new Map(),
14
+ refs: new Map(),
15
+ nextRefId: 1,
16
+ nextNodeId: 1
17
+ };
18
+ const previousElements = previousState.elements instanceof Map ? previousState.elements : new Map();
19
+ const globalState = {
20
+ elements: new Map(),
21
+ refs: new Map(),
22
+ nextRefId: typeof previousState.nextRefId === "number" ? previousState.nextRefId : 1,
23
+ nextNodeId: typeof previousState.nextNodeId === "number" ? previousState.nextNodeId : 1,
24
+ nextFrameId: 1
25
+ };
26
+ globalState.elements = new Map();
27
+ globalState.refs = new Map();
28
+ globalThis.__roxyMcpState = globalState;
29
+
30
+ const structuralRolesWithoutImplicitName = new Set([
31
+ "article",
32
+ "banner",
33
+ "blockquote",
34
+ "complementary",
35
+ "contentinfo",
36
+ "dialog",
37
+ "figure",
38
+ "form",
39
+ "generic",
40
+ "group",
41
+ "list",
42
+ "listbox",
43
+ "listitem",
44
+ "main",
45
+ "navigation",
46
+ "paragraph",
47
+ "row",
48
+ "rowgroup",
49
+ "search",
50
+ "section",
51
+ "separator",
52
+ "table"
53
+ ]);
54
+
55
+ function isAriaHidden(element) {
56
+ let current = element;
57
+ while (current) {
58
+ if (current.getAttribute && current.getAttribute("aria-hidden") === "true") {
59
+ return true;
60
+ }
61
+ current = current.parentElement;
62
+ }
63
+ return false;
64
+ }
65
+
66
+ function isElementVisible(element) {
67
+ if (!element || !element.isConnected) {
68
+ return false;
69
+ }
70
+
71
+ const style = globalThis.getComputedStyle(element);
72
+ if (!style || style.visibility === "hidden" || style.display === "none") {
73
+ return false;
74
+ }
75
+
76
+ const rect = element.getBoundingClientRect();
77
+ return rect.width > 0 && rect.height > 0;
78
+ }
79
+
80
+ function normalizeWhitespace(value) {
81
+ return String(value ?? "").replace(/\s+/g, " ").trim();
82
+ }
83
+
84
+ function formatInlineText(value) {
85
+ const text = normalizeWhitespace(value);
86
+ if (!text) {
87
+ return "";
88
+ }
89
+ return /^[\w\s.,!?:;<>/=+-]+$/.test(text) ? text : JSON.stringify(text);
90
+ }
91
+
92
+ function receivesPointerEvents(element) {
93
+ const style = globalThis.getComputedStyle(element);
94
+ return !style || style.pointerEvents !== "none";
95
+ }
96
+
97
+ function inferRole(element) {
98
+ const explicitRole = normalizeWhitespace(element.getAttribute("role"));
99
+ if (explicitRole) {
100
+ return explicitRole.split(" ")[0];
101
+ }
102
+
103
+ const tagName = element.tagName.toLowerCase();
104
+ if (tagName === "a" && element.hasAttribute("href")) {
105
+ return "link";
106
+ }
107
+ if (tagName === "button") {
108
+ return "button";
109
+ }
110
+ if (tagName === "input") {
111
+ const type = (element.getAttribute("type") || "text").toLowerCase();
112
+ if (type === "button" || type === "submit" || type === "reset") {
113
+ return "button";
114
+ }
115
+ if (type === "checkbox") {
116
+ return "checkbox";
117
+ }
118
+ if (type === "radio") {
119
+ return "radio";
120
+ }
121
+ if (type === "range") {
122
+ return "slider";
123
+ }
124
+ if (type === "number") {
125
+ return "spinbutton";
126
+ }
127
+ if (type === "search") {
128
+ return "searchbox";
129
+ }
130
+ return "textbox";
131
+ }
132
+ if (tagName === "textarea") {
133
+ return "textbox";
134
+ }
135
+ if (tagName === "select") {
136
+ return element.hasAttribute("multiple") || Number(element.getAttribute("size")) > 1
137
+ ? "listbox"
138
+ : "combobox";
139
+ }
140
+ if (tagName === "option") {
141
+ return "option";
142
+ }
143
+ if (tagName === "optgroup") {
144
+ return "group";
145
+ }
146
+ if (tagName === "img") {
147
+ return element.getAttribute("alt") === "" ? "presentation" : "img";
148
+ }
149
+ if (tagName === "ul" || tagName === "ol") {
150
+ return "list";
151
+ }
152
+ if (tagName === "li") {
153
+ return "listitem";
154
+ }
155
+ if (tagName === "label") {
156
+ return "label";
157
+ }
158
+ if (/^h[1-6]$/.test(tagName)) {
159
+ return "heading";
160
+ }
161
+ if (tagName === "main") {
162
+ return "main";
163
+ }
164
+ if (tagName === "nav") {
165
+ return "navigation";
166
+ }
167
+ if (tagName === "section") {
168
+ return "section";
169
+ }
170
+ if (tagName === "article") {
171
+ return "article";
172
+ }
173
+ if (tagName === "form") {
174
+ return "form";
175
+ }
176
+ if (tagName === "iframe") {
177
+ return "iframe";
178
+ }
179
+ if (tagName === "table") {
180
+ return "table";
181
+ }
182
+ if (tagName === "tr") {
183
+ return "row";
184
+ }
185
+ if (tagName === "th") {
186
+ return element.getAttribute("scope") === "row" ? "rowheader" : "columnheader";
187
+ }
188
+ if (tagName === "td") {
189
+ return "cell";
190
+ }
191
+ if (tagName === "thead" || tagName === "tbody" || tagName === "tfoot") {
192
+ return "rowgroup";
193
+ }
194
+ if (tagName === "caption") {
195
+ return "caption";
196
+ }
197
+ if (tagName === "details") {
198
+ return "group";
199
+ }
200
+ if (tagName === "summary") {
201
+ return "button";
202
+ }
203
+ if (tagName === "dialog") {
204
+ return "dialog";
205
+ }
206
+ if (tagName === "fieldset") {
207
+ return "group";
208
+ }
209
+ if (tagName === "legend") {
210
+ return "legend";
211
+ }
212
+ if (tagName === "figure") {
213
+ return "figure";
214
+ }
215
+ if (tagName === "figcaption") {
216
+ return "caption";
217
+ }
218
+ if (tagName === "progress") {
219
+ return "progressbar";
220
+ }
221
+ if (tagName === "meter") {
222
+ return "meter";
223
+ }
224
+ if (tagName === "output") {
225
+ return "status";
226
+ }
227
+ if (tagName === "hr") {
228
+ return "separator";
229
+ }
230
+ if (tagName === "blockquote") {
231
+ return "blockquote";
232
+ }
233
+ if (tagName === "p") {
234
+ return "paragraph";
235
+ }
236
+ if (tagName === "aside") {
237
+ return "complementary";
238
+ }
239
+ if (tagName === "header") {
240
+ return "banner";
241
+ }
242
+ if (tagName === "footer") {
243
+ return "contentinfo";
244
+ }
245
+ if (tagName === "search") {
246
+ return "search";
247
+ }
248
+ if (tagName === "menu") {
249
+ return "list";
250
+ }
251
+ if (tagName === "menuitem") {
252
+ return "menuitem";
253
+ }
254
+
255
+ return "generic";
256
+ }
257
+
258
+ function labelTextFor(element) {
259
+ if (!element.id) {
260
+ return "";
261
+ }
262
+ const ownerDocument = element.ownerDocument || rootDocument;
263
+ const escapedId = globalThis.CSS && globalThis.CSS.escape ? globalThis.CSS.escape(element.id) : element.id;
264
+ const labels = Array.from(ownerDocument.querySelectorAll('label[for="' + escapedId + '"]'));
265
+ return normalizeWhitespace(labels.map((label) => label.textContent || "").join(" "));
266
+ }
267
+
268
+ function accessibleName(element, role) {
269
+ const ownerDocument = element.ownerDocument || rootDocument;
270
+ const ariaLabel = normalizeWhitespace(element.getAttribute("aria-label"));
271
+ if (ariaLabel) {
272
+ return ariaLabel;
273
+ }
274
+
275
+ const labelledBy = normalizeWhitespace(element.getAttribute("aria-labelledby"));
276
+ if (labelledBy) {
277
+ const ids = labelledBy.split(" ").map((value) => value.trim()).filter(Boolean);
278
+ const text = ids
279
+ .map((id) => ownerDocument.getElementById(id))
280
+ .filter(Boolean)
281
+ .map((node) => node.textContent || "")
282
+ .join(" ");
283
+ const normalized = normalizeWhitespace(text);
284
+ if (normalized) {
285
+ return normalized;
286
+ }
287
+ }
288
+
289
+ const tagName = element.tagName.toLowerCase();
290
+ if (structuralRolesWithoutImplicitName.has(role)) {
291
+ return "";
292
+ }
293
+
294
+ if (tagName === "img") {
295
+ const alt = normalizeWhitespace(element.getAttribute("alt"));
296
+ if (alt) {
297
+ return alt;
298
+ }
299
+ }
300
+
301
+ if (role === "textbox") {
302
+ const label = labelTextFor(element);
303
+ if (label) {
304
+ return label;
305
+ }
306
+ const placeholder = normalizeWhitespace(element.getAttribute("placeholder"));
307
+ if (placeholder) {
308
+ return placeholder;
309
+ }
310
+ return "";
311
+ }
312
+
313
+ if (tagName === "select") {
314
+ const label = labelTextFor(element);
315
+ if (label) {
316
+ return label;
317
+ }
318
+ return "";
319
+ }
320
+
321
+ if (tagName === "input") {
322
+ const label = labelTextFor(element);
323
+ if (label) {
324
+ return label;
325
+ }
326
+ return "";
327
+ }
328
+
329
+ if (tagName === "iframe") {
330
+ const title = normalizeWhitespace(element.getAttribute("title"));
331
+ if (title) {
332
+ return title;
333
+ }
334
+ }
335
+
336
+ return normalizeWhitespace(element.textContent || "");
337
+ }
338
+
339
+ function createRef(element, frameIndex) {
340
+ const existingRef = element.__roxyAriaRef;
341
+ const prefix = frameIndex > 0 ? "f" + frameIndex : "";
342
+ const ref = typeof existingRef === "string" ? existingRef : prefix + "e" + globalState.nextRefId++;
343
+ element.__roxyAriaRef = ref;
344
+ const nodeToken = "n" + globalState.nextNodeId++;
345
+ globalState.elements.set(nodeToken, element);
346
+ globalState.refs.set(ref, nodeToken);
347
+ return { ref, nodeToken };
348
+ }
349
+
350
+ function ariaBoolean(element, attribute) {
351
+ const value = element.getAttribute(attribute);
352
+ if (value === null) {
353
+ return undefined;
354
+ }
355
+ const normalized = value.trim().toLowerCase();
356
+ if (normalized === "true") {
357
+ return true;
358
+ }
359
+ if (normalized === "false") {
360
+ return false;
361
+ }
362
+ if (normalized === "mixed") {
363
+ return "mixed";
364
+ }
365
+ return undefined;
366
+ }
367
+
368
+ function computeChecked(element, role) {
369
+ const ariaChecked = element.getAttribute("aria-checked");
370
+ if (ariaChecked !== null) {
371
+ const normalized = ariaChecked.trim().toLowerCase();
372
+ if (normalized === "mixed") {
373
+ return "mixed";
374
+ }
375
+ if (normalized === "true") {
376
+ return true;
377
+ }
378
+ if (normalized === "false") {
379
+ return false;
380
+ }
381
+ }
382
+ if (role === "checkbox" || role === "radio") {
383
+ if (element.indeterminate) {
384
+ return "mixed";
385
+ }
386
+ return Boolean(element.checked);
387
+ }
388
+ return undefined;
389
+ }
390
+
391
+ function computeDisabled(element) {
392
+ const ariaDisabled = ariaBoolean(element, "aria-disabled");
393
+ if (ariaDisabled === true) {
394
+ return true;
395
+ }
396
+ if (typeof element.disabled === "boolean" && element.disabled) {
397
+ return true;
398
+ }
399
+ return undefined;
400
+ }
401
+
402
+ function computeExpanded(element) {
403
+ const ariaExpanded = ariaBoolean(element, "aria-expanded");
404
+ if (ariaExpanded === true || ariaExpanded === false) {
405
+ return ariaExpanded;
406
+ }
407
+ if (element.tagName.toLowerCase() === "details") {
408
+ return Boolean(element.open);
409
+ }
410
+ return undefined;
411
+ }
412
+
413
+ function computePressed(element) {
414
+ const ariaPressed = element.getAttribute("aria-pressed");
415
+ if (ariaPressed === null) {
416
+ return undefined;
417
+ }
418
+ const normalized = ariaPressed.trim().toLowerCase();
419
+ if (normalized === "mixed") {
420
+ return "mixed";
421
+ }
422
+ if (normalized === "true") {
423
+ return true;
424
+ }
425
+ if (normalized === "false") {
426
+ return false;
427
+ }
428
+ return undefined;
429
+ }
430
+
431
+ function createAriaNode(element, frameIndex) {
432
+ const role = inferRole(element);
433
+ const name = accessibleName(element, role);
434
+ const rect = element.getBoundingClientRect();
435
+ const ariaLevel = element.getAttribute("aria-level");
436
+ const node = {
437
+ role,
438
+ name,
439
+ children: [],
440
+ ref: undefined,
441
+ active: element.ownerDocument.activeElement === element,
442
+ level: /^h[1-6]$/.test(element.tagName.toLowerCase())
443
+ ? Number(element.tagName[1])
444
+ : ariaLevel !== null && Number.isFinite(Number(ariaLevel))
445
+ ? Number(ariaLevel)
446
+ : undefined,
447
+ checked: undefined,
448
+ selected: undefined,
449
+ disabled: undefined,
450
+ expanded: undefined,
451
+ pressed: undefined,
452
+ box: {
453
+ x: Math.round(rect.x),
454
+ y: Math.round(rect.y),
455
+ width: Math.round(rect.width),
456
+ height: Math.round(rect.height)
457
+ }
458
+ };
459
+
460
+ if (
461
+ mode === "ai" &&
462
+ isElementVisible(element) &&
463
+ receivesPointerEvents(element)
464
+ ) {
465
+ node.ref = createRef(element, frameIndex).ref;
466
+ }
467
+
468
+ const checked = computeChecked(element, role);
469
+ if (checked !== undefined) {
470
+ node.checked = checked;
471
+ }
472
+
473
+ if (role === "option") {
474
+ node.selected = Boolean(element.selected);
475
+ } else {
476
+ const ariaSelected = ariaBoolean(element, "aria-selected");
477
+ if (ariaSelected === true) {
478
+ node.selected = true;
479
+ }
480
+ }
481
+
482
+ node.disabled = computeDisabled(element);
483
+ node.expanded = computeExpanded(element);
484
+ node.pressed = computePressed(element);
485
+
486
+ if (role === "textbox" && typeof element.value === "string" && element.type !== "checkbox" && element.type !== "radio") {
487
+ node.children.push(element.value);
488
+ }
489
+
490
+ return node;
491
+ }
492
+
493
+ function resolveRootNode() {
494
+ if (!target) {
495
+ return {
496
+ ok: true,
497
+ node: rootDocument.body || rootDocument.documentElement
498
+ };
499
+ }
500
+
501
+ if (target.nodeToken) {
502
+ const element = previousElements.get(String(target.nodeToken));
503
+ if (!element || !element.isConnected) {
504
+ return {
505
+ ok: false,
506
+ error: {
507
+ code: "stale"
508
+ }
509
+ };
510
+ }
511
+ return {
512
+ ok: true,
513
+ node: element
514
+ };
515
+ }
516
+
517
+ if (target.selector) {
518
+ try {
519
+ const elements = Array.from(rootDocument.querySelectorAll(String(target.selector)));
520
+ if (elements.length === 0) {
521
+ return {
522
+ ok: false,
523
+ error: {
524
+ code: "not_found",
525
+ message: '"' + String(target.selector) + '" does not match any element.'
526
+ }
527
+ };
528
+ }
529
+ if (elements.length > 1) {
530
+ return {
531
+ ok: false,
532
+ error: {
533
+ code: "strict",
534
+ message: 'strict mode violation: "' + String(target.selector) + '" matches multiple elements.'
535
+ }
536
+ };
537
+ }
538
+ return {
539
+ ok: true,
540
+ node: elements[0]
541
+ };
542
+ } catch (error) {
543
+ return {
544
+ ok: false,
545
+ error: {
546
+ code: "invalid_selector",
547
+ message: String(error && error.message ? error.message : error)
548
+ }
549
+ };
550
+ }
551
+ }
552
+
553
+ return {
554
+ ok: false,
555
+ error: {
556
+ code: "not_found"
557
+ }
558
+ };
559
+ }
560
+
561
+ function visitDom(parentAriaNode, node, forceInclude, frameIndex) {
562
+ if (!node) {
563
+ return;
564
+ }
565
+
566
+ if (node.nodeType === Node.TEXT_NODE) {
567
+ const text = normalizeWhitespace(node.nodeValue || "");
568
+ if (text && parentAriaNode.role !== "textbox") {
569
+ parentAriaNode.children.push(text);
570
+ }
571
+ return;
572
+ }
573
+
574
+ if (node.nodeType !== Node.ELEMENT_NODE) {
575
+ return;
576
+ }
577
+
578
+ const element = node;
579
+
580
+ // Skip aria-hidden subtrees (but not when we're force-including a target root)
581
+ if (!forceInclude && isAriaHidden(element)) {
582
+ return;
583
+ }
584
+
585
+ const visible = isElementVisible(element);
586
+ const role = inferRole(element);
587
+
588
+ // role=presentation and role=none strip semantics: traverse children under the parent
589
+ if (role === "presentation" || role === "none") {
590
+ for (const child of Array.from(element.childNodes)) {
591
+ visitDom(parentAriaNode, child, false, frameIndex);
592
+ }
593
+ return;
594
+ }
595
+
596
+ const include = forceInclude || visible || role === "iframe";
597
+ const ariaNode = include ? createAriaNode(element, frameIndex) : parentAriaNode;
598
+
599
+ if (include) {
600
+ parentAriaNode.children.push(ariaNode);
601
+ }
602
+
603
+ if (ariaNode.role === "iframe" && mode === "ai") {
604
+ try {
605
+ const frameDocument = element.contentDocument;
606
+ const frameBody = frameDocument && (frameDocument.body || frameDocument.documentElement);
607
+ if (frameBody) {
608
+ const childFrameIndex = globalState.nextFrameId++;
609
+ for (const child of Array.from(frameBody.childNodes)) {
610
+ visitDom(ariaNode, child, false, childFrameIndex);
611
+ }
612
+ return;
613
+ }
614
+ } catch {}
615
+ }
616
+
617
+ const assignedNodes = element.tagName === "SLOT" && typeof element.assignedNodes === "function"
618
+ ? element.assignedNodes()
619
+ : [];
620
+ if (assignedNodes.length) {
621
+ for (const child of Array.from(assignedNodes)) {
622
+ visitDom(ariaNode, child, false, frameIndex);
623
+ }
624
+ } else {
625
+ for (const child of Array.from(element.childNodes)) {
626
+ if (!child.assignedSlot) {
627
+ visitDom(ariaNode, child, false, frameIndex);
628
+ }
629
+ }
630
+ if (element.shadowRoot) {
631
+ for (const child of Array.from(element.shadowRoot.childNodes)) {
632
+ visitDom(ariaNode, child, false, frameIndex);
633
+ }
634
+ }
635
+ }
636
+ }
637
+
638
+ function normalizeChildren(node) {
639
+ const normalizedChildren = [];
640
+ const textBuffer = [];
641
+
642
+ const flushText = () => {
643
+ if (!textBuffer.length) {
644
+ return;
645
+ }
646
+ const text = normalizeWhitespace(textBuffer.join(" "));
647
+ if (text) {
648
+ normalizedChildren.push(text);
649
+ }
650
+ textBuffer.length = 0;
651
+ };
652
+
653
+ for (const child of node.children) {
654
+ if (typeof child === "string") {
655
+ textBuffer.push(child);
656
+ continue;
657
+ }
658
+ flushText();
659
+ normalizeChildren(child);
660
+ normalizedChildren.push(child);
661
+ }
662
+ flushText();
663
+ node.children = normalizedChildren;
664
+ if (node.children.length === 1 && node.children[0] === node.name) {
665
+ node.children = [];
666
+ }
667
+ }
668
+
669
+ function flattenGenericNodes(node) {
670
+ const flattenedChildren = [];
671
+ for (const child of node.children) {
672
+ if (typeof child === "string") {
673
+ flattenedChildren.push(child);
674
+ continue;
675
+ }
676
+ const flattened = flattenGenericNodes(child);
677
+ for (const nested of flattened) {
678
+ flattenedChildren.push(nested);
679
+ }
680
+ }
681
+ node.children = flattenedChildren;
682
+ const removeSelf =
683
+ node.role === "generic" &&
684
+ !node.name &&
685
+ flattenedChildren.length <= 1 &&
686
+ flattenedChildren.every((child) => typeof child !== "string" && child.ref);
687
+ return removeSelf ? flattenedChildren : [node];
688
+ }
689
+
690
+ function renderNode(node, depth, lines) {
691
+ if (maxDepth !== undefined && depth > maxDepth) {
692
+ return;
693
+ }
694
+
695
+ let line = " ".repeat(depth) + "- " + node.role;
696
+ if (node.name) {
697
+ line += " " + JSON.stringify(node.name);
698
+ }
699
+ if (node.checked === "mixed") {
700
+ line += " [checked=mixed]";
701
+ } else if (node.checked) {
702
+ line += " [checked]";
703
+ }
704
+ if (node.disabled) {
705
+ line += " [disabled]";
706
+ }
707
+ if (node.expanded === true) {
708
+ line += " [expanded]";
709
+ } else if (node.expanded === false) {
710
+ line += " [collapsed]";
711
+ }
712
+ if (node.level) {
713
+ line += " [level=" + node.level + "]";
714
+ }
715
+ if (node.pressed === "mixed") {
716
+ line += " [pressed=mixed]";
717
+ } else if (node.pressed === true) {
718
+ line += " [pressed]";
719
+ }
720
+ if (node.selected) {
721
+ line += " [selected]";
722
+ }
723
+ if (node.active) {
724
+ line += " [active]";
725
+ }
726
+ if (node.ref) {
727
+ line += " [ref=" + node.ref + "]";
728
+ }
729
+ if (includeBoxes) {
730
+ line += " [box=" + [node.box.x, node.box.y, node.box.width, node.box.height].join(",") + "]";
731
+ }
732
+
733
+ const singleInlineText =
734
+ node.children.length === 1 && typeof node.children[0] === "string"
735
+ ? formatInlineText(node.children[0])
736
+ : "";
737
+ const depthLimited = maxDepth !== undefined && depth === maxDepth;
738
+
739
+ if (singleInlineText) {
740
+ lines.push(line + ": " + singleInlineText);
741
+ return;
742
+ }
743
+
744
+ if (!node.children.length || depthLimited) {
745
+ lines.push(line);
746
+ return;
747
+ }
748
+
749
+ lines.push(line + ":");
750
+ for (const child of node.children) {
751
+ if (typeof child === "string") {
752
+ const text = formatInlineText(child);
753
+ if (text) {
754
+ lines.push(" ".repeat(depth + 1) + "- text: " + text);
755
+ }
756
+ continue;
757
+ }
758
+ renderNode(child, depth + 1, lines);
759
+ }
760
+ }
761
+
762
+ const resolvedRoot = resolveRootNode();
763
+ if (!resolvedRoot.ok) {
764
+ return {
765
+ refs: {},
766
+ text: "",
767
+ title: normalizeWhitespace(rootDocument.title || ""),
768
+ url: String(globalThis.location?.href || ""),
769
+ error: resolvedRoot.error
770
+ };
771
+ }
772
+
773
+ const root = {
774
+ role: "fragment",
775
+ children: []
776
+ };
777
+ visitDom(root, resolvedRoot.node, Boolean(target), 0);
778
+ for (const child of root.children) {
779
+ if (typeof child !== "string") {
780
+ normalizeChildren(child);
781
+ }
782
+ }
783
+
784
+ const renderedRoots = [];
785
+ for (const child of root.children) {
786
+ if (typeof child === "string") {
787
+ const text = formatInlineText(child);
788
+ if (text) {
789
+ renderedRoots.push(text);
790
+ }
791
+ continue;
792
+ }
793
+ for (const flattened of flattenGenericNodes(child)) {
794
+ renderedRoots.push(flattened);
795
+ }
796
+ }
797
+
798
+ const lines = [];
799
+ for (const child of renderedRoots) {
800
+ if (typeof child === "string") {
801
+ lines.push("- text: " + child);
802
+ continue;
803
+ }
804
+ renderNode(child, 0, lines);
805
+ }
806
+
807
+ return {
808
+ refs: Object.fromEntries(globalState.refs.entries()),
809
+ text: lines.join("\n"),
810
+ title: normalizeWhitespace(rootDocument.title || ""),
811
+ url: String(globalThis.location?.href || "")
812
+ };
813
+ }`;
814
+ export const ARIA_REF_SELECTOR_EVALUATE_SOURCE = String.raw `(payload) => {
815
+ const ref = String(payload && payload.ref ? payload.ref : "");
816
+ const state = globalThis.__roxyMcpState;
817
+ if (!state || !state.refs || !state.elements) {
818
+ return { ok: false, reason: "stale" };
819
+ }
820
+
821
+ const nodeToken = state.refs.get(ref);
822
+ if (!nodeToken) {
823
+ return { ok: false, reason: "stale" };
824
+ }
825
+
826
+ const element = state.elements.get(nodeToken);
827
+ if (!element || !element.isConnected) {
828
+ return { ok: false, reason: "stale" };
829
+ }
830
+
831
+ function cssEscape(value) {
832
+ const input = String(value);
833
+ if (globalThis.CSS && typeof globalThis.CSS.escape === "function") {
834
+ return globalThis.CSS.escape(input);
835
+ }
836
+
837
+ let output = "";
838
+ for (let index = 0; index < input.length; index += 1) {
839
+ const character = input.charCodeAt(index);
840
+ const symbol = input.charAt(index);
841
+
842
+ if (character === 0x0000) {
843
+ output += "\uFFFD";
844
+ continue;
845
+ }
846
+
847
+ const isControlCharacter =
848
+ (character >= 0x0001 && character <= 0x001f) || character === 0x007f;
849
+ const isLeadingDigit = index === 0 && character >= 0x0030 && character <= 0x0039;
850
+ const isSecondDigitAfterLeadingHyphen =
851
+ index === 1 &&
852
+ character >= 0x0030 &&
853
+ character <= 0x0039 &&
854
+ input.charCodeAt(0) === 0x002d;
855
+ if (isControlCharacter || isLeadingDigit || isSecondDigitAfterLeadingHyphen) {
856
+ output += "\\" + character.toString(16) + " ";
857
+ continue;
858
+ }
859
+
860
+ if (index === 0 && input.length === 1 && symbol === "-") {
861
+ output += "\\-";
862
+ continue;
863
+ }
864
+
865
+ const isIdentifierCharacter =
866
+ character >= 0x0080 ||
867
+ character === 0x002d ||
868
+ character === 0x005f ||
869
+ (character >= 0x0030 && character <= 0x0039) ||
870
+ (character >= 0x0041 && character <= 0x005a) ||
871
+ (character >= 0x0061 && character <= 0x007a);
872
+
873
+ output += isIdentifierCharacter ? symbol : "\\" + symbol;
874
+ }
875
+
876
+ return output;
877
+ }
878
+
879
+ function stringLiteral(value) {
880
+ return JSON.stringify(String(value));
881
+ }
882
+
883
+ function xpathLiteral(value) {
884
+ const input = String(value);
885
+ if (!input.includes('"')) {
886
+ return '"' + input + '"';
887
+ }
888
+ if (!input.includes("'")) {
889
+ return "'" + input + "'";
890
+ }
891
+ return "concat(" + input.split('"').map((part, index, items) => {
892
+ const tokens = [];
893
+ if (part) {
894
+ tokens.push('"' + part + '"');
895
+ }
896
+ if (index < items.length - 1) {
897
+ tokens.push("'\"'");
898
+ }
899
+ return tokens.join(", ");
900
+ }).filter(Boolean).join(", ") + ")";
901
+ }
902
+
903
+ function nthOfType(element) {
904
+ let index = 1;
905
+ let sibling = element.previousElementSibling;
906
+ while (sibling) {
907
+ if (sibling.tagName === element.tagName) {
908
+ index += 1;
909
+ }
910
+ sibling = sibling.previousElementSibling;
911
+ }
912
+ return index;
913
+ }
914
+
915
+ function hasUniqueIdInDocument(target) {
916
+ if (!target || !target.ownerDocument || !target.id || isInShadowTree(target)) {
917
+ return false;
918
+ }
919
+
920
+ const selector = "#" + cssEscape(target.id);
921
+ const matches = target.ownerDocument.querySelectorAll(selector);
922
+ return matches.length === 1 && matches[0] === target;
923
+ }
924
+
925
+ function isInShadowTree(node) {
926
+ if (!node || typeof node.getRootNode !== "function") {
927
+ return false;
928
+ }
929
+ const root = node.getRootNode();
930
+ return Boolean(root && root.host);
931
+ }
932
+
933
+ function selectorWithinDocument(target) {
934
+ if (!target || !target.ownerDocument || isInShadowTree(target)) {
935
+ return null;
936
+ }
937
+
938
+ const document = target.ownerDocument;
939
+ if (hasUniqueIdInDocument(target)) {
940
+ const selector = "#" + cssEscape(target.id);
941
+ return selector;
942
+ }
943
+
944
+ const segments = [];
945
+ let current = target;
946
+ while (current && current.nodeType === Node.ELEMENT_NODE && current !== document.documentElement) {
947
+ if (hasUniqueIdInDocument(current)) {
948
+ const selector = "#" + cssEscape(current.id);
949
+ segments.unshift(selector);
950
+ break;
951
+ }
952
+
953
+ const tagName = current.tagName.toLowerCase();
954
+ segments.unshift(tagName + ":nth-of-type(" + nthOfType(current) + ")");
955
+ current = current.parentElement;
956
+ if (current && isInShadowTree(current)) {
957
+ return null;
958
+ }
959
+ }
960
+
961
+ if (current === document.documentElement) {
962
+ segments.unshift("html");
963
+ }
964
+
965
+ return segments.join(" > ");
966
+ }
967
+
968
+ function xpathWithinDocument(target) {
969
+ if (!target || !target.ownerDocument || isInShadowTree(target)) {
970
+ return null;
971
+ }
972
+
973
+ if (hasUniqueIdInDocument(target)) {
974
+ return "//*[@id=" + xpathLiteral(target.id) + "]";
975
+ }
976
+
977
+ const segments = [];
978
+ let current = target;
979
+ while (current && current.nodeType === Node.ELEMENT_NODE) {
980
+ const tagName = current.tagName.toLowerCase();
981
+ let index = 1;
982
+ let sibling = current.previousElementSibling;
983
+ while (sibling) {
984
+ if (sibling.tagName === current.tagName) {
985
+ index += 1;
986
+ }
987
+ sibling = sibling.previousElementSibling;
988
+ }
989
+
990
+ segments.unshift(tagName + "[" + index + "]");
991
+ current = current.parentElement;
992
+ if (current && isInShadowTree(current)) {
993
+ return null;
994
+ }
995
+ }
996
+
997
+ return "/" + segments.join("/");
998
+ }
999
+
1000
+ function framePathForDocument(document) {
1001
+ const path = [];
1002
+ let view = document.defaultView;
1003
+ while (view && view.frameElement) {
1004
+ const frameElement = view.frameElement;
1005
+ path.unshift({
1006
+ selector: selectorWithinDocument(frameElement),
1007
+ xpath: xpathWithinDocument(frameElement)
1008
+ });
1009
+ view = frameElement.ownerDocument.defaultView;
1010
+ }
1011
+ return path;
1012
+ }
1013
+
1014
+ function buildQuerySelectorChain(framePath, selector) {
1015
+ if (!selector) {
1016
+ return null;
1017
+ }
1018
+
1019
+ let expression = "document";
1020
+ for (const frame of framePath) {
1021
+ if (!frame.selector) {
1022
+ return null;
1023
+ }
1024
+ expression += ".querySelector(" + stringLiteral(frame.selector) + ")";
1025
+ expression += "?.contentDocument";
1026
+ }
1027
+
1028
+ expression += ".querySelector(" + stringLiteral(selector) + ")";
1029
+ return expression;
1030
+ }
1031
+
1032
+ const selector = selectorWithinDocument(element);
1033
+ const xpath = xpathWithinDocument(element);
1034
+ const framePath = framePathForDocument(element.ownerDocument);
1035
+ const querySelectorChain = buildQuerySelectorChain(framePath, selector);
1036
+
1037
+ return {
1038
+ ok: true,
1039
+ ref,
1040
+ selector,
1041
+ xpath,
1042
+ querySelector: framePath.length === 0 && selector
1043
+ ? "document.querySelector(" + stringLiteral(selector) + ")"
1044
+ : null,
1045
+ querySelectorChain,
1046
+ framePath,
1047
+ inShadowTree: isInShadowTree(element)
1048
+ };
1049
+ }`;
1050
+ export const ACTION_POINT_BY_SELECTOR_SOURCE = String.raw `(payload) => {
1051
+ const element = document.querySelector(payload.selector);
1052
+ if (!element || !element.isConnected) {
1053
+ return { ok: false, reason: "not_found" };
1054
+ }
1055
+ element.scrollIntoView({ block: "center", inline: "center" });
1056
+ const rect = element.getBoundingClientRect();
1057
+ if (!rect || rect.width <= 0 || rect.height <= 0) {
1058
+ return { ok: false, reason: "hidden" };
1059
+ }
1060
+ return {
1061
+ ok: true,
1062
+ x: rect.left + rect.width / 2,
1063
+ y: rect.top + rect.height / 2
1064
+ };
1065
+ }`;
1066
+ export const ACTION_POINT_EVALUATE_SOURCE = String.raw `(payload) => {
1067
+ const state = globalThis.__roxyMcpState;
1068
+ if (!state || !state.elements || !state.elements.has(payload.nodeToken)) {
1069
+ return { ok: false, reason: "stale" };
1070
+ }
1071
+
1072
+ const element = state.elements.get(payload.nodeToken);
1073
+ if (!element || !element.isConnected) {
1074
+ return { ok: false, reason: "stale" };
1075
+ }
1076
+
1077
+ element.scrollIntoView({ block: "center", inline: "center" });
1078
+ const rect = element.getBoundingClientRect();
1079
+ if (!rect || rect.width <= 0 || rect.height <= 0) {
1080
+ return { ok: false, reason: "hidden" };
1081
+ }
1082
+
1083
+ return {
1084
+ ok: true,
1085
+ x: rect.left + rect.width / 2,
1086
+ y: rect.top + rect.height / 2
1087
+ };
1088
+ }`;
1089
+ export async function withOptionalTimeout(action, timeout, message) {
1090
+ if (!timeout || timeout <= 0) {
1091
+ return action;
1092
+ }
1093
+ return new Promise((resolve, reject) => {
1094
+ const timer = setTimeout(() => {
1095
+ reject(new TimeoutError(message));
1096
+ }, timeout);
1097
+ void action.then((result) => {
1098
+ clearTimeout(timer);
1099
+ resolve(result);
1100
+ }, (error) => {
1101
+ clearTimeout(timer);
1102
+ reject(error);
1103
+ });
1104
+ });
1105
+ }
1106
+ export function normalizeAriaSnapshotOptions(options = {}) {
1107
+ return {
1108
+ ...(options.boxes !== undefined ? { boxes: options.boxes } : {}),
1109
+ ...(options.depth !== undefined ? { depth: options.depth } : {}),
1110
+ ...(options.mode !== undefined ? { mode: options.mode } : {}),
1111
+ ...(options.timeout !== undefined ? { timeout: options.timeout } : {})
1112
+ };
1113
+ }
1114
+ export async function retryUntilReady(fn, { timeoutMs = 15_000 } = {}) {
1115
+ const delays = [100, 250, 500, 1000, 2000, 4000];
1116
+ const deadline = Date.now() + timeoutMs;
1117
+ let attempt = 0;
1118
+ let lastError;
1119
+ while (true) {
1120
+ try {
1121
+ const result = await fn();
1122
+ if (!result.notReady)
1123
+ return result;
1124
+ }
1125
+ catch (error) {
1126
+ // context detached during navigation — will retry
1127
+ lastError = error;
1128
+ }
1129
+ const backoff = delays[Math.min(attempt++, delays.length - 1)] ?? 4000;
1130
+ if (Date.now() + backoff >= deadline) {
1131
+ const detail = lastError instanceof Error ? ` Last error: ${lastError.message}` : "";
1132
+ throw new TimeoutError(`Timed out waiting for the page to be ready for a snapshot.${detail}`);
1133
+ }
1134
+ await new Promise(resolve => setTimeout(resolve, backoff));
1135
+ }
1136
+ }
1137
+ //# sourceMappingURL=ariaSnapshot.js.map