export type EmulatorControlStreamEvent = { streamId: string type: 'open' | 'message' | 'error' | 'close' data?: ArrayBuffer | string } export type EmulatorApi = { startControlStream: (args: { wsUrl: string; streamId: string }) => Promise stopControlStream: (args: { streamId: string }) => Promise sendControlStream: (args: { streamId: string; data: string | Uint8Array }) => void onControlStreamEvent: (callback: (event: EmulatorControlStreamEvent) => void) => () => void onPaneFocus: (callback: (data: { worktreeId: string }) => void) => () => void onAutoAttach: ( callback: (data: { worktreeId: string info: { deviceUdid: string; streamUrl: string; wsUrl: string; axUrl?: string } }) => void ) => () => void startFrameStream: (args: { streamUrl: string; streamKey?: string }) => Promise<{ streamId: string }> stopFrameStream: (args: { streamId: string }) => Promise onFrameStreamFrame: ( callback: (data: { streamId: string; bytes: ArrayBuffer }) => void ) => () => void onFrameStreamError: ( callback: (data: { streamId: string; message: string }) => void ) => () => void startVideoStream: (args: { deviceId: string; streamId: string }) => Promise<{ streamId: string }> stopVideoStream: (args: { streamId: string }) => Promise onVideoStreamMeta: ( callback: (data: { streamId: string deviceId: string meta: { codecId: string; width: number; height: number } }) => void ) => () => void sendScrcpyTouch: (touch: { deviceId: string type: 'begin' | 'move' | 'end' x: number y: number }) => void /** Resolves false when the device has no live scrcpy control socket. */ sendScrcpyKeyboard: ( input: { deviceId: string; text: string } | { deviceId: string; key: string; shift: boolean } ) => Promise onVideoStreamFrame: ( callback: (data: { streamId: string deviceId: string config: boolean keyFrame: boolean bytes: ArrayBuffer }) => void ) => () => void }