MCPcopy Index your code
hub / github.com/callstack/agent-device / getClickButtonValidationError

Function getClickButtonValidationError

src/core/click-button.ts:14–55  ·  view source on GitHub ↗
(options: {
  commandLabel: string;
  platform: string;
  button: ClickButton;
  count?: number;
  intervalMs?: number;
  holdMs?: number;
  jitterPx?: number;
  doubleTap?: boolean;
})

Source from the content-addressed store, hash-verified

12}
13
14export function getClickButtonValidationError(options: {
15 commandLabel: string;
16 platform: string;
17 button: ClickButton;
18 count?: number;
19 intervalMs?: number;
20 holdMs?: number;
21 jitterPx?: number;
22 doubleTap?: boolean;
23}): AppError | null {
24 if (options.button === 'primary') {
25 return null;
26 }
27 if (options.commandLabel !== 'click') {
28 return new AppError('INVALID_ARGS', '--button is supported only for click');
29 }
30 if (options.platform !== 'macos' && options.platform !== 'linux') {
31 return new AppError(
32 'UNSUPPORTED_OPERATION',
33 `click --button ${options.button} is supported only on macOS and Linux`,
34 );
35 }
36 if (options.platform === 'macos' && options.button === 'middle') {
37 return new AppError(
38 'UNSUPPORTED_OPERATION',
39 'click --button middle is not supported by the macOS runner yet',
40 );
41 }
42 if (
43 typeof options.count === 'number' ||
44 typeof options.intervalMs === 'number' ||
45 typeof options.holdMs === 'number' ||
46 typeof options.jitterPx === 'number' ||
47 options.doubleTap === true
48 ) {
49 return new AppError(
50 'INVALID_ARGS',
51 `click --button ${options.button} does not support repeat or gesture modifier flags`,
52 );
53 }
54 return null;
55}
56
57export function buttonTag(button: ClickButton): {} | { button: ClickButton } {
58 return button === 'primary' ? {} : { button };

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected