mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(spec): export typing builtin generator
This commit is contained in:
1 parent
923d06813e
commit
9ca16e7627
5 files changed
+8
-1
No files matched your search
@@ -65,7 +65,9 @@ export function Wait(parameters: { durationMillis: number }): WaitAction {
|
||||
return globalThis.__sanderling__.wait(parameters);
|
||||
}
|
||||
|
||||
function builtinGenerator(name: "taps" | "swipes" | "waitOnce" | "pressKeys"): ActionGenerator {
|
||||
function builtinGenerator(
|
||||
name: "taps" | "typing" | "swipes" | "waitOnce" | "pressKeys",
|
||||
): ActionGenerator {
|
||||
return new Proxy({} as ActionGenerator, {
|
||||
get(_target, property) {
|
||||
const runtime = globalThis.__sanderling__[name] as unknown as Record<
|
||||
@@ -78,6 +80,7 @@ function builtinGenerator(name: "taps" | "swipes" | "waitOnce" | "pressKeys"): A
|
||||
}
|
||||
|
||||
export const taps: ActionGenerator = builtinGenerator("taps");
|
||||
export const typing: ActionGenerator = builtinGenerator("typing");
|
||||
export const swipes: ActionGenerator = builtinGenerator("swipes");
|
||||
export const waitOnce: ActionGenerator = builtinGenerator("waitOnce");
|
||||
export const pressKey: ActionGenerator = builtinGenerator("pressKeys");
|
||||
@@ -40,6 +40,7 @@ export {
|
||||
pressKey,
|
||||
swipes,
|
||||
taps,
|
||||
typing,
|
||||
waitOnce,
|
||||
weighted,
|
||||
whenRoute,
|
||||
|
||||
@@ -206,6 +206,7 @@ export interface SanderlingRuntime {
|
||||
pressKey: (parameters: { key: Key }) => PressKeyAction;
|
||||
wait: (parameters: { durationMillis: number }) => WaitAction;
|
||||
taps: ActionGenerator;
|
||||
typing: ActionGenerator;
|
||||
swipes: ActionGenerator;
|
||||
waitOnce: ActionGenerator;
|
||||
pressKeys: ActionGenerator;
|
||||
|
||||
@@ -148,6 +148,7 @@ function installFakeRuntime(): RecordedRuntime {
|
||||
pressKey: ({ key }) => ({ kind: "PressKey", key }),
|
||||
wait: ({ durationMillis }) => ({ kind: "Wait", durationMillis }),
|
||||
taps: { __sanderlingActionGenerator: true, generate: () => [] },
|
||||
typing: { __sanderlingActionGenerator: true, generate: () => [] },
|
||||
swipes: { __sanderlingActionGenerator: true, generate: () => [] },
|
||||
waitOnce: { __sanderlingActionGenerator: true, generate: () => [] },
|
||||
pressKeys: { __sanderlingActionGenerator: true, generate: () => [] },
|
||||
|
||||
@@ -63,6 +63,7 @@ function installRuntime(initialState: State): RecordedRuntime {
|
||||
pressKey: ({ key }) => ({ kind: "PressKey", key }),
|
||||
wait: ({ durationMillis }) => ({ kind: "Wait", durationMillis }),
|
||||
taps: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
|
||||
typing: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
|
||||
swipes: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
|
||||
waitOnce: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
|
||||
pressKeys: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
|
||||
|
||||
Reference in new issue
Block a user