1import { ExpoDebuggerInfo } from '../device'; 2 3export interface InspectorHandler { 4 /** 5 * Intercept a message coming from the device, modify or respond to it through `this._sendMessageToDevice`. 6 * Return `true` if the message was handled, this will stop the message propagation. 7 */ 8 onDeviceMessage?(message: DeviceRequest | DeviceResponse, info: ExpoDebuggerInfo): boolean; 9 10 /** 11 * Intercept a message coming from the debugger, modify or respond to it through `socket.send`. 12 * Return `true` if the message was handled, this will stop the message propagation. 13 */ 14 onDebuggerMessage?(message: DebuggerRequest, info: ExpoDebuggerInfo): boolean; 15} 16 17/** 18 * The outline of a basic Chrome DevTools Protocol request, either from device or debugger. 19 * Both the request and response parameters could be optional, use `never` to enforce these fields. 20 */ 21export type CdpMessage< 22 Method extends string = string, 23 Request extends object = object, 24 Response extends object = object, 25> = { 26 id: number; 27 method: Method; 28 params: Request; 29 result: Response; 30}; 31 32export type DeviceRequest<M extends CdpMessage = CdpMessage> = Pick<M, 'method' | 'params'>; 33export type DeviceResponse<M extends CdpMessage = CdpMessage> = Pick<M, 'id' | 'result'>; 34 35export type DebuggerRequest<M extends CdpMessage = CdpMessage> = Pick< 36 M, 37 'id' | 'method' | 'params' 38>; 39export type DebuggerResponse<M extends CdpMessage = CdpMessage> = Pick<M, 'result'>; 40