devharness 0.8.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 (627) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/build/atomic-write.d.ts +28 -0
  4. package/build/atomic-write.d.ts.map +1 -0
  5. package/build/atomic-write.js +126 -0
  6. package/build/atomic-write.js.map +1 -0
  7. package/build/cdp-manager.d.ts +524 -0
  8. package/build/cdp-manager.d.ts.map +1 -0
  9. package/build/cdp-manager.js +1828 -0
  10. package/build/cdp-manager.js.map +1 -0
  11. package/build/cdp-manager.test.d.ts +6 -0
  12. package/build/cdp-manager.test.d.ts.map +1 -0
  13. package/build/cdp-manager.test.js +546 -0
  14. package/build/cdp-manager.test.js.map +1 -0
  15. package/build/chrome-launcher.d.ts +400 -0
  16. package/build/chrome-launcher.d.ts.map +1 -0
  17. package/build/chrome-launcher.js +1071 -0
  18. package/build/chrome-launcher.js.map +1 -0
  19. package/build/chrome-launcher.test.d.ts +11 -0
  20. package/build/chrome-launcher.test.d.ts.map +1 -0
  21. package/build/chrome-launcher.test.js +204 -0
  22. package/build/chrome-launcher.test.js.map +1 -0
  23. package/build/clickable-cache.d.ts +73 -0
  24. package/build/clickable-cache.d.ts.map +1 -0
  25. package/build/clickable-cache.js +90 -0
  26. package/build/clickable-cache.js.map +1 -0
  27. package/build/command-recorder.d.ts +401 -0
  28. package/build/command-recorder.d.ts.map +1 -0
  29. package/build/command-recorder.js +701 -0
  30. package/build/command-recorder.js.map +1 -0
  31. package/build/config.d.ts +390 -0
  32. package/build/config.d.ts.map +1 -0
  33. package/build/config.js +826 -0
  34. package/build/config.js.map +1 -0
  35. package/build/config.test.d.ts +2 -0
  36. package/build/config.test.d.ts.map +1 -0
  37. package/build/config.test.js +112 -0
  38. package/build/config.test.js.map +1 -0
  39. package/build/connection-manager.d.ts +159 -0
  40. package/build/connection-manager.d.ts.map +1 -0
  41. package/build/connection-manager.js +432 -0
  42. package/build/connection-manager.js.map +1 -0
  43. package/build/connection-manager.test.d.ts +11 -0
  44. package/build/connection-manager.test.d.ts.map +1 -0
  45. package/build/connection-manager.test.js +114 -0
  46. package/build/connection-manager.test.js.map +1 -0
  47. package/build/console-monitor.d.ts +150 -0
  48. package/build/console-monitor.d.ts.map +1 -0
  49. package/build/console-monitor.js +454 -0
  50. package/build/console-monitor.js.map +1 -0
  51. package/build/dashboard/bundle.js +1 -0
  52. package/build/dashboard/dashboard-client.d.ts +42 -0
  53. package/build/dashboard/dashboard-client.d.ts.map +1 -0
  54. package/build/dashboard/dashboard-client.js +184 -0
  55. package/build/dashboard/dashboard-client.js.map +1 -0
  56. package/build/dashboard/dashboard-hub.d.ts +50 -0
  57. package/build/dashboard/dashboard-hub.d.ts.map +1 -0
  58. package/build/dashboard/dashboard-hub.js +654 -0
  59. package/build/dashboard/dashboard-hub.js.map +1 -0
  60. package/build/dashboard/hub-lock.d.ts +16 -0
  61. package/build/dashboard/hub-lock.d.ts.map +1 -0
  62. package/build/dashboard/hub-lock.js +77 -0
  63. package/build/dashboard/hub-lock.js.map +1 -0
  64. package/build/dashboard/index.d.ts +25 -0
  65. package/build/dashboard/index.d.ts.map +1 -0
  66. package/build/dashboard/index.js +77 -0
  67. package/build/dashboard/index.js.map +1 -0
  68. package/build/dashboard/types.d.ts +83 -0
  69. package/build/dashboard/types.d.ts.map +1 -0
  70. package/build/dashboard/types.js +6 -0
  71. package/build/dashboard/types.js.map +1 -0
  72. package/build/debug-logger.d.ts +85 -0
  73. package/build/debug-logger.d.ts.map +1 -0
  74. package/build/debug-logger.js +195 -0
  75. package/build/debug-logger.js.map +1 -0
  76. package/build/debugger-aware-wrapper.d.ts +37 -0
  77. package/build/debugger-aware-wrapper.d.ts.map +1 -0
  78. package/build/debugger-aware-wrapper.js +128 -0
  79. package/build/debugger-aware-wrapper.js.map +1 -0
  80. package/build/dom-change-monitor.d.ts +92 -0
  81. package/build/dom-change-monitor.d.ts.map +1 -0
  82. package/build/dom-change-monitor.js +437 -0
  83. package/build/dom-change-monitor.js.map +1 -0
  84. package/build/element-collector.d.ts +16 -0
  85. package/build/element-collector.d.ts.map +1 -0
  86. package/build/element-collector.js +207 -0
  87. package/build/element-collector.js.map +1 -0
  88. package/build/error-helpers.d.ts +43 -0
  89. package/build/error-helpers.d.ts.map +1 -0
  90. package/build/error-helpers.js +143 -0
  91. package/build/error-helpers.js.map +1 -0
  92. package/build/formatters/console-formatter.d.ts +160 -0
  93. package/build/formatters/console-formatter.d.ts.map +1 -0
  94. package/build/formatters/console-formatter.js +338 -0
  95. package/build/formatters/console-formatter.js.map +1 -0
  96. package/build/helpers/parser-plugins.d.ts +44 -0
  97. package/build/helpers/parser-plugins.d.ts.map +1 -0
  98. package/build/helpers/parser-plugins.js +102 -0
  99. package/build/helpers/parser-plugins.js.map +1 -0
  100. package/build/helpers/paths.d.ts +79 -0
  101. package/build/helpers/paths.d.ts.map +1 -0
  102. package/build/helpers/paths.js +168 -0
  103. package/build/helpers/paths.js.map +1 -0
  104. package/build/helpers/process-liveness.d.ts +24 -0
  105. package/build/helpers/process-liveness.d.ts.map +1 -0
  106. package/build/helpers/process-liveness.js +36 -0
  107. package/build/helpers/process-liveness.js.map +1 -0
  108. package/build/helpers/process-liveness.test.d.ts +2 -0
  109. package/build/helpers/process-liveness.test.d.ts.map +1 -0
  110. package/build/helpers/process-liveness.test.js +40 -0
  111. package/build/helpers/process-liveness.test.js.map +1 -0
  112. package/build/helpers/sequence-tree.d.ts +27 -0
  113. package/build/helpers/sequence-tree.d.ts.map +1 -0
  114. package/build/helpers/sequence-tree.js +80 -0
  115. package/build/helpers/sequence-tree.js.map +1 -0
  116. package/build/helpers/sequence-tree.test.d.ts +2 -0
  117. package/build/helpers/sequence-tree.test.d.ts.map +1 -0
  118. package/build/helpers/sequence-tree.test.js +122 -0
  119. package/build/helpers/sequence-tree.test.js.map +1 -0
  120. package/build/index.d.ts +3 -0
  121. package/build/index.d.ts.map +1 -0
  122. package/build/index.js +2007 -0
  123. package/build/index.js.map +1 -0
  124. package/build/interaction-recorder.d.ts +214 -0
  125. package/build/interaction-recorder.d.ts.map +1 -0
  126. package/build/interaction-recorder.js +2007 -0
  127. package/build/interaction-recorder.js.map +1 -0
  128. package/build/issue-tracker.d.ts +107 -0
  129. package/build/issue-tracker.d.ts.map +1 -0
  130. package/build/issue-tracker.js +582 -0
  131. package/build/issue-tracker.js.map +1 -0
  132. package/build/issue-tracker.test.d.ts +2 -0
  133. package/build/issue-tracker.test.d.ts.map +1 -0
  134. package/build/issue-tracker.test.js +88 -0
  135. package/build/issue-tracker.test.js.map +1 -0
  136. package/build/launch-chrome-port.test.d.ts +14 -0
  137. package/build/launch-chrome-port.test.d.ts.map +1 -0
  138. package/build/launch-chrome-port.test.js +97 -0
  139. package/build/launch-chrome-port.test.js.map +1 -0
  140. package/build/log-processor/orchestrator.d.ts +32 -0
  141. package/build/log-processor/orchestrator.d.ts.map +1 -0
  142. package/build/log-processor/orchestrator.js +27 -0
  143. package/build/log-processor/orchestrator.js.map +1 -0
  144. package/build/logpoint-execution-tracker.d.ts +57 -0
  145. package/build/logpoint-execution-tracker.d.ts.map +1 -0
  146. package/build/logpoint-execution-tracker.js +112 -0
  147. package/build/logpoint-execution-tracker.js.map +1 -0
  148. package/build/mcp-supervisor.d.ts +3 -0
  149. package/build/mcp-supervisor.d.ts.map +1 -0
  150. package/build/mcp-supervisor.js +211 -0
  151. package/build/mcp-supervisor.js.map +1 -0
  152. package/build/messages.d.ts +165 -0
  153. package/build/messages.d.ts.map +1 -0
  154. package/build/messages.js +574 -0
  155. package/build/messages.js.map +1 -0
  156. package/build/network-monitor.d.ts +172 -0
  157. package/build/network-monitor.d.ts.map +1 -0
  158. package/build/network-monitor.js +350 -0
  159. package/build/network-monitor.js.map +1 -0
  160. package/build/overlays.d.ts +49 -0
  161. package/build/overlays.d.ts.map +1 -0
  162. package/build/overlays.js +409 -0
  163. package/build/overlays.js.map +1 -0
  164. package/build/persistent-profiles.test.d.ts +15 -0
  165. package/build/persistent-profiles.test.d.ts.map +1 -0
  166. package/build/persistent-profiles.test.js +470 -0
  167. package/build/persistent-profiles.test.js.map +1 -0
  168. package/build/port-reserver.d.ts +32 -0
  169. package/build/port-reserver.d.ts.map +1 -0
  170. package/build/port-reserver.js +118 -0
  171. package/build/port-reserver.js.map +1 -0
  172. package/build/puppeteer-manager.d.ts +47 -0
  173. package/build/puppeteer-manager.d.ts.map +1 -0
  174. package/build/puppeteer-manager.js +116 -0
  175. package/build/puppeteer-manager.js.map +1 -0
  176. package/build/recording-coverage.test.d.ts +12 -0
  177. package/build/recording-coverage.test.d.ts.map +1 -0
  178. package/build/recording-coverage.test.js +72 -0
  179. package/build/recording-coverage.test.js.map +1 -0
  180. package/build/reference-validator.d.ts +47 -0
  181. package/build/reference-validator.d.ts.map +1 -0
  182. package/build/reference-validator.js +86 -0
  183. package/build/reference-validator.js.map +1 -0
  184. package/build/reference-validator.test.d.ts +5 -0
  185. package/build/reference-validator.test.d.ts.map +1 -0
  186. package/build/reference-validator.test.js +243 -0
  187. package/build/reference-validator.test.js.map +1 -0
  188. package/build/replay-cursor.d.ts +27 -0
  189. package/build/replay-cursor.d.ts.map +1 -0
  190. package/build/replay-cursor.js +240 -0
  191. package/build/replay-cursor.js.map +1 -0
  192. package/build/runners/docker-compose-runner.d.ts +69 -0
  193. package/build/runners/docker-compose-runner.d.ts.map +1 -0
  194. package/build/runners/docker-compose-runner.js +438 -0
  195. package/build/runners/docker-compose-runner.js.map +1 -0
  196. package/build/runners/docker-runner.d.ts +65 -0
  197. package/build/runners/docker-runner.d.ts.map +1 -0
  198. package/build/runners/docker-runner.js +414 -0
  199. package/build/runners/docker-runner.js.map +1 -0
  200. package/build/runners/index.d.ts +19 -0
  201. package/build/runners/index.d.ts.map +1 -0
  202. package/build/runners/index.js +35 -0
  203. package/build/runners/index.js.map +1 -0
  204. package/build/runners/native-runner.d.ts +95 -0
  205. package/build/runners/native-runner.d.ts.map +1 -0
  206. package/build/runners/native-runner.js +370 -0
  207. package/build/runners/native-runner.js.map +1 -0
  208. package/build/runners/types.d.ts +147 -0
  209. package/build/runners/types.d.ts.map +1 -0
  210. package/build/runners/types.js +25 -0
  211. package/build/runners/types.js.map +1 -0
  212. package/build/self-restart.d.ts +12 -0
  213. package/build/self-restart.d.ts.map +1 -0
  214. package/build/self-restart.js +41 -0
  215. package/build/self-restart.js.map +1 -0
  216. package/build/self-restart.test.d.ts +2 -0
  217. package/build/self-restart.test.d.ts.map +1 -0
  218. package/build/self-restart.test.js +34 -0
  219. package/build/self-restart.test.js.map +1 -0
  220. package/build/server-claims.d.ts +161 -0
  221. package/build/server-claims.d.ts.map +1 -0
  222. package/build/server-claims.js +382 -0
  223. package/build/server-claims.js.map +1 -0
  224. package/build/server-claims.test.d.ts +2 -0
  225. package/build/server-claims.test.d.ts.map +1 -0
  226. package/build/server-claims.test.js +197 -0
  227. package/build/server-claims.test.js.map +1 -0
  228. package/build/server-manager.d.ts +438 -0
  229. package/build/server-manager.d.ts.map +1 -0
  230. package/build/server-manager.js +1674 -0
  231. package/build/server-manager.js.map +1 -0
  232. package/build/server-manager.test.d.ts +17 -0
  233. package/build/server-manager.test.d.ts.map +1 -0
  234. package/build/server-manager.test.js +122 -0
  235. package/build/server-manager.test.js.map +1 -0
  236. package/build/server-ownership.test.d.ts +2 -0
  237. package/build/server-ownership.test.d.ts.map +1 -0
  238. package/build/server-ownership.test.js +238 -0
  239. package/build/server-ownership.test.js.map +1 -0
  240. package/build/server-watcher.d.ts +21 -0
  241. package/build/server-watcher.d.ts.map +1 -0
  242. package/build/server-watcher.js +105 -0
  243. package/build/server-watcher.js.map +1 -0
  244. package/build/session-detector.d.ts +47 -0
  245. package/build/session-detector.d.ts.map +1 -0
  246. package/build/session-detector.js +229 -0
  247. package/build/session-detector.js.map +1 -0
  248. package/build/session-detector.test.d.ts +9 -0
  249. package/build/session-detector.test.d.ts.map +1 -0
  250. package/build/session-detector.test.js +45 -0
  251. package/build/session-detector.test.js.map +1 -0
  252. package/build/sourcemap-handler.d.ts +114 -0
  253. package/build/sourcemap-handler.d.ts.map +1 -0
  254. package/build/sourcemap-handler.js +479 -0
  255. package/build/sourcemap-handler.js.map +1 -0
  256. package/build/supervisor/child-manager.d.ts +43 -0
  257. package/build/supervisor/child-manager.d.ts.map +1 -0
  258. package/build/supervisor/child-manager.js +148 -0
  259. package/build/supervisor/child-manager.js.map +1 -0
  260. package/build/supervisor/child-manager.test.d.ts +2 -0
  261. package/build/supervisor/child-manager.test.d.ts.map +1 -0
  262. package/build/supervisor/child-manager.test.js +107 -0
  263. package/build/supervisor/child-manager.test.js.map +1 -0
  264. package/build/supervisor/client-watcher.d.ts +48 -0
  265. package/build/supervisor/client-watcher.d.ts.map +1 -0
  266. package/build/supervisor/client-watcher.js +186 -0
  267. package/build/supervisor/client-watcher.js.map +1 -0
  268. package/build/supervisor/client-watcher.test.d.ts +2 -0
  269. package/build/supervisor/client-watcher.test.d.ts.map +1 -0
  270. package/build/supervisor/client-watcher.test.js +121 -0
  271. package/build/supervisor/client-watcher.test.js.map +1 -0
  272. package/build/supervisor/idle-config.d.ts +30 -0
  273. package/build/supervisor/idle-config.d.ts.map +1 -0
  274. package/build/supervisor/idle-config.js +76 -0
  275. package/build/supervisor/idle-config.js.map +1 -0
  276. package/build/supervisor/idle-config.test.d.ts +2 -0
  277. package/build/supervisor/idle-config.test.d.ts.map +1 -0
  278. package/build/supervisor/idle-config.test.js +119 -0
  279. package/build/supervisor/idle-config.test.js.map +1 -0
  280. package/build/supervisor/ndjson-reader.d.ts +47 -0
  281. package/build/supervisor/ndjson-reader.d.ts.map +1 -0
  282. package/build/supervisor/ndjson-reader.js +75 -0
  283. package/build/supervisor/ndjson-reader.js.map +1 -0
  284. package/build/supervisor/ndjson-reader.test.d.ts +2 -0
  285. package/build/supervisor/ndjson-reader.test.d.ts.map +1 -0
  286. package/build/supervisor/ndjson-reader.test.js +92 -0
  287. package/build/supervisor/ndjson-reader.test.js.map +1 -0
  288. package/build/supervisor/pidfile.d.ts +11 -0
  289. package/build/supervisor/pidfile.d.ts.map +1 -0
  290. package/build/supervisor/pidfile.js +29 -0
  291. package/build/supervisor/pidfile.js.map +1 -0
  292. package/build/supervisor/pidfile.test.d.ts +8 -0
  293. package/build/supervisor/pidfile.test.d.ts.map +1 -0
  294. package/build/supervisor/pidfile.test.js +46 -0
  295. package/build/supervisor/pidfile.test.js.map +1 -0
  296. package/build/supervisor/restart-coordinator.d.ts +73 -0
  297. package/build/supervisor/restart-coordinator.d.ts.map +1 -0
  298. package/build/supervisor/restart-coordinator.js +300 -0
  299. package/build/supervisor/restart-coordinator.js.map +1 -0
  300. package/build/supervisor/restart-coordinator.test.d.ts +2 -0
  301. package/build/supervisor/restart-coordinator.test.d.ts.map +1 -0
  302. package/build/supervisor/restart-coordinator.test.js +434 -0
  303. package/build/supervisor/restart-coordinator.test.js.map +1 -0
  304. package/build/test-support/fake-execute-tool-call.d.ts +11 -0
  305. package/build/test-support/fake-execute-tool-call.d.ts.map +1 -0
  306. package/build/test-support/fake-execute-tool-call.js +19 -0
  307. package/build/test-support/fake-execute-tool-call.js.map +1 -0
  308. package/build/tool-error.d.ts +14 -0
  309. package/build/tool-error.d.ts.map +1 -0
  310. package/build/tool-error.js +18 -0
  311. package/build/tool-error.js.map +1 -0
  312. package/build/tool-response.d.ts +293 -0
  313. package/build/tool-response.d.ts.map +1 -0
  314. package/build/tool-response.js +365 -0
  315. package/build/tool-response.js.map +1 -0
  316. package/build/tools/assert-tools.d.ts +62 -0
  317. package/build/tools/assert-tools.d.ts.map +1 -0
  318. package/build/tools/assert-tools.js +330 -0
  319. package/build/tools/assert-tools.js.map +1 -0
  320. package/build/tools/breakpoint-await-abort.test.d.ts +2 -0
  321. package/build/tools/breakpoint-await-abort.test.d.ts.map +1 -0
  322. package/build/tools/breakpoint-await-abort.test.js +124 -0
  323. package/build/tools/breakpoint-await-abort.test.js.map +1 -0
  324. package/build/tools/breakpoint-tools.d.ts +99 -0
  325. package/build/tools/breakpoint-tools.d.ts.map +1 -0
  326. package/build/tools/breakpoint-tools.js +1197 -0
  327. package/build/tools/breakpoint-tools.js.map +1 -0
  328. package/build/tools/config-tools.d.ts +58 -0
  329. package/build/tools/config-tools.d.ts.map +1 -0
  330. package/build/tools/config-tools.js +180 -0
  331. package/build/tools/config-tools.js.map +1 -0
  332. package/build/tools/connection-routing.test.d.ts +12 -0
  333. package/build/tools/connection-routing.test.d.ts.map +1 -0
  334. package/build/tools/connection-routing.test.js +206 -0
  335. package/build/tools/connection-routing.test.js.map +1 -0
  336. package/build/tools/console-tools.d.ts +84 -0
  337. package/build/tools/console-tools.d.ts.map +1 -0
  338. package/build/tools/console-tools.js +241 -0
  339. package/build/tools/console-tools.js.map +1 -0
  340. package/build/tools/content-tools.d.ts +74 -0
  341. package/build/tools/content-tools.d.ts.map +1 -0
  342. package/build/tools/content-tools.js +582 -0
  343. package/build/tools/content-tools.js.map +1 -0
  344. package/build/tools/dashboard-tools.d.ts +38 -0
  345. package/build/tools/dashboard-tools.d.ts.map +1 -0
  346. package/build/tools/dashboard-tools.js +123 -0
  347. package/build/tools/dashboard-tools.js.map +1 -0
  348. package/build/tools/dom-tools.d.ts +41 -0
  349. package/build/tools/dom-tools.d.ts.map +1 -0
  350. package/build/tools/dom-tools.js +277 -0
  351. package/build/tools/dom-tools.js.map +1 -0
  352. package/build/tools/download-tools.d.ts +55 -0
  353. package/build/tools/download-tools.d.ts.map +1 -0
  354. package/build/tools/download-tools.js +280 -0
  355. package/build/tools/download-tools.js.map +1 -0
  356. package/build/tools/execution-tools.d.ts +40 -0
  357. package/build/tools/execution-tools.d.ts.map +1 -0
  358. package/build/tools/execution-tools.js +121 -0
  359. package/build/tools/execution-tools.js.map +1 -0
  360. package/build/tools/input-abort.test.d.ts +2 -0
  361. package/build/tools/input-abort.test.d.ts.map +1 -0
  362. package/build/tools/input-abort.test.js +227 -0
  363. package/build/tools/input-abort.test.js.map +1 -0
  364. package/build/tools/input-ambiguous-selector.test.d.ts +2 -0
  365. package/build/tools/input-ambiguous-selector.test.d.ts.map +1 -0
  366. package/build/tools/input-ambiguous-selector.test.js +34 -0
  367. package/build/tools/input-ambiguous-selector.test.js.map +1 -0
  368. package/build/tools/input-tools.d.ts +168 -0
  369. package/build/tools/input-tools.d.ts.map +1 -0
  370. package/build/tools/input-tools.js +1397 -0
  371. package/build/tools/input-tools.js.map +1 -0
  372. package/build/tools/inspection-tools.d.ts +112 -0
  373. package/build/tools/inspection-tools.d.ts.map +1 -0
  374. package/build/tools/inspection-tools.js +637 -0
  375. package/build/tools/inspection-tools.js.map +1 -0
  376. package/build/tools/interpolation.d.ts +30 -0
  377. package/build/tools/interpolation.d.ts.map +1 -0
  378. package/build/tools/interpolation.js +143 -0
  379. package/build/tools/interpolation.js.map +1 -0
  380. package/build/tools/issues-abort-hygiene.test.d.ts +2 -0
  381. package/build/tools/issues-abort-hygiene.test.d.ts.map +1 -0
  382. package/build/tools/issues-abort-hygiene.test.js +79 -0
  383. package/build/tools/issues-abort-hygiene.test.js.map +1 -0
  384. package/build/tools/issues-tools.d.ts +98 -0
  385. package/build/tools/issues-tools.d.ts.map +1 -0
  386. package/build/tools/issues-tools.js +821 -0
  387. package/build/tools/issues-tools.js.map +1 -0
  388. package/build/tools/issues-tools.test.d.ts +8 -0
  389. package/build/tools/issues-tools.test.d.ts.map +1 -0
  390. package/build/tools/issues-tools.test.js +184 -0
  391. package/build/tools/issues-tools.test.js.map +1 -0
  392. package/build/tools/modal-tools.d.ts +73 -0
  393. package/build/tools/modal-tools.d.ts.map +1 -0
  394. package/build/tools/modal-tools.js +161 -0
  395. package/build/tools/modal-tools.js.map +1 -0
  396. package/build/tools/network-tools.d.ts +72 -0
  397. package/build/tools/network-tools.d.ts.map +1 -0
  398. package/build/tools/network-tools.js +432 -0
  399. package/build/tools/network-tools.js.map +1 -0
  400. package/build/tools/page-tools.d.ts +78 -0
  401. package/build/tools/page-tools.d.ts.map +1 -0
  402. package/build/tools/page-tools.js +255 -0
  403. package/build/tools/page-tools.js.map +1 -0
  404. package/build/tools/plugin-tools.d.ts +16 -0
  405. package/build/tools/plugin-tools.d.ts.map +1 -0
  406. package/build/tools/plugin-tools.js +17 -0
  407. package/build/tools/plugin-tools.js.map +1 -0
  408. package/build/tools/replay-abort.test.d.ts +2 -0
  409. package/build/tools/replay-abort.test.d.ts.map +1 -0
  410. package/build/tools/replay-abort.test.js +259 -0
  411. package/build/tools/replay-abort.test.js.map +1 -0
  412. package/build/tools/replay-add-conditional.test.d.ts +2 -0
  413. package/build/tools/replay-add-conditional.test.d.ts.map +1 -0
  414. package/build/tools/replay-add-conditional.test.js +205 -0
  415. package/build/tools/replay-add-conditional.test.js.map +1 -0
  416. package/build/tools/replay-background-run.test.d.ts +2 -0
  417. package/build/tools/replay-background-run.test.d.ts.map +1 -0
  418. package/build/tools/replay-background-run.test.js +176 -0
  419. package/build/tools/replay-background-run.test.js.map +1 -0
  420. package/build/tools/replay-capture-variables.test.d.ts +2 -0
  421. package/build/tools/replay-capture-variables.test.d.ts.map +1 -0
  422. package/build/tools/replay-capture-variables.test.js +331 -0
  423. package/build/tools/replay-capture-variables.test.js.map +1 -0
  424. package/build/tools/replay-conditional-idb-and-launch.test.d.ts +11 -0
  425. package/build/tools/replay-conditional-idb-and-launch.test.d.ts.map +1 -0
  426. package/build/tools/replay-conditional-idb-and-launch.test.js +429 -0
  427. package/build/tools/replay-conditional-idb-and-launch.test.js.map +1 -0
  428. package/build/tools/replay-conditional-timeout.test.d.ts +14 -0
  429. package/build/tools/replay-conditional-timeout.test.d.ts.map +1 -0
  430. package/build/tools/replay-conditional-timeout.test.js +126 -0
  431. package/build/tools/replay-conditional-timeout.test.js.map +1 -0
  432. package/build/tools/replay-declare.test.d.ts +2 -0
  433. package/build/tools/replay-declare.test.d.ts.map +1 -0
  434. package/build/tools/replay-declare.test.js +106 -0
  435. package/build/tools/replay-declare.test.js.map +1 -0
  436. package/build/tools/replay-declared-browser-cleanup.test.d.ts +2 -0
  437. package/build/tools/replay-declared-browser-cleanup.test.d.ts.map +1 -0
  438. package/build/tools/replay-declared-browser-cleanup.test.js +103 -0
  439. package/build/tools/replay-declared-browser-cleanup.test.js.map +1 -0
  440. package/build/tools/replay-declared-profile.test.d.ts +2 -0
  441. package/build/tools/replay-declared-profile.test.d.ts.map +1 -0
  442. package/build/tools/replay-declared-profile.test.js +116 -0
  443. package/build/tools/replay-declared-profile.test.js.map +1 -0
  444. package/build/tools/replay-executor.d.ts +556 -0
  445. package/build/tools/replay-executor.d.ts.map +1 -0
  446. package/build/tools/replay-executor.js +2347 -0
  447. package/build/tools/replay-executor.js.map +1 -0
  448. package/build/tools/replay-folder-save.test.d.ts +2 -0
  449. package/build/tools/replay-folder-save.test.d.ts.map +1 -0
  450. package/build/tools/replay-folder-save.test.js +63 -0
  451. package/build/tools/replay-folder-save.test.js.map +1 -0
  452. package/build/tools/replay-formatters.d.ts +148 -0
  453. package/build/tools/replay-formatters.d.ts.map +1 -0
  454. package/build/tools/replay-formatters.js +856 -0
  455. package/build/tools/replay-formatters.js.map +1 -0
  456. package/build/tools/replay-kill-chrome-on-finish.test.d.ts +2 -0
  457. package/build/tools/replay-kill-chrome-on-finish.test.d.ts.map +1 -0
  458. package/build/tools/replay-kill-chrome-on-finish.test.js +175 -0
  459. package/build/tools/replay-kill-chrome-on-finish.test.js.map +1 -0
  460. package/build/tools/replay-multi-connection.test.d.ts +2 -0
  461. package/build/tools/replay-multi-connection.test.d.ts.map +1 -0
  462. package/build/tools/replay-multi-connection.test.js +547 -0
  463. package/build/tools/replay-multi-connection.test.js.map +1 -0
  464. package/build/tools/replay-output-and-record-options.test.d.ts +2 -0
  465. package/build/tools/replay-output-and-record-options.test.d.ts.map +1 -0
  466. package/build/tools/replay-output-and-record-options.test.js +240 -0
  467. package/build/tools/replay-output-and-record-options.test.js.map +1 -0
  468. package/build/tools/replay-production-error-shape.test.d.ts +7 -0
  469. package/build/tools/replay-production-error-shape.test.d.ts.map +1 -0
  470. package/build/tools/replay-production-error-shape.test.js +93 -0
  471. package/build/tools/replay-production-error-shape.test.js.map +1 -0
  472. package/build/tools/replay-rebase.test.d.ts +2 -0
  473. package/build/tools/replay-rebase.test.d.ts.map +1 -0
  474. package/build/tools/replay-rebase.test.js +58 -0
  475. package/build/tools/replay-rebase.test.js.map +1 -0
  476. package/build/tools/replay-retry-classification.test.d.ts +9 -0
  477. package/build/tools/replay-retry-classification.test.d.ts.map +1 -0
  478. package/build/tools/replay-retry-classification.test.js +57 -0
  479. package/build/tools/replay-retry-classification.test.js.map +1 -0
  480. package/build/tools/replay-run-registry.d.ts +55 -0
  481. package/build/tools/replay-run-registry.d.ts.map +1 -0
  482. package/build/tools/replay-run-registry.js +65 -0
  483. package/build/tools/replay-run-registry.js.map +1 -0
  484. package/build/tools/replay-sequence-reload.test.d.ts +2 -0
  485. package/build/tools/replay-sequence-reload.test.d.ts.map +1 -0
  486. package/build/tools/replay-sequence-reload.test.js +82 -0
  487. package/build/tools/replay-sequence-reload.test.js.map +1 -0
  488. package/build/tools/replay-socket-scope.test.d.ts +2 -0
  489. package/build/tools/replay-socket-scope.test.d.ts.map +1 -0
  490. package/build/tools/replay-socket-scope.test.js +75 -0
  491. package/build/tools/replay-socket-scope.test.js.map +1 -0
  492. package/build/tools/replay-step-connection.test.d.ts +2 -0
  493. package/build/tools/replay-step-connection.test.d.ts.map +1 -0
  494. package/build/tools/replay-step-connection.test.js +292 -0
  495. package/build/tools/replay-step-connection.test.js.map +1 -0
  496. package/build/tools/replay-step-timeout.test.d.ts +2 -0
  497. package/build/tools/replay-step-timeout.test.d.ts.map +1 -0
  498. package/build/tools/replay-step-timeout.test.js +204 -0
  499. package/build/tools/replay-step-timeout.test.js.map +1 -0
  500. package/build/tools/replay-tags.test.d.ts +2 -0
  501. package/build/tools/replay-tags.test.d.ts.map +1 -0
  502. package/build/tools/replay-tags.test.js +99 -0
  503. package/build/tools/replay-tags.test.js.map +1 -0
  504. package/build/tools/replay-teardown-and-foreach.test.d.ts +13 -0
  505. package/build/tools/replay-teardown-and-foreach.test.d.ts.map +1 -0
  506. package/build/tools/replay-teardown-and-foreach.test.js +318 -0
  507. package/build/tools/replay-teardown-and-foreach.test.js.map +1 -0
  508. package/build/tools/replay-tool-name-validation.test.d.ts +2 -0
  509. package/build/tools/replay-tool-name-validation.test.d.ts.map +1 -0
  510. package/build/tools/replay-tool-name-validation.test.js +280 -0
  511. package/build/tools/replay-tool-name-validation.test.js.map +1 -0
  512. package/build/tools/replay-tools.d.ts +288 -0
  513. package/build/tools/replay-tools.d.ts.map +1 -0
  514. package/build/tools/replay-tools.js +2994 -0
  515. package/build/tools/replay-tools.js.map +1 -0
  516. package/build/tools/request-abort.test.d.ts +2 -0
  517. package/build/tools/request-abort.test.d.ts.map +1 -0
  518. package/build/tools/request-abort.test.js +130 -0
  519. package/build/tools/request-abort.test.js.map +1 -0
  520. package/build/tools/request-tools.d.ts +56 -0
  521. package/build/tools/request-tools.d.ts.map +1 -0
  522. package/build/tools/request-tools.js +174 -0
  523. package/build/tools/request-tools.js.map +1 -0
  524. package/build/tools/screenshot-tools.d.ts +135 -0
  525. package/build/tools/screenshot-tools.d.ts.map +1 -0
  526. package/build/tools/screenshot-tools.js +636 -0
  527. package/build/tools/screenshot-tools.js.map +1 -0
  528. package/build/tools/server-tools.d.ts +88 -0
  529. package/build/tools/server-tools.d.ts.map +1 -0
  530. package/build/tools/server-tools.js +485 -0
  531. package/build/tools/server-tools.js.map +1 -0
  532. package/build/tools/source-tools.d.ts +46 -0
  533. package/build/tools/source-tools.d.ts.map +1 -0
  534. package/build/tools/source-tools.js +47 -0
  535. package/build/tools/source-tools.js.map +1 -0
  536. package/build/tools/storage-tools.d.ts +141 -0
  537. package/build/tools/storage-tools.d.ts.map +1 -0
  538. package/build/tools/storage-tools.js +894 -0
  539. package/build/tools/storage-tools.js.map +1 -0
  540. package/build/tools/storage-tools.test.d.ts +13 -0
  541. package/build/tools/storage-tools.test.d.ts.map +1 -0
  542. package/build/tools/storage-tools.test.js +707 -0
  543. package/build/tools/storage-tools.test.js.map +1 -0
  544. package/build/tools/tab-tools.d.ts +42 -0
  545. package/build/tools/tab-tools.d.ts.map +1 -0
  546. package/build/tools/tab-tools.js +296 -0
  547. package/build/tools/tab-tools.js.map +1 -0
  548. package/build/tools/wait-tools.d.ts +85 -0
  549. package/build/tools/wait-tools.d.ts.map +1 -0
  550. package/build/tools/wait-tools.js +236 -0
  551. package/build/tools/wait-tools.js.map +1 -0
  552. package/build/tools/wait-tools.test.d.ts +9 -0
  553. package/build/tools/wait-tools.test.d.ts.map +1 -0
  554. package/build/tools/wait-tools.test.js +193 -0
  555. package/build/tools/wait-tools.test.js.map +1 -0
  556. package/build/types.d.ts +133 -0
  557. package/build/types.d.ts.map +1 -0
  558. package/build/types.js +5 -0
  559. package/build/types.js.map +1 -0
  560. package/build/ui-verifier.d.ts +88 -0
  561. package/build/ui-verifier.d.ts.map +1 -0
  562. package/build/ui-verifier.js +540 -0
  563. package/build/ui-verifier.js.map +1 -0
  564. package/build/utils/abort.d.ts +68 -0
  565. package/build/utils/abort.d.ts.map +1 -0
  566. package/build/utils/abort.js +159 -0
  567. package/build/utils/abort.js.map +1 -0
  568. package/build/utils/abort.test.d.ts +2 -0
  569. package/build/utils/abort.test.d.ts.map +1 -0
  570. package/build/utils/abort.test.js +174 -0
  571. package/build/utils/abort.test.js.map +1 -0
  572. package/build/utils/modal-detection-core.d.ts +150 -0
  573. package/build/utils/modal-detection-core.d.ts.map +1 -0
  574. package/build/utils/modal-detection-core.js +332 -0
  575. package/build/utils/modal-detection-core.js.map +1 -0
  576. package/build/utils/modal-detection-core.test.d.ts +5 -0
  577. package/build/utils/modal-detection-core.test.d.ts.map +1 -0
  578. package/build/utils/modal-detection-core.test.js +492 -0
  579. package/build/utils/modal-detection-core.test.js.map +1 -0
  580. package/build/utils/modal-detector.d.ts +29 -0
  581. package/build/utils/modal-detector.d.ts.map +1 -0
  582. package/build/utils/modal-detector.js +281 -0
  583. package/build/utils/modal-detector.js.map +1 -0
  584. package/build/utils/modal-dismissal.d.ts +32 -0
  585. package/build/utils/modal-dismissal.d.ts.map +1 -0
  586. package/build/utils/modal-dismissal.js +190 -0
  587. package/build/utils/modal-dismissal.js.map +1 -0
  588. package/build/utils/port-check.d.ts +31 -0
  589. package/build/utils/port-check.d.ts.map +1 -0
  590. package/build/utils/port-check.js +87 -0
  591. package/build/utils/port-check.js.map +1 -0
  592. package/build/utils/port-check.test.d.ts +2 -0
  593. package/build/utils/port-check.test.d.ts.map +1 -0
  594. package/build/utils/port-check.test.js +66 -0
  595. package/build/utils/port-check.test.js.map +1 -0
  596. package/build/utils/selector-resolver.d.ts +66 -0
  597. package/build/utils/selector-resolver.d.ts.map +1 -0
  598. package/build/utils/selector-resolver.js +200 -0
  599. package/build/utils/selector-resolver.js.map +1 -0
  600. package/build/validation-helpers.d.ts +41 -0
  601. package/build/validation-helpers.d.ts.map +1 -0
  602. package/build/validation-helpers.js +236 -0
  603. package/build/validation-helpers.js.map +1 -0
  604. package/build/window-sizing.d.ts +26 -0
  605. package/build/window-sizing.d.ts.map +1 -0
  606. package/build/window-sizing.js +87 -0
  607. package/build/window-sizing.js.map +1 -0
  608. package/build/window-sizing.test.d.ts +8 -0
  609. package/build/window-sizing.test.d.ts.map +1 -0
  610. package/build/window-sizing.test.js +113 -0
  611. package/build/window-sizing.test.js.map +1 -0
  612. package/docs/README.md +74 -0
  613. package/docs/automation.md +562 -0
  614. package/docs/debugging.md +229 -0
  615. package/docs/installation.md +133 -0
  616. package/docs/instructions.md +227 -0
  617. package/docs/mcp-instructions.md +15 -0
  618. package/docs/message-system.md +327 -0
  619. package/docs/messages.md +3480 -0
  620. package/docs/parser-plugins.md +132 -0
  621. package/docs/replay.md +1411 -0
  622. package/docs/troubleshooting.md +272 -0
  623. package/docs/working_with_llm_notes.md +5 -0
  624. package/package.json +87 -0
  625. package/skills/devharness/SKILL.md +195 -0
  626. package/skills/devharness/references/sequences.md +613 -0
  627. package/skills/devharness/references/tool-categories.md +99 -0
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Modal detection utilities for Puppeteer pages
3
+ *
4
+ * This module provides functions to detect and classify modals on web pages.
5
+ * It uses the core detection logic from modal-detection-core.ts and executes
6
+ * it in the browser context via page.evaluate().
7
+ */
8
+ import { debugLog } from '../debug-logger.js';
9
+ import { MODAL_PATTERNS, COMMON_MODAL_SELECTORS, isElementBlockingViewport, isBasicVisible, isBlockingPosition, hasMinimumZIndex, coversMinimumViewport, isVisibleOnTop, classifyModal, getDismissStrategies, getUniqueSelector, } from './modal-detection-core.js';
10
+ /**
11
+ * Detects modals and blocking overlays on the page
12
+ *
13
+ * This is the fixed implementation that uses elementFromPoint for reliable detection
14
+ */
15
+ export async function detectModals(page, options = {}) {
16
+ const { minZIndex = 100, minViewportCoverage = 0.25, includeBackdrops = true, } = options;
17
+ const pageUrl = page.url();
18
+ await debugLog('ModalDetector', `Detecting modals on page: ${pageUrl}`);
19
+ await debugLog('ModalDetector', `Options: minZIndex=${minZIndex}, minViewportCoverage=${minViewportCoverage}, includeBackdrops=${includeBackdrops}`);
20
+ // Serialize RegExp patterns in MODAL_PATTERNS to strings
21
+ const serializedPatterns = {
22
+ cookieConsent: {
23
+ ...MODAL_PATTERNS.cookieConsent,
24
+ textPatterns: MODAL_PATTERNS.cookieConsent.textPatterns.source,
25
+ textPatternsFlags: MODAL_PATTERNS.cookieConsent.textPatterns.flags,
26
+ },
27
+ newsletter: {
28
+ ...MODAL_PATTERNS.newsletter,
29
+ textPatterns: MODAL_PATTERNS.newsletter.textPatterns.source,
30
+ textPatternsFlags: MODAL_PATTERNS.newsletter.textPatterns.flags,
31
+ },
32
+ ageVerification: {
33
+ ...MODAL_PATTERNS.ageVerification,
34
+ textPatterns: MODAL_PATTERNS.ageVerification.textPatterns.source,
35
+ textPatternsFlags: MODAL_PATTERNS.ageVerification.textPatterns.flags,
36
+ },
37
+ genericDialog: {
38
+ ...MODAL_PATTERNS.genericDialog,
39
+ textPatterns: null,
40
+ textPatternsFlags: null,
41
+ },
42
+ };
43
+ // Serialize functions and data to pass into browser context
44
+ const modals = await page.evaluate((opts) => {
45
+ const { minZIndex, minViewportCoverage, includeBackdrops, modalPatterns, commonSelectors, isBasicVisibleFn, isBlockingPositionFn, hasMinimumZIndexFn, coversMinimumViewportFn, isVisibleOnTopFn, isElementBlockingViewportFn, classifyModalFn, getDismissStrategiesFn, getUniqueSelectorFn, } = opts;
46
+ const global = globalThis;
47
+ // Reconstruct RegExp patterns from serialized strings
48
+ const reconstructedPatterns = {
49
+ cookieConsent: {
50
+ ...modalPatterns.cookieConsent,
51
+ textPatterns: new RegExp(modalPatterns.cookieConsent.textPatterns, modalPatterns.cookieConsent.textPatternsFlags),
52
+ },
53
+ newsletter: {
54
+ ...modalPatterns.newsletter,
55
+ textPatterns: new RegExp(modalPatterns.newsletter.textPatterns, modalPatterns.newsletter.textPatternsFlags),
56
+ },
57
+ ageVerification: {
58
+ ...modalPatterns.ageVerification,
59
+ textPatterns: new RegExp(modalPatterns.ageVerification.textPatterns, modalPatterns.ageVerification.textPatternsFlags),
60
+ },
61
+ genericDialog: {
62
+ ...modalPatterns.genericDialog,
63
+ textPatterns: null,
64
+ },
65
+ };
66
+ // Reconstruct helper functions first (needed by isElementBlockingViewport)
67
+ // Use eval without parentheses to define functions in scope
68
+ // eslint-disable-next-line no-eval
69
+ eval(isBasicVisibleFn);
70
+ // eslint-disable-next-line no-eval
71
+ eval(isBlockingPositionFn);
72
+ // eslint-disable-next-line no-eval
73
+ eval(hasMinimumZIndexFn);
74
+ // eslint-disable-next-line no-eval
75
+ eval(coversMinimumViewportFn);
76
+ // eslint-disable-next-line no-eval
77
+ eval(isVisibleOnTopFn);
78
+ // Now reconstruct main functions (these depend on the helpers above)
79
+ // eslint-disable-next-line no-eval
80
+ eval(isElementBlockingViewportFn);
81
+ // eslint-disable-next-line no-eval
82
+ eval(classifyModalFn);
83
+ // eslint-disable-next-line no-eval
84
+ eval(getDismissStrategiesFn);
85
+ // eslint-disable-next-line no-eval
86
+ eval(getUniqueSelectorFn);
87
+ // Reference the now-defined functions
88
+ // @ts-ignore - Functions are defined by eval above
89
+ const isElementBlockingViewportFunc = isElementBlockingViewport;
90
+ // @ts-ignore
91
+ const classifyModalFunc = classifyModal;
92
+ // @ts-ignore
93
+ const getDismissStrategiesFunc = getDismissStrategies;
94
+ // @ts-ignore
95
+ const getUniqueSelectorFunc = getUniqueSelector;
96
+ const detectedModals = [];
97
+ const candidateElements = [];
98
+ // Scan using common selectors
99
+ commonSelectors.forEach((selector) => {
100
+ try {
101
+ const elements = global.document.querySelectorAll(selector);
102
+ elements.forEach((el) => {
103
+ if (!candidateElements.includes(el) &&
104
+ isElementBlockingViewportFunc(el, minZIndex, minViewportCoverage)) {
105
+ candidateElements.push(el);
106
+ }
107
+ });
108
+ }
109
+ catch (e) {
110
+ // Ignore selector errors
111
+ }
112
+ });
113
+ // Fallback: scan all fixed/absolute positioned elements if no candidates found
114
+ if (candidateElements.length === 0) {
115
+ const allElements = global.document.querySelectorAll('*');
116
+ allElements.forEach((el) => {
117
+ const style = global.window.getComputedStyle(el);
118
+ if ((style.position === 'fixed' || style.position === 'absolute') &&
119
+ isElementBlockingViewportFunc(el, minZIndex, minViewportCoverage)) {
120
+ candidateElements.push(el);
121
+ }
122
+ });
123
+ }
124
+ // Process candidates
125
+ candidateElements.forEach((el, idx) => {
126
+ try {
127
+ const rect = el.getBoundingClientRect();
128
+ const style = global.window.getComputedStyle(el);
129
+ const zIndex = parseInt(style.zIndex, 10) || 0;
130
+ const classification = classifyModalFunc(el, reconstructedPatterns);
131
+ const strategies = getDismissStrategiesFunc(el, classification.type);
132
+ // Filter out backdrops if requested
133
+ if (!includeBackdrops && classification.type === 'blocking-overlay') {
134
+ return;
135
+ }
136
+ const selector = getUniqueSelectorFunc(el);
137
+ detectedModals.push({
138
+ selector: selector,
139
+ type: classification.type,
140
+ zIndex,
141
+ boundingBox: {
142
+ x: rect.left,
143
+ y: rect.top,
144
+ width: rect.width,
145
+ height: rect.height,
146
+ },
147
+ dismissStrategies: strategies,
148
+ confidence: classification.confidence,
149
+ description: classification.description,
150
+ });
151
+ }
152
+ catch (e) {
153
+ // Ignore errors processing individual candidates
154
+ }
155
+ });
156
+ // Sort by z-index (highest first) and confidence
157
+ detectedModals.sort((a, b) => {
158
+ if (b.zIndex !== a.zIndex) {
159
+ return b.zIndex - a.zIndex;
160
+ }
161
+ return b.confidence - a.confidence;
162
+ });
163
+ return detectedModals;
164
+ }, {
165
+ minZIndex,
166
+ minViewportCoverage,
167
+ includeBackdrops,
168
+ modalPatterns: serializedPatterns,
169
+ commonSelectors: COMMON_MODAL_SELECTORS,
170
+ // Serialize helper functions first
171
+ isBasicVisibleFn: isBasicVisible.toString(),
172
+ isBlockingPositionFn: isBlockingPosition.toString(),
173
+ hasMinimumZIndexFn: hasMinimumZIndex.toString(),
174
+ coversMinimumViewportFn: coversMinimumViewport.toString(),
175
+ isVisibleOnTopFn: isVisibleOnTop.toString(),
176
+ // Then serialize main functions
177
+ isElementBlockingViewportFn: isElementBlockingViewport.toString(),
178
+ classifyModalFn: classifyModal.toString(),
179
+ getDismissStrategiesFn: getDismissStrategies.toString(),
180
+ getUniqueSelectorFn: getUniqueSelector.toString(),
181
+ });
182
+ await debugLog('ModalDetector', `Detected ${modals.length} modal(s)`);
183
+ return modals;
184
+ }
185
+ /**
186
+ * Checks if a specific element is blocked by a modal/overlay
187
+ *
188
+ * This uses the reverse approach (elementFromPoint) which is more reliable
189
+ * than proactive scanning
190
+ */
191
+ export async function isElementBlocked(page, selector) {
192
+ await debugLog('ModalDetector', `Checking if element ${selector} is blocked`);
193
+ const result = await page.evaluate((sel) => {
194
+ const global = globalThis;
195
+ const element = global.document.querySelector(sel);
196
+ if (!element) {
197
+ return { blocked: false, error: 'Element not found' };
198
+ }
199
+ const rect = element.getBoundingClientRect();
200
+ const centerX = rect.left + rect.width / 2;
201
+ const centerY = rect.top + rect.height / 2;
202
+ // Check what element is at the target's center point
203
+ const topElement = global.document.elementFromPoint(centerX, centerY);
204
+ if (!topElement) {
205
+ return { blocked: false };
206
+ }
207
+ // If the top element is the target or a child, it's not blocked
208
+ if (topElement === element || element.contains(topElement)) {
209
+ return { blocked: false };
210
+ }
211
+ // Find the blocking element's topmost ancestor that's fixed/absolute
212
+ let blockingElement = topElement;
213
+ while (blockingElement && blockingElement !== global.document.body) {
214
+ const style = global.window.getComputedStyle(blockingElement);
215
+ const position = style.position;
216
+ if (position === 'fixed' || position === 'absolute') {
217
+ const zIndex = parseInt(style.zIndex, 10) || 0;
218
+ const blockingRect = blockingElement.getBoundingClientRect();
219
+ // Generate selector for blocking element
220
+ let blockingSelector;
221
+ if (blockingElement.id) {
222
+ blockingSelector = `#${blockingElement.id}`;
223
+ }
224
+ else if (blockingElement.className && typeof blockingElement.className === 'string') {
225
+ const classes = blockingElement.className.split(/\s+/).filter(Boolean);
226
+ blockingSelector = classes.length > 0 ? `.${classes[0]}` : blockingElement.tagName.toLowerCase();
227
+ }
228
+ else {
229
+ blockingSelector = blockingElement.tagName.toLowerCase();
230
+ }
231
+ return {
232
+ blocked: true,
233
+ blockingElement: {
234
+ selector: blockingSelector,
235
+ zIndex,
236
+ boundingBox: {
237
+ x: blockingRect.left,
238
+ y: blockingRect.top,
239
+ width: blockingRect.width,
240
+ height: blockingRect.height,
241
+ },
242
+ },
243
+ };
244
+ }
245
+ blockingElement = blockingElement.parentElement;
246
+ }
247
+ return { blocked: true, blockingElement: null };
248
+ }, selector);
249
+ if (!result.blocked) {
250
+ await debugLog('ModalDetector', `Element ${selector} is not blocked`);
251
+ return { blocked: false };
252
+ }
253
+ // If we found a blocking element, try to classify it
254
+ if (result.blockingElement) {
255
+ const modals = await detectModals(page);
256
+ const matchingModal = modals.find(m => m.selector === result.blockingElement.selector);
257
+ if (matchingModal) {
258
+ await debugLog('ModalDetector', `Element ${selector} is blocked by modal: ${matchingModal.type}`);
259
+ return {
260
+ blocked: true,
261
+ blockingModal: matchingModal,
262
+ };
263
+ }
264
+ else {
265
+ await debugLog('ModalDetector', `Element ${selector} is blocked by unknown element`);
266
+ return {
267
+ blocked: true,
268
+ blockingModal: {
269
+ ...result.blockingElement,
270
+ type: 'unknown',
271
+ dismissStrategies: ['remove'],
272
+ confidence: 50,
273
+ description: 'Unknown blocking element',
274
+ },
275
+ };
276
+ }
277
+ }
278
+ await debugLog('ModalDetector', `Element ${selector} is blocked (reason unknown)`);
279
+ return { blocked: true };
280
+ }
281
+ //# sourceMappingURL=modal-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-detector.js","sourceRoot":"","sources":["../../src/utils/modal-detector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAS9C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAMnC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAU,EACV,UAAiC,EAAE;IAEnC,MAAM,EACJ,SAAS,GAAG,GAAG,EACf,mBAAmB,GAAG,IAAI,EAC1B,gBAAgB,GAAG,IAAI,GACxB,GAAG,OAAO,CAAC;IAEZ,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,MAAM,QAAQ,CAAC,eAAe,EAAE,6BAA6B,OAAO,EAAE,CAAC,CAAC;IACxE,MAAM,QAAQ,CAAC,eAAe,EAAE,sBAAsB,SAAS,yBAAyB,mBAAmB,sBAAsB,gBAAgB,EAAE,CAAC,CAAC;IAErJ,yDAAyD;IACzD,MAAM,kBAAkB,GAAG;QACzB,aAAa,EAAE;YACb,GAAG,cAAc,CAAC,aAAa;YAC/B,YAAY,EAAE,cAAc,CAAC,aA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GAAG,MAAM,CAAC,IAAI,CAC/B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,eAAe,CAAC,QAAQ,CACpD,CAAC;QAEF,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,QAAQ,CAAC,eAAe,EAAE,WAAW,QAAQ,yBAAyB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;YAClG,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,aAAa;aAC7B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,CAAC,eAAe,EAAE,WAAW,QAAQ,gCAAgC,CAAC,CAAC;YACrF,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE;oBACb,GAAG,MAAM,CAAC,eAAe;oBACzB,IAAI,EAAE,SAAsB;oBAC5B,iBAAiB,EAAE,CAAC,QAAQ,CAAsB;oBAClD,UAAU,EAAE,EAAE;oBACd,WAAW,EAAE,0BAA0B;iBACxC;aACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,CAAC,eAAe,EAAE,WAAW,QAAQ,8BAA8B,CAAC,CAAC;IACnF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Modal dismissal utilities
3
+ *
4
+ * This module handles the logic for dismissing modals using various strategies.
5
+ * It was extracted from duplicate code in modal-tools.ts and input-tools.ts
6
+ */
7
+ import type { Page } from 'puppeteer-core';
8
+ import type { DetectedModalInfo as DetectedModal, DismissStrategy } from './modal-detection-core.js';
9
+ export interface DismissalResult {
10
+ success: boolean;
11
+ method?: string;
12
+ error?: string;
13
+ }
14
+ /**
15
+ * Dismiss a modal using a specific strategy
16
+ *
17
+ * @param page - Puppeteer page instance
18
+ * @param modal - The detected modal to dismiss
19
+ * @param strategy - Dismissal strategy (accept, reject, close, remove)
20
+ * @param retryAttempts - Number of retry attempts when clicking buttons
21
+ * @returns Result indicating success or failure
22
+ */
23
+ export declare function dismissModalByStrategy(page: Page, modal: DetectedModal, strategy: DismissStrategy, retryAttempts?: number): Promise<DismissalResult>;
24
+ /**
25
+ * Select the best dismissal strategy based on modal type
26
+ *
27
+ * @param modal - The detected modal
28
+ * @param requestedStrategy - User-requested strategy or 'auto'
29
+ * @returns Effective strategy to use
30
+ */
31
+ export declare function selectDismissalStrategy(modal: DetectedModal, requestedStrategy: DismissStrategy | 'auto'): DismissStrategy;
32
+ //# sourceMappingURL=modal-dismissal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-dismissal.d.ts","sourceRoot":"","sources":["../../src/utils/modal-dismissal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,IAAI,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAErG,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,eAAe,EACzB,aAAa,GAAE,MAAU,GACxB,OAAO,CAAC,eAAe,CAAC,CA6I1B;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,EACpB,iBAAiB,EAAE,eAAe,GAAG,MAAM,GAC1C,eAAe,CAqCjB"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Modal dismissal utilities
3
+ *
4
+ * This module handles the logic for dismissing modals using various strategies.
5
+ * It was extracted from duplicate code in modal-tools.ts and input-tools.ts
6
+ */
7
+ /**
8
+ * Dismiss a modal using a specific strategy
9
+ *
10
+ * @param page - Puppeteer page instance
11
+ * @param modal - The detected modal to dismiss
12
+ * @param strategy - Dismissal strategy (accept, reject, close, remove)
13
+ * @param retryAttempts - Number of retry attempts when clicking buttons
14
+ * @returns Result indicating success or failure
15
+ */
16
+ export async function dismissModalByStrategy(page, modal, strategy, retryAttempts = 3) {
17
+ // Remove strategy - just remove from DOM
18
+ if (strategy === 'remove') {
19
+ try {
20
+ await page.evaluate((sel) => {
21
+ const element = globalThis.document.querySelector(sel);
22
+ if (element) {
23
+ element.remove();
24
+ return true;
25
+ }
26
+ return false;
27
+ }, modal.selector);
28
+ // Verify removal
29
+ const stillExists = await page.$(modal.selector);
30
+ if (stillExists) {
31
+ return { success: false, error: 'Element still exists after removal attempt' };
32
+ }
33
+ return { success: true, method: 'DOM removal' };
34
+ }
35
+ catch (error) {
36
+ return { success: false, error: error.message };
37
+ }
38
+ }
39
+ // Button click strategies - need to find appropriate button
40
+ const buttonSelectors = await page.evaluate((sel, strat) => {
41
+ const modal = globalThis.document.querySelector(sel);
42
+ if (!modal)
43
+ return [];
44
+ const selectors = [];
45
+ // Define button search patterns based on strategy
46
+ // TODO: These button text patterns are English-only. Non-English sites will fail button detection.
47
+ // Workaround: Use strategy: 'remove' for non-English sites.
48
+ // See KNOWN_LIMITATIONS.md "Language Limitations" section for details.
49
+ let textPatterns;
50
+ let classPatterns;
51
+ switch (strat) {
52
+ case 'accept':
53
+ textPatterns = /accept|agree|allow|enable|ok|got it|i accept|continue|yes/i;
54
+ classPatterns = ['accept', 'agree', 'allow', 'enable', 'ok', 'continue', 'yes'];
55
+ break;
56
+ case 'reject':
57
+ textPatterns = /reject|decline|deny|disable|no thanks|refuse|dismiss/i;
58
+ classPatterns = ['reject', 'decline', 'deny', 'refuse', 'no'];
59
+ break;
60
+ case 'close':
61
+ textPatterns = /close|dismiss|×|✕|✖|skip|no thanks/i;
62
+ classPatterns = ['close', 'dismiss', 'skip'];
63
+ break;
64
+ default:
65
+ return [];
66
+ }
67
+ // Find buttons within modal
68
+ const buttons = modal.querySelectorAll('button, [role="button"], a[href="#"], .button, .btn, [class*="button" i], [class*="btn" i]');
69
+ buttons.forEach((btn, idx) => {
70
+ const text = (btn.textContent || '').trim().toLowerCase();
71
+ const ariaLabel = (btn.getAttribute('aria-label') || '').toLowerCase();
72
+ const className = btn.className.toLowerCase();
73
+ const id = btn.id.toLowerCase();
74
+ const combined = `${text} ${ariaLabel} ${className} ${id}`;
75
+ // Check text pattern
76
+ if (textPatterns.test(combined)) {
77
+ // Try to create a unique selector
78
+ if (btn.id) {
79
+ selectors.push(`#${btn.id}`);
80
+ }
81
+ else if (btn.className) {
82
+ const classes = btn.className.split(/\s+/).filter(Boolean);
83
+ if (classes.length > 0) {
84
+ selectors.push(`${sel} .${classes.join('.')}`);
85
+ }
86
+ }
87
+ else {
88
+ // Fallback to nth-of-type
89
+ selectors.push(`${sel} button:nth-of-type(${idx + 1})`);
90
+ }
91
+ }
92
+ // Check class patterns
93
+ classPatterns.forEach(pattern => {
94
+ if (className.includes(pattern.toLowerCase())) {
95
+ if (btn.id) {
96
+ selectors.push(`#${btn.id}`);
97
+ }
98
+ else if (btn.className) {
99
+ const classes = btn.className.split(/\s+/).filter(Boolean);
100
+ selectors.push(`${sel} .${classes.join('.')}`);
101
+ }
102
+ }
103
+ });
104
+ });
105
+ return [...new Set(selectors)]; // Remove duplicates
106
+ }, modal.selector, strategy);
107
+ // Try each button selector
108
+ for (const btnSelector of buttonSelectors) {
109
+ for (let attempt = 0; attempt < retryAttempts; attempt++) {
110
+ try {
111
+ const button = await page.$(btnSelector);
112
+ if (!button)
113
+ continue;
114
+ // Click the button
115
+ await button.click();
116
+ // Wait for modal to disappear (with timeout)
117
+ try {
118
+ await page.waitForSelector(modal.selector, { hidden: true, timeout: 1000 });
119
+ return { success: true, method: `Clicked button: ${btnSelector}` };
120
+ }
121
+ catch (e) {
122
+ // Modal didn't disappear, try next button
123
+ continue;
124
+ }
125
+ }
126
+ catch (error) {
127
+ // Try next button or retry
128
+ continue;
129
+ }
130
+ }
131
+ }
132
+ // If no buttons worked, fall back to DOM removal
133
+ if (buttonSelectors.length === 0) {
134
+ return {
135
+ success: false,
136
+ error: `No ${strategy} buttons found in modal. Use strategy "remove" to force removal.`,
137
+ };
138
+ }
139
+ return {
140
+ success: false,
141
+ error: `Found ${buttonSelectors.length} potential ${strategy} button(s) but none successfully dismissed the modal`,
142
+ };
143
+ }
144
+ /**
145
+ * Select the best dismissal strategy based on modal type
146
+ *
147
+ * @param modal - The detected modal
148
+ * @param requestedStrategy - User-requested strategy or 'auto'
149
+ * @returns Effective strategy to use
150
+ */
151
+ export function selectDismissalStrategy(modal, requestedStrategy) {
152
+ if (requestedStrategy === 'auto') {
153
+ // Smart strategy selection based on modal type
154
+ switch (modal.type) {
155
+ case 'cookie-consent':
156
+ // Prefer accept for cookie consents (least friction)
157
+ return modal.dismissStrategies.includes('accept')
158
+ ? 'accept'
159
+ : modal.dismissStrategies.includes('close')
160
+ ? 'close'
161
+ : 'remove';
162
+ case 'newsletter-popup':
163
+ // Prefer close for newsletters (non-committal)
164
+ return modal.dismissStrategies.includes('close')
165
+ ? 'close'
166
+ : modal.dismissStrategies.includes('reject')
167
+ ? 'reject'
168
+ : 'remove';
169
+ case 'age-verification':
170
+ // Prefer accept for age gates (necessary)
171
+ return modal.dismissStrategies.includes('accept')
172
+ ? 'accept'
173
+ : 'remove';
174
+ default:
175
+ // For unknown modals, prefer close, then remove
176
+ return modal.dismissStrategies.includes('close')
177
+ ? 'close'
178
+ : 'remove';
179
+ }
180
+ }
181
+ else {
182
+ // Use requested strategy if available
183
+ if (!modal.dismissStrategies.includes(requestedStrategy)) {
184
+ // Fall back to remove if requested strategy not available
185
+ return 'remove';
186
+ }
187
+ return requestedStrategy;
188
+ }
189
+ }
190
+ //# sourceMappingURL=modal-dismissal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-dismissal.js","sourceRoot":"","sources":["../../src/utils/modal-dismissal.ts"],"names":[],"mappings":"AAAA;;;;;G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C;QAClB,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Port Check Utility
3
+ * Check if a port is open before attempting to connect
4
+ */
5
+ export interface PortCheckResult {
6
+ open: boolean;
7
+ host: string;
8
+ port: number;
9
+ error?: string;
10
+ }
11
+ /**
12
+ * Check if a port is open on a given host
13
+ * @param port The port number to check
14
+ * @param host The host to check (default: localhost)
15
+ * @param timeoutMs Timeout in milliseconds (default: 2000)
16
+ */
17
+ export declare function checkPort(port: number, host?: string, timeoutMs?: number): Promise<PortCheckResult>;
18
+ /**
19
+ * Parse a URL and extract host and port
20
+ * Returns null if URL is invalid or doesn't have a port
21
+ */
22
+ export declare function parseUrlForPortCheck(url: string): {
23
+ host: string;
24
+ port: number;
25
+ } | null;
26
+ /**
27
+ * Check if a URL's server is reachable
28
+ * Only checks localhost/127.0.0.1 URLs (skips external URLs)
29
+ */
30
+ export declare function checkUrlPort(url: string, timeoutMs?: number): Promise<PortCheckResult | null>;
31
+ //# sourceMappingURL=port-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port-check.d.ts","sourceRoot":"","sources":["../../src/utils/port-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAoB,EAC1B,SAAS,GAAE,MAAa,GACvB,OAAO,CAAC,eAAe,CAAC,CAkC1B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAqBvF;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,MAAa,GACvB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAgBjC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Port Check Utility
3
+ * Check if a port is open before attempting to connect
4
+ */
5
+ import * as net from 'net';
6
+ /**
7
+ * Check if a port is open on a given host
8
+ * @param port The port number to check
9
+ * @param host The host to check (default: localhost)
10
+ * @param timeoutMs Timeout in milliseconds (default: 2000)
11
+ */
12
+ export async function checkPort(port, host = 'localhost', timeoutMs = 2000) {
13
+ return new Promise((resolve) => {
14
+ const socket = new net.Socket();
15
+ let resolved = false;
16
+ const cleanup = () => {
17
+ if (!resolved) {
18
+ resolved = true;
19
+ socket.destroy();
20
+ }
21
+ };
22
+ socket.setTimeout(timeoutMs);
23
+ socket.on('connect', () => {
24
+ cleanup();
25
+ resolve({ open: true, host, port });
26
+ });
27
+ socket.on('timeout', () => {
28
+ cleanup();
29
+ resolve({ open: false, host, port, error: 'Connection timed out' });
30
+ });
31
+ socket.on('error', (err) => {
32
+ cleanup();
33
+ const errorMessage = err.code === 'ECONNREFUSED'
34
+ ? 'Connection refused'
35
+ : err.message;
36
+ resolve({ open: false, host, port, error: errorMessage });
37
+ });
38
+ socket.connect(port, host);
39
+ });
40
+ }
41
+ /**
42
+ * Parse a URL and extract host and port
43
+ * Returns null if URL is invalid or doesn't have a port
44
+ */
45
+ export function parseUrlForPortCheck(url) {
46
+ try {
47
+ const parsed = new URL(url);
48
+ const host = parsed.hostname;
49
+ // Get port from URL or use default based on protocol
50
+ let port;
51
+ if (parsed.port) {
52
+ port = parseInt(parsed.port, 10);
53
+ }
54
+ else if (parsed.protocol === 'https:') {
55
+ port = 443;
56
+ }
57
+ else if (parsed.protocol === 'http:') {
58
+ port = 80;
59
+ }
60
+ else {
61
+ return null;
62
+ }
63
+ return { host, port };
64
+ }
65
+ catch {
66
+ return null;
67
+ }
68
+ }
69
+ /**
70
+ * Check if a URL's server is reachable
71
+ * Only checks localhost/127.0.0.1 URLs (skips external URLs)
72
+ */
73
+ export async function checkUrlPort(url, timeoutMs = 2000) {
74
+ const parsed = parseUrlForPortCheck(url);
75
+ if (!parsed) {
76
+ return null;
77
+ }
78
+ // Only check localhost URLs - external sites may have firewalls, CDNs, etc.
79
+ const isLocalhost = parsed.host === 'localhost' ||
80
+ parsed.host === '127.0.0.1' ||
81
+ parsed.host === '0.0.0.0';
82
+ if (!isLocalhost) {
83
+ return null; // Skip check for non-localhost
84
+ }
85
+ return checkPort(parsed.port, parsed.host, timeoutMs);
86
+ }
87
+ //# sourceMappingURL=port-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port-check.js","sourceRoot":"","sources":["../../src/utils/port-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAS3B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAY,EACZ,OAAe,WAAW,EAC1B,YAAoB,IAAI;IAExB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAChC,IAAI,QAAQ,GAAG,KAAK,CAAC;QAErB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,QAAQ,GAAG,IAAI,CAAC;gBAChB,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAE7B,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACxB,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC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