From 8644744dce57f4489c4b98340e94e9559657ef1f Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Thu, 16 Nov 2023 08:23:08 +0100 Subject: [PATCH] chore: use a type for protocol (#11394) --- packages/puppeteer-core/src/api/Browser.ts | 3 ++- packages/puppeteer-core/src/common/ConnectOptions.ts | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/puppeteer-core/src/api/Browser.ts b/packages/puppeteer-core/src/api/Browser.ts index d469cdc66f3..fc54766e46e 100644 --- a/packages/puppeteer-core/src/api/Browser.ts +++ b/packages/puppeteer-core/src/api/Browser.ts @@ -27,6 +27,7 @@ import { fromEvent, type Observable, } from '../../third_party/rxjs/rxjs.js'; +import type {ProtocolType} from '../common/ConnectOptions.js'; import {EventEmitter, type EventType} from '../common/EventEmitter.js'; import {debugError} from '../common/util.js'; import {timeout} from '../common/util.js'; @@ -444,5 +445,5 @@ export abstract class Browser extends EventEmitter { /** * @internal */ - abstract get protocol(): 'cdp' | 'webDriverBiDi'; + abstract get protocol(): ProtocolType; } diff --git a/packages/puppeteer-core/src/common/ConnectOptions.ts b/packages/puppeteer-core/src/common/ConnectOptions.ts index c7463c0e42b..674df2ba33a 100644 --- a/packages/puppeteer-core/src/common/ConnectOptions.ts +++ b/packages/puppeteer-core/src/common/ConnectOptions.ts @@ -22,6 +22,11 @@ import type { import type {ConnectionTransport} from './ConnectionTransport.js'; import type {Viewport} from './Viewport.js'; +/** + * @internal + */ +export type ProtocolType = 'cdp' | 'webDriverBiDi'; + /** * Generic browser options that can be passed when launching any browser or when * connecting to an existing browser instance. @@ -54,7 +59,7 @@ export interface BrowserConnectOptions { * @defaultValue 'cdp' * @internal */ - protocol?: 'cdp' | 'webDriverBiDi'; + protocol?: ProtocolType; /** * Timeout setting for individual protocol (CDP) calls. *