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