spana-test 0.16.0 → 0.19.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 (308) hide show
  1. package/README.md +11 -0
  2. package/dist/accessibility-audit-IWTD2HPR.js +17 -0
  3. package/dist/agent/index.js +36 -33
  4. package/dist/agent/index.js.map +1 -1
  5. package/dist/{agent-fixture-H6GOUHNX.js → agent-fixture-WQVCNL73.js} +4 -3
  6. package/dist/{allure-XOM7BXL5.js → allure-LF4CALKP.js} +3 -2
  7. package/dist/{allure-XOM7BXL5.js.map → allure-LF4CALKP.js.map} +1 -1
  8. package/dist/{android-C2S4B4TH.js → android-TPO53H5Q.js} +4 -3
  9. package/dist/api/app.d.ts +79 -14
  10. package/dist/api/app.d.ts.map +1 -1
  11. package/dist/api/expect.d.ts +3 -0
  12. package/dist/api/expect.d.ts.map +1 -1
  13. package/dist/api/flow.d.ts +37 -14
  14. package/dist/api/flow.d.ts.map +1 -1
  15. package/dist/app-LGNFQMU7.js +17 -0
  16. package/dist/{appium-CC77BJNK.js → appium-2PJWZXJI.js} +64 -64
  17. package/dist/{appium-CC77BJNK.js.map → appium-2PJWZXJI.js.map} +1 -1
  18. package/dist/{appium-server-M6CWWUWF.js → appium-server-CCTQQGTV.js} +3 -2
  19. package/dist/{appium-server-M6CWWUWF.js.map → appium-server-CCTQQGTV.js.map} +1 -1
  20. package/dist/{baseline-manager-LVUVH2MJ.js → baseline-manager-XJ3LADKC.js} +3 -2
  21. package/dist/{baseline-manager-LVUVH2MJ.js.map → baseline-manager-XJ3LADKC.js.map} +1 -1
  22. package/dist/bridge-server-X5W4PCAR.js +13 -0
  23. package/dist/cache-command-OMV6DPC7.js +13 -0
  24. package/dist/channels/cdp-client.d.ts +15 -2
  25. package/dist/channels/cdp-client.d.ts.map +1 -1
  26. package/dist/channels/dom-channel.d.ts +31 -2
  27. package/dist/channels/dom-channel.d.ts.map +1 -1
  28. package/dist/{chunk-WJH5K42V.js → chunk-3HQKY24K.js} +4 -3
  29. package/dist/{chunk-WJH5K42V.js.map → chunk-3HQKY24K.js.map} +1 -1
  30. package/dist/{chunk-WBCAF7SC.js → chunk-3ONT32BO.js} +314 -182
  31. package/dist/chunk-3ONT32BO.js.map +1 -0
  32. package/dist/{chunk-HIEOI3WN.js → chunk-44U3F2RY.js} +264 -54
  33. package/dist/chunk-44U3F2RY.js.map +1 -0
  34. package/dist/{chunk-FHCOPLYB.js → chunk-4TTYSFBG.js} +4 -2
  35. package/dist/chunk-4TTYSFBG.js.map +1 -0
  36. package/dist/{chunk-4LJ3KYCX.js → chunk-5DSPPJ76.js} +4 -3
  37. package/dist/{chunk-4LJ3KYCX.js.map → chunk-5DSPPJ76.js.map} +1 -1
  38. package/dist/{accessibility-audit-F5KLUHLS.js → chunk-5TAHLRZD.js} +8 -5
  39. package/dist/chunk-5TAHLRZD.js.map +1 -0
  40. package/dist/chunk-67PLJEY2.js +24645 -0
  41. package/dist/chunk-67PLJEY2.js.map +1 -0
  42. package/dist/{chunk-JRGJTUPS.js → chunk-6X2SK2XO.js} +5 -4
  43. package/dist/{chunk-JRGJTUPS.js.map → chunk-6X2SK2XO.js.map} +1 -1
  44. package/dist/{chunk-CA66JCX2.js → chunk-7K24Q7V3.js} +976 -219
  45. package/dist/chunk-7K24Q7V3.js.map +1 -0
  46. package/dist/{chunk-2MA5G2VH.js → chunk-AGG2RJGU.js} +4 -3
  47. package/dist/{chunk-2MA5G2VH.js.map → chunk-AGG2RJGU.js.map} +1 -1
  48. package/dist/{chunk-LGFTUVN4.js → chunk-AP5SGSO7.js} +49 -48
  49. package/dist/{chunk-LGFTUVN4.js.map → chunk-AP5SGSO7.js.map} +1 -1
  50. package/dist/{chunk-NWGA3R2E.js → chunk-B4FOISOF.js} +3 -2
  51. package/dist/{chunk-NWGA3R2E.js.map → chunk-B4FOISOF.js.map} +1 -1
  52. package/dist/{chunk-7Q7TSUNL.js → chunk-B6NTHBPF.js} +3 -2
  53. package/dist/{chunk-7Q7TSUNL.js.map → chunk-B6NTHBPF.js.map} +1 -1
  54. package/dist/{chunk-7WHQIQPM.js → chunk-BPUBV7OF.js} +7 -4
  55. package/dist/chunk-BPUBV7OF.js.map +1 -0
  56. package/dist/{chunk-62SDNQKK.js → chunk-C2YM5GNF.js} +33 -32
  57. package/dist/{chunk-62SDNQKK.js.map → chunk-C2YM5GNF.js.map} +1 -1
  58. package/dist/{chunk-HJZT6YOA.js → chunk-C7HZJIGQ.js} +6 -5
  59. package/dist/{chunk-HJZT6YOA.js.map → chunk-C7HZJIGQ.js.map} +1 -1
  60. package/dist/{chunk-GMEVJQTT.js → chunk-CQ67PB3R.js} +5 -4
  61. package/dist/{chunk-GMEVJQTT.js.map → chunk-CQ67PB3R.js.map} +1 -1
  62. package/dist/{chunk-GDVHJBR2.js → chunk-CZAFFUMN.js} +5 -4
  63. package/dist/{chunk-GDVHJBR2.js.map → chunk-CZAFFUMN.js.map} +1 -1
  64. package/dist/{chunk-4TYO6O7T.js → chunk-DNWVDGKS.js} +46 -45
  65. package/dist/{chunk-4TYO6O7T.js.map → chunk-DNWVDGKS.js.map} +1 -1
  66. package/dist/{chunk-5WPPWTC3.js → chunk-E67QUGT3.js} +1888 -675
  67. package/dist/chunk-E67QUGT3.js.map +1 -0
  68. package/dist/{chunk-FSPMFRJO.js → chunk-FBJPNZUN.js} +3 -2
  69. package/dist/{chunk-FSPMFRJO.js.map → chunk-FBJPNZUN.js.map} +1 -1
  70. package/dist/{chunk-EA7DZ5TN.js → chunk-FLPPA2XY.js} +40 -5
  71. package/dist/chunk-FLPPA2XY.js.map +1 -0
  72. package/dist/{chunk-UZU7VYKN.js → chunk-FZ7EMXIM.js} +289 -125
  73. package/dist/chunk-FZ7EMXIM.js.map +1 -0
  74. package/dist/{chunk-ZCSH3QKX.js → chunk-G4ZUJCEN.js} +1518 -1069
  75. package/dist/chunk-G4ZUJCEN.js.map +1 -0
  76. package/dist/{chunk-X5FRYDZ3.js → chunk-GACJRITH.js} +4 -3
  77. package/dist/{chunk-X5FRYDZ3.js.map → chunk-GACJRITH.js.map} +1 -1
  78. package/dist/{chunk-K4K2ACT2.js → chunk-IC46FAEW.js} +8 -7
  79. package/dist/chunk-IC46FAEW.js.map +1 -0
  80. package/dist/{chunk-7O5YXVCD.js → chunk-IJWAAODK.js} +4 -3
  81. package/dist/{chunk-7O5YXVCD.js.map → chunk-IJWAAODK.js.map} +1 -1
  82. package/dist/{chunk-MUMIMDRJ.js → chunk-IKMNHITS.js} +3 -2
  83. package/dist/{chunk-MUMIMDRJ.js.map → chunk-IKMNHITS.js.map} +1 -1
  84. package/dist/{chunk-6C2EILMC.js → chunk-KIDTBRIV.js} +47 -7
  85. package/dist/chunk-KIDTBRIV.js.map +1 -0
  86. package/dist/{chunk-TFEXYI6N.js → chunk-KRTQZPYL.js} +3 -2
  87. package/dist/{chunk-TFEXYI6N.js.map → chunk-KRTQZPYL.js.map} +1 -1
  88. package/dist/{chunk-HWS3XUEF.js → chunk-LX6GMZIN.js} +8 -7
  89. package/dist/{chunk-HWS3XUEF.js.map → chunk-LX6GMZIN.js.map} +1 -1
  90. package/dist/{chunk-MPJCUL2B.js → chunk-MQRGWQI5.js} +3 -2
  91. package/dist/{chunk-MPJCUL2B.js.map → chunk-MQRGWQI5.js.map} +1 -1
  92. package/dist/{chunk-7K7WVTFZ.js → chunk-NC32K762.js} +75 -74
  93. package/dist/{chunk-7K7WVTFZ.js.map → chunk-NC32K762.js.map} +1 -1
  94. package/dist/{chunk-ZIETAMAD.js → chunk-NQYTD3JG.js} +3 -2
  95. package/dist/{chunk-ZIETAMAD.js.map → chunk-NQYTD3JG.js.map} +1 -1
  96. package/dist/{chunk-KIFNHFFI.js → chunk-NR4QAM5W.js} +335 -69
  97. package/dist/chunk-NR4QAM5W.js.map +1 -0
  98. package/dist/{chunk-YFTHJRDO.js → chunk-ODRB22QA.js} +3 -2
  99. package/dist/{chunk-YFTHJRDO.js.map → chunk-ODRB22QA.js.map} +1 -1
  100. package/dist/{chunk-HNQLWFHL.js → chunk-OYME74M3.js} +3 -2
  101. package/dist/{chunk-HNQLWFHL.js.map → chunk-OYME74M3.js.map} +1 -1
  102. package/dist/chunk-PS3DALTI.js +17 -0
  103. package/dist/chunk-PS3DALTI.js.map +1 -0
  104. package/dist/{chunk-UKUXNFQP.js → chunk-QU365GZA.js} +3 -2
  105. package/dist/{chunk-UKUXNFQP.js.map → chunk-QU365GZA.js.map} +1 -1
  106. package/dist/{chunk-HIGFQRWM.js → chunk-R52P4KQC.js} +3 -2
  107. package/dist/{chunk-HIGFQRWM.js.map → chunk-R52P4KQC.js.map} +1 -1
  108. package/dist/{chunk-U56N5JCJ.js → chunk-RL3ICBAB.js} +3 -2
  109. package/dist/{chunk-U56N5JCJ.js.map → chunk-RL3ICBAB.js.map} +1 -1
  110. package/dist/{chunk-HUYC4OAL.js → chunk-RQRJ2I2Z.js} +3 -2
  111. package/dist/{chunk-HUYC4OAL.js.map → chunk-RQRJ2I2Z.js.map} +1 -1
  112. package/dist/{chunk-NXET4BFJ.js → chunk-SPGD4QGA.js} +3 -2
  113. package/dist/{chunk-NXET4BFJ.js.map → chunk-SPGD4QGA.js.map} +1 -1
  114. package/dist/{chunk-XVL4FHXA.js → chunk-T46S4VA3.js} +3 -2
  115. package/dist/{chunk-XVL4FHXA.js.map → chunk-T46S4VA3.js.map} +1 -1
  116. package/dist/{chunk-RIXZISMX.js → chunk-V6PEMZCL.js} +3 -2
  117. package/dist/{chunk-RIXZISMX.js.map → chunk-V6PEMZCL.js.map} +1 -1
  118. package/dist/{chunk-FTXUQMGH.js → chunk-VBAPZMPX.js} +2 -1
  119. package/dist/{chunk-FTXUQMGH.js.map → chunk-VBAPZMPX.js.map} +1 -1
  120. package/dist/{chunk-DMF2BPPA.js → chunk-VILLVGBP.js} +3 -2
  121. package/dist/{chunk-DMF2BPPA.js.map → chunk-VILLVGBP.js.map} +1 -1
  122. package/dist/{chunk-NHT3XSX3.js → chunk-XGXOE3DF.js} +3 -2
  123. package/dist/{chunk-NHT3XSX3.js.map → chunk-XGXOE3DF.js.map} +1 -1
  124. package/dist/{chunk-PRQTAIYA.js → chunk-XPEWAHAK.js} +4 -3
  125. package/dist/{chunk-PRQTAIYA.js.map → chunk-XPEWAHAK.js.map} +1 -1
  126. package/dist/{chunk-GLNTGHR6.js → chunk-YKNHKVE6.js} +49 -40
  127. package/dist/chunk-YKNHKVE6.js.map +1 -0
  128. package/dist/{chunk-XD6A3VXB.js → chunk-Z5BMFLZ5.js} +8 -7
  129. package/dist/chunk-Z5BMFLZ5.js.map +1 -0
  130. package/dist/cli/test-command.d.ts +2 -0
  131. package/dist/cli/test-command.d.ts.map +1 -1
  132. package/dist/cli.js +102 -35
  133. package/dist/cli.js.map +1 -1
  134. package/dist/cloud/common.d.ts.map +1 -1
  135. package/dist/{compiler-44UW2FID.js → compiler-UOVKUQHE.js} +4 -3
  136. package/dist/{compiler-44UW2FID.js.map → compiler-UOVKUQHE.js.map} +1 -1
  137. package/dist/config-loader-MX232REU.js +11 -0
  138. package/dist/{console-T6TVZ65G.js → console-OHKVJLW3.js} +39 -6
  139. package/dist/console-OHKVJLW3.js.map +1 -0
  140. package/dist/core/accessibility-audit.d.ts.map +1 -1
  141. package/dist/core/engine.d.ts +1 -1
  142. package/dist/core/engine.d.ts.map +1 -1
  143. package/dist/core/orchestrator.d.ts +1 -0
  144. package/dist/core/orchestrator.d.ts.map +1 -1
  145. package/dist/core/projects.d.ts +10 -6
  146. package/dist/core/projects.d.ts.map +1 -1
  147. package/dist/core/rejections.d.ts +5 -0
  148. package/dist/core/rejections.d.ts.map +1 -0
  149. package/dist/core/screenshot-compare.d.ts +7 -2
  150. package/dist/core/screenshot-compare.d.ts.map +1 -1
  151. package/dist/core/video-recorder.d.ts.map +1 -1
  152. package/dist/{daemon-manager-2SK5PHJR.js → daemon-manager-6CFUXGTR.js} +4 -3
  153. package/dist/discover-AHMM7QLN.js +16 -0
  154. package/dist/{doctor-command-UUQ4RFMK.js → doctor-command-YTT5SMQW.js} +18 -16
  155. package/dist/{doctor-command-UUQ4RFMK.js.map → doctor-command-YTT5SMQW.js.map} +1 -1
  156. package/dist/driver-AN3I4H6O.js +21 -0
  157. package/dist/driver-X4FWTDNU.js +20 -0
  158. package/dist/drivers/cdp-browser.d.ts +36 -2
  159. package/dist/drivers/cdp-browser.d.ts.map +1 -1
  160. package/dist/drivers/cdp-embed.d.ts +104 -0
  161. package/dist/drivers/cdp-embed.d.ts.map +1 -0
  162. package/dist/drivers/electron.d.ts +0 -8
  163. package/dist/drivers/electron.d.ts.map +1 -1
  164. package/dist/drivers/playwright.d.ts +18 -7
  165. package/dist/drivers/playwright.d.ts.map +1 -1
  166. package/dist/drivers/raw-driver.d.ts +36 -3
  167. package/dist/drivers/raw-driver.d.ts.map +1 -1
  168. package/dist/electrobun-OUTYOM5G.js +17 -0
  169. package/dist/electron-XL7H25IQ.js +10 -0
  170. package/dist/{filters-5DCGGJRN.js → filters-6W73R3IV.js} +4 -3
  171. package/dist/gherkin/steps.js +3 -2
  172. package/dist/gherkin/steps.js.map +1 -1
  173. package/dist/github-pr-XZZZ3YE6.js +11 -0
  174. package/dist/{html-KJ2QAGF4.js → html-GDWXFYFL.js} +4 -3
  175. package/dist/{html-KJ2QAGF4.js.map → html-GDWXFYFL.js.map} +1 -1
  176. package/dist/index.d.ts +8 -5
  177. package/dist/index.d.ts.map +1 -1
  178. package/dist/index.js +237 -122
  179. package/dist/index.js.map +1 -1
  180. package/dist/{init-command-V5VGN3IS.js → init-command-PYZ5X6M5.js} +3 -2
  181. package/dist/{init-command-V5VGN3IS.js.map → init-command-PYZ5X6M5.js.map} +1 -1
  182. package/dist/{init-flow-command-INYUCC6N.js → init-flow-command-SLLEGSRZ.js} +4 -3
  183. package/dist/{init-flow-command-INYUCC6N.js.map → init-flow-command-SLLEGSRZ.js.map} +1 -1
  184. package/dist/installer-3X5SKWVX.js +18 -0
  185. package/dist/{installer-DMTY47SI.js → installer-Q37BOG5G.js} +6 -5
  186. package/dist/{ios-SZ4RBI7Q.js → ios-YFRAK2CL.js} +5 -4
  187. package/dist/{json-67HY4VQK.js → json-QVHG6I3O.js} +3 -2
  188. package/dist/{json-67HY4VQK.js.map → json-QVHG6I3O.js.map} +1 -1
  189. package/dist/{junit-MHD5AXBU.js → junit-G5LNOYUL.js} +3 -2
  190. package/dist/{junit-MHD5AXBU.js.map → junit-G5LNOYUL.js.map} +1 -1
  191. package/dist/local-UWIYOREU.js +40 -0
  192. package/dist/{machine-NOOFRT45.js → machine-VEVBT2GU.js} +4 -3
  193. package/dist/pagesource-GQLIXL5R.js +10 -0
  194. package/dist/pagesource-HKLE3FZN.js +10 -0
  195. package/dist/playwright-KBWUBU5S.js +30 -0
  196. package/dist/provider-HWM3GF54.js +14 -0
  197. package/dist/{redact-OG4M3IEU.js → redact-YWR6GHBX.js} +3 -2
  198. package/dist/{redact-OG4M3IEU.js.map → redact-YWR6GHBX.js.map} +1 -1
  199. package/dist/report/console.d.ts +2 -0
  200. package/dist/report/console.d.ts.map +1 -1
  201. package/dist/report/types.d.ts +2 -0
  202. package/dist/report/types.d.ts.map +1 -1
  203. package/dist/{runner-ABGUVOJG.js → runner-P2BFG4VZ.js} +4 -3
  204. package/dist/runtime/daemon-manager.d.ts.map +1 -1
  205. package/dist/runtime/local.d.ts +17 -0
  206. package/dist/runtime/local.d.ts.map +1 -1
  207. package/dist/runtime/web-server.d.ts +5 -1
  208. package/dist/runtime/web-server.d.ts.map +1 -1
  209. package/dist/schemas/config.d.ts +78 -6
  210. package/dist/schemas/config.d.ts.map +1 -1
  211. package/dist/schemas/selector.d.ts +6 -2
  212. package/dist/schemas/selector.d.ts.map +1 -1
  213. package/dist/screenshot-compare-DNIP2EK4.js +15 -0
  214. package/dist/{server-RTDMJIQZ.js → server-BS3O4WVU.js} +42 -39
  215. package/dist/{server-RTDMJIQZ.js.map → server-BS3O4WVU.js.map} +1 -1
  216. package/dist/server-CWCMC244.js +15 -0
  217. package/dist/session-YWYRRXXR.js +42 -0
  218. package/dist/smart/auto-wait.d.ts.map +1 -1
  219. package/dist/smart/channel-resolver.d.ts +4 -0
  220. package/dist/smart/channel-resolver.d.ts.map +1 -1
  221. package/dist/smart/coordinator.d.ts +12 -2
  222. package/dist/smart/coordinator.d.ts.map +1 -1
  223. package/dist/smart/diagnostics.d.ts.map +1 -1
  224. package/dist/smart/element-matcher.d.ts.map +1 -1
  225. package/dist/{studio-command-PZHMLCKE.js → studio-command-XJDGLNAJ.js} +4 -3
  226. package/dist/{studio-command-PZHMLCKE.js.map → studio-command-XJDGLNAJ.js.map} +1 -1
  227. package/dist/{test-command-FJOP2GYD.js → test-command-3IRGNEPB.js} +518 -88
  228. package/dist/test-command-3IRGNEPB.js.map +1 -0
  229. package/dist/validator-6XP3PGCP.js +18 -0
  230. package/dist/watch-mode-HWZ4XCKH.js +11 -0
  231. package/dist/watch-mode-HWZ4XCKH.js.map +1 -0
  232. package/native/darwin-arm64/libspana_native.dylib +0 -0
  233. package/native/darwin-x64/libspana_native.dylib +0 -0
  234. package/native/linux-arm64/libspana_native.so +0 -0
  235. package/native/linux-x64/libspana_native.so +0 -0
  236. package/native/win32-x64/spana_native.dll +0 -0
  237. package/package.json +15 -6
  238. package/studio-dist/assets/{index-DXGUfzm3.js → index-DAE7R_Zp.js} +1 -1
  239. package/studio-dist/index.html +1 -1
  240. package/dist/accessibility-audit-F5KLUHLS.js.map +0 -1
  241. package/dist/app-C353NGBT.js +0 -13
  242. package/dist/bridge-server-S3DHK7XE.js +0 -12
  243. package/dist/cache-command-OL7HUK2K.js +0 -12
  244. package/dist/chunk-5WPPWTC3.js.map +0 -1
  245. package/dist/chunk-6C2EILMC.js.map +0 -1
  246. package/dist/chunk-7WHQIQPM.js.map +0 -1
  247. package/dist/chunk-A7Z52TDQ.js +0 -97
  248. package/dist/chunk-A7Z52TDQ.js.map +0 -1
  249. package/dist/chunk-CA66JCX2.js.map +0 -1
  250. package/dist/chunk-EA7DZ5TN.js.map +0 -1
  251. package/dist/chunk-FHCOPLYB.js.map +0 -1
  252. package/dist/chunk-GLNTGHR6.js.map +0 -1
  253. package/dist/chunk-HIEOI3WN.js.map +0 -1
  254. package/dist/chunk-K4K2ACT2.js.map +0 -1
  255. package/dist/chunk-KIFNHFFI.js.map +0 -1
  256. package/dist/chunk-UZU7VYKN.js.map +0 -1
  257. package/dist/chunk-WBCAF7SC.js.map +0 -1
  258. package/dist/chunk-XD6A3VXB.js.map +0 -1
  259. package/dist/chunk-ZCSH3QKX.js.map +0 -1
  260. package/dist/config-loader-TSADVSBY.js +0 -10
  261. package/dist/console-T6TVZ65G.js.map +0 -1
  262. package/dist/discover-6ULCTB5T.js +0 -15
  263. package/dist/driver-3HBDKESK.js +0 -19
  264. package/dist/driver-LKXSKNG3.js +0 -19
  265. package/dist/electrobun-HILYDIJ3.js +0 -15
  266. package/dist/electron-SQACDON3.js +0 -9
  267. package/dist/github-pr-RYO6IAKD.js +0 -10
  268. package/dist/installer-KL2NCILK.js +0 -17
  269. package/dist/local-J2NC6YKI.js +0 -30
  270. package/dist/pagesource-KIQ5T5MA.js +0 -9
  271. package/dist/pagesource-KKG7WMFJ.js +0 -9
  272. package/dist/playwright-JMHCABDJ.js +0 -28
  273. package/dist/provider-CBAXZ2VA.js +0 -12
  274. package/dist/screenshot-compare-BJRJHKNQ.js +0 -12
  275. package/dist/server-RHAHCANZ.js +0 -14
  276. package/dist/session-7CWHTQ2E.js +0 -39
  277. package/dist/test-command-FJOP2GYD.js.map +0 -1
  278. package/dist/validator-AJNOFBQM.js +0 -17
  279. package/dist/watch-mode-NR5MHNNL.js +0 -10
  280. /package/dist/{agent-fixture-H6GOUHNX.js.map → accessibility-audit-IWTD2HPR.js.map} +0 -0
  281. /package/dist/{android-C2S4B4TH.js.map → agent-fixture-WQVCNL73.js.map} +0 -0
  282. /package/dist/{app-C353NGBT.js.map → android-TPO53H5Q.js.map} +0 -0
  283. /package/dist/{bridge-server-S3DHK7XE.js.map → app-LGNFQMU7.js.map} +0 -0
  284. /package/dist/{cache-command-OL7HUK2K.js.map → bridge-server-X5W4PCAR.js.map} +0 -0
  285. /package/dist/{config-loader-TSADVSBY.js.map → cache-command-OMV6DPC7.js.map} +0 -0
  286. /package/dist/{daemon-manager-2SK5PHJR.js.map → config-loader-MX232REU.js.map} +0 -0
  287. /package/dist/{discover-6ULCTB5T.js.map → daemon-manager-6CFUXGTR.js.map} +0 -0
  288. /package/dist/{driver-3HBDKESK.js.map → discover-AHMM7QLN.js.map} +0 -0
  289. /package/dist/{driver-LKXSKNG3.js.map → driver-AN3I4H6O.js.map} +0 -0
  290. /package/dist/{electrobun-HILYDIJ3.js.map → driver-X4FWTDNU.js.map} +0 -0
  291. /package/dist/{electron-SQACDON3.js.map → electrobun-OUTYOM5G.js.map} +0 -0
  292. /package/dist/{filters-5DCGGJRN.js.map → electron-XL7H25IQ.js.map} +0 -0
  293. /package/dist/{github-pr-RYO6IAKD.js.map → filters-6W73R3IV.js.map} +0 -0
  294. /package/dist/{installer-DMTY47SI.js.map → github-pr-XZZZ3YE6.js.map} +0 -0
  295. /package/dist/{installer-KL2NCILK.js.map → installer-3X5SKWVX.js.map} +0 -0
  296. /package/dist/{ios-SZ4RBI7Q.js.map → installer-Q37BOG5G.js.map} +0 -0
  297. /package/dist/{local-J2NC6YKI.js.map → ios-YFRAK2CL.js.map} +0 -0
  298. /package/dist/{machine-NOOFRT45.js.map → local-UWIYOREU.js.map} +0 -0
  299. /package/dist/{pagesource-KIQ5T5MA.js.map → machine-VEVBT2GU.js.map} +0 -0
  300. /package/dist/{pagesource-KKG7WMFJ.js.map → pagesource-GQLIXL5R.js.map} +0 -0
  301. /package/dist/{playwright-JMHCABDJ.js.map → pagesource-HKLE3FZN.js.map} +0 -0
  302. /package/dist/{provider-CBAXZ2VA.js.map → playwright-KBWUBU5S.js.map} +0 -0
  303. /package/dist/{runner-ABGUVOJG.js.map → provider-HWM3GF54.js.map} +0 -0
  304. /package/dist/{screenshot-compare-BJRJHKNQ.js.map → runner-P2BFG4VZ.js.map} +0 -0
  305. /package/dist/{server-RHAHCANZ.js.map → screenshot-compare-DNIP2EK4.js.map} +0 -0
  306. /package/dist/{session-7CWHTQ2E.js.map → server-CWCMC244.js.map} +0 -0
  307. /package/dist/{validator-AJNOFBQM.js.map → session-YWYRRXXR.js.map} +0 -0
  308. /package/dist/{watch-mode-NR5MHNNL.js.map → validator-6XP3PGCP.js.map} +0 -0
