mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(spec): add LongPress and Scroll authoring surface
This commit is contained in:
1 parent
a6a629a6bc
commit
66b2877f9f
2 files changed
+42
-1
No files matched your search
+25
-1
@@ -2,12 +2,15 @@ import type {
|
||||
AccessibilityElement,
|
||||
Action,
|
||||
ActionGenerator,
|
||||
Direction,
|
||||
DoubleTapAction,
|
||||
InputTextAction,
|
||||
Key,
|
||||
LongPressAction,
|
||||
Point,
|
||||
PressKeyAction,
|
||||
Sampler,
|
||||
ScrollAction,
|
||||
SwipeAction,
|
||||
TapAction,
|
||||
WaitAction,
|
||||
@@ -47,6 +50,17 @@ export function DoubleTap(parameters: { on: string | AccessibilityElement }): Do
|
||||
return globalThis.__sanderling__.doubleTap(parameters);
|
||||
}
|
||||
|
||||
export function LongPress(parameters: { on: string | AccessibilityElement }): LongPressAction {
|
||||
return globalThis.__sanderling__.longPress(parameters);
|
||||
}
|
||||
|
||||
export function Scroll(parameters: {
|
||||
direction: Direction;
|
||||
in?: string | AccessibilityElement;
|
||||
}): ScrollAction {
|
||||
return globalThis.__sanderling__.scroll(parameters);
|
||||
}
|
||||
|
||||
export function InputText(parameters: {
|
||||
into: string | AccessibilityElement;
|
||||
text: string;
|
||||
@@ -71,7 +85,15 @@ export function Wait(parameters: { durationMillis: number }): WaitAction {
|
||||
}
|
||||
|
||||
function builtinGenerator(
|
||||
name: "taps" | "doubleTaps" | "typing" | "swipes" | "waitOnce" | "pressKeys",
|
||||
name:
|
||||
| "taps"
|
||||
| "doubleTaps"
|
||||
| "longPresses"
|
||||
| "scrolls"
|
||||
| "typing"
|
||||
| "swipes"
|
||||
| "waitOnce"
|
||||
| "pressKeys",
|
||||
): ActionGenerator {
|
||||
return new Proxy({} as ActionGenerator, {
|
||||
get(_target, property) {
|
||||
@@ -86,6 +108,8 @@ function builtinGenerator(
|
||||
|
||||
export const taps: ActionGenerator = builtinGenerator("taps");
|
||||
export const doubleTaps: ActionGenerator = builtinGenerator("doubleTaps");
|
||||
export const longPresses: ActionGenerator = builtinGenerator("longPresses");
|
||||
export const scrolls: ActionGenerator = builtinGenerator("scrolls");
|
||||
export const typing: ActionGenerator = builtinGenerator("typing");
|
||||
export const swipes: ActionGenerator = builtinGenerator("swipes");
|
||||
export const waitOnce: ActionGenerator = builtinGenerator("waitOnce");
|
||||
|
||||
@@ -132,8 +132,16 @@ export interface Point {
|
||||
y: number;
|
||||
}
|
||||
|
||||
export type Direction = "up" | "down" | "left" | "right";
|
||||
|
||||
export type TapAction = { kind: "Tap"; on: string | AccessibilityElement };
|
||||
export type DoubleTapAction = { kind: "DoubleTap"; on: string | AccessibilityElement };
|
||||
export type LongPressAction = { kind: "LongPress"; on: string | AccessibilityElement };
|
||||
export type ScrollAction = {
|
||||
kind: "Scroll";
|
||||
direction: Direction;
|
||||
in?: string | AccessibilityElement;
|
||||
};
|
||||
export type InputTextAction = {
|
||||
kind: "InputText";
|
||||
into: string | AccessibilityElement;
|
||||
@@ -150,6 +158,8 @@ export type WaitAction = { kind: "Wait"; durationMillis: number };
|
||||
export type Action =
|
||||
| TapAction
|
||||
| DoubleTapAction
|
||||
| LongPressAction
|
||||
| ScrollAction
|
||||
| InputTextAction
|
||||
| SwipeAction
|
||||
| PressKeyAction
|
||||
@@ -197,6 +207,11 @@ export interface SanderlingRuntime {
|
||||
from: <T>(items: readonly T[]) => Sampler<T>;
|
||||
tap: (parameters: { on: string | AccessibilityElement }) => TapAction;
|
||||
doubleTap: (parameters: { on: string | AccessibilityElement }) => DoubleTapAction;
|
||||
longPress: (parameters: { on: string | AccessibilityElement }) => LongPressAction;
|
||||
scroll: (parameters: {
|
||||
direction: Direction;
|
||||
in?: string | AccessibilityElement;
|
||||
}) => ScrollAction;
|
||||
inputText: (parameters: {
|
||||
into: string | AccessibilityElement;
|
||||
text: string;
|
||||
@@ -210,6 +225,8 @@ export interface SanderlingRuntime {
|
||||
wait: (parameters: { durationMillis: number }) => WaitAction;
|
||||
taps: ActionGenerator;
|
||||
doubleTaps: ActionGenerator;
|
||||
longPresses: ActionGenerator;
|
||||
scrolls: ActionGenerator;
|
||||
typing: ActionGenerator;
|
||||
swipes: ActionGenerator;
|
||||
waitOnce: ActionGenerator;
|
||||
|
||||
Reference in new issue
Block a user