@vforsh/argus 0.1.13 → 0.1.15

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 (245) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/argus.js +3963 -2198
  3. package/dist/cli/defineCommand.d.ts +26 -0
  4. package/dist/cli/defineCommand.d.ts.map +1 -0
  5. package/dist/cli/defineCommand.js +55 -0
  6. package/dist/cli/defineCommand.js.map +1 -0
  7. package/dist/cli/defineWatcherCommand.d.ts +112 -0
  8. package/dist/cli/defineWatcherCommand.d.ts.map +1 -0
  9. package/dist/cli/defineWatcherCommand.js +89 -0
  10. package/dist/cli/defineWatcherCommand.js.map +1 -0
  11. package/dist/cli/plugins/pluginAliases.d.ts +6 -0
  12. package/dist/cli/plugins/pluginAliases.d.ts.map +1 -0
  13. package/dist/cli/plugins/pluginAliases.js +10 -0
  14. package/dist/cli/plugins/pluginAliases.js.map +1 -0
  15. package/dist/cli/plugins/pluginHost.d.ts +3 -0
  16. package/dist/cli/plugins/pluginHost.d.ts.map +1 -0
  17. package/dist/cli/plugins/pluginHost.js +30 -0
  18. package/dist/cli/plugins/pluginHost.js.map +1 -0
  19. package/dist/cli/plugins/registerPlugins.d.ts +32 -1
  20. package/dist/cli/plugins/registerPlugins.d.ts.map +1 -1
  21. package/dist/cli/plugins/registerPlugins.js +102 -12
  22. package/dist/cli/plugins/registerPlugins.js.map +1 -1
  23. package/dist/cli/program.d.ts.map +1 -1
  24. package/dist/cli/program.js +2 -0
  25. package/dist/cli/program.js.map +1 -1
  26. package/dist/cli/register/index.d.ts.map +1 -1
  27. package/dist/cli/register/index.js +8 -2
  28. package/dist/cli/register/index.js.map +1 -1
  29. package/dist/cli/register/registerAuth.d.ts.map +1 -1
  30. package/dist/cli/register/registerAuth.js +13 -8
  31. package/dist/cli/register/registerAuth.js.map +1 -1
  32. package/dist/cli/register/registerCode.d.ts.map +1 -1
  33. package/dist/cli/register/registerCode.js +19 -0
  34. package/dist/cli/register/registerCode.js.map +1 -1
  35. package/dist/cli/register/registerDom.d.ts.map +1 -1
  36. package/dist/cli/register/registerDom.js +3 -1
  37. package/dist/cli/register/registerDom.js.map +1 -1
  38. package/dist/cli/register/registerEval.d.ts.map +1 -1
  39. package/dist/cli/register/registerEval.js +13 -0
  40. package/dist/cli/register/registerEval.js.map +1 -1
  41. package/dist/cli/register/registerExtension.d.ts.map +1 -1
  42. package/dist/cli/register/registerExtension.js +12 -0
  43. package/dist/cli/register/registerExtension.js.map +1 -1
  44. package/dist/cli/register/registerNet.d.ts.map +1 -1
  45. package/dist/cli/register/registerNet.js +40 -6
  46. package/dist/cli/register/registerNet.js.map +1 -1
  47. package/dist/cli/register/registerPage.d.ts.map +1 -1
  48. package/dist/cli/register/registerPage.js +17 -0
  49. package/dist/cli/register/registerPage.js.map +1 -1
  50. package/dist/cli/register/registerPlugin.d.ts +3 -0
  51. package/dist/cli/register/registerPlugin.d.ts.map +1 -0
  52. package/dist/cli/register/registerPlugin.js +34 -0
  53. package/dist/cli/register/registerPlugin.js.map +1 -0
  54. package/dist/cli/register/registerSnapshot.d.ts.map +1 -1
  55. package/dist/cli/register/registerSnapshot.js +2 -1
  56. package/dist/cli/register/registerSnapshot.js.map +1 -1
  57. package/dist/cli/register/registerWatcher.d.ts.map +1 -1
  58. package/dist/cli/register/registerWatcher.js +19 -0
  59. package/dist/cli/register/registerWatcher.js.map +1 -1
  60. package/dist/commands/auth.d.ts.map +1 -1
  61. package/dist/commands/auth.js +4 -9
  62. package/dist/commands/auth.js.map +1 -1
  63. package/dist/commands/authCookieSupport.d.ts.map +1 -1
  64. package/dist/commands/authCookieSupport.js +4 -6
  65. package/dist/commands/authCookieSupport.js.map +1 -1
  66. package/dist/commands/authCookies.d.ts +4 -4
  67. package/dist/commands/authCookies.d.ts.map +1 -1
  68. package/dist/commands/authCookies.js +85 -105
  69. package/dist/commands/authCookies.js.map +1 -1
  70. package/dist/commands/code.js +3 -25
  71. package/dist/commands/code.js.map +1 -1
  72. package/dist/commands/codeEdit.d.ts +9 -0
  73. package/dist/commands/codeEdit.d.ts.map +1 -0
  74. package/dist/commands/codeEdit.js +155 -0
  75. package/dist/commands/codeEdit.js.map +1 -0
  76. package/dist/commands/configInit.d.ts.map +1 -1
  77. package/dist/commands/configInit.js +1 -0
  78. package/dist/commands/configInit.js.map +1 -1
  79. package/dist/commands/dialog.d.ts +5 -5
  80. package/dist/commands/dialog.d.ts.map +1 -1
  81. package/dist/commands/dialog.js +36 -54
  82. package/dist/commands/dialog.js.map +1 -1
  83. package/dist/commands/domAdd.d.ts +1 -1
  84. package/dist/commands/domAdd.d.ts.map +1 -1
  85. package/dist/commands/domAdd.js +26 -30
  86. package/dist/commands/domAdd.js.map +1 -1
  87. package/dist/commands/domClick.d.ts +4 -1
  88. package/dist/commands/domClick.d.ts.map +1 -1
  89. package/dist/commands/domClick.js +83 -75
  90. package/dist/commands/domClick.js.map +1 -1
  91. package/dist/commands/domFill.d.ts +2 -2
  92. package/dist/commands/domFill.d.ts.map +1 -1
  93. package/dist/commands/domFill.js +56 -67
  94. package/dist/commands/domFill.js.map +1 -1
  95. package/dist/commands/domFocus.d.ts +1 -1
  96. package/dist/commands/domFocus.d.ts.map +1 -1
  97. package/dist/commands/domFocus.js +27 -35
  98. package/dist/commands/domFocus.js.map +1 -1
  99. package/dist/commands/domHover.d.ts +1 -1
  100. package/dist/commands/domHover.d.ts.map +1 -1
  101. package/dist/commands/domHover.js +27 -35
  102. package/dist/commands/domHover.js.map +1 -1
  103. package/dist/commands/domInfo.d.ts +1 -1
  104. package/dist/commands/domInfo.d.ts.map +1 -1
  105. package/dist/commands/domInfo.js +18 -23
  106. package/dist/commands/domInfo.js.map +1 -1
  107. package/dist/commands/domKeydown.d.ts +1 -1
  108. package/dist/commands/domKeydown.d.ts.map +1 -1
  109. package/dist/commands/domKeydown.js +22 -43
  110. package/dist/commands/domKeydown.js.map +1 -1
  111. package/dist/commands/domModify.js +27 -30
  112. package/dist/commands/domModify.js.map +1 -1
  113. package/dist/commands/domRemove.d.ts +1 -1
  114. package/dist/commands/domRemove.d.ts.map +1 -1
  115. package/dist/commands/domRemove.js +25 -34
  116. package/dist/commands/domRemove.js.map +1 -1
  117. package/dist/commands/domScroll.d.ts +2 -2
  118. package/dist/commands/domScroll.d.ts.map +1 -1
  119. package/dist/commands/domScroll.js +19 -25
  120. package/dist/commands/domScroll.js.map +1 -1
  121. package/dist/commands/domScrollTo.d.ts +1 -1
  122. package/dist/commands/domScrollTo.d.ts.map +1 -1
  123. package/dist/commands/domScrollTo.js +15 -24
  124. package/dist/commands/domScrollTo.js.map +1 -1
  125. package/dist/commands/domSetFile.d.ts +1 -1
  126. package/dist/commands/domSetFile.d.ts.map +1 -1
  127. package/dist/commands/domSetFile.js +24 -33
  128. package/dist/commands/domSetFile.js.map +1 -1
  129. package/dist/commands/domTree.d.ts +1 -1
  130. package/dist/commands/domTree.d.ts.map +1 -1
  131. package/dist/commands/domTree.js +18 -24
  132. package/dist/commands/domTree.js.map +1 -1
  133. package/dist/commands/eval.d.ts +4 -0
  134. package/dist/commands/eval.d.ts.map +1 -1
  135. package/dist/commands/eval.js +43 -56
  136. package/dist/commands/eval.js.map +1 -1
  137. package/dist/commands/evalPolling.d.ts +55 -0
  138. package/dist/commands/evalPolling.d.ts.map +1 -0
  139. package/dist/commands/evalPolling.js +59 -0
  140. package/dist/commands/evalPolling.js.map +1 -0
  141. package/dist/commands/evalShared.d.ts +24 -0
  142. package/dist/commands/evalShared.d.ts.map +1 -1
  143. package/dist/commands/evalShared.js +75 -7
  144. package/dist/commands/evalShared.js.map +1 -1
  145. package/dist/commands/evalUntil.d.ts +4 -0
  146. package/dist/commands/evalUntil.d.ts.map +1 -1
  147. package/dist/commands/evalUntil.js +47 -64
  148. package/dist/commands/evalUntil.js.map +1 -1
  149. package/dist/commands/extension/resolveExtensionWatcher.d.ts +20 -0
  150. package/dist/commands/extension/resolveExtensionWatcher.d.ts.map +1 -0
  151. package/dist/commands/extension/resolveExtensionWatcher.js +73 -0
  152. package/dist/commands/extension/resolveExtensionWatcher.js.map +1 -0
  153. package/dist/commands/extension/tabs.d.ts +8 -0
  154. package/dist/commands/extension/tabs.d.ts.map +1 -0
  155. package/dist/commands/extension/tabs.js +85 -0
  156. package/dist/commands/extension/tabs.js.map +1 -0
  157. package/dist/commands/locate.js +2 -2
  158. package/dist/commands/locate.js.map +1 -1
  159. package/dist/commands/logs.d.ts +1 -1
  160. package/dist/commands/logs.d.ts.map +1 -1
  161. package/dist/commands/logs.js +18 -27
  162. package/dist/commands/logs.js.map +1 -1
  163. package/dist/commands/net.d.ts +1 -1
  164. package/dist/commands/net.d.ts.map +1 -1
  165. package/dist/commands/net.js +14 -19
  166. package/dist/commands/net.js.map +1 -1
  167. package/dist/commands/netCapture.d.ts +10 -5
  168. package/dist/commands/netCapture.d.ts.map +1 -1
  169. package/dist/commands/netCapture.js +113 -15
  170. package/dist/commands/netCapture.js.map +1 -1
  171. package/dist/commands/netClear.d.ts +1 -1
  172. package/dist/commands/netClear.d.ts.map +1 -1
  173. package/dist/commands/netClear.js +7 -19
  174. package/dist/commands/netClear.js.map +1 -1
  175. package/dist/commands/netExport.d.ts +2 -7
  176. package/dist/commands/netExport.d.ts.map +1 -1
  177. package/dist/commands/netExport.js.map +1 -1
  178. package/dist/commands/netSse.d.ts +6 -0
  179. package/dist/commands/netSse.d.ts.map +1 -0
  180. package/dist/commands/netSse.js +26 -0
  181. package/dist/commands/netSse.js.map +1 -0
  182. package/dist/commands/netWatch.d.ts +2 -7
  183. package/dist/commands/netWatch.d.ts.map +1 -1
  184. package/dist/commands/netWatch.js.map +1 -1
  185. package/dist/commands/netWebSocket.d.ts +10 -0
  186. package/dist/commands/netWebSocket.d.ts.map +1 -0
  187. package/dist/commands/netWebSocket.js +58 -0
  188. package/dist/commands/netWebSocket.js.map +1 -0
  189. package/dist/commands/pageEmulation.d.ts +3 -3
  190. package/dist/commands/pageEmulation.d.ts.map +1 -1
  191. package/dist/commands/pageEmulation.js +72 -143
  192. package/dist/commands/pageEmulation.js.map +1 -1
  193. package/dist/commands/pageVisibility.d.ts +9 -0
  194. package/dist/commands/pageVisibility.d.ts.map +1 -0
  195. package/dist/commands/pageVisibility.js +24 -0
  196. package/dist/commands/pageVisibility.js.map +1 -0
  197. package/dist/commands/pluginConfig.d.ts +7 -0
  198. package/dist/commands/pluginConfig.d.ts.map +1 -0
  199. package/dist/commands/pluginConfig.js +199 -0
  200. package/dist/commands/pluginConfig.js.map +1 -0
  201. package/dist/commands/pluginList.d.ts +5 -0
  202. package/dist/commands/pluginList.d.ts.map +1 -0
  203. package/dist/commands/pluginList.js +26 -0
  204. package/dist/commands/pluginList.js.map +1 -0
  205. package/dist/commands/reload.d.ts +1 -1
  206. package/dist/commands/reload.d.ts.map +1 -1
  207. package/dist/commands/reload.js +8 -17
  208. package/dist/commands/reload.js.map +1 -1
  209. package/dist/commands/screenshot.d.ts +2 -1
  210. package/dist/commands/screenshot.d.ts.map +1 -1
  211. package/dist/commands/screenshot.js +45 -16
  212. package/dist/commands/screenshot.js.map +1 -1
  213. package/dist/commands/snapshot.d.ts +1 -1
  214. package/dist/commands/snapshot.d.ts.map +1 -1
  215. package/dist/commands/snapshot.js +26 -49
  216. package/dist/commands/snapshot.js.map +1 -1
  217. package/dist/commands/storage.d.ts.map +1 -1
  218. package/dist/commands/storage.js +26 -58
  219. package/dist/commands/storage.js.map +1 -1
  220. package/dist/commands/throttle.d.ts +6 -3
  221. package/dist/commands/throttle.d.ts.map +1 -1
  222. package/dist/commands/throttle.js +46 -118
  223. package/dist/commands/throttle.js.map +1 -1
  224. package/dist/commands/watcherStatus.d.ts +1 -1
  225. package/dist/commands/watcherStatus.d.ts.map +1 -1
  226. package/dist/commands/watcherStatus.js +8 -20
  227. package/dist/commands/watcherStatus.js.map +1 -1
  228. package/dist/config/argusConfig.d.ts +5 -0
  229. package/dist/config/argusConfig.d.ts.map +1 -1
  230. package/dist/config/argusConfig.js +33 -2
  231. package/dist/config/argusConfig.js.map +1 -1
  232. package/dist/eval/evalClient.d.ts +1 -0
  233. package/dist/eval/evalClient.d.ts.map +1 -1
  234. package/dist/eval/evalClient.js +2 -0
  235. package/dist/eval/evalClient.js.map +1 -1
  236. package/dist/output/net.d.ts +4 -1
  237. package/dist/output/net.d.ts.map +1 -1
  238. package/dist/output/net.js +59 -0
  239. package/dist/output/net.js.map +1 -1
  240. package/package.json +2 -2
  241. package/schemas/argus.config.schema.json +16 -0
  242. package/dist/cli/register/registerClick.d.ts +0 -3
  243. package/dist/cli/register/registerClick.d.ts.map +0 -1
  244. package/dist/cli/register/registerClick.js +0 -24
  245. package/dist/cli/register/registerClick.js.map +0 -1