@@ -1,64 +1,73 @@
1
+ import { createRequire as __spanaCreateRequire } from "node:module"; const require = __spanaCreateRequire(import.meta.url);
1
2
  import {
2
3
  splitGraphemes
3
- } from "./chunk-MUMIMDRJ.js";
4
+ } from "./chunk-IKMNHITS.js";
4
5
  import {
5
6
  mergeLaunchOptions
6
- } from "./chunk-NWGA3R2E.js";
7
+ } from "./chunk-B4FOISOF.js";
7
8
  import {
8
9
  buildDomActionabilityDiagScript,
10
+ buildDomArmTapGuardBySelectorScript,
9
11
  buildDomFindElementScript,
10
12
  buildDomFocusScript,
13
+ buildDomFrameEvaluateScript,
11
14
  buildDomSelectOptionScript,
12
15
  domMatchToElement,
13
16
  formatByteSize,
14
17
  isWasmTrapError,
15
18
  parseByteSize
16
- } from "./chunk-CA66JCX2.js";
19
+ } from "./chunk-7K24Q7V3.js";
17
20
  import {
18
21
  DriverError,
22
+ Duration_exports,
23
+ Effect_exports,
19
24
  ElementNotFoundError,
25
+ Schema_exports,
20
26
  TextMismatchError,
21
27
  WaitTimeoutError
22
- } from "./chunk-A7Z52TDQ.js";
28
+ } from "./chunk-67PLJEY2.js";
23
29
  import {
24
30
  compareScreenshots,
25
31
  cropToElement
26
- } from "./chunk-6C2EILMC.js";
32
+ } from "./chunk-KIDTBRIV.js";
33
+ import {
34
+ filterViolations,
35
+ formatViolationSummary
36
+ } from "./chunk-5TAHLRZD.js";
27
37
  import {
28
38
  init_esm_shims
29
- } from "./chunk-FTXUQMGH.js";
39
+ } from "./chunk-VBAPZMPX.js";
30
40
 
31
41
  // src/api/app.ts
32
42
  init_esm_shims();
33
- import { Effect as Effect6 } from "effect";
34
43
 
35
44
  // src/schemas/selector.ts
36
45
  init_esm_shims();
