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