/** * Platform adapter interfaces -- segregated by capability (ISP). * * Instead of a single monolithic PlatformAdapter that forces Browser and * Desktop to throw "not supported" for mobile-only features, the contract * is split into focused interfaces: * * CorePlatformAdapter -- universal: every platform implements this * AppManagementAdapter -- launchApp / stopApp / installApp * PermissionAdapter -- grant / revoke / reset permissions * ShellAdapter -- shell / logs / clearLogs * * Each concrete adapter implements only the interfaces it actually supports. * Consumers use type guards (`hasAppManagement`, `hasPermissions`, etc.) * to narrow before calling capability-specific methods. * * The legacy `PlatformAdapter` type alias is preserved for backward * compatibility -- it is the intersection of all capability interfaces. */ import type { Platform, Device } from "../device-manager.js"; import type { CompressOptions } from "../utils/image.js"; export interface CorePlatformAdapter { /** Which platform this adapter serves. */ readonly platform: Platform; listDevices(): Device[]; selectDevice(deviceId: string): void; getSelectedDeviceId(): string | undefined; autoDetectDevice(): Device | undefined; tap(x: number, y: number, targetPid?: number, deviceId?: string): Promise; doubleTap(x: number, y: number, intervalMs?: number, deviceId?: string): Promise; longPress(x: number, y: number, durationMs?: number, deviceId?: string): Promise; swipe(x1: number, y1: number, x2: number, y2: number, durationMs?: number, deviceId?: string): Promise; swipeDirection(direction: "up" | "down" | "left" | "right", deviceId?: string): Promise; inputText(text: string, targetPid?: number, deviceId?: string): Promise; pressKey(key: string, targetPid?: number, deviceId?: string): Promise; screenshotAsync(compress: boolean, options?: CompressOptions & { monitorIndex?: number; }, deviceId?: string): Promise<{ data: string; mimeType: string; }>; getScreenshotBufferAsync(deviceId?: string): Promise; getUiHierarchy(deviceId?: string, turbo?: boolean): Promise; getSystemInfo(deviceId?: string): Promise; } export interface AppManagementAdapter { launchApp(packageOrBundleId: string, deviceId?: string): string | Promise; stopApp(packageOrBundleId: string, deviceId?: string): void; installApp(path: string, deviceId?: string): string; } export interface PermissionAdapter { grantPermission(packageOrBundleId: string, permission: string, deviceId?: string): string; revokePermission(packageOrBundleId: string, permission: string, deviceId?: string): string; resetPermissions(packageOrBundleId: string, deviceId?: string): string; } export interface ShellAdapter { shell(command: string, deviceId?: string): string; getLogs(options: { level?: string; tag?: string; lines?: number; package?: string; }, deviceId?: string): string; clearLogs(deviceId?: string): string; } export interface SyncScreenshotAdapter { screenshotRaw(): string; } export declare function hasAppManagement(adapter: CorePlatformAdapter): adapter is CorePlatformAdapter & AppManagementAdapter; export declare function hasPermissions(adapter: CorePlatformAdapter): adapter is CorePlatformAdapter & PermissionAdapter; export declare function hasShell(adapter: CorePlatformAdapter): adapter is CorePlatformAdapter & ShellAdapter; export declare function hasSyncScreenshot(adapter: CorePlatformAdapter): adapter is CorePlatformAdapter & SyncScreenshotAdapter; export declare class CapabilityNotSupportedError extends Error { readonly platform: Platform; readonly capability: string; constructor(platform: Platform, capability: string); } export declare function requireAppManagement(adapter: CorePlatformAdapter): CorePlatformAdapter & AppManagementAdapter; export declare function requirePermissions(adapter: CorePlatformAdapter): CorePlatformAdapter & PermissionAdapter; export declare function requireShell(adapter: CorePlatformAdapter): CorePlatformAdapter & ShellAdapter; /** * Legacy full interface -- the intersection of ALL capabilities. * * Existing code that imports `PlatformAdapter` still compiles, but new * code should prefer `CorePlatformAdapter` and narrow with type guards. * * @deprecated Prefer `CorePlatformAdapter` with capability type guards. */ export type PlatformAdapter = CorePlatformAdapter & AppManagementAdapter & PermissionAdapter & ShellAdapter & SyncScreenshotAdapter; //# sourceMappingURL=platform-adapter.d.ts.map