@@ -1,12 +1,62 @@
1
1
  import { readFile } from 'node:fs/promises';
2
- import { createOutput } from '../output/io.js';
2
+ import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
3
3
  import { formatError } from '../cli/parse.js';
4
- import { readStdin } from './evalShared.js';
5
4
  import { resolvePath } from '../utils/paths.js';
6
- import { requestWatcherAction } from '../watchers/requestWatcher.js';
7
5
  import { describeElementTarget, parseWaitDuration, requireElementTarget, writeNoElementFound } from './dom/shared.js';
8
- /** Resolve the fill value from inline argument, --value-file, or --value-stdin. Returns null on error. */
9
- const resolveValueInput = async (value, options, output) => {
6
+ import { readStdin } from './evalShared.js';
7
+ /** Execute the dom fill command for a watcher id. The first positional arg is the inline value. */
8
+ export const runDomFill = defineWatcherCommand({
9
+ build: async ([value], options, output) => buildFillPlan(value, options, output),
10
+ formatHuman: (response, { output, options }) => {
11
+ const target = { selector: resolveFillSelector(options), ref: options.ref };
12
+ if (response.matches === 0) {
13
+ writeNoElementFound(target.selector ?? target.ref, output);
14
+ return;
15
+ }
16
+ const elLabel = response.filled === 1 ? '1 element' : `${response.filled} elements`;
17
+ output.writeHuman(`Filled ${elLabel} for ${describeElementTarget(target)}`);
18
+ },
19
+ });
20
+ /** Apply the `--name` shorthand: `--name foo` is equivalent to `--selector '[name="foo"]'`. */
21
+ const resolveFillSelector = (options) => (options.name ? `[name="${options.name}"]` : options.selector);
22
+ /** Resolve `--name` shorthand, the value source, and `--wait` into a `/dom/fill` request plan. */
23
+ const buildFillPlan = async (value, options, output) => {
24
+ if (options.name && (options.selector || options.ref)) {
25
+ output.writeWarn('Cannot use --name with --selector or --ref');
26
+ process.exitCode = 2;
27
+ return null;
28
+ }
29
+ const target = requireElementTarget({ selector: resolveFillSelector(options), ref: options.ref }, output);
30
+ if (!target)
31
+ return null;
32
+ const resolvedValue = await resolveFillValue(value, options, output);
33
+ if (resolvedValue == null) {
34
+ process.exitCode = 2;
35
+ return null;
36
+ }
37
+ const waitMs = parseWaitDuration(options.wait, output);
38
+ if (waitMs == null)
39
+ return null;
40
+ const body = {
41
+ value: resolvedValue,
42
+ all: options.all ?? false,
43
+ text: options.text,
44
+ };
45
+ if (target.selector)
46
+ body.selector = target.selector;
47
+ if (target.ref)
48
+ body.ref = target.ref;
49
+ if (waitMs > 0)
50
+ body.wait = waitMs;
51
+ return {
52
+ path: '/dom/fill',
53
+ method: 'POST',
54
+ body,
55
+ timeoutMs: Math.max(30_000, waitMs + 5_000),
56
+ };
57
+ };
58
+ /** Resolve the fill value from inline arg, --value-file, or --value-stdin. Returns null on error. */
59
+ const resolveFillValue = async (value, options, output) => {
10
60
  const wantsStdin = options.valueStdin === true || value === '-';
11
61
  const hasInline = value != null && value !== '-';
12
62
  const hasFile = options.valueFile != null;
@@ -43,70 +93,9 @@ const resolveValueInput = async (value, options, output) => {
43
93
  return null;
44
94
  }
45
95
  }
46
- if (hasInline) {
96
+ if (hasInline)
47
97
  return value;
48
- }
49
98
  output.writeWarn('Value is required. Provide an inline value, --value-file, or --value-stdin (or pass - as value).');
50
99
  return null;
51
100
  };
