1 | import type { EventEmitter } from 'node:events';
|
2 | import type { Options, Capabilities, ThenArg } from '@wdio/types';
|
3 | import type { WebDriverBidiProtocol, ProtocolCommands } from '@wdio/protocols';
|
4 | import type { BidiHandler } from './bidi/handler.js';
|
5 | import type { EventData } from './bidi/localTypes.js';
|
6 | export interface JSONWPCommandError extends Error {
|
7 | code?: string;
|
8 | statusCode?: string;
|
9 | statusMessage?: string;
|
10 | }
|
11 | export interface SessionFlags {
|
12 | isW3C: boolean;
|
13 | isChromium: boolean;
|
14 | isFirefox: boolean;
|
15 | isAndroid: boolean;
|
16 | isMobile: boolean;
|
17 | isIOS: boolean;
|
18 | isSauce: boolean;
|
19 | isSeleniumStandalone: boolean;
|
20 | isBidi: boolean;
|
21 | }
|
22 | type Fn = (...args: any) => any;
|
23 | type ValueOf<T> = T[keyof T];
|
24 | type ObtainMethods<T> = {
|
25 | [Prop in keyof T]: T[Prop] extends Fn ? ThenArg<ReturnType<T[Prop]>> : never;
|
26 | };
|
27 | type WebDriverBidiCommands = typeof WebDriverBidiProtocol;
|
28 | export type BidiCommands = WebDriverBidiCommands[keyof WebDriverBidiCommands]['socket']['command'];
|
29 | export type BidiResponses = ValueOf<ObtainMethods<Pick<BidiHandler, BidiCommands>>>;
|
30 | export type RemoteConfig = Options.WebDriver & Capabilities.WithRequestedCapabilities;
|
31 | type BidiInterface = ObtainMethods<Pick<BidiHandler, BidiCommands>>;
|
32 | type WebDriverClassicEvents = {
|
33 | command: {
|
34 | command: string;
|
35 | method: string;
|
36 | endpoint: string;
|
37 | body: any;
|
38 | };
|
39 | result: {
|
40 | command: string;
|
41 | method: string;
|
42 | endpoint: string;
|
43 | body: any;
|
44 | result: any;
|
45 | };
|
46 | 'request.performance': {
|
47 | durationMillisecond: number;
|
48 | error: string;
|
49 | request: any;
|
50 | retryCount: number;
|
51 | success: boolean;
|
52 | };
|
53 | };
|
54 | export type BidiEventMap = {
|
55 | [Event in keyof Omit<WebDriverBidiCommands, 'sendCommand' | 'sendAsyncCommand'>]: BidiInterface[WebDriverBidiCommands[Event]['socket']['command']];
|
56 | };
|
57 | type GetParam<T extends {
|
58 | method: string;
|
59 | params: any;
|
60 | }, U extends string> = T extends {
|
61 | method: U;
|
62 | } ? T['params'] : never;
|
63 | export type EventMap = {
|
64 | [Event in EventData['method']]: GetParam<EventData, Event>;
|
65 | } & WebDriverClassicEvents;
|
66 | interface BidiEventHandler {
|
67 | on<K extends keyof EventMap>(event: K, listener: (this: Client, param: EventMap[K]) => void): this;
|
68 | once<K extends keyof EventMap>(event: K, listener: (this: Client, param: EventMap[K]) => void): this;
|
69 | }
|
70 | export interface BaseClient extends EventEmitter, SessionFlags {
|
71 | sessionId: string;
|
72 | capabilities: WebdriverIO.Capabilities;
|
73 | requestedCapabilities: Capabilities.WithRequestedCapabilities['capabilities'];
|
74 | options: Options.WebDriver;
|
75 | }
|
76 | export interface Client extends Omit<BaseClient, keyof BidiEventHandler>, ProtocolCommands, BidiHandler, BidiEventHandler {
|
77 | }
|
78 | export interface AttachOptions extends Partial<SessionFlags>, Partial<Options.WebDriver> {
|
79 | sessionId: string;
|
80 | capabilities?: WebdriverIO.Capabilities;
|
81 | requestedCapabilities?: Capabilities.WithRequestedCapabilities['capabilities'];
|
82 | }
|
83 | export {};
|
84 | //# sourceMappingURL=types.d.ts.map |
\ | No newline at end of file |