( interactor: Interactor, positionals: string[], context: DispatchContext | undefined, )
| 743 | } |
| 744 | |
| 745 | export async function handleScrollCommand( |
| 746 | interactor: Interactor, |
| 747 | positionals: string[], |
| 748 | context: DispatchContext | undefined, |
| 749 | ): Promise<Record<string, unknown>> { |
| 750 | const directionInput = positionals[0]; |
| 751 | const amount = positionals[1] ? Number(positionals[1]) : undefined; |
| 752 | const pixels = context?.pixels; |
| 753 | const durationMs = context?.durationMs; |
| 754 | if (!directionInput) throw new AppError('INVALID_ARGS', 'scroll requires direction'); |
| 755 | assertScrollCommandInputs(amount, pixels, durationMs); |
| 756 | |
| 757 | const target = parseScrollTarget(directionInput); |
| 758 | const options = { amount, pixels, durationMs }; |
| 759 | const { interactionResult, completedPasses } = await runDispatchedScroll( |
| 760 | interactor, |
| 761 | context, |
| 762 | target, |
| 763 | options, |
| 764 | ); |
| 765 | |
| 766 | const result = buildDispatchedScrollResult(target, options, completedPasses, interactionResult); |
| 767 | return withSuccessText( |
| 768 | result, |
| 769 | formatScrollEdgeMessage(target.direction, target.edge, completedPasses, amount, pixels), |
| 770 | ); |
| 771 | } |
| 772 | |
| 773 | function assertScrollCommandInputs( |
| 774 | amount: number | undefined, |
no test coverage detected