52
- /** Execute the dom fill command for a watcher id. */
53
- export const runDomFill = async (id, value, options) => {
54
- const output = createOutput(options);
55
- if (options.name && (options.selector || options.ref)) {
56
- output.writeWarn('Cannot use --name with --selector or --ref');
57
- process.exitCode = 2;
58
- return;
59
- }
60
- if (options.name) {
61
- options.selector = `[name="${options.name}"]`;
62
- }
63
- const target = requireElementTarget({ selector: options.selector, ref: options.ref }, output);
64
- if (!target) {
65
- return;
66
- }
67
- const resolvedValue = await resolveValueInput(value, options, output);
68
- if (resolvedValue == null) {
69
- process.exitCode = 2;
70
- return;
71
- }
72
- const waitMs = parseWaitDuration(options.wait, output);
73
- if (waitMs == null) {
74
- return;
75
- }
76
- const body = {
77
- value: resolvedValue,
78
- all: options.all ?? false,
79
- text: options.text,
80
- };
81
- if (target.selector) {
82
- body.selector = target.selector;
83
- }
84
- if (target.ref) {
85
- body.ref = target.ref;
86
- }
87
- if (waitMs > 0) {
88
- body.wait = waitMs;
89
- }
90
- const result = await requestWatcherAction({
91
- id,
92
- path: '/dom/fill',
93
- method: 'POST',
94
- body,
95
- timeoutMs: Math.max(30_000, waitMs + 5_000),
96
- }, output);
97
- if (!result) {
98
- return;
99
- }
100
- const successResp = result.data;
101
- if (options.json) {
102
- output.writeJson(successResp);
103
- return;
104
- }
105
- if (successResp.matches === 0) {
106
- writeNoElementFound(target.selector ?? target.ref, output);
107
- return;
108
- }
109
- const elLabel = successResp.filled === 1 ? '1 element' : `${successResp.filled} elements`;
110
- output.writeHuman(`Filled ${elLabel} for ${describeElementTarget(target)}`);
111
- };
112
101
  //# sourceMappingURL=domFill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domFill.js","sourceRoot":"","sources":["../../src/commands/domFill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAe,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+B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AAI,CAAA;AACZ,CAAC,CAAA"}
