( interactor: Interactor, x: number, y: number, series: PressSeriesOptions, )
| 496 | } |
| 497 | |
| 498 | async 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 | |
| 540 | function runnerOptionsFromContext(context: DispatchContext | undefined): RunnerCallOptions { |
| 541 | return { |
no test coverage detected