export type DevicePlatform = "ios" | "android"; export interface Device { platform: DevicePlatform; /** The simulator's UDID or the emulator's serial. */ id: string; name: string; } /** An accessibility element, its box as fractions (0..1) of the screen. */ export interface DeviceElement { role: string; label: string; x: number; y: number; w: number; h: number; } export interface DeviceTools { /** `xcrun simctl` works (Xcode is installed). */ simctl: boolean; /** `idb`, for iOS taps, typing and the accessibility tree. */ idb: string | null; /** `adb`, for Android emulators. */ adb: string | null; } export type Runner = (cmd: string, args: readonly string[], opts?: { timeoutMs?: number; }) => Promise<{ stdout: Buffer; stderr: string; }>; export declare const runTool: Runner; /** An executable on PATH (or a listed extra place), or null. */ export declare function findExecutable(name: string, extra?: readonly string[], env?: NodeJS.ProcessEnv): string | null; export declare function detectTools(run?: Runner, env?: NodeJS.ProcessEnv): Promise; /** Booted simulators from `xcrun simctl list devices booted -j`. */ export declare function parseSimctlDevices(json: string): Device[]; /** Running emulators and devices from `adb devices -l`. */ export declare function parseAdbDevices(text: string): Device[]; export declare function listDevices(tools: DeviceTools, run?: Runner): Promise; /** The image type of a screenshot (simctl sends JPEG, adb PNG). */ export declare function imageType(buf: Buffer): "image/png" | "image/jpeg" | null; /** A PNG's pixel size from its header, or null. */ export declare function pngSize(png: Buffer): { width: number; height: number; } | null; interface Frame { x: number; y: number; width: number; height: number; } /** * `idb ui describe-all --json`: one JSON array (newer idb) or one object per * line. Boxes come in points; the application element gives the screen size. */ export declare function parseIdbTree(text: string): { elements: DeviceElement[]; screen: Frame | null; }; /** `uiautomator dump`: its nodes, boxes in pixels; the first node spans the screen. */ export declare function parseUiAutomator(xml: string): { elements: DeviceElement[]; screen: { width: number; height: number; } | null; }; /** Text for `adb shell input text`: spaces as %s, quoted for the device's shell. */ export declare function adbInputText(text: string): string; export interface DeviceDriver { device: Device; /** Taps, swipes and typing reach the device. */ canInput: boolean; /** Its accessibility tree can be read (for picking). */ canInspect: boolean; screenshot: () => Promise; elements: () => Promise; /** Positions are fractions (0..1) of the screen. */ tap: (x: number, y: number) => Promise; swipe: (x1: number, y1: number, x2: number, y2: number, ms: number) => Promise; type: (text: string) => Promise; key: (key: DeviceKey) => Promise; } export type DeviceKey = "enter" | "backspace"; export interface DriverOptions { run?: Runner; } export declare function createDriver(device: Device, tools: DeviceTools, opts?: DriverOptions): DeviceDriver; export {};