@vforsh/argus-watcher 0.1.11 → 0.1.13

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 (329) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cdp/mouse.d.ts +19 -3
  3. package/dist/cdp/mouse.d.ts.map +1 -1
  4. package/dist/cdp/mouse.js +57 -9
  5. package/dist/cdp/mouse.js.map +1 -1
  6. package/dist/cdp/pageIndicator.d.ts +5 -0
  7. package/dist/cdp/pageIndicator.d.ts.map +1 -1
  8. package/dist/cdp/pageIndicator.js +22 -254
  9. package/dist/cdp/pageIndicator.js.map +1 -1
  10. package/dist/cdp/pageIndicatorScript.d.ts +20 -0
  11. package/dist/cdp/pageIndicatorScript.d.ts.map +1 -0
  12. package/dist/cdp/pageIndicatorScript.js +405 -0
  13. package/dist/cdp/pageIndicatorScript.js.map +1 -0
  14. package/dist/cdp/recording.d.ts +15 -0
  15. package/dist/cdp/recording.d.ts.map +1 -0
  16. package/dist/cdp/recording.js +389 -0
  17. package/dist/cdp/recording.js.map +1 -0
  18. package/dist/cdp/screenshot.d.ts.map +1 -1
  19. package/dist/cdp/screenshot.js +2 -133
  20. package/dist/cdp/screenshot.js.map +1 -1
  21. package/dist/cdp/visualCapture.d.ts +38 -0
  22. package/dist/cdp/visualCapture.d.ts.map +1 -0
  23. package/dist/cdp/visualCapture.js +156 -0
  24. package/dist/cdp/visualCapture.js.map +1 -0
  25. package/dist/events.d.ts +1 -1
  26. package/dist/events.d.ts.map +1 -1
  27. package/dist/http/routes/authCookies.d.ts +5 -10
  28. package/dist/http/routes/authCookies.d.ts.map +1 -1
  29. package/dist/http/routes/authCookies.js +17 -30
  30. package/dist/http/routes/authCookies.js.map +1 -1
  31. package/dist/http/routes/defineDomTargetRoute.d.ts +14 -5
  32. package/dist/http/routes/defineDomTargetRoute.d.ts.map +1 -1
  33. package/dist/http/routes/defineDomTargetRoute.js +27 -33
  34. package/dist/http/routes/defineDomTargetRoute.js.map +1 -1
  35. package/dist/http/routes/defineRoute.d.ts +9 -0
  36. package/dist/http/routes/defineRoute.d.ts.map +1 -1
  37. package/dist/http/routes/defineRoute.js +9 -9
  38. package/dist/http/routes/defineRoute.js.map +1 -1
  39. package/dist/http/routes/domSelectorRoute.d.ts +4 -11
  40. package/dist/http/routes/domSelectorRoute.d.ts.map +1 -1
  41. package/dist/http/routes/domSelectorRoute.js +9 -17
  42. package/dist/http/routes/domSelectorRoute.js.map +1 -1
  43. package/dist/http/routes/getAuthCookies.d.ts +1 -2
  44. package/dist/http/routes/getAuthCookies.d.ts.map +1 -1
  45. package/dist/http/routes/getAuthCookies.js +14 -14
  46. package/dist/http/routes/getAuthCookies.js.map +1 -1
  47. package/dist/http/routes/getAuthState.d.ts +1 -2
  48. package/dist/http/routes/getAuthState.d.ts.map +1 -1
  49. package/dist/http/routes/getAuthState.js +13 -13
  50. package/dist/http/routes/getAuthState.js.map +1 -1
  51. package/dist/http/routes/getDialog.d.ts +1 -2
  52. package/dist/http/routes/getDialog.d.ts.map +1 -1
  53. package/dist/http/routes/getDialog.js +7 -10
  54. package/dist/http/routes/getDialog.js.map +1 -1
  55. package/dist/http/routes/getEmulation.d.ts +1 -2
  56. package/dist/http/routes/getEmulation.d.ts.map +1 -1
  57. package/dist/http/routes/getEmulation.js +7 -7
  58. package/dist/http/routes/getEmulation.js.map +1 -1
  59. package/dist/http/routes/getExtensionDiagnostics.d.ts +2 -0
  60. package/dist/http/routes/getExtensionDiagnostics.d.ts.map +1 -0
  61. package/dist/http/routes/getExtensionDiagnostics.js +16 -0
  62. package/dist/http/routes/getExtensionDiagnostics.js.map +1 -0
  63. package/dist/http/routes/getExtensionTabs.d.ts +1 -2
  64. package/dist/http/routes/getExtensionTabs.d.ts.map +1 -1
  65. package/dist/http/routes/getExtensionTabs.js +18 -16
  66. package/dist/http/routes/getExtensionTabs.js.map +1 -1
  67. package/dist/http/routes/getLogs.d.ts +1 -2
  68. package/dist/http/routes/getLogs.d.ts.map +1 -1
  69. package/dist/http/routes/getLogs.js +31 -26
  70. package/dist/http/routes/getLogs.js.map +1 -1
  71. package/dist/http/routes/getNet.d.ts +1 -2
  72. package/dist/http/routes/getNet.d.ts.map +1 -1
  73. package/dist/http/routes/getNet.js +19 -21
  74. package/dist/http/routes/getNet.js.map +1 -1
  75. package/dist/http/routes/getNetRequest.d.ts +1 -2
  76. package/dist/http/routes/getNetRequest.d.ts.map +1 -1
  77. package/dist/http/routes/getNetRequest.js +22 -20
  78. package/dist/http/routes/getNetRequest.js.map +1 -1
  79. package/dist/http/routes/getNetRequestBody.d.ts +1 -2
  80. package/dist/http/routes/getNetRequestBody.d.ts.map +1 -1
  81. package/dist/http/routes/getNetRequestBody.js +53 -51
  82. package/dist/http/routes/getNetRequestBody.js.map +1 -1
  83. package/dist/http/routes/getNetRequests.d.ts +1 -2
  84. package/dist/http/routes/getNetRequests.d.ts.map +1 -1
  85. package/dist/http/routes/getNetRequests.js +19 -21
  86. package/dist/http/routes/getNetRequests.js.map +1 -1
  87. package/dist/http/routes/getNetSse.d.ts +1 -2
  88. package/dist/http/routes/getNetSse.d.ts.map +1 -1
  89. package/dist/http/routes/getNetSse.js +19 -21
  90. package/dist/http/routes/getNetSse.js.map +1 -1
  91. package/dist/http/routes/getNetTail.d.ts +1 -2
  92. package/dist/http/routes/getNetTail.d.ts.map +1 -1
  93. package/dist/http/routes/getNetTail.js +21 -30
  94. package/dist/http/routes/getNetTail.js.map +1 -1
  95. package/dist/http/routes/getNetWebSocketConnection.d.ts +1 -2
  96. package/dist/http/routes/getNetWebSocketConnection.d.ts.map +1 -1
  97. package/dist/http/routes/getNetWebSocketConnection.js +22 -17
  98. package/dist/http/routes/getNetWebSocketConnection.js.map +1 -1
  99. package/dist/http/routes/getNetWebSockets.d.ts +1 -2
  100. package/dist/http/routes/getNetWebSockets.d.ts.map +1 -1
  101. package/dist/http/routes/getNetWebSockets.js +19 -21
  102. package/dist/http/routes/getNetWebSockets.js.map +1 -1
  103. package/dist/http/routes/getStatus.d.ts +1 -2
  104. package/dist/http/routes/getStatus.d.ts.map +1 -1
  105. package/dist/http/routes/getStatus.js +6 -4
  106. package/dist/http/routes/getStatus.js.map +1 -1
  107. package/dist/http/routes/getTail.d.ts +1 -2
  108. package/dist/http/routes/getTail.d.ts.map +1 -1
  109. package/dist/http/routes/getTail.js +31 -26
  110. package/dist/http/routes/getTail.js.map +1 -1
  111. package/dist/http/routes/getTargets.d.ts +1 -2
  112. package/dist/http/routes/getTargets.d.ts.map +1 -1
  113. package/dist/http/routes/getTargets.js +14 -13
  114. package/dist/http/routes/getTargets.js.map +1 -1
  115. package/dist/http/routes/getThrottle.d.ts +1 -2
  116. package/dist/http/routes/getThrottle.d.ts.map +1 -1
  117. package/dist/http/routes/getThrottle.js +7 -7
  118. package/dist/http/routes/getThrottle.js.map +1 -1
  119. package/dist/http/routes/index.d.ts +5 -1
  120. package/dist/http/routes/index.d.ts.map +1 -1
  121. package/dist/http/routes/index.js +121 -114
  122. package/dist/http/routes/index.js.map +1 -1
  123. package/dist/http/routes/netFilters.d.ts +10 -0
  124. package/dist/http/routes/netFilters.d.ts.map +1 -1
  125. package/dist/http/routes/netFilters.js +23 -1
  126. package/dist/http/routes/netFilters.js.map +1 -1
  127. package/dist/http/routes/netMock.d.ts +3 -0
  128. package/dist/http/routes/netMock.d.ts.map +1 -0
  129. package/dist/http/routes/netMock.js +141 -0
  130. package/dist/http/routes/netMock.js.map +1 -0
  131. package/dist/http/routes/postAttach.d.ts +1 -2
  132. package/dist/http/routes/postAttach.d.ts.map +1 -1
  133. package/dist/http/routes/postAttach.js +23 -22
  134. package/dist/http/routes/postAttach.js.map +1 -1
  135. package/dist/http/routes/postAuthStateLoad.d.ts +1 -2
  136. package/dist/http/routes/postAuthStateLoad.d.ts.map +1 -1
  137. package/dist/http/routes/postAuthStateLoad.js +29 -34
  138. package/dist/http/routes/postAuthStateLoad.js.map +1 -1
  139. package/dist/http/routes/postCodeEdit.d.ts +1 -2
  140. package/dist/http/routes/postCodeEdit.d.ts.map +1 -1
  141. package/dist/http/routes/postCodeEdit.js +20 -25
  142. package/dist/http/routes/postCodeEdit.js.map +1 -1
  143. package/dist/http/routes/postCodeGrep.d.ts +1 -2
  144. package/dist/http/routes/postCodeGrep.d.ts.map +1 -1
  145. package/dist/http/routes/postCodeGrep.js +20 -25
  146. package/dist/http/routes/postCodeGrep.js.map +1 -1
  147. package/dist/http/routes/postCodeList.d.ts +1 -2
  148. package/dist/http/routes/postCodeList.d.ts.map +1 -1
  149. package/dist/http/routes/postCodeList.js +14 -19
  150. package/dist/http/routes/postCodeList.js.map +1 -1
  151. package/dist/http/routes/postCodeRead.d.ts +1 -2
  152. package/dist/http/routes/postCodeRead.d.ts.map +1 -1
  153. package/dist/http/routes/postCodeRead.js +24 -29
  154. package/dist/http/routes/postCodeRead.js.map +1 -1
  155. package/dist/http/routes/postDetach.d.ts +1 -2
  156. package/dist/http/routes/postDetach.d.ts.map +1 -1
  157. package/dist/http/routes/postDetach.js +23 -22
  158. package/dist/http/routes/postDetach.js.map +1 -1
  159. package/dist/http/routes/postDialog.d.ts +1 -2
  160. package/dist/http/routes/postDialog.d.ts.map +1 -1
  161. package/dist/http/routes/postDialog.js +30 -29
  162. package/dist/http/routes/postDialog.js.map +1 -1
  163. package/dist/http/routes/postDomAdd.d.ts +1 -2
  164. package/dist/http/routes/postDomAdd.d.ts.map +1 -1
  165. package/dist/http/routes/postDomAdd.js +44 -48
  166. package/dist/http/routes/postDomAdd.js.map +1 -1
  167. package/dist/http/routes/postDomClick.d.ts +0 -1
  168. package/dist/http/routes/postDomClick.d.ts.map +1 -1
  169. package/dist/http/routes/postDomClick.js +12 -21
  170. package/dist/http/routes/postDomClick.js.map +1 -1
  171. package/dist/http/routes/postDomDrag.d.ts +2 -0
  172. package/dist/http/routes/postDomDrag.d.ts.map +1 -0
  173. package/dist/http/routes/postDomDrag.js +54 -0
  174. package/dist/http/routes/postDomDrag.js.map +1 -0
  175. package/dist/http/routes/postDomFill.d.ts +1 -2
  176. package/dist/http/routes/postDomFill.d.ts.map +1 -1
  177. package/dist/http/routes/postDomFill.js +17 -49
  178. package/dist/http/routes/postDomFill.js.map +1 -1
  179. package/dist/http/routes/postDomInfo.d.ts +1 -2
  180. package/dist/http/routes/postDomInfo.d.ts.map +1 -1
  181. package/dist/http/routes/postDomInfo.js +14 -20
  182. package/dist/http/routes/postDomInfo.js.map +1 -1
  183. package/dist/http/routes/postDomKeydown.d.ts +1 -2
  184. package/dist/http/routes/postDomKeydown.d.ts.map +1 -1
  185. package/dist/http/routes/postDomKeydown.js +26 -30
  186. package/dist/http/routes/postDomKeydown.js.map +1 -1
  187. package/dist/http/routes/postDomModify.d.ts +1 -2
  188. package/dist/http/routes/postDomModify.d.ts.map +1 -1
  189. package/dist/http/routes/postDomModify.js +30 -41
  190. package/dist/http/routes/postDomModify.js.map +1 -1
  191. package/dist/http/routes/postDomRemove.d.ts +1 -2
  192. package/dist/http/routes/postDomRemove.d.ts.map +1 -1
  193. package/dist/http/routes/postDomRemove.js +13 -18
  194. package/dist/http/routes/postDomRemove.js.map +1 -1
  195. package/dist/http/routes/postDomScroll.d.ts +1 -2
  196. package/dist/http/routes/postDomScroll.d.ts.map +1 -1
  197. package/dist/http/routes/postDomScroll.js +37 -42
  198. package/dist/http/routes/postDomScroll.js.map +1 -1
  199. package/dist/http/routes/postDomScrollTo.d.ts +1 -2
  200. package/dist/http/routes/postDomScrollTo.d.ts.map +1 -1
  201. package/dist/http/routes/postDomScrollTo.js +42 -48
  202. package/dist/http/routes/postDomScrollTo.js.map +1 -1
  203. package/dist/http/routes/postDomSetFile.d.ts +1 -2
  204. package/dist/http/routes/postDomSetFile.d.ts.map +1 -1
  205. package/dist/http/routes/postDomSetFile.js +29 -32
  206. package/dist/http/routes/postDomSetFile.js.map +1 -1
  207. package/dist/http/routes/postDomTree.d.ts +1 -2
  208. package/dist/http/routes/postDomTree.d.ts.map +1 -1
  209. package/dist/http/routes/postDomTree.js +13 -17
  210. package/dist/http/routes/postDomTree.js.map +1 -1
  211. package/dist/http/routes/postEmulation.d.ts +1 -2
  212. package/dist/http/routes/postEmulation.d.ts.map +1 -1
  213. package/dist/http/routes/postEmulation.js +29 -39
  214. package/dist/http/routes/postEmulation.js.map +1 -1
  215. package/dist/http/routes/postEval.d.ts +1 -2
  216. package/dist/http/routes/postEval.d.ts.map +1 -1
  217. package/dist/http/routes/postEval.js +22 -26
  218. package/dist/http/routes/postEval.js.map +1 -1
  219. package/dist/http/routes/postLocate.d.ts +2 -4
  220. package/dist/http/routes/postLocate.d.ts.map +1 -1
  221. package/dist/http/routes/postLocate.js +40 -60
  222. package/dist/http/routes/postLocate.js.map +1 -1
  223. package/dist/http/routes/postNetClear.d.ts +1 -2
  224. package/dist/http/routes/postNetClear.d.ts.map +1 -1
  225. package/dist/http/routes/postNetClear.js +14 -13
  226. package/dist/http/routes/postNetClear.js.map +1 -1
  227. package/dist/http/routes/postRecord.d.ts +3 -0
  228. package/dist/http/routes/postRecord.d.ts.map +1 -0
  229. package/dist/http/routes/postRecord.js +88 -0
  230. package/dist/http/routes/postRecord.js.map +1 -0
  231. package/dist/http/routes/postReload.d.ts +1 -2
  232. package/dist/http/routes/postReload.d.ts.map +1 -1
  233. package/dist/http/routes/postReload.js +10 -16
  234. package/dist/http/routes/postReload.js.map +1 -1
  235. package/dist/http/routes/postScreenshot.d.ts +1 -2
  236. package/dist/http/routes/postScreenshot.d.ts.map +1 -1
  237. package/dist/http/routes/postScreenshot.js +11 -22
  238. package/dist/http/routes/postScreenshot.js.map +1 -1
  239. package/dist/http/routes/postShutdown.d.ts +1 -2
  240. package/dist/http/routes/postShutdown.d.ts.map +1 -1
  241. package/dist/http/routes/postShutdown.js +15 -11
  242. package/dist/http/routes/postShutdown.js.map +1 -1
  243. package/dist/http/routes/postSnapshot.d.ts +1 -2
  244. package/dist/http/routes/postSnapshot.d.ts.map +1 -1
  245. package/dist/http/routes/postSnapshot.js +21 -26
  246. package/dist/http/routes/postSnapshot.js.map +1 -1
  247. package/dist/http/routes/postThrottle.d.ts +1 -2
  248. package/dist/http/routes/postThrottle.d.ts.map +1 -1
  249. package/dist/http/routes/postThrottle.js +26 -35
  250. package/dist/http/routes/postThrottle.js.map +1 -1
  251. package/dist/http/routes/postTraceStart.d.ts +1 -2
  252. package/dist/http/routes/postTraceStart.d.ts.map +1 -1
  253. package/dist/http/routes/postTraceStart.js +8 -16
  254. package/dist/http/routes/postTraceStart.js.map +1 -1
  255. package/dist/http/routes/postTraceStop.d.ts +1 -2
  256. package/dist/http/routes/postTraceStop.d.ts.map +1 -1
  257. package/dist/http/routes/postTraceStop.js +8 -16
  258. package/dist/http/routes/postTraceStop.js.map +1 -1
  259. package/dist/http/routes/postVisibility.d.ts +1 -2
  260. package/dist/http/routes/postVisibility.d.ts.map +1 -1
  261. package/dist/http/routes/postVisibility.js +21 -27
  262. package/dist/http/routes/postVisibility.js.map +1 -1
  263. package/dist/http/routes/storage.d.ts +2 -4
  264. package/dist/http/routes/storage.d.ts.map +1 -1
  265. package/dist/http/routes/storage.js +13 -25
  266. package/dist/http/routes/storage.js.map +1 -1
  267. package/dist/http/server.d.ts +6 -1
  268. package/dist/http/server.d.ts.map +1 -1
  269. package/dist/http/server.js.map +1 -1
  270. package/dist/index.d.ts +5 -5
  271. package/dist/index.d.ts.map +1 -1
  272. package/dist/index.js.map +1 -1
  273. package/dist/native-messaging/control-session-manager.d.ts +36 -0
  274. package/dist/native-messaging/control-session-manager.d.ts.map +1 -0
  275. package/dist/native-messaging/control-session-manager.js +96 -0
  276. package/dist/native-messaging/control-session-manager.js.map +1 -0
  277. package/dist/native-messaging/messaging.d.ts +4 -4
  278. package/dist/native-messaging/messaging.d.ts.map +1 -1
  279. package/dist/native-messaging/messaging.js.map +1 -1
  280. package/dist/native-messaging/session-manager.d.ts +2 -15
  281. package/dist/native-messaging/session-manager.d.ts.map +1 -1
  282. package/dist/native-messaging/session-manager.js +0 -34
  283. package/dist/native-messaging/session-manager.js.map +1 -1
  284. package/dist/native-messaging/types.d.ts +78 -2
  285. package/dist/native-messaging/types.d.ts.map +1 -1
  286. package/dist/net/NetMockController.d.ts +26 -0
  287. package/dist/net/NetMockController.d.ts.map +1 -0
  288. package/dist/net/NetMockController.js +264 -0
  289. package/dist/net/NetMockController.js.map +1 -0
  290. package/dist/runtime/watcherServices.d.ts +3 -0
  291. package/dist/runtime/watcherServices.d.ts.map +1 -1
  292. package/dist/runtime/watcherServices.js +14 -1
  293. package/dist/runtime/watcherServices.js.map +1 -1
  294. package/dist/runtime/watcherSetup.d.ts +3 -0
  295. package/dist/runtime/watcherSetup.d.ts.map +1 -1
  296. package/dist/runtime/watcherSetup.js +4 -0
  297. package/dist/runtime/watcherSetup.js.map +1 -1
  298. package/dist/scripts/install-host.js +58 -54
  299. package/dist/scripts/install-host.js.map +1 -1
  300. package/dist/sources/extension-control-source.d.ts +9 -0
  301. package/dist/sources/extension-control-source.d.ts.map +1 -0
  302. package/dist/sources/extension-control-source.js +109 -0
  303. package/dist/sources/extension-control-source.js.map +1 -0
  304. package/dist/sources/extension-frame-state.d.ts +5 -0
  305. package/dist/sources/extension-frame-state.d.ts.map +1 -1
  306. package/dist/sources/extension-frame-state.js +7 -0
  307. package/dist/sources/extension-frame-state.js.map +1 -1
  308. package/dist/sources/extension-source.d.ts +3 -1
  309. package/dist/sources/extension-source.d.ts.map +1 -1
  310. package/dist/sources/extension-source.js +50 -137
  311. package/dist/sources/extension-source.js.map +1 -1
  312. package/dist/sources/extension-target-recovery.d.ts +32 -0
  313. package/dist/sources/extension-target-recovery.d.ts.map +1 -0
  314. package/dist/sources/extension-target-recovery.js +114 -0
  315. package/dist/sources/extension-target-recovery.js.map +1 -0
  316. package/dist/sources/types.d.ts +8 -3
  317. package/dist/sources/types.d.ts.map +1 -1
  318. package/dist/startWatcherRuntime.d.ts.map +1 -1
  319. package/dist/startWatcherRuntime.js +12 -2
  320. package/dist/startWatcherRuntime.js.map +1 -1
  321. package/package.json +1 -1
  322. package/dist/http/routes/postStorageLocal.d.ts +0 -2
  323. package/dist/http/routes/postStorageLocal.d.ts.map +0 -1
  324. package/dist/http/routes/postStorageLocal.js +0 -3
  325. package/dist/http/routes/postStorageLocal.js.map +0 -1
  326. package/dist/http/routes/postStorageSession.d.ts +0 -2
  327. package/dist/http/routes/postStorageSession.d.ts.map +0 -1
  328. package/dist/http/routes/postStorageSession.js +0 -3
  329. package/dist/http/routes/postStorageSession.js.map +0 -1
