mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-05 02:02:05 +03:00
chore: use channel traits (#10389)
This commit is contained in:
parent
dc89738233
commit
70ede0d987
@ -100,7 +100,8 @@ export class BrowserServerLauncherImpl implements BrowserServerLauncher {
|
||||
}
|
||||
|
||||
// This class implements multiplexing browser dispatchers over a single Browser instance.
|
||||
class ConnectedBrowserDispatcher extends Dispatcher<Browser, channels.BrowserInitializer, channels.BrowserEvents> implements channels.BrowserChannel {
|
||||
class ConnectedBrowserDispatcher extends Dispatcher<Browser, channels.BrowserChannel> implements channels.BrowserChannel {
|
||||
_type_Browser = true;
|
||||
private _contexts = new Set<BrowserContext>();
|
||||
private _selectors: Selectors;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import { EventEmitter } from 'events';
|
||||
type Direction = 'down' | 'up' | 'left' | 'right';
|
||||
type SpeedOptions = { speed?: number };
|
||||
|
||||
export class Android extends ChannelOwner<channels.AndroidChannel, channels.AndroidInitializer> implements api.Android {
|
||||
export class Android extends ChannelOwner<channels.AndroidChannel> implements api.Android {
|
||||
readonly _timeoutSettings: TimeoutSettings;
|
||||
|
||||
static from(android: channels.AndroidChannel): Android {
|
||||
@ -55,7 +55,7 @@ export class Android extends ChannelOwner<channels.AndroidChannel, channels.Andr
|
||||
}
|
||||
}
|
||||
|
||||
export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel, channels.AndroidDeviceInitializer> implements api.AndroidDevice {
|
||||
export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel> implements api.AndroidDevice {
|
||||
readonly _timeoutSettings: TimeoutSettings;
|
||||
private _webViews = new Map<number, AndroidWebView>();
|
||||
|
||||
@ -249,7 +249,7 @@ export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel, c
|
||||
}
|
||||
}
|
||||
|
||||
export class AndroidSocket extends ChannelOwner<channels.AndroidSocketChannel, channels.AndroidSocketInitializer> implements api.AndroidSocket {
|
||||
export class AndroidSocket extends ChannelOwner<channels.AndroidSocketChannel> implements api.AndroidSocket {
|
||||
static from(androidDevice: channels.AndroidSocketChannel): AndroidSocket {
|
||||
return (androidDevice as any)._object;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import { mkdirIfNeeded } from '../utils/utils';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
export class Artifact extends ChannelOwner<channels.ArtifactChannel, channels.ArtifactInitializer> {
|
||||
export class Artifact extends ChannelOwner<channels.ArtifactChannel> {
|
||||
static from(channel: channels.ArtifactChannel): Artifact {
|
||||
return (channel as any)._object;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import * as api from '../../types/types';
|
||||
import { CDPSession } from './cdpSession';
|
||||
import type { BrowserType } from './browserType';
|
||||
|
||||
export class Browser extends ChannelOwner<channels.BrowserChannel, channels.BrowserInitializer> implements api.Browser {
|
||||
export class Browser extends ChannelOwner<channels.BrowserChannel> implements api.Browser {
|
||||
readonly _contexts = new Set<BrowserContext>();
|
||||
private _isConnected = true;
|
||||
private _closedPromise: Promise<void>;
|
||||
|
@ -39,7 +39,7 @@ import { Artifact } from './artifact';
|
||||
import { APIRequestContext } from './fetch';
|
||||
import { createInstrumentation } from './clientInstrumentation';
|
||||
|
||||
export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel, channels.BrowserContextInitializer> implements api.BrowserContext {
|
||||
export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel> implements api.BrowserContext {
|
||||
_pages = new Set<Page>();
|
||||
private _routes: network.RouteHandler[] = [];
|
||||
readonly _browser: Browser | null = null;
|
||||
|
@ -41,7 +41,7 @@ export interface BrowserServer extends api.BrowserServer {
|
||||
kill(): Promise<void>;
|
||||
}
|
||||
|
||||
export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, channels.BrowserTypeInitializer> implements api.BrowserType {
|
||||
export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> implements api.BrowserType {
|
||||
_serverLauncher?: BrowserServerLauncher;
|
||||
_contexts = new Set<BrowserContext>();
|
||||
_playwright!: Playwright;
|
||||
|
@ -19,7 +19,7 @@ import { ChannelOwner } from './channelOwner';
|
||||
import { Protocol } from '../server/chromium/protocol';
|
||||
import * as api from '../../types/types';
|
||||
|
||||
export class CDPSession extends ChannelOwner<channels.CDPSessionChannel, channels.CDPSessionInitializer> implements api.CDPSession {
|
||||
export class CDPSession extends ChannelOwner<channels.CDPSessionChannel> implements api.CDPSession {
|
||||
static from(cdpSession: channels.CDPSessionChannel): CDPSession {
|
||||
return (cdpSession as any)._object;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import { ClientInstrumentation } from './clientInstrumentation';
|
||||
import type { Connection } from './connection';
|
||||
import type { Logger } from './types';
|
||||
|
||||
export abstract class ChannelOwner<T extends channels.Channel = channels.Channel, Initializer = {}> extends EventEmitter {
|
||||
export abstract class ChannelOwner<T extends channels.Channel = channels.Channel> extends EventEmitter {
|
||||
readonly _connection: Connection;
|
||||
private _parent: ChannelOwner | undefined;
|
||||
private _objects = new Map<string, ChannelOwner>();
|
||||
@ -32,11 +32,11 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
||||
readonly _type: string;
|
||||
readonly _guid: string;
|
||||
readonly _channel: T;
|
||||
readonly _initializer: Initializer;
|
||||
readonly _initializer: channels.InitializerTraits<T>;
|
||||
_logger: Logger | undefined;
|
||||
_instrumentation: ClientInstrumentation | undefined;
|
||||
|
||||
constructor(parent: ChannelOwner | Connection, type: string, guid: string, initializer: Initializer, instrumentation?: ClientInstrumentation) {
|
||||
constructor(parent: ChannelOwner | Connection, type: string, guid: string, initializer: channels.InitializerTraits<T>, instrumentation?: ClientInstrumentation) {
|
||||
super();
|
||||
this.setMaxListeners(0);
|
||||
this._connection = parent instanceof ChannelOwner ? parent._connection : parent;
|
||||
|
@ -41,7 +41,7 @@ import { EventEmitter } from 'events';
|
||||
import { JsonPipe } from './jsonPipe';
|
||||
import { APIRequestContext } from './fetch';
|
||||
|
||||
class Root extends ChannelOwner<channels.RootChannel, {}> {
|
||||
class Root extends ChannelOwner<channels.RootChannel> {
|
||||
constructor(connection: Connection) {
|
||||
super(connection, 'Root', '', {});
|
||||
}
|
||||
@ -142,7 +142,7 @@ export class Connection extends EventEmitter {
|
||||
const object = this._objects.get(guid);
|
||||
if (!object)
|
||||
throw new Error(`Cannot find object to emit "${method}": ${guid}`);
|
||||
object._channel.emit(method, object._type === 'JsonPipe' ? params : this._replaceGuidsWithChannels(params));
|
||||
(object._channel as any).emit(method, object._type === 'JsonPipe' ? params : this._replaceGuidsWithChannels(params));
|
||||
}
|
||||
|
||||
close(errorMessage: string = 'Connection closed') {
|
||||
@ -173,7 +173,7 @@ export class Connection extends EventEmitter {
|
||||
const parent = this._objects.get(parentGuid);
|
||||
if (!parent)
|
||||
throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
|
||||
let result: ChannelOwner<any, any>;
|
||||
let result: ChannelOwner<any>;
|
||||
initializer = this._replaceGuidsWithChannels(initializer);
|
||||
switch (type) {
|
||||
case 'Android':
|
||||
|
@ -22,7 +22,7 @@ import * as api from '../../types/types';
|
||||
|
||||
type ConsoleMessageLocation = channels.ConsoleMessageInitializer['location'];
|
||||
|
||||
export class ConsoleMessage extends ChannelOwner<channels.ConsoleMessageChannel, channels.ConsoleMessageInitializer> implements api.ConsoleMessage {
|
||||
export class ConsoleMessage extends ChannelOwner<channels.ConsoleMessageChannel> implements api.ConsoleMessage {
|
||||
static from(message: channels.ConsoleMessageChannel): ConsoleMessage {
|
||||
return (message as any)._object;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import * as channels from '../protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import * as api from '../../types/types';
|
||||
|
||||
export class Dialog extends ChannelOwner<channels.DialogChannel, channels.DialogInitializer> implements api.Dialog {
|
||||
export class Dialog extends ChannelOwner<channels.DialogChannel> implements api.Dialog {
|
||||
static from(dialog: channels.DialogChannel): Dialog {
|
||||
return (dialog as any)._object;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ type ElectronOptions = Omit<channels.ElectronLaunchOptions, 'env'|'extraHTTPHead
|
||||
|
||||
type ElectronAppType = typeof import('electron');
|
||||
|
||||
export class Electron extends ChannelOwner<channels.ElectronChannel, channels.ElectronInitializer> implements api.Electron {
|
||||
export class Electron extends ChannelOwner<channels.ElectronChannel> implements api.Electron {
|
||||
static from(electron: channels.ElectronChannel): Electron {
|
||||
return (electron as any)._object;
|
||||
}
|
||||
@ -57,7 +57,7 @@ export class Electron extends ChannelOwner<channels.ElectronChannel, channels.El
|
||||
}
|
||||
}
|
||||
|
||||
export class ElectronApplication extends ChannelOwner<channels.ElectronApplicationChannel, channels.ElectronApplicationInitializer> implements api.ElectronApplication {
|
||||
export class ElectronApplication extends ChannelOwner<channels.ElectronApplicationChannel> implements api.ElectronApplication {
|
||||
private _context: BrowserContext;
|
||||
private _windows = new Set<Page>();
|
||||
private _timeoutSettings = new TimeoutSettings();
|
||||
|
@ -70,7 +70,7 @@ export class APIRequest implements api.APIRequest {
|
||||
}
|
||||
}
|
||||
|
||||
export class APIRequestContext extends ChannelOwner<channels.APIRequestContextChannel, channels.APIRequestContextInitializer> implements api.APIRequestContext {
|
||||
export class APIRequestContext extends ChannelOwner<channels.APIRequestContextChannel> implements api.APIRequestContext {
|
||||
static from(channel: channels.APIRequestContextChannel): APIRequestContext {
|
||||
return (channel as any)._object;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ export type WaitForNavigationOptions = {
|
||||
url?: URLMatch,
|
||||
};
|
||||
|
||||
export class Frame extends ChannelOwner<channels.FrameChannel, channels.FrameInitializer> implements api.Frame {
|
||||
export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Frame {
|
||||
_eventEmitter: EventEmitter;
|
||||
_loadStates: Set<LifecycleEvent>;
|
||||
_parentFrame: Frame | null = null;
|
||||
|
@ -20,7 +20,7 @@ import { parseSerializedValue, serializeValue } from '../protocol/serializers';
|
||||
import * as api from '../../types/types';
|
||||
import * as structs from '../../types/structs';
|
||||
|
||||
export class JSHandle<T = any> extends ChannelOwner<channels.JSHandleChannel, channels.JSHandleInitializer> implements api.JSHandle {
|
||||
export class JSHandle<T = any> extends ChannelOwner<channels.JSHandleChannel> implements api.JSHandle {
|
||||
private _preview: string;
|
||||
|
||||
static from(handle: channels.JSHandleChannel): JSHandle {
|
||||
|
@ -17,7 +17,7 @@
|
||||
import * as channels from '../protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
export class JsonPipe extends ChannelOwner<channels.JsonPipeChannel, channels.JsonPipeInitializer> {
|
||||
export class JsonPipe extends ChannelOwner<channels.JsonPipeChannel> {
|
||||
static from(jsonPipe: channels.JsonPipeChannel): JsonPipe {
|
||||
return (jsonPipe as any)._object;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export type SetNetworkCookieParam = {
|
||||
sameSite?: 'Strict' | 'Lax' | 'None'
|
||||
};
|
||||
|
||||
export class Request extends ChannelOwner<channels.RequestChannel, channels.RequestInitializer> implements api.Request {
|
||||
export class Request extends ChannelOwner<channels.RequestChannel> implements api.Request {
|
||||
private _redirectedFrom: Request | null = null;
|
||||
private _redirectedTo: Request | null = null;
|
||||
_failureText: string | null = null;
|
||||
@ -215,7 +215,7 @@ export class Request extends ChannelOwner<channels.RequestChannel, channels.Requ
|
||||
}
|
||||
}
|
||||
|
||||
export class Route extends ChannelOwner<channels.RouteChannel, channels.RouteInitializer> implements api.Route {
|
||||
export class Route extends ChannelOwner<channels.RouteChannel> implements api.Route {
|
||||
static from(route: channels.RouteChannel): Route {
|
||||
return (route as any)._object;
|
||||
}
|
||||
@ -334,7 +334,7 @@ export type RequestSizes = {
|
||||
responseHeadersSize: number;
|
||||
};
|
||||
|
||||
export class Response extends ChannelOwner<channels.ResponseChannel, channels.ResponseInitializer> implements api.Response {
|
||||
export class Response extends ChannelOwner<channels.ResponseChannel> implements api.Response {
|
||||
private _provisionalHeaders: RawHeaders;
|
||||
private _actualHeadersPromise: Promise<RawHeaders> | undefined;
|
||||
private _request: Request;
|
||||
@ -445,7 +445,7 @@ export class Response extends ChannelOwner<channels.ResponseChannel, channels.Re
|
||||
}
|
||||
}
|
||||
|
||||
export class WebSocket extends ChannelOwner<channels.WebSocketChannel, channels.WebSocketInitializer> implements api.WebSocket {
|
||||
export class WebSocket extends ChannelOwner<channels.WebSocketChannel> implements api.WebSocket {
|
||||
private _page: Page;
|
||||
private _isClosed: boolean;
|
||||
|
||||
|
@ -62,7 +62,7 @@ type PDFOptions = Omit<channels.PagePdfParams, 'width' | 'height' | 'margin'> &
|
||||
};
|
||||
type Listener = (...args: any[]) => void;
|
||||
|
||||
export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitializer> implements api.Page {
|
||||
export class Page extends ChannelOwner<channels.PageChannel> implements api.Page {
|
||||
private _browserContext: BrowserContext;
|
||||
_ownedContext: BrowserContext | undefined;
|
||||
|
||||
@ -96,7 +96,7 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
|
||||
|
||||
constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.PageInitializer) {
|
||||
super(parent, type, guid, initializer);
|
||||
this._browserContext = parent as BrowserContext;
|
||||
this._browserContext = parent as unknown as BrowserContext;
|
||||
this._timeoutSettings = new TimeoutSettings(this._browserContext._timeoutSettings);
|
||||
|
||||
this.accessibility = new Accessibility(this._channel);
|
||||
@ -698,7 +698,7 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
|
||||
}
|
||||
}
|
||||
|
||||
export class BindingCall extends ChannelOwner<channels.BindingCallChannel, channels.BindingCallInitializer> {
|
||||
export class BindingCall extends ChannelOwner<channels.BindingCallChannel> {
|
||||
static from(channel: channels.BindingCallChannel): BindingCall {
|
||||
return (channel as any)._object;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ type DeviceDescriptor = {
|
||||
};
|
||||
type Devices = { [name: string]: DeviceDescriptor };
|
||||
|
||||
export class Playwright extends ChannelOwner<channels.PlaywrightChannel, channels.PlaywrightInitializer> {
|
||||
export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
|
||||
readonly _android: Android;
|
||||
readonly _electron: Electron;
|
||||
readonly chromium: BrowserType;
|
||||
|
@ -45,7 +45,7 @@ export class Selectors implements api.Selectors {
|
||||
}
|
||||
}
|
||||
|
||||
export class SelectorsOwner extends ChannelOwner<channels.SelectorsChannel, channels.SelectorsInitializer> {
|
||||
export class SelectorsOwner extends ChannelOwner<channels.SelectorsChannel> {
|
||||
static from(browser: channels.SelectorsChannel): SelectorsOwner {
|
||||
return (browser as any)._object;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import { Readable } from 'stream';
|
||||
import * as channels from '../protocol/channels';
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
|
||||
export class Stream extends ChannelOwner<channels.StreamChannel, channels.StreamInitializer> {
|
||||
export class Stream extends ChannelOwner<channels.StreamChannel> {
|
||||
static from(Stream: channels.StreamChannel): Stream {
|
||||
return (Stream as any)._object;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import { BrowserContext } from './browserContext';
|
||||
import * as api from '../../types/types';
|
||||
import * as structs from '../../types/structs';
|
||||
|
||||
export class Worker extends ChannelOwner<channels.WorkerChannel, channels.WorkerInitializer> implements api.Worker {
|
||||
export class Worker extends ChannelOwner<channels.WorkerChannel> implements api.Worker {
|
||||
_page: Page | undefined; // Set for web workers.
|
||||
_context: BrowserContext | undefined; // Set for service workers.
|
||||
|
||||
|
@ -20,7 +20,8 @@ import * as channels from '../protocol/channels';
|
||||
import { BrowserContextDispatcher } from './browserContextDispatcher';
|
||||
import { CallMetadata } from '../server/instrumentation';
|
||||
|
||||
export class AndroidDispatcher extends Dispatcher<Android, channels.AndroidInitializer, channels.AndroidEvents> implements channels.AndroidChannel {
|
||||
export class AndroidDispatcher extends Dispatcher<Android, channels.AndroidChannel> implements channels.AndroidChannel {
|
||||
_type_Android = true;
|
||||
constructor(scope: DispatcherScope, android: Android) {
|
||||
super(scope, android, 'Android', {}, true);
|
||||
}
|
||||
@ -37,7 +38,9 @@ export class AndroidDispatcher extends Dispatcher<Android, channels.AndroidIniti
|
||||
}
|
||||
}
|
||||
|
||||
export class AndroidDeviceDispatcher extends Dispatcher<AndroidDevice, channels.AndroidDeviceInitializer, channels.AndroidDeviceEvents> implements channels.AndroidDeviceChannel {
|
||||
export class AndroidDeviceDispatcher extends Dispatcher<AndroidDevice, channels.AndroidDeviceChannel> implements channels.AndroidDeviceChannel {
|
||||
_type_EventTarget = true;
|
||||
_type_AndroidDevice = true;
|
||||
|
||||
static from(scope: DispatcherScope, device: AndroidDevice): AndroidDeviceDispatcher {
|
||||
const result = existingDispatcher<AndroidDeviceDispatcher>(device);
|
||||
@ -169,7 +172,9 @@ export class AndroidDeviceDispatcher extends Dispatcher<AndroidDevice, channels.
|
||||
}
|
||||
}
|
||||
|
||||
export class AndroidSocketDispatcher extends Dispatcher<SocketBackend, channels.AndroidSocketInitializer, channels.AndroidSocketEvents> implements channels.AndroidSocketChannel {
|
||||
export class AndroidSocketDispatcher extends Dispatcher<SocketBackend, channels.AndroidSocketChannel> implements channels.AndroidSocketChannel {
|
||||
_type_AndroidSocket = true;
|
||||
|
||||
constructor(scope: DispatcherScope, socket: SocketBackend) {
|
||||
super(scope, socket, 'AndroidSocket', {}, true);
|
||||
socket.on('data', (data: Buffer) => this._dispatchEvent('data', { data: data.toString('base64') }));
|
||||
|
@ -21,7 +21,8 @@ import fs from 'fs';
|
||||
import { mkdirIfNeeded } from '../utils/utils';
|
||||
import { Artifact } from '../server/artifact';
|
||||
|
||||
export class ArtifactDispatcher extends Dispatcher<Artifact, channels.ArtifactInitializer, channels.ArtifactEvents> implements channels.ArtifactChannel {
|
||||
export class ArtifactDispatcher extends Dispatcher<Artifact, channels.ArtifactChannel> implements channels.ArtifactChannel {
|
||||
_type_Artifact = true;
|
||||
constructor(scope: DispatcherScope, artifact: Artifact) {
|
||||
super(scope, artifact, 'Artifact', {
|
||||
absolutePath: artifact.localPath(),
|
||||
|
@ -28,7 +28,9 @@ import { ArtifactDispatcher } from './artifactDispatcher';
|
||||
import { Artifact } from '../server/artifact';
|
||||
import { Request, Response } from '../server/network';
|
||||
|
||||
export class BrowserContextDispatcher extends Dispatcher<BrowserContext, channels.BrowserContextInitializer, channels.BrowserContextEvents> implements channels.BrowserContextChannel {
|
||||
export class BrowserContextDispatcher extends Dispatcher<BrowserContext, channels.BrowserContextChannel> implements channels.BrowserContextChannel {
|
||||
_type_EventTarget = true;
|
||||
_type_BrowserContext = true;
|
||||
private _context: BrowserContext;
|
||||
|
||||
constructor(scope: DispatcherScope, context: BrowserContext) {
|
||||
|
@ -23,7 +23,8 @@ import { CRBrowser } from '../server/chromium/crBrowser';
|
||||
import { PageDispatcher } from './pageDispatcher';
|
||||
import { CallMetadata } from '../server/instrumentation';
|
||||
|
||||
export class BrowserDispatcher extends Dispatcher<Browser, channels.BrowserInitializer, channels.BrowserEvents> implements channels.BrowserChannel {
|
||||
export class BrowserDispatcher extends Dispatcher<Browser, channels.BrowserChannel> implements channels.BrowserChannel {
|
||||
_type_Browser = true;
|
||||
constructor(scope: DispatcherScope, browser: Browser) {
|
||||
super(scope, browser, 'Browser', { version: browser.version(), name: browser.options.name }, true);
|
||||
browser.on(Browser.Events.Disconnected, () => this._didClose());
|
||||
|
@ -25,7 +25,8 @@ import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher';
|
||||
import { getUserAgent, makeWaitForNextTask } from '../utils/utils';
|
||||
import { ManualPromise } from '../utils/async';
|
||||
|
||||
export class BrowserTypeDispatcher extends Dispatcher<BrowserType, channels.BrowserTypeInitializer, channels.BrowserTypeEvents> implements channels.BrowserTypeChannel {
|
||||
export class BrowserTypeDispatcher extends Dispatcher<BrowserType, channels.BrowserTypeChannel> implements channels.BrowserTypeChannel {
|
||||
_type_BrowserType = true;
|
||||
constructor(scope: DispatcherScope, browserType: BrowserType) {
|
||||
super(scope, browserType, 'BrowserType', {
|
||||
executablePath: browserType.executablePath(),
|
||||
|
@ -18,7 +18,9 @@ import { CRSession, CRSessionEvents } from '../server/chromium/crConnection';
|
||||
import * as channels from '../protocol/channels';
|
||||
import { Dispatcher, DispatcherScope } from './dispatcher';
|
||||
|
||||
export class CDPSessionDispatcher extends Dispatcher<CRSession, channels.CDPSessionInitializer, channels.CDPSessionEvents> implements channels.CDPSessionChannel {
|
||||
export class CDPSessionDispatcher extends Dispatcher<CRSession, channels.CDPSessionChannel> implements channels.CDPSessionChannel {
|
||||
_type_CDPSession = true;
|
||||
|
||||
constructor(scope: DispatcherScope, crSession: CRSession) {
|
||||
super(scope, crSession, 'CDPSession', {}, true);
|
||||
crSession._eventListener = (method, params) => {
|
||||
|
@ -19,7 +19,8 @@ import * as channels from '../protocol/channels';
|
||||
import { Dispatcher, DispatcherScope } from './dispatcher';
|
||||
import { ElementHandleDispatcher } from './elementHandlerDispatcher';
|
||||
|
||||
export class ConsoleMessageDispatcher extends Dispatcher<ConsoleMessage, channels.ConsoleMessageInitializer, channels.ConsoleMessageEvents> implements channels.ConsoleMessageChannel {
|
||||
export class ConsoleMessageDispatcher extends Dispatcher<ConsoleMessage, channels.ConsoleMessageChannel> implements channels.ConsoleMessageChannel {
|
||||
_type_ConsoleMessage = true;
|
||||
constructor(scope: DispatcherScope, message: ConsoleMessage) {
|
||||
super(scope, message, 'ConsoleMessage', {
|
||||
type: message.type(),
|
||||
|
@ -18,7 +18,8 @@ import { Dialog } from '../server/dialog';
|
||||
import * as channels from '../protocol/channels';
|
||||
import { Dispatcher, DispatcherScope } from './dispatcher';
|
||||
|
||||
export class DialogDispatcher extends Dispatcher<Dialog, channels.DialogInitializer, channels.DialogEvents> implements channels.DialogChannel {
|
||||
export class DialogDispatcher extends Dispatcher<Dialog, channels.DialogChannel> implements channels.DialogChannel {
|
||||
_type_Dialog = true;
|
||||
constructor(scope: DispatcherScope, dialog: Dialog) {
|
||||
super(scope, dialog, 'Dialog', {
|
||||
type: dialog.type(),
|
||||
|
@ -41,21 +41,21 @@ export function lookupNullableDispatcher<DispatcherType>(object: any | null): Di
|
||||
return object ? lookupDispatcher(object) : undefined;
|
||||
}
|
||||
|
||||
export class Dispatcher<Type extends { guid: string }, Initializer, Events> extends EventEmitter implements channels.Channel {
|
||||
export class Dispatcher<Type extends { guid: string }, ChannelType> extends EventEmitter implements channels.Channel {
|
||||
private _connection: DispatcherConnection;
|
||||
private _isScope: boolean;
|
||||
// Parent is always "isScope".
|
||||
private _parent: Dispatcher<any, any, {}> | undefined;
|
||||
private _parent: Dispatcher<any, any> | undefined;
|
||||
// Only "isScope" channel owners have registered dispatchers inside.
|
||||
private _dispatchers = new Map<string, Dispatcher<any, any, {}>>();
|
||||
private _dispatchers = new Map<string, Dispatcher<any, any>>();
|
||||
protected _disposed = false;
|
||||
|
||||
readonly _guid: string;
|
||||
readonly _type: string;
|
||||
readonly _scope: Dispatcher<any, any, {}>;
|
||||
readonly _scope: Dispatcher<any, any>;
|
||||
_object: Type;
|
||||
|
||||
constructor(parent: Dispatcher<any, any, {}> | DispatcherConnection, object: Type, type: string, initializer: Initializer, isScope?: boolean) {
|
||||
constructor(parent: Dispatcher<any, any> | DispatcherConnection, object: Type, type: string, initializer: channels.InitializerTraits<Type>, isScope?: boolean) {
|
||||
super();
|
||||
|
||||
this._connection = parent instanceof DispatcherConnection ? parent : parent._connection;
|
||||
@ -80,7 +80,7 @@ export class Dispatcher<Type extends { guid: string }, Initializer, Events> exte
|
||||
this._connection.sendMessageToClient(this._parent._guid, type, '__create__', { type, initializer, guid }, this._parent._object);
|
||||
}
|
||||
|
||||
_dispatchEvent<T extends keyof Events>(method: T, params?: Events[T]) {
|
||||
_dispatchEvent<T extends keyof channels.EventsTraits<ChannelType>>(method: T, params?: channels.EventsTraits<ChannelType>[T]) {
|
||||
if (this._disposed) {
|
||||
if (isUnderTest())
|
||||
throw new Error(`${this._guid} is sending "${method}" event after being disposed`);
|
||||
@ -121,8 +121,8 @@ export class Dispatcher<Type extends { guid: string }, Initializer, Events> exte
|
||||
}
|
||||
}
|
||||
|
||||
export type DispatcherScope = Dispatcher<any, any, {}>;
|
||||
export class Root extends Dispatcher<{ guid: '' }, {}, {}> {
|
||||
export type DispatcherScope = Dispatcher<any, any>;
|
||||
export class Root extends Dispatcher<{ guid: '' }, any> {
|
||||
private _initialized = false;
|
||||
|
||||
constructor(connection: DispatcherConnection, private readonly createPlaywright?: (scope: DispatcherScope, options: channels.RootInitializeParams) => Promise<PlaywrightDispatcher>) {
|
||||
@ -140,7 +140,7 @@ export class Root extends Dispatcher<{ guid: '' }, {}, {}> {
|
||||
}
|
||||
|
||||
export class DispatcherConnection {
|
||||
readonly _dispatchers = new Map<string, Dispatcher<any, any, {}>>();
|
||||
readonly _dispatchers = new Map<string, Dispatcher<any, any>>();
|
||||
onmessage = (message: object) => {};
|
||||
private _validateParams: (type: string, method: string, params: any) => any;
|
||||
private _validateMetadata: (metadata: any) => { stack?: channels.StackFrame[] };
|
||||
|
@ -22,7 +22,8 @@ import { PageDispatcher } from './pageDispatcher';
|
||||
import { parseArgument, serializeResult } from './jsHandleDispatcher';
|
||||
import { ElementHandleDispatcher } from './elementHandlerDispatcher';
|
||||
|
||||
export class ElectronDispatcher extends Dispatcher<Electron, channels.ElectronInitializer, channels.ElectronEvents> implements channels.ElectronChannel {
|
||||
export class ElectronDispatcher extends Dispatcher<Electron, channels.ElectronChannel> implements channels.ElectronChannel {
|
||||
_type_Electron = true;
|
||||
constructor(scope: DispatcherScope, electron: Electron) {
|
||||
super(scope, electron, 'Electron', {}, true);
|
||||
}
|
||||
@ -33,7 +34,10 @@ export class ElectronDispatcher extends Dispatcher<Electron, channels.ElectronIn
|
||||
}
|
||||
}
|
||||
|
||||
export class ElectronApplicationDispatcher extends Dispatcher<ElectronApplication, channels.ElectronApplicationInitializer, channels.ElectronApplicationEvents> implements channels.ElectronApplicationChannel {
|
||||
export class ElectronApplicationDispatcher extends Dispatcher<ElectronApplication, channels.ElectronApplicationChannel> implements channels.ElectronApplicationChannel {
|
||||
_type_EventTarget = true;
|
||||
_type_ElectronApplication = true;
|
||||
|
||||
constructor(scope: DispatcherScope, electronApplication: ElectronApplication) {
|
||||
super(scope, electronApplication, 'ElectronApplication', {
|
||||
context: new BrowserContextDispatcher(scope, electronApplication.context())
|
||||
|
@ -23,6 +23,8 @@ import { FrameDispatcher } from './frameDispatcher';
|
||||
import { CallMetadata } from '../server/instrumentation';
|
||||
|
||||
export class ElementHandleDispatcher extends JSHandleDispatcher implements channels.ElementHandleChannel {
|
||||
_type_ElementHandle = true;
|
||||
|
||||
readonly _elementHandle: ElementHandle;
|
||||
|
||||
static from(scope: DispatcherScope, handle: ElementHandle): ElementHandleDispatcher {
|
||||
|
@ -22,7 +22,8 @@ import { parseArgument, serializeResult } from './jsHandleDispatcher';
|
||||
import { ResponseDispatcher, RequestDispatcher } from './networkDispatchers';
|
||||
import { CallMetadata } from '../server/instrumentation';
|
||||
|
||||
export class FrameDispatcher extends Dispatcher<Frame, channels.FrameInitializer, channels.FrameEvents> implements channels.FrameChannel {
|
||||
export class FrameDispatcher extends Dispatcher<Frame, channels.FrameChannel> implements channels.FrameChannel {
|
||||
_type_Frame = true;
|
||||
private _frame: Frame;
|
||||
|
||||
static from(scope: DispatcherScope, frame: Frame): FrameDispatcher {
|
||||
|
@ -20,7 +20,8 @@ import { Dispatcher, DispatcherScope } from './dispatcher';
|
||||
import { ElementHandleDispatcher } from './elementHandlerDispatcher';
|
||||
import { parseSerializedValue, serializeValue } from '../protocol/serializers';
|
||||
|
||||
export class JSHandleDispatcher extends Dispatcher<js.JSHandle, channels.JSHandleInitializer, channels.JSHandleEvents> implements channels.JSHandleChannel {
|
||||
export class JSHandleDispatcher extends Dispatcher<js.JSHandle, channels.JSHandleChannel> implements channels.JSHandleChannel {
|
||||
_type_JSHandle = true;
|
||||
|
||||
protected constructor(scope: DispatcherScope, jsHandle: js.JSHandle) {
|
||||
// Do not call this directly, use createHandle() instead.
|
||||
|
@ -19,7 +19,8 @@ import { Dispatcher, DispatcherScope } from './dispatcher';
|
||||
import { createGuid } from '../utils/utils';
|
||||
import { serializeError } from '../protocol/serializers';
|
||||
|
||||
export class JsonPipeDispatcher extends Dispatcher<{ guid: string }, channels.JsonPipeInitializer, channels.JsonPipeEvents> implements channels.JsonPipeChannel {
|
||||
export class JsonPipeDispatcher extends Dispatcher<{ guid: string }, channels.JsonPipeChannel> implements channels.JsonPipeChannel {
|
||||
_type_JsonPipe = true;
|
||||
constructor(scope: DispatcherScope) {
|
||||
super(scope, { guid: 'jsonPipe@' + createGuid() }, 'JsonPipe', {});
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ import { Request, Response, Route, WebSocket } from '../server/network';
|
||||
import { Dispatcher, DispatcherScope, existingDispatcher, lookupNullableDispatcher } from './dispatcher';
|
||||
import { FrameDispatcher } from './frameDispatcher';
|
||||
|
||||
export class RequestDispatcher extends Dispatcher<Request, channels.RequestInitializer, channels.RequestEvents> implements channels.RequestChannel {
|
||||
export class RequestDispatcher extends Dispatcher<Request, channels.RequestChannel> implements channels.RequestChannel {
|
||||
_type_Request: boolean;
|
||||
|
||||
static from(scope: DispatcherScope, request: Request): RequestDispatcher {
|
||||
const result = existingDispatcher<RequestDispatcher>(request);
|
||||
@ -44,6 +45,7 @@ export class RequestDispatcher extends Dispatcher<Request, channels.RequestIniti
|
||||
isNavigationRequest: request.isNavigationRequest(),
|
||||
redirectedFrom: RequestDispatcher.fromNullable(scope, request.redirectedFrom()),
|
||||
});
|
||||
this._type_Request = true;
|
||||
}
|
||||
|
||||
async rawRequestHeaders(params?: channels.RequestRawRequestHeadersParams): Promise<channels.RequestRawRequestHeadersResult> {
|
||||
@ -55,7 +57,8 @@ export class RequestDispatcher extends Dispatcher<Request, channels.RequestIniti
|
||||
}
|
||||
}
|
||||
|
||||
export class ResponseDispatcher extends Dispatcher<Response, channels.ResponseInitializer, channels.ResponseEvents> implements channels.ResponseChannel {
|
||||
export class ResponseDispatcher extends Dispatcher<Response, channels.ResponseChannel> implements channels.ResponseChannel {
|
||||
_type_Response = true;
|
||||
|
||||
static from(scope: DispatcherScope, response: Response): ResponseDispatcher {
|
||||
const result = existingDispatcher<ResponseDispatcher>(response);
|
||||
@ -99,7 +102,8 @@ export class ResponseDispatcher extends Dispatcher<Response, channels.ResponseIn
|
||||
}
|
||||
}
|
||||
|
||||
export class RouteDispatcher extends Dispatcher<Route, channels.RouteInitializer, channels.RouteEvents> implements channels.RouteChannel {
|
||||
export class RouteDispatcher extends Dispatcher<Route, channels.RouteChannel> implements channels.RouteChannel {
|
||||
_type_Route = true;
|
||||
|
||||
static from(scope: DispatcherScope, route: Route): RouteDispatcher {
|
||||
const result = existingDispatcher<RouteDispatcher>(route);
|
||||
@ -131,7 +135,10 @@ export class RouteDispatcher extends Dispatcher<Route, channels.RouteInitializer
|
||||
}
|
||||
}
|
||||
|
||||
export class WebSocketDispatcher extends Dispatcher<WebSocket, channels.WebSocketInitializer, channels.WebSocketEvents> implements channels.WebSocketChannel {
|
||||
export class WebSocketDispatcher extends Dispatcher<WebSocket, channels.WebSocketChannel> implements channels.WebSocketChannel {
|
||||
_type_EventTarget = true;
|
||||
_type_WebSocket = true;
|
||||
|
||||
constructor(scope: DispatcherScope, webSocket: WebSocket) {
|
||||
super(scope, webSocket, 'WebSocket', {
|
||||
url: webSocket.url(),
|
||||
@ -143,7 +150,9 @@ export class WebSocketDispatcher extends Dispatcher<WebSocket, channels.WebSocke
|
||||
}
|
||||
}
|
||||
|
||||
export class APIRequestContextDispatcher extends Dispatcher<APIRequestContext, channels.APIRequestContextInitializer, channels.APIRequestContextEvents> implements channels.APIRequestContextChannel {
|
||||
export class APIRequestContextDispatcher extends Dispatcher<APIRequestContext, channels.APIRequestContextChannel> implements channels.APIRequestContextChannel {
|
||||
_type_APIRequestContext = true;
|
||||
|
||||
static from(scope: DispatcherScope, request: APIRequestContext): APIRequestContextDispatcher {
|
||||
const result = existingDispatcher<APIRequestContextDispatcher>(request);
|
||||
return result || new APIRequestContextDispatcher(scope, request);
|
||||
|
@ -35,7 +35,9 @@ import { ArtifactDispatcher } from './artifactDispatcher';
|
||||
import { Download } from '../server/download';
|
||||
import { createGuid } from '../utils/utils';
|
||||
|
||||
export class PageDispatcher extends Dispatcher<Page, channels.PageInitializer, channels.PageEvents> implements channels.PageChannel {
|
||||
export class PageDispatcher extends Dispatcher<Page, channels.PageChannel> implements channels.PageChannel {
|
||||
_type_EventTarget = true;
|
||||
_type_Page = true;
|
||||
private _page: Page;
|
||||
|
||||
static fromNullable(scope: DispatcherScope, page: Page | undefined): PageDispatcher | undefined {
|
||||
@ -253,7 +255,8 @@ export class PageDispatcher extends Dispatcher<Page, channels.PageInitializer, c
|
||||
}
|
||||
|
||||
|
||||
export class WorkerDispatcher extends Dispatcher<Worker, channels.WorkerInitializer, channels.WorkerEvents> implements channels.WorkerChannel {
|
||||
export class WorkerDispatcher extends Dispatcher<Worker, channels.WorkerChannel> implements channels.WorkerChannel {
|
||||
_type_Worker = true;
|
||||
constructor(scope: DispatcherScope, worker: Worker) {
|
||||
super(scope, worker, 'Worker', {
|
||||
url: worker.url()
|
||||
@ -270,7 +273,8 @@ export class WorkerDispatcher extends Dispatcher<Worker, channels.WorkerInitiali
|
||||
}
|
||||
}
|
||||
|
||||
export class BindingCallDispatcher extends Dispatcher<{ guid: string }, channels.BindingCallInitializer, channels.BindingCallEvents> implements channels.BindingCallChannel {
|
||||
export class BindingCallDispatcher extends Dispatcher<{ guid: string }, channels.BindingCallChannel> implements channels.BindingCallChannel {
|
||||
_type_BindingCall = true;
|
||||
private _resolve: ((arg: any) => void) | undefined;
|
||||
private _reject: ((error: any) => void) | undefined;
|
||||
private _promise: Promise<any>;
|
||||
|
@ -29,7 +29,8 @@ import { ElectronDispatcher } from './electronDispatcher';
|
||||
import { APIRequestContextDispatcher } from './networkDispatchers';
|
||||
import { SelectorsDispatcher } from './selectorsDispatcher';
|
||||
|
||||
export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.PlaywrightInitializer, channels.PlaywrightEvents> implements channels.PlaywrightChannel {
|
||||
export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.PlaywrightChannel> implements channels.PlaywrightChannel {
|
||||
_type_Playwright;
|
||||
private _socksProxy: SocksProxy | undefined;
|
||||
|
||||
constructor(scope: DispatcherScope, playwright: Playwright, customSelectors?: channels.SelectorsChannel, preLaunchedBrowser?: channels.BrowserChannel) {
|
||||
@ -46,6 +47,7 @@ export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.Playwr
|
||||
selectors: customSelectors || new SelectorsDispatcher(scope, playwright.selectors),
|
||||
preLaunchedBrowser,
|
||||
}, false);
|
||||
this._type_Playwright = true;
|
||||
}
|
||||
|
||||
async enableSocksProxy() {
|
||||
|
@ -18,7 +18,8 @@ import { Dispatcher, DispatcherScope } from './dispatcher';
|
||||
import * as channels from '../protocol/channels';
|
||||
import { Selectors } from '../server/selectors';
|
||||
|
||||
export class SelectorsDispatcher extends Dispatcher<Selectors, channels.SelectorsInitializer, channels.SelectorsEvents> implements channels.SelectorsChannel {
|
||||
export class SelectorsDispatcher extends Dispatcher<Selectors, channels.SelectorsChannel> implements channels.SelectorsChannel {
|
||||
_type_Selectors = true;
|
||||
constructor(scope: DispatcherScope, selectors: Selectors) {
|
||||
super(scope, selectors, 'Selectors', {});
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ import { Dispatcher, DispatcherScope } from './dispatcher';
|
||||
import * as stream from 'stream';
|
||||
import { createGuid } from '../utils/utils';
|
||||
|
||||
export class StreamDispatcher extends Dispatcher<{ guid: string, stream: stream.Readable }, channels.StreamInitializer, channels.StreamEvents> implements channels.StreamChannel {
|
||||
export class StreamDispatcher extends Dispatcher<{ guid: string, stream: stream.Readable }, channels.StreamChannel> implements channels.StreamChannel {
|
||||
_type_Stream = true;
|
||||
private _ended: boolean = false;
|
||||
constructor(scope: DispatcherScope, stream: stream.Readable) {
|
||||
super(scope, { guid: 'stream@' + createGuid(), stream }, 'Stream', {});
|
||||
|
@ -16,13 +16,110 @@
|
||||
|
||||
// This file is generated by generate_channels.js, do not edit manually.
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export type Binary = string;
|
||||
|
||||
export interface Channel extends EventEmitter {
|
||||
export interface Channel {
|
||||
}
|
||||
|
||||
// ----------- Initializer Traits -----------
|
||||
export type InitializerTraits<T> =
|
||||
T extends JsonPipeChannel ? JsonPipeInitializer :
|
||||
T extends AndroidDeviceChannel ? AndroidDeviceInitializer :
|
||||
T extends AndroidSocketChannel ? AndroidSocketInitializer :
|
||||
T extends AndroidChannel ? AndroidInitializer :
|
||||
T extends ElectronApplicationChannel ? ElectronApplicationInitializer :
|
||||
T extends ElectronChannel ? ElectronInitializer :
|
||||
T extends CDPSessionChannel ? CDPSessionInitializer :
|
||||
T extends StreamChannel ? StreamInitializer :
|
||||
T extends ArtifactChannel ? ArtifactInitializer :
|
||||
T extends DialogChannel ? DialogInitializer :
|
||||
T extends BindingCallChannel ? BindingCallInitializer :
|
||||
T extends ConsoleMessageChannel ? ConsoleMessageInitializer :
|
||||
T extends WebSocketChannel ? WebSocketInitializer :
|
||||
T extends ResponseChannel ? ResponseInitializer :
|
||||
T extends RouteChannel ? RouteInitializer :
|
||||
T extends RequestChannel ? RequestInitializer :
|
||||
T extends ElementHandleChannel ? ElementHandleInitializer :
|
||||
T extends JSHandleChannel ? JSHandleInitializer :
|
||||
T extends WorkerChannel ? WorkerInitializer :
|
||||
T extends FrameChannel ? FrameInitializer :
|
||||
T extends PageChannel ? PageInitializer :
|
||||
T extends BrowserContextChannel ? BrowserContextInitializer :
|
||||
T extends EventTargetChannel ? EventTargetInitializer :
|
||||
T extends BrowserChannel ? BrowserInitializer :
|
||||
T extends BrowserTypeChannel ? BrowserTypeInitializer :
|
||||
T extends SelectorsChannel ? SelectorsInitializer :
|
||||
T extends PlaywrightChannel ? PlaywrightInitializer :
|
||||
T extends RootChannel ? RootInitializer :
|
||||
T extends APIRequestContextChannel ? APIRequestContextInitializer :
|
||||
object;
|
||||
|
||||
// ----------- Event Traits -----------
|
||||
export type EventsTraits<T> =
|
||||
T extends JsonPipeChannel ? JsonPipeEvents :
|
||||
T extends AndroidDeviceChannel ? AndroidDeviceEvents :
|
||||
T extends AndroidSocketChannel ? AndroidSocketEvents :
|
||||
T extends AndroidChannel ? AndroidEvents :
|
||||
T extends ElectronApplicationChannel ? ElectronApplicationEvents :
|
||||
T extends ElectronChannel ? ElectronEvents :
|
||||
T extends CDPSessionChannel ? CDPSessionEvents :
|
||||
T extends StreamChannel ? StreamEvents :
|
||||
T extends ArtifactChannel ? ArtifactEvents :
|
||||
T extends DialogChannel ? DialogEvents :
|
||||
T extends BindingCallChannel ? BindingCallEvents :
|
||||
T extends ConsoleMessageChannel ? ConsoleMessageEvents :
|
||||
T extends WebSocketChannel ? WebSocketEvents :
|
||||
T extends ResponseChannel ? ResponseEvents :
|
||||
T extends RouteChannel ? RouteEvents :
|
||||
T extends RequestChannel ? RequestEvents :
|
||||
T extends ElementHandleChannel ? ElementHandleEvents :
|
||||
T extends JSHandleChannel ? JSHandleEvents :
|
||||
T extends WorkerChannel ? WorkerEvents :
|
||||
T extends FrameChannel ? FrameEvents :
|
||||
T extends PageChannel ? PageEvents :
|
||||
T extends BrowserContextChannel ? BrowserContextEvents :
|
||||
T extends EventTargetChannel ? EventTargetEvents :
|
||||
T extends BrowserChannel ? BrowserEvents :
|
||||
T extends BrowserTypeChannel ? BrowserTypeEvents :
|
||||
T extends SelectorsChannel ? SelectorsEvents :
|
||||
T extends PlaywrightChannel ? PlaywrightEvents :
|
||||
T extends RootChannel ? RootEvents :
|
||||
T extends APIRequestContextChannel ? APIRequestContextEvents :
|
||||
undefined;
|
||||
|
||||
// ----------- EventTarget Traits -----------
|
||||
export type EventTargetTraits<T> =
|
||||
T extends JsonPipeChannel ? JsonPipeEventTarget :
|
||||
T extends AndroidDeviceChannel ? AndroidDeviceEventTarget :
|
||||
T extends AndroidSocketChannel ? AndroidSocketEventTarget :
|
||||
T extends AndroidChannel ? AndroidEventTarget :
|
||||
T extends ElectronApplicationChannel ? ElectronApplicationEventTarget :
|
||||
T extends ElectronChannel ? ElectronEventTarget :
|
||||
T extends CDPSessionChannel ? CDPSessionEventTarget :
|
||||
T extends StreamChannel ? StreamEventTarget :
|
||||
T extends ArtifactChannel ? ArtifactEventTarget :
|
||||
T extends DialogChannel ? DialogEventTarget :
|
||||
T extends BindingCallChannel ? BindingCallEventTarget :
|
||||
T extends ConsoleMessageChannel ? ConsoleMessageEventTarget :
|
||||
T extends WebSocketChannel ? WebSocketEventTarget :
|
||||
T extends ResponseChannel ? ResponseEventTarget :
|
||||
T extends RouteChannel ? RouteEventTarget :
|
||||
T extends RequestChannel ? RequestEventTarget :
|
||||
T extends ElementHandleChannel ? ElementHandleEventTarget :
|
||||
T extends JSHandleChannel ? JSHandleEventTarget :
|
||||
T extends WorkerChannel ? WorkerEventTarget :
|
||||
T extends FrameChannel ? FrameEventTarget :
|
||||
T extends PageChannel ? PageEventTarget :
|
||||
T extends BrowserContextChannel ? BrowserContextEventTarget :
|
||||
T extends EventTargetChannel ? EventTargetEventTarget :
|
||||
T extends BrowserChannel ? BrowserEventTarget :
|
||||
T extends BrowserTypeChannel ? BrowserTypeEventTarget :
|
||||
T extends SelectorsChannel ? SelectorsEventTarget :
|
||||
T extends PlaywrightChannel ? PlaywrightEventTarget :
|
||||
T extends RootChannel ? RootEventTarget :
|
||||
T extends APIRequestContextChannel ? APIRequestContextEventTarget :
|
||||
undefined;
|
||||
|
||||
export type StackFrame = {
|
||||
file: string,
|
||||
line?: number,
|
||||
@ -163,7 +260,10 @@ export type FormField = {
|
||||
|
||||
// ----------- APIRequestContext -----------
|
||||
export type APIRequestContextInitializer = {};
|
||||
export interface APIRequestContextChannel extends Channel {
|
||||
export interface APIRequestContextEventTarget {
|
||||
}
|
||||
export interface APIRequestContextChannel extends APIRequestContextEventTarget, Channel {
|
||||
_type_APIRequestContext: boolean;
|
||||
fetch(params: APIRequestContextFetchParams, metadata?: Metadata): Promise<APIRequestContextFetchResult>;
|
||||
fetchResponseBody(params: APIRequestContextFetchResponseBodyParams, metadata?: Metadata): Promise<APIRequestContextFetchResponseBodyResult>;
|
||||
storageState(params?: APIRequestContextStorageStateParams, metadata?: Metadata): Promise<APIRequestContextStorageStateResult>;
|
||||
@ -239,7 +339,10 @@ export type APIResponse = {
|
||||
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
||||
// ----------- Root -----------
|
||||
export type RootInitializer = {};
|
||||
export interface RootChannel extends Channel {
|
||||
export interface RootEventTarget {
|
||||
}
|
||||
export interface RootChannel extends RootEventTarget, Channel {
|
||||
_type_Root: boolean;
|
||||
initialize(params: RootInitializeParams, metadata?: Metadata): Promise<RootInitializeResult>;
|
||||
}
|
||||
export type RootInitializeParams = {
|
||||
@ -283,10 +386,13 @@ export type PlaywrightInitializer = {
|
||||
selectors: SelectorsChannel,
|
||||
preLaunchedBrowser?: BrowserChannel,
|
||||
};
|
||||
export interface PlaywrightChannel extends Channel {
|
||||
export interface PlaywrightEventTarget {
|
||||
on(event: 'socksRequested', callback: (params: PlaywrightSocksRequestedEvent) => void): this;
|
||||
on(event: 'socksData', callback: (params: PlaywrightSocksDataEvent) => void): this;
|
||||
on(event: 'socksClosed', callback: (params: PlaywrightSocksClosedEvent) => void): this;
|
||||
}
|
||||
export interface PlaywrightChannel extends PlaywrightEventTarget, Channel {
|
||||
_type_Playwright: boolean;
|
||||
socksConnected(params: PlaywrightSocksConnectedParams, metadata?: Metadata): Promise<PlaywrightSocksConnectedResult>;
|
||||
socksFailed(params: PlaywrightSocksFailedParams, metadata?: Metadata): Promise<PlaywrightSocksFailedResult>;
|
||||
socksData(params: PlaywrightSocksDataParams, metadata?: Metadata): Promise<PlaywrightSocksDataResult>;
|
||||
@ -400,7 +506,10 @@ export interface PlaywrightEvents {
|
||||
|
||||
// ----------- Selectors -----------
|
||||
export type SelectorsInitializer = {};
|
||||
export interface SelectorsChannel extends Channel {
|
||||
export interface SelectorsEventTarget {
|
||||
}
|
||||
export interface SelectorsChannel extends SelectorsEventTarget, Channel {
|
||||
_type_Selectors: boolean;
|
||||
register(params: SelectorsRegisterParams, metadata?: Metadata): Promise<SelectorsRegisterResult>;
|
||||
}
|
||||
export type SelectorsRegisterParams = {
|
||||
@ -421,7 +530,10 @@ export type BrowserTypeInitializer = {
|
||||
executablePath: string,
|
||||
name: string,
|
||||
};
|
||||
export interface BrowserTypeChannel extends Channel {
|
||||
export interface BrowserTypeEventTarget {
|
||||
}
|
||||
export interface BrowserTypeChannel extends BrowserTypeEventTarget, Channel {
|
||||
_type_BrowserType: boolean;
|
||||
connect(params: BrowserTypeConnectParams, metadata?: Metadata): Promise<BrowserTypeConnectResult>;
|
||||
launch(params: BrowserTypeLaunchParams, metadata?: Metadata): Promise<BrowserTypeLaunchResult>;
|
||||
launchPersistentContext(params: BrowserTypeLaunchPersistentContextParams, metadata?: Metadata): Promise<BrowserTypeLaunchPersistentContextResult>;
|
||||
@ -664,8 +776,11 @@ export type BrowserInitializer = {
|
||||
version: string,
|
||||
name: string,
|
||||
};
|
||||
export interface BrowserChannel extends Channel {
|
||||
export interface BrowserEventTarget {
|
||||
on(event: 'close', callback: (params: BrowserCloseEvent) => void): this;
|
||||
}
|
||||
export interface BrowserChannel extends BrowserEventTarget, Channel {
|
||||
_type_Browser: boolean;
|
||||
close(params?: BrowserCloseParams, metadata?: Metadata): Promise<BrowserCloseResult>;
|
||||
killForTests(params?: BrowserKillForTestsParams, metadata?: Metadata): Promise<BrowserKillForTestsResult>;
|
||||
newContext(params: BrowserNewContextParams, metadata?: Metadata): Promise<BrowserNewContextResult>;
|
||||
@ -831,7 +946,10 @@ export interface BrowserEvents {
|
||||
|
||||
// ----------- EventTarget -----------
|
||||
export type EventTargetInitializer = {};
|
||||
export interface EventTargetChannel extends Channel {
|
||||
export interface EventTargetEventTarget {
|
||||
}
|
||||
export interface EventTargetChannel extends EventTargetEventTarget, Channel {
|
||||
_type_EventTarget: boolean;
|
||||
waitForEventInfo(params: EventTargetWaitForEventInfoParams, metadata?: Metadata): Promise<EventTargetWaitForEventInfoResult>;
|
||||
}
|
||||
export type EventTargetWaitForEventInfoParams = {
|
||||
@ -856,7 +974,7 @@ export type BrowserContextInitializer = {
|
||||
isChromium: boolean,
|
||||
APIRequestContext: APIRequestContextChannel,
|
||||
};
|
||||
export interface BrowserContextChannel extends EventTargetChannel {
|
||||
export interface BrowserContextEventTarget {
|
||||
on(event: 'bindingCall', callback: (params: BrowserContextBindingCallEvent) => void): this;
|
||||
on(event: 'close', callback: (params: BrowserContextCloseEvent) => void): this;
|
||||
on(event: 'page', callback: (params: BrowserContextPageEvent) => void): this;
|
||||
@ -868,6 +986,9 @@ export interface BrowserContextChannel extends EventTargetChannel {
|
||||
on(event: 'requestFailed', callback: (params: BrowserContextRequestFailedEvent) => void): this;
|
||||
on(event: 'requestFinished', callback: (params: BrowserContextRequestFinishedEvent) => void): this;
|
||||
on(event: 'response', callback: (params: BrowserContextResponseEvent) => void): this;
|
||||
}
|
||||
export interface BrowserContextChannel extends BrowserContextEventTarget, EventTargetChannel {
|
||||
_type_BrowserContext: boolean;
|
||||
addCookies(params: BrowserContextAddCookiesParams, metadata?: Metadata): Promise<BrowserContextAddCookiesResult>;
|
||||
addInitScript(params: BrowserContextAddInitScriptParams, metadata?: Metadata): Promise<BrowserContextAddInitScriptResult>;
|
||||
clearCookies(params?: BrowserContextClearCookiesParams, metadata?: Metadata): Promise<BrowserContextClearCookiesResult>;
|
||||
@ -1153,7 +1274,7 @@ export type PageInitializer = {
|
||||
isClosed: boolean,
|
||||
opener?: PageChannel,
|
||||
};
|
||||
export interface PageChannel extends EventTargetChannel {
|
||||
export interface PageEventTarget {
|
||||
on(event: 'bindingCall', callback: (params: PageBindingCallEvent) => void): this;
|
||||
on(event: 'close', callback: (params: PageCloseEvent) => void): this;
|
||||
on(event: 'console', callback: (params: PageConsoleEvent) => void): this;
|
||||
@ -1170,6 +1291,9 @@ export interface PageChannel extends EventTargetChannel {
|
||||
on(event: 'video', callback: (params: PageVideoEvent) => void): this;
|
||||
on(event: 'webSocket', callback: (params: PageWebSocketEvent) => void): this;
|
||||
on(event: 'worker', callback: (params: PageWorkerEvent) => void): this;
|
||||
}
|
||||
export interface PageChannel extends PageEventTarget, EventTargetChannel {
|
||||
_type_Page: boolean;
|
||||
setDefaultNavigationTimeoutNoReply(params: PageSetDefaultNavigationTimeoutNoReplyParams, metadata?: Metadata): Promise<PageSetDefaultNavigationTimeoutNoReplyResult>;
|
||||
setDefaultTimeoutNoReply(params: PageSetDefaultTimeoutNoReplyParams, metadata?: Metadata): Promise<PageSetDefaultTimeoutNoReplyResult>;
|
||||
setFileChooserInterceptedNoReply(params: PageSetFileChooserInterceptedNoReplyParams, metadata?: Metadata): Promise<PageSetFileChooserInterceptedNoReplyResult>;
|
||||
@ -1600,9 +1724,12 @@ export type FrameInitializer = {
|
||||
parentFrame?: FrameChannel,
|
||||
loadStates: LifecycleEvent[],
|
||||
};
|
||||
export interface FrameChannel extends Channel {
|
||||
export interface FrameEventTarget {
|
||||
on(event: 'loadstate', callback: (params: FrameLoadstateEvent) => void): this;
|
||||
on(event: 'navigated', callback: (params: FrameNavigatedEvent) => void): this;
|
||||
}
|
||||
export interface FrameChannel extends FrameEventTarget, Channel {
|
||||
_type_Frame: boolean;
|
||||
evalOnSelector(params: FrameEvalOnSelectorParams, metadata?: Metadata): Promise<FrameEvalOnSelectorResult>;
|
||||
evalOnSelectorAll(params: FrameEvalOnSelectorAllParams, metadata?: Metadata): Promise<FrameEvalOnSelectorAllResult>;
|
||||
addScriptTag(params: FrameAddScriptTagParams, metadata?: Metadata): Promise<FrameAddScriptTagResult>;
|
||||
@ -2244,8 +2371,11 @@ export interface FrameEvents {
|
||||
export type WorkerInitializer = {
|
||||
url: string,
|
||||
};
|
||||
export interface WorkerChannel extends Channel {
|
||||
export interface WorkerEventTarget {
|
||||
on(event: 'close', callback: (params: WorkerCloseEvent) => void): this;
|
||||
}
|
||||
export interface WorkerChannel extends WorkerEventTarget, Channel {
|
||||
_type_Worker: boolean;
|
||||
evaluateExpression(params: WorkerEvaluateExpressionParams, metadata?: Metadata): Promise<WorkerEvaluateExpressionResult>;
|
||||
evaluateExpressionHandle(params: WorkerEvaluateExpressionHandleParams, metadata?: Metadata): Promise<WorkerEvaluateExpressionHandleResult>;
|
||||
}
|
||||
@ -2281,8 +2411,11 @@ export interface WorkerEvents {
|
||||
export type JSHandleInitializer = {
|
||||
preview: string,
|
||||
};
|
||||
export interface JSHandleChannel extends Channel {
|
||||
export interface JSHandleEventTarget {
|
||||
on(event: 'previewUpdated', callback: (params: JSHandlePreviewUpdatedEvent) => void): this;
|
||||
}
|
||||
export interface JSHandleChannel extends JSHandleEventTarget, Channel {
|
||||
_type_JSHandle: boolean;
|
||||
dispose(params?: JSHandleDisposeParams, metadata?: Metadata): Promise<JSHandleDisposeResult>;
|
||||
evaluateExpression(params: JSHandleEvaluateExpressionParams, metadata?: Metadata): Promise<JSHandleEvaluateExpressionResult>;
|
||||
evaluateExpressionHandle(params: JSHandleEvaluateExpressionHandleParams, metadata?: Metadata): Promise<JSHandleEvaluateExpressionHandleResult>;
|
||||
@ -2347,7 +2480,10 @@ export interface JSHandleEvents {
|
||||
|
||||
// ----------- ElementHandle -----------
|
||||
export type ElementHandleInitializer = {};
|
||||
export interface ElementHandleChannel extends JSHandleChannel {
|
||||
export interface ElementHandleEventTarget {
|
||||
}
|
||||
export interface ElementHandleChannel extends ElementHandleEventTarget, JSHandleChannel {
|
||||
_type_ElementHandle: boolean;
|
||||
evalOnSelector(params: ElementHandleEvalOnSelectorParams, metadata?: Metadata): Promise<ElementHandleEvalOnSelectorResult>;
|
||||
evalOnSelectorAll(params: ElementHandleEvalOnSelectorAllParams, metadata?: Metadata): Promise<ElementHandleEvalOnSelectorAllResult>;
|
||||
boundingBox(params?: ElementHandleBoundingBoxParams, metadata?: Metadata): Promise<ElementHandleBoundingBoxResult>;
|
||||
@ -2764,7 +2900,10 @@ export type RequestInitializer = {
|
||||
isNavigationRequest: boolean,
|
||||
redirectedFrom?: RequestChannel,
|
||||
};
|
||||
export interface RequestChannel extends Channel {
|
||||
export interface RequestEventTarget {
|
||||
}
|
||||
export interface RequestChannel extends RequestEventTarget, Channel {
|
||||
_type_Request: boolean;
|
||||
response(params?: RequestResponseParams, metadata?: Metadata): Promise<RequestResponseResult>;
|
||||
rawRequestHeaders(params?: RequestRawRequestHeadersParams, metadata?: Metadata): Promise<RequestRawRequestHeadersResult>;
|
||||
}
|
||||
@ -2786,7 +2925,10 @@ export interface RequestEvents {
|
||||
export type RouteInitializer = {
|
||||
request: RequestChannel,
|
||||
};
|
||||
export interface RouteChannel extends Channel {
|
||||
export interface RouteEventTarget {
|
||||
}
|
||||
export interface RouteChannel extends RouteEventTarget, Channel {
|
||||
_type_Route: boolean;
|
||||
abort(params: RouteAbortParams, metadata?: Metadata): Promise<RouteAbortResult>;
|
||||
continue(params: RouteContinueParams, metadata?: Metadata): Promise<RouteContinueResult>;
|
||||
fulfill(params: RouteFulfillParams, metadata?: Metadata): Promise<RouteFulfillResult>;
|
||||
@ -2850,7 +2992,10 @@ export type ResponseInitializer = {
|
||||
headers: NameValue[],
|
||||
timing: ResourceTiming,
|
||||
};
|
||||
export interface ResponseChannel extends Channel {
|
||||
export interface ResponseEventTarget {
|
||||
}
|
||||
export interface ResponseChannel extends ResponseEventTarget, Channel {
|
||||
_type_Response: boolean;
|
||||
body(params?: ResponseBodyParams, metadata?: Metadata): Promise<ResponseBodyResult>;
|
||||
securityDetails(params?: ResponseSecurityDetailsParams, metadata?: Metadata): Promise<ResponseSecurityDetailsResult>;
|
||||
serverAddr(params?: ResponseServerAddrParams, metadata?: Metadata): Promise<ResponseServerAddrResult>;
|
||||
@ -2910,13 +3055,16 @@ export type RemoteAddr = {
|
||||
export type WebSocketInitializer = {
|
||||
url: string,
|
||||
};
|
||||
export interface WebSocketChannel extends EventTargetChannel {
|
||||
export interface WebSocketEventTarget {
|
||||
on(event: 'open', callback: (params: WebSocketOpenEvent) => void): this;
|
||||
on(event: 'frameSent', callback: (params: WebSocketFrameSentEvent) => void): this;
|
||||
on(event: 'frameReceived', callback: (params: WebSocketFrameReceivedEvent) => void): this;
|
||||
on(event: 'socketError', callback: (params: WebSocketSocketErrorEvent) => void): this;
|
||||
on(event: 'close', callback: (params: WebSocketCloseEvent) => void): this;
|
||||
}
|
||||
export interface WebSocketChannel extends WebSocketEventTarget, EventTargetChannel {
|
||||
_type_WebSocket: boolean;
|
||||
}
|
||||
export type WebSocketOpenEvent = {};
|
||||
export type WebSocketFrameSentEvent = {
|
||||
opcode: number,
|
||||
@ -2950,7 +3098,10 @@ export type ConsoleMessageInitializer = {
|
||||
columnNumber: number,
|
||||
},
|
||||
};
|
||||
export interface ConsoleMessageChannel extends Channel {
|
||||
export interface ConsoleMessageEventTarget {
|
||||
}
|
||||
export interface ConsoleMessageChannel extends ConsoleMessageEventTarget, Channel {
|
||||
_type_ConsoleMessage: boolean;
|
||||
}
|
||||
|
||||
export interface ConsoleMessageEvents {
|
||||
@ -2963,7 +3114,10 @@ export type BindingCallInitializer = {
|
||||
args?: SerializedValue[],
|
||||
handle?: JSHandleChannel,
|
||||
};
|
||||
export interface BindingCallChannel extends Channel {
|
||||
export interface BindingCallEventTarget {
|
||||
}
|
||||
export interface BindingCallChannel extends BindingCallEventTarget, Channel {
|
||||
_type_BindingCall: boolean;
|
||||
reject(params: BindingCallRejectParams, metadata?: Metadata): Promise<BindingCallRejectResult>;
|
||||
resolve(params: BindingCallResolveParams, metadata?: Metadata): Promise<BindingCallResolveResult>;
|
||||
}
|
||||
@ -2991,7 +3145,10 @@ export type DialogInitializer = {
|
||||
message: string,
|
||||
defaultValue: string,
|
||||
};
|
||||
export interface DialogChannel extends Channel {
|
||||
export interface DialogEventTarget {
|
||||
}
|
||||
export interface DialogChannel extends DialogEventTarget, Channel {
|
||||
_type_Dialog: boolean;
|
||||
accept(params: DialogAcceptParams, metadata?: Metadata): Promise<DialogAcceptResult>;
|
||||
dismiss(params?: DialogDismissParams, metadata?: Metadata): Promise<DialogDismissResult>;
|
||||
}
|
||||
@ -3013,7 +3170,10 @@ export interface DialogEvents {
|
||||
export type ArtifactInitializer = {
|
||||
absolutePath: string,
|
||||
};
|
||||
export interface ArtifactChannel extends Channel {
|
||||
export interface ArtifactEventTarget {
|
||||
}
|
||||
export interface ArtifactChannel extends ArtifactEventTarget, Channel {
|
||||
_type_Artifact: boolean;
|
||||
pathAfterFinished(params?: ArtifactPathAfterFinishedParams, metadata?: Metadata): Promise<ArtifactPathAfterFinishedResult>;
|
||||
saveAs(params: ArtifactSaveAsParams, metadata?: Metadata): Promise<ArtifactSaveAsResult>;
|
||||
saveAsStream(params?: ArtifactSaveAsStreamParams, metadata?: Metadata): Promise<ArtifactSaveAsStreamResult>;
|
||||
@ -3061,7 +3221,10 @@ export interface ArtifactEvents {
|
||||
|
||||
// ----------- Stream -----------
|
||||
export type StreamInitializer = {};
|
||||
export interface StreamChannel extends Channel {
|
||||
export interface StreamEventTarget {
|
||||
}
|
||||
export interface StreamChannel extends StreamEventTarget, Channel {
|
||||
_type_Stream: boolean;
|
||||
read(params: StreamReadParams, metadata?: Metadata): Promise<StreamReadResult>;
|
||||
close(params?: StreamCloseParams, metadata?: Metadata): Promise<StreamCloseResult>;
|
||||
}
|
||||
@ -3083,8 +3246,11 @@ export interface StreamEvents {
|
||||
|
||||
// ----------- CDPSession -----------
|
||||
export type CDPSessionInitializer = {};
|
||||
export interface CDPSessionChannel extends Channel {
|
||||
export interface CDPSessionEventTarget {
|
||||
on(event: 'event', callback: (params: CDPSessionEventEvent) => void): this;
|
||||
}
|
||||
export interface CDPSessionChannel extends CDPSessionEventTarget, Channel {
|
||||
_type_CDPSession: boolean;
|
||||
send(params: CDPSessionSendParams, metadata?: Metadata): Promise<CDPSessionSendResult>;
|
||||
detach(params?: CDPSessionDetachParams, metadata?: Metadata): Promise<CDPSessionDetachResult>;
|
||||
}
|
||||
@ -3112,7 +3278,10 @@ export interface CDPSessionEvents {
|
||||
|
||||
// ----------- Electron -----------
|
||||
export type ElectronInitializer = {};
|
||||
export interface ElectronChannel extends Channel {
|
||||
export interface ElectronEventTarget {
|
||||
}
|
||||
export interface ElectronChannel extends ElectronEventTarget, Channel {
|
||||
_type_Electron: boolean;
|
||||
launch(params: ElectronLaunchParams, metadata?: Metadata): Promise<ElectronLaunchResult>;
|
||||
}
|
||||
export type ElectronLaunchParams = {
|
||||
@ -3198,8 +3367,11 @@ export interface ElectronEvents {
|
||||
export type ElectronApplicationInitializer = {
|
||||
context: BrowserContextChannel,
|
||||
};
|
||||
export interface ElectronApplicationChannel extends EventTargetChannel {
|
||||
export interface ElectronApplicationEventTarget {
|
||||
on(event: 'close', callback: (params: ElectronApplicationCloseEvent) => void): this;
|
||||
}
|
||||
export interface ElectronApplicationChannel extends ElectronApplicationEventTarget, EventTargetChannel {
|
||||
_type_ElectronApplication: boolean;
|
||||
browserWindow(params: ElectronApplicationBrowserWindowParams, metadata?: Metadata): Promise<ElectronApplicationBrowserWindowResult>;
|
||||
evaluateExpression(params: ElectronApplicationEvaluateExpressionParams, metadata?: Metadata): Promise<ElectronApplicationEvaluateExpressionResult>;
|
||||
evaluateExpressionHandle(params: ElectronApplicationEvaluateExpressionHandleParams, metadata?: Metadata): Promise<ElectronApplicationEvaluateExpressionHandleResult>;
|
||||
@ -3247,7 +3419,10 @@ export interface ElectronApplicationEvents {
|
||||
|
||||
// ----------- Android -----------
|
||||
export type AndroidInitializer = {};
|
||||
export interface AndroidChannel extends Channel {
|
||||
export interface AndroidEventTarget {
|
||||
}
|
||||
export interface AndroidChannel extends AndroidEventTarget, Channel {
|
||||
_type_Android: boolean;
|
||||
devices(params?: AndroidDevicesParams, metadata?: Metadata): Promise<AndroidDevicesResult>;
|
||||
setDefaultTimeoutNoReply(params: AndroidSetDefaultTimeoutNoReplyParams, metadata?: Metadata): Promise<AndroidSetDefaultTimeoutNoReplyResult>;
|
||||
}
|
||||
@ -3269,9 +3444,12 @@ export interface AndroidEvents {
|
||||
|
||||
// ----------- AndroidSocket -----------
|
||||
export type AndroidSocketInitializer = {};
|
||||
export interface AndroidSocketChannel extends Channel {
|
||||
export interface AndroidSocketEventTarget {
|
||||
on(event: 'data', callback: (params: AndroidSocketDataEvent) => void): this;
|
||||
on(event: 'close', callback: (params: AndroidSocketCloseEvent) => void): this;
|
||||
}
|
||||
export interface AndroidSocketChannel extends AndroidSocketEventTarget, Channel {
|
||||
_type_AndroidSocket: boolean;
|
||||
write(params: AndroidSocketWriteParams, metadata?: Metadata): Promise<AndroidSocketWriteResult>;
|
||||
close(params?: AndroidSocketCloseParams, metadata?: Metadata): Promise<AndroidSocketCloseResult>;
|
||||
}
|
||||
@ -3300,9 +3478,12 @@ export type AndroidDeviceInitializer = {
|
||||
model: string,
|
||||
serial: string,
|
||||
};
|
||||
export interface AndroidDeviceChannel extends EventTargetChannel {
|
||||
export interface AndroidDeviceEventTarget {
|
||||
on(event: 'webViewAdded', callback: (params: AndroidDeviceWebViewAddedEvent) => void): this;
|
||||
on(event: 'webViewRemoved', callback: (params: AndroidDeviceWebViewRemovedEvent) => void): this;
|
||||
}
|
||||
export interface AndroidDeviceChannel extends AndroidDeviceEventTarget, EventTargetChannel {
|
||||
_type_AndroidDevice: boolean;
|
||||
wait(params: AndroidDeviceWaitParams, metadata?: Metadata): Promise<AndroidDeviceWaitResult>;
|
||||
fill(params: AndroidDeviceFillParams, metadata?: Metadata): Promise<AndroidDeviceFillResult>;
|
||||
tap(params: AndroidDeviceTapParams, metadata?: Metadata): Promise<AndroidDeviceTapResult>;
|
||||
@ -3698,9 +3879,12 @@ export type AndroidElementInfo = {
|
||||
|
||||
// ----------- JsonPipe -----------
|
||||
export type JsonPipeInitializer = {};
|
||||
export interface JsonPipeChannel extends Channel {
|
||||
export interface JsonPipeEventTarget {
|
||||
on(event: 'message', callback: (params: JsonPipeMessageEvent) => void): this;
|
||||
on(event: 'closed', callback: (params: JsonPipeClosedEvent) => void): this;
|
||||
}
|
||||
export interface JsonPipeChannel extends JsonPipeEventTarget, Channel {
|
||||
_type_JsonPipe: boolean;
|
||||
send(params: JsonPipeSendParams, metadata?: Metadata): Promise<JsonPipeSendResult>;
|
||||
close(params?: JsonPipeCloseParams, metadata?: Metadata): Promise<JsonPipeCloseResult>;
|
||||
}
|
||||
|
@ -124,11 +124,9 @@ const channels_ts = [
|
||||
|
||||
// This file is generated by ${path.basename(__filename).split(path.sep).join(path.posix.sep)}, do not edit manually.
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export type Binary = string;
|
||||
|
||||
export interface Channel extends EventEmitter {
|
||||
export interface Channel {
|
||||
}
|
||||
`];
|
||||
|
||||
@ -202,6 +200,35 @@ for (const [name, item] of Object.entries(protocol)) {
|
||||
}
|
||||
}
|
||||
|
||||
channels_ts.push(`// ----------- Initializer Traits -----------`);
|
||||
channels_ts.push(`export type InitializerTraits<T> =`);
|
||||
const entriesInReverse = Object.entries(protocol).reverse();
|
||||
for (const [name, item] of entriesInReverse) {
|
||||
if (item.type !== 'interface')
|
||||
continue;
|
||||
channels_ts.push(` T extends ${name}Channel ? ${name}Initializer :`);
|
||||
}
|
||||
channels_ts.push(` object;`);
|
||||
channels_ts.push(``);
|
||||
channels_ts.push(`// ----------- Event Traits -----------`);
|
||||
channels_ts.push(`export type EventsTraits<T> =`);
|
||||
for (const [name, item] of entriesInReverse) {
|
||||
if (item.type !== 'interface')
|
||||
continue;
|
||||
channels_ts.push(` T extends ${name}Channel ? ${name}Events :`);
|
||||
}
|
||||
channels_ts.push(` undefined;`);
|
||||
channels_ts.push(``);
|
||||
channels_ts.push(`// ----------- EventTarget Traits -----------`);
|
||||
channels_ts.push(`export type EventTargetTraits<T> =`);
|
||||
for (const [name, item] of entriesInReverse) {
|
||||
if (item.type !== 'interface')
|
||||
continue;
|
||||
channels_ts.push(` T extends ${name}Channel ? ${name}EventTarget :`);
|
||||
}
|
||||
channels_ts.push(` undefined;`);
|
||||
channels_ts.push(``);
|
||||
|
||||
for (const [name, item] of Object.entries(protocol)) {
|
||||
if (item.type === 'interface') {
|
||||
const channelName = name;
|
||||
@ -210,7 +237,7 @@ for (const [name, item] of Object.entries(protocol)) {
|
||||
const initializerName = channelName + 'Initializer';
|
||||
channels_ts.push(`export type ${initializerName} = ${init.ts};`);
|
||||
|
||||
channels_ts.push(`export interface ${channelName}Channel extends ${(item.extends || '') + 'Channel'} {`);
|
||||
channels_ts.push(`export interface ${channelName}EventTarget {`);
|
||||
const ts_types = new Map();
|
||||
|
||||
/** @type{{eventName: string, eventType: string}[]} */
|
||||
@ -224,7 +251,10 @@ for (const [name, item] of Object.entries(protocol)) {
|
||||
channels_ts.push(` on(event: '${eventName}', callback: (params: ${paramsName}) => void): this;`);
|
||||
eventTypes.push({eventName, eventType: paramsName});
|
||||
}
|
||||
channels_ts.push(`}`);
|
||||
|
||||
channels_ts.push(`export interface ${channelName}Channel extends ${channelName}EventTarget, ${(item.extends || '') + 'Channel'} {`);
|
||||
channels_ts.push(` _type_${channelName}: boolean;`);
|
||||
for (let [methodName, method] of Object.entries(item.commands || {})) {
|
||||
if (method === null)
|
||||
method = {};
|
||||
|
Loading…
Reference in New Issue
Block a user