diff --git a/pkg/spec/src/actions.ts b/pkg/spec/src/actions.ts index 1010ea3..95ad388 100644 --- a/pkg/spec/src/actions.ts +++ b/pkg/spec/src/actions.ts @@ -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"); diff --git a/pkg/spec/src/index.ts b/pkg/spec/src/index.ts index 4bbb54e..85febaf 100644 --- a/pkg/spec/src/index.ts +++ b/pkg/spec/src/index.ts @@ -40,6 +40,7 @@ export { pressKey, swipes, taps, + typing, waitOnce, weighted, whenRoute, diff --git a/pkg/spec/src/types.ts b/pkg/spec/src/types.ts index ac44523..0e548be 100644 --- a/pkg/spec/src/types.ts +++ b/pkg/spec/src/types.ts @@ -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; diff --git a/pkg/spec/test/api.test.ts b/pkg/spec/test/api.test.ts index e97502a..5eb545c 100644 --- a/pkg/spec/test/api.test.ts +++ b/pkg/spec/test/api.test.ts @@ -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: () => [] }, diff --git a/pkg/spec/test/defaults.test.ts b/pkg/spec/test/defaults.test.ts index 4fcb6e2..3f354a1 100644 --- a/pkg/spec/test/defaults.test.ts +++ b/pkg/spec/test/defaults.test.ts @@ -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,