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 | import type { RequestStartEvent, RequestEndEvent, RequestPerformanceEvent, RequestRetryEvent } from './request/types.js';
|
9 | export interface JSONWPCommandError extends Error {
|
10 | code?: string;
|
11 | statusCode?: string;
|
12 | statusMessage?: string;
|
13 | }
|
14 | export interface SessionFlags {
|
15 | isW3C: boolean;
|
16 | isChromium: boolean;
|
17 | isFirefox: boolean;
|
18 | isAndroid: boolean;
|
19 | isMobile: boolean;
|
20 | isNativeContext: boolean;
|
21 | mobileContext: string | undefined;
|
22 | isIOS: boolean;
|
23 | isSauce: boolean;
|
24 | isSeleniumStandalone: boolean;
|
25 | isBidi: boolean;
|
26 | }
|
27 | type Fn = (...args: unknown[]) => unknown;
|
28 | type ValueOf<T> = T[keyof T];
|
29 | type ObtainMethods<T> = {
|
30 | [Prop in keyof T]: T[Prop] extends Fn ? ThenArg<ReturnType<T[Prop]>> : never;
|
31 | };
|
32 | type WebDriverBidiCommands = typeof WebDriverBidiProtocol;
|
33 | export type BidiCommands = WebDriverBidiCommands[keyof WebDriverBidiCommands]['socket']['command'];
|
34 | export type BidiResponses = ValueOf<ObtainMethods<Pick<BidiHandler, BidiCommands>>>;
|
35 | export type RemoteConfig = Options.WebDriver & Capabilities.WithRequestedCapabilities;
|
36 | type BidiInterface = ObtainMethods<Pick<BidiHandler, BidiCommands>>;
|
37 | type WebDriverClassicEvents = {
|
38 | command: {
|
39 | command: string;
|
40 | method: string;
|
41 | endpoint: string;
|
42 | body: unknown;
|
43 | };
|
44 | result: {
|
45 | command: string;
|
46 | method: string;
|
47 | endpoint: string;
|
48 | body: unknown;
|
49 | result: unknown;
|
50 | };
|
51 | bidiCommand: Omit<CommandData, 'id'>;
|
52 | bidiResult: CommandResponse;
|
53 | 'request.performance': RequestPerformanceEvent;
|
54 | 'request.retry': RequestRetryEvent;
|
55 | 'request.start': RequestStartEvent;
|
56 | 'request.end': RequestEndEvent;
|
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: unknown;
|
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 |