import type { Device } from '@mobilewright/core'; import type { DeviceInfo, ScreenSize } from '@mobilewright/protocol'; /** Platform launcher injected from mobilewright to avoid a circular dependency. */ export interface MobilewrightLauncher { /** List all connected/booted devices for this platform. */ devices(): Promise; /** Launch and connect to a specific device by id. */ launch(opts: { deviceId: string; autoStart?: boolean; autoAppLaunch?: boolean; }): Promise; } /** Discriminated union of error codes thrown by DeviceManager. */ export type DeviceErrorCode = 'in_progress' | 'not_found' | 'connect_failed'; /** Structured error thrown by DeviceManager for expected failure modes. */ export declare class DeviceError extends Error { /** Machine-readable error code indicating the failure reason. */ readonly code: DeviceErrorCode; /** @param message Human-readable description. @param code Machine-readable failure reason. */ constructor(message: string, code: DeviceErrorCode); } /** DeviceInfo tagged with its platform, returned by listDevices(). */ export type TaggedDeviceInfo = DeviceInfo & { platform: 'ios' | 'android'; }; /** Options for {@link DeviceManager}. */ export interface DeviceManagerOptions { ios: MobilewrightLauncher; android: MobilewrightLauncher; /** How long a screen size call may take before it counts as failed and is asked again. */ screenSizeTimeoutMs?: number; } /** Minimal device identity record held by DeviceManager while a device is active. */ export type DeviceInfoRecord = { id: string; platform: 'ios' | 'android'; }; /** * Manages a single active device connection shared across the inspect lifecycle. * Coordinates concurrent select() and inspect operations via in-flight flags. */ export declare class DeviceManager { #private; /** @param ios iOS launcher from mobilewright. @param android Android launcher from mobilewright. */ constructor({ ios, android, screenSizeTimeoutMs }: DeviceManagerOptions); /** * List all connected/booted devices across both platforms. * Each platform is queried independently so a failure on one does not hide the other. */ listDevices(): Promise; /** * Connect to a device, closing any previous connection first. * Waits for in-flight inspects and device actions to finish (codegen refreshes back to back, so * an inspect is nearly always running) and refuses new ones until the switch is done, so nothing * uses a device while it is being closed. * Throws DeviceError if a select is already in progress or the previous device cannot be * cleanly disconnected. */ select(deviceId: string, platform: 'ios' | 'android'): Promise; /** * Mark the start of an inspect operation. * Returns false if an inspect is already in flight or a device switch is in progress. */ beginInspect(): boolean; /** Clear the inspect-in-flight flag set by beginInspect(), releasing a waiting select(). */ endInspect(): void; /** * Run a device action (tap, button press, ...) on the active device. A device switch waits for it * before closing the device. Rejects with DeviceError 'not_found' without a device, and * 'in_progress' while a switch is underway. */ withDevice(run: (device: Device) => Promise): Promise; /** * Close the active device connection. Safe to call with no active device. * Throws if the underlying driver close fails; state is only cleared on success. */ close(): Promise; /** The active device's screen size, asked once per connection; a failed ask is retried next call. */ screenSize(): Promise; /** The currently connected device, or null if none selected. */ get device(): Device | null; /** Id and platform of the currently connected device, or null if none selected. */ get deviceInfo(): DeviceInfoRecord | null; } //# sourceMappingURL=device-manager.d.ts.map