import type { EventEmitter } from 'node:events'; import type { Options, Capabilities, ThenArg } from '@wdio/types'; import type { WebDriverBidiProtocol, ProtocolCommands } from '@wdio/protocols'; import type { BidiHandler } from './bidi/handler.js'; import type { EventData } from './bidi/localTypes.js'; import type { CommandData } from './bidi/remoteTypes.js'; import type { CommandResponse } from './bidi/localTypes.js'; export interface JSONWPCommandError extends Error { code?: string; statusCode?: string; statusMessage?: string; } export interface SessionFlags { isW3C: boolean; isChromium: boolean; isFirefox: boolean; isAndroid: boolean; isMobile: boolean; isIOS: boolean; isSauce: boolean; isSeleniumStandalone: boolean; isBidi: boolean; } type Fn = (...args: any) => any; type ValueOf = T[keyof T]; type ObtainMethods = { [Prop in keyof T]: T[Prop] extends Fn ? ThenArg> : never; }; type WebDriverBidiCommands = typeof WebDriverBidiProtocol; export type BidiCommands = WebDriverBidiCommands[keyof WebDriverBidiCommands]['socket']['command']; export type BidiResponses = ValueOf>>; export type RemoteConfig = Options.WebDriver & Capabilities.WithRequestedCapabilities; type BidiInterface = ObtainMethods>; type WebDriverClassicEvents = { command: { command: string; method: string; endpoint: string; body: any; }; result: { command: string; method: string; endpoint: string; body: any; result: any; }; bidiCommand: Omit; bidiResult: CommandResponse; 'request.performance': { durationMillisecond: number; error: string; request: any; retryCount: number; success: boolean; }; }; export type BidiEventMap = { [Event in keyof Omit]: BidiInterface[WebDriverBidiCommands[Event]['socket']['command']]; }; type GetParam = T extends { method: U; } ? T['params'] : never; export type EventMap = { [Event in EventData['method']]: GetParam; } & WebDriverClassicEvents; interface BidiEventHandler { on(event: K, listener: (this: Client, param: EventMap[K]) => void): this; once(event: K, listener: (this: Client, param: EventMap[K]) => void): this; } export interface BaseClient extends EventEmitter, SessionFlags { sessionId: string; capabilities: WebdriverIO.Capabilities; requestedCapabilities: Capabilities.WithRequestedCapabilities['capabilities']; options: Options.WebDriver; } export interface Client extends Omit, ProtocolCommands, BidiHandler, BidiEventHandler { } export interface AttachOptions extends Partial, Partial { sessionId: string; capabilities?: WebdriverIO.Capabilities; requestedCapabilities?: Capabilities.WithRequestedCapabilities['capabilities']; } export {}; //# sourceMappingURL=types.d.ts.map