@@ -7,5 +7,5 @@ export type DomFocusOptions = {
7
7
  json?: boolean;
8
8
  };
9
9
  /** Execute the dom focus command for a watcher id. */
10
- export declare const runDomFocus: (id: string | undefined, options: DomFocusOptions) => Promise<void>;
10
+ export declare const runDomFocus: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], DomFocusOptions>;
11
11
  //# sourceMappingURL=domFocus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domFocus.d.ts","sourceRoot":"","sources":["../../src/commands/domFocus.ts"],"names":[],"mappings":"AAKA,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,WAAW,GAAU,IAAI,MAAM,GAAG,SAAS,EAAE,SAAS,eAAe,KAAG,OAAO,CAAC,IAAI,CAuChG,CAAA"}
1
+ {"version":3,"file":"domFocus.d.ts","sourceRoot":"","sources":["../../src/commands/domFocus.ts"],"names":[],"mappings":"AAIA,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,WAAW,oFAyBtB,CAAA"}
@@ -1,38 +1,30 @@
1
- import { createOutput } from '../output/io.js';
2
- import { requestWatcherAction } from '../watchers/requestWatcher.js';
1
+ import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
3
2
  import { describeElementTarget, requireElementTarget, writeNoElementFound } from './dom/shared.js';
4
3
  /** Execute the dom focus command for a watcher id. */