37
- import { Schema } from "effect";
38
- var _TestIDSelectorSchema = Schema.Struct({ testID: Schema.String });
39
- var _TextSelectorSchema = Schema.Struct({
40
- text: Schema.String,
41
- systemUI: Schema.optional(Schema.Boolean)
46
+ var _TestIDSelectorSchema = Schema_exports.Struct({ testID: Schema_exports.String });
47
+ var _TextSelectorSchema = Schema_exports.Struct({
48
+ text: Schema_exports.String,
49
+ systemUI: Schema_exports.optional(Schema_exports.Boolean)
42
50
  });
43
- var _AccessibilityLabelSelectorSchema = Schema.Struct({
44
- accessibilityLabel: Schema.String,
45
- systemUI: Schema.optional(Schema.Boolean)
51
+ var _AccessibilityLabelSelectorSchema = Schema_exports.Struct({
52
+ accessibilityLabel: Schema_exports.String,
53
+ systemUI: Schema_exports.optional(Schema_exports.Boolean)
46
54
  });
47
- var _RoleSelectorSchema = Schema.Struct({
48
- role: Schema.String,
49
- name: Schema.optional(Schema.String),
50
- exact: Schema.optional(Schema.Boolean),
51
- level: Schema.optional(Schema.Number),
52
- includeHidden: Schema.optional(Schema.Boolean)
55
+ var _RoleSelectorSchema = Schema_exports.Struct({
56
+ role: Schema_exports.String,
57
+ name: Schema_exports.optional(Schema_exports.String),
58
+ exact: Schema_exports.optional(Schema_exports.Boolean),
59
+ level: Schema_exports.optional(Schema_exports.Number),
60
+ pressed: Schema_exports.optional(Schema_exports.Boolean),
61
+ includeHidden: Schema_exports.optional(Schema_exports.Boolean)
53
62
  });
54
- var _CssSelectorSchema = Schema.Struct({
55
- css: Schema.String
63
+ var _CssSelectorSchema = Schema_exports.Struct({
64
+ css: Schema_exports.String
56
65
  });
57
- var _PointSelectorSchema = Schema.Struct({
58
- point: Schema.Struct({ x: Schema.Number, y: Schema.Number })
66
+ var _PointSelectorSchema = Schema_exports.Struct({
67
+ point: Schema_exports.Struct({ x: Schema_exports.Number, y: Schema_exports.Number })
59
68
  });
60
- var SelectorSchema = Schema.Union([
61
- Schema.String,
69
+ var SelectorSchema = Schema_exports.Union([
70
+ Schema_exports.String,
62
71
  _TestIDSelectorSchema,
63
72
  _TextSelectorSchema,
64
73
  _AccessibilityLabelSelectorSchema,
@@ -169,7 +178,6 @@ function isComposableDomSelector(sel) {
169
178
 
170
179
  // src/smart/coordinator.ts
171
180
  init_esm_shims();
172
- import { Duration as Duration2, Effect as Effect4 } from "effect";
173
181
 
174
182
  // src/smart/element-matcher.ts
175
183
  init_esm_shims();
@@ -187,26 +195,83 @@ function flattenElements(root) {
187
195
  }
188
196
  return result;
189
197
  }
198
+ function normalizeWs(s) {
199
+ return s.replaceAll(/[\s\u00a0\u202f]+/g, " ").trim();
200
+ }
201
+ function matchTextSpec(actual, spec, exact) {
202
+ const normActual = normalizeWs(actual);
203
+ if (spec instanceof RegExp) {
204
+ return spec.test(actual) || spec.test(normActual);
205
+ }
206
+ const normSpec = normalizeWs(spec);
207
+ return exact ? normActual === normSpec : normActual.toLowerCase().includes(normSpec.toLowerCase());
208
+ }
209
+ function computeAccessibleName(element) {
210
+ if (element.accessibilityLabel && normalizeWs(element.accessibilityLabel).length > 0) {
211
+ return normalizeWs(element.accessibilityLabel);
212
+ }
213
+ const ariaLabel = element.attributes?.["aria-label"];
214
+ if (ariaLabel && normalizeWs(ariaLabel).length > 0) {
215
+ return normalizeWs(ariaLabel);
216
+ }
217
+ if (element.text && normalizeWs(element.text).length > 0) {
218
+ return normalizeWs(element.text);
219
+ }
220
+ if (!element.children || element.children.length === 0) {
221
+ return "";
222
+ }
223
+ const parts = [];
224
+ const stack = [];
225
+ for (let i = element.children.length - 1; i >= 0; i--) {
226
+ stack.push(element.children[i]);
227
+ }
228
+ while (stack.length > 0) {
229
+ const child = stack.pop();
230
+ if (child.attributes?.["aria-hidden"] === "true") continue;
231
+ if (child.visible === false) continue;
232
+ const childLabel = child.accessibilityLabel ?? child.attributes?.["aria-label"];
233
+ if (childLabel && normalizeWs(childLabel).length > 0) {
234
+ parts.push(normalizeWs(childLabel));
235
+ continue;
236
+ }
237
+ if (child.text && normalizeWs(child.text).length > 0) {
238
+ parts.push(normalizeWs(child.text));
239
+ }
240
+ if (child.children && child.children.length > 0) {
241
+ for (let i = child.children.length - 1; i >= 0; i--) {
242
+ stack.push(child.children[i]);
243
+ }
244
+ }
245
+ }
246
+ return normalizeWs(parts.join(" "));
247
+ }
190
248
  function matchesSelector(element, selector) {
191
249
  if (typeof selector === "string") {
192
- return element.text?.toLowerCase().includes(selector.toLowerCase()) ?? false;
250
+ return element.text !== void 0 && matchTextSpec(element.text, selector, false);
193
251
  }
194
252
  let baseMatch = false;
195
253
  if ("testID" in selector) {
196
254
  baseMatch = element.id === selector.testID;
197
255
  } else if ("text" in selector) {
198
- baseMatch = selector.exact ? element.text === selector.text : element.text?.toLowerCase().includes(selector.text.toLowerCase()) ?? false;
256
+ baseMatch = element.text !== void 0 && matchTextSpec(element.text, selector.text, selector.exact);
199
257
  } else if ("accessibilityLabel" in selector) {
200
258
  baseMatch = element.accessibilityLabel === selector.accessibilityLabel;
201
259
  } else if ("role" in selector) {
260
+ if (!selector.includeHidden && (element.attributes?.["aria-hidden"] === "true" || "inert" in (element.attributes ?? {}))) {
261
+ return false;
262
+ }
202
263
  const elRole = (element.attributes?.role ?? element.elementType ?? "").toLowerCase();
203
264
  const roleMatch = elRole === selector.role.toLowerCase();
204
265
  if (!roleMatch) return false;
266
+ if (selector.pressed !== void 0) {
267
+ const ariaPressed = (element.attributes?.["aria-pressed"] ?? "").trim().toLowerCase();
268
+ if (selector.pressed ? ariaPressed !== "true" : ariaPressed !== "false") return false;
269
+ }
205
270
  if (selector.name === void 0) {
206
271
  baseMatch = true;
207
272
  } else {
208
- const candidateName = element.accessibilityLabel ?? element.text ?? "";
209
- baseMatch = selector.name instanceof RegExp ? selector.name.test(candidateName) : selector.exact ? candidateName === selector.name : candidateName.toLowerCase().includes(selector.name.toLowerCase());
273
+ const candidateName = computeAccessibleName(element);
274
+ baseMatch = matchTextSpec(candidateName, selector.name, selector.exact);
210
275
  }
211
276
  } else if ("css" in selector) {
212
277
  baseMatch = false;
@@ -221,12 +286,10 @@ function matchesSelector(element, selector) {
221
286
  if (!("point" in selector)) {
222
287
  const text = element.text ?? element.accessibilityLabel ?? "";
223
288
  if (selector.hasText !== void 0) {
224
- const ok = selector.hasText instanceof RegExp ? selector.hasText.test(text) : text.toLowerCase().includes(selector.hasText.toLowerCase());
225
- if (!ok) return false;
289
+ if (!matchTextSpec(text, selector.hasText, false)) return false;
226
290
  }
227
291
  if (selector.hasNotText !== void 0) {
228
- const bad = selector.hasNotText instanceof RegExp ? selector.hasNotText.test(text) : text.toLowerCase().includes(selector.hasNotText.toLowerCase());
229
- if (bad) return false;
292
+ if (matchTextSpec(text, selector.hasNotText, false)) return false;
230
293
  }
231
294
  if (selector.has !== void 0) {
232
295
  const descendants = flattenElements(element).slice(1);
@@ -239,8 +302,29 @@ function matchesSelector(element, selector) {
239
302
  }
240
303
  return true;
241
304
  }
305
+ function flattenElementsForSelector(root, skipAriaHiddenSubtrees) {
306
+ if (!skipAriaHiddenSubtrees) return flattenElements(root);
307
+ const result = [];
308
+ const stack = [root];
309
+ while (stack.length > 0) {
310
+ const node = stack.pop();
311
+ if (node.attributes?.["aria-hidden"] === "true" || "inert" in (node.attributes ?? {})) {
312
+ continue;
313
+ }
314
+ result.push(node);
315
+ if (node.children) {
316
+ for (let i = node.children.length - 1; i >= 0; i--) {
317
+ stack.push(node.children[i]);
318
+ }
319
+ }
320
+ }
321
+ return result;
322
+ }
242
323
  function findElements(root, selector) {
243
- const matched = flattenElements(root).filter((el) => matchesSelector(el, selector));
324
+ const skipAriaHidden = typeof selector === "object" && selector !== null && "role" in selector && !selector.includeHidden;
325
+ const matched = flattenElementsForSelector(root, skipAriaHidden).filter(
326
+ (el) => matchesSelector(el, selector)
327
+ );
244
328
  if (typeof selector === "object" && selector !== null && !("point" in selector)) {
245
329
  if (selector.first) return matched.length > 0 ? [matched[0]] : [];
246
330
  if (selector.last) return matched.length > 0 ? [matched[matched.length - 1]] : [];
@@ -319,7 +403,8 @@ function formatSimpleSelector(sel) {
319
403
  if (typeof sel === "string") return `"${sel}"`;
320
404
  let base;
321
405
  if ("testID" in sel) base = `testID: "${sel.testID}"`;
322
- else if ("text" in sel) base = `text: "${sel.text}"`;
406
+ else if ("text" in sel)
407
+ base = `text: ${sel.text instanceof RegExp ? sel.text.toString() : JSON.stringify(sel.text)}`;
323
408
  else if ("accessibilityLabel" in sel) base = `accessibilityLabel: "${sel.accessibilityLabel}"`;
324
409
  else if ("role" in sel) {
325
410
  const parts = [`role: "${sel.role}"`];
@@ -408,7 +493,6 @@ function findRelativeElement(root, rel) {
408
493
 
409
494
  // src/smart/auto-wait.ts
410
495
  init_esm_shims();
411
- import { Duration, Effect as Effect2 } from "effect";
412
496
 
413
497
  // src/smart/diagnostics.ts
414
498
  init_esm_shims();
@@ -457,7 +541,7 @@ function diagnoseElementNotFound(root, selector) {
457
541
  } else if ("testID" in simpleSelector && simpleSelector.testID) {
458
542
  const similar = findSimilarByTestID(allElements, simpleSelector.testID);
459
543
  suggestions.push(...similar);
460
- } else if ("text" in simpleSelector && simpleSelector.text) {
544
+ } else if ("text" in simpleSelector && typeof simpleSelector.text === "string" && simpleSelector.text) {
461
545
  const similar = findSimilarByText(allElements, simpleSelector.text);
462
546
  suggestions.push(...similar);
463
547
  }
@@ -495,7 +579,6 @@ function formatDiagnostic(diag) {
495
579
 
496
580
  // src/smart/channel-resolver.ts
497
581
  init_esm_shims();
498
- import { Effect } from "effect";
499
582
  function isInvalidSelectorError(err) {
500
583
  const msg = err instanceof Error ? err.message : String(err ?? "");
501
584
  return msg.includes("Invalid CSS selector") || msg.includes("Unsupported selector");
@@ -561,42 +644,49 @@ function pickBestDomMatch(matches) {
561
644
  }
562
645
  function getNativeHierarchy(driver, parse, cache) {
563
646
  if (cache) return cache.get(driver, parse);
564
- return Effect.gen(function* () {
647
+ return Effect_exports.gen(function* () {
565
648
  const raw = yield* driver.dumpHierarchy();
566
649
  return parse(raw);
567
650
  });
568
651
  }
569
652
  function resolveElementAcrossChannels(driver, selector, parse, cache, options = {}) {
570
- return Effect.gen(function* () {
653
+ return Effect_exports.gen(function* () {
571
654
  const domChannel = driver.domChannel;
572
655
  const isSystemUI = isSystemUISelector(selector);
573
656
  const forAction = options.forAction ?? false;
574
657
  const tapMode = options.tapMode ?? "native";
575
658
  const canTryDom = !isSystemUI && !isRelativeSelector(selector) && domChannel !== void 0 && (isTestIDSelector(selector) || isComposableDomSelector(selector) || domChannel.isConnected());
576
659
  if (canTryDom) {
577
- const domMatches = yield* Effect.tryPromise({
660
+ const domMatches = yield* Effect_exports.tryPromise({
578
661
  try: async () => {
579
662
  if (!domChannel.isConnected()) {
580
663
  if (!isTestIDSelector(selector) && !isComposableDomSelector(selector)) return [];
581
664
  try {
582
665
  await domChannel.connect();
583
- } catch {
666
+ } catch (connectErr) {
667
+ if (options.diagnostics) {
668
+ options.diagnostics.lastDomError = `DOM channel connect failed: ${connectErr instanceof Error ? connectErr.message : String(connectErr)}`;
669
+ }
584
670
  return [];
585
671
  }
586
672
  }
587
673
  return await domChannel.query(selector);
588
674
  },
589
675
  catch: (err) => {
676
+ const msg = err instanceof Error ? err.message : String(err);
677
+ if (options.diagnostics) {
678
+ options.diagnostics.lastDomError = `DOM channel query failed: ${msg}`;
679
+ }
590
680
  if (isInvalidSelectorError(err)) {
591
681
  return new DriverError({
592
- message: err instanceof Error ? err.message : String(err)
682
+ message: msg
593
683
  });
594
684
  }
595
685
  return null;
596
686
  }
597
687
  }).pipe(
598
- Effect.catch(
599
- (err) => err instanceof DriverError ? Effect.fail(err) : Effect.succeed([])
688
+ Effect_exports.catch(
689
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed([])
600
690
  )
601
691
  );
602
692
  const best = pickBestDomMatch(domMatches);
@@ -610,10 +700,10 @@ function resolveElementAcrossChannels(driver, selector, parse, cache, options =
610
700
  }
611
701
  let targetMatch = best;
612
702
  if (isOffscreenInViewport(best) && domChannel.scrollIntoView) {
613
- const scrolled = yield* Effect.tryPromise({
703
+ const scrolled = yield* Effect_exports.tryPromise({
614
704
  try: () => domChannel.scrollIntoView(selector),
615
705
  catch: () => null
616
- }).pipe(Effect.catch(() => Effect.succeed(null)));
706
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
617
707
  if (scrolled) {
618
708
  targetMatch = scrolled;
619
709
  }
@@ -680,7 +770,7 @@ var DEFAULT_INITIAL_POLL_INTERVAL = 50;
680
770
  var DEFAULT_SETTLE_TIMEOUT = 0;
681
771
  function getHierarchy(driver, parse, cache) {
682
772
  if (cache) return cache.get(driver, parse);
683
- return Effect2.gen(function* () {
773
+ return Effect_exports.gen(function* () {
684
774
  const raw = yield* driver.dumpHierarchy();
685
775
  return parse(raw);
686
776
  });
@@ -694,12 +784,12 @@ function nextInterval(elapsed, timeout, initial, max) {
694
784
  function maybeWaitForBridgeIdle(driver, timeout) {
695
785
  const domChannel = driver.domChannel;
696
786
  if (!domChannel || !domChannel.isConnected() || !domChannel.waitForIdle) {
697
- return Effect2.void;
787
+ return Effect_exports.void;
698
788
  }
699
- return Effect2.tryPromise({
789
+ return Effect_exports.tryPromise({
700
790
  try: () => domChannel.waitForIdle({ timeout: Math.min(timeout, 2500) }),
701
791
  catch: () => void 0
702
- }).pipe(Effect2.catch(() => Effect2.void));
792
+ }).pipe(Effect_exports.catch(() => Effect_exports.void));
703
793
  }
704
794
  function isRelativeSelectorLike(selector) {
705
795
  if (typeof selector !== "object" || selector === null) return false;
@@ -710,7 +800,7 @@ function waitForResolvedAcrossChannels(driver, selector, parse, forAction, opts,
710
800
  const pollInterval = opts?.pollInterval ?? DEFAULT_POLL_INTERVAL;
711
801
  const initialPollInterval = opts?.initialPollInterval ?? DEFAULT_INITIAL_POLL_INTERVAL;
712
802
  const settleTimeout = opts?.settleTimeout ?? DEFAULT_SETTLE_TIMEOUT;
713
- return Effect2.gen(function* () {
803
+ return Effect_exports.gen(function* () {
714
804
  const start = Date.now();
715
805
  let waitedForIdle = false;
716
806
  let isFirstPoll = true;
@@ -723,10 +813,11 @@ function waitForResolvedAcrossChannels(driver, selector, parse, forAction, opts,
723
813
  while (attemptIdx === 0 || Date.now() - start < timeout) {
724
814
  attemptIdx += 1;
725
815
  const remaining = Math.max(10, timeout - (Date.now() - start));
726
- const reactiveMatches = yield* Effect2.tryPromise({
816
+ const reactiveMatches = yield* Effect_exports.tryPromise({
727
817
  try: () => initialDomChannel.waitForSelector(selector, {
728
818
  timeoutMs: remaining,
729
- forAction: opts?.force ? false : forAction,
819
+ forAction,
820
+ ...opts?.force ? { force: true } : {},
730
821
  checkHitTest: opts?.force ? false : void 0,
731
822
  failFastWhenIdle: opts?.failFastWhenIdle,
732
823
  idleQuietMs: opts?.idleQuietMs,
@@ -742,8 +833,8 @@ function waitForResolvedAcrossChannels(driver, selector, parse, forAction, opts,
742
833
  return null;
743
834
  }
744
835
  }).pipe(
745
- Effect2.catch(
746
- (err) => err instanceof DriverError ? Effect2.fail(err) : Effect2.succeed(null)
836
+ Effect_exports.catch(
837
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
747
838
  )
748
839
  );
749
840
  if (Array.isArray(reactiveMatches) && reactiveMatches.length > 0) {
@@ -761,7 +852,7 @@ function waitForResolvedAcrossChannels(driver, selector, parse, forAction, opts,
761
852
  break;
762
853
  }
763
854
  const waitMs = Math.min(50, Math.max(10, timeout - (Date.now() - start)));
764
- yield* Effect2.sleep(Duration.millis(waitMs));
855
+ yield* Effect_exports.sleep(Duration_exports.millis(waitMs));
765
856
  continue;
766
857
  }
767
858
  if (lastReactiveErrorMsg && /Iframe matching .* not found/i.test(lastReactiveErrorMsg)) {
@@ -775,13 +866,25 @@ function waitForResolvedAcrossChannels(driver, selector, parse, forAction, opts,
775
866
  break;
776
867
  }
777
868
  const retryWait = Math.min(60, Math.max(10, timeout - (Date.now() - start)));
778
- yield* Effect2.sleep(Duration.millis(retryWait));
869
+ yield* Effect_exports.sleep(Duration_exports.millis(retryWait));
779
870
  }
780
871
  if (sawEmptyArray || forAction || Date.now() - start >= timeout) {
781
- const actionDiag = yield* Effect2.tryPromise({
872
+ const actionDiag = yield* Effect_exports.tryPromise({
782
873
  try: () => initialDomChannel.evaluate(buildDomActionabilityDiagScript(selector)),
783
- catch: () => null
784
- }).pipe(Effect2.catch(() => Effect2.succeed(null)));
874
+ catch: (diagErr) => {
875
+ if (!lastReactiveErrorMsg) {
876
+ lastReactiveErrorMsg = `DOM actionability diagnostic failed: ${diagErr instanceof Error ? diagErr.message : String(diagErr)}`;
877
+ }
878
+ return null;
879
+ }
880
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
881
+ if (forAction && actionDiag?.found && actionDiag.pointerEventsNone) {
882
+ return yield* new ElementNotFoundError({
883
+ message: `Element has pointer-events: none (not actionable within ${timeout}ms) \u2014 selector: ${formatSelector(selector)}`,
884
+ selector,
885
+ timeoutMs: timeout
886
+ });
887
+ }
785
888
  if (forAction && actionDiag?.found && actionDiag.obstructedBy) {
786
889
  return yield* new ElementNotFoundError({
787
890
  message: `Element is covered by ${actionDiag.obstructedBy} (not actionable within ${timeout}ms) \u2014 selector: ${formatSelector(selector)}`,
@@ -799,19 +902,25 @@ function waitForResolvedAcrossChannels(driver, selector, parse, forAction, opts,
799
902
  const extraHints = [];
800
903
  if (actionDiag?.found && !actionDiag.visible && (actionDiag.matchCount ?? 0) > 0) {
801
904
  extraHints.push(
802
- `Matched ${actionDiag.matchCount} element(s) (${actionDiag.visibleCount ?? 0} visible); picked match is hidden`
905
+ `Matched ${actionDiag.matchCount} element(s) (${actionDiag.visibleCount ?? 0} visible); picked match is hidden${actionDiag.hiddenReason ? ` (${actionDiag.hiddenReason})` : ""}`
803
906
  );
804
907
  }
908
+ if (forAction && actionDiag?.found && actionDiag.pointerEventsNone) {
909
+ extraHints.push("Actionability check failed: element has pointer-events: none");
910
+ }
911
+ if (forAction && actionDiag?.lastActionFailure) {
912
+ extraHints.push(`Actionability check failed: ${actionDiag.lastActionFailure}`);
913
+ }
805
914
  if (actionDiag?.detachedAfterScroll) {
806
915
  extraHints.push("Element detached from the DOM after scrolling");
807
916
  }
808
- if (lastReactiveErrorMsg && !sawEmptyArray) {
809
- extraHints.push(`Last error: ${lastReactiveErrorMsg}`);
917
+ if (lastReactiveErrorMsg) {
918
+ extraHints.push(`Last DOM channel error: ${lastReactiveErrorMsg}`);
810
919
  }
811
920
  if (cache) cache.invalidate();
812
921
  const diagRoot2 = yield* getHierarchy(driver, parse, cache).pipe(
813
- Effect2.catch(
814
- () => Effect2.succeed({ bounds: { x: 0, y: 0, width: 0, height: 0 }, children: [] })
922
+ Effect_exports.catch(
923
+ () => Effect_exports.succeed({ bounds: { x: 0, y: 0, width: 0, height: 0 }, children: [] })
815
924
  )
816
925
  );
817
926
  const diagnostic2 = diagnoseElementNotFound(diagRoot2, selector);
@@ -826,22 +935,25 @@ ${diagMessage2}`,
826
935
  });
827
936
  }
828
937
  }
938
+ const channelDiag = {};
829
939
  while (isFirstPoll || Date.now() - start < timeout) {
830
940
  if (!isFirstPoll && cache) cache.invalidate();
831
941
  isFirstPoll = false;
832
942
  const resolved = yield* resolveElementAcrossChannels(driver, selector, parse, cache, {
833
943
  forAction,
834
944
  tapMode: opts?.tapMode,
835
- platform: opts?.platform
945
+ platform: opts?.platform,
946
+ diagnostics: channelDiag
836
947
  });
837
948
  if (resolved) {
838
949
  if (settleTimeout > 0) {
839
- yield* Effect2.sleep(Duration.millis(settleTimeout));
950
+ yield* Effect_exports.sleep(Duration_exports.millis(settleTimeout));
840
951
  if (cache) cache.invalidate();
841
952
  const settled = yield* resolveElementAcrossChannels(driver, selector, parse, cache, {
842
953
  forAction,
843
954
  tapMode: opts?.tapMode,
844
- platform: opts?.platform
955
+ platform: opts?.platform,
956
+ diagnostics: channelDiag
845
957
  });
846
958
  if (settled) return settled;
847
959
  } else {
@@ -852,7 +964,7 @@ ${diagMessage2}`,
852
964
  if (canReactiveDomWait && domChannel?.isConnected() && domChannel.waitForSelector) {
853
965
  const remaining = Math.max(0, timeout - (Date.now() - start));
854
966
  if (remaining > 0) {
855
- const reactiveResult = yield* Effect2.tryPromise({
967
+ const reactiveResult = yield* Effect_exports.tryPromise({
856
968
  try: () => domChannel.waitForSelector(selector, {
857
969
  timeoutMs: Math.min(remaining, opts?.platform === "web" ? remaining : 1e3),
858
970
  forAction,
@@ -861,8 +973,11 @@ ${diagMessage2}`,
861
973
  ...opts?.actionStableFrames !== void 0 ? { stableFrames: opts.actionStableFrames } : {},
862
974
  ...opts?.armTapGuard && !opts?.force ? { armTapGuard: true } : {}
863
975
  }),
864
- catch: () => null
865
- }).pipe(Effect2.catch(() => Effect2.succeed(null)));
976
+ catch: (err) => {
977
+ channelDiag.lastDomError = `DOM waitForSelector failed: ${err instanceof Error ? err.message : String(err)}`;
978
+ return null;
979
+ }
980
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
866
981
  if (Array.isArray(reactiveResult) && reactiveResult.length > 0) {
867
982
  continue;
868
983
  }
@@ -881,14 +996,16 @@ ${diagMessage2}`,
881
996
  }
882
997
  const elapsed = Date.now() - start;
883
998
  const interval = nextInterval(elapsed, timeout, initialPollInterval, pollInterval);
884
- yield* Effect2.sleep(Duration.millis(interval));
999
+ yield* Effect_exports.sleep(Duration_exports.millis(interval));
885
1000
  }
886
1001
  if (cache) cache.invalidate();
887
1002
  const diagRoot = yield* getHierarchy(driver, parse, cache);
888
1003
  const diagnostic = diagnoseElementNotFound(diagRoot, selector);
889
1004
  const diagMessage = formatDiagnostic(diagnostic);
1005
+ const domErrSuffix = channelDiag.lastDomError ? `
1006
+ Last DOM channel error: ${channelDiag.lastDomError}` : "";
890
1007
  return yield* new ElementNotFoundError({
891
- message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}
1008
+ message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}${domErrSuffix}
892
1009
  ${diagMessage}`,
893
1010
  selector,
894
1011
  timeoutMs: timeout
@@ -900,19 +1017,19 @@ function waitForResolvedElementResult(driver, selector, parse, forAction, opts,
900
1017
  }
901
1018
  function waitForElement(driver, selector, parse, opts, cache) {
902
1019
  return waitForResolvedAcrossChannels(driver, selector, parse, false, opts, cache).pipe(
903
- Effect2.map((r) => r.element)
1020
+ Effect_exports.map((r) => r.element)
904
1021
  );
905
1022
  }
906
1023
  function waitForActionElement(driver, selector, parse, opts, cache) {
907
1024
  return waitForResolvedAcrossChannels(driver, selector, parse, true, opts, cache).pipe(
908
- Effect2.map((r) => r.element)
1025
+ Effect_exports.map((r) => r.element)
909
1026
  );
910
1027
  }
911
1028
  function waitForNotVisible(driver, selector, parse, opts, cache) {
912
1029
  const timeout = opts?.timeout ?? DEFAULT_TIMEOUT;
913
1030
  const pollInterval = opts?.pollInterval ?? DEFAULT_POLL_INTERVAL;
914
1031
  const initialPollInterval = opts?.initialPollInterval ?? DEFAULT_INITIAL_POLL_INTERVAL;
915
- return Effect2.gen(function* () {
1032
+ return Effect_exports.gen(function* () {
916
1033
  const start = Date.now();
917
1034
  let waitedForIdle = false;
918
1035
  let isFirstPoll = true;
@@ -923,15 +1040,15 @@ function waitForNotVisible(driver, selector, parse, opts, cache) {
923
1040
  while (hiddenAttempt === 0 || Date.now() - start < timeout) {
924
1041
  hiddenAttempt += 1;
925
1042
  const remaining = Math.max(10, timeout - (Date.now() - start));
926
- const hidden = yield* Effect2.tryPromise({
1043
+ const hidden = yield* Effect_exports.tryPromise({
927
1044
  try: () => domChannel.waitForHidden(selector, { timeoutMs: remaining }),
928
1045
  catch: (err) => {
929
1046
  const msg = err instanceof Error ? err.message : String(err);
930
1047
  return isInvalidSelectorError(err) || /context closed/i.test(msg) ? new DriverError({ message: msg }) : null;
931
1048
  }
932
1049
  }).pipe(
933
- Effect2.catch(
934
- (err) => err instanceof DriverError ? Effect2.fail(err) : Effect2.succeed(null)
1050
+ Effect_exports.catch(
1051
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
935
1052
  )
936
1053
  );
937
1054
  if (hidden === true) return;
@@ -943,8 +1060,8 @@ function waitForNotVisible(driver, selector, parse, opts, cache) {
943
1060
  });
944
1061
  }
945
1062
  if (Date.now() - start >= timeout) break;
946
- yield* Effect2.sleep(
947
- Duration.millis(Math.min(50, Math.max(10, timeout - (Date.now() - start))))
1063
+ yield* Effect_exports.sleep(
1064
+ Duration_exports.millis(Math.min(50, Math.max(10, timeout - (Date.now() - start))))
948
1065
  );
949
1066
  }
950
1067
  }
@@ -966,7 +1083,7 @@ function waitForNotVisible(driver, selector, parse, opts, cache) {
966
1083
  }
967
1084
  const elapsed = Date.now() - start;
968
1085
  const interval = nextInterval(elapsed, timeout, initialPollInterval, pollInterval);
969
- yield* Effect2.sleep(Duration.millis(interval));
1086
+ yield* Effect_exports.sleep(Duration_exports.millis(interval));
970
1087
  }
971
1088
  return yield* new WaitTimeoutError({
972
1089
  message: `Element still visible after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
@@ -978,7 +1095,6 @@ function waitForNotVisible(driver, selector, parse, opts, cache) {
978
1095
 
979
1096
  // src/smart/hierarchy-cache.ts
980
1097
  init_esm_shims();
981
- import { Effect as Effect3 } from "effect";
982
1098
  var DEFAULT_CACHE_TTL = 100;
983
1099
  function createHierarchyCache(config) {
984
1100
  const ttl = config?.hierarchyCacheTtl ?? DEFAULT_CACHE_TTL;
@@ -986,7 +1102,7 @@ function createHierarchyCache(config) {
986
1102
  let cachedAt = 0;
987
1103
  return {
988
1104
  get(driver, parse) {
989
- return Effect3.gen(function* () {
1105
+ return Effect_exports.gen(function* () {
990
1106
  const now = Date.now();
991
1107
  if (ttl > 0 && cachedRoot && now - cachedAt < ttl) {
992
1108
  return cachedRoot;
@@ -1015,10 +1131,49 @@ async function loadCachedAxeSource() {
1015
1131
  const { readFileSync: readFileSync2 } = await import("fs");
1016
1132
  const { createRequire } = await import("module");
1017
1133
  const require2 = createRequire(import.meta.url);
1018
- const axePath = require2.resolve("axe-core/axe.js");
1134
+ let axePath;
1135
+ try {
1136
+ axePath = require2.resolve("axe-core/axe.min.js");
1137
+ } catch {
1138
+ try {
1139
+ axePath = require2.resolve("axe-core/axe.js");
1140
+ } catch (cause) {
1141
+ throw new Error(
1142
+ 'Accessibility audits (toPassAccessibilityAudit / auditAccessibility) require the optional "axe-core" add-on. Install it with: npm install axe-core',
1143
+ { cause }
1144
+ );
1145
+ }
1146
+ }
1019
1147
  cachedAxeSource = readFileSync2(axePath, "utf-8");
1020
1148
  return cachedAxeSource;
1021
1149
  }
1150
+ function withIncludeHiddenSelector(selector) {
1151
+ if (typeof selector !== "object" || selector === null) return selector;
1152
+ const obj = selector;
1153
+ const next = { ...obj };
1154
+ if ("role" in next) next["includeHidden"] = true;
1155
+ if ("includeHidden" in next || "role" in next) next["includeHidden"] = true;
1156
+ if (next["within"] && typeof next["within"] === "object") {
1157
+ next["within"] = withIncludeHiddenSelector(next["within"]);
1158
+ }
1159
+ if (next["target"] && typeof next["target"] === "object") {
1160
+ next["target"] = withIncludeHiddenSelector(next["target"]);
1161
+ }
1162
+ if (next["has"] && typeof next["has"] === "object") {
1163
+ next["has"] = withIncludeHiddenSelector(next["has"]);
1164
+ }
1165
+ if (next["hasNot"] && typeof next["hasNot"] === "object") {
1166
+ next["hasNot"] = withIncludeHiddenSelector(next["hasNot"]);
1167
+ }
1168
+ if (Array.isArray(next["or"])) {
1169
+ next["or"] = next["or"].map((s) => withIncludeHiddenSelector(s));
1170
+ }
1171
+ if (Array.isArray(next["and"])) {
1172
+ next["and"] = next["and"].map((s) => withIncludeHiddenSelector(s));
1173
+ }
1174
+ next["includeHidden"] = true;
1175
+ return next;
1176
+ }
1022
1177
  var DEFAULT_MAX_SCROLLS = 5;
1023
1178
  var DEFAULT_DISMISS_KEYBOARD_STRATEGY = "auto";
1024
1179
  var DEFAULT_MAX_BACKS = 3;
@@ -1045,9 +1200,9 @@ function createCoordinator(driver, config) {
1045
1200
  const cache = createHierarchyCache(cacheConfig);
1046
1201
  const idleWait = () => {
1047
1202
  const ms = config.waitForIdleTimeout;
1048
- return ms && ms > 0 ? Effect4.sleep(Duration2.millis(ms)) : Effect4.void;
1203
+ return ms && ms > 0 ? Effect_exports.sleep(Duration_exports.millis(ms)) : Effect_exports.void;
1049
1204
  };
1050
- const afterMutation = () => Effect4.gen(function* () {
1205
+ const afterMutation = () => Effect_exports.gen(function* () {
1051
1206
  cache.invalidate();
1052
1207
  yield* idleWait();
1053
1208
  });
@@ -1055,7 +1210,7 @@ function createCoordinator(driver, config) {
1055
1210
  const safeMinY = screenH * 0.15;
1056
1211
  const safeMaxY = screenH * 0.85;
1057
1212
  const clampY = (y) => Math.max(safeMinY, Math.min(safeMaxY, y));
1058
- const swipeEffect = (direction, opts) => Effect4.gen(function* () {
1213
+ const swipeEffect = (direction, opts) => Effect_exports.gen(function* () {
1059
1214
  const w = config.screenWidth ?? 1080;
1060
1215
  const h = config.screenHeight ?? 1920;
1061
1216
  const coords = computeSwipeCoords(direction, w, h, 0.2);
@@ -1068,7 +1223,7 @@ function createCoordinator(driver, config) {
1068
1223
  );
1069
1224
  yield* afterMutation();
1070
1225
  });
1071
- const scrollEffect = (direction) => Effect4.gen(function* () {
1226
+ const scrollEffect = (direction) => Effect_exports.gen(function* () {
1072
1227
  const w = config.screenWidth ?? 1080;
1073
1228
  const h = config.screenHeight ?? 1920;
1074
1229
  const coords = computeSwipeCoords(direction, w, h, 0.3);
@@ -1090,26 +1245,26 @@ function createCoordinator(driver, config) {
1090
1245
  }
1091
1246
  if (config.platform !== "web") {
1092
1247
  if (driver.domChannel?.isConnected() && driver.domChannel.waitForIdle) {
1093
- yield* Effect4.tryPromise({
1248
+ yield* Effect_exports.tryPromise({
1094
1249
  try: () => driver.domChannel.waitForIdle({ timeout: 150, quietPeriodMs: 30 }),
1095
1250
  catch: () => void 0
1096
- }).pipe(Effect4.catch(() => Effect4.void));
1251
+ }).pipe(Effect_exports.catch(() => Effect_exports.void));
1097
1252
  } else {
1098
- yield* Effect4.promise(() => new Promise((r) => setTimeout(r, 100)));
1253
+ yield* Effect_exports.promise(() => new Promise((r) => setTimeout(r, 100)));
1099
1254
  }
1100
1255
  }
1101
1256
  yield* afterMutation();
1102
1257
  });
1103
- const probeVisible = (selector, opts) => Effect4.gen(function* () {
1258
+ const probeVisible = (selector, opts) => Effect_exports.gen(function* () {
1104
1259
  cache.invalidate();
1105
1260
  const domChannel = driver.domChannel;
1106
1261
  if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1107
- const matches = yield* Effect4.tryPromise({
1262
+ const matches = yield* Effect_exports.tryPromise({
1108
1263
  try: () => domChannel.query(selector),
1109
1264
  catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1110
1265
  }).pipe(
1111
- Effect4.catch(
1112
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1266
+ Effect_exports.catch(
1267
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
1113
1268
  )
1114
1269
  );
1115
1270
  if (matches) {
@@ -1117,7 +1272,7 @@ function createCoordinator(driver, config) {
1117
1272
  }
1118
1273
  }
1119
1274
  const probeTimeout = opts?.probeTimeout ?? 1;
1120
- const result = yield* Effect4.result(
1275
+ const result = yield* Effect_exports.result(
1121
1276
  waitForElement(
1122
1277
  driver,
1123
1278
  selector,
@@ -1143,7 +1298,7 @@ function createCoordinator(driver, config) {
1143
1298
  };
1144
1299
  return directionMap[direction];
1145
1300
  };
1146
- const normalizeWhitespace = (s) => s.replaceAll(/\s+/g, " ").trim();
1301
+ const normalizeWhitespace = (s) => s.replaceAll(/[\s\u00a0\u202f]+/g, " ").trim();
1147
1302
  const collectContainerText = (el) => {
1148
1303
  if (el.text) return el.text;
1149
1304
  const parts = [];
@@ -1160,7 +1315,7 @@ function createCoordinator(driver, config) {
1160
1315
  }
1161
1316
  return parts.join(" ").trim();
1162
1317
  };
1163
- const pollUntilMatch = (selector, opts, check, formatError, domMatchSpec, negate = false) => Effect4.gen(function* () {
1318
+ const pollUntilMatch = (selector, opts, check, formatError, domMatchSpec, negate = false) => Effect_exports.gen(function* () {
1164
1319
  const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1165
1320
  const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 200;
1166
1321
  const start = Date.now();
@@ -1174,7 +1329,7 @@ function createCoordinator(driver, config) {
1174
1329
  while (attemptIdx === 0 || Date.now() < deadline) {
1175
1330
  attemptIdx += 1;
1176
1331
  const remaining = Math.max(10, deadline - Date.now());
1177
- const reactive = yield* Effect4.tryPromise({
1332
+ const reactive = yield* Effect_exports.tryPromise({
1178
1333
  try: () => domChannel.waitForMatch(selector, {
1179
1334
  ...domMatchSpec,
1180
1335
  ...negate ? { negate: true } : {},
@@ -1189,8 +1344,8 @@ function createCoordinator(driver, config) {
1189
1344
  return null;
1190
1345
  }
1191
1346
  }).pipe(
1192
- Effect4.catch(
1193
- (err2) => err2 instanceof DriverError ? Effect4.fail(err2) : Effect4.succeed(null)
1347
+ Effect_exports.catch(
1348
+ (err2) => err2 instanceof DriverError ? Effect_exports.fail(err2) : Effect_exports.succeed(null)
1194
1349
  )
1195
1350
  );
1196
1351
  if (reactive) {
@@ -1203,7 +1358,7 @@ function createCoordinator(driver, config) {
1203
1358
  if (Date.now() >= deadline || !earlyEmptyOrTransient) {
1204
1359
  if (Date.now() >= deadline) break;
1205
1360
  }
1206
- yield* Effect4.sleep(Duration2.millis(Math.min(60, Math.max(10, deadline - Date.now()))));
1361
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(60, Math.max(10, deadline - Date.now()))));
1207
1362
  continue;
1208
1363
  }
1209
1364
  if (lastReactiveError && /Iframe matching .* not found/i.test(lastReactiveError)) {
@@ -1216,7 +1371,7 @@ function createCoordinator(driver, config) {
1216
1371
  });
1217
1372
  }
1218
1373
  if (Date.now() >= deadline) break;
1219
- yield* Effect4.sleep(Duration2.millis(Math.min(60, Math.max(10, deadline - Date.now()))));
1374
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(60, Math.max(10, deadline - Date.now()))));
1220
1375
  }
1221
1376
  if (sawReactiveResult || Date.now() >= deadline) {
1222
1377
  const err2 = formatError(lastActual, timeout);
@@ -1234,12 +1389,12 @@ function createCoordinator(driver, config) {
1234
1389
  if (cache) cache.invalidate();
1235
1390
  let element;
1236
1391
  if (allowHiddenDom && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1237
- const domMatches = yield* Effect4.tryPromise({
1392
+ const domMatches = yield* Effect_exports.tryPromise({
1238
1393
  try: () => domChannel.query(selector),
1239
1394
  catch: (err2) => isInvalidSelectorError(err2) ? new DriverError({ message: err2 instanceof Error ? err2.message : String(err2) }) : null
1240
1395
  }).pipe(
1241
- Effect4.catch(
1242
- (err2) => err2 instanceof DriverError ? Effect4.fail(err2) : Effect4.succeed(null)
1396
+ Effect_exports.catch(
1397
+ (err2) => err2 instanceof DriverError ? Effect_exports.fail(err2) : Effect_exports.succeed(null)
1243
1398
  )
1244
1399
  );
1245
1400
  if (domMatches && domMatches.length > 0) {
@@ -1259,7 +1414,7 @@ function createCoordinator(driver, config) {
1259
1414
  if (negate ? !result.matched : result.matched) return;
1260
1415
  lastActual = result.actual;
1261
1416
  }
1262
- yield* Effect4.sleep(Duration2.millis(pollInterval));
1417
+ yield* Effect_exports.sleep(Duration_exports.millis(pollInterval));
1263
1418
  }
1264
1419
  const err = formatError(lastActual, timeout);
1265
1420
  return yield* new TextMismatchError({
@@ -1269,15 +1424,15 @@ function createCoordinator(driver, config) {
1269
1424
  selector
1270
1425
  });
1271
1426
  });
1272
- const dismissKeyboardWithDriver = () => Effect4.gen(function* () {
1427
+ const dismissKeyboardWithDriver = () => Effect_exports.gen(function* () {
1273
1428
  yield* driver.hideKeyboard();
1274
1429
  yield* afterMutation();
1275
1430
  });
1276
- const dismissKeyboardWithBack = () => Effect4.gen(function* () {
1431
+ const dismissKeyboardWithBack = () => Effect_exports.gen(function* () {
1277
1432
  yield* driver.back();
1278
1433
  yield* afterMutation();
1279
1434
  });
1280
- const scaleGesture = (methodName, selector, opts) => Effect4.gen(function* () {
1435
+ const scaleGesture = (methodName, selector, opts) => Effect_exports.gen(function* () {
1281
1436
  const element = yield* waitForActionElement(
1282
1437
  driver,
1283
1438
  selector,
@@ -1318,908 +1473,1020 @@ function createCoordinator(driver, config) {
1318
1473
  { kind: "enabled" },
1319
1474
  !expectedEnabled
1320
1475
  );
1321
- const createAssertions = () => ({
1322
- assertVisible: (selector, opts) => waitForElement(driver, selector, parse, { ...defaults, ...opts }, cache),
1323
- assertHidden: (selector, opts) => waitForNotVisible(driver, selector, parse, { ...defaults, ...opts }, cache),
1324
- assertText: (selector, expected, opts, negate = false) => {
1325
- if (expected instanceof RegExp) {
1476
+ const createAssertions = () => {
1477
+ let hasInjectedAxe = false;
1478
+ return {
1479
+ assertVisible: (selector, opts) => waitForElement(
1480
+ driver,
1481
+ selector,
1482
+ parse,
1483
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1484
+ cache
1485
+ ),
1486
+ assertHidden: (selector, opts) => waitForNotVisible(
1487
+ driver,
1488
+ selector,
1489
+ parse,
1490
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1491
+ cache
1492
+ ),
1493
+ assertText: (selector, expected, opts, negate = false) => {
1494
+ if (expected instanceof RegExp) {
1495
+ return pollUntilMatch(
1496
+ selector,
1497
+ opts,
1498
+ (el) => {
1499
+ const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1500
+ return { matched: expected.test(actual), actual };
1501
+ },
1502
+ (actual, timeout) => ({
1503
+ message: negate ? `Expected text NOT to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1504
+ expected: negate ? `not ${String(expected)}` : String(expected)
1505
+ }),
1506
+ { kind: "matchesText", patternSource: expected.source, patternFlags: expected.flags },
1507
+ negate
1508
+ );
1509
+ }
1510
+ const normalizedExpected = normalizeWhitespace(expected);
1326
1511
  return pollUntilMatch(
1327
1512
  selector,
1328
1513
  opts,
1329
1514
  (el) => {
1330
- const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1331
- return { matched: expected.test(actual), actual };
1515
+ const raw = el.textContent ?? el.text;
1516
+ const actual = raw !== void 0 ? normalizeWhitespace(raw) : void 0;
1517
+ return { matched: actual === normalizedExpected, actual };
1332
1518
  },
1333
1519
  (actual, timeout) => ({
1334
- message: negate ? `Expected text NOT to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${expected} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1335
- expected: negate ? `not ${String(expected)}` : String(expected)
1520
+ message: negate ? `Expected text NOT to be "${expected}" after ${timeout}ms` : `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1521
+ expected: negate ? `not ${expected}` : expected
1336
1522
  }),
1337
- { kind: "matchesText", patternSource: expected.source, patternFlags: expected.flags },
1523
+ { kind: "text", expected },
1338
1524
  negate
1339
1525
  );
1340
- }
1341
- const normalizedExpected = normalizeWhitespace(expected);
1342
- return pollUntilMatch(
1526
+ },
1527
+ assertContainsText: (selector, expected, opts, negate = false) => {
1528
+ const ignoreCase = Boolean(opts?.ignoreCase);
1529
+ const normalizedExpected = ignoreCase ? normalizeWhitespace(expected).toLowerCase() : normalizeWhitespace(expected);
1530
+ return pollUntilMatch(
1531
+ selector,
1532
+ opts,
1533
+ (el) => {
1534
+ const raw = el.textContent ?? el.text ?? "";
1535
+ const actual = normalizeWhitespace(raw);
1536
+ const matched = ignoreCase ? actual.toLowerCase().includes(normalizedExpected) : actual.includes(normalizedExpected);
1537
+ return { matched, actual };
1538
+ },
1539
+ (actual, timeout) => ({
1540
+ message: negate ? `Expected text NOT to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1541
+ expected: negate ? `not containing ${expected}` : expected
1542
+ }),
1543
+ { kind: "containsText", expected, ...ignoreCase ? { ignoreCase: true } : {} },
1544
+ negate
1545
+ );
1546
+ },
1547
+ assertEnabled: (selector, opts) => assertEnabledState(selector, true, opts),
1548
+ assertDisabled: (selector, opts) => assertEnabledState(selector, false, opts),
1549
+ getText: (selector, opts) => Effect_exports.gen(function* () {
1550
+ const element = yield* waitForElement(
1551
+ driver,
1552
+ selector,
1553
+ parse,
1554
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1555
+ cache
1556
+ );
1557
+ return collectContainerText(element);
1558
+ }),
1559
+ count: (selector, opts) => Effect_exports.gen(function* () {
1560
+ cache.invalidate();
1561
+ const includeHidden = opts?.includeHidden;
1562
+ const visibleOnly = includeHidden === false || Boolean(opts?.visible);
1563
+ const effectiveSelector = includeHidden === true ? withIncludeHiddenSelector(selector) : selector;
1564
+ const domChannel = driver.domChannel;
1565
+ if (!isSystemUISelector(effectiveSelector) && !isRelativeSelectorLike2(effectiveSelector) && domChannel?.isConnected()) {
1566
+ const matches = yield* Effect_exports.tryPromise({
1567
+ try: () => domChannel.query(effectiveSelector),
1568
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1569
+ }).pipe(
1570
+ Effect_exports.catch(
1571
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
1572
+ )
1573
+ );
1574
+ if (matches) {
1575
+ return visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
1576
+ }
1577
+ }
1578
+ const raw = yield* driver.dumpHierarchy();
1579
+ const root = parse(raw);
1580
+ if (isRelativeSelectorLike2(effectiveSelector)) {
1581
+ const resolved = yield* resolveElementAcrossChannels(
1582
+ driver,
1583
+ effectiveSelector,
1584
+ parse,
1585
+ cache,
1586
+ {
1587
+ forAction: false,
1588
+ platform: opts?.platform ?? config.platform
1589
+ }
1590
+ );
1591
+ return resolved ? 1 : 0;
1592
+ }
1593
+ const matched = findElements(root, effectiveSelector);
1594
+ return visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
1595
+ }),
1596
+ isElementEnabled: (selector, opts) => Effect_exports.gen(function* () {
1597
+ if (opts?.includeHidden && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && driver.domChannel?.isConnected()) {
1598
+ const timeout = opts.timeout ?? defaults?.timeout ?? 5e3;
1599
+ const pollInterval = opts.pollInterval ?? defaults?.pollInterval ?? 100;
1600
+ const effectiveSelector = withIncludeHiddenSelector(selector);
1601
+ const start = Date.now();
1602
+ while (true) {
1603
+ const matches = yield* Effect_exports.tryPromise({
1604
+ try: () => driver.domChannel.query(effectiveSelector),
1605
+ catch: () => null
1606
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
1607
+ if (matches && matches.length > 0) {
1608
+ const target = matches[matches.length - 1];
1609
+ return target.enabled !== false;
1610
+ }
1611
+ if (Date.now() - start >= timeout) {
1612
+ return yield* new ElementNotFoundError({
1613
+ message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1614
+ selector,
1615
+ timeoutMs: timeout
1616
+ });
1617
+ }
1618
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(pollInterval, 100)));
1619
+ }
1620
+ }
1621
+ const element = yield* waitForElement(
1622
+ driver,
1623
+ selector,
1624
+ parse,
1625
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1626
+ cache
1627
+ );
1628
+ return element.enabled !== false;
1629
+ }),
1630
+ isChecked: (selector, opts) => Effect_exports.gen(function* () {
1631
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1632
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1633
+ const domChannel = driver.domChannel;
1634
+ if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1635
+ const effectiveSelector = opts?.includeHidden ? withIncludeHiddenSelector(selector) : selector;
1636
+ const start = Date.now();
1637
+ while (true) {
1638
+ const matches = yield* Effect_exports.tryPromise({
1639
+ try: () => domChannel.query(effectiveSelector),
1640
+ catch: () => null
1641
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
1642
+ if (matches && matches.length > 0) {
1643
+ const visibleMatches = matches.filter((m) => m.visible);
1644
+ const target = opts?.includeHidden === false ? visibleMatches[visibleMatches.length - 1] : visibleMatches[visibleMatches.length - 1] ?? matches[matches.length - 1];
1645
+ if (target) {
1646
+ return Boolean(
1647
+ target.checked === true || target.attributes?.["aria-checked"] === "true"
1648
+ );
1649
+ }
1650
+ }
1651
+ if (Date.now() - start >= timeout) {
1652
+ return yield* new ElementNotFoundError({
1653
+ message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1654
+ selector,
1655
+ timeoutMs: timeout
1656
+ });
1657
+ }
1658
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(pollInterval, 100)));
1659
+ }
1660
+ }
1661
+ const element = yield* waitForElement(
1662
+ driver,
1663
+ selector,
1664
+ parse,
1665
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1666
+ cache
1667
+ );
1668
+ return Boolean(
1669
+ element.checked === true || element.attributes?.["aria-checked"] === "true"
1670
+ );
1671
+ }),
1672
+ assertValue: (selector, expected, opts, negate = false) => {
1673
+ const isRe = expected instanceof RegExp;
1674
+ const expectedStr = isRe ? String(expected) : String(expected);
1675
+ return pollUntilMatch(
1676
+ selector,
1677
+ opts,
1678
+ (el) => {
1679
+ const actual = el.value ?? "";
1680
+ const matched = isRe ? expected.test(actual) : actual === expectedStr;
1681
+ return { matched, actual };
1682
+ },
1683
+ (actual, timeout) => ({
1684
+ message: negate ? `Expected value NOT to ${isRe ? "match" : "be"} ${isRe ? expectedStr : JSON.stringify(expectedStr)} after ${timeout}ms` : `Expected value ${isRe ? expectedStr : JSON.stringify(expectedStr)} but got "${actual ?? "(no value)"}" after ${timeout}ms`,
1685
+ expected: negate ? `not ${expectedStr}` : expectedStr
1686
+ }),
1687
+ isRe ? { kind: "value", patternSource: expected.source, patternFlags: expected.flags } : { kind: "value", expected: expectedStr },
1688
+ negate
1689
+ );
1690
+ },
1691
+ assertAttribute: (selector, name, expectedValue, opts, negate = false) => {
1692
+ const isRe = expectedValue instanceof RegExp;
1693
+ return pollUntilMatch(
1694
+ selector,
1695
+ opts,
1696
+ (el) => {
1697
+ const actual = el.attributes?.[name];
1698
+ if (expectedValue === void 0) {
1699
+ return { matched: actual !== void 0, actual };
1700
+ }
1701
+ const matched = isRe ? actual !== void 0 && expectedValue.test(actual) : actual === expectedValue;
1702
+ return { matched, actual };
1703
+ },
1704
+ (actual, timeout) => negate ? expectedValue === void 0 ? {
1705
+ message: `Expected attribute "${name}" NOT to exist but got "${actual ?? ""}" after ${timeout}ms`,
1706
+ expected: `not ${name}`
1707
+ } : {
1708
+ message: `Expected attribute "${name}" NOT to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} after ${timeout}ms`,
1709
+ expected: `not ${String(expectedValue)}`
1710
+ } : expectedValue === void 0 ? {
1711
+ message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
1712
+ expected: name
1713
+ } : {
1714
+ message: `Expected attribute "${name}" to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} but got "${actual ?? "(not found)"}" after ${timeout}ms`,
1715
+ expected: String(expectedValue)
1716
+ },
1717
+ isRe ? {
1718
+ kind: "attribute",
1719
+ attributeName: name,
1720
+ patternSource: expectedValue.source,
1721
+ patternFlags: expectedValue.flags
1722
+ } : { kind: "attribute", attributeName: name, expected: expectedValue },
1723
+ negate
1724
+ );
1725
+ },
1726
+ assertAttached: (selector, opts, negate = false) => Effect_exports.gen(function* () {
1727
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1728
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1729
+ const start = Date.now();
1730
+ const deadline = start + timeout;
1731
+ let lastActual;
1732
+ while (true) {
1733
+ const domChannel = driver.domChannel;
1734
+ if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
1735
+ const remaining = Math.max(50, deadline - Date.now());
1736
+ const reactive = yield* Effect_exports.tryPromise({
1737
+ try: () => domChannel.waitForMatch(selector, {
1738
+ kind: "attached",
1739
+ ...negate ? { negate: true } : {},
1740
+ timeoutMs: remaining
1741
+ }),
1742
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1743
+ }).pipe(
1744
+ Effect_exports.catch(
1745
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
1746
+ )
1747
+ );
1748
+ if (reactive) {
1749
+ if (reactive.matched) return;
1750
+ if (reactive.actual !== void 0) lastActual = reactive.actual;
1751
+ if (Date.now() >= deadline) break;
1752
+ yield* Effect_exports.sleep(
1753
+ Duration_exports.millis(Math.min(30, Math.max(10, deadline - Date.now())))
1754
+ );
1755
+ continue;
1756
+ }
1757
+ }
1758
+ cache.invalidate();
1759
+ let attached = false;
1760
+ if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1761
+ const matches = yield* Effect_exports.tryPromise({
1762
+ try: () => domChannel.query(selector),
1763
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1764
+ }).pipe(
1765
+ Effect_exports.catch(
1766
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
1767
+ )
1768
+ );
1769
+ if (matches) {
1770
+ attached = matches.length > 0;
1771
+ }
1772
+ } else {
1773
+ const raw = yield* driver.dumpHierarchy();
1774
+ const root = parse(raw);
1775
+ attached = findElements(root, selector).length > 0;
1776
+ }
1777
+ lastActual = attached ? "attached" : "detached";
1778
+ if (negate ? !attached : attached) return;
1779
+ if (Date.now() >= deadline) break;
1780
+ yield* Effect_exports.sleep(
1781
+ Duration_exports.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1782
+ );
1783
+ }
1784
+ return yield* new TextMismatchError({
1785
+ message: negate ? `Expected element NOT to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1786
+ expected: negate ? "detached" : "attached",
1787
+ actual: lastActual ?? (negate ? "attached" : "detached"),
1788
+ selector
1789
+ });
1790
+ }),
1791
+ assertInViewport: (selector, opts, negate = false) => pollUntilMatch(
1343
1792
  selector,
1344
1793
  opts,
1345
1794
  (el) => {
1346
- const raw = el.textContent ?? el.text;
1347
- const actual = raw !== void 0 ? normalizeWhitespace(raw) : void 0;
1348
- return { matched: actual === normalizedExpected, actual };
1795
+ const vpW = config.screenWidth ?? 1280;
1796
+ const vpH = config.screenHeight ?? 720;
1797
+ const b = el.bounds;
1798
+ const inVp = b.width > 0 && b.height > 0 && b.x + b.width > 0 && b.y + b.height > 0 && b.x < vpW && b.y < vpH;
1799
+ return { matched: inVp, actual: inVp ? "in viewport" : "outside viewport" };
1349
1800
  },
1350
1801
  (actual, timeout) => ({
1351
- message: negate ? `Expected text NOT to be "${expected}" after ${timeout}ms` : `Expected text "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1352
- expected: negate ? `not ${expected}` : expected
1802
+ message: negate ? `Expected element NOT to be in viewport after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be in viewport but it was "${actual ?? "outside viewport"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1803
+ expected: negate ? "outside viewport" : "in viewport"
1353
1804
  }),
1354
- { kind: "text", expected },
1805
+ { kind: "inViewport" },
1355
1806
  negate
1356
- );
1357
- },
1358
- assertContainsText: (selector, expected, opts, negate = false) => {
1359
- const ignoreCase = Boolean(opts?.ignoreCase);
1360
- const normalizedExpected = ignoreCase ? normalizeWhitespace(expected).toLowerCase() : normalizeWhitespace(expected);
1361
- return pollUntilMatch(
1807
+ ),
1808
+ assertJSProperty: (selector, propertyName, expectedValue, opts, negate = false) => pollUntilMatch(
1362
1809
  selector,
1363
1810
  opts,
1364
1811
  (el) => {
1365
- const raw = el.textContent ?? el.text ?? "";
1366
- const actual = normalizeWhitespace(raw);
1367
- const matched = ignoreCase ? actual.toLowerCase().includes(normalizedExpected) : actual.includes(normalizedExpected);
1368
- return { matched, actual };
1812
+ const raw = el[propertyName];
1813
+ const matched = JSON.stringify(raw) === JSON.stringify(expectedValue);
1814
+ return {
1815
+ matched,
1816
+ actual: typeof raw === "string" ? raw : JSON.stringify(raw)
1817
+ };
1369
1818
  },
1370
1819
  (actual, timeout) => ({
1371
- message: negate ? `Expected text NOT to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to contain "${expected}" but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1372
- expected: negate ? `not containing ${expected}` : expected
1820
+ message: negate ? `Expected JS property "${propertyName}" NOT to equal ${JSON.stringify(expectedValue)} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected JS property "${propertyName}" to equal ${JSON.stringify(expectedValue)} but got ${actual ?? "undefined"} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1821
+ expected: negate ? `not ${JSON.stringify(expectedValue)}` : JSON.stringify(expectedValue)
1373
1822
  }),
1374
- { kind: "containsText", expected, ...ignoreCase ? { ignoreCase: true } : {} },
1823
+ { kind: "jsProperty", propertyName, expectedValue },
1375
1824
  negate
1376
- );
1377
- },
1378
- assertEnabled: (selector, opts) => assertEnabledState(selector, true, opts),
1379
- assertDisabled: (selector, opts) => assertEnabledState(selector, false, opts),
1380
- getText: (selector, opts) => Effect4.gen(function* () {
1381
- const element = yield* waitForElement(
1382
- driver,
1825
+ ),
1826
+ assertMatchesText: (selector, pattern, opts, negate = false) => pollUntilMatch(
1383
1827
  selector,
1384
- parse,
1385
- { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1386
- cache
1387
- );
1388
- return collectContainerText(element);
1389
- }),
1390
- count: (selector, opts) => Effect4.gen(function* () {
1391
- cache.invalidate();
1392
- const visibleOnly = Boolean(opts?.visible);
1393
- const domChannel = driver.domChannel;
1394
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1395
- const matches = yield* Effect4.tryPromise({
1396
- try: () => domChannel.query(selector),
1397
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1398
- }).pipe(
1399
- Effect4.catch(
1400
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1401
- )
1828
+ opts,
1829
+ (el) => {
1830
+ const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1831
+ return { matched: pattern.test(actual), actual };
1832
+ },
1833
+ (actual, timeout) => ({
1834
+ message: negate ? `Expected text NOT to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1835
+ expected: negate ? `not ${String(pattern)}` : String(pattern)
1836
+ }),
1837
+ { kind: "matchesText", patternSource: pattern.source, patternFlags: pattern.flags },
1838
+ negate
1839
+ ),
1840
+ getAttribute: (selector, name, opts) => Effect_exports.gen(function* () {
1841
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1842
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1843
+ const domChannel = driver.domChannel;
1844
+ const effectiveSelector = opts?.includeHidden ? withIncludeHiddenSelector(selector) : selector;
1845
+ if (!isSystemUISelector(effectiveSelector) && !isRelativeSelectorLike2(effectiveSelector) && domChannel?.isConnected()) {
1846
+ const start = Date.now();
1847
+ while (true) {
1848
+ const matches = yield* Effect_exports.tryPromise({
1849
+ try: () => domChannel.query(effectiveSelector),
1850
+ catch: () => null
1851
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
1852
+ if (matches && matches.length > 0) {
1853
+ const target = opts?.includeHidden === false ? matches.filter((m) => m.visible).at(-1) : matches[matches.length - 1];
1854
+ if (target) {
1855
+ return target.attributes?.[name] ?? null;
1856
+ }
1857
+ }
1858
+ if (Date.now() - start >= timeout) {
1859
+ return yield* new ElementNotFoundError({
1860
+ message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1861
+ selector,
1862
+ timeoutMs: timeout
1863
+ });
1864
+ }
1865
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(pollInterval, 100)));
1866
+ }
1867
+ }
1868
+ const element = yield* waitForElement(
1869
+ driver,
1870
+ effectiveSelector,
1871
+ parse,
1872
+ { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1873
+ cache
1874
+ );
1875
+ return element.attributes?.[name] ?? null;
1876
+ }),
1877
+ assertScreenshot: (selector, name, flowFilePath, flowName, platform, options) => Effect_exports.gen(function* () {
1878
+ const { resolveBaselinePath, readBaseline, writeBaseline } = yield* Effect_exports.promise(
1879
+ () => import("./baseline-manager-XJ3LADKC.js")
1880
+ );
1881
+ const { cropToElement: cropToElement2, applyMask, compareScreenshots: compareScreenshots2 } = yield* Effect_exports.promise(
1882
+ () => import("./screenshot-compare-DNIP2EK4.js")
1402
1883
  );
1403
- if (matches) {
1404
- return visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
1884
+ const raw = options.fullPage && driver.takeFullPageScreenshot ? yield* driver.takeFullPageScreenshot() : yield* driver.takeScreenshot();
1885
+ const resolvedMasks = [
1886
+ ...options.mask ?? []
1887
+ ];
1888
+ let cropOriginX = 0;
1889
+ let cropOriginY = 0;
1890
+ if (options.maskSelectors && options.maskSelectors.length > 0) {
1891
+ for (const maskSel of options.maskSelectors) {
1892
+ const found = yield* resolveElementAcrossChannels(driver, maskSel, parse, cache, {
1893
+ forAction: false,
1894
+ platform: config.platform
1895
+ });
1896
+ if (found?.element?.bounds) {
1897
+ resolvedMasks.push(found.element.bounds);
1898
+ }
1899
+ }
1405
1900
  }
1406
- }
1407
- const raw = yield* driver.dumpHierarchy();
1408
- const root = parse(raw);
1409
- if (isRelativeSelectorLike2(selector)) {
1410
- const resolved = yield* resolveElementAcrossChannels(driver, selector, parse, cache, {
1411
- forAction: false,
1412
- platform: opts?.platform ?? config.platform
1901
+ let screenshotBuf;
1902
+ if (selector !== void 0) {
1903
+ const element = yield* waitForElement(
1904
+ driver,
1905
+ selector,
1906
+ parse,
1907
+ { ...defaults, platform: config.platform },
1908
+ cache
1909
+ );
1910
+ cropOriginX = element.bounds.x;
1911
+ cropOriginY = element.bounds.y;
1912
+ screenshotBuf = yield* Effect_exports.promise(() => cropToElement2(raw, element.bounds));
1913
+ } else {
1914
+ screenshotBuf = Buffer.from(raw);
1915
+ }
1916
+ const effectiveMasks = selector !== void 0 ? resolvedMasks.map((m) => ({
1917
+ x: Math.max(0, m.x - cropOriginX),
1918
+ y: Math.max(0, m.y - cropOriginY),
1919
+ width: m.width,
1920
+ height: m.height
1921
+ })) : resolvedMasks;
1922
+ const baselinePath = resolveBaselinePath(
1923
+ flowFilePath,
1924
+ flowName,
1925
+ platform,
1926
+ name,
1927
+ options.baselinesDir
1928
+ );
1929
+ if (options.updateBaselines) {
1930
+ const toWrite = effectiveMasks.length > 0 ? yield* Effect_exports.promise(
1931
+ () => applyMask(screenshotBuf, effectiveMasks, options.maskColor)
1932
+ ) : screenshotBuf;
1933
+ yield* Effect_exports.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1934
+ return;
1935
+ }
1936
+ const existing = readBaseline(baselinePath);
1937
+ if (existing === null) {
1938
+ const toWrite = effectiveMasks.length > 0 ? yield* Effect_exports.promise(
1939
+ () => applyMask(screenshotBuf, effectiveMasks, options.maskColor)
1940
+ ) : screenshotBuf;
1941
+ yield* Effect_exports.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1942
+ return;
1943
+ }
1944
+ let actualBuf = screenshotBuf;
1945
+ let expectedBuf = existing;
1946
+ if (effectiveMasks.length > 0) {
1947
+ actualBuf = yield* Effect_exports.promise(
1948
+ () => applyMask(screenshotBuf, effectiveMasks, options.maskColor)
1949
+ );
1950
+ expectedBuf = yield* Effect_exports.promise(
1951
+ () => applyMask(existing, effectiveMasks, options.maskColor)
1952
+ );
1953
+ }
1954
+ const result = compareScreenshots2(expectedBuf, actualBuf, {
1955
+ threshold: options.threshold,
1956
+ maxDiffPixelRatio: options.maxDiffPixelRatio
1413
1957
  });
1414
- return resolved ? 1 : 0;
1415
- }
1416
- const matched = findElements(root, selector);
1417
- return visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
1418
- }),
1419
- isElementEnabled: (selector, opts) => Effect4.gen(function* () {
1420
- const element = yield* waitForElement(
1421
- driver,
1958
+ if (!result.match) {
1959
+ const { writeFileSync: writeFileSync2, mkdirSync: mkdirSync2 } = yield* Effect_exports.promise(() => import("fs"));
1960
+ const { join: join2 } = yield* Effect_exports.promise(() => import("path"));
1961
+ const outDir = options.outputDir ?? config.outputDir ?? "spana-output";
1962
+ mkdirSync2(outDir, { recursive: true });
1963
+ const safeFlowName = flowName.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-|-$/g, "");
1964
+ const prefix = join2(outDir, `${safeFlowName}-${platform}-${name}`);
1965
+ writeFileSync2(`${prefix}-expected.png`, existing);
1966
+ writeFileSync2(`${prefix}-actual.png`, actualBuf);
1967
+ if (result.diffImage) {
1968
+ writeFileSync2(`${prefix}-diff.png`, result.diffImage);
1969
+ }
1970
+ const detail = result.sizeMismatch ? "image dimensions differ" : `${result.diffPixelCount} differing pixels (ratio: ${(result.diffPixelRatio * 100).toFixed(2)}%)`;
1971
+ return yield* new DriverError({
1972
+ message: `Screenshot mismatch for "${name}": ${detail}. Expected: ${prefix}-expected.png, Actual: ${prefix}-actual.png${result.diffImage ? `, Diff: ${prefix}-diff.png` : ""}`
1973
+ });
1974
+ }
1975
+ }),
1976
+ assertAccessibilityLabel: (selector, expected, opts) => pollUntilMatch(
1422
1977
  selector,
1423
- parse,
1424
- { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1425
- cache
1426
- );
1427
- return element.enabled !== false;
1428
- }),
1429
- assertValue: (selector, expected, opts, negate = false) => {
1430
- const isRe = expected instanceof RegExp;
1431
- const expectedStr = isRe ? String(expected) : String(expected);
1432
- return pollUntilMatch(
1978
+ opts,
1979
+ (el) => {
1980
+ const label = el.accessibilityLabel;
1981
+ if (expected === void 0) {
1982
+ return { matched: label !== void 0 && label.length > 0, actual: label };
1983
+ }
1984
+ return { matched: label === expected, actual: label };
1985
+ },
1986
+ (actual, timeout) => expected === void 0 ? {
1987
+ message: `Expected element to have a non-empty accessibilityLabel but got "${actual ?? "(none)"}" after ${timeout}ms`,
1988
+ expected: "(non-empty)"
1989
+ } : {
1990
+ message: `Expected accessibilityLabel "${expected}" but got "${actual ?? "(none)"}" after ${timeout}ms`,
1991
+ expected
1992
+ },
1993
+ { kind: "accessibilityLabel", expected }
1994
+ ),
1995
+ assertAccessibleName: (selector, expected, opts, negate = false) => pollUntilMatch(
1433
1996
  selector,
1434
1997
  opts,
1435
1998
  (el) => {
1436
- const actual = el.value ?? "";
1437
- const matched = isRe ? expected.test(actual) : actual === expectedStr;
1999
+ const actual = el.accessibilityLabel || el.text || "";
2000
+ const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1438
2001
  return { matched, actual };
1439
2002
  },
1440
2003
  (actual, timeout) => ({
1441
- message: negate ? `Expected value NOT to ${isRe ? "match" : "be"} ${isRe ? expectedStr : JSON.stringify(expectedStr)} after ${timeout}ms` : `Expected value ${isRe ? expectedStr : JSON.stringify(expectedStr)} but got "${actual ?? "(no value)"}" after ${timeout}ms`,
1442
- expected: negate ? `not ${expectedStr}` : expectedStr
2004
+ message: negate ? `Expected accessible name NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible name ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2005
+ expected: negate ? `not ${String(expected)}` : String(expected)
1443
2006
  }),
1444
- isRe ? { kind: "value", patternSource: expected.source, patternFlags: expected.flags } : { kind: "value", expected: expectedStr },
2007
+ expected instanceof RegExp ? {
2008
+ kind: "accessibleName",
2009
+ patternSource: expected.source,
2010
+ patternFlags: expected.flags
2011
+ } : { kind: "accessibleName", expected },
1445
2012
  negate
1446
- );
1447
- },
1448
- assertAttribute: (selector, name, expectedValue, opts, negate = false) => {
1449
- const isRe = expectedValue instanceof RegExp;
1450
- return pollUntilMatch(
2013
+ ),
2014
+ assertAccessibleDescription: (selector, expected, opts, negate = false) => pollUntilMatch(
1451
2015
  selector,
1452
2016
  opts,
1453
2017
  (el) => {
1454
- const actual = el.attributes?.[name];
1455
- if (expectedValue === void 0) {
1456
- return { matched: actual !== void 0, actual };
1457
- }
1458
- const matched = isRe ? actual !== void 0 && expectedValue.test(actual) : actual === expectedValue;
2018
+ const actual = el.accessibleDescription ?? el.attributes?.["aria-description"] ?? "";
2019
+ const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1459
2020
  return { matched, actual };
1460
2021
  },
1461
- (actual, timeout) => negate ? expectedValue === void 0 ? {
1462
- message: `Expected attribute "${name}" NOT to exist but got "${actual ?? ""}" after ${timeout}ms`,
1463
- expected: `not ${name}`
1464
- } : {
1465
- message: `Expected attribute "${name}" NOT to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} after ${timeout}ms`,
1466
- expected: `not ${String(expectedValue)}`
1467
- } : expectedValue === void 0 ? {
1468
- message: `Expected attribute "${name}" to exist but it was not found after ${timeout}ms`,
1469
- expected: name
1470
- } : {
1471
- message: `Expected attribute "${name}" to ${isRe ? "match" : "be"} ${isRe ? String(expectedValue) : JSON.stringify(expectedValue)} but got "${actual ?? "(not found)"}" after ${timeout}ms`,
1472
- expected: String(expectedValue)
2022
+ (actual, timeout) => ({
2023
+ message: negate ? `Expected accessible description NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible description ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2024
+ expected: negate ? `not ${String(expected)}` : String(expected)
2025
+ }),
2026
+ expected instanceof RegExp ? {
2027
+ kind: "accessibleDescription",
2028
+ patternSource: expected.source,
2029
+ patternFlags: expected.flags
2030
+ } : { kind: "accessibleDescription", expected },
2031
+ negate
2032
+ ),
2033
+ assertFocused: (selector, opts, negate = false) => pollUntilMatch(
2034
+ selector,
2035
+ opts,
2036
+ (el) => ({
2037
+ matched: el.focused === true,
2038
+ actual: el.focused ? "focused" : "not focused"
2039
+ }),
2040
+ (actual, timeout) => ({
2041
+ message: negate ? `Expected element NOT to be focused but it was "${actual ?? "focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be focused but it was "${actual ?? "not focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2042
+ expected: negate ? "not focused" : "focused"
2043
+ }),
2044
+ { kind: "focused" },
2045
+ negate
2046
+ ),
2047
+ assertChecked: (selector, opts, negate = false) => pollUntilMatch(
2048
+ selector,
2049
+ opts,
2050
+ (el) => ({
2051
+ matched: el.checked === true || el.attributes?.["aria-checked"] === "true",
2052
+ actual: el.checked ? "checked" : "unchecked"
2053
+ }),
2054
+ (actual, timeout) => ({
2055
+ message: negate ? `Expected element NOT to be checked but it was "${actual ?? "checked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be checked but it was "${actual ?? "unchecked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2056
+ expected: negate ? "unchecked" : "checked"
2057
+ }),
2058
+ { kind: "checked" },
2059
+ negate
2060
+ ),
2061
+ assertEditable: (selector, opts, negate = false) => pollUntilMatch(
2062
+ selector,
2063
+ opts,
2064
+ (el) => ({
2065
+ matched: el.editable === true,
2066
+ actual: el.editable ? "editable" : "not editable"
2067
+ }),
2068
+ (actual, timeout) => ({
2069
+ message: negate ? `Expected element NOT to be editable but it was "${actual ?? "editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be editable but it was "${actual ?? "not editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2070
+ expected: negate ? "not editable" : "editable"
2071
+ }),
2072
+ { kind: "editable" },
2073
+ negate
2074
+ ),
2075
+ assertEmpty: (selector, opts, negate = false) => pollUntilMatch(
2076
+ selector,
2077
+ opts,
2078
+ (el) => {
2079
+ const isEmpty = el.empty !== void 0 ? el.empty : (el.value ?? el.textContent ?? el.text ?? "").trim().length === 0;
2080
+ return {
2081
+ matched: isEmpty,
2082
+ actual: isEmpty ? "empty" : el.value ?? el.text ?? "non-empty"
2083
+ };
1473
2084
  },
1474
- isRe ? {
1475
- kind: "attribute",
1476
- attributeName: name,
1477
- patternSource: expectedValue.source,
1478
- patternFlags: expectedValue.flags
1479
- } : { kind: "attribute", attributeName: name, expected: expectedValue },
2085
+ (actual, timeout) => ({
2086
+ message: negate ? `Expected element NOT to be empty after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be empty but got "${actual ?? "(non-empty)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2087
+ expected: negate ? "non-empty" : "empty"
2088
+ }),
2089
+ { kind: "empty" },
1480
2090
  negate
1481
- );
1482
- },
1483
- assertAttached: (selector, opts, negate = false) => Effect4.gen(function* () {
1484
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1485
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1486
- const start = Date.now();
1487
- const deadline = start + timeout;
1488
- let lastActual;
1489
- while (true) {
1490
- const domChannel = driver.domChannel;
1491
- if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
1492
- const remaining = Math.max(50, deadline - Date.now());
1493
- const reactive = yield* Effect4.tryPromise({
1494
- try: () => domChannel.waitForMatch(selector, {
1495
- kind: "attached",
1496
- ...negate ? { negate: true } : {},
1497
- timeoutMs: remaining
1498
- }),
1499
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1500
- }).pipe(
1501
- Effect4.catch(
1502
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1503
- )
1504
- );
1505
- if (reactive) {
1506
- if (reactive.matched) return;
1507
- if (reactive.actual !== void 0) lastActual = reactive.actual;
1508
- if (Date.now() >= deadline) break;
1509
- yield* Effect4.sleep(
1510
- Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
1511
- );
1512
- continue;
1513
- }
1514
- }
1515
- cache.invalidate();
1516
- let attached = false;
1517
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1518
- const matches = yield* Effect4.tryPromise({
1519
- try: () => domChannel.query(selector),
1520
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1521
- }).pipe(
1522
- Effect4.catch(
1523
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1524
- )
1525
- );
1526
- if (matches) {
1527
- attached = matches.length > 0;
1528
- }
1529
- } else {
1530
- const raw = yield* driver.dumpHierarchy();
1531
- const root = parse(raw);
1532
- attached = findElements(root, selector).length > 0;
1533
- }
1534
- lastActual = attached ? "attached" : "detached";
1535
- if (negate ? !attached : attached) return;
1536
- if (Date.now() >= deadline) break;
1537
- yield* Effect4.sleep(
1538
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1539
- );
1540
- }
1541
- return yield* new TextMismatchError({
1542
- message: negate ? `Expected element NOT to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be attached after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1543
- expected: negate ? "detached" : "attached",
1544
- actual: lastActual ?? (negate ? "attached" : "detached"),
1545
- selector
1546
- });
1547
- }),
1548
- assertInViewport: (selector, opts, negate = false) => pollUntilMatch(
1549
- selector,
1550
- opts,
1551
- (el) => {
1552
- const vpW = config.screenWidth ?? 1280;
1553
- const vpH = config.screenHeight ?? 720;
1554
- const b = el.bounds;
1555
- const inVp = b.width > 0 && b.height > 0 && b.x + b.width > 0 && b.y + b.height > 0 && b.x < vpW && b.y < vpH;
1556
- return { matched: inVp, actual: inVp ? "in viewport" : "outside viewport" };
1557
- },
1558
- (actual, timeout) => ({
1559
- message: negate ? `Expected element NOT to be in viewport after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be in viewport but it was "${actual ?? "outside viewport"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1560
- expected: negate ? "outside viewport" : "in viewport"
1561
- }),
1562
- { kind: "inViewport" },
1563
- negate
1564
- ),
1565
- assertJSProperty: (selector, propertyName, expectedValue, opts, negate = false) => pollUntilMatch(
1566
- selector,
1567
- opts,
1568
- (el) => {
1569
- const raw = el[propertyName];
1570
- const matched = JSON.stringify(raw) === JSON.stringify(expectedValue);
1571
- return {
1572
- matched,
1573
- actual: typeof raw === "string" ? raw : JSON.stringify(raw)
1574
- };
1575
- },
1576
- (actual, timeout) => ({
1577
- message: negate ? `Expected JS property "${propertyName}" NOT to equal ${JSON.stringify(expectedValue)} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected JS property "${propertyName}" to equal ${JSON.stringify(expectedValue)} but got ${actual ?? "undefined"} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1578
- expected: negate ? `not ${JSON.stringify(expectedValue)}` : JSON.stringify(expectedValue)
1579
- }),
1580
- { kind: "jsProperty", propertyName, expectedValue },
1581
- negate
1582
- ),
1583
- assertMatchesText: (selector, pattern, opts, negate = false) => pollUntilMatch(
1584
- selector,
1585
- opts,
1586
- (el) => {
1587
- const actual = normalizeWhitespace(el.textContent ?? el.text ?? "");
1588
- return { matched: pattern.test(actual), actual };
1589
- },
1590
- (actual, timeout) => ({
1591
- message: negate ? `Expected text NOT to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms` : `Expected text to match ${pattern} but got "${actual ?? "(no text)"}" after ${timeout}ms`,
1592
- expected: negate ? `not ${String(pattern)}` : String(pattern)
1593
- }),
1594
- { kind: "matchesText", patternSource: pattern.source, patternFlags: pattern.flags },
1595
- negate
1596
- ),
1597
- getAttribute: (selector, name, opts) => Effect4.gen(function* () {
1598
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1599
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1600
- const domChannel = driver.domChannel;
1601
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1602
- const start = Date.now();
1603
- while (true) {
1604
- const matches = yield* Effect4.tryPromise({
1605
- try: () => domChannel.query(selector),
1606
- catch: () => null
1607
- }).pipe(Effect4.catch(() => Effect4.succeed(null)));
1608
- if (matches && matches.length > 0) {
1609
- const target = matches[matches.length - 1];
1610
- return target.attributes?.[name] ?? null;
1611
- }
1612
- if (Date.now() - start >= timeout) {
1613
- return yield* new ElementNotFoundError({
1614
- message: `Element not found within ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1615
- selector,
1616
- timeoutMs: timeout
1617
- });
1618
- }
1619
- yield* Effect4.sleep(Duration2.millis(Math.min(pollInterval, 100)));
1620
- }
1621
- }
1622
- const element = yield* waitForElement(
1623
- driver,
2091
+ ),
2092
+ assertClass: (selector, expected, opts, negate = false) => pollUntilMatch(
1624
2093
  selector,
1625
- parse,
1626
- { ...defaults, ...opts, platform: opts?.platform ?? config.platform },
1627
- cache
1628
- );
1629
- return element.attributes?.[name] ?? null;
1630
- }),
1631
- assertScreenshot: (selector, name, flowFilePath, flowName, platform, options) => Effect4.gen(function* () {
1632
- const { resolveBaselinePath, readBaseline, writeBaseline } = yield* Effect4.promise(
1633
- () => import("./baseline-manager-LVUVH2MJ.js")
1634
- );
1635
- const { cropToElement: cropToElement2, applyMask, compareScreenshots: compareScreenshots2 } = yield* Effect4.promise(
1636
- () => import("./screenshot-compare-BJRJHKNQ.js")
1637
- );
1638
- const raw = options.fullPage && driver.takeFullPageScreenshot ? yield* driver.takeFullPageScreenshot() : yield* driver.takeScreenshot();
1639
- const resolvedMasks = [
1640
- ...options.mask ?? []
1641
- ];
1642
- let cropOriginX = 0;
1643
- let cropOriginY = 0;
1644
- if (options.maskSelectors && options.maskSelectors.length > 0) {
1645
- for (const maskSel of options.maskSelectors) {
1646
- const found = yield* resolveElementAcrossChannels(driver, maskSel, parse, cache, {
1647
- forAction: false,
1648
- platform: config.platform
1649
- });
1650
- if (found?.element?.bounds) {
1651
- resolvedMasks.push(found.element.bounds);
1652
- }
1653
- }
1654
- }
1655
- let screenshotBuf;
1656
- if (selector !== void 0) {
1657
- const element = yield* waitForElement(driver, selector, parse, { ...defaults }, cache);
1658
- cropOriginX = element.bounds.x;
1659
- cropOriginY = element.bounds.y;
1660
- screenshotBuf = yield* Effect4.promise(() => cropToElement2(raw, element.bounds));
1661
- } else {
1662
- screenshotBuf = Buffer.from(raw);
1663
- }
1664
- const effectiveMasks = selector !== void 0 ? resolvedMasks.map((m) => ({
1665
- x: Math.max(0, m.x - cropOriginX),
1666
- y: Math.max(0, m.y - cropOriginY),
1667
- width: m.width,
1668
- height: m.height
1669
- })) : resolvedMasks;
1670
- const baselinePath = resolveBaselinePath(
1671
- flowFilePath,
1672
- flowName,
1673
- platform,
1674
- name,
1675
- options.baselinesDir
1676
- );
1677
- if (options.updateBaselines) {
1678
- const toWrite = effectiveMasks.length > 0 ? yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks)) : screenshotBuf;
1679
- yield* Effect4.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1680
- return;
1681
- }
1682
- const existing = readBaseline(baselinePath);
1683
- if (existing === null) {
1684
- const toWrite = effectiveMasks.length > 0 ? yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks)) : screenshotBuf;
1685
- yield* Effect4.promise(() => Promise.resolve(writeBaseline(baselinePath, toWrite)));
1686
- return;
1687
- }
1688
- let actualBuf = screenshotBuf;
1689
- let expectedBuf = existing;
1690
- if (effectiveMasks.length > 0) {
1691
- actualBuf = yield* Effect4.promise(() => applyMask(screenshotBuf, effectiveMasks));
1692
- expectedBuf = yield* Effect4.promise(() => applyMask(existing, effectiveMasks));
1693
- }
1694
- const result = compareScreenshots2(expectedBuf, actualBuf, {
1695
- threshold: options.threshold,
1696
- maxDiffPixelRatio: options.maxDiffPixelRatio
1697
- });
1698
- if (!result.match) {
1699
- const { writeFileSync: writeFileSync2, mkdirSync: mkdirSync2 } = yield* Effect4.promise(() => import("fs"));
1700
- const { join: join2 } = yield* Effect4.promise(() => import("path"));
1701
- const outDir = options.outputDir ?? config.outputDir ?? "spana-output";
1702
- mkdirSync2(outDir, { recursive: true });
1703
- const safeFlowName = flowName.toLowerCase().replaceAll(/[^a-z0-9]+/g, "-").replaceAll(/^-|-$/g, "");
1704
- const prefix = join2(outDir, `${safeFlowName}-${platform}-${name}`);
1705
- writeFileSync2(`${prefix}-expected.png`, existing);
1706
- writeFileSync2(`${prefix}-actual.png`, actualBuf);
1707
- if (result.diffImage) {
1708
- writeFileSync2(`${prefix}-diff.png`, result.diffImage);
1709
- }
1710
- const detail = result.sizeMismatch ? "image dimensions differ" : `${result.diffPixelCount} differing pixels (ratio: ${(result.diffPixelRatio * 100).toFixed(2)}%)`;
1711
- return yield* new DriverError({
1712
- message: `Screenshot mismatch for "${name}": ${detail}. Expected: ${prefix}-expected.png, Actual: ${prefix}-actual.png${result.diffImage ? `, Diff: ${prefix}-diff.png` : ""}`
1713
- });
1714
- }
1715
- }),
1716
- assertAccessibilityLabel: (selector, expected, opts) => pollUntilMatch(
1717
- selector,
1718
- opts,
1719
- (el) => {
1720
- const label = el.accessibilityLabel;
1721
- if (expected === void 0) {
1722
- return { matched: label !== void 0 && label.length > 0, actual: label };
1723
- }
1724
- return { matched: label === expected, actual: label };
1725
- },
1726
- (actual, timeout) => expected === void 0 ? {
1727
- message: `Expected element to have a non-empty accessibilityLabel but got "${actual ?? "(none)"}" after ${timeout}ms`,
1728
- expected: "(non-empty)"
1729
- } : {
1730
- message: `Expected accessibilityLabel "${expected}" but got "${actual ?? "(none)"}" after ${timeout}ms`,
1731
- expected
1732
- },
1733
- { kind: "accessibilityLabel", expected }
1734
- ),
1735
- assertAccessibleName: (selector, expected, opts, negate = false) => pollUntilMatch(
1736
- selector,
1737
- opts,
1738
- (el) => {
1739
- const actual = el.accessibilityLabel || el.text || "";
1740
- const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1741
- return { matched, actual };
1742
- },
1743
- (actual, timeout) => ({
1744
- message: negate ? `Expected accessible name NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible name ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1745
- expected: negate ? `not ${String(expected)}` : String(expected)
1746
- }),
1747
- expected instanceof RegExp ? {
1748
- kind: "accessibleName",
1749
- patternSource: expected.source,
1750
- patternFlags: expected.flags
1751
- } : { kind: "accessibleName", expected },
1752
- negate
1753
- ),
1754
- assertAccessibleDescription: (selector, expected, opts, negate = false) => pollUntilMatch(
1755
- selector,
1756
- opts,
1757
- (el) => {
1758
- const actual = el.accessibleDescription ?? el.attributes?.["aria-description"] ?? "";
1759
- const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1760
- return { matched, actual };
1761
- },
1762
- (actual, timeout) => ({
1763
- message: negate ? `Expected accessible description NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected accessible description ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? "(none)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1764
- expected: negate ? `not ${String(expected)}` : String(expected)
1765
- }),
1766
- expected instanceof RegExp ? {
1767
- kind: "accessibleDescription",
1768
- patternSource: expected.source,
1769
- patternFlags: expected.flags
1770
- } : { kind: "accessibleDescription", expected },
1771
- negate
1772
- ),
1773
- assertFocused: (selector, opts, negate = false) => pollUntilMatch(
1774
- selector,
1775
- opts,
1776
- (el) => ({
1777
- matched: el.focused === true,
1778
- actual: el.focused ? "focused" : "not focused"
1779
- }),
1780
- (actual, timeout) => ({
1781
- message: negate ? `Expected element NOT to be focused but it was "${actual ?? "focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be focused but it was "${actual ?? "not focused"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1782
- expected: negate ? "not focused" : "focused"
1783
- }),
1784
- { kind: "focused" },
1785
- negate
1786
- ),
1787
- assertChecked: (selector, opts, negate = false) => pollUntilMatch(
1788
- selector,
1789
- opts,
1790
- (el) => ({
1791
- matched: el.checked === true || el.attributes?.["aria-checked"] === "true",
1792
- actual: el.checked ? "checked" : "unchecked"
1793
- }),
1794
- (actual, timeout) => ({
1795
- message: negate ? `Expected element NOT to be checked but it was "${actual ?? "checked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be checked but it was "${actual ?? "unchecked"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1796
- expected: negate ? "unchecked" : "checked"
1797
- }),
1798
- { kind: "checked" },
1799
- negate
1800
- ),
1801
- assertEditable: (selector, opts, negate = false) => pollUntilMatch(
1802
- selector,
1803
- opts,
1804
- (el) => ({
1805
- matched: el.editable === true,
1806
- actual: el.editable ? "editable" : "not editable"
1807
- }),
1808
- (actual, timeout) => ({
1809
- message: negate ? `Expected element NOT to be editable but it was "${actual ?? "editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be editable but it was "${actual ?? "not editable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1810
- expected: negate ? "not editable" : "editable"
1811
- }),
1812
- { kind: "editable" },
1813
- negate
1814
- ),
1815
- assertEmpty: (selector, opts, negate = false) => pollUntilMatch(
1816
- selector,
1817
- opts,
1818
- (el) => {
1819
- const isEmpty = el.empty !== void 0 ? el.empty : (el.value ?? el.textContent ?? el.text ?? "").trim().length === 0;
1820
- return {
1821
- matched: isEmpty,
1822
- actual: isEmpty ? "empty" : el.value ?? el.text ?? "non-empty"
1823
- };
1824
- },
1825
- (actual, timeout) => ({
1826
- message: negate ? `Expected element NOT to be empty after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected element to be empty but got "${actual ?? "(non-empty)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1827
- expected: negate ? "non-empty" : "empty"
1828
- }),
1829
- { kind: "empty" },
1830
- negate
1831
- ),
1832
- assertClass: (selector, expected, opts, negate = false) => pollUntilMatch(
1833
- selector,
1834
- opts,
1835
- (el) => {
1836
- const cls = el.className ?? el.attributes?.["class"] ?? "";
1837
- const matched = expected instanceof RegExp ? expected.test(cls) : expected.trim().split(/\s+/).filter(Boolean).every((tok) => cls.trim().split(/\s+/).includes(tok));
1838
- return { matched, actual: cls };
1839
- },
1840
- (actual, timeout) => ({
1841
- message: negate ? `Expected class NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected class ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1842
- expected: negate ? `not ${String(expected)}` : String(expected)
1843
- }),
1844
- expected instanceof RegExp ? { kind: "class", patternSource: expected.source, patternFlags: expected.flags } : { kind: "class", expected },
1845
- negate
1846
- ),
1847
- assertCss: (selector, property, expected, opts, negate = false) => pollUntilMatch(
1848
- selector,
1849
- opts,
1850
- (el) => {
1851
- const actual = el.attributes?.[`style:${property}`] ?? "";
1852
- const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
1853
- return { matched, actual };
1854
- },
1855
- (actual, timeout) => ({
1856
- message: negate ? `Expected CSS "${property}" NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected CSS "${property}" to be ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1857
- expected: negate ? `not ${String(expected)}` : String(expected)
1858
- }),
1859
- expected instanceof RegExp ? {
1860
- kind: "css",
1861
- cssProperty: property,
1862
- patternSource: expected.source,
1863
- patternFlags: expected.flags
1864
- } : { kind: "css", cssProperty: property, expected },
1865
- negate
1866
- ),
1867
- waitForTitle: (expected, opts, negate = false) => Effect4.gen(function* () {
1868
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1869
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1870
- const start = Date.now();
1871
- const deadline = start + timeout;
1872
- let lastTitle = "";
1873
- const matchesTitle = (t) => expected instanceof RegExp ? expected.test(t) : t === expected;
1874
- while (true) {
1875
- const domChannel = driver.domChannel;
1876
- if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
1877
- const remaining = Math.max(50, deadline - Date.now());
1878
- const reactive = yield* Effect4.tryPromise({
1879
- try: () => domChannel.waitForMatch("", {
1880
- kind: "title",
1881
- ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
1882
- ...negate ? { negate: true } : {},
1883
- timeoutMs: remaining
1884
- }),
1885
- catch: () => null
1886
- }).pipe(Effect4.catch(() => Effect4.succeed(null)));
1887
- if (reactive) {
1888
- if (reactive.matched) return;
1889
- if (reactive.actual !== void 0) lastTitle = reactive.actual;
1890
- if (Date.now() >= deadline) break;
1891
- yield* Effect4.sleep(
1892
- Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
1893
- );
1894
- continue;
2094
+ opts,
2095
+ (el) => {
2096
+ const cls = el.className ?? el.attributes?.["class"] ?? "";
2097
+ const matched = expected instanceof RegExp ? expected.test(cls) : expected.trim().split(/\s+/).filter(Boolean).every((tok) => cls.trim().split(/\s+/).includes(tok));
2098
+ return { matched, actual: cls };
2099
+ },
2100
+ (actual, timeout) => ({
2101
+ message: negate ? `Expected class NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected class ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2102
+ expected: negate ? `not ${String(expected)}` : String(expected)
2103
+ }),
2104
+ expected instanceof RegExp ? { kind: "class", patternSource: expected.source, patternFlags: expected.flags } : { kind: "class", expected },
2105
+ negate
2106
+ ),
2107
+ assertCss: (selector, property, expected, opts, negate = false) => pollUntilMatch(
2108
+ selector,
2109
+ opts,
2110
+ (el) => {
2111
+ const actual = el.attributes?.[`style:${property}`] ?? "";
2112
+ const matched = expected instanceof RegExp ? expected.test(actual) : actual.trim() === expected.trim();
2113
+ return { matched, actual };
2114
+ },
2115
+ (actual, timeout) => ({
2116
+ message: negate ? `Expected CSS "${property}" NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected CSS "${property}" to be ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got "${actual ?? ""}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2117
+ expected: negate ? `not ${String(expected)}` : String(expected)
2118
+ }),
2119
+ expected instanceof RegExp ? {
2120
+ kind: "css",
2121
+ cssProperty: property,
2122
+ patternSource: expected.source,
2123
+ patternFlags: expected.flags
2124
+ } : { kind: "css", cssProperty: property, expected },
2125
+ negate
2126
+ ),
2127
+ waitForTitle: (expected, opts, negate = false) => Effect_exports.gen(function* () {
2128
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2129
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2130
+ const start = Date.now();
2131
+ const deadline = start + timeout;
2132
+ let lastTitle = "";
2133
+ const matchesTitle = (t) => expected instanceof RegExp ? expected.test(t) : t === expected;
2134
+ while (true) {
2135
+ const domChannel = driver.domChannel;
2136
+ if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
2137
+ const remaining = Math.max(50, deadline - Date.now());
2138
+ const reactive = yield* Effect_exports.tryPromise({
2139
+ try: () => domChannel.waitForMatch("", {
2140
+ kind: "title",
2141
+ ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
2142
+ ...negate ? { negate: true } : {},
2143
+ timeoutMs: remaining
2144
+ }),
2145
+ catch: () => null
2146
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
2147
+ if (reactive) {
2148
+ if (reactive.matched) return;
2149
+ if (reactive.actual !== void 0) lastTitle = reactive.actual;
2150
+ if (Date.now() >= deadline) break;
2151
+ yield* Effect_exports.sleep(
2152
+ Duration_exports.millis(Math.min(30, Math.max(10, deadline - Date.now())))
2153
+ );
2154
+ continue;
2155
+ }
1895
2156
  }
1896
- }
1897
- const title = yield* driver.evaluate("typeof document !== 'undefined' ? String(document.title || '') : ''").pipe(Effect4.catch(() => Effect4.succeed("")));
1898
- lastTitle = title;
1899
- if (negate ? !matchesTitle(title) : matchesTitle(title)) return;
1900
- if (Date.now() >= deadline) break;
1901
- yield* Effect4.sleep(
1902
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1903
- );
1904
- }
1905
- return yield* new TextMismatchError({
1906
- message: negate ? `Expected title NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms` : `Expected title ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms`,
1907
- expected: negate ? `not ${String(expected)}` : String(expected),
1908
- actual: lastTitle,
1909
- selector: "title"
1910
- });
1911
- }),
1912
- assertCount: (selector, expectedCount, opts, negate = false) => Effect4.gen(function* () {
1913
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1914
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 200;
1915
- const visibleOnly = Boolean(opts?.visible);
1916
- const start = Date.now();
1917
- const deadline = start + timeout;
1918
- let lastCount = -1;
1919
- let lastActualStr;
1920
- while (true) {
1921
- const domChannel = driver.domChannel;
1922
- if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
1923
- const remaining = Math.max(50, deadline - Date.now());
1924
- const reactive = yield* Effect4.tryPromise({
1925
- try: () => domChannel.waitForMatch(selector, {
1926
- kind: "count",
1927
- expectedCount,
1928
- ...visibleOnly ? { visibleOnly: true } : {},
1929
- ...negate ? { negate: true } : {},
1930
- timeoutMs: remaining
1931
- }),
1932
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1933
- }).pipe(
1934
- Effect4.catch(
1935
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1936
- )
2157
+ const title = yield* driver.evaluate(
2158
+ "typeof document !== 'undefined' ? String(document.title || '') : ''"
2159
+ ).pipe(Effect_exports.catch(() => Effect_exports.succeed("")));
2160
+ lastTitle = title;
2161
+ if (negate ? !matchesTitle(title) : matchesTitle(title)) return;
2162
+ if (Date.now() >= deadline) break;
2163
+ yield* Effect_exports.sleep(
2164
+ Duration_exports.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1937
2165
  );
1938
- if (reactive) {
1939
- if (reactive.matched) return;
1940
- if (reactive.actual !== void 0) lastActualStr = reactive.actual;
1941
- if (Date.now() >= deadline) break;
1942
- yield* Effect4.sleep(
1943
- Duration2.millis(Math.min(30, Math.max(10, deadline - Date.now())))
2166
+ }
2167
+ return yield* new TextMismatchError({
2168
+ message: negate ? `Expected title NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms` : `Expected title ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastTitle)} after ${timeout}ms`,
2169
+ expected: negate ? `not ${String(expected)}` : String(expected),
2170
+ actual: lastTitle,
2171
+ selector: "title"
2172
+ });
2173
+ }),
2174
+ assertCount: (selector, expectedCount, opts, negate = false) => Effect_exports.gen(function* () {
2175
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2176
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 200;
2177
+ const visibleOnly = Boolean(opts?.visible);
2178
+ const start = Date.now();
2179
+ const deadline = start + timeout;
2180
+ let lastCount = -1;
2181
+ let lastActualStr;
2182
+ while (true) {
2183
+ const domChannel = driver.domChannel;
2184
+ if ((config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.waitForMatch) {
2185
+ const remaining = Math.max(50, deadline - Date.now());
2186
+ const reactive = yield* Effect_exports.tryPromise({
2187
+ try: () => domChannel.waitForMatch(selector, {
2188
+ kind: "count",
2189
+ expectedCount,
2190
+ ...visibleOnly ? { visibleOnly: true } : {},
2191
+ ...negate ? { negate: true } : {},
2192
+ timeoutMs: remaining
2193
+ }),
2194
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
2195
+ }).pipe(
2196
+ Effect_exports.catch(
2197
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
2198
+ )
1944
2199
  );
1945
- continue;
2200
+ if (reactive) {
2201
+ if (reactive.matched) return;
2202
+ if (reactive.actual !== void 0) lastActualStr = reactive.actual;
2203
+ if (Date.now() >= deadline) break;
2204
+ yield* Effect_exports.sleep(
2205
+ Duration_exports.millis(Math.min(30, Math.max(10, deadline - Date.now())))
2206
+ );
2207
+ continue;
2208
+ }
1946
2209
  }
1947
- }
1948
- cache.invalidate();
1949
- if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
1950
- const matches = yield* Effect4.tryPromise({
1951
- try: () => domChannel.query(selector),
1952
- catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
1953
- }).pipe(
1954
- Effect4.catch(
1955
- (err) => err instanceof DriverError ? Effect4.fail(err) : Effect4.succeed(null)
1956
- )
1957
- );
1958
- if (matches) {
1959
- const count2 = visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
1960
- lastCount = count2;
1961
- lastActualStr = String(count2);
1962
- if (negate ? count2 !== expectedCount : count2 === expectedCount) return;
1963
- if (Date.now() >= deadline) break;
1964
- yield* Effect4.sleep(
1965
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2210
+ cache.invalidate();
2211
+ if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected()) {
2212
+ const matches = yield* Effect_exports.tryPromise({
2213
+ try: () => domChannel.query(selector),
2214
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
2215
+ }).pipe(
2216
+ Effect_exports.catch(
2217
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
2218
+ )
1966
2219
  );
1967
- continue;
2220
+ if (matches) {
2221
+ const count2 = visibleOnly ? matches.filter((m) => m.visible).length : matches.length;
2222
+ lastCount = count2;
2223
+ lastActualStr = String(count2);
2224
+ if (negate ? count2 !== expectedCount : count2 === expectedCount) return;
2225
+ if (Date.now() >= deadline) break;
2226
+ yield* Effect_exports.sleep(
2227
+ Duration_exports.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2228
+ );
2229
+ continue;
2230
+ }
1968
2231
  }
2232
+ const raw = yield* driver.dumpHierarchy();
2233
+ const root = parse(raw);
2234
+ const matched = findElements(root, selector);
2235
+ const count = visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
2236
+ lastCount = count;
2237
+ lastActualStr = String(count);
2238
+ if (negate ? count !== expectedCount : count === expectedCount) return;
2239
+ if (Date.now() >= deadline) break;
2240
+ yield* Effect_exports.sleep(
2241
+ Duration_exports.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2242
+ );
1969
2243
  }
1970
- const raw = yield* driver.dumpHierarchy();
1971
- const root = parse(raw);
1972
- const matched = findElements(root, selector);
1973
- const count = visibleOnly ? matched.filter((el) => el.visible !== false).length : matched.length;
1974
- lastCount = count;
1975
- lastActualStr = String(count);
1976
- if (negate ? count !== expectedCount : count === expectedCount) return;
1977
- if (Date.now() >= deadline) break;
1978
- yield* Effect4.sleep(
1979
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
1980
- );
1981
- }
1982
- const finalActual = lastActualStr ?? String(lastCount >= 0 ? lastCount : 0);
1983
- return yield* new TextMismatchError({
1984
- message: negate ? `Expected count NOT to be ${expectedCount} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected count ${expectedCount} but got ${finalActual} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
1985
- expected: negate ? `not ${expectedCount}` : String(expectedCount),
1986
- actual: finalActual,
1987
- selector
1988
- });
1989
- }),
1990
- waitForURL: (expected, opts, negate = false) => Effect4.gen(function* () {
1991
- const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
1992
- const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
1993
- const start = Date.now();
1994
- const deadline = start + timeout;
1995
- let lastUrl = "";
1996
- const matchesUrl = (url) => expected instanceof RegExp ? expected.test(url) : url === expected || url.includes(expected);
1997
- const initialNavUrls = driver.getNavigationUrls ? driver.getNavigationUrls() : [];
1998
- const navMark = initialNavUrls.length;
1999
- const lastPreMarkUrl = navMark > 0 ? initialNavUrls[navMark - 1] : void 0;
2000
- const checkRecentNavUrls = () => {
2001
- if (negate || !driver.getNavigationUrls) return false;
2002
- const all = driver.getNavigationUrls();
2003
- const sinceMark = all.slice(Math.min(navMark, all.length));
2004
- if (sinceMark.some((u) => matchesUrl(u))) return true;
2005
- if (lastPreMarkUrl && matchesUrl(lastPreMarkUrl)) return true;
2006
- return false;
2007
- };
2008
- const readCurrentUrl = () => driver.getUrl ? driver.getUrl().pipe(Effect4.catch(() => Effect4.succeed(""))) : driver.evaluate(
2009
- "typeof window !== 'undefined' && window.location ? window.location.href : ''"
2010
- ).pipe(Effect4.catch(() => Effect4.succeed("")));
2011
- const initialUrl = yield* readCurrentUrl();
2012
- lastUrl = initialUrl;
2013
- if (negate ? !matchesUrl(initialUrl) : matchesUrl(initialUrl) || checkRecentNavUrls()) {
2014
- return;
2015
- }
2016
- while (Date.now() < deadline) {
2017
- if (checkRecentNavUrls()) return;
2018
- const domChannel = driver.domChannel;
2019
- if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
2020
- const remaining = Math.max(50, deadline - Date.now());
2021
- const reactive = yield* Effect4.tryPromise({
2022
- try: () => domChannel.waitForMatch("", {
2023
- kind: "url",
2024
- ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
2025
- ...negate ? { negate: true } : {},
2026
- timeoutMs: Math.min(remaining, 300)
2027
- }),
2028
- catch: () => null
2029
- }).pipe(Effect4.catch(() => Effect4.succeed(null)));
2030
- if (reactive?.matched) return;
2031
- if (reactive?.actual) lastUrl = reactive.actual;
2244
+ const finalActual = lastActualStr ?? String(lastCount >= 0 ? lastCount : 0);
2245
+ return yield* new TextMismatchError({
2246
+ message: negate ? `Expected count NOT to be ${expectedCount} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected count ${expectedCount} but got ${finalActual} after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2247
+ expected: negate ? `not ${expectedCount}` : String(expectedCount),
2248
+ actual: finalActual,
2249
+ selector
2250
+ });
2251
+ }),
2252
+ waitForURL: (expected, opts, negate = false) => Effect_exports.gen(function* () {
2253
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2254
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2255
+ const start = Date.now();
2256
+ const deadline = start + timeout;
2257
+ let lastUrl = "";
2258
+ const matchesUrl = (url) => expected instanceof RegExp ? expected.test(url) : url === expected || url.includes(expected);
2259
+ const initialNavUrls = driver.getNavigationUrls ? driver.getNavigationUrls() : [];
2260
+ const navMark = initialNavUrls.length;
2261
+ const lastPreMarkUrl = navMark > 0 ? initialNavUrls[navMark - 1] : void 0;
2262
+ const checkRecentNavUrls = () => {
2263
+ if (negate || !driver.getNavigationUrls) return false;
2264
+ const all = driver.getNavigationUrls();
2265
+ const sinceMark = all.slice(Math.min(navMark, all.length));
2266
+ if (sinceMark.some((u) => matchesUrl(u))) return true;
2267
+ if (lastPreMarkUrl && matchesUrl(lastPreMarkUrl)) return true;
2268
+ return false;
2269
+ };
2270
+ const readCurrentUrl = () => driver.getUrl ? driver.getUrl().pipe(Effect_exports.catch(() => Effect_exports.succeed(""))) : driver.evaluate(
2271
+ "typeof window !== 'undefined' && window.location ? window.location.href : ''"
2272
+ ).pipe(Effect_exports.catch(() => Effect_exports.succeed("")));
2273
+ const initialUrl = yield* readCurrentUrl();
2274
+ lastUrl = initialUrl;
2275
+ if (negate ? !matchesUrl(initialUrl) : matchesUrl(initialUrl) || checkRecentNavUrls()) {
2276
+ return;
2277
+ }
2278
+ while (Date.now() < deadline) {
2032
2279
  if (checkRecentNavUrls()) return;
2280
+ const domChannel = driver.domChannel;
2281
+ if ((config.platform === "web" || !config.platform) && domChannel?.isConnected() && domChannel.waitForMatch) {
2282
+ const remaining = Math.max(50, deadline - Date.now());
2283
+ const reactive = yield* Effect_exports.tryPromise({
2284
+ try: () => domChannel.waitForMatch("", {
2285
+ kind: "url",
2286
+ ...expected instanceof RegExp ? { patternSource: expected.source, patternFlags: expected.flags } : { expected },
2287
+ ...negate ? { negate: true } : {},
2288
+ timeoutMs: Math.min(remaining, 300)
2289
+ }),
2290
+ catch: () => null
2291
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
2292
+ if (reactive?.matched) return;
2293
+ if (reactive?.actual) lastUrl = reactive.actual;
2294
+ if (checkRecentNavUrls()) return;
2295
+ }
2296
+ const url = yield* readCurrentUrl();
2297
+ if (url) lastUrl = url;
2298
+ if (negate ? !matchesUrl(url) : matchesUrl(url) || checkRecentNavUrls()) return;
2299
+ if (Date.now() >= deadline) break;
2300
+ yield* Effect_exports.sleep(
2301
+ Duration_exports.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2302
+ );
2033
2303
  }
2034
- const url = yield* readCurrentUrl();
2035
- if (url) lastUrl = url;
2036
- if (negate ? !matchesUrl(url) : matchesUrl(url) || checkRecentNavUrls()) return;
2037
- if (Date.now() >= deadline) break;
2038
- yield* Effect4.sleep(
2039
- Duration2.millis(Math.min(pollInterval, Math.max(10, deadline - Date.now())))
2304
+ return yield* new TextMismatchError({
2305
+ message: negate ? `Expected URL NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms` : `Expected URL ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms`,
2306
+ expected: negate ? `not ${String(expected)}` : String(expected),
2307
+ actual: lastUrl,
2308
+ selector: "url"
2309
+ });
2310
+ }),
2311
+ assertFocusable: (selector, platform, opts) => Effect_exports.gen(function* () {
2312
+ const { isFocusable } = yield* Effect_exports.promise(
2313
+ () => import("./accessibility-audit-IWTD2HPR.js")
2040
2314
  );
2041
- }
2042
- return yield* new TextMismatchError({
2043
- message: negate ? `Expected URL NOT to match ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms` : `Expected URL ${expected instanceof RegExp ? String(expected) : JSON.stringify(expected)} but got ${JSON.stringify(lastUrl)} after ${timeout}ms`,
2044
- expected: negate ? `not ${String(expected)}` : String(expected),
2045
- actual: lastUrl,
2046
- selector: "url"
2047
- });
2048
- }),
2049
- assertFocusable: (selector, platform, opts) => Effect4.gen(function* () {
2050
- const { isFocusable } = yield* Effect4.promise(
2051
- () => import("./accessibility-audit-F5KLUHLS.js")
2052
- );
2053
- yield* pollUntilMatch(
2315
+ yield* pollUntilMatch(
2316
+ selector,
2317
+ opts,
2318
+ (el) => {
2319
+ const focusable = isFocusable(el, {
2320
+ platform
2321
+ });
2322
+ return { matched: focusable, actual: focusable ? "focusable" : "not focusable" };
2323
+ },
2324
+ (actual, timeout) => ({
2325
+ message: `Expected element to be focusable but it was "${actual ?? "not focusable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2326
+ expected: "focusable"
2327
+ })
2328
+ );
2329
+ }),
2330
+ assertRole: (selector, expectedRole, platform, opts, negate = false) => Effect_exports.gen(function* () {
2331
+ const { normalizeRole } = yield* Effect_exports.promise(
2332
+ () => import("./accessibility-audit-IWTD2HPR.js")
2333
+ );
2334
+ yield* pollUntilMatch(
2335
+ selector,
2336
+ opts,
2337
+ (el) => {
2338
+ const actual = el.role ?? normalizeRole(
2339
+ platform,
2340
+ el.elementType ?? "",
2341
+ el.attributes ?? {}
2342
+ );
2343
+ return { matched: actual === expectedRole, actual };
2344
+ },
2345
+ (actual, timeout) => ({
2346
+ message: negate ? `Expected role NOT to be "${expectedRole}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected role "${expectedRole}" but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2347
+ expected: negate ? `not ${expectedRole}` : expectedRole
2348
+ }),
2349
+ { kind: "role", expected: expectedRole },
2350
+ negate
2351
+ );
2352
+ }),
2353
+ assertMinTouchTarget: (selector, minSize, opts) => pollUntilMatch(
2054
2354
  selector,
2055
2355
  opts,
2056
2356
  (el) => {
2057
- const focusable = isFocusable(el, {
2058
- platform
2059
- });
2060
- return { matched: focusable, actual: focusable ? "focusable" : "not focusable" };
2357
+ const { width, height } = el.bounds;
2358
+ const passed = width >= minSize && height >= minSize;
2359
+ const actual = `${width}x${height}`;
2360
+ return { matched: passed, actual };
2061
2361
  },
2062
2362
  (actual, timeout) => ({
2063
- message: `Expected element to be focusable but it was "${actual ?? "not focusable"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2064
- expected: "focusable"
2363
+ message: `Expected touch target to be at least ${minSize}x${minSize}px but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2364
+ expected: `${minSize}x${minSize}`
2065
2365
  })
2066
- );
2067
- }),
2068
- assertRole: (selector, expectedRole, platform, opts, negate = false) => Effect4.gen(function* () {
2069
- const { normalizeRole } = yield* Effect4.promise(
2070
- () => import("./accessibility-audit-F5KLUHLS.js")
2071
- );
2072
- yield* pollUntilMatch(
2073
- selector,
2074
- opts,
2075
- (el) => {
2076
- const actual = el.role ?? normalizeRole(
2077
- platform,
2078
- el.elementType ?? "",
2079
- el.attributes ?? {}
2080
- );
2081
- return { matched: actual === expectedRole, actual };
2082
- },
2083
- (actual, timeout) => ({
2084
- message: negate ? `Expected role NOT to be "${expectedRole}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}` : `Expected role "${expectedRole}" but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2085
- expected: negate ? `not ${expectedRole}` : expectedRole
2086
- }),
2087
- { kind: "role", expected: expectedRole },
2088
- negate
2089
- );
2090
- }),
2091
- assertMinTouchTarget: (selector, minSize, opts) => pollUntilMatch(
2092
- selector,
2093
- opts,
2094
- (el) => {
2095
- const { width, height } = el.bounds;
2096
- const passed = width >= minSize && height >= minSize;
2097
- const actual = `${width}x${height}`;
2098
- return { matched: passed, actual };
2099
- },
2100
- (actual, timeout) => ({
2101
- message: `Expected touch target to be at least ${minSize}x${minSize}px but got "${actual ?? "(unknown)"}" after ${timeout}ms \u2014 selector: ${formatSelector(selector)}`,
2102
- expected: `${minSize}x${minSize}`
2366
+ ),
2367
+ runAccessibilityAudit: (platform, options = {}) => Effect_exports.gen(function* () {
2368
+ if (platform !== "web") {
2369
+ return yield* new DriverError({
2370
+ message: `accessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2371
+ });
2372
+ }
2373
+ const axeContext = {};
2374
+ const includes = [
2375
+ ...options.targetSelector ? [options.targetSelector] : [],
2376
+ ...options.includeSelectors ?? []
2377
+ ];
2378
+ if (includes.length > 0) {
2379
+ axeContext["include"] = includes.map((s) => [s]);
2380
+ }
2381
+ if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2382
+ axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2383
+ }
2384
+ const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2385
+ const axeOptions = {};
2386
+ const rulesConfig = {};
2387
+ for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2388
+ for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2389
+ if (Object.keys(rulesConfig).length > 0) {
2390
+ axeOptions["rules"] = rulesConfig;
2391
+ }
2392
+ if (options.tags && options.tags.length > 0) {
2393
+ axeOptions["runOnly"] = { type: "tag", values: options.tags };
2394
+ }
2395
+ const runExpr = `axe.run(${serializedContext}, ${JSON.stringify(axeOptions)})`;
2396
+ let rawResult;
2397
+ if (hasInjectedAxe) {
2398
+ const fastScript = `(function() { if (typeof axe === "undefined") return { __spanaNeedAxe: true }; return ${runExpr}; })()`;
2399
+ rawResult = yield* driver.evaluate(fastScript);
2400
+ } else {
2401
+ rawResult = { __spanaNeedAxe: true };
2402
+ }
2403
+ if (rawResult && typeof rawResult === "object" && "__spanaNeedAxe" in rawResult) {
2404
+ const axeSource = yield* Effect_exports.promise(() => loadCachedAxeSource());
2405
+ const injectAndRunScript = `(function() { if (typeof axe === "undefined") { ${axeSource} } return ${runExpr}; })()`;
2406
+ rawResult = yield* driver.evaluate(injectAndRunScript);
2407
+ hasInjectedAxe = true;
2408
+ }
2409
+ const axeResult = rawResult;
2410
+ const violations = (axeResult?.violations ?? []).map((v) => ({
2411
+ ruleId: v.id,
2412
+ severity: v.impact ?? "minor",
2413
+ description: v.description,
2414
+ helpUrl: v.helpUrl,
2415
+ wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2416
+ elements: v.nodes.map((n) => ({
2417
+ selector: n.target.join(", "),
2418
+ html: n.html,
2419
+ failureSummary: n.failureSummary
2420
+ }))
2421
+ }));
2422
+ return { violations };
2423
+ }),
2424
+ assertAccessibilityAudit: (platform, options = {}) => Effect_exports.gen(function* () {
2425
+ if (platform !== "web") {
2426
+ return yield* new DriverError({
2427
+ message: `assertAccessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2428
+ });
2429
+ }
2430
+ const axeContext = {};
2431
+ const includes = [
2432
+ ...options.targetSelector ? [options.targetSelector] : [],
2433
+ ...options.includeSelectors ?? []
2434
+ ];
2435
+ if (includes.length > 0) {
2436
+ axeContext["include"] = includes.map((s) => [s]);
2437
+ }
2438
+ if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2439
+ axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2440
+ }
2441
+ const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2442
+ const axeOptions = {};
2443
+ const rulesConfig = {};
2444
+ for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2445
+ for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2446
+ if (Object.keys(rulesConfig).length > 0) {
2447
+ axeOptions["rules"] = rulesConfig;
2448
+ }
2449
+ if (options.tags && options.tags.length > 0) {
2450
+ axeOptions["runOnly"] = { type: "tag", values: options.tags };
2451
+ }
2452
+ const runExpr = `axe.run(${serializedContext}, ${JSON.stringify(axeOptions)})`;
2453
+ let rawResult;
2454
+ if (hasInjectedAxe) {
2455
+ const fastScript = `(function() { if (typeof axe === "undefined") return { __spanaNeedAxe: true }; return ${runExpr}; })()`;
2456
+ rawResult = yield* driver.evaluate(fastScript);
2457
+ } else {
2458
+ rawResult = { __spanaNeedAxe: true };
2459
+ }
2460
+ if (rawResult && typeof rawResult === "object" && "__spanaNeedAxe" in rawResult) {
2461
+ const axeSource = yield* Effect_exports.promise(() => loadCachedAxeSource());
2462
+ const injectAndRunScript = `(function() { if (typeof axe === "undefined") { ${axeSource} } return ${runExpr}; })()`;
2463
+ rawResult = yield* driver.evaluate(injectAndRunScript);
2464
+ hasInjectedAxe = true;
2465
+ }
2466
+ const axeResult = rawResult;
2467
+ const violations = (axeResult?.violations ?? []).map((v) => ({
2468
+ ruleId: v.id,
2469
+ severity: v.impact ?? "minor",
2470
+ description: v.description,
2471
+ helpUrl: v.helpUrl,
2472
+ wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2473
+ elements: v.nodes.map((n) => ({
2474
+ selector: n.target.join(", "),
2475
+ html: n.html,
2476
+ failureSummary: n.failureSummary
2477
+ }))
2478
+ }));
2479
+ const minSeverity = options.severity ?? "serious";
2480
+ const filtered = filterViolations(violations, minSeverity);
2481
+ if (filtered.length > 0) {
2482
+ const summary = formatViolationSummary(filtered);
2483
+ return yield* new DriverError({ message: summary });
2484
+ }
2103
2485
  })
2104
- ),
2105
- runAccessibilityAudit: (platform, options = {}) => Effect4.gen(function* () {
2106
- if (platform !== "web") {
2107
- return yield* new DriverError({
2108
- message: `accessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2109
- });
2110
- }
2111
- const axeContext = {};
2112
- const includes = [
2113
- ...options.targetSelector ? [options.targetSelector] : [],
2114
- ...options.includeSelectors ?? []
2115
- ];
2116
- if (includes.length > 0) {
2117
- axeContext["include"] = includes.map((s) => [s]);
2118
- }
2119
- if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2120
- axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2121
- }
2122
- const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2123
- const axeOptions = {};
2124
- const rulesConfig = {};
2125
- for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2126
- for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2127
- if (Object.keys(rulesConfig).length > 0) {
2128
- axeOptions["rules"] = rulesConfig;
2129
- }
2130
- if (options.tags && options.tags.length > 0) {
2131
- axeOptions["runOnly"] = { type: "tag", values: options.tags };
2132
- }
2133
- const runExpr = `axe.run(${serializedContext}, ${JSON.stringify(axeOptions)})`;
2134
- const fastScript = `(function() { if (typeof axe === "undefined") return { __spanaNeedAxe: true }; return ${runExpr}; })()`;
2135
- let rawResult = yield* driver.evaluate(fastScript);
2136
- if (rawResult && typeof rawResult === "object" && "__spanaNeedAxe" in rawResult) {
2137
- const axeSource = yield* Effect4.promise(() => loadCachedAxeSource());
2138
- const injectAndRunScript = `(function() { if (typeof axe === "undefined") { ${axeSource} } return ${runExpr}; })()`;
2139
- rawResult = yield* driver.evaluate(injectAndRunScript);
2140
- }
2141
- const axeResult = rawResult;
2142
- const violations = (axeResult?.violations ?? []).map((v) => ({
2143
- ruleId: v.id,
2144
- severity: v.impact ?? "minor",
2145
- description: v.description,
2146
- helpUrl: v.helpUrl,
2147
- wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2148
- elements: v.nodes.map((n) => ({
2149
- selector: n.target.join(", "),
2150
- html: n.html,
2151
- failureSummary: n.failureSummary
2152
- }))
2153
- }));
2154
- return { violations };
2155
- }),
2156
- assertAccessibilityAudit: (platform, options = {}) => Effect4.gen(function* () {
2157
- if (platform !== "web") {
2158
- return yield* new DriverError({
2159
- message: `assertAccessibilityAudit() is only supported on web \u2014 platform "${platform}" is not supported`
2160
- });
2161
- }
2162
- const { readFileSync: readFileSync2 } = yield* Effect4.promise(() => import("fs"));
2163
- const { createRequire } = yield* Effect4.promise(() => import("module"));
2164
- const require2 = createRequire(import.meta.url);
2165
- const axePath = require2.resolve("axe-core/axe.js");
2166
- const axeSource = readFileSync2(axePath, "utf-8");
2167
- const { filterViolations, formatViolationSummary } = yield* Effect4.promise(
2168
- () => import("./accessibility-audit-F5KLUHLS.js")
2169
- );
2170
- const axeContext = {};
2171
- const includes = [
2172
- ...options.targetSelector ? [options.targetSelector] : [],
2173
- ...options.includeSelectors ?? []
2174
- ];
2175
- if (includes.length > 0) {
2176
- axeContext["include"] = includes.map((s) => [s]);
2177
- }
2178
- if (options.excludeSelectors && options.excludeSelectors.length > 0) {
2179
- axeContext["exclude"] = options.excludeSelectors.map((s) => [s]);
2180
- }
2181
- const serializedContext = Object.keys(axeContext).length > 0 ? JSON.stringify(axeContext) : "document";
2182
- const axeOptions = {};
2183
- const rulesConfig = {};
2184
- for (const r of options.rules ?? []) rulesConfig[r] = { enabled: true };
2185
- for (const r of options.disableRules ?? []) rulesConfig[r] = { enabled: false };
2186
- if (Object.keys(rulesConfig).length > 0) {
2187
- axeOptions["rules"] = rulesConfig;
2188
- }
2189
- if (options.tags && options.tags.length > 0) {
2190
- axeOptions["runOnly"] = { type: "tag", values: options.tags };
2191
- }
2192
- const script = `
2193
- (function() {
2194
- if (typeof axe === "undefined") {
2195
- ${axeSource}
2196
- }
2197
- return axe.run(${serializedContext}, ${JSON.stringify(axeOptions)});
2198
- })()
2199
- `;
2200
- const axeResult = yield* driver.evaluate(script);
2201
- const violations = (axeResult?.violations ?? []).map((v) => ({
2202
- ruleId: v.id,
2203
- severity: v.impact ?? "minor",
2204
- description: v.description,
2205
- helpUrl: v.helpUrl,
2206
- wcagCriteria: v.tags.filter((t) => t.startsWith("wcag")),
2207
- elements: v.nodes.map((n) => ({
2208
- selector: n.target.join(", "),
2209
- html: n.html,
2210
- failureSummary: n.failureSummary
2211
- }))
2212
- }));
2213
- const minSeverity = options.severity ?? "serious";
2214
- const filtered = filterViolations(violations, minSeverity);
2215
- if (filtered.length > 0) {
2216
- const summary = formatViolationSummary(filtered);
2217
- return yield* new DriverError({ message: summary });
2218
- }
2219
- })
2220
- });
2486
+ };
2487
+ };
2221
2488
  const assertions = createAssertions();
2222
- const runGuardedPointerAction = (selector, opts, actionLabel, performPointer, options) => Effect4.gen(function* () {
2489
+ const runGuardedPointerAction = (selector, opts, actionLabel, performPointer, options) => Effect_exports.gen(function* () {
2223
2490
  const effectiveTapMode = opts?.tapMode ?? config.tapMode ?? "native";
2224
2491
  const totalTimeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2225
2492
  const deadline = Date.now() + totalTimeout;
@@ -2248,15 +2515,15 @@ function createCoordinator(driver, config) {
2248
2515
  );
2249
2516
  if (options?.shouldSkip?.(resolved.element)) {
2250
2517
  if (canInlineTapGuard && driver.domChannel?.checkTapGuard) {
2251
- yield* Effect4.tryPromise({
2518
+ yield* Effect_exports.tryPromise({
2252
2519
  try: () => driver.domChannel.checkTapGuard(),
2253
2520
  catch: () => false
2254
- }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2521
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2255
2522
  }
2256
2523
  return false;
2257
2524
  }
2258
2525
  if (options?.allowDomTap && resolved.channel === "dom" && effectiveTapMode === "dom" && driver.domChannel) {
2259
- const tapped = yield* Effect4.tryPromise({
2526
+ const tapped = yield* Effect_exports.tryPromise({
2260
2527
  try: () => driver.domChannel.tapDom(selector),
2261
2528
  catch: (e) => new DriverError({ message: `DOM tap failed: ${e}` })
2262
2529
  });
@@ -2265,17 +2532,17 @@ function createCoordinator(driver, config) {
2265
2532
  return true;
2266
2533
  }
2267
2534
  }
2268
- const { x, y } = centerOf(resolved.element);
2269
- const guardActive = !opts?.force && resolved.channel === "dom" && !isRelativeSelectorLike2(selector) && !isSystemUISelector(selector) && !(typeof selector === "object" && selector !== null && "frame" in selector && selector.frame) && driver.domChannel?.isConnected();
2535
+ const { x, y } = resolved.domMatch?.clickPoint && (!resolved.webViewFrame || resolved.webViewFrame.x === 0 && resolved.webViewFrame.y === 0 && config.platform !== "ios" && config.platform !== "android") ? resolved.domMatch.clickPoint : centerOf(resolved.element);
2536
+ const guardActive = !opts?.force && resolved.channel === "dom" && !isSystemUISelector(selector) && driver.domChannel?.isConnected();
2270
2537
  if (guardActive && canInlineTapGuard) {
2271
2538
  yield* performPointer(x, y, resolved);
2272
- const missed = yield* Effect4.tryPromise({
2539
+ const missed = yield* Effect_exports.tryPromise({
2273
2540
  try: () => driver.domChannel.checkTapGuard(),
2274
2541
  catch: () => false
2275
- }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2542
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2276
2543
  if (missed) {
2277
2544
  if (Date.now() < deadline && attempts < 20) {
2278
- yield* Effect4.sleep(Duration2.millis(25));
2545
+ yield* Effect_exports.sleep(Duration_exports.millis(25));
2279
2546
  continue;
2280
2547
  }
2281
2548
  return yield* new DriverError({
@@ -2283,12 +2550,24 @@ function createCoordinator(driver, config) {
2283
2550
  });
2284
2551
  }
2285
2552
  } else if (guardActive) {
2286
- const armed = yield* Effect4.tryPromise({
2287
- try: () => driver.domChannel.evaluate(
2288
- `((tx, ty) => {
2553
+ const isRel = isRelativeSelectorLike2(selector);
2554
+ const armScript = !isRel ? buildDomArmTapGuardBySelectorScript(selector) : `((tx, ty, expectedId, expectedTag, expectedText) => {
2289
2555
  try {
2290
- const expected = document.elementFromPoint(tx, ty);
2291
- if (!expected) return false;
2556
+ const hit = document.elementFromPoint(tx, ty);
2557
+ if (!hit) return false;
2558
+ let expected = hit;
2559
+ if (expectedId) {
2560
+ const byId = hit.closest ? hit.closest('[data-testid="' + expectedId.replace(/"/g, '\\\\"') + '"], [id="' + expectedId.replace(/"/g, '\\\\"') + '"]') : null;
2561
+ if (!byId) return false;
2562
+ expected = byId;
2563
+ } else if (expectedTag) {
2564
+ const byTag = hit.closest ? hit.closest(expectedTag) : null;
2565
+ if (byTag) expected = byTag;
2566
+ }
2567
+ if (expectedText) {
2568
+ const actualText = (expected.innerText || expected.textContent || "").trim().replace(/\\s+/g, " ");
2569
+ if (actualText && actualText !== expectedText && actualText.indexOf(expectedText) === -1) return false;
2570
+ }
2292
2571
  if (window.__spanaTapGuardCleanup) window.__spanaTapGuardCleanup();
2293
2572
  window.__spanaTapMissed = false;
2294
2573
  const match = (t) => {
@@ -2299,30 +2578,41 @@ function createCoordinator(driver, config) {
2299
2578
  if (expected.tagName === "LABEL" && expected.control && (t === expected.control || (expected.control.contains && expected.control.contains(t)))) return true;
2300
2579
  return false;
2301
2580
  };
2581
+ const cleanup = () => {
2582
+ window.removeEventListener("pointerdown", onEvt, true);
2583
+ window.removeEventListener("mousedown", onEvt, true);
2584
+ window.removeEventListener("mouseup", onMouseUp, true);
2585
+ window.removeEventListener("click", onEvt, true);
2586
+ if (window.__spanaTapGuardCleanup === cleanup) delete window.__spanaTapGuardCleanup;
2587
+ };
2588
+ const onMouseUp = (e) => {
2589
+ if (!e.isTrusted) return;
2590
+ Promise.resolve().then(cleanup);
2591
+ };
2302
2592
  const onEvt = (e) => {
2303
2593
  if (!e.isTrusted) return;
2304
- const hit = document.elementFromPoint(e.clientX, e.clientY) || e.target;
2305
- if (!match(hit) && !match(e.target)) {
2594
+ const curHit = document.elementFromPoint(e.clientX, e.clientY) || e.target;
2595
+ if (!match(curHit) && !match(e.target)) {
2306
2596
  e.stopImmediatePropagation();
2307
2597
  e.preventDefault();
2308
2598
  window.__spanaTapMissed = true;
2599
+ if (e.type === "click") cleanup();
2600
+ } else if (e.type === "click") {
2601
+ cleanup();
2309
2602
  }
2310
2603
  };
2311
2604
  window.addEventListener("pointerdown", onEvt, true);
2312
2605
  window.addEventListener("mousedown", onEvt, true);
2606
+ window.addEventListener("mouseup", onMouseUp, true);
2313
2607
  window.addEventListener("click", onEvt, true);
2314
- window.__spanaTapGuardCleanup = () => {
2315
- window.removeEventListener("pointerdown", onEvt, true);
2316
- window.removeEventListener("mousedown", onEvt, true);
2317
- window.removeEventListener("click", onEvt, true);
2318
- delete window.__spanaTapGuardCleanup;
2319
- };
2608
+ window.__spanaTapGuardCleanup = cleanup;
2320
2609
  return true;
2321
2610
  } catch { return false; }
2322
- })(${x}, ${y})`
2323
- ),
2611
+ })(${x}, ${y}, ${JSON.stringify(resolved.domMatch?.id ?? resolved.element.id ?? null)}, ${JSON.stringify(resolved.domMatch?.tag ?? null)}, ${JSON.stringify(resolved.domMatch?.text ?? resolved.element.text ?? null)})`;
2612
+ const armed = yield* Effect_exports.tryPromise({
2613
+ try: () => driver.domChannel.evaluate(armScript),
2324
2614
  catch: () => false
2325
- }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2615
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2326
2616
  yield* performPointer(x, y, resolved);
2327
2617
  if (armed) {
2328
2618
  const fastEval = driver.domChannel.evaluateFast;
@@ -2332,13 +2622,13 @@ function createCoordinator(driver, config) {
2332
2622
  delete window.__spanaTapMissed;
2333
2623
  return m;
2334
2624
  })()`;
2335
- const missed = yield* Effect4.tryPromise({
2625
+ const missed = yield* Effect_exports.tryPromise({
2336
2626
  try: () => fastEval ? fastEval.call(driver.domChannel, checkScript) : driver.domChannel.evaluate(checkScript),
2337
2627
  catch: () => false
2338
- }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2628
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2339
2629
  if (missed) {
2340
2630
  if (Date.now() < deadline && attempts < 20) {
2341
- yield* Effect4.sleep(Duration2.millis(25));
2631
+ yield* Effect_exports.sleep(Duration_exports.millis(25));
2342
2632
  continue;
2343
2633
  }
2344
2634
  return yield* new DriverError({
@@ -2354,28 +2644,28 @@ function createCoordinator(driver, config) {
2354
2644
  }
2355
2645
  });
2356
2646
  return {
2357
- tap: (selector, opts) => Effect4.asVoid(
2647
+ tap: (selector, opts) => Effect_exports.asVoid(
2358
2648
  runGuardedPointerAction(selector, opts, "tap", (x, y) => driver.tapAtCoordinate(x, y), {
2359
2649
  allowDomTap: true
2360
2650
  })
2361
2651
  ),
2362
- tapXY: (x, y) => Effect4.gen(function* () {
2652
+ tapXY: (x, y) => Effect_exports.gen(function* () {
2363
2653
  yield* driver.tapAtCoordinate(x, y);
2364
2654
  yield* afterMutation();
2365
2655
  }),
2366
- doubleTap: (selector, opts) => Effect4.asVoid(
2656
+ doubleTap: (selector, opts) => Effect_exports.asVoid(
2367
2657
  runGuardedPointerAction(
2368
2658
  selector,
2369
2659
  opts,
2370
2660
  "doubleTap",
2371
- (x, y) => Effect4.gen(function* () {
2661
+ (x, y) => driver.domChannel && driver.doubleTapAtCoordinate ? driver.doubleTapAtCoordinate(x, y) : Effect_exports.gen(function* () {
2372
2662
  yield* driver.tapAtCoordinate(x, y);
2373
- yield* Effect4.promise(() => new Promise((r) => setTimeout(r, 200)));
2663
+ yield* Effect_exports.promise(() => new Promise((r) => setTimeout(r, 200)));
2374
2664
  yield* driver.tapAtCoordinate(x, y);
2375
2665
  })
2376
2666
  )
2377
2667
  ),
2378
- longPress: (selector, duration = 1e3, opts) => Effect4.asVoid(
2668
+ longPress: (selector, duration = 1e3, opts) => Effect_exports.asVoid(
2379
2669
  runGuardedPointerAction(
2380
2670
  selector,
2381
2671
  opts,
@@ -2383,16 +2673,16 @@ function createCoordinator(driver, config) {
2383
2673
  (x, y) => driver.longPressAtCoordinate(x, y, duration)
2384
2674
  )
2385
2675
  ),
2386
- longPressXY: (x, y, duration = 1e3) => Effect4.gen(function* () {
2676
+ longPressXY: (x, y, duration = 1e3) => Effect_exports.gen(function* () {
2387
2677
  yield* driver.longPressAtCoordinate(x, y, duration);
2388
2678
  yield* afterMutation();
2389
2679
  }),
2390
- inputText: (text) => Effect4.gen(function* () {
2680
+ inputText: (text) => Effect_exports.gen(function* () {
2391
2681
  const delay = config.typingDelay;
2392
2682
  if (delay && delay > 0) {
2393
2683
  for (const segment of splitGraphemes(text)) {
2394
2684
  yield* driver.inputText(segment);
2395
- yield* Effect4.sleep(Duration2.millis(delay));
2685
+ yield* Effect_exports.sleep(Duration_exports.millis(delay));
2396
2686
  }
2397
2687
  } else {
2398
2688
  yield* driver.inputText(text);
@@ -2402,7 +2692,7 @@ function createCoordinator(driver, config) {
2402
2692
  /**
2403
2693
  * Hover the pointer over an actionable element (moves pointer to its center).
2404
2694
  */
2405
- hover: (selector, opts) => Effect4.gen(function* () {
2695
+ hover: (selector, opts) => Effect_exports.gen(function* () {
2406
2696
  const mergedOpts = {
2407
2697
  ...defaults,
2408
2698
  ...opts,
@@ -2416,7 +2706,7 @@ function createCoordinator(driver, config) {
2416
2706
  mergedOpts,
2417
2707
  cache
2418
2708
  );
2419
- const { x, y } = centerOf(resolved.element);
2709
+ const { x, y } = resolved.domMatch?.clickPoint && (!resolved.webViewFrame || resolved.webViewFrame.x === 0 && resolved.webViewFrame.y === 0 && config.platform !== "ios" && config.platform !== "android") ? resolved.domMatch.clickPoint : centerOf(resolved.element);
2420
2710
  if (driver.hoverAtCoordinate) {
2421
2711
  yield* driver.hoverAtCoordinate(x, y);
2422
2712
  } else if (config.platform === "web") {
@@ -2446,14 +2736,14 @@ function createCoordinator(driver, config) {
2446
2736
  * (TipTap/ProseMirror/Lexical/Slate) or stubborn controlled inputs, falls back
2447
2737
  * seamlessly to native tap + SelectAll + Backspace + keyboard input.
2448
2738
  */
2449
- fill: (selector, text, opts) => Effect4.gen(function* () {
2739
+ fill: (selector, text, opts) => Effect_exports.gen(function* () {
2450
2740
  const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2451
2741
  const fillStart = Date.now();
2452
2742
  const domChannel = driver.domChannel;
2453
2743
  if (!isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && domChannel?.isConnected() && domChannel.fillDom) {
2454
2744
  const verifyDelayMs = opts?.fillVerifyMs ?? defaults?.fillVerifyMs;
2455
- const fillAttempt = yield* Effect4.result(
2456
- Effect4.tryPromise({
2745
+ const fillAttempt = yield* Effect_exports.result(
2746
+ Effect_exports.tryPromise({
2457
2747
  try: () => domChannel.fillDom(selector, text, {
2458
2748
  timeoutMs: timeout,
2459
2749
  ...verifyDelayMs !== void 0 ? { verifyDelayMs } : {}
@@ -2466,7 +2756,7 @@ function createCoordinator(driver, config) {
2466
2756
  return;
2467
2757
  }
2468
2758
  const remaining = Math.max(50, timeout - (Date.now() - fillStart));
2469
- const fallbackEl = yield* Effect4.result(
2759
+ const fallbackEl = yield* Effect_exports.result(
2470
2760
  waitForActionElement(
2471
2761
  driver,
2472
2762
  selector,
@@ -2484,18 +2774,18 @@ function createCoordinator(driver, config) {
2484
2774
  const { x: x2, y: y2 } = centerOf(fallbackEl.success);
2485
2775
  yield* driver.tapAtCoordinate(x2, y2);
2486
2776
  const selectAllKey = process.platform === "darwin" ? "Meta+a" : "Control+a";
2487
- yield* Effect4.result(driver.pressKey(selectAllKey));
2488
- yield* Effect4.result(driver.pressKey("Backspace"));
2777
+ yield* Effect_exports.result(driver.pressKey(selectAllKey));
2778
+ yield* Effect_exports.result(driver.pressKey("Backspace"));
2489
2779
  if (text.length > 0) {
2490
2780
  yield* driver.inputText(text);
2491
2781
  }
2492
2782
  yield* afterMutation();
2493
2783
  return;
2494
2784
  }
2495
- const actionDiag = yield* Effect4.tryPromise({
2785
+ const actionDiag = yield* Effect_exports.tryPromise({
2496
2786
  try: () => domChannel.evaluate(buildDomActionabilityDiagScript(selector)),
2497
2787
  catch: () => null
2498
- }).pipe(Effect4.catch(() => Effect4.succeed(null)));
2788
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
2499
2789
  if (actionDiag?.found && actionDiag.obstructedBy) {
2500
2790
  return yield* new ElementNotFoundError({
2501
2791
  message: `Element is covered by ${actionDiag.obstructedBy} (not fillable within ${timeout}ms) \u2014 selector: ${formatSelector(selector)}`,
@@ -2528,11 +2818,11 @@ function createCoordinator(driver, config) {
2528
2818
  yield* driver.inputText(text);
2529
2819
  yield* afterMutation();
2530
2820
  }),
2531
- pressKey: (key) => Effect4.gen(function* () {
2821
+ pressKey: (key) => Effect_exports.gen(function* () {
2532
2822
  yield* driver.pressKey(key);
2533
2823
  cache.invalidate();
2534
2824
  }),
2535
- check: (selector, opts) => Effect4.gen(function* () {
2825
+ check: (selector, opts) => Effect_exports.gen(function* () {
2536
2826
  const totalTimeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2537
2827
  const deadline = Date.now() + totalTimeout;
2538
2828
  const clicked = yield* runGuardedPointerAction(
@@ -2547,9 +2837,9 @@ function createCoordinator(driver, config) {
2547
2837
  if (!clicked) return;
2548
2838
  const verifyTimeout = Math.max(500, deadline - Date.now());
2549
2839
  yield* assertions.assertChecked(selector, { ...opts, timeout: verifyTimeout }, false).pipe(
2550
- Effect4.catchTag(
2840
+ Effect_exports.catchTag(
2551
2841
  "TextMismatchError",
2552
- () => Effect4.fail(
2842
+ () => Effect_exports.fail(
2553
2843
  new DriverError({
2554
2844
  message: `check() clicked element but it did not become checked within ${verifyTimeout}ms \u2014 selector: ${formatSelector(selector)}`
2555
2845
  })
@@ -2557,7 +2847,7 @@ function createCoordinator(driver, config) {
2557
2847
  )
2558
2848
  );
2559
2849
  }),
2560
- uncheck: (selector, opts) => Effect4.gen(function* () {
2850
+ uncheck: (selector, opts) => Effect_exports.gen(function* () {
2561
2851
  const totalTimeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2562
2852
  const deadline = Date.now() + totalTimeout;
2563
2853
  const clicked = yield* runGuardedPointerAction(
@@ -2572,9 +2862,9 @@ function createCoordinator(driver, config) {
2572
2862
  if (!clicked) return;
2573
2863
  const verifyTimeout = Math.max(500, deadline - Date.now());
2574
2864
  yield* assertions.assertChecked(selector, { ...opts, timeout: verifyTimeout }, true).pipe(
2575
- Effect4.catchTag(
2865
+ Effect_exports.catchTag(
2576
2866
  "TextMismatchError",
2577
- () => Effect4.fail(
2867
+ () => Effect_exports.fail(
2578
2868
  new DriverError({
2579
2869
  message: `uncheck() clicked element but it remained checked after ${verifyTimeout}ms \u2014 selector: ${formatSelector(selector)}`
2580
2870
  })
@@ -2582,7 +2872,29 @@ function createCoordinator(driver, config) {
2582
2872
  )
2583
2873
  );
2584
2874
  }),
2585
- blur: (selector, opts) => Effect4.gen(function* () {
2875
+ blur: (selector, opts) => Effect_exports.gen(function* () {
2876
+ if (!isRelativeSelectorLike2(selector) && !isSystemUISelector(selector) && driver.domChannel?.isConnected()) {
2877
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2878
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2879
+ const deadline = Date.now() + timeout;
2880
+ const script = `(() => {
2881
+ const el = ${buildDomFindElementScript(selector)};
2882
+ if (el && typeof el.blur === "function") { el.blur(); return true; }
2883
+ return false;
2884
+ })()`;
2885
+ while (true) {
2886
+ const ok = yield* Effect_exports.tryPromise({
2887
+ try: () => driver.domChannel.evaluate(script),
2888
+ catch: () => false
2889
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2890
+ if (ok) {
2891
+ yield* afterMutation();
2892
+ return;
2893
+ }
2894
+ if (Date.now() >= deadline) break;
2895
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(pollInterval, 100)));
2896
+ }
2897
+ }
2586
2898
  yield* waitForResolvedElementResult(
2587
2899
  driver,
2588
2900
  selector,
@@ -2601,18 +2913,11 @@ function createCoordinator(driver, config) {
2601
2913
  }
2602
2914
  return false;
2603
2915
  })()`;
2604
- if (driver.domChannel?.isConnected()) {
2605
- yield* Effect4.tryPromise({
2606
- try: () => driver.domChannel.evaluate(script),
2607
- catch: () => false
2608
- }).pipe(Effect4.catch(() => Effect4.succeed(false)));
2609
- } else {
2610
- yield* driver.evaluate(script).pipe(Effect4.catch(() => Effect4.succeed(false)));
2611
- }
2916
+ yield* driver.evaluate(script).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2612
2917
  }
2613
2918
  yield* afterMutation();
2614
2919
  }),
2615
- selectOption: (selector, option, opts) => Effect4.gen(function* () {
2920
+ selectOption: (selector, option, opts) => Effect_exports.gen(function* () {
2616
2921
  yield* waitForResolvedElementResult(
2617
2922
  driver,
2618
2923
  selector,
@@ -2631,7 +2936,7 @@ function createCoordinator(driver, config) {
2631
2936
  const deadline = Date.now() + effectiveTimeout;
2632
2937
  let res;
2633
2938
  while (true) {
2634
- res = driver.domChannel?.isConnected() ? yield* Effect4.tryPromise({
2939
+ res = driver.domChannel?.isConnected() ? yield* Effect_exports.tryPromise({
2635
2940
  try: () => driver.domChannel.evaluate(
2636
2941
  script
2637
2942
  ),
@@ -2640,7 +2945,7 @@ function createCoordinator(driver, config) {
2640
2945
  if (res?.ok) break;
2641
2946
  const retryable = res?.error !== void 0 && (res.error.startsWith("Option not found") || res.error === "Select element not found");
2642
2947
  if (!retryable || Date.now() >= deadline) break;
2643
- yield* Effect4.sleep(50);
2948
+ yield* Effect_exports.sleep(50);
2644
2949
  }
2645
2950
  if (!res?.ok) {
2646
2951
  return yield* new DriverError({
@@ -2650,7 +2955,25 @@ function createCoordinator(driver, config) {
2650
2955
  yield* afterMutation();
2651
2956
  return res.selected ?? [];
2652
2957
  }),
2653
- focus: (selector, opts) => Effect4.gen(function* () {
2958
+ focus: (selector, opts) => Effect_exports.gen(function* () {
2959
+ if (!isRelativeSelectorLike2(selector) && !isSystemUISelector(selector) && driver.domChannel?.isConnected()) {
2960
+ const timeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2961
+ const pollInterval = opts?.pollInterval ?? defaults?.pollInterval ?? 100;
2962
+ const deadline = Date.now() + timeout;
2963
+ const script = buildDomFocusScript(selector);
2964
+ while (true) {
2965
+ const ok = yield* Effect_exports.tryPromise({
2966
+ try: () => driver.domChannel.evaluate(script),
2967
+ catch: () => false
2968
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2969
+ if (ok) {
2970
+ yield* afterMutation();
2971
+ return;
2972
+ }
2973
+ if (Date.now() >= deadline) break;
2974
+ yield* Effect_exports.sleep(Duration_exports.millis(Math.min(pollInterval, 100)));
2975
+ }
2976
+ }
2654
2977
  const resolved = yield* waitForResolvedElementResult(
2655
2978
  driver,
2656
2979
  selector,
@@ -2661,20 +2984,17 @@ function createCoordinator(driver, config) {
2661
2984
  );
2662
2985
  if (!isRelativeSelectorLike2(selector) && !isSystemUISelector(selector)) {
2663
2986
  const script = buildDomFocusScript(selector);
2664
- const ok = driver.domChannel?.isConnected() ? yield* Effect4.tryPromise({
2665
- try: () => driver.domChannel.evaluate(script),
2666
- catch: () => false
2667
- }).pipe(Effect4.catch(() => Effect4.succeed(false))) : yield* driver.evaluate(script).pipe(Effect4.catch(() => Effect4.succeed(false)));
2987
+ const ok = yield* driver.evaluate(script).pipe(Effect_exports.catch(() => Effect_exports.succeed(false)));
2668
2988
  if (ok) {
2669
2989
  yield* afterMutation();
2670
2990
  return;
2671
2991
  }
2672
2992
  }
2673
- const { x, y } = centerOf(resolved.element);
2993
+ const { x, y } = resolved.domMatch?.clickPoint && (!resolved.webViewFrame || resolved.webViewFrame.x === 0 && resolved.webViewFrame.y === 0 && config.platform !== "ios" && config.platform !== "android") ? resolved.domMatch.clickPoint : centerOf(resolved.element);
2674
2994
  yield* driver.tapAtCoordinate(x, y);
2675
2995
  yield* afterMutation();
2676
2996
  }),
2677
- dragTo: (source, target, opts) => Effect4.gen(function* () {
2997
+ dragTo: (source, target, opts) => Effect_exports.gen(function* () {
2678
2998
  const merged = { ...defaults, ...opts, platform: opts?.platform ?? config.platform };
2679
2999
  const src = yield* waitForActionElement(driver, source, parse, merged, cache);
2680
3000
  const dst = yield* waitForActionElement(driver, target, parse, merged, cache);
@@ -2687,11 +3007,11 @@ function createCoordinator(driver, config) {
2687
3007
  }
2688
3008
  yield* afterMutation();
2689
3009
  }),
2690
- hideKeyboard: () => Effect4.gen(function* () {
3010
+ hideKeyboard: () => Effect_exports.gen(function* () {
2691
3011
  yield* driver.hideKeyboard();
2692
3012
  cache.invalidate();
2693
3013
  }),
2694
- dismissKeyboard: (opts) => Effect4.gen(function* () {
3014
+ dismissKeyboard: (opts) => Effect_exports.gen(function* () {
2695
3015
  const strategy = opts?.strategy ?? DEFAULT_DISMISS_KEYBOARD_STRATEGY;
2696
3016
  if (strategy === "driver") {
2697
3017
  return yield* dismissKeyboardWithDriver();
@@ -2700,13 +3020,13 @@ function createCoordinator(driver, config) {
2700
3020
  return yield* dismissKeyboardWithBack();
2701
3021
  }
2702
3022
  const platform = (yield* driver.getDeviceInfo()).platform;
2703
- const hideKeyboardResult = yield* Effect4.result(driver.hideKeyboard());
3023
+ const hideKeyboardResult = yield* Effect_exports.result(driver.hideKeyboard());
2704
3024
  if (hideKeyboardResult._tag === "Success") {
2705
3025
  yield* afterMutation();
2706
3026
  return;
2707
3027
  }
2708
3028
  if (platform === "android") {
2709
- const backResult = yield* Effect4.result(driver.back());
3029
+ const backResult = yield* Effect_exports.result(driver.back());
2710
3030
  if (backResult._tag === "Success") {
2711
3031
  yield* afterMutation();
2712
3032
  return;
@@ -2721,15 +3041,52 @@ function createCoordinator(driver, config) {
2721
3041
  }),
2722
3042
  swipe: (direction, opts) => swipeEffect(direction, opts),
2723
3043
  scroll: (direction) => scrollEffect(direction),
2724
- scrollUntilVisible: (selector, opts) => Effect4.gen(function* () {
3044
+ scrollUntilVisible: (selector, opts) => Effect_exports.gen(function* () {
2725
3045
  const searchDirection = opts?.direction ?? DEFAULT_SCROLL_SEARCH_DIRECTION;
2726
3046
  const gestureDirection = gestureDirectionForSearch(searchDirection);
2727
3047
  const maxScrolls = Math.max(0, opts?.maxScrolls ?? DEFAULT_MAX_SCROLLS);
2728
3048
  const totalTimeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2729
3049
  const deadline = Date.now() + totalTimeout;
2730
3050
  let scrollCount = 0;
3051
+ const domChannel = driver.domChannel;
3052
+ const isWebDom = (config.platform === "web" || !config.platform) && !isSystemUISelector(selector) && !isRelativeSelectorLike2(selector) && Boolean(domChannel?.isConnected());
3053
+ const isRectInViewport = (m) => {
3054
+ const vpW = m.viewportWidth || 0;
3055
+ const vpH = m.viewportHeight || 0;
3056
+ if (vpW <= 0 || vpH <= 0) return true;
3057
+ const r = m.rect;
3058
+ return r.width > 0 && r.height > 0 && r.x + r.width > 0 && r.y + r.height > 0 && r.x < vpW && r.y < vpH;
3059
+ };
3060
+ const probeVisibleInViewport = () => Effect_exports.gen(function* () {
3061
+ if (isWebDom && domChannel) {
3062
+ const matches = yield* Effect_exports.tryPromise({
3063
+ try: () => domChannel.query(selector),
3064
+ catch: (err) => isInvalidSelectorError(err) ? new DriverError({ message: err instanceof Error ? err.message : String(err) }) : null
3065
+ }).pipe(
3066
+ Effect_exports.catch(
3067
+ (err) => err instanceof DriverError ? Effect_exports.fail(err) : Effect_exports.succeed(null)
3068
+ )
3069
+ );
3070
+ if (matches) {
3071
+ const visibleMatches = matches.filter((m) => m.visible);
3072
+ if (visibleMatches.length === 0) return false;
3073
+ if (visibleMatches.some(isRectInViewport)) return true;
3074
+ if (domChannel.scrollIntoView) {
3075
+ const scrolled = yield* Effect_exports.tryPromise({
3076
+ try: () => domChannel.scrollIntoView(selector),
3077
+ catch: () => null
3078
+ }).pipe(Effect_exports.catch(() => Effect_exports.succeed(null)));
3079
+ if (scrolled && scrolled.visible && isRectInViewport(scrolled)) {
3080
+ return true;
3081
+ }
3082
+ }
3083
+ return false;
3084
+ }
3085
+ }
3086
+ return yield* probeVisible(selector, opts);
3087
+ });
2731
3088
  while (scrollCount <= maxScrolls && Date.now() <= deadline) {
2732
- const found = yield* probeVisible(selector, opts);
3089
+ const found = yield* probeVisibleInViewport();
2733
3090
  if (found) {
2734
3091
  return;
2735
3092
  }
@@ -2745,7 +3102,7 @@ function createCoordinator(driver, config) {
2745
3102
  timeoutMs: totalTimeout
2746
3103
  });
2747
3104
  }),
2748
- backUntilVisible: (selector, opts) => Effect4.gen(function* () {
3105
+ backUntilVisible: (selector, opts) => Effect_exports.gen(function* () {
2749
3106
  const maxBacks = Math.max(0, opts?.maxBacks ?? DEFAULT_MAX_BACKS);
2750
3107
  const totalTimeout = opts?.timeout ?? defaults?.timeout ?? 5e3;
2751
3108
  const deadline = Date.now() + totalTimeout;
@@ -2758,7 +3115,7 @@ function createCoordinator(driver, config) {
2758
3115
  if (backCount === maxBacks) {
2759
3116
  break;
2760
3117
  }
2761
- const backResult = yield* Effect4.result(driver.back());
3118
+ const backResult = yield* Effect_exports.result(driver.back());
2762
3119
  if (backResult._tag === "Failure") {
2763
3120
  return yield* new DriverError({
2764
3121
  message: `backUntilVisible() failed on back attempt ${backCount + 1}: ${backResult.failure.message}`
@@ -2775,7 +3132,7 @@ function createCoordinator(driver, config) {
2775
3132
  }),
2776
3133
  pinch: (selector, opts) => scaleGesture("pinch", selector, opts),
2777
3134
  zoom: (selector, opts) => scaleGesture("zoom", selector, opts),
2778
- multiTouch: (sequences) => Effect4.gen(function* () {
3135
+ multiTouch: (sequences) => Effect_exports.gen(function* () {
2779
3136
  if (!driver.multiTouch) {
2780
3137
  return yield* new DriverError({
2781
3138
  message: "multiTouch() is only supported on mobile platforms (Android/iOS)"
@@ -2858,7 +3215,6 @@ init_esm_shims();
2858
3215
  import { AsyncLocalStorage } from "async_hooks";
2859
3216
  import { mkdir, readFile, writeFile } from "fs/promises";
2860
3217
  import { dirname as dirname2, resolve as resolvePath } from "path";
2861
- import { Effect as Effect5 } from "effect";
2862
3218
 
2863
3219
  // src/api/snapshots.ts
2864
3220
  init_esm_shims();
@@ -3060,7 +3416,7 @@ function createPromiseExpect(driver, config, recorder, flowContext, visualRegres
3060
3416
  }
3061
3417
  return defaultTimeout;
3062
3418
  };
3063
- const run = (effect) => Effect5.runPromise(effect);
3419
+ const run = (effect) => Effect_exports.runPromise(effect);
3064
3420
  const recordSoft = async (action) => {
3065
3421
  if (!ctx.recordSoftFailure || retryScope.getStore()) return action();
3066
3422
  try {
@@ -3257,6 +3613,11 @@ function createPromiseExpect(driver, config, recorder, flowContext, visualRegres
3257
3613
  (v) => v === void 0,
3258
3614
  (v) => negate ? `Expected polled value NOT to be undefined` : `Expected polled value to be undefined, received ${JSON.stringify(v)}`
3259
3615
  ),
3616
+ toBeNull: () => check(
3617
+ "toBeNull",
3618
+ (v) => v === null,
3619
+ (v) => negate ? `Expected polled value NOT to be null` : `Expected polled value to be null, received ${JSON.stringify(v)}`
3620
+ ),
3260
3621
  toHaveLength: (expected) => check(
3261
3622
  `toHaveLength(${expected})`,
3262
3623
  (v) => v !== null && v !== void 0 && typeof v.length === "number" && v.length === expected,
@@ -3388,6 +3749,7 @@ ${actual}`
3388
3749
  maxDiffPixelRatio: options?.maxDiffPixelRatio ?? visualRegression?.maxDiffPixelRatio,
3389
3750
  mask: [],
3390
3751
  maskSelectors: options?.mask,
3752
+ maskColor: options?.maskColor,
3391
3753
  fullPage: options?.fullPage,
3392
3754
  updateBaselines: ctx.updateBaselines,
3393
3755
  baselinesDir: visualRegression?.baselinesDir
@@ -3605,7 +3967,8 @@ function parseSetCookieHeader(headerValue, originUrl) {
3605
3967
  const v = rest.join("=").trim();
3606
3968
  if (k === "path" && v) cookie.path = v;
3607
3969
  else if (k === "domain" && v) {
3608
- cookie.domain = v;
3970
+ const bare = v.replace(/^\.+/, "");
3971
+ cookie.domain = bare ? `.${bare}` : v;
3609
3972
  delete cookie.url;
3610
3973
  } else if (k === "httponly") cookie.httpOnly = true;
3611
3974
  else if (k === "secure") cookie.secure = true;
@@ -3669,8 +4032,8 @@ function wrapRawPageWithStepRecording(rawPage, recorder) {
3669
4032
  function createPromiseApp(driver, appId, config, recorder, options = {}) {
3670
4033
  const coord = createCoordinator(driver, config);
3671
4034
  const platform = options.platform ?? (appId.startsWith("http://") || appId.startsWith("https://") ? "web" : void 0);
3672
- const run = (effect) => Effect6.runPromise(effect);
3673
- const unsupportedWebFeature = (feature) => Effect6.fail(new DriverError({ message: `${feature}() is only supported on the web platform` }));
4035
+ const run = (effect) => Effect_exports.runPromise(effect);
4036
+ const unsupportedWebFeature = (feature) => Effect_exports.fail(new DriverError({ message: `${feature}() is only supported on the web platform` }));
3674
4037
  const optionalMethod = (name, method) => method ?? ((..._args) => unsupportedWebFeature(name));
3675
4038
  const unsupportedNetworkFeature = async (name) => {
3676
4039
  const target = platform ?? (await run(driver.getDeviceInfo())).platform;
@@ -3678,7 +4041,10 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
3678
4041
  message: `${name}() is not supported on ${target} with the current driver`
3679
4042
  });
3680
4043
  };
3681
- const runStep = (command, action, opts) => recorder ? recorder.runStep(command, action, opts) : action();
4044
+ const runStep = (command, action, opts) => {
4045
+ options.onActiveDriver?.(driver);
4046
+ return recorder ? recorder.runStep(command, action, opts) : action();
4047
+ };
3682
4048
  const runDeviceStep = (name, method, ...args) => runStep(name, async () => {
3683
4049
  if (!method) {
3684
4050
  const target = platform ?? (await run(driver.getDeviceInfo())).platform;
@@ -3694,7 +4060,7 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
3694
4060
  return run(
3695
4061
  driver.evaluate(
3696
4062
  "typeof window !== 'undefined' && window.location ? String(window.location.href || '') : ''"
3697
- ).pipe(Effect6.catch(() => Effect6.succeed("")))
4063
+ ).pipe(Effect_exports.catch(() => Effect_exports.succeed("")))
3698
4064
  );
3699
4065
  };
3700
4066
  const resolveRequestUrl = async (rawUrl) => {
@@ -4210,18 +4576,18 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4210
4576
  insertText: (text) => runStep("keyboard.insertText", () => run(coord.inputText(text)))
4211
4577
  };
4212
4578
  const mouseClient = {
4213
- move: (x, y) => runStep(
4579
+ move: (x, y, opts) => runStep(
4214
4580
  `mouse.move(${x},${y})`,
4215
- () => run(optionalMethod("mouse.move", driver.hoverAtCoordinate)(x, y))
4581
+ () => run(optionalMethod("mouse.move", driver.hoverAtCoordinate)(x, y, opts))
4216
4582
  ),
4217
- down: (x, y, opts) => runStep(
4218
- `mouse.down(${x},${y})`,
4583
+ down: ((x, y, opts) => runStep(
4584
+ typeof x === "number" ? `mouse.down(${x},${y})` : "mouse.down()",
4219
4585
  () => run(optionalMethod("mouse.down", driver.mouseDown)(x, y, opts))
4220
- ),
4221
- up: (x, y, opts) => runStep(
4222
- `mouse.up(${x},${y})`,
4586
+ )),
4587
+ up: ((x, y, opts) => runStep(
4588
+ typeof x === "number" ? `mouse.up(${x},${y})` : "mouse.up()",
4223
4589
  () => run(optionalMethod("mouse.up", driver.mouseUp)(x, y, opts))
4224
- ),
4590
+ )),
4225
4591
  click: (x, y) => runStep(`mouse.click(${x},${y})`, () => run(coord.tapXY(x, y))),
4226
4592
  wheel: (deltaX, deltaY, opts) => runStep(`mouse.wheel(${deltaX},${deltaY})`, async () => {
4227
4593
  const x = opts?.x ?? 0;
@@ -4444,6 +4810,7 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4444
4810
  captureScreenshot: true
4445
4811
  }
4446
4812
  ),
4813
+ lastNavigationStatus: () => driver.getLastNavigationStatus?.() ?? null,
4447
4814
  openStory: (storyId, opts) => runStep(
4448
4815
  `openStory(${storyId})`,
4449
4816
  async () => {
@@ -4522,12 +4889,28 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4522
4889
  const timeout = opts?.timeout ?? config.defaults?.timeout ?? 5e3;
4523
4890
  const pollInterval = opts?.pollInterval ?? 100;
4524
4891
  const deadline = Date.now() + timeout;
4892
+ let lastTransientErr;
4525
4893
  while (Date.now() < deadline) {
4526
- const val = arg === void 0 ? await run(driver.evaluate(fn)) : await run(driver.evaluate(fn, arg));
4527
- if (val) return val;
4528
- await new Promise((r) => setTimeout(r, pollInterval));
4894
+ try {
4895
+ const val = arg === void 0 ? await run(driver.evaluate(fn)) : await run(driver.evaluate(fn, arg));
4896
+ if (val) return val;
4897
+ lastTransientErr = void 0;
4898
+ } catch (err) {
4899
+ const msg = err instanceof Error ? err.message : String(err);
4900
+ const isNavContextDestroyed = /Execution context was destroyed|Cannot find context with specified id|Inspected target navigated or closed/i.test(
4901
+ msg
4902
+ );
4903
+ if (!isNavContextDestroyed) throw err;
4904
+ lastTransientErr = err;
4905
+ }
4906
+ await new Promise(
4907
+ (r) => setTimeout(r, Math.min(pollInterval, Math.max(10, deadline - Date.now())))
4908
+ );
4529
4909
  }
4530
- throw new DriverError({ message: `waitForFunction() timed out after ${timeout}ms` });
4910
+ const detail = lastTransientErr instanceof Error ? ` (${lastTransientErr.message})` : "";
4911
+ throw new DriverError({
4912
+ message: `waitForFunction() timed out after ${timeout}ms${detail}`
4913
+ });
4531
4914
  })),
4532
4915
  waitForPopup: (triggerFn, opts) => runStep(
4533
4916
  "waitForPopup",
@@ -4541,11 +4924,35 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4541
4924
  `exposeFunction(${name})`,
4542
4925
  () => run(optionalMethod("exposeFunction", driver.exposeFunction)(name, fn))
4543
4926
  ),
4544
- takeScreenshot: (name) => runScreenshotStep(
4927
+ takeScreenshot: (name, opts) => runScreenshotStep(
4545
4928
  name ? `takeScreenshot(${name})` : "takeScreenshot",
4546
- () => run(driver.takeScreenshot()),
4929
+ () => run(
4930
+ opts?.fullPage && driver.takeFullPageScreenshot ? driver.takeFullPageScreenshot() : driver.takeScreenshot()
4931
+ ),
4547
4932
  { name }
4548
4933
  ),
4934
+ boundingBox: (selector, opts) => runStep(
4935
+ "boundingBox",
4936
+ async () => {
4937
+ try {
4938
+ const el = await run(
4939
+ coord.assertVisible(selector, {
4940
+ timeout: opts?.timeout ?? 5e3,
4941
+ platform: config.platform
4942
+ })
4943
+ );
4944
+ return {
4945
+ x: el.bounds.x,
4946
+ y: el.bounds.y,
4947
+ width: el.bounds.width,
4948
+ height: el.bounds.height
4949
+ };
4950
+ } catch {
4951
+ return null;
4952
+ }
4953
+ },
4954
+ { selector }
4955
+ ),
4549
4956
  evaluate: ((fn, ...args) => runStep(
4550
4957
  formatEvaluateCommand(fn),
4551
4958
  () => run(driver.evaluate(fn, ...args))
@@ -4555,6 +4962,11 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4555
4962
  () => driver.route ? run(driver.route(matcher, handler)) : unsupportedNetworkFeature("route"),
4556
4963
  { selector: { matcher: describeMatcher(matcher) } }
4557
4964
  ),
4965
+ unroute: (matcher, handler) => runStep(
4966
+ "unroute",
4967
+ () => driver.unroute ? run(driver.unroute(matcher, handler)) : unsupportedNetworkFeature("unroute"),
4968
+ { selector: { matcher: describeMatcher(matcher) } }
4969
+ ),
4558
4970
  mockNetwork: (matcher, response) => runStep(
4559
4971
  "mockNetwork",
4560
4972
  () => driver.mockNetwork ? run(driver.mockNetwork(matcher, response)) : unsupportedNetworkFeature("mockNetwork"),
@@ -4677,7 +5089,7 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4677
5089
  throw closedError();
4678
5090
  }
4679
5091
  if (prop === "getNavigationUrls") return [];
4680
- return Effect6.fail(closedError());
5092
+ return Effect_exports.fail(closedError());
4681
5093
  }
4682
5094
  return val.apply(target, args);
4683
5095
  };
@@ -4741,7 +5153,28 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4741
5153
  getAttribute: (sel, name, opts) => appObj.getAttribute(scoped(sel), name, opts),
4742
5154
  isVisible: (sel, opts) => appObj.isVisible(scoped(sel), opts),
4743
5155
  isEnabled: (sel, opts) => appObj.isEnabled(scoped(sel), opts),
5156
+ isChecked: (sel, opts) => appObj.isChecked(scoped(sel), opts),
4744
5157
  count: (sel, opts) => appObj.count(scoped(sel), opts),
5158
+ evaluate: (fn, ...args) => runStep(
5159
+ "frame.evaluate",
5160
+ async () => {
5161
+ const ch = driver.domChannel;
5162
+ if (ch?.isConnected() && ch.evaluateInFrame) {
5163
+ return ch.evaluateInFrame(frameSelector, fn, ...args);
5164
+ }
5165
+ const expr = buildDomFrameEvaluateScript(frameSelector, fn, args);
5166
+ const res = await appObj.evaluate(
5167
+ expr
5168
+ );
5169
+ if (res?.__spanaFrameEvalOk) {
5170
+ return res.value;
5171
+ }
5172
+ throw new DriverError({
5173
+ message: `Iframe matching ${JSON.stringify(frameSelector)} not found`
5174
+ });
5175
+ },
5176
+ { selector: frameSelector }
5177
+ ),
4745
5178
  expect: (sel) => appExpect(scoped(sel))
4746
5179
  };
4747
5180
  },
@@ -4826,15 +5259,28 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4826
5259
  selector
4827
5260
  }),
4828
5261
  isVisible: (selector, opts) => {
4829
- const timeout = opts?.timeout ?? 1e3;
5262
+ const timeout = opts?.timeout ?? 0;
4830
5263
  return run(
4831
- Effect6.gen(function* () {
4832
- const result = yield* Effect6.result(
5264
+ Effect_exports.gen(function* () {
5265
+ if (timeout <= 0) {
5266
+ const resolved = yield* Effect_exports.result(
5267
+ resolveElementAcrossChannels(driver, selector, config.parse, void 0, {
5268
+ forAction: false,
5269
+ platform: config.platform
5270
+ })
5271
+ );
5272
+ return resolved._tag === "Success" && resolved.success !== void 0;
5273
+ }
5274
+ const result = yield* Effect_exports.result(
4833
5275
  waitForElement(
4834
5276
  driver,
4835
5277
  selector,
4836
5278
  config.parse,
4837
- { timeout, pollInterval: 100 },
5279
+ {
5280
+ timeout,
5281
+ pollInterval: Math.min(100, timeout),
5282
+ platform: config.platform
5283
+ },
4838
5284
  void 0
4839
5285
  )
4840
5286
  );
@@ -4843,6 +5289,7 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
4843
5289
  );
4844
5290
  },
4845
5291
  isEnabled: (selector, opts) => runStep("isEnabled", () => run(coord.isElementEnabled(selector, opts)), { selector }),
5292
+ isChecked: (selector, opts) => runStep("isChecked", () => run(coord.isChecked(selector, opts)), { selector }),
4846
5293
  count: (selector, opts) => runStep("count", () => run(coord.count(selector, opts)), { selector }),
4847
5294
  // Web-first bridge & fast state helpers
4848
5295
  waitForIdle: (opts) => runStep("waitForIdle", async () => {
@@ -5102,19 +5549,19 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
5102
5549
  // WebView / hybrid context switching (low-level escape hatches)
5103
5550
  getContexts: () => runStep(
5104
5551
  "getContexts",
5105
- () => run((driver.getContexts ?? (() => Effect6.succeed(["NATIVE_APP"])))())
5552
+ () => run((driver.getContexts ?? (() => Effect_exports.succeed(["NATIVE_APP"])))())
5106
5553
  ),
5107
5554
  getCurrentContext: () => runStep(
5108
5555
  "getCurrentContext",
5109
- () => run((driver.getCurrentContext ?? (() => Effect6.succeed("NATIVE_APP")))())
5556
+ () => run((driver.getCurrentContext ?? (() => Effect_exports.succeed("NATIVE_APP")))())
5110
5557
  ),
5111
5558
  switchToContext: (contextId) => runStep(
5112
5559
  `switchToContext(${contextId})`,
5113
- () => run((driver.setContext ?? ((_id) => Effect6.void))(contextId))
5560
+ () => run((driver.setContext ?? ((_id) => Effect_exports.void))(contextId))
5114
5561
  ),
5115
5562
  switchToWebView: () => runStep("switchToWebView", async () => {
5116
5563
  const contexts = await run(
5117
- (driver.getContexts ?? (() => Effect6.succeed(["NATIVE_APP"])))()
5564
+ (driver.getContexts ?? (() => Effect_exports.succeed(["NATIVE_APP"])))()
5118
5565
  );
5119
5566
  const webview = contexts.find((c) => c.startsWith("WEBVIEW_"));
5120
5567
  if (!webview) {
@@ -5122,11 +5569,11 @@ function createPromiseApp(driver, appId, config, recorder, options = {}) {
5122
5569
  message: `No WebView context found. Available contexts: ${contexts.join(", ")}`
5123
5570
  });
5124
5571
  }
5125
- await run((driver.setContext ?? ((_id) => Effect6.void))(webview));
5572
+ await run((driver.setContext ?? ((_id) => Effect_exports.void))(webview));
5126
5573
  }),
5127
5574
  switchToNativeApp: () => runStep(
5128
5575
  "switchToNativeApp",
5129
- () => run((driver.setContext ?? ((_id) => Effect6.void))("NATIVE_APP"))
5576
+ () => run((driver.setContext ?? ((_id) => Effect_exports.void))("NATIVE_APP"))
5130
5577
  )
5131
5578
  };
5132
5579
  return appObj;
@@ -5157,11 +5604,13 @@ export {
5157
5604
  domRectToScreenBounds,
5158
5605
  isOffscreenInViewport,
5159
5606
  resolveElementAcrossChannels,
5607
+ loadCachedAxeSource,
5160
5608
  createCoordinator,
5161
5609
  buildStorybookUrl,
5162
5610
  matchDataSnapshot,
5163
5611
  assertDataSnapshot,
5164
5612
  createPromiseExpect,
5613
+ parseSetCookieHeader,
5165
5614
  createPromiseApp
5166
5615
  };
5167
- //# sourceMappingURL=chunk-ZCSH3QKX.js.map
5616
+ //# sourceMappingURL=chunk-G4ZUJCEN.js.map