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

Function runDirectPressSeries

src/core/dispatch-interactions.ts:498–538  ·  view source on GitHub ↗
(
  interactor: Interactor,
  x: number,
  y: number,
  series: PressSeriesOptions,
)

Source from the content-addressed store, hash-verified

496}
497
498async function runDirectPressSeries(
499 interactor: Interactor,
500 x: number,
501 y: number,
502 series: PressSeriesOptions,
503): Promise<Record<string, unknown>> {
504 let interactionResult: Record<string, unknown> | undefined;
505 await runRepeatedSeries(series.count, series.intervalMs, async (index) => {
506 const [dx, dy] = computeDeterministicJitter(index, series.jitterPx);
507 const targetX = x + dx;
508 const targetY = y + dy;
509 // `??=` must not guard the awaited call itself: that would short-circuit
510 // every press after the first. Only the first result is kept.
511 if (series.doubleTap) {
512 const result = await interactor.doubleTap(targetX, targetY);
513 interactionResult ??= result ?? undefined;
514 return;
515 }
516 if (series.holdMs > 0) {
517 const result = await interactor.longPress(targetX, targetY, series.holdMs);
518 interactionResult ??= result ?? undefined;
519 } else {
520 const result = await interactor.tap(targetX, targetY);
521 interactionResult ??= result ?? undefined;
522 }
523 });
524
525 return withSuccessText(
526 {
527 x,
528 y,
529 count: series.count,
530 intervalMs: series.intervalMs,
531 holdMs: series.holdMs,
532 jitterPx: series.jitterPx,
533 doubleTap: series.doubleTap,
534 ...interactionResult,
535 },
536 formatPressMessage({ x, y }),
537 );
538}
539
540function runnerOptionsFromContext(context: DispatchContext | undefined): RunnerCallOptions {
541 return {

Callers 1

handlePressCommandFunction · 0.85

Calls 7

runRepeatedSeriesFunction · 0.90
withSuccessTextFunction · 0.90
formatPressMessageFunction · 0.85
doubleTapMethod · 0.80
longPressMethod · 0.80
tapMethod · 0.80

Tested by

no test coverage detected