5
- export const runDomFocus = async (id, options) => {
6
- const output = createOutput(options);
7
- const target = requireElementTarget({ selector: options.selector, ref: options.ref }, output);
8
- if (!target) {
9
- return;
10
- }
11
- const result = await requestWatcherAction({
12
- id,
13
- path: '/dom/focus',
14
- method: 'POST',
15
- body: {
16
- selector: target.selector,
17
- ref: target.ref,
18
- all: options.all ?? false,
19
- text: options.text,
20
- },
21
- timeoutMs: 30_000,
22
- }, output);
23
- if (!result) {
24
- return;
25
- }
26
- const successResp = result.data;
27
- if (options.json) {
28
- output.writeJson(successResp);
29
- return;
30
- }
31
- if (successResp.matches === 0) {
32
- writeNoElementFound(target.selector ?? target.ref, output);
33
- return;
34
- }
35
- const label = successResp.focused === 1 ? 'element' : 'elements';
36
- output.writeHuman(`Focused ${successResp.focused} ${label} for ${describeElementTarget(target)}`);
37
- };
4
+ export const runDomFocus = defineWatcherCommand({
5
+ build: (_args, options, output) => {
6
+ const target = requireElementTarget({ selector: options.selector, ref: options.ref }, output);
7
+ if (!target)
8
+ return null;
9
+ return {
10
+ path: '/dom/focus',
11
+ method: 'POST',
12
+ body: {
13
+ selector: target.selector,
14
+ ref: target.ref,
15
+ all: options.all ?? false,
16
+ text: options.text,
17
+ },
18
+ };
19
+ },
20
+ formatHuman: (response, { output, options }) => {
21
+ const target = { selector: options.selector, ref: options.ref };
22
+ if (response.matches === 0) {
23
+ writeNoElementFound(target.selector ?? target.ref, output);
24
+ return;
25
+ }
26
+ const label = response.focused === 1 ? 'element' : 'elements';
27
+ output.writeHuman(`Focused ${response.focused} ${label} for ${describeElementTarget(target)}`);
28
+ },
29
+ });
38
30
  //# sourceMappingURL=domFocus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domFocus.js","sourceRoot":"","sources":["../../src/commands/domFocus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OA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AK,CAAC,EAAE,CAAC;YAC5B,mBAAmB,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,GAAI,EAAE,MAAM,CAAC,CAAA;YAC3D,OAAM;QACP,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;QAC7D,MAAM,CAAC,UAAU,CAAC,WAAW,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC/F,CAAC;CACD,CAAC,CAAA"}