@@ -1,44 +1,41 @@
1
- import { respondMultipleMatches } from './domSelectorRoute.js';
2
- import { emitRequest } from './types.js';
3
1
  import { setFileOnResolvedNodes } from '../../cdp/dom.js';
4
2
  import { resolveSelectorTargets } from '../../cdp/dom/selector.js';
5
- import { respondJson, respondInvalidBody, respondError, readJsonBody } from '../httpUtils.js';
6
- export const handle = async (req, res, _url, ctx) => {
7
- const payload = await readJsonBody(req, res);
8
- if (!payload) {
9
- return;
10
- }
11
- if (!payload.selector || typeof payload.selector !== 'string') {
12
- return respondInvalidBody(res, 'selector is required');
13
- }
14
- if (!Array.isArray(payload.files) || payload.files.length === 0) {
15
- return respondInvalidBody(res, 'files array is required and must not be empty');
16
- }
17
- const all = payload.all ?? false;
18
- if (typeof all !== 'boolean') {
19
- return respondInvalidBody(res, 'all must be a boolean');
20
- }
21
- const waitMs = payload.wait ?? 0;
22
- if (typeof waitMs !== 'number' || !Number.isFinite(waitMs) || waitMs < 0) {
23
- return respondInvalidBody(res, 'wait must be a non-negative number (ms)');
24
- }
25
- emitRequest(ctx, res, 'dom/set-file');
26
- try {
3
+ import { defineJsonRoute } from './defineRoute.js';
4
+ import { respondMultipleMatches } from './domSelectorRoute.js';
5
+ export const route = defineJsonRoute({
6
+ method: 'POST',
7
+ path: '/dom/set-file',
8
+ parseBody: true,
9
+ endpoint: 'dom/set-file',
10
+ validate: (payload) => {
11
+ if (!payload.selector || typeof payload.selector !== 'string') {
12
+ return 'selector is required';
13
+ }
14
+ if (!Array.isArray(payload.files) || payload.files.length === 0) {
15
+ return 'files array is required and must not be empty';
16
+ }
17
+ if (typeof (payload.all ?? false) !== 'boolean') {
18
+ return 'all must be a boolean';
19
+ }
20
+ const waitMs = payload.wait ?? 0;
21
+ if (typeof waitMs !== 'number' || !Number.isFinite(waitMs) || waitMs < 0) {
22
+ return 'wait must be a non-negative number (ms)';
23
+ }
24
+ return null;
25
+ },
26
+ handle: async ({ res, ctx, body: payload }) => {
27
+ const all = payload.all ?? false;
27
28
  const { allNodeIds, nodeIds } = await resolveSelectorTargets(ctx.cdpSession, {
28
29
  selector: payload.selector,
29
30
  all,
30
31
  text: payload.text,
31
- waitMs,
32
+ waitMs: payload.wait ?? 0,
32
33
  });
33
34
  if (!all && allNodeIds.length > 1) {
34
35
  return respondMultipleMatches(res, allNodeIds.length, 'set files on');
35
36
  }
36
37
  const updatedCount = await setFileOnResolvedNodes(ctx.cdpSession, nodeIds, payload.files);
37
- const response = { ok: true, matches: allNodeIds.length, updated: updatedCount };
38
- respondJson(res, response);
39
- }
40
- catch (error) {
41
- respondError(res, error);
42
- }
43
- };
38
+ return { ok: true, matches: allNodeIds.length, updated: updatedCount };
39
+ },
40
+ });
44
41
  //# sourceMappingURL=postDomSetFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postDomSetFile.js","sourceRoot":"","sources":["../../../src/http/routes/postDomSetFile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE7F,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAA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AAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,CAAA;IACvE,CAAC;CACD,CAAC,CAAA"}
@@ -1,3 +1,2 @@
1
- import type { RouteHandler } from './types.js';
2
- export declare const handle: RouteHandler;
1
+ export declare const route: import("./defineRoute.js").WatcherRouteDefinition;
3
2
  //# sourceMappingURL=postDomTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postDomTree.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postDomTree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAM9C,eAAO,MAAM,MAAM,EAAE,YA0BpB,CAAA"}
1
+ {"version":3,"file":"postDomTree.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postDomTree.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,mDAsBhB,CAAA"}
@@ -1,15 +1,14 @@
1
- import { readDomSelectorPayload, respondMultipleMatches } from './domSelectorRoute.js';
2
- import { emitRequest } from './types.js';
3
1
  import { fetchDomSubtreeBySelector } from '../../cdp/dom.js';
4
- import { respondJson, respondError } from '../httpUtils.js';
5
- export const handle = async (req, res, _url, ctx) => {
6
- const parsed = await readDomSelectorPayload(req, res);
7
- if (!parsed) {
8
- return;
9
- }
10
- const { payload, all } = parsed;
11
- emitRequest(ctx, res, 'dom/tree');
12
- try {
2
+ import { defineJsonRoute } from './defineRoute.js';
3
+ import { respondMultipleMatches, validateDomTargetBody } from './domSelectorRoute.js';
4
+ export const route = defineJsonRoute({
5
+ method: 'POST',
6
+ path: '/dom/tree',
7
+ parseBody: true,
8
+ endpoint: 'dom/tree',
9
+ validate: validateDomTargetBody,
10
+ handle: async ({ res, ctx, body: payload }) => {
11
+ const all = payload.all ?? false;
13
12
  const response = await fetchDomSubtreeBySelector(ctx.cdpSession, {
14
13
  selector: payload.selector,
15
14
  depth: payload.depth,
@@ -20,10 +19,7 @@ export const handle = async (req, res, _url, ctx) => {
20
19
  if (!all && response.matches > 1) {
21
20
  return respondMultipleMatches(res, response.matches, 'return');
22
21
  }
23
- respondJson(res, response);
24
- }
25
- catch (error) {
26
- respondError(res, error);
27
- }
28
- };
22
+ return response;
23
+ },
24
+ });
29
25
  //# sourceMappingURL=postDomTree.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postDomTree.js","sourceRoot":"","sources":["../../../src/http/routes/postDomTree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE3D,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAiB,GAAG,EAAE,GAAG,CAAC,CAAA;IACrE,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAM;IACP,CAAC;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;IAE/B,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAEjC,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAoB,MAAM,yBAAyB,CAAC,GAAG,CAAC,UAAU,EAAE;YACjF,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,GAAG;YACH,IAAI,EAAE,OAAO,CAAC,IAAI;SAClB,CAAC,CAAA;QAEF,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;YAClC,OAAO,sBAAsB,CAAC,GA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,CAAC;QAED,OAAO,QAAQ,CAAA;IAChB,CAAC;CACD,CAAC,CAAA"}
@@ -1,3 +1,2 @@
1
- import type { RouteHandler } from './types.js';
2
- export declare const handle: RouteHandler;
1
+ export declare const route: import("./defineRoute.js").WatcherRouteDefinition;
3
2
  //# sourceMappingURL=postEmulation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postEmulation.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postEmulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,eAAO,MAAM,MAAM,EAAE,YAyEpB,CAAA"}
1
+ {"version":3,"file":"postEmulation.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postEmulation.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,mDAgBhB,CAAA"}
@@ -1,70 +1,60 @@
1
- import { emitRequest } from './types.js';
2
- import { respondJson, respondInvalidBody, respondError, readJsonBody } from '../httpUtils.js';
3
- export const handle = async (req, res, _url, ctx) => {
4
- const payload = await readJsonBody(req, res);
5
- if (!payload) {
6
- return;
7
- }
8
- const validActions = ['set', 'clear'];
1
+ import { defineJsonRoute } from './defineRoute.js';
2
+ const validActions = ['set', 'clear'];
3
+ export const route = defineJsonRoute({
4
+ method: 'POST',
5
+ path: '/emulation',
6
+ parseBody: true,
7
+ endpoint: 'emulation',
8
+ validate: validateEmulationRequest,
9
+ handle: async ({ ctx, body: payload }) => {
10
+ const session = ctx.cdpSession.isAttached() ? ctx.cdpSession : null;
11
+ if (payload.action === 'clear') {
12
+ return ctx.emulationController.clearDesired(session);
13
+ }
14
+ const state = payload.state;
15
+ return ctx.emulationController.setDesired(state, session);
16
+ },
17
+ });
18
+ function validateEmulationRequest(payload) {
9
19
  const action = payload.action;
10
20
  if (!action || !validActions.includes(action)) {
11
- return respondInvalidBody(res, `action must be one of: ${validActions.join(', ')}`);
21
+ return `action must be one of: ${validActions.join(', ')}`;
12
22
  }
13
- emitRequest(ctx, res, 'emulation');
14
23
  if (action === 'clear') {
15
- try {
16
- const session = ctx.cdpSession.isAttached() ? ctx.cdpSession : null;
17
- const response = await ctx.emulationController.clearDesired(session);
18
- respondJson(res, response);
19
- }
20
- catch (error) {
21
- respondError(res, error);
22
- }
23
- return;
24
+ return null;
24
25
  }
25
- // action === 'set'
26
26
  const setPayload = payload;
27
27
  if (!setPayload.state || typeof setPayload.state !== 'object') {
28
- return respondInvalidBody(res, 'state is required for set action');
28
+ return 'state is required for set action';
29
29
  }
30
30
  const state = setPayload.state;
31
- // Validate viewport if present
32
31
  if (state.viewport != null) {
33
32
  const vp = state.viewport;
34
33
  if (!Number.isInteger(vp.width) || vp.width <= 0) {
35
- return respondInvalidBody(res, 'viewport.width must be a positive integer');
34
+ return 'viewport.width must be a positive integer';
36
35
  }
37
36
  if (!Number.isInteger(vp.height) || vp.height <= 0) {
38
- return respondInvalidBody(res, 'viewport.height must be a positive integer');
37
+ return 'viewport.height must be a positive integer';
39
38
  }
40
39
  if (typeof vp.deviceScaleFactor !== 'number' || !Number.isFinite(vp.deviceScaleFactor) || vp.deviceScaleFactor <= 0) {
41
- return respondInvalidBody(res, 'viewport.deviceScaleFactor must be a finite number > 0');
40
+ return 'viewport.deviceScaleFactor must be a finite number > 0';
42
41
  }
43
42
  if (typeof vp.mobile !== 'boolean') {
44
- return respondInvalidBody(res, 'viewport.mobile must be a boolean');
43
+ return 'viewport.mobile must be a boolean';
45
44
  }
46
45
  }
47
- // Validate touch if present
48
46
  if (state.touch != null) {
49
47
  const touch = state.touch;
50
48
  if (typeof touch.enabled !== 'boolean') {
51
- return respondInvalidBody(res, 'touch.enabled must be a boolean');
49
+ return 'touch.enabled must be a boolean';
52
50
  }
53
51
  }
54
- // Validate userAgent if present
55
52
  if (state.userAgent != null) {
56
53
  const ua = state.userAgent;
57
54
  if (ua.value !== null && (typeof ua.value !== 'string' || ua.value === '')) {
58
- return respondInvalidBody(res, 'userAgent.value must be a non-empty string or null');
55
+ return 'userAgent.value must be a non-empty string or null';
59
56
  }
60
57
  }
61
- try {
62
- const session = ctx.cdpSession.isAttached() ? ctx.cdpSession : null;
63
- const response = await ctx.emulationController.setDesired(state, session);
64
- respondJson(res, response);
65
- }
66
- catch (error) {
67
- respondError(res, error);
68
- }
69
- };
58
+ return null;
59
+ }
70
60
  //# sourceMappingURL=postEmulation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postEmulation.js","sourceRoot":"","sources":["../../../src/http/routes/postEmulation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE7F,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAmB,GAAG,EAAE,GAAG,CAAC,CAAA;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAM;IACP,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,CAAU,CAAA;IAC9C,MAAM,MAAM,GAAI,OAA+B,CAAC,MAAM,CAAA;IACtD,IAAI,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAuC,CAAC,EAAE,CAAC;QAChF,OAAO,kBAAkB,CAAC,GAAG,EAAE,0BAA0B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpF,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;IAElC,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAA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K,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,KAAK,QAAQ,IAAI,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,EAAE,CAAC;YAC5E,OAAO,oDAAoD,CAAA;QAC5D,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC"}
@@ -1,3 +1,2 @@
1
- import type { RouteHandler } from './types.js';
2
- export declare const handle: RouteHandler;
1
+ export declare const route: import("./defineRoute.js").WatcherRouteDefinition;
3
2
  //# sourceMappingURL=postEval.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postEval.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postEval.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAK9C,eAAO,MAAM,MAAM,EAAE,YAyBpB,CAAA"}
1
+ {"version":3,"file":"postEval.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postEval.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,mDAoBhB,CAAA"}
@@ -1,30 +1,26 @@
1
- import { emitRequest } from './types.js';
2
1
  import { evaluateExpression } from '../../cdp/eval.js';
3
- import { respondJson, respondInvalidBody, respondError, readJsonBody, normalizeBoolean, normalizeTimeout } from '../httpUtils.js';
4
- export const handle = async (req, res, _url, ctx) => {
5
- const payload = await readJsonBody(req, res);
6
- if (!payload) {
7
- return;
8
- }
9
- if (!payload.expression || typeof payload.expression !== 'string') {
10
- return respondInvalidBody(res, 'expression is required');
11
- }
12
- emitRequest(ctx, res, 'eval');
13
- try {
14
- const response = await evaluateExpression(ctx.cdpSession, {
15
- expression: payload.expression,
16
- args: normalizeEvalArgs(payload.args),
17
- awaitPromise: normalizeBoolean(payload.awaitPromise, true),
18
- replMode: normalizeBoolean(payload.replMode, true),
19
- returnByValue: normalizeBoolean(payload.returnByValue, true),
20
- timeoutMs: normalizeTimeout(payload.timeoutMs),
21
- });
22
- respondJson(res, response);
23
- }
24
- catch (error) {
25
- respondError(res, error);
26
- }
27
- };
2
+ import { defineJsonRoute } from './defineRoute.js';
3
+ import { normalizeBoolean, normalizeTimeout } from '../httpUtils.js';
4
+ export const route = defineJsonRoute({
5
+ method: 'POST',
6
+ path: '/eval',
7
+ parseBody: true,
8
+ endpoint: 'eval',
9
+ validate: (payload) => {
10
+ if (!payload.expression || typeof payload.expression !== 'string') {
11
+ return 'expression is required';
12
+ }
13
+ return null;
14
+ },
15
+ handle: ({ ctx, body: payload }) => evaluateExpression(ctx.cdpSession, {
16
+ expression: payload.expression,
17
+ args: normalizeEvalArgs(payload.args),
18
+ awaitPromise: normalizeBoolean(payload.awaitPromise, true),
19
+ replMode: normalizeBoolean(payload.replMode, true),
20
+ returnByValue: normalizeBoolean(payload.returnByValue, true),
21
+ timeoutMs: normalizeTimeout(payload.timeoutMs),
22
+ }),
23
+ });
28
24
  const normalizeEvalArgs = (args) => {
29
25
  if (args == null || typeof args !== 'object' || Array.isArray(args)) {
30
26
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"postEval.js","sourceRoot":"","sources":["../../../src/http/routes/postEval.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEjI,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAc,GAAG,EAAE,GAAG,CAAC,CAAA;IACzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAM;IACP,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,OAAO,CAAC,UAAU,KA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,CAAC,SAAS,CAAC;KAC9C,CAAC;CACH,CAAC,CAAA;AAEF,MAAM,iBAAiB,GAAG,CAAC,IAAyB,EAAsC,EAAE;IAC3F,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,OAAO,SAAS,CAAA;IACjB,CAAC;IAED,MAAM,UAAU,GAA2B,EAAE,CAAA;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACxB,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAA;AACnE,CAAC,CAAA"}
@@ -1,5 +1,3 @@
1
- import type { RouteHandler } from './types.js';
2
- export declare const handleLocateRole: RouteHandler;
3
- export declare const handleLocateText: RouteHandler;
4
- export declare const handleLocateLabel: RouteHandler;
1
+ import type { WatcherRouteDefinition } from './defineRoute.js';
2
+ export declare const locateRoutes: WatcherRouteDefinition[];
5
3
  //# sourceMappingURL=postLocate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postLocate.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postLocate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAuC9C,eAAO,MAAM,gBAAgB,cAI3B,CAAA;AAEF,eAAO,MAAM,gBAAgB,cAI3B,CAAA;AAEF,eAAO,MAAM,iBAAiB,cAI5B,CAAA"}
1
+ {"version":3,"file":"postLocate.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postLocate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AA+C9D,eAAO,MAAM,YAAY,EAAE,sBAAsB,EAgBhD,CAAA"}
@@ -1,67 +1,47 @@
1
- import { respondMultipleMatches } from './domSelectorRoute.js';
2
- import { emitRequest } from './types.js';
3
1
  import { locateByLabel, locateByRole, locateByText } from '../../cdp/locate.js';
4
- import { respondError, respondInvalidBody, respondJson, readJsonBody } from '../httpUtils.js';
5
- function createLocateHandler(config) {
6
- return async (req, res, _url, ctx) => {
7
- const payload = await readJsonBody(req, res);
8
- if (!payload) {
9
- return;
2
+ import { defineJsonRoute } from './defineRoute.js';
3
+ import { respondMultipleMatches } from './domSelectorRoute.js';
4
+ const createLocateRoute = (config) => defineJsonRoute({
5
+ method: 'POST',
6
+ path: `/${config.endpoint}`,
7
+ parseBody: true,
8
+ endpoint: config.endpoint,
9
+ validate: (payload) => {
10
+ const required = payload[config.requiredField];
11
+ if (typeof required !== 'string' || required.trim() === '') {
12
+ return `${config.requiredField} is required`;
10
13
  }
11
- if (!validateRequiredString(res, payload[config.requiredField], config.requiredField)) {
12
- return;
14
+ if (payload.all != null && typeof payload.all !== 'boolean') {
15
+ return 'all must be a boolean';
13
16
  }
14
- if (!validateLocateOptions(res, payload)) {
15
- return;
17
+ if (payload.exact != null && typeof payload.exact !== 'boolean') {
18
+ return 'exact must be a boolean';
16
19
  }
17
- emitRequest(ctx, res, config.endpoint);
18
- const allowMultiple = payload.all === true;
19
- await handleLocateRequest(res, allowMultiple, () => config.run(ctx, payload));
20
- };
21
- }
22
- export const handleLocateRole = createLocateHandler({
23
- endpoint: 'locate/role',
24
- requiredField: 'role',
25
- run: (ctx, payload) => locateByRole(ctx.cdpSession, ctx.elementRefs, payload),
26
- });
27
- export const handleLocateText = createLocateHandler({
28
- endpoint: 'locate/text',
29
- requiredField: 'text',
30
- run: (ctx, payload) => locateByText(ctx.cdpSession, ctx.elementRefs, payload),
31
- });
32
- export const handleLocateLabel = createLocateHandler({
33
- endpoint: 'locate/label',
34
- requiredField: 'label',
35
- run: (ctx, payload) => locateByLabel(ctx.cdpSession, ctx.elementRefs, payload),
36
- });
37
- const handleLocateRequest = async (res, all, run) => {
38
- try {
39
- const response = await run();
40
- if (!all && response.matches > 1) {
20
+ return null;
21
+ },
22
+ handle: async ({ res, ctx, body: payload }) => {
23
+ const response = await config.run(ctx, payload);
24
+ if (payload.all !== true && response.matches > 1) {
41
25
  return respondMultipleMatches(res, response.matches, 'return');
42
26
  }
43
- respondJson(res, response);
44
- }
45
- catch (error) {
46
- respondError(res, error);
47
- }
48
- };
49
- const validateLocateOptions = (res, payload) => {
50
- if (payload.all != null && typeof payload.all !== 'boolean') {
51
- respondInvalidBody(res, 'all must be a boolean');
52
- return false;
53
- }
54
- if (payload.exact != null && typeof payload.exact !== 'boolean') {
55
- respondInvalidBody(res, 'exact must be a boolean');
56
- return false;
57
- }
58
- return true;
59
- };
60
- const validateRequiredString = (res, value, label) => {
61
- if (typeof value === 'string' && value.trim() !== '') {
62
- return true;
63
- }
64
- respondInvalidBody(res, `${label} is required`);
65
- return false;
66
- };
27
+ return response;
28
+ },
29
+ });
30
+ export const locateRoutes = [
31
+ createLocateRoute({
32
+ endpoint: 'locate/role',
33
+ requiredField: 'role',
34
+ run: (ctx, payload) => locateByRole(ctx.cdpSession, ctx.elementRefs, payload),
35
+ }),
36
+ createLocateRoute({
37
+ endpoint: 'locate/text',
38
+ requiredField: 'text',
39
+ run: (ctx, payload) => locateByText(ctx.cdpSession, ctx.elementRefs, payload),
40
+ }),
41
+ createLocateRoute({
42
+ endpoint: 'locate/label',
43
+ requiredField: 'label',
44
+ run: (ctx, payload) => locateByLabel(ctx.cdpSession, ctx.elementRefs, payload),
45
+ }),
46
+ ];
67
47
  //# sourceMappingURL=postLocate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postLocate.js","sourceRoot":"","sources":["../../../src/http/routes/postLocate.ts"],"names":[],"mappings":"AAEA,OA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GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC;KAC7E,CAAC;IACF,iBAAiB,CAAqB;QACrC,QAAQ,EAAE,cAAc;QACxB,aAAa,EAAE,OAAO;QACtB,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC;KAC9E,CAAC;CACF,CAAA"}
@@ -1,3 +1,2 @@
1
- import type { RouteHandler } from './types.js';
2
- export declare const handle: RouteHandler;
1
+ export declare const route: import("./defineRoute.js").WatcherRouteDefinition;
3
2
  //# sourceMappingURL=postNetClear.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postNetClear.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postNetClear.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,eAAO,MAAM,MAAM,EAAE,YAapB,CAAA"}
1
+ {"version":3,"file":"postNetClear.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postNetClear.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,mDAYhB,CAAA"}
@@ -1,15 +1,16 @@
1
+ import { defineJsonRoute } from './defineRoute.js';
1
2
  import { emitRequest } from './types.js';
2
- import { respondJson } from '../httpUtils.js';
3
- export const handle = (_req, res, _url, ctx) => {
4
- if (!ctx.netBuffer) {
5
- return respondJson(res, { ok: false, error: { code: 'net_disabled', message: 'Network capture is disabled for this watcher' } }, 400);
6
- }
7
- emitRequest(ctx, res, 'net/clear');
8
- const realtimeCleared = ctx.realtimeNetBuffer?.clear() ?? 0;
9
- const response = {
10
- ok: true,
11
- cleared: ctx.netBuffer.clear() + realtimeCleared,
12
- };
13
- respondJson(res, response);
14
- };
3
+ import { respondNetDisabled } from './netFilters.js';
4
+ export const route = defineJsonRoute({
5
+ method: 'POST',
6
+ path: '/net/clear',
7
+ handle: ({ res, ctx }) => {
8
+ if (!ctx.netBuffer) {
9
+ return respondNetDisabled(res);
10
+ }
11
+ emitRequest(ctx, res, 'net/clear');
12
+ const realtimeCleared = ctx.realtimeNetBuffer?.clear() ?? 0;
13
+ return { ok: true, cleared: ctx.netBuffer.clear() + realtimeCleared };
14
+ },
15
+ });
15
16
  //# sourceMappingURL=postNetClear.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postNetClear.js","sourceRoot":"","sources":["../../../src/http/routes/postNetClear.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,CAAC,MAAM,MAAM,GAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IAC5D,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACpB,OAAO,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,8CAA8C,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACtI,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;IAElC,MAAM,eAAe,GAAG,GAAG,CAAC,iBAAiB,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAC3D,MAAM,QAAQ,GAAqB;QAClC,EAAE,EAAE,IAAI;QACR,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,eAAe;KAChD,CAAA;IACD,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC3B,CAAC,CAAA"}
1
+ {"version":3,"file":"postNetClear.js","sourceRoot":"","sources":["../../../src/http/routes/postNetClear.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAA8B;IACjE,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE;QACxB,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAA;QAC/B,CAAC;QAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,CAAC,CAAA;QAClC,MAAM,eAAe,GAAG,GAAG,CAAC,iBAAiB,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QAC3D,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,eAAe,EAAE,CAAA;IACtE,CAAC;CACD,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { type WatcherRouteDefinition } from './defineRoute.js';
2
+ export declare const recordRoutes: readonly WatcherRouteDefinition[];
3
+ //# sourceMappingURL=postRecord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postRecord.d.ts","sourceRoot":"","sources":["../../../src/http/routes/postRecord.ts"],"names":[],"mappings":"AAWA,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAE/E,eAAO,MAAM,YAAY,EAAE,SAAS,sBAAsB,EAyBzD,CAAA"}