@@ -7,5 +7,5 @@ export type DomHoverOptions = {
7
7
  json?: boolean;
8
8
  };
9
9
  /** Execute the dom hover command for a watcher id. */
10
- export declare const runDomHover: (id: string | undefined, options: DomHoverOptions) => Promise<void>;
10
+ export declare const runDomHover: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], DomHoverOptions>;
11
11
  //# sourceMappingURL=domHover.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domHover.d.ts","sourceRoot":"","sources":["../../src/commands/domHover.ts"],"names":[],"mappings":"AAKA,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,WAAW,GAAU,IAAI,MAAM,GAAG,SAAS,EAAE,SAAS,eAAe,KAAG,OAAO,CAAC,IAAI,CAuChG,CAAA"}
1
+ {"version":3,"file":"domHover.d.ts","sourceRoot":"","sources":["../../src/commands/domHover.ts"],"names":[],"mappings":"AAIA,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,WAAW,oFAyBtB,CAAA"}
@@ -1,38 +1,30 @@
1
- import { createOutput } from '../output/io.js';
2
- import { requestWatcherAction } from '../watchers/requestWatcher.js';
1
+ import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
3
2
  import { describeElementTarget, requireElementTarget, writeNoElementFound } from './dom/shared.js';
4
3
  /** Execute the dom hover command for a watcher id. */
5
- export const runDomHover = async (id, options) => {
6
- const output = createOutput(options);
7
- const target = requireElementTarget({ selector: options.selector, ref: options.ref }, output);
8
- if (!target) {
9
- return;
10
- }
11
- const result = await requestWatcherAction({
12
- id,
13
- path: '/dom/hover',
14
- method: 'POST',
15
- body: {
16
- selector: target.selector,
17
- ref: target.ref,
18
- all: options.all ?? false,
19
- text: options.text,
20
- },
21
- timeoutMs: 30_000,
22
- }, output);
23
- if (!result) {
24
- return;
25
- }
26
- const successResp = result.data;
27
- if (options.json) {
28
- output.writeJson(successResp);
29
- return;
30
- }
31
- if (successResp.matches === 0) {
32
- writeNoElementFound(target.selector ?? target.ref, output);
33
- return;
34
- }
35
- const label = successResp.hovered === 1 ? 'element' : 'elements';
36
- output.writeHuman(`Hovered ${successResp.hovered} ${label} for ${describeElementTarget(target)}`);
37
- };
4
+ export const runDomHover = defineWatcherCommand({
5
+ build: (_args, options, output) => {
6
+ const target = requireElementTarget({ selector: options.selector, ref: options.ref }, output);
7
+ if (!target)
8
+ return null;
9
+ return {
10
+ path: '/dom/hover',
11
+ method: 'POST',
12
+ body: {
13
+ selector: target.selector,
14
+ ref: target.ref,
15
+ all: options.all ?? false,
16
+ text: options.text,
17
+ },
18
+ };
19
+ },
20
+ formatHuman: (response, { output, options }) => {
21
+ const target = { selector: options.selector, ref: options.ref };
22
+ if (response.matches === 0) {
23
+ writeNoElementFound(target.selector ?? target.ref, output);
24
+ return;
25
+ }
26
+ const label = response.hovered === 1 ? 'element' : 'elements';
27
+ output.writeHuman(`Hovered ${response.hovered} ${label} for ${describeElementTarget(target)}`);
28
+ },
29
+ });
38
30
  //# sourceMappingURL=domHover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domHover.js","sourceRoot":"","sources":["../../src/commands/domHover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAWlG,sDAAsD;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,EAAsB,EAAE,OAAwB,EAAiB,EAAE;IACpG,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,oBAAoB,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAA;IAC7F,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAM;IACP,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACxC;QACC,EAAE;QACF,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI;SAClB;QACD,SAAS,EAAE,MAAM;KACjB,EACD,MAAM,CACN,CAAA;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAM;IACP,CAAC;IACD,MA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AAM,CAAC,GAAG;gBACf,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK;gBACzB,IAAI,EAAE,OAAO,CAAC,IAAI;aAClB;SACD,CAAA;IACF,CAAC;IACD,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAA;QAC/D,IAAI,QAAQ,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YAC5B,mBAAmB,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,GAAI,EAAE,MAAM,CAAC,CAAA;YAC3D,OAAM;QACP,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;QAC7D,MAAM,CAAC,UAAU,CAAC,WAAW,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC/F,CAAC;CACD,CAAC,CAAA"}
@@ -8,5 +8,5 @@ export type DomInfoOptions = {
8
8
  json?: boolean;
9
9
  };
10
10
  /** Execute the dom info command for a watcher id. */
11
- export declare const runDomInfo: (id: string | undefined, options: DomInfoOptions) => Promise<void>;
11
+ export declare const runDomInfo: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], DomInfoOptions>;
12
12
  //# sourceMappingURL=domInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domInfo.d.ts","sourceRoot":"","sources":["../../src/commands/domInfo.ts"],"names":[],"mappings":"AAOA,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,UAAU,GAAU,IAAI,MAAM,GAAG,SAAS,EAAE,SAAS,cAAc,KAAG,OAAO,CAAC,IAAI,CA+C9F,CAAA"}
1
+ {"version":3,"file":"domInfo.d.ts","sourceRoot":"","sources":["../../src/commands/domInfo.ts"],"names":[],"mappings":"AAOA,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,qDAAqD;AACrD,eAAO,MAAM,UAAU,mFAYrB,CAAA"}
@@ -1,23 +1,32 @@
1
1
  import { formatDomInfo } from '../output/dom.js';
2
- import { createOutput } from '../output/io.js';
3
2
  import { parsePositiveInt } from '../cli/parse.js';
4
- import { requestWatcherAction } from '../watchers/requestWatcher.js';
3
+ import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
5
4
  import { requireElementTarget, writeNoElementFound } from './dom/shared.js';
6
5
  /** Execute the dom info command for a watcher id. */
7
- export const runDomInfo = async (id, options) => {
8
- const output = createOutput(options);
6
+ export const runDomInfo = defineWatcherCommand({
7
+ build: (_args, options, output) => buildDomInfoPlan(options, output),
8
+ formatHuman: (response, { output, options }) => {
9
+ const target = { selector: options.selector, ref: options.ref };
10
+ if (response.matches === 0) {
11
+ writeNoElementFound(target.selector ?? target.ref, output);
12
+ return;
13
+ }
14
+ const formatted = formatDomInfo(response.elements);
15
+ output.writeHuman(formatted);
16
+ },
17
+ });
18
+ const buildDomInfoPlan = (options, output) => {
9
19
  const target = requireElementTarget({ selector: options.selector, ref: options.ref }, output);
10
20
  if (!target) {
11
- return;
21
+ return null;
12
22
  }
13
23
  const outerHtmlMaxChars = parsePositiveInt(options.outerHtmlMax);
14
24
  if (options.outerHtmlMax !== undefined && outerHtmlMaxChars === undefined) {
15
25
  output.writeWarn('--outer-html-max must be a positive integer');
16
26
  process.exitCode = 2;
17
- return;
27
+ return null;
18
28
  }
19
- const result = await requestWatcherAction({
20
- id,
29
+ return {
21
30
  path: '/dom/info',
22
31
  method: 'POST',
23
32
  body: {
@@ -28,20 +37,6 @@ export const runDomInfo = async (id, options) => {
28
37
  text: options.text,
29
38
  },
30
39
  timeoutMs: 30_000,
31
- }, output);
32
- if (!result) {
33
- return;
34
- }
35
- const successResp = result.data;
36
- if (options.json) {
37
- output.writeJson(successResp);
38
- return;
39
- }
40
- if (successResp.matches === 0) {
41
- writeNoElementFound(target.selector ?? target.ref, output);
42
- return;
43
- }
44
- const formatted = formatDomInfo(successResp.elements);
45
- output.writeHuman(formatted);
40
+ };
46
41
  };
47
42
  //# sourceMappingURL=domInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domInfo.js","sourceRoot":"","sources":["../../src/commands/domInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAY3E,qDAAqD;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAsB,EAAE,OAAuB,EAAiB,EAAE;IAClG,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,oBAAoB,CA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G,EAAE,EAAE,MAAM,CAAC,CAAA;IAC7F,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAChE,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC3E,MAAM,CAAC,SAAS,CAAC,6CAA6C,CAAC,CAAA;QAC/D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK;YACzB,iBAAiB;YACjB,IAAI,EAAE,OAAO,CAAC,IAAI;SAClB;QACD,SAAS,EAAE,MAAM;KACjB,CAAA;AACF,CAAC,CAAA"}
@@ -6,5 +6,5 @@ export type DomKeydownOptions = {
6
6
  json?: boolean;
7
7
  };
8
8
  /** Execute the dom keydown command for a watcher id. */
9
- export declare const runDomKeydown: (id: string | undefined, options: DomKeydownOptions) => Promise<void>;
9
+ export declare const runDomKeydown: import("../cli/defineWatcherCommand.js").WatcherCommandRunner<[], DomKeydownOptions>;
10
10
  //# sourceMappingURL=domKeydown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domKeydown.d.ts","sourceRoot":"","sources":["../../src/commands/domKeydown.ts"],"names":[],"mappings":"AAIA,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,wDAAwD;AACxD,eAAO,MAAM,aAAa,GAAU,IAAI,MAAM,GAAG,SAAS,EAAE,SAAS,iBAAiB,KAAG,OAAO,CAAC,IAAI,CA8CpG,CAAA"}
1
+ {"version":3,"file":"domKeydown.d.ts","sourceRoot":"","sources":["../../src/commands/domKeydown.ts"],"names":[],"mappings":"AAGA,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACd,CAAA;AAED,wDAAwD;AACxD,eAAO,MAAM,aAAa,sFAqBxB,CAAA"}
@@ -1,46 +1,25 @@
1
- import { createOutput } from '../output/io.js';
2
- import { requestWatcherJson, writeRequestError } from '../watchers/requestWatcher.js';
1
+ import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
3
2
  /** Execute the dom keydown command for a watcher id. */
4
- export const runDomKeydown = async (id, options) => {
5
- const output = createOutput(options);
6
- if (!options.key || options.key.trim() === '') {
7
- output.writeWarn('--key is required');
8
- process.exitCode = 2;
9
- return;
10
- }
11
- const result = await requestWatcherJson({
12
- id,
13
- path: '/dom/keydown',
14
- method: 'POST',
15
- body: {
16
- key: options.key,
17
- selector: options.selector,
18
- modifiers: options.modifiers,
19
- },
20
- timeoutMs: 30_000,
21
- returnErrorResponse: true,
22
- });
23
- if (!result.ok) {
24
- writeRequestError(result, output);
25
- return;
26
- }
27
- const response = result.data;
28
- if (!response.ok) {
29
- const errorResp = response;
30
- if (options.json) {
31
- output.writeJson(response);
3
+ export const runDomKeydown = defineWatcherCommand({
4
+ build: (_args, options, output) => {
5
+ if (!options.key || options.key.trim() === '') {
6
+ output.writeWarn('--key is required');
7
+ process.exitCode = 2;
8
+ return null;
32
9
  }
33
- else {
34
- output.writeWarn(`Error: ${errorResp.error.message}`);
35
- }
36
- process.exitCode = 1;
37
- return;
38
- }
39
- const successResp = response;
40
- if (options.json) {
41
- output.writeJson(successResp);
42
- return;
43
- }
44
- output.writeHuman(`Dispatched keydown: ${successResp.key}`);
45
- };
10
+ return {
11
+ path: '/dom/keydown',
12
+ method: 'POST',
13
+ body: {
14
+ key: options.key,
15
+ selector: options.selector,
16
+ modifiers: options.modifiers,
17
+ },
18
+ timeoutMs: 30_000,
19
+ };
20
+ },
21
+ formatHuman: (response, { output }) => {
22
+ output.writeHuman(`Dispatched keydown: ${response.key}`);
23
+ },
24
+ });
46
25
  //# sourceMappingURL=domKeydown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domKeydown.js","sourceRoot":"","sources":["../../src/commands/domKeydown.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAUrF,wDAAwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAAsB,EAAE,OAA0B,EAAiB,EAAE;IACxG,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IACpC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAA;QACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACP,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAqC;QAC3E,EAAE;QACF,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACL,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B;QACD,SAAS,EAAE,MAAM;QACjB,mBAAmB,EAAE,IAAI;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QAAQ,GAAG,CAAC,CAAA;YACpB,OAAO,IAAI,CAAA;QACZ,CAAC;QACD,OAAO;YACN,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACL,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;aAC5B;YACD,SAAS,EAAE,MAAM;SACjB,CAAA;IACF,CAAC;IACD,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACrC,MAAM,CAAC,UAAU,CAAC,uBAAuB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CACD,CAAC,CAAA"}
@@ -1,37 +1,34 @@
1
+ import { defineWatcherCommand } from '../cli/defineWatcherCommand.js';
1
2
  import { createOutput } from '../output/io.js';
2
- import { requestWatcherAction } from '../watchers/requestWatcher.js';
3
3
  import { requireSelector, writeNoElementFound } from './dom/shared.js';
4
4
  const executeModify = async (id, options, payload, successMessage) => {
5
- const output = createOutput(options);
6
- const selector = requireSelector(options, output);
7
- if (!selector) {
8
- return;
9
- }
10
- const result = await requestWatcherAction({
11
- id,
12
- path: '/dom/modify',
13
- method: 'POST',
14
- body: {
15
- ...payload,
16
- selector,
17
- ...(options.text != null ? { text: options.text } : {}),
18
- },
19
- timeoutMs: 30_000,
20
- }, output);
21
- if (!result) {
22
- return;
23
- }
24
- const successResp = result.data;
25
- if (options.json) {
26
- output.writeJson(successResp);
27
- return;
28
- }
29
- if (successResp.matches === 0) {
30
- writeNoElementFound(selector, output);
31
- return;
32
- }
33
- output.writeHuman(successMessage(successResp));
5
+ await runDomModifyRequest(id, payload, successMessage, options);
34
6
  };
7
+ const runDomModifyRequest = defineWatcherCommand({
8
+ build: ([payload], options, output) => {
9
+ const selector = requireSelector(options, output);
10
+ if (!selector) {
11
+ return null;
12
+ }
13
+ return {
14
+ path: '/dom/modify',
15
+ method: 'POST',
16
+ body: {
17
+ ...payload,
18
+ selector,
19
+ ...(options.text != null ? { text: options.text } : {}),
20
+ },
21
+ timeoutMs: 30_000,
22
+ };
23
+ },
24
+ formatHuman: (successResp, { output, options, args }) => {
25
+ if (successResp.matches === 0) {
26
+ writeNoElementFound(options.selector, output);
27
+ return;
28
+ }
29
+ output.writeHuman(args[1](successResp));
30
+ },
31
+ });
35
32
  /**
36
33
  * Parse attribute arguments: "name" (boolean) or "name=value".
37
34
  */