first commit
This commit is contained in:
12
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.d.ts
generated
vendored
Normal file
12
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Connection as CdpConnection } from '../cdp/Connection.js';
|
||||
import { BidiConnection } from './Connection.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare function connectBidiOverCdp(cdp: CdpConnection): Promise<BidiConnection>;
|
||||
//# sourceMappingURL=BidiOverCdp.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BidiOverCdp.d.ts","sourceRoot":"","sources":["../../../src/bidi/BidiOverCdp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAC,UAAU,IAAI,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAKtE,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAM/C;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,cAAc,CAAC,CAqCzB"}
|
||||
146
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.js
generated
vendored
Normal file
146
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import * as BidiMapper from 'chromium-bidi/lib/bidiMapper/BidiMapper.js';
|
||||
import { debug } from '../common/Debug.js';
|
||||
import { TargetCloseError } from '../common/Errors.js';
|
||||
import { BidiConnection } from './Connection.js';
|
||||
const bidiServerLogger = (prefix, ...args) => {
|
||||
debug(`bidi:${prefix}`)(args);
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export async function connectBidiOverCdp(cdp) {
|
||||
const transportBiDi = new NoOpTransport();
|
||||
const cdpConnectionAdapter = new CdpConnectionAdapter(cdp);
|
||||
const pptrTransport = {
|
||||
send(message) {
|
||||
// Forwards a BiDi command sent by Puppeteer to the input of the BidiServer.
|
||||
transportBiDi.emitMessage(JSON.parse(message));
|
||||
},
|
||||
close() {
|
||||
bidiServer.close();
|
||||
cdpConnectionAdapter.close();
|
||||
cdp.dispose();
|
||||
},
|
||||
onmessage(_message) {
|
||||
// The method is overridden by the Connection.
|
||||
},
|
||||
};
|
||||
transportBiDi.on('bidiResponse', (message) => {
|
||||
// Forwards a BiDi event sent by BidiServer to Puppeteer.
|
||||
pptrTransport.onmessage(JSON.stringify(message));
|
||||
});
|
||||
const pptrBiDiConnection = new BidiConnection(cdp.url(), pptrTransport, cdp._idGenerator, cdp.delay, cdp.timeout);
|
||||
const bidiServer = await BidiMapper.BidiServer.createAndStart(transportBiDi, cdpConnectionAdapter, cdpConnectionAdapter.browserClient(),
|
||||
/* selfTargetId= */ '', undefined, bidiServerLogger);
|
||||
return pptrBiDiConnection;
|
||||
}
|
||||
/**
|
||||
* Manages CDPSessions for BidiServer.
|
||||
* @internal
|
||||
*/
|
||||
class CdpConnectionAdapter {
|
||||
#cdp;
|
||||
#adapters = new Map();
|
||||
#browserCdpConnection;
|
||||
constructor(cdp) {
|
||||
this.#cdp = cdp;
|
||||
this.#browserCdpConnection = new CDPClientAdapter(cdp);
|
||||
}
|
||||
browserClient() {
|
||||
return this.#browserCdpConnection;
|
||||
}
|
||||
getCdpClient(id) {
|
||||
const session = this.#cdp.session(id);
|
||||
if (!session) {
|
||||
throw new Error(`Unknown CDP session with id ${id}`);
|
||||
}
|
||||
if (!this.#adapters.has(session)) {
|
||||
const adapter = new CDPClientAdapter(session, id, this.#browserCdpConnection);
|
||||
this.#adapters.set(session, adapter);
|
||||
return adapter;
|
||||
}
|
||||
return this.#adapters.get(session);
|
||||
}
|
||||
close() {
|
||||
this.#browserCdpConnection.close();
|
||||
for (const adapter of this.#adapters.values()) {
|
||||
adapter.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Wrapper on top of CDPSession/CDPConnection to satisfy CDP interface that
|
||||
* BidiServer needs.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class CDPClientAdapter extends BidiMapper.EventEmitter {
|
||||
#closed = false;
|
||||
#client;
|
||||
sessionId = undefined;
|
||||
#browserClient;
|
||||
constructor(client, sessionId, browserClient) {
|
||||
super();
|
||||
this.#client = client;
|
||||
this.sessionId = sessionId;
|
||||
this.#browserClient = browserClient;
|
||||
this.#client.on('*', this.#forwardMessage);
|
||||
}
|
||||
browserClient() {
|
||||
return this.#browserClient;
|
||||
}
|
||||
#forwardMessage = (method, event) => {
|
||||
this.emit(method, event);
|
||||
};
|
||||
async sendCommand(method, ...params) {
|
||||
if (this.#closed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
return await this.#client.send(method, ...params);
|
||||
}
|
||||
catch (err) {
|
||||
if (this.#closed) {
|
||||
return;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
close() {
|
||||
this.#client.off('*', this.#forwardMessage);
|
||||
this.#closed = true;
|
||||
}
|
||||
isCloseError(error) {
|
||||
return error instanceof TargetCloseError;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This transport is given to the BiDi server instance and allows Puppeteer
|
||||
* to send and receive commands to the BiDiServer.
|
||||
* @internal
|
||||
*/
|
||||
class NoOpTransport extends BidiMapper.EventEmitter {
|
||||
#onMessage = async (_m) => {
|
||||
return;
|
||||
};
|
||||
emitMessage(message) {
|
||||
void this.#onMessage(message);
|
||||
}
|
||||
setOnMessage(onMessage) {
|
||||
this.#onMessage = onMessage;
|
||||
}
|
||||
async sendMessage(message) {
|
||||
this.emit('bidiResponse', message);
|
||||
}
|
||||
close() {
|
||||
this.#onMessage = async (_m) => {
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=BidiOverCdp.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BidiOverCdp.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BidiOverCdp.js","sourceRoot":"","sources":["../../../src/bidi/BidiOverCdp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,UAAU,MAAM,4CAA4C,CAAC;AAKzE,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE/C,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAE,GAAG,IAAe,EAAQ,EAAE;IACpE,KAAK,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAkB;IAElB,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;IAC3D,MAAM,aAAa,GAAG;QACpB,IAAI,CAAC,OAAe;YAClB,4EAA4E;YAC5E,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACjD,CAAC;QACD,KAAK;YACH,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,oBAAoB,CAAC,KAAK,EAAE,CAAC;YAC7B,GAAG,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AAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,OAAO;YACT,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,eAA+B,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,YAAY,CAAC,KAAc;QACzB,OAAO,KAAK,YAAY,gBAAgB,CAAC;IAC3C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,aACJ,SAAQ,UAAU,CAAC,YAEjB;IAGF,UAAU,GAA2C,KAAK,EACxD,EAAO,EACQ,EAAE;QACjB,OAAO;IACT,CAAC,CAAC;IAEF,WAAW,CAAC,OAAY;QACtB,KAAK,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,YAAY,CAAC,SAAiD;QAC5D,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAY;QAC5B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,KAAK,EAAE,EAAO,EAAiB,EAAE;YACjD,OAAO;QACT,CAAC,CAAC;IACJ,CAAC;CACF"}
|
||||
18
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.d.ts
generated
vendored
Normal file
18
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { AdapterState, BluetoothEmulation, PreconnectedPeripheral } from '../api/BluetoothEmulation.js';
|
||||
import type { Session } from './core/Session.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiBluetoothEmulation implements BluetoothEmulation {
|
||||
#private;
|
||||
constructor(contextId: string, session: Session);
|
||||
emulateAdapter(state: AdapterState, leSupported?: boolean): Promise<void>;
|
||||
disableEmulation(): Promise<void>;
|
||||
simulatePreconnectedPeripheral(preconnectedPeripheral: PreconnectedPeripheral): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=BluetoothEmulation.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BluetoothEmulation.d.ts","sourceRoot":"","sources":["../../../src/bidi/BluetoothEmulation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,qBAAa,sBAAuB,YAAW,kBAAkB;;gBAInD,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAKzC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtE,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC,8BAA8B,CAClC,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,IAAI,CAAC;CASjB"}
|
||||
38
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.js
generated
vendored
Normal file
38
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiBluetoothEmulation {
|
||||
#session;
|
||||
#contextId;
|
||||
constructor(contextId, session) {
|
||||
this.#contextId = contextId;
|
||||
this.#session = session;
|
||||
}
|
||||
async emulateAdapter(state, leSupported = true) {
|
||||
await this.#session.send('bluetooth.simulateAdapter', {
|
||||
context: this.#contextId,
|
||||
state,
|
||||
leSupported,
|
||||
});
|
||||
}
|
||||
async disableEmulation() {
|
||||
await this.#session.send('bluetooth.disableSimulation', {
|
||||
context: this.#contextId,
|
||||
});
|
||||
}
|
||||
async simulatePreconnectedPeripheral(preconnectedPeripheral) {
|
||||
await this.#session.send('bluetooth.simulatePreconnectedPeripheral', {
|
||||
context: this.#contextId,
|
||||
address: preconnectedPeripheral.address,
|
||||
name: preconnectedPeripheral.name,
|
||||
manufacturerData: preconnectedPeripheral.manufacturerData,
|
||||
knownServiceUuids: preconnectedPeripheral.knownServiceUuids,
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=BluetoothEmulation.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BluetoothEmulation.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BluetoothEmulation.js","sourceRoot":"","sources":["../../../src/bidi/BluetoothEmulation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACxB,QAAQ,CAAU;IAClB,UAAU,CAAS;IAE5B,YAAY,SAAiB,EAAE,OAAgB;QAC7C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAAmB,EAAE,WAAW,GAAG,IAAI;QAC1D,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,2BAA2B,EAAE;YACpD,OAAO,EAAE,IAAI,CAAC,UAAU;YACxB,KAAK;YACL,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,6BAA6B,EAAE;YACtD,OAAO,EAAE,IAAI,CAAC,UAAU;SACzB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,8BAA8B,CAClC,sBAA8C;QAE9C,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,0CAA0C,EAAE;YACnE,OAAO,EAAE,IAAI,CAAC,UAAU;YACxB,OAAO,EAAE,sBAAsB,CAAC,OAAO;YACvC,IAAI,EAAE,sBAAsB,CAAC,IAAI;YACjC,gBAAgB,EAAE,sBAAsB,CAAC,gBAAgB;YACzD,iBAAiB,EAAE,sBAAsB,CAAC,iBAAiB;SAC5D,CAAC,CAAC;IACL,CAAC;CACF"}
|
||||
70
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.d.ts
generated
vendored
Normal file
70
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { ChildProcess } from 'node:child_process';
|
||||
import type { CreatePageOptions } from '../api/Browser.js';
|
||||
import { Browser, type BrowserCloseCallback, type BrowserContextOptions, type ScreenInfo, type AddScreenParams, type WindowBounds, type WindowId, type DebugInfo } from '../api/Browser.js';
|
||||
import type { Extension } from '../api/Extension.js';
|
||||
import type { Page } from '../api/Page.js';
|
||||
import type { Target } from '../api/Target.js';
|
||||
import type { Connection as CdpConnection } from '../cdp/Connection.js';
|
||||
import type { SupportedWebDriverCapabilities } from '../common/ConnectOptions.js';
|
||||
import type { Viewport } from '../common/Viewport.js';
|
||||
import { BidiBrowserContext } from './BrowserContext.js';
|
||||
import type { BidiConnection, CdpEvent } from './Connection.js';
|
||||
import { BidiBrowserTarget } from './Target.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface BidiBrowserOptions {
|
||||
process?: ChildProcess;
|
||||
closeCallback?: BrowserCloseCallback;
|
||||
connection: BidiConnection;
|
||||
cdpConnection?: CdpConnection;
|
||||
defaultViewport: Viewport | null;
|
||||
acceptInsecureCerts?: boolean;
|
||||
capabilities?: SupportedWebDriverCapabilities;
|
||||
networkEnabled: boolean;
|
||||
issuesEnabled: boolean;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiBrowser extends Browser {
|
||||
#private;
|
||||
readonly protocol = "webDriverBiDi";
|
||||
static readonly subscribeModules: [string, ...string[]];
|
||||
static readonly subscribeCdpEvents: Array<CdpEvent['method']>;
|
||||
static create(opts: BidiBrowserOptions): Promise<BidiBrowser>;
|
||||
private constructor();
|
||||
get cdpSupported(): boolean;
|
||||
get cdpConnection(): CdpConnection | undefined;
|
||||
userAgent(): Promise<string>;
|
||||
get connection(): BidiConnection;
|
||||
wsEndpoint(): string;
|
||||
close(): Promise<void>;
|
||||
get connected(): boolean;
|
||||
process(): ChildProcess | null;
|
||||
createBrowserContext(options?: BrowserContextOptions): Promise<BidiBrowserContext>;
|
||||
version(): Promise<string>;
|
||||
browserContexts(): BidiBrowserContext[];
|
||||
defaultBrowserContext(): BidiBrowserContext;
|
||||
newPage(options?: CreatePageOptions): Promise<Page>;
|
||||
installExtension(path: string): Promise<string>;
|
||||
uninstallExtension(id: string): Promise<void>;
|
||||
screens(): Promise<ScreenInfo[]>;
|
||||
addScreen(_params: AddScreenParams): Promise<ScreenInfo>;
|
||||
removeScreen(_screenId: string): Promise<void>;
|
||||
getWindowBounds(windowId: WindowId): Promise<WindowBounds>;
|
||||
setWindowBounds(windowId: WindowId, windowBounds: WindowBounds): Promise<void>;
|
||||
targets(): Target[];
|
||||
target(): BidiBrowserTarget;
|
||||
disconnect(): Promise<void>;
|
||||
get debugInfo(): DebugInfo;
|
||||
isNetworkEnabled(): boolean;
|
||||
extensions(): Promise<Map<string, Extension>>;
|
||||
isIssuesEnabled(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=Browser.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Browser.d.ts","sourceRoot":"","sources":["../../../src/bidi/Browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAgB,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACxE,OAAO,EACL,OAAO,EAEP,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAC,UAAU,IAAI,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,6BAA6B,CAAC;AAIhF,OAAO,KAAK,EAAC,QAAQ,EAAC,MAA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AIxB,oBAAoB,CACjC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,kBAAkB,CAAC;IAKf,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,eAAe,IAAI,kBAAkB,EAAE;IAMvC,qBAAqB,IAAI,kBAAkB;IAI3C,OAAO,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzC,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAIhC,SAAS,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAIxD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAY1D,eAAe,CAC5B,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;IAsBP,OAAO,IAAI,MAAM,EAAE;IASnB,MAAM,IAAI,iBAAiB;IAIrB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAW1C,IAAa,SAAS,IAAI,SAAS,CAIlC;IAEQ,gBAAgB,IAAI,OAAO;IAI3B,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAI7C,eAAe,IAAI,OAAO;CAGpC"}
|
||||
342
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.js
generated
vendored
Normal file
342
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.js
generated
vendored
Normal file
@@ -0,0 +1,342 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
||||
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
||||
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
||||
};
|
||||
import { Browser, } from '../api/Browser.js';
|
||||
import { ProtocolError, UnsupportedOperation } from '../common/Errors.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { debugError } from '../common/util.js';
|
||||
import { bubble } from '../util/decorators.js';
|
||||
import { BidiBrowserContext } from './BrowserContext.js';
|
||||
import { Session } from './core/Session.js';
|
||||
import { BidiBrowserTarget } from './Target.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
let BidiBrowser = (() => {
|
||||
let _classSuper = Browser;
|
||||
let _private_trustedEmitter_decorators;
|
||||
let _private_trustedEmitter_initializers = [];
|
||||
let _private_trustedEmitter_extraInitializers = [];
|
||||
let _private_trustedEmitter_descriptor;
|
||||
return class BidiBrowser extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_private_trustedEmitter_decorators = [bubble()];
|
||||
__esDecorate(this, _private_trustedEmitter_descriptor = { get: __setFunctionName(function () { return this.#trustedEmitter_accessor_storage; }, "#trustedEmitter", "get"), set: __setFunctionName(function (value) { this.#trustedEmitter_accessor_storage = value; }, "#trustedEmitter", "set") }, _private_trustedEmitter_decorators, { kind: "accessor", name: "#trustedEmitter", static: false, private: true, access: { has: obj => #trustedEmitter in obj, get: obj => obj.#trustedEmitter, set: (obj, value) => { obj.#trustedEmitter = value; } }, metadata: _metadata }, _private_trustedEmitter_initializers, _private_trustedEmitter_extraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
protocol = 'webDriverBiDi';
|
||||
static subscribeModules = [
|
||||
'browsingContext',
|
||||
'network',
|
||||
'log',
|
||||
'script',
|
||||
'input',
|
||||
];
|
||||
static subscribeCdpEvents = [
|
||||
// Coverage
|
||||
'goog:cdp.Debugger.scriptParsed',
|
||||
'goog:cdp.CSS.styleSheetAdded',
|
||||
'goog:cdp.Runtime.executionContextsCleared',
|
||||
// Tracing
|
||||
'goog:cdp.Tracing.tracingComplete',
|
||||
// TODO: subscribe to all CDP events in the future.
|
||||
'goog:cdp.Network.requestWillBeSent',
|
||||
'goog:cdp.Debugger.scriptParsed',
|
||||
'goog:cdp.Page.screencastFrame',
|
||||
];
|
||||
static async create(opts) {
|
||||
const session = await Session.from(opts.connection, {
|
||||
firstMatch: opts.capabilities?.firstMatch,
|
||||
alwaysMatch: {
|
||||
...opts.capabilities?.alwaysMatch,
|
||||
// Capabilities that come from Puppeteer's API take precedence.
|
||||
acceptInsecureCerts: opts.acceptInsecureCerts,
|
||||
unhandledPromptBehavior: {
|
||||
default: "ignore" /* Bidi.Session.UserPromptHandlerType.Ignore */,
|
||||
},
|
||||
webSocketUrl: true,
|
||||
// Puppeteer with WebDriver BiDi does not support prerendering
|
||||
// yet because WebDriver BiDi behavior is not specified. See
|
||||
// https://github.com/w3c/webdriver-bidi/issues/321.
|
||||
'goog:prerenderingDisabled': true,
|
||||
// TODO: remove after Puppeteer rolled Chrome to 142 after Oct 28, 2025.
|
||||
'goog:disableNetworkDurableMessages': true,
|
||||
},
|
||||
});
|
||||
// Subscribe to all WebDriver BiDi events. Also subscribe to CDP events if CDP
|
||||
// connection is available.
|
||||
await session.subscribe((opts.cdpConnection
|
||||
? [...BidiBrowser.subscribeModules, ...BidiBrowser.subscribeCdpEvents]
|
||||
: BidiBrowser.subscribeModules).filter(module => {
|
||||
if (!opts.networkEnabled) {
|
||||
return (module !== 'network' &&
|
||||
module !== 'goog:cdp.Network.requestWillBeSent');
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
await Promise.all(["request" /* Bidi.Network.DataType.Request */, "response" /* Bidi.Network.DataType.Response */].map(
|
||||
// Data collectors might be not implemented for specific data type, so create them
|
||||
// separately and ignore protocol errors.
|
||||
async (dataType) => {
|
||||
try {
|
||||
await session.send('network.addDataCollector', {
|
||||
dataTypes: [dataType],
|
||||
// Buffer size of 20 MB is equivalent to the CDP:
|
||||
maxEncodedDataSize: 20_000_000,
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof ProtocolError) {
|
||||
debugError(err);
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}));
|
||||
const browser = new BidiBrowser(session.browser, opts);
|
||||
browser.#initialize();
|
||||
return browser;
|
||||
}
|
||||
#trustedEmitter_accessor_storage = __runInitializers(this, _private_trustedEmitter_initializers, new EventEmitter());
|
||||
get #trustedEmitter() { return _private_trustedEmitter_descriptor.get.call(this); }
|
||||
set #trustedEmitter(value) { return _private_trustedEmitter_descriptor.set.call(this, value); }
|
||||
#process = __runInitializers(this, _private_trustedEmitter_extraInitializers);
|
||||
#closeCallback;
|
||||
#browserCore;
|
||||
#defaultViewport;
|
||||
#browserContexts = new WeakMap();
|
||||
#target = new BidiBrowserTarget(this);
|
||||
#cdpConnection;
|
||||
#networkEnabled;
|
||||
#issuesEnabled;
|
||||
constructor(browserCore, opts) {
|
||||
super();
|
||||
this.#process = opts.process;
|
||||
this.#closeCallback = opts.closeCallback;
|
||||
this.#browserCore = browserCore;
|
||||
this.#defaultViewport = opts.defaultViewport;
|
||||
this.#cdpConnection = opts.cdpConnection;
|
||||
this.#networkEnabled = opts.networkEnabled;
|
||||
this.#issuesEnabled = opts.issuesEnabled;
|
||||
}
|
||||
#initialize() {
|
||||
// Initializing existing contexts.
|
||||
for (const userContext of this.#browserCore.userContexts) {
|
||||
this.#createBrowserContext(userContext);
|
||||
}
|
||||
this.#browserCore.once('disconnected', () => {
|
||||
this.#trustedEmitter.emit("disconnected" /* BrowserEvent.Disconnected */, undefined);
|
||||
this.#trustedEmitter.removeAllListeners();
|
||||
});
|
||||
this.#process?.once('close', () => {
|
||||
this.#browserCore.dispose('Browser process exited.', true);
|
||||
this.connection.dispose();
|
||||
});
|
||||
}
|
||||
get #browserName() {
|
||||
return this.#browserCore.session.capabilities.browserName;
|
||||
}
|
||||
get #browserVersion() {
|
||||
return this.#browserCore.session.capabilities.browserVersion;
|
||||
}
|
||||
get cdpSupported() {
|
||||
return this.#cdpConnection !== undefined;
|
||||
}
|
||||
get cdpConnection() {
|
||||
return this.#cdpConnection;
|
||||
}
|
||||
async userAgent() {
|
||||
return this.#browserCore.session.capabilities.userAgent;
|
||||
}
|
||||
#createBrowserContext(userContext) {
|
||||
const browserContext = BidiBrowserContext.from(this, userContext, {
|
||||
defaultViewport: this.#defaultViewport,
|
||||
});
|
||||
this.#browserContexts.set(userContext, browserContext);
|
||||
browserContext.trustedEmitter.on("targetcreated" /* BrowserContextEvent.TargetCreated */, target => {
|
||||
this.#trustedEmitter.emit("targetcreated" /* BrowserEvent.TargetCreated */, target);
|
||||
});
|
||||
browserContext.trustedEmitter.on("targetchanged" /* BrowserContextEvent.TargetChanged */, target => {
|
||||
this.#trustedEmitter.emit("targetchanged" /* BrowserEvent.TargetChanged */, target);
|
||||
});
|
||||
browserContext.trustedEmitter.on("targetdestroyed" /* BrowserContextEvent.TargetDestroyed */, target => {
|
||||
this.#trustedEmitter.emit("targetdestroyed" /* BrowserEvent.TargetDestroyed */, target);
|
||||
});
|
||||
return browserContext;
|
||||
}
|
||||
get connection() {
|
||||
// SAFETY: We only have one implementation.
|
||||
return this.#browserCore.session.connection;
|
||||
}
|
||||
wsEndpoint() {
|
||||
return this.connection.url;
|
||||
}
|
||||
async close() {
|
||||
if (this.connection.closed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.#browserCore.close();
|
||||
await this.#closeCallback?.call(null);
|
||||
}
|
||||
catch (error) {
|
||||
// Fail silently.
|
||||
debugError(error);
|
||||
}
|
||||
finally {
|
||||
this.connection.dispose();
|
||||
}
|
||||
}
|
||||
get connected() {
|
||||
return !this.#browserCore.disconnected;
|
||||
}
|
||||
process() {
|
||||
return this.#process ?? null;
|
||||
}
|
||||
async createBrowserContext(options = {}) {
|
||||
const userContext = await this.#browserCore.createUserContext(options);
|
||||
return this.#createBrowserContext(userContext);
|
||||
}
|
||||
async version() {
|
||||
return `${this.#browserName}/${this.#browserVersion}`;
|
||||
}
|
||||
browserContexts() {
|
||||
return [...this.#browserCore.userContexts].map(context => {
|
||||
return this.#browserContexts.get(context);
|
||||
});
|
||||
}
|
||||
defaultBrowserContext() {
|
||||
return this.#browserContexts.get(this.#browserCore.defaultUserContext);
|
||||
}
|
||||
newPage(options) {
|
||||
return this.defaultBrowserContext().newPage(options);
|
||||
}
|
||||
installExtension(path) {
|
||||
return this.#browserCore.installExtension(path);
|
||||
}
|
||||
async uninstallExtension(id) {
|
||||
await this.#browserCore.uninstallExtension(id);
|
||||
}
|
||||
screens() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
addScreen(_params) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
removeScreen(_screenId) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async getWindowBounds(windowId) {
|
||||
const clientWindowInfo = await this.#browserCore.getClientWindowInfo(windowId);
|
||||
return {
|
||||
left: clientWindowInfo.x,
|
||||
top: clientWindowInfo.y,
|
||||
width: clientWindowInfo.width,
|
||||
height: clientWindowInfo.height,
|
||||
windowState: clientWindowInfo.state,
|
||||
};
|
||||
}
|
||||
async setWindowBounds(windowId, windowBounds) {
|
||||
let params;
|
||||
const windowState = windowBounds.windowState ?? 'normal';
|
||||
if (windowState === 'normal') {
|
||||
params = {
|
||||
clientWindow: windowId,
|
||||
state: 'normal',
|
||||
x: windowBounds.left,
|
||||
y: windowBounds.top,
|
||||
width: windowBounds.width,
|
||||
height: windowBounds.height,
|
||||
};
|
||||
}
|
||||
else {
|
||||
params = {
|
||||
clientWindow: windowId,
|
||||
state: windowState,
|
||||
};
|
||||
}
|
||||
await this.#browserCore.setClientWindowState(params);
|
||||
}
|
||||
targets() {
|
||||
return [
|
||||
this.#target,
|
||||
...this.browserContexts().flatMap(context => {
|
||||
return context.targets();
|
||||
}),
|
||||
];
|
||||
}
|
||||
target() {
|
||||
return this.#target;
|
||||
}
|
||||
async disconnect() {
|
||||
try {
|
||||
await this.#browserCore.session.end();
|
||||
}
|
||||
catch (error) {
|
||||
// Fail silently.
|
||||
debugError(error);
|
||||
}
|
||||
finally {
|
||||
this.connection.dispose();
|
||||
}
|
||||
}
|
||||
get debugInfo() {
|
||||
return {
|
||||
pendingProtocolErrors: this.connection.getPendingProtocolErrors(),
|
||||
};
|
||||
}
|
||||
isNetworkEnabled() {
|
||||
return this.#networkEnabled;
|
||||
}
|
||||
extensions() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
isIssuesEnabled() {
|
||||
return this.#issuesEnabled;
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiBrowser };
|
||||
//# sourceMappingURL=Browser.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Browser.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.d.ts
generated
vendored
Normal file
18
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { ConnectionTransport } from '../common/ConnectionTransport.js';
|
||||
import type { ConnectOptions } from '../common/ConnectOptions.js';
|
||||
import type { BidiBrowser } from './Browser.js';
|
||||
/**
|
||||
* Users should never call this directly; it's called when calling `puppeteer.connect`
|
||||
* with `protocol: 'webDriverBiDi'`. This method attaches Puppeteer to an existing browser
|
||||
* instance. First it tries to connect to the browser using pure BiDi. If the protocol is
|
||||
* not supported, connects to the browser using BiDi over CDP.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare function _connectToBiDiBrowser(connectionTransport: ConnectionTransport, url: string, options: ConnectOptions): Promise<BidiBrowser>;
|
||||
//# sourceMappingURL=BrowserConnector.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserConnector.d.ts","sourceRoot":"","sources":["../../../src/bidi/BrowserConnector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAKhE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAG9C;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,mBAAmB,EAAE,mBAAmB,EACxC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,WAAW,CAAC,CAuBtB"}
|
||||
84
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.js
generated
vendored
Normal file
84
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { Connection } from '../cdp/Connection.js';
|
||||
import { ProtocolError, UnsupportedOperation } from '../common/Errors.js';
|
||||
import { debugError, DEFAULT_VIEWPORT } from '../common/util.js';
|
||||
import { createIncrementalIdGenerator } from '../util/incremental-id-generator.js';
|
||||
/**
|
||||
* Users should never call this directly; it's called when calling `puppeteer.connect`
|
||||
* with `protocol: 'webDriverBiDi'`. This method attaches Puppeteer to an existing browser
|
||||
* instance. First it tries to connect to the browser using pure BiDi. If the protocol is
|
||||
* not supported, connects to the browser using BiDi over CDP.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export async function _connectToBiDiBrowser(connectionTransport, url, options) {
|
||||
const { acceptInsecureCerts = false, networkEnabled = true, issuesEnabled = true, defaultViewport = DEFAULT_VIEWPORT, } = options;
|
||||
const { bidiConnection, cdpConnection, closeCallback } = await getBiDiConnection(connectionTransport, url, options);
|
||||
const BiDi = await import(/* webpackIgnore: true */ './bidi.js');
|
||||
const bidiBrowser = await BiDi.BidiBrowser.create({
|
||||
connection: bidiConnection,
|
||||
cdpConnection,
|
||||
closeCallback,
|
||||
process: undefined,
|
||||
defaultViewport: defaultViewport,
|
||||
acceptInsecureCerts: acceptInsecureCerts,
|
||||
networkEnabled,
|
||||
issuesEnabled,
|
||||
capabilities: options.capabilities,
|
||||
});
|
||||
return bidiBrowser;
|
||||
}
|
||||
/**
|
||||
* Returns a BiDiConnection established to the endpoint specified by the options and a
|
||||
* callback closing the browser. Callback depends on whether the connection is pure BiDi
|
||||
* or BiDi over CDP.
|
||||
* The method tries to connect to the browser using pure BiDi protocol, and falls back
|
||||
* to BiDi over CDP.
|
||||
*/
|
||||
async function getBiDiConnection(connectionTransport, url, options) {
|
||||
const BiDi = await import(/* webpackIgnore: true */ './bidi.js');
|
||||
const { slowMo = 0, protocolTimeout, idGenerator = createIncrementalIdGenerator(), } = options;
|
||||
// Try pure BiDi first.
|
||||
const pureBidiConnection = new BiDi.BidiConnection(url, connectionTransport, idGenerator, slowMo, protocolTimeout);
|
||||
try {
|
||||
const result = await pureBidiConnection.send('session.status', {});
|
||||
if ('type' in result && result.type === 'success') {
|
||||
// The `browserWSEndpoint` points to an endpoint supporting pure WebDriver BiDi.
|
||||
return {
|
||||
bidiConnection: pureBidiConnection,
|
||||
closeCallback: async () => {
|
||||
await pureBidiConnection.send('browser.close', {}).catch(debugError);
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
if (!(e instanceof ProtocolError)) {
|
||||
// Unexpected exception not related to BiDi / CDP. Rethrow.
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// Unbind the connection to avoid memory leaks.
|
||||
pureBidiConnection.unbind();
|
||||
// Fall back to CDP over BiDi reusing the WS connection.
|
||||
const cdpConnection = new Connection(url, connectionTransport, slowMo, protocolTimeout,
|
||||
/* rawErrors= */ true, idGenerator);
|
||||
const version = await cdpConnection.send('Browser.getVersion');
|
||||
if (version.product.toLowerCase().includes('firefox')) {
|
||||
throw new UnsupportedOperation('Firefox is not supported in BiDi over CDP mode.');
|
||||
}
|
||||
const bidiOverCdpConnection = await BiDi.connectBidiOverCdp(cdpConnection);
|
||||
return {
|
||||
cdpConnection,
|
||||
bidiConnection: bidiOverCdpConnection,
|
||||
closeCallback: async () => {
|
||||
// In case of BiDi over CDP, we need to close browser via CDP.
|
||||
await cdpConnection.send('Browser.close').catch(debugError);
|
||||
},
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=BrowserConnector.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserConnector.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserConnector.js","sourceRoot":"","sources":["../../../src/bidi/BrowserConnector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,aAAa,EAAE,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAC,4BAA4B,EAAC,MAAM,qCAAqC,CAAC;AAKjF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,mBAAwC,EACxC,GAAW,EACX,OAAuB;IAEvB,MAAM,EACJ,mBAAmB,GAAG,KAAK,EAC3B,cAAc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aAAa,EAAE,KAAK,IAAI,EAAE;oBACxB,MAAM,kBAAkB,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBACvE,CAAC;aACF,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,CAAC,CAAC,YAAY,aAAa,CAAC,EAAE,CAAC;YAClC,2DAA2D;YAC3D,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,+CAA+C;IAC/C,kBAAkB,CAAC,MAAM,EAAE,CAAC;IAE5B,wDAAwD;IACxD,MAAM,aAAa,GAAG,IAAI,UAAU,CAClC,GAAG,EACH,mBAAmB,EACnB,MAAM,EACN,eAAe;IACf,gBAAgB,CAAC,IAAI,EACrB,WAAW,CACZ,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAC/D,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,oBAAoB,CAC5B,iDAAiD,CAClD,CAAC;IACJ,CAAC;IAED,MAAM,qBAAqB,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC3E,OAAO;QACL,aAAa;QACb,cAAc,EAAE,qBAAqB;QACrC,aAAa,EAAE,KAAK,IAAI,EAAE;YACxB,8DAA8D;YAC9D,MAAM,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
||||
52
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.d.ts
generated
vendored
Normal file
52
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { CreatePageOptions, Permission, PermissionDescriptor, PermissionState } from '../api/Browser.js';
|
||||
import type { BrowserContextEvents } from '../api/BrowserContext.js';
|
||||
import { BrowserContext } from '../api/BrowserContext.js';
|
||||
import { type Page } from '../api/Page.js';
|
||||
import type { Target } from '../api/Target.js';
|
||||
import type { Cookie, CookieData } from '../common/Cookie.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import type { Viewport } from '../common/Viewport.js';
|
||||
import type { BidiBrowser } from './Browser.js';
|
||||
import { UserContext } from './core/UserContext.js';
|
||||
import { BidiPage } from './Page.js';
|
||||
import { BidiPageTarget } from './Target.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface BidiBrowserContextOptions {
|
||||
defaultViewport: Viewport | null;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiBrowserContext extends BrowserContext {
|
||||
#private;
|
||||
static from(browser: BidiBrowser, userContext: UserContext, options: BidiBrowserContextOptions): BidiBrowserContext;
|
||||
accessor trustedEmitter: EventEmitter<BrowserContextEvents>;
|
||||
readonly userContext: UserContext;
|
||||
private constructor();
|
||||
targets(): Target[];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
getTargetForPage(page: BidiPage): BidiPageTarget | undefined;
|
||||
newPage(options?: CreatePageOptions): Promise<Page>;
|
||||
close(): Promise<void>;
|
||||
browser(): BidiBrowser;
|
||||
pages(_includeAll?: boolean): Promise<BidiPage[]>;
|
||||
overridePermissions(origin: string, permissions: Permission[]): Promise<void>;
|
||||
setPermission(origin: string | '*', ...permissions: Array<{
|
||||
permission: PermissionDescriptor;
|
||||
state: PermissionState;
|
||||
}>): Promise<void>;
|
||||
clearPermissionOverrides(): Promise<void>;
|
||||
get id(): string | undefined;
|
||||
cookies(): Promise<Cookie[]>;
|
||||
setCookie(...cookies: CookieData[]): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=BrowserContext.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserContext.d.ts","sourceRoot":"","sources":["../../../src/bidi/BrowserContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAC,cAAc,EAAsB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAY,KAAK,IAAI,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAIpD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAElD,OAAO,EACL,QAAQ,EAMT,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAkB,cAAc,EAAC,MAAM,aAAa,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,QAAQ,GAAG,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;;IACpD,MAAM,CAAC,IAAI,CACT,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,yBAAyB,GACjC,kBAAkB;IAOrB,QAAQ,CAAC,cAAc,qCAA4C;IAKnE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAYlC,OAAO;IAqGE,OAAO,IAAI,MAAM,EAAE;IAM5B;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,GAAG,SAAS;IAI7C,OAAO,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B,OAAO,IAAI,WAAW;IAIhB,KAAK,CAAC,WAAW,UAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAM/C,mBAAmB,CAChC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,UAAU,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC;IAmCD,aAAa,CAC1B,MAAM,EAAE,MAAM,GAAG,GAAG,EACpB,GAAG,WAAW,EAAE,KAAK,CAAC;QACpB,UAAU,EAAE,oBAAoB,CAAC;QACjC,KAAK,EAAE,eAAe,CAAC;KACxB,CAAC,GACD,OAAO,CAAC,IAAI,CAAC;IAkCD,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBxD,IAAa,EAAE,IAAI,MAAM,GAAG,SAAS,CAKpC;IAEc,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAO5B,SAAS,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAgClE"}
|
||||
382
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.js
generated
vendored
Normal file
382
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.js
generated
vendored
Normal file
@@ -0,0 +1,382 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose, inner;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
if (async) inner = dispose;
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
};
|
||||
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
||||
return function (env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
var r, s = 0;
|
||||
function next() {
|
||||
while (r = env.stack.pop()) {
|
||||
try {
|
||||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
||||
if (r.dispose) {
|
||||
var result = r.dispose.call(r.value);
|
||||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
else s |= 1;
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
};
|
||||
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
});
|
||||
import { WEB_PERMISSION_TO_PROTOCOL_PERMISSION } from '../api/Browser.js';
|
||||
import { BrowserContext } from '../api/BrowserContext.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { debugError } from '../common/util.js';
|
||||
import { assert } from '../util/assert.js';
|
||||
import { bubble } from '../util/decorators.js';
|
||||
import { UserContext } from './core/UserContext.js';
|
||||
import { BidiPage, bidiToPuppeteerCookie, cdpSpecificCookiePropertiesFromPuppeteerToBidi, convertCookiesExpiryCdpToBiDi, convertCookiesPartitionKeyFromPuppeteerToBiDi, convertCookiesSameSiteCdpToBiDi, } from './Page.js';
|
||||
import { BidiWorkerTarget } from './Target.js';
|
||||
import { BidiFrameTarget, BidiPageTarget } from './Target.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
let BidiBrowserContext = (() => {
|
||||
let _classSuper = BrowserContext;
|
||||
let _trustedEmitter_decorators;
|
||||
let _trustedEmitter_initializers = [];
|
||||
let _trustedEmitter_extraInitializers = [];
|
||||
return class BidiBrowserContext extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_trustedEmitter_decorators = [bubble()];
|
||||
__esDecorate(this, null, _trustedEmitter_decorators, { kind: "accessor", name: "trustedEmitter", static: false, private: false, access: { has: obj => "trustedEmitter" in obj, get: obj => obj.trustedEmitter, set: (obj, value) => { obj.trustedEmitter = value; } }, metadata: _metadata }, _trustedEmitter_initializers, _trustedEmitter_extraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
static from(browser, userContext, options) {
|
||||
const context = new BidiBrowserContext(browser, userContext, options);
|
||||
context.#initialize();
|
||||
return context;
|
||||
}
|
||||
#trustedEmitter_accessor_storage = __runInitializers(this, _trustedEmitter_initializers, new EventEmitter());
|
||||
get trustedEmitter() { return this.#trustedEmitter_accessor_storage; }
|
||||
set trustedEmitter(value) { this.#trustedEmitter_accessor_storage = value; }
|
||||
#browser = __runInitializers(this, _trustedEmitter_extraInitializers);
|
||||
#defaultViewport;
|
||||
// This is public because of cookies.
|
||||
userContext;
|
||||
#pages = new WeakMap();
|
||||
#targets = new Map();
|
||||
#overrides = [];
|
||||
constructor(browser, userContext, options) {
|
||||
super();
|
||||
this.#browser = browser;
|
||||
this.userContext = userContext;
|
||||
this.#defaultViewport = options.defaultViewport;
|
||||
}
|
||||
#initialize() {
|
||||
// Create targets for existing browsing contexts.
|
||||
for (const browsingContext of this.userContext.browsingContexts) {
|
||||
this.#createPage(browsingContext);
|
||||
}
|
||||
this.userContext.on('browsingcontext', browsingContext => {
|
||||
const page = this.#createPage(browsingContext);
|
||||
// We need to wait for the DOMContentLoaded as the
|
||||
// browsingContext still may be navigating from the about:blank
|
||||
if (browsingContext.originalOpener) {
|
||||
for (const context of this.userContext.browsingContexts) {
|
||||
if (context.id === browsingContext.originalOpener) {
|
||||
this.#pages
|
||||
.get(context)
|
||||
.trustedEmitter.emit("popup" /* PageEvent.Popup */, page);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.userContext.on('closed', () => {
|
||||
this.trustedEmitter.removeAllListeners();
|
||||
});
|
||||
}
|
||||
#createPage(browsingContext) {
|
||||
const page = BidiPage.from(this, browsingContext);
|
||||
this.#pages.set(browsingContext, page);
|
||||
page.trustedEmitter.on("close" /* PageEvent.Close */, () => {
|
||||
this.#pages.delete(browsingContext);
|
||||
});
|
||||
// -- Target stuff starts here --
|
||||
const pageTarget = new BidiPageTarget(page);
|
||||
const pageTargets = new Map();
|
||||
this.#targets.set(page, [pageTarget, pageTargets]);
|
||||
page.trustedEmitter.on("frameattached" /* PageEvent.FrameAttached */, frame => {
|
||||
const bidiFrame = frame;
|
||||
const target = new BidiFrameTarget(bidiFrame);
|
||||
pageTargets.set(bidiFrame, target);
|
||||
this.trustedEmitter.emit("targetcreated" /* BrowserContextEvent.TargetCreated */, target);
|
||||
});
|
||||
page.trustedEmitter.on("framenavigated" /* PageEvent.FrameNavigated */, frame => {
|
||||
const bidiFrame = frame;
|
||||
const target = pageTargets.get(bidiFrame);
|
||||
// If there is no target, then this is the page's frame.
|
||||
if (target === undefined) {
|
||||
this.trustedEmitter.emit("targetchanged" /* BrowserContextEvent.TargetChanged */, pageTarget);
|
||||
}
|
||||
else {
|
||||
this.trustedEmitter.emit("targetchanged" /* BrowserContextEvent.TargetChanged */, target);
|
||||
}
|
||||
});
|
||||
page.trustedEmitter.on("framedetached" /* PageEvent.FrameDetached */, frame => {
|
||||
const bidiFrame = frame;
|
||||
const target = pageTargets.get(bidiFrame);
|
||||
if (target === undefined) {
|
||||
return;
|
||||
}
|
||||
pageTargets.delete(bidiFrame);
|
||||
this.trustedEmitter.emit("targetdestroyed" /* BrowserContextEvent.TargetDestroyed */, target);
|
||||
});
|
||||
page.trustedEmitter.on("workercreated" /* PageEvent.WorkerCreated */, worker => {
|
||||
const bidiWorker = worker;
|
||||
const target = new BidiWorkerTarget(bidiWorker);
|
||||
pageTargets.set(bidiWorker, target);
|
||||
this.trustedEmitter.emit("targetcreated" /* BrowserContextEvent.TargetCreated */, target);
|
||||
});
|
||||
page.trustedEmitter.on("workerdestroyed" /* PageEvent.WorkerDestroyed */, worker => {
|
||||
const bidiWorker = worker;
|
||||
const target = pageTargets.get(bidiWorker);
|
||||
if (target === undefined) {
|
||||
return;
|
||||
}
|
||||
pageTargets.delete(worker);
|
||||
this.trustedEmitter.emit("targetdestroyed" /* BrowserContextEvent.TargetDestroyed */, target);
|
||||
});
|
||||
page.trustedEmitter.on("close" /* PageEvent.Close */, () => {
|
||||
this.#targets.delete(page);
|
||||
this.trustedEmitter.emit("targetdestroyed" /* BrowserContextEvent.TargetDestroyed */, pageTarget);
|
||||
});
|
||||
this.trustedEmitter.emit("targetcreated" /* BrowserContextEvent.TargetCreated */, pageTarget);
|
||||
// -- Target stuff ends here --
|
||||
return page;
|
||||
}
|
||||
targets() {
|
||||
return [...this.#targets.values()].flatMap(([target, frames]) => {
|
||||
return [target, ...frames.values()];
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
getTargetForPage(page) {
|
||||
return this.#targets.get(page)?.[0];
|
||||
}
|
||||
async newPage(options) {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const _guard = __addDisposableResource(env_1, await this.waitForScreenshotOperations(), false);
|
||||
const type = options?.type === 'window'
|
||||
? "window" /* Bidi.BrowsingContext.CreateType.Window */
|
||||
: "tab" /* Bidi.BrowsingContext.CreateType.Tab */;
|
||||
const context = await this.userContext.createBrowsingContext(type, {
|
||||
background: options?.background,
|
||||
});
|
||||
const page = this.#pages.get(context);
|
||||
if (!page) {
|
||||
throw new Error('Page is not found');
|
||||
}
|
||||
if (this.#defaultViewport) {
|
||||
try {
|
||||
await page.setViewport(this.#defaultViewport);
|
||||
}
|
||||
catch (error) {
|
||||
// Tolerate not supporting `browsingContext.setViewport`. Only log it.
|
||||
debugError(error);
|
||||
}
|
||||
}
|
||||
if (options?.type === 'window' && options?.windowBounds !== undefined) {
|
||||
try {
|
||||
await this.browser().setWindowBounds(context.windowId, options.windowBounds);
|
||||
}
|
||||
catch (error) {
|
||||
// Tolerate not supporting `browser.setClientWindowState`. Only log it.
|
||||
debugError(error);
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
catch (e_1) {
|
||||
env_1.error = e_1;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
async close() {
|
||||
assert(this.userContext.id !== UserContext.DEFAULT, 'Default BrowserContext cannot be closed!');
|
||||
try {
|
||||
await this.userContext.remove();
|
||||
}
|
||||
catch (error) {
|
||||
debugError(error);
|
||||
}
|
||||
this.#targets.clear();
|
||||
}
|
||||
browser() {
|
||||
return this.#browser;
|
||||
}
|
||||
async pages(_includeAll = false) {
|
||||
return [...this.userContext.browsingContexts].map(context => {
|
||||
return this.#pages.get(context);
|
||||
});
|
||||
}
|
||||
async overridePermissions(origin, permissions) {
|
||||
const permissionsSet = new Set(permissions.map(permission => {
|
||||
const protocolPermission = WEB_PERMISSION_TO_PROTOCOL_PERMISSION.get(permission);
|
||||
if (!protocolPermission) {
|
||||
throw new Error('Unknown permission: ' + permission);
|
||||
}
|
||||
return permission;
|
||||
}));
|
||||
await Promise.all(Array.from(WEB_PERMISSION_TO_PROTOCOL_PERMISSION.keys()).map(permission => {
|
||||
const result = this.userContext.setPermissions(origin, {
|
||||
name: permission,
|
||||
}, permissionsSet.has(permission)
|
||||
? "granted" /* Bidi.Permissions.PermissionState.Granted */
|
||||
: "denied" /* Bidi.Permissions.PermissionState.Denied */);
|
||||
this.#overrides.push({ origin, permission });
|
||||
// TODO: some permissions are outdated and setting them to denied does
|
||||
// not work.
|
||||
if (!permissionsSet.has(permission)) {
|
||||
return result.catch(debugError);
|
||||
}
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
async setPermission(origin, ...permissions) {
|
||||
if (origin === '*') {
|
||||
throw new UnsupportedOperation('Origin (*) is not supported by WebDriver BiDi');
|
||||
}
|
||||
await Promise.all(permissions.map(permission => {
|
||||
if (permission.permission.allowWithoutSanitization) {
|
||||
throw new UnsupportedOperation('allowWithoutSanitization is not supported by WebDriver BiDi');
|
||||
}
|
||||
if (permission.permission.panTiltZoom) {
|
||||
throw new UnsupportedOperation('panTiltZoom is not supported by WebDriver BiDi');
|
||||
}
|
||||
if (permission.permission.userVisibleOnly) {
|
||||
throw new UnsupportedOperation('userVisibleOnly is not supported by WebDriver BiDi');
|
||||
}
|
||||
return this.userContext.setPermissions(origin, {
|
||||
name: permission.permission.name,
|
||||
}, permission.state);
|
||||
}));
|
||||
}
|
||||
async clearPermissionOverrides() {
|
||||
const promises = this.#overrides.map(({ permission, origin }) => {
|
||||
return this.userContext
|
||||
.setPermissions(origin, {
|
||||
name: permission,
|
||||
}, "prompt" /* Bidi.Permissions.PermissionState.Prompt */)
|
||||
.catch(debugError);
|
||||
});
|
||||
this.#overrides = [];
|
||||
await Promise.all(promises);
|
||||
}
|
||||
get id() {
|
||||
if (this.userContext.id === UserContext.DEFAULT) {
|
||||
return undefined;
|
||||
}
|
||||
return this.userContext.id;
|
||||
}
|
||||
async cookies() {
|
||||
const cookies = await this.userContext.getCookies();
|
||||
return cookies.map(cookie => {
|
||||
return bidiToPuppeteerCookie(cookie, true);
|
||||
});
|
||||
}
|
||||
async setCookie(...cookies) {
|
||||
await Promise.all(cookies.map(async (cookie) => {
|
||||
const bidiCookie = {
|
||||
domain: cookie.domain,
|
||||
name: cookie.name,
|
||||
value: {
|
||||
type: 'string',
|
||||
value: cookie.value,
|
||||
},
|
||||
...(cookie.path !== undefined ? { path: cookie.path } : {}),
|
||||
...(cookie.httpOnly !== undefined ? { httpOnly: cookie.httpOnly } : {}),
|
||||
...(cookie.secure !== undefined ? { secure: cookie.secure } : {}),
|
||||
...(cookie.sameSite !== undefined
|
||||
? { sameSite: convertCookiesSameSiteCdpToBiDi(cookie.sameSite) }
|
||||
: {}),
|
||||
...{ expiry: convertCookiesExpiryCdpToBiDi(cookie.expires) },
|
||||
// Chrome-specific properties.
|
||||
...cdpSpecificCookiePropertiesFromPuppeteerToBidi(cookie, 'sourceScheme', 'priority', 'url'),
|
||||
};
|
||||
return await this.userContext.setCookie(bidiCookie, convertCookiesPartitionKeyFromPuppeteerToBiDi(cookie.partitionKey));
|
||||
}));
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiBrowserContext };
|
||||
//# sourceMappingURL=BrowserContext.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/BrowserContext.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.d.ts
generated
vendored
Normal file
29
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js';
|
||||
import type { CommandOptions } from '../api/CDPSession.js';
|
||||
import { CDPSession } from '../api/CDPSession.js';
|
||||
import type { Connection as CdpConnection } from '../cdp/Connection.js';
|
||||
import type { BidiFrame } from './Frame.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiCdpSession extends CDPSession {
|
||||
#private;
|
||||
static sessions: Map<string, BidiCdpSession>;
|
||||
readonly frame: BidiFrame;
|
||||
constructor(frame: BidiFrame, sessionId?: string);
|
||||
connection(): CdpConnection | undefined;
|
||||
get detached(): boolean;
|
||||
send<T extends keyof ProtocolMapping.Commands>(method: T, params?: ProtocolMapping.Commands[T]['paramsType'][0], options?: CommandOptions): Promise<ProtocolMapping.Commands[T]['returnType']>;
|
||||
detach(): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
onClose: () => void;
|
||||
id(): string;
|
||||
}
|
||||
//# sourceMappingURL=CDPSession.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CDPSession.d.ts","sourceRoot":"","sources":["../../../src/bidi/CDPSession.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,eAAe,MAAM,6CAA6C,CAAC;AAE/E,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAC,UAAU,IAAI,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAKtE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;;IAC5C,MAAM,CAAC,QAAQ,8BAAqC;IAKpD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;gBAEd,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM;IA+BvC,UAAU,IAAI,aAAa,GAAG,SAAS;IAIhD,IAAa,QAAQ,IAAI,OAAO,CAE/B;IAEc,IAAI,CAAC,CAAC,SAAS,MAAM,eAAe,CAAC,QAAQ,EAC1D,MAAM,EAAE,CAAC,EACT,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EACrD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAwBtC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBtC;;OAEG;IACH,OAAO,QAAO,IAAI,CAGhB;IAEO,EAAE,IAAI,MAAM;CAItB"}
|
||||
90
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.js
generated
vendored
Normal file
90
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
import { CDPSession } from '../api/CDPSession.js';
|
||||
import { TargetCloseError, UnsupportedOperation } from '../common/Errors.js';
|
||||
import { Deferred } from '../util/Deferred.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiCdpSession extends CDPSession {
|
||||
static sessions = new Map();
|
||||
#detached = false;
|
||||
#connection;
|
||||
#sessionId = Deferred.create();
|
||||
frame;
|
||||
constructor(frame, sessionId) {
|
||||
super();
|
||||
this.frame = frame;
|
||||
if (!this.frame.page().browser().cdpSupported) {
|
||||
return;
|
||||
}
|
||||
const connection = this.frame.page().browser().connection;
|
||||
this.#connection = connection;
|
||||
if (sessionId) {
|
||||
this.#sessionId.resolve(sessionId);
|
||||
BidiCdpSession.sessions.set(sessionId, this);
|
||||
}
|
||||
else {
|
||||
(async () => {
|
||||
try {
|
||||
const { result } = await connection.send('goog:cdp.getSession', {
|
||||
context: frame._id,
|
||||
});
|
||||
this.#sessionId.resolve(result.session);
|
||||
BidiCdpSession.sessions.set(result.session, this);
|
||||
}
|
||||
catch (error) {
|
||||
this.#sessionId.reject(error);
|
||||
}
|
||||
})();
|
||||
}
|
||||
// SAFETY: We never throw #sessionId.
|
||||
BidiCdpSession.sessions.set(this.#sessionId.value(), this);
|
||||
}
|
||||
connection() {
|
||||
return undefined;
|
||||
}
|
||||
get detached() {
|
||||
return this.#detached;
|
||||
}
|
||||
async send(method, params, options) {
|
||||
if (this.#connection === undefined) {
|
||||
throw new UnsupportedOperation('CDP support is required for this feature. The current browser does not support CDP.');
|
||||
}
|
||||
if (this.#detached) {
|
||||
throw new TargetCloseError(`Protocol error (${method}): Session closed. Most likely the page has been closed.`);
|
||||
}
|
||||
const session = await this.#sessionId.valueOrThrow();
|
||||
const { result } = await this.#connection.send('goog:cdp.sendCommand', {
|
||||
method: method,
|
||||
params: params,
|
||||
session,
|
||||
}, options?.timeout);
|
||||
return result.result;
|
||||
}
|
||||
async detach() {
|
||||
if (this.#connection === undefined ||
|
||||
this.#connection.closed ||
|
||||
this.#detached) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.frame.client.send('Target.detachFromTarget', {
|
||||
sessionId: this.id(),
|
||||
});
|
||||
}
|
||||
finally {
|
||||
this.onClose();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
onClose = () => {
|
||||
BidiCdpSession.sessions.delete(this.id());
|
||||
this.#detached = true;
|
||||
};
|
||||
id() {
|
||||
const value = this.#sessionId.value();
|
||||
return typeof value === 'string' ? value : '';
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=CDPSession.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/CDPSession.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CDPSession.js","sourceRoot":"","sources":["../../../src/bidi/CDPSession.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAC,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAK7C;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,MAAM,CAAC,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEpD,SAAS,GAAG,KAAK,CAAC;IACT,WAAW,CAAkB;IAC7B,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAU,CAAC;IACvC,KAAK,CAAY;IAE1B,YAAY,KAAgB,EAAE,SAAkB;QAC9C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,YAAY,EAAE,CAAC;YAC9C,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACnC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,CAAC,KAAK,IAAI,EAAE;gBACV,IAAI,CAAC;oBACH,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,qBAAqB,EA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AC;IAEQ,KAAK,CAAC,MAAM;QACnB,IACE,IAAI,CAAC,WAAW,KAAK,SAAS;YAC9B,IAAI,CAAC,WAAW,CAAC,MAAM;YACvB,IAAI,CAAC,SAAS,EACd,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE;gBACtD,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;aACrB,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,OAAO,GAAG,GAAS,EAAE;QACnB,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC,CAAC;IAEO,EAAE;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,CAAC"}
|
||||
59
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.d.ts
generated
vendored
Normal file
59
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.d.ts
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as ChromiumBidi from 'chromium-bidi/lib/protocol/protocol.js';
|
||||
import type { ConnectionTransport } from '../common/ConnectionTransport.js';
|
||||
import type { EventsWithWildcard } from '../common/EventEmitter.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import type { GetIdFn } from '../util/incremental-id-generator.js';
|
||||
import type { BidiEvents, Commands as BidiCommands, Connection } from './core/Connection.js';
|
||||
export type CdpEvent = ChromiumBidi.Cdp.Event;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface Commands extends BidiCommands {
|
||||
'goog:cdp.sendCommand': {
|
||||
params: ChromiumBidi.Cdp.SendCommandParameters;
|
||||
returnType: ChromiumBidi.Cdp.SendCommandResult;
|
||||
};
|
||||
'goog:cdp.getSession': {
|
||||
params: ChromiumBidi.Cdp.GetSessionParameters;
|
||||
returnType: ChromiumBidi.Cdp.GetSessionResult;
|
||||
};
|
||||
'goog:cdp.resolveRealm': {
|
||||
params: ChromiumBidi.Cdp.ResolveRealmParameters;
|
||||
returnType: ChromiumBidi.Cdp.ResolveRealmResult;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiConnection extends EventEmitter<BidiEvents> implements Connection {
|
||||
#private;
|
||||
constructor(url: string, transport: ConnectionTransport, idGenerator: GetIdFn, delay?: number, timeout?: number);
|
||||
get closed(): boolean;
|
||||
get url(): string;
|
||||
pipeTo<Events extends BidiEvents>(emitter: EventEmitter<Events>): void;
|
||||
emit<Key extends keyof EventsWithWildcard<BidiEvents>>(type: Key, event: EventsWithWildcard<BidiEvents>[Key]): boolean;
|
||||
send<T extends keyof Commands>(method: T, params: Commands[T]['params'], timeout?: number): Promise<{
|
||||
result: Commands[T]['returnType'];
|
||||
}>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected onMessage(message: string): Promise<void>;
|
||||
/**
|
||||
* Unbinds the connection, but keeps the transport open. Useful when the transport will
|
||||
* be reused by other connection e.g. with different protocol.
|
||||
* @internal
|
||||
*/
|
||||
unbind(): void;
|
||||
/**
|
||||
* Unbinds the connection and closes the transport.
|
||||
*/
|
||||
dispose(): void;
|
||||
getPendingProtocolErrors(): Error[];
|
||||
}
|
||||
//# sourceMappingURL=Connection.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Connection.d.ts","sourceRoot":"","sources":["../../../src/bidi/Connection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,YAAY,MAAM,wCAAwC,CAAC;AAI5E,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAG1E,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,qCAAqC,CAAC;AAGjE,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,IAAI,YAAY,EACxB,UAAU,EACX,MAAM,sBAAsB,CAAC;AAK9B,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,QAAS,SAAQ,YAAY;IAC5C,sBAAsB,EAAE;QACtB,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC;QAC/C,UAAU,EAAE,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC;KAChD,CAAC;IACF,qBAAqB,EAAE;QACrB,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,oBAAoB,CAAC;QAC9C,UAAU,EAAE,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC;KAC/C,CAAC;IACF,uBAAuB,EAAE;QACvB,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAChD,UAAU,EAAE,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC;KACjD,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,cACX,SAAQ,YAAY,CAAC,UAAU,CAC/B,YAAW,UAAU;;gBAWnB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,mBAAmB,EAC9B,WAAW,EAAE,OAAO,EACpB,KAAK,SAAI,EACT,OAAO,CAAC,EAAE,MAAM;IAalB,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,MAAM,CAAC,MAAM,SAAS,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,IAAI;IAgB7D,IAAI,CAAC,GAAG,SAAS,MAAM,kBAAkB,CAAC,UAAU,CAAC,EAC5D,IAAI,EAAE,GAAG,EACT,KAAK,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GACzC,OAAO;IAWV,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAC3B,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAC7B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;QAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;KAAC,CAAC;IAe/C;;OAEG;cACa,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+CzD;;;;OAIG;IACH,MAAM,IAAI,IAAI;IAYd;;OAEG;IACH,OAAO,IAAI,IAAI;IAKf,wBAAwB,IAAI,KAAK,EAAE;CAGpC"}
|
||||
160
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.js
generated
vendored
Normal file
160
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.js
generated
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { CallbackRegistry } from '../common/CallbackRegistry.js';
|
||||
import { debug } from '../common/Debug.js';
|
||||
import { ConnectionClosedError } from '../common/Errors.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { debugError } from '../common/util.js';
|
||||
import { BidiCdpSession } from './CDPSession.js';
|
||||
const debugProtocolSend = debug('puppeteer:webDriverBiDi:SEND ►');
|
||||
const debugProtocolReceive = debug('puppeteer:webDriverBiDi:RECV ◀');
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiConnection extends EventEmitter {
|
||||
#url;
|
||||
#transport;
|
||||
#delay;
|
||||
#timeout = 0;
|
||||
#closed = false;
|
||||
#callbacks;
|
||||
#emitters = [];
|
||||
constructor(url, transport, idGenerator, delay = 0, timeout) {
|
||||
super();
|
||||
this.#url = url;
|
||||
this.#delay = delay;
|
||||
this.#timeout = timeout ?? 180_000;
|
||||
this.#callbacks = new CallbackRegistry(idGenerator);
|
||||
this.#transport = transport;
|
||||
this.#transport.onmessage = this.onMessage.bind(this);
|
||||
this.#transport.onclose = this.unbind.bind(this);
|
||||
}
|
||||
get closed() {
|
||||
return this.#closed;
|
||||
}
|
||||
get url() {
|
||||
return this.#url;
|
||||
}
|
||||
pipeTo(emitter) {
|
||||
this.#emitters.push(emitter);
|
||||
}
|
||||
#toWebDriverOnlyEvent(event) {
|
||||
for (const key in event) {
|
||||
if (key.startsWith('goog:')) {
|
||||
delete event[key];
|
||||
}
|
||||
else {
|
||||
if (typeof event[key] === 'object' && event[key] !== null) {
|
||||
this.#toWebDriverOnlyEvent(event[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
emit(type, event) {
|
||||
if (process.env['PUPPETEER_WEBDRIVER_BIDI_ONLY'] === 'true') {
|
||||
// Required for WebDriver-only testing.
|
||||
this.#toWebDriverOnlyEvent(event);
|
||||
}
|
||||
for (const emitter of this.#emitters) {
|
||||
emitter.emit(type, event);
|
||||
}
|
||||
return super.emit(type, event);
|
||||
}
|
||||
send(method, params, timeout) {
|
||||
if (this.#closed) {
|
||||
return Promise.reject(new ConnectionClosedError('Connection closed.'));
|
||||
}
|
||||
return this.#callbacks.create(method, timeout ?? this.#timeout, id => {
|
||||
const stringifiedMessage = JSON.stringify({
|
||||
id,
|
||||
method,
|
||||
params,
|
||||
});
|
||||
debugProtocolSend(stringifiedMessage);
|
||||
this.#transport.send(stringifiedMessage);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async onMessage(message) {
|
||||
if (this.#delay) {
|
||||
await new Promise(f => {
|
||||
return setTimeout(f, this.#delay);
|
||||
});
|
||||
}
|
||||
debugProtocolReceive(message);
|
||||
const object = JSON.parse(message);
|
||||
if ('type' in object) {
|
||||
switch (object.type) {
|
||||
case 'success':
|
||||
this.#callbacks.resolve(object.id, object);
|
||||
return;
|
||||
case 'error':
|
||||
if (object.id === null) {
|
||||
break;
|
||||
}
|
||||
this.#callbacks.reject(object.id, createProtocolError(object), `${object.error}: ${object.message}`);
|
||||
return;
|
||||
case 'event':
|
||||
if (isCdpEvent(object)) {
|
||||
BidiCdpSession.sessions
|
||||
.get(object.params.session)
|
||||
?.emit(object.params.event, object.params.params);
|
||||
return;
|
||||
}
|
||||
// SAFETY: We know the method and parameter still match here.
|
||||
this.emit(object.method, object.params);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Even if the response in not in BiDi protocol format but `id` is provided, reject
|
||||
// the callback. This can happen if the endpoint supports CDP instead of BiDi.
|
||||
if ('id' in object) {
|
||||
this.#callbacks.reject(object.id, `Protocol Error. Message is not in BiDi protocol format: '${message}'`, object.message);
|
||||
}
|
||||
debugError(object);
|
||||
}
|
||||
/**
|
||||
* Unbinds the connection, but keeps the transport open. Useful when the transport will
|
||||
* be reused by other connection e.g. with different protocol.
|
||||
* @internal
|
||||
*/
|
||||
unbind() {
|
||||
if (this.#closed) {
|
||||
return;
|
||||
}
|
||||
this.#closed = true;
|
||||
// Both may still be invoked and produce errors
|
||||
this.#transport.onmessage = () => { };
|
||||
this.#transport.onclose = () => { };
|
||||
this.#callbacks.clear();
|
||||
}
|
||||
/**
|
||||
* Unbinds the connection and closes the transport.
|
||||
*/
|
||||
dispose() {
|
||||
this.unbind();
|
||||
this.#transport.close();
|
||||
}
|
||||
getPendingProtocolErrors() {
|
||||
return this.#callbacks.getPendingProtocolErrors();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function createProtocolError(object) {
|
||||
let message = `${object.error} ${object.message}`;
|
||||
if (object.stacktrace) {
|
||||
message += ` ${object.stacktrace}`;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
function isCdpEvent(event) {
|
||||
return event.method.startsWith('goog:cdp.');
|
||||
}
|
||||
//# sourceMappingURL=Connection.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Connection.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Connection.js","sourceRoot":"","sources":["../../../src/bidi/Connection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAO/C,MAAM,iBAAiB,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;AAClE,MAAM,oBAAoB,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;AAsBrE;;GAEG;AACH,MAAM,OAAO,cACX,SAAQ,YAAwB;IAGhC,IAAI,CAAS;IACb,UAAU,CAAsB;IAChC,MAAM,CAAS;IACf,QAAQ,GAAG,CAAC,CAAC;IACb,OAAO,GAAG,KAAK,CAAC;IAChB,UAAU,CAAmB;IAC7B,SAAS,GAA6B,EAAE,CAAC;IAEzC,YACE,GAAW,EACX,SAA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CAAC;YACjB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,+CAA+C;QAC/C,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEnC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,wBAAwB;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,wBAAwB,EAAE,CAAC;IACpD,CAAC;CACF;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,MAA0B;IACrD,IAAI,OAAO,GAAG,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;IAClD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAAC,KAA4B;IAC9C,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAC9C,CAAC"}
|
||||
14
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.d.ts
generated
vendored
Normal file
14
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiDeserializer {
|
||||
#private;
|
||||
static deserialize(result: Bidi.Script.RemoteValue): any;
|
||||
}
|
||||
//# sourceMappingURL=Deserializer.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Deserializer.d.ts","sourceRoot":"","sources":["../../../src/bidi/Deserializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAIrD;;GAEG;AACH,qBAAa,gBAAgB;;IAC3B,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,GAAG;CA6EzD"}
|
||||
80
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.js
generated
vendored
Normal file
80
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { debugError } from '../common/util.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiDeserializer {
|
||||
static deserialize(result) {
|
||||
if (!result) {
|
||||
debugError('Service did not produce a result.');
|
||||
return undefined;
|
||||
}
|
||||
switch (result.type) {
|
||||
case 'array':
|
||||
return result.value?.map(value => {
|
||||
return this.deserialize(value);
|
||||
});
|
||||
case 'set':
|
||||
return result.value?.reduce((acc, value) => {
|
||||
return acc.add(this.deserialize(value));
|
||||
}, new Set());
|
||||
case 'object':
|
||||
return result.value?.reduce((acc, tuple) => {
|
||||
const { key, value } = this.#deserializeTuple(tuple);
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
}, {});
|
||||
case 'map':
|
||||
return result.value?.reduce((acc, tuple) => {
|
||||
const { key, value } = this.#deserializeTuple(tuple);
|
||||
return acc.set(key, value);
|
||||
}, new Map());
|
||||
case 'promise':
|
||||
return {};
|
||||
case 'regexp':
|
||||
return new RegExp(result.value.pattern, result.value.flags);
|
||||
case 'date':
|
||||
return new Date(result.value);
|
||||
case 'undefined':
|
||||
return undefined;
|
||||
case 'null':
|
||||
return null;
|
||||
case 'number':
|
||||
return this.#deserializeNumber(result.value);
|
||||
case 'bigint':
|
||||
return BigInt(result.value);
|
||||
case 'boolean':
|
||||
return Boolean(result.value);
|
||||
case 'string':
|
||||
return result.value;
|
||||
}
|
||||
debugError(`Deserialization of type ${result.type} not supported.`);
|
||||
return undefined;
|
||||
}
|
||||
static #deserializeNumber(value) {
|
||||
switch (value) {
|
||||
case '-0':
|
||||
return -0;
|
||||
case 'NaN':
|
||||
return NaN;
|
||||
case 'Infinity':
|
||||
return Infinity;
|
||||
case '-Infinity':
|
||||
return -Infinity;
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
static #deserializeTuple([serializedKey, serializedValue]) {
|
||||
const key = typeof serializedKey === 'string'
|
||||
? serializedKey
|
||||
: this.deserialize(serializedKey);
|
||||
const value = this.deserialize(serializedValue);
|
||||
return { key, value };
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Deserializer.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Deserializer.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Deserializer.js","sourceRoot":"","sources":["../../../src/bidi/Deserializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,WAAW,CAAC,MAA+B;QAChD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,UAAU,CAAC,mCAAmC,CAAC,CAAC;YAChD,OAAO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}
|
||||
27
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.d.ts
generated
vendored
Normal file
27
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
import { DeviceRequestPrompt, type DeviceRequestPromptDevice } from '../api/DeviceRequestPrompt.js';
|
||||
import type { Session } from './core/Session.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiDeviceRequestPromptManager {
|
||||
#private;
|
||||
constructor(contextId: string, session: Session);
|
||||
waitForDevicePrompt(timeout: number, signal: AbortSignal | undefined): Promise<DeviceRequestPrompt>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiDeviceRequestPrompt extends DeviceRequestPrompt {
|
||||
#private;
|
||||
constructor(contextId: string, promptId: string, session: Session, devices: Bidi.Bluetooth.RequestDeviceInfo[]);
|
||||
cancel(): Promise<void>;
|
||||
select(device: DeviceRequestPromptDevice): Promise<void>;
|
||||
waitForDevice(): never;
|
||||
}
|
||||
//# sourceMappingURL=DeviceRequestPrompt.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DeviceRequestPrompt.d.ts","sourceRoot":"","sources":["../../../src/bidi/DeviceRequestPrompt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,KAAK,yBAAyB,EAC/B,MAAM,+BAA+B,CAAC;AAIvC,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,qBAAa,8BAA8B;;gBAK7B,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAezC,mBAAmB,CACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,mBAAmB,CAAC;CA2ChC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,mBAAmB;;gBAM5D,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;IAiBvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAQvB,MAAM,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9D,aAAa,IAAI,KAAK;CAGvB"}
|
||||
85
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.js
generated
vendored
Normal file
85
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { DeviceRequestPrompt, } from '../api/DeviceRequestPrompt.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { Deferred } from '../util/Deferred.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiDeviceRequestPromptManager {
|
||||
#session;
|
||||
#contextId;
|
||||
#enabled = false;
|
||||
constructor(contextId, session) {
|
||||
this.#session = session;
|
||||
this.#contextId = contextId;
|
||||
}
|
||||
async #enableIfNeeded() {
|
||||
if (!this.#enabled) {
|
||||
this.#enabled = true;
|
||||
await this.#session.subscribe(['bluetooth.requestDevicePromptUpdated'], [this.#contextId]);
|
||||
}
|
||||
}
|
||||
async waitForDevicePrompt(timeout, signal) {
|
||||
const deferred = Deferred.create({
|
||||
message: `Waiting for \`DeviceRequestPrompt\` failed: ${timeout}ms exceeded`,
|
||||
timeout,
|
||||
});
|
||||
const onRequestDevicePromptUpdated = (params) => {
|
||||
if (params.context === this.#contextId) {
|
||||
deferred.resolve(new BidiDeviceRequestPrompt(this.#contextId, params.prompt, this.#session, params.devices));
|
||||
this.#session.off('bluetooth.requestDevicePromptUpdated', onRequestDevicePromptUpdated);
|
||||
}
|
||||
};
|
||||
this.#session.on('bluetooth.requestDevicePromptUpdated', onRequestDevicePromptUpdated);
|
||||
if (signal) {
|
||||
signal.addEventListener('abort', () => {
|
||||
deferred.reject(signal.reason);
|
||||
}, { once: true });
|
||||
}
|
||||
await this.#enableIfNeeded();
|
||||
return await deferred.valueOrThrow();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiDeviceRequestPrompt extends DeviceRequestPrompt {
|
||||
#session;
|
||||
#promptId;
|
||||
#contextId;
|
||||
constructor(contextId, promptId, session, devices) {
|
||||
super();
|
||||
this.#session = session;
|
||||
this.#promptId = promptId;
|
||||
this.#contextId = contextId;
|
||||
this.devices.push(...devices.map(d => {
|
||||
return {
|
||||
id: d.id,
|
||||
name: d.name ?? 'UNKNOWN',
|
||||
};
|
||||
}));
|
||||
}
|
||||
async cancel() {
|
||||
await this.#session.send('bluetooth.handleRequestDevicePrompt', {
|
||||
context: this.#contextId,
|
||||
prompt: this.#promptId,
|
||||
accept: false,
|
||||
});
|
||||
}
|
||||
async select(device) {
|
||||
await this.#session.send('bluetooth.handleRequestDevicePrompt', {
|
||||
context: this.#contextId,
|
||||
prompt: this.#promptId,
|
||||
accept: true,
|
||||
device: device.id,
|
||||
});
|
||||
}
|
||||
waitForDevice() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=DeviceRequestPrompt.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/DeviceRequestPrompt.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DeviceRequestPrompt.js","sourceRoot":"","sources":["../../../src/bidi/DeviceRequestPrompt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAI7C;;GAEG;AACH,MAAM,OAAO,8BAA8B;IAChC,QAAQ,CAAU;IAClB,UAAU,CAAS;IAC5B,QAAQ,GAAG,KAAK,CAAC;IAEjB,YAAY,SAAiB,EAAE,OAAgB;QAC7C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAC3B,CAAC,sCAAsC,CAAC,EACxC,CAAC,IAAI,CAAC,UAAU,CAAC,CAClB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,OAAe,EACf,MAA+B;QAE/B,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAsB;YACpD,OAAO,EAAE,+CAA+C,OAAO,aAAa;YAC5E,OAAO;SACR,CAAC,CAAC;QAEH,MAAM,4BAA4B,GAAG,CACnC,MAA2D,EAC3D,EAAE;YACF,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;gBACvC,QAAQ,CAAC,OAAO,CACd,IAAI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AC,QAAQ,CAAC,IAAI,CAAC,qCAAqC,EAAE;YAC9D,OAAO,EAAE,IAAI,CAAC,UAAU;YACxB,MAAM,EAAE,IAAI,CAAC,SAAS;YACtB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAiC;QAC5C,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,qCAAqC,EAAE;YAC9D,OAAO,EAAE,IAAI,CAAC,UAAU;YACxB,MAAM,EAAE,IAAI,CAAC,SAAS;YACtB,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,MAAM,CAAC,EAAE;SAClB,CAAC,CAAC;IACL,CAAC;IAED,aAAa;QACX,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;CACF"}
|
||||
17
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.d.ts
generated
vendored
Normal file
17
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { Dialog } from '../api/Dialog.js';
|
||||
import type { UserPrompt } from './core/UserPrompt.js';
|
||||
export declare class BidiDialog extends Dialog {
|
||||
#private;
|
||||
static from(prompt: UserPrompt): BidiDialog;
|
||||
private constructor();
|
||||
handle(options: {
|
||||
accept: boolean;
|
||||
text?: string;
|
||||
}): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=Dialog.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/bidi/Dialog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAExC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD,qBAAa,UAAW,SAAQ,MAAM;;IACpC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU;IAK3C,OAAO;IAMQ,MAAM,CAAC,OAAO,EAAE;QAC7B,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlB"}
|
||||
24
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.js
generated
vendored
Normal file
24
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { Dialog } from '../api/Dialog.js';
|
||||
export class BidiDialog extends Dialog {
|
||||
static from(prompt) {
|
||||
return new BidiDialog(prompt);
|
||||
}
|
||||
#prompt;
|
||||
constructor(prompt) {
|
||||
super(prompt.info.type, prompt.info.message, prompt.info.defaultValue);
|
||||
this.#prompt = prompt;
|
||||
this.handled = prompt.handled;
|
||||
}
|
||||
async handle(options) {
|
||||
await this.#prompt.handle({
|
||||
accept: options.accept,
|
||||
userText: options.text,
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Dialog.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Dialog.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/bidi/Dialog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAIxC,MAAM,OAAO,UAAW,SAAQ,MAAM;IACpC,MAAM,CAAC,IAAI,CAAC,MAAkB;QAC5B,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAa;IACpB,YAAoB,MAAkB;QACpC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;IAEQ,KAAK,CAAC,MAAM,CAAC,OAGrB;QACC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;CACF"}
|
||||
29
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.d.ts
generated
vendored
Normal file
29
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
import { ElementHandle, type AutofillData } from '../api/ElementHandle.js';
|
||||
import type { AwaitableIterable } from '../common/types.js';
|
||||
import type { BidiFrame } from './Frame.js';
|
||||
import { BidiJSHandle } from './JSHandle.js';
|
||||
import type { BidiFrameRealm } from './Realm.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiElementHandle<ElementType extends Node = Element> extends ElementHandle<ElementType> {
|
||||
#private;
|
||||
static from<ElementType extends Node = Element>(value: Bidi.Script.RemoteValue, realm: BidiFrameRealm): BidiElementHandle<ElementType>;
|
||||
handle: BidiJSHandle<ElementType>;
|
||||
constructor(value: Bidi.Script.RemoteValue, realm: BidiFrameRealm);
|
||||
get realm(): BidiFrameRealm;
|
||||
get frame(): BidiFrame;
|
||||
remoteValue(): Bidi.Script.RemoteValue;
|
||||
autofill(data: AutofillData): Promise<void>;
|
||||
contentFrame(this: BidiElementHandle<HTMLIFrameElement>): Promise<BidiFrame>;
|
||||
uploadFile(this: BidiElementHandle<HTMLInputElement>, ...files: string[]): Promise<void>;
|
||||
queryAXTree(this: BidiElementHandle<HTMLElement>, name?: string | undefined, role?: string | undefined): AwaitableIterable<ElementHandle<Node>>;
|
||||
backendNodeId(): Promise<number>;
|
||||
}
|
||||
//# sourceMappingURL=ElementHandle.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ElementHandle.d.ts","sourceRoot":"","sources":["../../../src/bidi/ElementHandle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAEL,aAAa,EACb,KAAK,YAAY,EAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAK1D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE/C;;GAEG;AACH,qBAAa,iBAAiB,CAC5B,WAAW,SAAS,IAAI,GAAG,OAAO,CAClC,SAAQ,aAAa,CAAC,WAAW,CAAC;;IAGlC,MAAM,CAAC,IAAI,CAAC,WAAW,SAAS,IAAI,GAAG,OAAO,EAC5C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAC9B,KAAK,EAAE,cAAc,GACpB,iBAAiB,CAAC,WAAW,CAAC;IAIzB,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;gBAE9B,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc;IAIjE,IAAa,KAAK,IAAI,cAAc,CAGnC;IAED,IAAa,KAAK,IAAI,SAAS,CAE9B;IAED,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW;IAKvB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAe3C,YAAY,CACzB,IAAI,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,GACzC,OAAO,CAAC,SAAS,CAAC;IA2BN,UAAU,CACvB,IAAI,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,EACzC,GAAG,KAAK,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,IAAI,CAAC;IAeA,WAAW,CACzB,IAAI,EAAE,iBAAiB,CAAC,WAAW,CAAC,EACpC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GACxB,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAe1B,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;CAahD"}
|
||||
219
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.js
generated
vendored
Normal file
219
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose, inner;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
if (async) inner = dispose;
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
};
|
||||
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
||||
return function (env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
var r, s = 0;
|
||||
function next() {
|
||||
while (r = env.stack.pop()) {
|
||||
try {
|
||||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
||||
if (r.dispose) {
|
||||
var result = r.dispose.call(r.value);
|
||||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
else s |= 1;
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
};
|
||||
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
});
|
||||
import { bindIsolatedHandle, ElementHandle, } from '../api/ElementHandle.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { environment } from '../environment.js';
|
||||
import { AsyncIterableUtil } from '../util/AsyncIterableUtil.js';
|
||||
import { throwIfDisposed } from '../util/decorators.js';
|
||||
import { BidiJSHandle } from './JSHandle.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
let BidiElementHandle = (() => {
|
||||
let _classSuper = ElementHandle;
|
||||
let _instanceExtraInitializers = [];
|
||||
let _autofill_decorators;
|
||||
let _contentFrame_decorators;
|
||||
return class BidiElementHandle extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_autofill_decorators = [throwIfDisposed()];
|
||||
_contentFrame_decorators = [throwIfDisposed(), bindIsolatedHandle];
|
||||
__esDecorate(this, null, _autofill_decorators, { kind: "method", name: "autofill", static: false, private: false, access: { has: obj => "autofill" in obj, get: obj => obj.autofill }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _contentFrame_decorators, { kind: "method", name: "contentFrame", static: false, private: false, access: { has: obj => "contentFrame" in obj, get: obj => obj.contentFrame }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
#backendNodeId = __runInitializers(this, _instanceExtraInitializers);
|
||||
static from(value, realm) {
|
||||
return new BidiElementHandle(value, realm);
|
||||
}
|
||||
constructor(value, realm) {
|
||||
super(BidiJSHandle.from(value, realm));
|
||||
}
|
||||
get realm() {
|
||||
// SAFETY: See the super call in the constructor.
|
||||
return this.handle.realm;
|
||||
}
|
||||
get frame() {
|
||||
return this.realm.environment;
|
||||
}
|
||||
remoteValue() {
|
||||
return this.handle.remoteValue();
|
||||
}
|
||||
async autofill(data) {
|
||||
const client = this.frame.client;
|
||||
const nodeInfo = await client.send('DOM.describeNode', {
|
||||
objectId: this.handle.id,
|
||||
});
|
||||
const fieldId = nodeInfo.node.backendNodeId;
|
||||
const frameId = this.frame._id;
|
||||
await client.send('Autofill.trigger', {
|
||||
fieldId,
|
||||
frameId,
|
||||
card: data.creditCard,
|
||||
address: data.address,
|
||||
});
|
||||
}
|
||||
async contentFrame() {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_1, (await this.evaluateHandle(element => {
|
||||
if (element instanceof HTMLIFrameElement ||
|
||||
element instanceof HTMLFrameElement) {
|
||||
return element.contentWindow;
|
||||
}
|
||||
return;
|
||||
})), false);
|
||||
const value = handle.remoteValue();
|
||||
if (value.type === 'window') {
|
||||
return (this.frame
|
||||
.page()
|
||||
.frames()
|
||||
.find(frame => {
|
||||
return frame._id === value.value.context;
|
||||
}) ?? null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (e_1) {
|
||||
env_1.error = e_1;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
async uploadFile(...files) {
|
||||
// Locate all files and confirm that they exist.
|
||||
const path = environment.value.path;
|
||||
if (path) {
|
||||
files = files.map(file => {
|
||||
if (path.win32.isAbsolute(file) || path.posix.isAbsolute(file)) {
|
||||
return file;
|
||||
}
|
||||
else {
|
||||
return path.resolve(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
await this.frame.setFiles(this, files);
|
||||
}
|
||||
async *queryAXTree(name, role) {
|
||||
const results = await this.frame.locateNodes(this, {
|
||||
type: 'accessibility',
|
||||
value: {
|
||||
role,
|
||||
name,
|
||||
},
|
||||
});
|
||||
return yield* AsyncIterableUtil.map(results, node => {
|
||||
// TODO: maybe change ownership since the default ownership is probably none.
|
||||
return Promise.resolve(BidiElementHandle.from(node, this.realm));
|
||||
});
|
||||
}
|
||||
async backendNodeId() {
|
||||
if (!this.frame.page().browser().cdpSupported) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
if (this.#backendNodeId) {
|
||||
return this.#backendNodeId;
|
||||
}
|
||||
const { node } = await this.frame.client.send('DOM.describeNode', {
|
||||
objectId: this.handle.id,
|
||||
});
|
||||
this.#backendNodeId = node.backendNodeId;
|
||||
return this.#backendNodeId;
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiElementHandle };
|
||||
//# sourceMappingURL=ElementHandle.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ElementHandle.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ElementHandle.js","sourceRoot":"","sources":["../../../src/bidi/ElementHandle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,OAAO,EACL,kBAAkB,EAClB,aAAa,GAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAG3C;;GAEG;IACU,iBAAiB;sBAEpB,aAAa;;;;iBAFV,iBAEX,SAAQ,WAA0B;;;oCA6BjC,eAAe,EAAE;wCAmBjB,eAAe,EAAE,EACjB,kBAAkB;YAnBnB,2KAAe,QAAQ,6DAatB;YAOD,uLAAe,YAAY,6DAsB1B;;;QAvED,cAAc,GAHH,mDAAiB,CAGJ;QAExB,MAAM,CAAC,IAAI,CACT,KAA8B,EAC9B,KAAqB;YAErB,OAAO,IAAI,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;QAID,YAAY,KAA8B,EAAE,KAAqB;YAC/D,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACzC,CAAC;QAED,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AC,CAAC,CAAC;YACnE,CAAC,CAAC,CAAC;QACL,CAAC;QAEQ,KAAK,CAAC,aAAa;YAC1B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,YAAY,EAAE,CAAC;gBAC9C,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YACD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC,cAAc,CAAC;YAC7B,CAAC;YACD,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE;gBAC9D,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;aACzB,CAAC,CAAC;YACH,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;YACzC,OAAO,IAAI,CAAC,cAAc,CAAC;QAC7B,CAAC;;;SA7HU,iBAAiB"}
|
||||
19
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.d.ts
generated
vendored
Normal file
19
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Awaitable } from '../common/types.js';
|
||||
import type { BidiFrame } from './Frame.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class ExposableFunction<Args extends unknown[], Ret> {
|
||||
#private;
|
||||
static from<Args extends unknown[], Ret>(frame: BidiFrame, name: string, apply: (...args: Args) => Awaitable<Ret>, isolate?: boolean): Promise<ExposableFunction<Args, Ret>>;
|
||||
readonly name: string;
|
||||
constructor(frame: BidiFrame, name: string, apply: (...args: Args) => Awaitable<Ret>, isolate?: boolean);
|
||||
[Symbol.dispose](): void;
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=ExposedFunction.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ExposedFunction.d.ts","sourceRoot":"","sources":["../../../src/bidi/ExposedFunction.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAC,SAAS,EAAgB,MAAM,oBAAoB,CAAC;AAOjE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAW1C;;GAEG;AACH,qBAAa,iBAAiB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,GAAG;;WAC3C,IAAI,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,GAAG,EAC3C,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,GAAG,CAAC,EACxC,OAAO,UAAQ,GACd,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAQxC,QAAQ,CAAC,IAAI,SAAC;gBAUZ,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,GAAG,CAAC,EACxC,OAAO,UAAQ;IA2KjB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIlB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB7C"}
|
||||
261
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.js
generated
vendored
Normal file
261
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.js
generated
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose, inner;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
if (async) inner = dispose;
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
};
|
||||
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
||||
return function (env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
var r, s = 0;
|
||||
function next() {
|
||||
while (r = env.stack.pop()) {
|
||||
try {
|
||||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
||||
if (r.dispose) {
|
||||
var result = r.dispose.call(r.value);
|
||||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
else s |= 1;
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
};
|
||||
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
});
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { debugError } from '../common/util.js';
|
||||
import { DisposableStack } from '../util/disposable.js';
|
||||
import { interpolateFunction, stringifyFunction } from '../util/Function.js';
|
||||
import { BidiElementHandle } from './ElementHandle.js';
|
||||
import { BidiJSHandle } from './JSHandle.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class ExposableFunction {
|
||||
static async from(frame, name, apply, isolate = false) {
|
||||
const func = new ExposableFunction(frame, name, apply, isolate);
|
||||
await func.#initialize();
|
||||
return func;
|
||||
}
|
||||
#frame;
|
||||
name;
|
||||
#apply;
|
||||
#isolate;
|
||||
#channel;
|
||||
#scripts = [];
|
||||
#disposables = new DisposableStack();
|
||||
constructor(frame, name, apply, isolate = false) {
|
||||
this.#frame = frame;
|
||||
this.name = name;
|
||||
this.#apply = apply;
|
||||
this.#isolate = isolate;
|
||||
this.#channel = `__puppeteer__${this.#frame._id}_page_exposeFunction_${this.name}`;
|
||||
}
|
||||
async #initialize() {
|
||||
const connection = this.#connection;
|
||||
const channel = {
|
||||
type: 'channel',
|
||||
value: {
|
||||
channel: this.#channel,
|
||||
ownership: "root" /* Bidi.Script.ResultOwnership.Root */,
|
||||
},
|
||||
};
|
||||
const connectionEmitter = this.#disposables.use(new EventEmitter(connection));
|
||||
connectionEmitter.on('script.message', this.#handleMessage);
|
||||
const functionDeclaration = stringifyFunction(interpolateFunction((callback) => {
|
||||
Object.assign(globalThis, {
|
||||
[PLACEHOLDER('name')]: function (...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
callback([resolve, reject, args]);
|
||||
});
|
||||
},
|
||||
});
|
||||
}, { name: JSON.stringify(this.name) }));
|
||||
const frames = [this.#frame];
|
||||
for (const frame of frames) {
|
||||
frames.push(...frame.childFrames());
|
||||
}
|
||||
await Promise.all(frames.map(async (frame) => {
|
||||
const realm = this.#isolate ? frame.isolatedRealm() : frame.mainRealm();
|
||||
try {
|
||||
const [script] = await Promise.all([
|
||||
frame.browsingContext.addPreloadScript(functionDeclaration, {
|
||||
arguments: [channel],
|
||||
sandbox: realm.sandbox,
|
||||
}),
|
||||
realm.realm.callFunction(functionDeclaration, false, {
|
||||
arguments: [channel],
|
||||
}),
|
||||
]);
|
||||
this.#scripts.push([frame, script]);
|
||||
}
|
||||
catch (error) {
|
||||
// If it errors, the frame probably doesn't support call function. We
|
||||
// fail gracefully.
|
||||
debugError(error);
|
||||
}
|
||||
}));
|
||||
}
|
||||
get #connection() {
|
||||
return this.#frame.page().browser().connection;
|
||||
}
|
||||
#handleMessage = async (params) => {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
if (params.channel !== this.#channel) {
|
||||
return;
|
||||
}
|
||||
const realm = this.#getRealm(params.source);
|
||||
if (!realm) {
|
||||
// Unrelated message.
|
||||
return;
|
||||
}
|
||||
const dataHandle = __addDisposableResource(env_1, BidiJSHandle.from(params.data, realm), false);
|
||||
const stack = __addDisposableResource(env_1, new DisposableStack(), false);
|
||||
const args = [];
|
||||
let result;
|
||||
try {
|
||||
const env_2 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const argsHandle = __addDisposableResource(env_2, await dataHandle.evaluateHandle(([, , args]) => {
|
||||
return args;
|
||||
}), false);
|
||||
for (const [index, handle] of await argsHandle.getProperties()) {
|
||||
stack.use(handle);
|
||||
// Element handles are passed as is.
|
||||
if (handle instanceof BidiElementHandle) {
|
||||
args[+index] = handle;
|
||||
stack.use(handle);
|
||||
continue;
|
||||
}
|
||||
// Everything else is passed as the JS value.
|
||||
args[+index] = handle.jsonValue();
|
||||
}
|
||||
result = await this.#apply(...(await Promise.all(args)));
|
||||
}
|
||||
catch (e_1) {
|
||||
env_2.error = e_1;
|
||||
env_2.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_2);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
try {
|
||||
if (error instanceof Error) {
|
||||
await dataHandle.evaluate(([, reject], name, message, stack) => {
|
||||
const error = new Error(message);
|
||||
error.name = name;
|
||||
if (stack) {
|
||||
error.stack = stack;
|
||||
}
|
||||
reject(error);
|
||||
}, error.name, error.message, error.stack);
|
||||
}
|
||||
else {
|
||||
await dataHandle.evaluate(([, reject], error) => {
|
||||
reject(error);
|
||||
}, error);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
debugError(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await dataHandle.evaluate(([resolve], result) => {
|
||||
resolve(result);
|
||||
}, result);
|
||||
}
|
||||
catch (error) {
|
||||
debugError(error);
|
||||
}
|
||||
}
|
||||
catch (e_2) {
|
||||
env_1.error = e_2;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
};
|
||||
#getRealm(source) {
|
||||
const frame = this.#findFrame(source.context);
|
||||
if (!frame) {
|
||||
// Unrelated message.
|
||||
return;
|
||||
}
|
||||
return frame.realm(source.realm);
|
||||
}
|
||||
#findFrame(id) {
|
||||
const frames = [this.#frame];
|
||||
for (const frame of frames) {
|
||||
if (frame._id === id) {
|
||||
return frame;
|
||||
}
|
||||
frames.push(...frame.childFrames());
|
||||
}
|
||||
return;
|
||||
}
|
||||
[Symbol.dispose]() {
|
||||
void this[Symbol.asyncDispose]().catch(debugError);
|
||||
}
|
||||
async [Symbol.asyncDispose]() {
|
||||
this.#disposables.dispose();
|
||||
await Promise.all(this.#scripts.map(async ([frame, script]) => {
|
||||
const realm = this.#isolate ? frame.isolatedRealm() : frame.mainRealm();
|
||||
try {
|
||||
await Promise.all([
|
||||
realm.evaluate(name => {
|
||||
delete globalThis[name];
|
||||
}, this.name),
|
||||
...frame.childFrames().map(childFrame => {
|
||||
return childFrame.evaluate(name => {
|
||||
delete globalThis[name];
|
||||
}, this.name);
|
||||
}),
|
||||
frame.browsingContext.removePreloadScript(script),
|
||||
]);
|
||||
}
|
||||
catch (error) {
|
||||
debugError(error);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ExposedFunction.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/ExposedFunction.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
55
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.d.ts
generated
vendored
Normal file
55
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { CDPSession } from '../api/CDPSession.js';
|
||||
import type { DeviceRequestPrompt } from '../api/DeviceRequestPrompt.js';
|
||||
import { Frame, type GoToOptions, type SetContentWaitForOptions, type WaitForOptions } from '../api/Frame.js';
|
||||
import { type WaitTimeoutOptions } from '../api/Page.js';
|
||||
import type { Realm } from '../api/Realm.js';
|
||||
import { Accessibility } from '../cdp/Accessibility.js';
|
||||
import type { TimeoutSettings } from '../common/TimeoutSettings.js';
|
||||
import type { Awaitable, HandleFor } from '../common/types.js';
|
||||
import { BidiCdpSession } from './CDPSession.js';
|
||||
import type { BrowsingContext } from './core/BrowsingContext.js';
|
||||
import { BidiElementHandle } from './ElementHandle.js';
|
||||
import type { BidiHTTPResponse } from './HTTPResponse.js';
|
||||
import type { BidiPage } from './Page.js';
|
||||
import type { BidiRealm } from './Realm.js';
|
||||
import { BidiFrameRealm } from './Realm.js';
|
||||
export declare class BidiFrame extends Frame {
|
||||
#private;
|
||||
static from(parent: BidiPage | BidiFrame, browsingContext: BrowsingContext): BidiFrame;
|
||||
readonly browsingContext: BrowsingContext;
|
||||
readonly realms: {
|
||||
default: BidiFrameRealm;
|
||||
internal: BidiFrameRealm;
|
||||
};
|
||||
readonly _id: string;
|
||||
readonly client: BidiCdpSession;
|
||||
readonly accessibility: Accessibility;
|
||||
private constructor();
|
||||
get timeoutSettings(): TimeoutSettings;
|
||||
mainRealm(): BidiFrameRealm;
|
||||
isolatedRealm(): BidiFrameRealm;
|
||||
realm(id: string): BidiRealm | undefined;
|
||||
page(): BidiPage;
|
||||
url(): string;
|
||||
parentFrame(): BidiFrame | null;
|
||||
childFrames(): BidiFrame[];
|
||||
goto(url: string, options?: GoToOptions): Promise<BidiHTTPResponse | null>;
|
||||
setContent(html: string, options?: SetContentWaitForOptions): Promise<void>;
|
||||
waitForNavigation(options?: WaitForOptions): Promise<BidiHTTPResponse | null>;
|
||||
waitForDevicePrompt(options?: WaitTimeoutOptions): Promise<DeviceRequestPrompt>;
|
||||
get detached(): boolean;
|
||||
exposeFunction<Args extends unknown[], Ret>(name: string, apply: (...args: Args) => Awaitable<Ret>): Promise<void>;
|
||||
removeExposedFunction(name: string): Promise<void>;
|
||||
createCDPSession(): Promise<CDPSession>;
|
||||
setFiles(element: BidiElementHandle, files: string[]): Promise<void>;
|
||||
frameElement(): Promise<HandleFor<HTMLIFrameElement> | null>;
|
||||
locateNodes(element: BidiElementHandle, locator: Bidi.BrowsingContext.Locator): Promise<Bidi.Script.NodeRemoteValue[]>;
|
||||
extensionRealms(): Realm[];
|
||||
}
|
||||
//# sourceMappingURL=Frame.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Frame.d.ts","sourceRoot":"","sources":["../../../src/bidi/Frame.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAgBhD,OAAO,KAAK,EA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AAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,OAAO,GACpC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;IAQhC,eAAe,IAAI,KAAK,EAAE;CAGpC"}
|
||||
469
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.js
generated
vendored
Normal file
469
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.js
generated
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
||||
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
||||
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
||||
};
|
||||
import { combineLatest, defer, delayWhen, filter, first, firstValueFrom, map, of, race, raceWith, switchMap, } from '../../third_party/rxjs/rxjs.js';
|
||||
import { Frame, throwIfDetached, } from '../api/Frame.js';
|
||||
import { Accessibility } from '../cdp/Accessibility.js';
|
||||
import { TargetCloseError, UnsupportedOperation } from '../common/Errors.js';
|
||||
import { debugError, fromAbortSignal, fromEmitterEvent, timeout, } from '../common/util.js';
|
||||
import { isErrorLike } from '../util/ErrorLike.js';
|
||||
import { BidiCdpSession } from './CDPSession.js';
|
||||
import { BidiDialog } from './Dialog.js';
|
||||
import { BidiElementHandle } from './ElementHandle.js';
|
||||
import { ExposableFunction } from './ExposedFunction.js';
|
||||
import { BidiHTTPRequest, requests } from './HTTPRequest.js';
|
||||
import { BidiFrameRealm } from './Realm.js';
|
||||
import { getConsoleMessage, isConsoleLogEntry, isJavaScriptLogEntry, rewriteNavigationError, } from './util.js';
|
||||
import { BidiWebWorker } from './WebWorker.js';
|
||||
let BidiFrame = (() => {
|
||||
var _a;
|
||||
let _classSuper = Frame;
|
||||
let _instanceExtraInitializers = [];
|
||||
let _goto_decorators;
|
||||
let _setContent_decorators;
|
||||
let _waitForNavigation_decorators;
|
||||
let _private_waitForLoad$_decorators;
|
||||
let _private_waitForLoad$_descriptor;
|
||||
let _private_waitForNetworkIdle$_decorators;
|
||||
let _private_waitForNetworkIdle$_descriptor;
|
||||
let _setFiles_decorators;
|
||||
let _frameElement_decorators;
|
||||
let _locateNodes_decorators;
|
||||
return class BidiFrame extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_goto_decorators = [throwIfDetached];
|
||||
_setContent_decorators = [throwIfDetached];
|
||||
_waitForNavigation_decorators = [throwIfDetached];
|
||||
_private_waitForLoad$_decorators = [throwIfDetached];
|
||||
_private_waitForNetworkIdle$_decorators = [throwIfDetached];
|
||||
_setFiles_decorators = [throwIfDetached];
|
||||
_frameElement_decorators = [throwIfDetached];
|
||||
_locateNodes_decorators = [throwIfDetached];
|
||||
__esDecorate(this, null, _goto_decorators, { kind: "method", name: "goto", static: false, private: false, access: { has: obj => "goto" in obj, get: obj => obj.goto }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setContent_decorators, { kind: "method", name: "setContent", static: false, private: false, access: { has: obj => "setContent" in obj, get: obj => obj.setContent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _waitForNavigation_decorators, { kind: "method", name: "waitForNavigation", static: false, private: false, access: { has: obj => "waitForNavigation" in obj, get: obj => obj.waitForNavigation }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, _private_waitForLoad$_descriptor = { value: __setFunctionName(function (options = {}) {
|
||||
let { waitUntil = 'load' } = options;
|
||||
const { timeout: ms = this.timeoutSettings.navigationTimeout() } = options;
|
||||
if (!Array.isArray(waitUntil)) {
|
||||
waitUntil = [waitUntil];
|
||||
}
|
||||
const events = new Set();
|
||||
for (const lifecycleEvent of waitUntil) {
|
||||
switch (lifecycleEvent) {
|
||||
case 'load': {
|
||||
events.add('load');
|
||||
break;
|
||||
}
|
||||
case 'domcontentloaded': {
|
||||
events.add('DOMContentLoaded');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (events.size === 0) {
|
||||
return of(undefined);
|
||||
}
|
||||
return combineLatest([...events].map(event => {
|
||||
return fromEmitterEvent(this.browsingContext, event);
|
||||
})).pipe(map(() => { }), first(), raceWith(timeout(ms), this.#detached$().pipe(map(() => {
|
||||
throw new Error('Frame detached.');
|
||||
}))));
|
||||
}, "#waitForLoad$") }, _private_waitForLoad$_decorators, { kind: "method", name: "#waitForLoad$", static: false, private: true, access: { has: obj => #waitForLoad$ in obj, get: obj => obj.#waitForLoad$ }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, _private_waitForNetworkIdle$_descriptor = { value: __setFunctionName(function (options = {}) {
|
||||
let { waitUntil = 'load' } = options;
|
||||
if (!Array.isArray(waitUntil)) {
|
||||
waitUntil = [waitUntil];
|
||||
}
|
||||
let concurrency = Infinity;
|
||||
for (const event of waitUntil) {
|
||||
switch (event) {
|
||||
case 'networkidle0': {
|
||||
concurrency = Math.min(0, concurrency);
|
||||
break;
|
||||
}
|
||||
case 'networkidle2': {
|
||||
concurrency = Math.min(2, concurrency);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (concurrency === Infinity) {
|
||||
return of(undefined);
|
||||
}
|
||||
return this.page().waitForNetworkIdle$({
|
||||
idleTime: 500,
|
||||
timeout: options.timeout ?? this.timeoutSettings.timeout(),
|
||||
concurrency,
|
||||
});
|
||||
}, "#waitForNetworkIdle$") }, _private_waitForNetworkIdle$_decorators, { kind: "method", name: "#waitForNetworkIdle$", static: false, private: true, access: { has: obj => #waitForNetworkIdle$ in obj, get: obj => obj.#waitForNetworkIdle$ }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setFiles_decorators, { kind: "method", name: "setFiles", static: false, private: false, access: { has: obj => "setFiles" in obj, get: obj => obj.setFiles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _frameElement_decorators, { kind: "method", name: "frameElement", static: false, private: false, access: { has: obj => "frameElement" in obj, get: obj => obj.frameElement }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _locateNodes_decorators, { kind: "method", name: "locateNodes", static: false, private: false, access: { has: obj => "locateNodes" in obj, get: obj => obj.locateNodes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
static from(parent, browsingContext) {
|
||||
const frame = new BidiFrame(parent, browsingContext);
|
||||
frame.#initialize();
|
||||
return frame;
|
||||
}
|
||||
#parent = __runInitializers(this, _instanceExtraInitializers);
|
||||
browsingContext;
|
||||
#frames = new WeakMap();
|
||||
realms;
|
||||
_id;
|
||||
client;
|
||||
accessibility;
|
||||
constructor(parent, browsingContext) {
|
||||
super();
|
||||
this.#parent = parent;
|
||||
this.browsingContext = browsingContext;
|
||||
this._id = browsingContext.id;
|
||||
this.client = new BidiCdpSession(this);
|
||||
this.realms = {
|
||||
default: BidiFrameRealm.from(this.browsingContext.defaultRealm, this),
|
||||
internal: BidiFrameRealm.from(this.browsingContext.createWindowRealm(`__puppeteer_internal_${Math.ceil(Math.random() * 10000)}`), this),
|
||||
};
|
||||
this.accessibility = new Accessibility(this.realms.default, this._id);
|
||||
}
|
||||
#initialize() {
|
||||
for (const browsingContext of this.browsingContext.children) {
|
||||
this.#createFrameTarget(browsingContext);
|
||||
}
|
||||
this.browsingContext.on('browsingcontext', browsingContext => {
|
||||
this.#createFrameTarget(browsingContext);
|
||||
});
|
||||
this.browsingContext.on('closed', () => {
|
||||
for (const session of BidiCdpSession.sessions.values()) {
|
||||
if (session.frame === this) {
|
||||
session.onClose();
|
||||
}
|
||||
}
|
||||
this.page().trustedEmitter.emit("framedetached" /* PageEvent.FrameDetached */, this);
|
||||
});
|
||||
this.browsingContext.on('request', request => {
|
||||
const httpRequest = BidiHTTPRequest.from(request, this, this.page().isNetworkInterceptionEnabled);
|
||||
request.once('success', () => {
|
||||
this.page().trustedEmitter.emit("requestfinished" /* PageEvent.RequestFinished */, httpRequest);
|
||||
});
|
||||
request.once('error', () => {
|
||||
this.page().trustedEmitter.emit("requestfailed" /* PageEvent.RequestFailed */, httpRequest);
|
||||
});
|
||||
void httpRequest.finalizeInterceptions();
|
||||
});
|
||||
this.browsingContext.on('navigation', navigation => {
|
||||
navigation.once('fragment', () => {
|
||||
this.page().trustedEmitter.emit("framenavigated" /* PageEvent.FrameNavigated */, this);
|
||||
});
|
||||
});
|
||||
this.browsingContext.on('load', () => {
|
||||
this.page().trustedEmitter.emit("load" /* PageEvent.Load */, undefined);
|
||||
});
|
||||
this.browsingContext.on('DOMContentLoaded', () => {
|
||||
this._hasStartedLoading = true;
|
||||
this.page().trustedEmitter.emit("domcontentloaded" /* PageEvent.DOMContentLoaded */, undefined);
|
||||
this.page().trustedEmitter.emit("framenavigated" /* PageEvent.FrameNavigated */, this);
|
||||
});
|
||||
this.browsingContext.on('userprompt', userPrompt => {
|
||||
this.page().trustedEmitter.emit("dialog" /* PageEvent.Dialog */, BidiDialog.from(userPrompt));
|
||||
});
|
||||
this.browsingContext.on('log', entry => {
|
||||
if (this._id !== entry.source.context) {
|
||||
return;
|
||||
}
|
||||
if (isConsoleLogEntry(entry)) {
|
||||
if (!this.page().listenerCount("console" /* PageEvent.Console */)) {
|
||||
return;
|
||||
}
|
||||
const args = entry.args.map(arg => {
|
||||
return this.mainRealm().createHandle(arg);
|
||||
});
|
||||
this.page().trustedEmitter.emit("console" /* PageEvent.Console */, getConsoleMessage(entry, args, this));
|
||||
}
|
||||
else if (isJavaScriptLogEntry(entry)) {
|
||||
const error = new Error(entry.text ?? '');
|
||||
const messageHeight = error.message.split('\n').length;
|
||||
const messageLines = error.stack.split('\n').splice(0, messageHeight);
|
||||
const stackLines = [];
|
||||
if (entry.stackTrace) {
|
||||
for (const frame of entry.stackTrace.callFrames) {
|
||||
// Note we need to add `1` because the values are 0-indexed.
|
||||
stackLines.push(` at ${frame.functionName || '<anonymous>'} (${frame.url}:${frame.lineNumber + 1}:${frame.columnNumber + 1})`);
|
||||
if (stackLines.length >= Error.stackTraceLimit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
error.stack = [...messageLines, ...stackLines].join('\n');
|
||||
this.page().trustedEmitter.emit("pageerror" /* PageEvent.PageError */, error);
|
||||
}
|
||||
else {
|
||||
debugError(`Unhandled LogEntry with type "${entry.type}", text "${entry.text}" and level "${entry.level}"`);
|
||||
}
|
||||
});
|
||||
this.browsingContext.on('worker', realm => {
|
||||
const worker = BidiWebWorker.from(this, realm);
|
||||
realm.on('destroyed', () => {
|
||||
this.page().trustedEmitter.emit("workerdestroyed" /* PageEvent.WorkerDestroyed */, worker);
|
||||
});
|
||||
this.page().trustedEmitter.emit("workercreated" /* PageEvent.WorkerCreated */, worker);
|
||||
});
|
||||
}
|
||||
#createFrameTarget(browsingContext) {
|
||||
const frame = BidiFrame.from(this, browsingContext);
|
||||
this.#frames.set(browsingContext, frame);
|
||||
this.page().trustedEmitter.emit("frameattached" /* PageEvent.FrameAttached */, frame);
|
||||
browsingContext.on('closed', () => {
|
||||
this.#frames.delete(browsingContext);
|
||||
});
|
||||
return frame;
|
||||
}
|
||||
get timeoutSettings() {
|
||||
return this.page()._timeoutSettings;
|
||||
}
|
||||
mainRealm() {
|
||||
return this.realms.default;
|
||||
}
|
||||
isolatedRealm() {
|
||||
return this.realms.internal;
|
||||
}
|
||||
realm(id) {
|
||||
for (const realm of Object.values(this.realms)) {
|
||||
if (realm.realm.id === id) {
|
||||
return realm;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
page() {
|
||||
let parent = this.#parent;
|
||||
while (parent instanceof BidiFrame) {
|
||||
parent = parent.#parent;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
url() {
|
||||
return this.browsingContext.url;
|
||||
}
|
||||
parentFrame() {
|
||||
if (this.#parent instanceof BidiFrame) {
|
||||
return this.#parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
childFrames() {
|
||||
return [...this.browsingContext.children].map(child => {
|
||||
return this.#frames.get(child);
|
||||
});
|
||||
}
|
||||
#detached$() {
|
||||
return defer(() => {
|
||||
if (this.detached) {
|
||||
return of(this);
|
||||
}
|
||||
return fromEmitterEvent(this.page().trustedEmitter, "framedetached" /* PageEvent.FrameDetached */).pipe(filter(detachedFrame => {
|
||||
return detachedFrame === this;
|
||||
}));
|
||||
});
|
||||
}
|
||||
async goto(url, options = {}) {
|
||||
const [response] = await Promise.all([
|
||||
this.waitForNavigation(options),
|
||||
// Some implementations currently only report errors when the
|
||||
// readiness=interactive.
|
||||
//
|
||||
// Related: https://bugzilla.mozilla.org/show_bug.cgi?id=1846601
|
||||
this.browsingContext
|
||||
.navigate(url, "interactive" /* Bidi.BrowsingContext.ReadinessState.Interactive */)
|
||||
.catch(error => {
|
||||
if (isErrorLike(error) &&
|
||||
error.message.includes('net::ERR_HTTP_RESPONSE_CODE_FAILURE')) {
|
||||
return;
|
||||
}
|
||||
if (error.message.includes('navigation canceled')) {
|
||||
return;
|
||||
}
|
||||
if (error.message.includes('Navigation was aborted by another navigation')) {
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}),
|
||||
]).catch(rewriteNavigationError(url, options.timeout ?? this.timeoutSettings.navigationTimeout()));
|
||||
return response;
|
||||
}
|
||||
async setContent(html, options = {}) {
|
||||
await Promise.all([
|
||||
this.setFrameContent(html),
|
||||
firstValueFrom(combineLatest([
|
||||
this.#waitForLoad$(options),
|
||||
this.#waitForNetworkIdle$(options),
|
||||
])),
|
||||
]);
|
||||
}
|
||||
async waitForNavigation(options = {}) {
|
||||
const { timeout: ms = this.timeoutSettings.navigationTimeout(), signal } = options;
|
||||
const frames = this.childFrames().map(frame => {
|
||||
return frame.#detached$();
|
||||
});
|
||||
return await firstValueFrom(combineLatest([
|
||||
race(fromEmitterEvent(this.browsingContext, 'navigation'), fromEmitterEvent(this.browsingContext, 'historyUpdated').pipe(map(() => {
|
||||
return null;
|
||||
})))
|
||||
.pipe(first())
|
||||
.pipe(switchMap(navigation => {
|
||||
if (navigation === null) {
|
||||
return of(null);
|
||||
}
|
||||
return this.#waitForLoad$(options).pipe(delayWhen(() => {
|
||||
if (frames.length === 0) {
|
||||
return of(undefined);
|
||||
}
|
||||
return combineLatest(frames);
|
||||
}), raceWith(fromEmitterEvent(navigation, 'fragment'), fromEmitterEvent(navigation, 'failed'), fromEmitterEvent(navigation, 'aborted')), switchMap(() => {
|
||||
if (navigation.request) {
|
||||
function requestFinished$(request) {
|
||||
if (navigation === null) {
|
||||
return of(null);
|
||||
}
|
||||
// Reduces flakiness if the response events arrive after
|
||||
// the load event.
|
||||
// Usually, the response or error is already there at this point.
|
||||
if (request.response || request.error) {
|
||||
return of(navigation);
|
||||
}
|
||||
if (request.redirect) {
|
||||
return requestFinished$(request.redirect);
|
||||
}
|
||||
return fromEmitterEvent(request, 'success')
|
||||
.pipe(raceWith(fromEmitterEvent(request, 'error')), raceWith(fromEmitterEvent(request, 'redirect')))
|
||||
.pipe(switchMap(() => {
|
||||
return requestFinished$(request);
|
||||
}));
|
||||
}
|
||||
return requestFinished$(navigation.request);
|
||||
}
|
||||
return of(navigation);
|
||||
}));
|
||||
})),
|
||||
this.#waitForNetworkIdle$(options),
|
||||
]).pipe(map(([navigation]) => {
|
||||
if (!navigation) {
|
||||
return null;
|
||||
}
|
||||
const request = navigation.request;
|
||||
if (!request) {
|
||||
return null;
|
||||
}
|
||||
const lastRequest = request.lastRedirect ?? request;
|
||||
const httpRequest = requests.get(lastRequest);
|
||||
return httpRequest.response();
|
||||
}), raceWith(timeout(ms), fromAbortSignal(signal), this.#detached$().pipe(map(() => {
|
||||
throw new TargetCloseError('Frame detached.');
|
||||
})))));
|
||||
}
|
||||
waitForDevicePrompt(options = {}) {
|
||||
const { timeout = this.timeoutSettings.timeout(), signal } = options;
|
||||
return this.browsingContext.waitForDevicePrompt(timeout, signal);
|
||||
}
|
||||
get detached() {
|
||||
return this.browsingContext.closed;
|
||||
}
|
||||
#exposedFunctions = new Map();
|
||||
async exposeFunction(name, apply) {
|
||||
if (this.#exposedFunctions.has(name)) {
|
||||
throw new Error(`Failed to add page binding with name ${name}: globalThis['${name}'] already exists!`);
|
||||
}
|
||||
const exposable = await ExposableFunction.from(this, name, apply);
|
||||
this.#exposedFunctions.set(name, exposable);
|
||||
}
|
||||
async removeExposedFunction(name) {
|
||||
const exposedFunction = this.#exposedFunctions.get(name);
|
||||
if (!exposedFunction) {
|
||||
throw new Error(`Failed to remove page binding with name ${name}: window['${name}'] does not exists!`);
|
||||
}
|
||||
this.#exposedFunctions.delete(name);
|
||||
await exposedFunction[Symbol.asyncDispose]();
|
||||
}
|
||||
async createCDPSession() {
|
||||
if (!this.page().browser().cdpSupported) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
const cdpConnection = this.page().browser().cdpConnection;
|
||||
return await cdpConnection._createSession({ targetId: this._id });
|
||||
}
|
||||
get #waitForLoad$() { return _private_waitForLoad$_descriptor.value; }
|
||||
get #waitForNetworkIdle$() { return _private_waitForNetworkIdle$_descriptor.value; }
|
||||
async setFiles(element, files) {
|
||||
await this.browsingContext.setFiles(
|
||||
// SAFETY: ElementHandles are always remote references.
|
||||
element.remoteValue(), files);
|
||||
}
|
||||
async frameElement() {
|
||||
const parentFrame = this.parentFrame();
|
||||
if (!parentFrame) {
|
||||
return null;
|
||||
}
|
||||
const [node] = await parentFrame.browsingContext.locateNodes({
|
||||
type: 'context',
|
||||
value: {
|
||||
context: this._id,
|
||||
},
|
||||
});
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
return BidiElementHandle.from(node, parentFrame.mainRealm());
|
||||
}
|
||||
async locateNodes(element, locator) {
|
||||
return await this.browsingContext.locateNodes(locator,
|
||||
// SAFETY: ElementHandles are always remote references.
|
||||
[element.remoteValue()]);
|
||||
}
|
||||
extensionRealms() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiFrame };
|
||||
//# sourceMappingURL=Frame.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Frame.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
47
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPRequest.d.ts
generated
vendored
Normal file
47
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPRequest.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Protocol } from 'devtools-protocol';
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { CDPSession } from '../api/CDPSession.js';
|
||||
import type { ContinueRequestOverrides, InterceptResolutionState, ResponseForRequest } from '../api/HTTPRequest.js';
|
||||
import { HTTPRequest, type ResourceType } from '../api/HTTPRequest.js';
|
||||
import type { Request } from './core/Request.js';
|
||||
import type { BidiFrame } from './Frame.js';
|
||||
import { BidiHTTPResponse } from './HTTPResponse.js';
|
||||
export declare const requests: WeakMap<Request, BidiHTTPRequest>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiHTTPRequest extends HTTPRequest {
|
||||
#private;
|
||||
static from(bidiRequest: Request, frame: BidiFrame, isNetworkInterceptionEnabled: boolean, redirect?: BidiHTTPRequest): BidiHTTPRequest;
|
||||
readonly id: string;
|
||||
private constructor();
|
||||
get client(): CDPSession;
|
||||
protected canBeIntercepted(): boolean;
|
||||
interceptResolutionState(): InterceptResolutionState;
|
||||
url(): string;
|
||||
resourceType(): ResourceType;
|
||||
method(): string;
|
||||
postData(): string | undefined;
|
||||
hasPostData(): boolean;
|
||||
fetchPostData(): Promise<string | undefined>;
|
||||
headers(): Record<string, string>;
|
||||
response(): BidiHTTPResponse | null;
|
||||
failure(): {
|
||||
errorText: string;
|
||||
} | null;
|
||||
isNavigationRequest(): boolean;
|
||||
initiator(): Protocol.Network.Initiator | undefined;
|
||||
redirectChain(): BidiHTTPRequest[];
|
||||
frame(): BidiFrame;
|
||||
_continue(overrides?: ContinueRequestOverrides): Promise<void>;
|
||||
_abort(): Promise<void>;
|
||||
_respond(response: Partial<ResponseForRequest>, _priority?: number): Promise<void>;
|
||||
timing(): Bidi.Network.FetchTimingInfo;
|
||||
getResponseContent(): Promise<Uint8Array>;
|
||||
}
|
||||
//# sourceMappingURL=HTTPRequest.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPRequest.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPRequest.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTTPRequest.d.ts","sourceRoot":"","sources":["../../../src/bidi/HTTPRequest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,WAAW,EAEX,KAAK,YAAY,EAGlB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,QAAQ,mCAA0C,CAAC;AAEhE;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;;IAC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/bidi/HTTPRequest.js
generated
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
var _a;
|
||||
import { HTTPRequest, STATUS_TEXTS, handleError, InterceptResolutionAction, } from '../api/HTTPRequest.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { stringToBase64 } from '../util/encoding.js';
|
||||
import { BidiHTTPResponse } from './HTTPResponse.js';
|
||||
export const requests = new WeakMap();
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiHTTPRequest extends HTTPRequest {
|
||||
static from(bidiRequest, frame, isNetworkInterceptionEnabled, redirect) {
|
||||
const request = new _a(bidiRequest, frame, isNetworkInterceptionEnabled, redirect);
|
||||
request.#initialize();
|
||||
return request;
|
||||
}
|
||||
#redirectChain;
|
||||
#response = null;
|
||||
id;
|
||||
#frame;
|
||||
#request;
|
||||
constructor(request, frame, isNetworkInterceptionEnabled, redirect) {
|
||||
super();
|
||||
requests.set(request, this);
|
||||
this.interception.enabled = isNetworkInterceptionEnabled;
|
||||
this.#request = request;
|
||||
this.#frame = frame;
|
||||
this.#redirectChain = redirect ? redirect.#redirectChain : [];
|
||||
this.id = request.id;
|
||||
}
|
||||
get client() {
|
||||
return this.#frame.client;
|
||||
}
|
||||
#initialize() {
|
||||
this.#request.on('redirect', request => {
|
||||
const httpRequest = _a.from(request, this.#frame, this.interception.enabled, this);
|
||||
this.#redirectChain.push(this);
|
||||
request.once('success', () => {
|
||||
this.#frame
|
||||
.page()
|
||||
.trustedEmitter.emit("requestfinished" /* PageEvent.RequestFinished */, httpRequest);
|
||||
});
|
||||
request.once('error', () => {
|
||||
this.#frame
|
||||
.page()
|
||||
.trustedEmitter.emit("requestfailed" /* PageEvent.RequestFailed */, httpRequest);
|
||||
});
|
||||
void httpRequest.finalizeInterceptions();
|
||||
});
|
||||
this.#request.once('response', data => {
|
||||
// Create new response with the initial data. Note: the data can be updated later
|
||||
// on, when the `success` event is received.
|
||||
this.#response = BidiHTTPResponse.from(data, this, this.#frame.page().browser().cdpSupported);
|
||||
});
|
||||
this.#request.once('success', data => {
|
||||
// The `network.responseCompleted` event (mapped to `success` here)
|
||||
// contains the most up-to-date and complete response data, including
|
||||
// headers that might be missing from `network.responseStarted`
|
||||
// (e.g., `Set-Cookie` for navigation requests in Chrome).
|
||||
this.#response = BidiHTTPResponse.from(data, this, this.#frame.page().browser().cdpSupported);
|
||||
});
|
||||
this.#request.on('authenticate', this.#handleAuthentication);
|
||||
this.#frame.page().trustedEmitter.emit("request" /* PageEvent.Request */, this);
|
||||
}
|
||||
canBeIntercepted() {
|
||||
return this.#request.isBlocked;
|
||||
}
|
||||
interceptResolutionState() {
|
||||
if (!this.#request.isBlocked) {
|
||||
return { action: InterceptResolutionAction.Disabled };
|
||||
}
|
||||
return super.interceptResolutionState();
|
||||
}
|
||||
url() {
|
||||
return this.#request.url;
|
||||
}
|
||||
resourceType() {
|
||||
if (!this.#frame.page().browser().cdpSupported) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
return (this.#request.resourceType || 'other').toLowerCase();
|
||||
}
|
||||
method() {
|
||||
return this.#request.method;
|
||||
}
|
||||
postData() {
|
||||
if (!this.#frame.page().browser().cdpSupported) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
return this.#request.postData;
|
||||
}
|
||||
hasPostData() {
|
||||
return this.#request.hasPostData;
|
||||
}
|
||||
async fetchPostData() {
|
||||
return await this.#request.fetchPostData();
|
||||
}
|
||||
headers() {
|
||||
// Callers should not be allowed to mutate internal structure.
|
||||
const headers = {};
|
||||
for (const header of this.#request.headers) {
|
||||
headers[header.name.toLowerCase()] = header.value.value;
|
||||
}
|
||||
return {
|
||||
...headers,
|
||||
};
|
||||
}
|
||||
response() {
|
||||
return this.#response;
|
||||
}
|
||||
failure() {
|
||||
if (this.#request.error === undefined) {
|
||||
return null;
|
||||
}
|
||||
return { errorText: this.#request.error };
|
||||
}
|
||||
isNavigationRequest() {
|
||||
return this.#request.navigation !== undefined;
|
||||
}
|
||||
initiator() {
|
||||
return {
|
||||
...this.#request.initiator,
|
||||
type: this.#request.initiator?.type ?? 'other',
|
||||
};
|
||||
}
|
||||
redirectChain() {
|
||||
return this.#redirectChain.slice();
|
||||
}
|
||||
frame() {
|
||||
return this.#frame;
|
||||
}
|
||||
async _continue(overrides = {}) {
|
||||
const headers = getBidiHeaders(overrides.headers);
|
||||
this.interception.handled = true;
|
||||
return await this.#request
|
||||
.continueRequest({
|
||||
url: overrides.url,
|
||||
method: overrides.method,
|
||||
body: overrides.postData
|
||||
? {
|
||||
type: 'base64',
|
||||
value: stringToBase64(overrides.postData),
|
||||
}
|
||||
: undefined,
|
||||
headers: headers.length > 0 ? headers : undefined,
|
||||
})
|
||||
.catch(error => {
|
||||
this.interception.handled = false;
|
||||
return handleError(error);
|
||||
});
|
||||
}
|
||||
async _abort() {
|
||||
this.interception.handled = true;
|
||||
return await this.#request.failRequest().catch(error => {
|
||||
this.interception.handled = false;
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
async _respond(response, _priority) {
|
||||
this.interception.handled = true;
|
||||
let parsedBody;
|
||||
if (response.body) {
|
||||
parsedBody = HTTPRequest.getResponse(response.body);
|
||||
}
|
||||
const headers = getBidiHeaders(response.headers);
|
||||
const hasContentLength = headers.some(header => {
|
||||
return header.name === 'content-length';
|
||||
});
|
||||
if (response.contentType) {
|
||||
headers.push({
|
||||
name: 'content-type',
|
||||
value: {
|
||||
type: 'string',
|
||||
value: response.contentType,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (parsedBody?.contentLength && !hasContentLength) {
|
||||
headers.push({
|
||||
name: 'content-length',
|
||||
value: {
|
||||
type: 'string',
|
||||
value: String(parsedBody.contentLength),
|
||||
},
|
||||
});
|
||||
}
|
||||
const status = response.status || 200;
|
||||
return await this.#request
|
||||
.provideResponse({
|
||||
statusCode: status,
|
||||
headers: headers.length > 0 ? headers : undefined,
|
||||
reasonPhrase: STATUS_TEXTS[status],
|
||||
body: parsedBody?.base64
|
||||
? {
|
||||
type: 'base64',
|
||||
value: parsedBody?.base64,
|
||||
}
|
||||
: undefined,
|
||||
})
|
||||
.catch(error => {
|
||||
this.interception.handled = false;
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
#authenticationHandled = false;
|
||||
#handleAuthentication = async () => {
|
||||
if (!this.#frame) {
|
||||
return;
|
||||
}
|
||||
const credentials = this.#frame.page()._credentials;
|
||||
if (credentials && !this.#authenticationHandled) {
|
||||
this.#authenticationHandled = true;
|
||||
void this.#request.continueWithAuth({
|
||||
action: 'provideCredentials',
|
||||
credentials: {
|
||||
type: 'password',
|
||||
username: credentials.username,
|
||||
password: credentials.password,
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
void this.#request.continueWithAuth({
|
||||
action: 'cancel',
|
||||
});
|
||||
}
|
||||
};
|
||||
timing() {
|
||||
return this.#request.timing();
|
||||
}
|
||||
getResponseContent() {
|
||||
return this.#request.getResponseContent();
|
||||
}
|
||||
}
|
||||
_a = BidiHTTPRequest;
|
||||
function getBidiHeaders(rawHeaders) {
|
||||
const headers = [];
|
||||
for (const [name, value] of Object.entries(rawHeaders ?? [])) {
|
||||
if (!Object.is(value, undefined)) {
|
||||
const values = Array.isArray(value) ? value : [value];
|
||||
for (const value of values) {
|
||||
headers.push({
|
||||
name: name.toLowerCase(),
|
||||
value: {
|
||||
type: 'string',
|
||||
value: String(value),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
//# sourceMappingURL=HTTPRequest.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPRequest.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPRequest.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
35
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.d.ts
generated
vendored
Normal file
35
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Protocol } from 'devtools-protocol';
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { Frame } from '../api/Frame.js';
|
||||
import { HTTPResponse, type RemoteAddress } from '../api/HTTPResponse.js';
|
||||
import { SecurityDetails } from '../common/SecurityDetails.js';
|
||||
import type { BidiHTTPRequest } from './HTTPRequest.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiHTTPResponse extends HTTPResponse {
|
||||
#private;
|
||||
/**
|
||||
* Returns a new BidiHTTPResponse or updates the existing one if it already exists.
|
||||
*/
|
||||
static from(data: Bidi.Network.ResponseData, request: BidiHTTPRequest, cdpSupported: boolean): BidiHTTPResponse;
|
||||
private constructor();
|
||||
remoteAddress(): RemoteAddress;
|
||||
url(): string;
|
||||
status(): number;
|
||||
statusText(): string;
|
||||
headers(): Record<string, string>;
|
||||
request(): BidiHTTPRequest;
|
||||
fromCache(): boolean;
|
||||
timing(): Protocol.Network.ResourceTiming | null;
|
||||
frame(): Frame | null;
|
||||
fromServiceWorker(): boolean;
|
||||
securityDetails(): SecurityDetails | null;
|
||||
content(): Promise<Uint8Array>;
|
||||
}
|
||||
//# sourceMappingURL=HTTPResponse.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTTPResponse.d.ts","sourceRoot":"","sources":["../../../src/bidi/HTTPResponse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAE,KAAK,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAGxE,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAI7D,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEtD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;;IAChD;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAC/B,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,OAAO,GACpB,gBAAgB;IAkBnB,OAAO;IA+BE,aAAa,IAAI,aAAa;IAO9B,GAAG,IAAI,MAAM;IAIb,MAAM,IAAI,MAAM;IAIhB,UAAU,IAAI,MAAM;IAIpB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAcjC,OAAO,IAAI,eAAe;IAI1B,SAAS,IAAI,OAAO;IAIpB,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,cAAc,GAAG,IAAI;IA2BhD,KAAK,IAAI,KAAK,GAAG,IAAI;IAIrB,iBAAiB,IAAI,OAAO;IAI5B,eAAe,IAAI,eAAe,GAAG,IAAI;IAO5C,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;CAGrC"}
|
||||
169
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.js
generated
vendored
Normal file
169
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.js
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
import { HTTPResponse } from '../api/HTTPResponse.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { SecurityDetails } from '../common/SecurityDetails.js';
|
||||
import { invokeAtMostOnceForArguments } from '../util/decorators.js';
|
||||
import { normalizeHeaderValue } from '../util/httpUtils.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
let BidiHTTPResponse = (() => {
|
||||
let _classSuper = HTTPResponse;
|
||||
let _instanceExtraInitializers = [];
|
||||
let _remoteAddress_decorators;
|
||||
return class BidiHTTPResponse extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_remoteAddress_decorators = [invokeAtMostOnceForArguments];
|
||||
__esDecorate(this, null, _remoteAddress_decorators, { kind: "method", name: "remoteAddress", static: false, private: false, access: { has: obj => "remoteAddress" in obj, get: obj => obj.remoteAddress }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
/**
|
||||
* Returns a new BidiHTTPResponse or updates the existing one if it already exists.
|
||||
*/
|
||||
static from(data, request, cdpSupported) {
|
||||
const existingResponse = request.response();
|
||||
if (existingResponse) {
|
||||
// Update existing response data with up-to-date data.
|
||||
existingResponse.#data = data;
|
||||
return existingResponse;
|
||||
}
|
||||
const response = new BidiHTTPResponse(data, request, cdpSupported);
|
||||
response.#initialize();
|
||||
return response;
|
||||
}
|
||||
#data = __runInitializers(this, _instanceExtraInitializers);
|
||||
#request;
|
||||
#securityDetails;
|
||||
#cdpSupported = false;
|
||||
constructor(data, request, cdpSupported) {
|
||||
super();
|
||||
this.#data = data;
|
||||
this.#request = request;
|
||||
this.#cdpSupported = cdpSupported;
|
||||
// @ts-expect-error non-standard property.
|
||||
const securityDetails = data['goog:securityDetails'];
|
||||
if (cdpSupported && securityDetails) {
|
||||
this.#securityDetails = new SecurityDetails(securityDetails);
|
||||
}
|
||||
}
|
||||
#initialize() {
|
||||
if (this.#data.fromCache) {
|
||||
this.#request._fromMemoryCache = true;
|
||||
this.#request
|
||||
.frame()
|
||||
?.page()
|
||||
.trustedEmitter.emit("requestservedfromcache" /* PageEvent.RequestServedFromCache */, this.#request);
|
||||
}
|
||||
this.#request.frame()?.page().trustedEmitter.emit("response" /* PageEvent.Response */, this);
|
||||
}
|
||||
remoteAddress() {
|
||||
return {
|
||||
ip: '',
|
||||
port: -1,
|
||||
};
|
||||
}
|
||||
url() {
|
||||
return this.#data.url;
|
||||
}
|
||||
status() {
|
||||
return this.#data.status;
|
||||
}
|
||||
statusText() {
|
||||
return this.#data.statusText;
|
||||
}
|
||||
headers() {
|
||||
const headers = {};
|
||||
for (const header of this.#data.headers) {
|
||||
// TODO: How to handle Binary Headers
|
||||
// https://w3c.github.io/webdriver-bidi/#type-network-Header
|
||||
if (header.value.type === 'string') {
|
||||
headers[header.name.toLowerCase()] = normalizeHeaderValue(header.value.value);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
request() {
|
||||
return this.#request;
|
||||
}
|
||||
fromCache() {
|
||||
return this.#data.fromCache;
|
||||
}
|
||||
timing() {
|
||||
const bidiTiming = this.#request.timing();
|
||||
return {
|
||||
requestTime: bidiTiming.requestTime,
|
||||
proxyStart: -1,
|
||||
proxyEnd: -1,
|
||||
dnsStart: bidiTiming.dnsStart,
|
||||
dnsEnd: bidiTiming.dnsEnd,
|
||||
connectStart: bidiTiming.connectStart,
|
||||
connectEnd: bidiTiming.connectEnd,
|
||||
sslStart: bidiTiming.tlsStart,
|
||||
sslEnd: -1,
|
||||
workerStart: -1,
|
||||
workerReady: -1,
|
||||
workerFetchStart: -1,
|
||||
workerRespondWithSettled: -1,
|
||||
workerRouterEvaluationStart: -1,
|
||||
workerCacheLookupStart: -1,
|
||||
sendStart: bidiTiming.requestStart,
|
||||
sendEnd: -1,
|
||||
pushStart: -1,
|
||||
pushEnd: -1,
|
||||
receiveHeadersStart: bidiTiming.responseStart,
|
||||
receiveHeadersEnd: bidiTiming.responseEnd,
|
||||
};
|
||||
}
|
||||
frame() {
|
||||
return this.#request.frame();
|
||||
}
|
||||
fromServiceWorker() {
|
||||
return false;
|
||||
}
|
||||
securityDetails() {
|
||||
if (!this.#cdpSupported) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
return this.#securityDetails ?? null;
|
||||
}
|
||||
async content() {
|
||||
return await this.#request.getResponseContent();
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiHTTPResponse };
|
||||
//# sourceMappingURL=HTTPResponse.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/HTTPResponse.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTTPResponse.js","sourceRoot":"","sources":["../../../src/bidi/HTTPResponse.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,OAAO,EAAC,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,4BAA4B,EAAC,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAI1D;;GAEG;IACU,gBAAgB;sBAAS,YAAY;;;iBAArC,gBAAiB,SAAQ,WAAY;;;yCAwD/C,4BAA4B;YAC7B,0LAAS,aAAa,6DAKrB;;;QA7DD;;WAEG;QACH,MAAM,CAAC,IAAI,CACT,IAA+B,EAC/B,OAAwB,EACxB,YAAqB;YAErB,MAAM,gBAAgB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC5C,IAAI,gBAAgB,EAAE,CAAC;gBACrB,sDAAsD;gBACtD,gBAAgB,CAAC,KAAK,GAAG,IAAI,CAAC;gBAC9B,OAAO,gBAAgB,CAAC;YAC1B,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;YACnE,QAAQ,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,KAAK,GArBM,mDAAgB,CAqBM;QACjC,QAAQ,CAAkB;QAC1B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B,EAAE,UAAU,CAAC,aAAa;gBAC7C,iBAAiB,EAAE,UAAU,CAAC,WAAW;aAC1C,CAAC;QACJ,CAAC;QAEQ,KAAK;YACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;QAEQ,iBAAiB;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAEQ,eAAe;YACtB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;gBACxB,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YACD,OAAO,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC;QACvC,CAAC;QAED,KAAK,CAAC,OAAO;YACX,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;QAClD,CAAC;;;SA9IU,gBAAgB"}
|
||||
78
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.d.ts
generated
vendored
Normal file
78
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.d.ts
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import * as Bidi from 'webdriver-bidi-protocol';
|
||||
import { Keyboard, Mouse, Touchscreen, type TouchHandle, type KeyboardTypeOptions, type KeyDownOptions, type KeyPressOptions, type MouseClickOptions, type MouseMoveOptions, type MouseOptions, type MouseWheelOptions } from '../api/Input.js';
|
||||
import type { KeyInput } from '../common/USKeyboardLayout.js';
|
||||
import type { BidiPage } from './Page.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiKeyboard extends Keyboard {
|
||||
#private;
|
||||
constructor(page: BidiPage);
|
||||
down(key: KeyInput, _options?: Readonly<KeyDownOptions>): Promise<void>;
|
||||
up(key: KeyInput): Promise<void>;
|
||||
press(key: KeyInput, options?: Readonly<KeyPressOptions>): Promise<void>;
|
||||
type(text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
|
||||
sendCharacter(char: string): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface BidiMouseClickOptions extends MouseClickOptions {
|
||||
origin?: Bidi.Input.Origin;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface BidiMouseMoveOptions extends MouseMoveOptions {
|
||||
origin?: Bidi.Input.Origin;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface BidiTouchMoveOptions {
|
||||
origin?: Bidi.Input.Origin;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiMouse extends Mouse {
|
||||
#private;
|
||||
constructor(page: BidiPage);
|
||||
reset(): Promise<void>;
|
||||
move(x: number, y: number, options?: Readonly<BidiMouseMoveOptions>): Promise<void>;
|
||||
down(options?: Readonly<MouseOptions>): Promise<void>;
|
||||
up(options?: Readonly<MouseOptions>): Promise<void>;
|
||||
click(x: number, y: number, options?: Readonly<BidiMouseClickOptions>): Promise<void>;
|
||||
wheel(options?: Readonly<MouseWheelOptions>): Promise<void>;
|
||||
drag(): never;
|
||||
dragOver(): never;
|
||||
dragEnter(): never;
|
||||
drop(): never;
|
||||
dragAndDrop(): never;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
declare class BidiTouchHandle implements TouchHandle {
|
||||
#private;
|
||||
constructor(page: BidiPage, touchScreen: BidiTouchscreen, id: number, x: number, y: number, properties: Bidi.Input.PointerCommonProperties);
|
||||
start(options?: BidiTouchMoveOptions): Promise<void>;
|
||||
move(x: number, y: number): Promise<void>;
|
||||
end(): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiTouchscreen extends Touchscreen {
|
||||
#private;
|
||||
touches: BidiTouchHandle[];
|
||||
constructor(page: BidiPage);
|
||||
touchStart(x: number, y: number, options?: BidiTouchMoveOptions): Promise<TouchHandle>;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=Input.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/bidi/Input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAGhD,OAAO,EACL,QAAQ,EACR,KAAK,EAEL,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC;AAE5D,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAC;AAyPxC;;GAEG;AACH,qBAAa,YAAa,SAAQ,QAAQ;;gBAG5B,IAAI,EAAE,QAAQ;IAKX,IAAI,CACjB,GAAG,EAAE,QAAQ,EACb,QAAQ,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC;IAeD,EAAE,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAehC,KAAK,CAClB,GAAG,EAAE,QAAQ,EACb,OAAO,GAAE,QAAQ,CAAC,eAAe,CAAM,GACtC,OAAO,CAAC,IAAI,CAAC;IA2BD,IAAI,CACjB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,QAAQ,CAAC,mBAAmB,CAAM,GAC1C,OAAO,CAAC,IAAI,CAAC;IA8CD,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAU1D;AAED;;GAEG;A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,EACV,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,uBAAuB;IAU1C,KAAK,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B9D,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBnC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB3B;AACD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;;IAEtC,OAAO,EAAE,eAAe,EAAE,CAAC;gBAEvB,IAAI,EAAE,QAAQ;IAKX,UAAU,CACvB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,WAAW,CAAC;CAYxB"}
|
||||
628
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.js
generated
vendored
Normal file
628
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.js
generated
vendored
Normal file
@@ -0,0 +1,628 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { Keyboard, Mouse, MouseButton, Touchscreen, } from '../api/Input.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { TouchError } from '../common/Errors.js';
|
||||
var SourceActionsType;
|
||||
(function (SourceActionsType) {
|
||||
SourceActionsType["None"] = "none";
|
||||
SourceActionsType["Key"] = "key";
|
||||
SourceActionsType["Pointer"] = "pointer";
|
||||
SourceActionsType["Wheel"] = "wheel";
|
||||
})(SourceActionsType || (SourceActionsType = {}));
|
||||
var ActionType;
|
||||
(function (ActionType) {
|
||||
ActionType["Pause"] = "pause";
|
||||
ActionType["KeyDown"] = "keyDown";
|
||||
ActionType["KeyUp"] = "keyUp";
|
||||
ActionType["PointerUp"] = "pointerUp";
|
||||
ActionType["PointerDown"] = "pointerDown";
|
||||
ActionType["PointerMove"] = "pointerMove";
|
||||
ActionType["Scroll"] = "scroll";
|
||||
})(ActionType || (ActionType = {}));
|
||||
const getBidiKeyValue = (key) => {
|
||||
switch (key) {
|
||||
case '\r':
|
||||
case '\n':
|
||||
key = 'Enter';
|
||||
break;
|
||||
}
|
||||
// Measures the number of code points rather than UTF-16 code units.
|
||||
if ([...key].length === 1) {
|
||||
return key;
|
||||
}
|
||||
switch (key) {
|
||||
case 'Cancel':
|
||||
return '\uE001';
|
||||
case 'Help':
|
||||
return '\uE002';
|
||||
case 'Backspace':
|
||||
return '\uE003';
|
||||
case 'Tab':
|
||||
return '\uE004';
|
||||
case 'Clear':
|
||||
return '\uE005';
|
||||
case 'Enter':
|
||||
return '\uE007';
|
||||
case 'Shift':
|
||||
case 'ShiftLeft':
|
||||
return '\uE008';
|
||||
case 'Control':
|
||||
case 'ControlLeft':
|
||||
return '\uE009';
|
||||
case 'Alt':
|
||||
case 'AltLeft':
|
||||
return '\uE00A';
|
||||
case 'Pause':
|
||||
return '\uE00B';
|
||||
case 'Escape':
|
||||
return '\uE00C';
|
||||
case 'PageUp':
|
||||
return '\uE00E';
|
||||
case 'PageDown':
|
||||
return '\uE00F';
|
||||
case 'End':
|
||||
return '\uE010';
|
||||
case 'Home':
|
||||
return '\uE011';
|
||||
case 'ArrowLeft':
|
||||
return '\uE012';
|
||||
case 'ArrowUp':
|
||||
return '\uE013';
|
||||
case 'ArrowRight':
|
||||
return '\uE014';
|
||||
case 'ArrowDown':
|
||||
return '\uE015';
|
||||
case 'Insert':
|
||||
return '\uE016';
|
||||
case 'Delete':
|
||||
return '\uE017';
|
||||
case 'NumpadEqual':
|
||||
return '\uE019';
|
||||
case 'Numpad0':
|
||||
return '\uE01A';
|
||||
case 'Numpad1':
|
||||
return '\uE01B';
|
||||
case 'Numpad2':
|
||||
return '\uE01C';
|
||||
case 'Numpad3':
|
||||
return '\uE01D';
|
||||
case 'Numpad4':
|
||||
return '\uE01E';
|
||||
case 'Numpad5':
|
||||
return '\uE01F';
|
||||
case 'Numpad6':
|
||||
return '\uE020';
|
||||
case 'Numpad7':
|
||||
return '\uE021';
|
||||
case 'Numpad8':
|
||||
return '\uE022';
|
||||
case 'Numpad9':
|
||||
return '\uE023';
|
||||
case 'NumpadMultiply':
|
||||
return '\uE024';
|
||||
case 'NumpadAdd':
|
||||
return '\uE025';
|
||||
case 'NumpadSubtract':
|
||||
return '\uE027';
|
||||
case 'NumpadDecimal':
|
||||
return '\uE028';
|
||||
case 'NumpadDivide':
|
||||
return '\uE029';
|
||||
case 'F1':
|
||||
return '\uE031';
|
||||
case 'F2':
|
||||
return '\uE032';
|
||||
case 'F3':
|
||||
return '\uE033';
|
||||
case 'F4':
|
||||
return '\uE034';
|
||||
case 'F5':
|
||||
return '\uE035';
|
||||
case 'F6':
|
||||
return '\uE036';
|
||||
case 'F7':
|
||||
return '\uE037';
|
||||
case 'F8':
|
||||
return '\uE038';
|
||||
case 'F9':
|
||||
return '\uE039';
|
||||
case 'F10':
|
||||
return '\uE03A';
|
||||
case 'F11':
|
||||
return '\uE03B';
|
||||
case 'F12':
|
||||
return '\uE03C';
|
||||
case 'Meta':
|
||||
case 'MetaLeft':
|
||||
return '\uE03D';
|
||||
case 'ShiftRight':
|
||||
return '\uE050';
|
||||
case 'ControlRight':
|
||||
return '\uE051';
|
||||
case 'AltRight':
|
||||
return '\uE052';
|
||||
case 'MetaRight':
|
||||
return '\uE053';
|
||||
case 'Digit0':
|
||||
return '0';
|
||||
case 'Digit1':
|
||||
return '1';
|
||||
case 'Digit2':
|
||||
return '2';
|
||||
case 'Digit3':
|
||||
return '3';
|
||||
case 'Digit4':
|
||||
return '4';
|
||||
case 'Digit5':
|
||||
return '5';
|
||||
case 'Digit6':
|
||||
return '6';
|
||||
case 'Digit7':
|
||||
return '7';
|
||||
case 'Digit8':
|
||||
return '8';
|
||||
case 'Digit9':
|
||||
return '9';
|
||||
case 'KeyA':
|
||||
return 'a';
|
||||
case 'KeyB':
|
||||
return 'b';
|
||||
case 'KeyC':
|
||||
return 'c';
|
||||
case 'KeyD':
|
||||
return 'd';
|
||||
case 'KeyE':
|
||||
return 'e';
|
||||
case 'KeyF':
|
||||
return 'f';
|
||||
case 'KeyG':
|
||||
return 'g';
|
||||
case 'KeyH':
|
||||
return 'h';
|
||||
case 'KeyI':
|
||||
return 'i';
|
||||
case 'KeyJ':
|
||||
return 'j';
|
||||
case 'KeyK':
|
||||
return 'k';
|
||||
case 'KeyL':
|
||||
return 'l';
|
||||
case 'KeyM':
|
||||
return 'm';
|
||||
case 'KeyN':
|
||||
return 'n';
|
||||
case 'KeyO':
|
||||
return 'o';
|
||||
case 'KeyP':
|
||||
return 'p';
|
||||
case 'KeyQ':
|
||||
return 'q';
|
||||
case 'KeyR':
|
||||
return 'r';
|
||||
case 'KeyS':
|
||||
return 's';
|
||||
case 'KeyT':
|
||||
return 't';
|
||||
case 'KeyU':
|
||||
return 'u';
|
||||
case 'KeyV':
|
||||
return 'v';
|
||||
case 'KeyW':
|
||||
return 'w';
|
||||
case 'KeyX':
|
||||
return 'x';
|
||||
case 'KeyY':
|
||||
return 'y';
|
||||
case 'KeyZ':
|
||||
return 'z';
|
||||
case 'Semicolon':
|
||||
return ';';
|
||||
case 'Equal':
|
||||
return '=';
|
||||
case 'Comma':
|
||||
return ',';
|
||||
case 'Minus':
|
||||
return '-';
|
||||
case 'Period':
|
||||
return '.';
|
||||
case 'Slash':
|
||||
return '/';
|
||||
case 'Backquote':
|
||||
return '`';
|
||||
case 'BracketLeft':
|
||||
return '[';
|
||||
case 'Backslash':
|
||||
return '\\';
|
||||
case 'BracketRight':
|
||||
return ']';
|
||||
case 'Quote':
|
||||
return '"';
|
||||
default:
|
||||
throw new Error(`Unknown key: "${key}"`);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiKeyboard extends Keyboard {
|
||||
#page;
|
||||
constructor(page) {
|
||||
super();
|
||||
this.#page = page;
|
||||
}
|
||||
async down(key, _options) {
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Key,
|
||||
id: "__puppeteer_keyboard" /* InputId.Keyboard */,
|
||||
actions: [
|
||||
{
|
||||
type: ActionType.KeyDown,
|
||||
value: getBidiKeyValue(key),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
async up(key) {
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Key,
|
||||
id: "__puppeteer_keyboard" /* InputId.Keyboard */,
|
||||
actions: [
|
||||
{
|
||||
type: ActionType.KeyUp,
|
||||
value: getBidiKeyValue(key),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
async press(key, options = {}) {
|
||||
const { delay = 0 } = options;
|
||||
const actions = [
|
||||
{
|
||||
type: ActionType.KeyDown,
|
||||
value: getBidiKeyValue(key),
|
||||
},
|
||||
];
|
||||
if (delay > 0) {
|
||||
actions.push({
|
||||
type: ActionType.Pause,
|
||||
duration: delay,
|
||||
});
|
||||
}
|
||||
actions.push({
|
||||
type: ActionType.KeyUp,
|
||||
value: getBidiKeyValue(key),
|
||||
});
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Key,
|
||||
id: "__puppeteer_keyboard" /* InputId.Keyboard */,
|
||||
actions,
|
||||
},
|
||||
]);
|
||||
}
|
||||
async type(text, options = {}) {
|
||||
const { delay = 0 } = options;
|
||||
// This spread separates the characters into code points rather than UTF-16
|
||||
// code units.
|
||||
const values = [...text].map(getBidiKeyValue);
|
||||
const actions = [];
|
||||
if (delay <= 0) {
|
||||
for (const value of values) {
|
||||
actions.push({
|
||||
type: ActionType.KeyDown,
|
||||
value,
|
||||
}, {
|
||||
type: ActionType.KeyUp,
|
||||
value,
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const value of values) {
|
||||
actions.push({
|
||||
type: ActionType.KeyDown,
|
||||
value,
|
||||
}, {
|
||||
type: ActionType.Pause,
|
||||
duration: delay,
|
||||
}, {
|
||||
type: ActionType.KeyUp,
|
||||
value,
|
||||
});
|
||||
}
|
||||
}
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Key,
|
||||
id: "__puppeteer_keyboard" /* InputId.Keyboard */,
|
||||
actions,
|
||||
},
|
||||
]);
|
||||
}
|
||||
async sendCharacter(char) {
|
||||
// Measures the number of code points rather than UTF-16 code units.
|
||||
if ([...char].length > 1) {
|
||||
throw new Error('Cannot send more than 1 character.');
|
||||
}
|
||||
const frame = await this.#page.focusedFrame();
|
||||
await frame.isolatedRealm().evaluate(async (char) => {
|
||||
document.execCommand('insertText', false, char);
|
||||
}, char);
|
||||
}
|
||||
}
|
||||
const getBidiButton = (button) => {
|
||||
switch (button) {
|
||||
case MouseButton.Left:
|
||||
return 0;
|
||||
case MouseButton.Middle:
|
||||
return 1;
|
||||
case MouseButton.Right:
|
||||
return 2;
|
||||
case MouseButton.Back:
|
||||
return 3;
|
||||
case MouseButton.Forward:
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiMouse extends Mouse {
|
||||
#page;
|
||||
#lastMovePoint = { x: 0, y: 0 };
|
||||
constructor(page) {
|
||||
super();
|
||||
this.#page = page;
|
||||
}
|
||||
async reset() {
|
||||
this.#lastMovePoint = { x: 0, y: 0 };
|
||||
await this.#page.mainFrame().browsingContext.releaseActions();
|
||||
}
|
||||
async move(x, y, options = {}) {
|
||||
const from = this.#lastMovePoint;
|
||||
const to = {
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
};
|
||||
const actions = [];
|
||||
const steps = options.steps ?? 0;
|
||||
for (let i = 0; i < steps; ++i) {
|
||||
actions.push({
|
||||
type: ActionType.PointerMove,
|
||||
x: from.x + (to.x - from.x) * (i / steps),
|
||||
y: from.y + (to.y - from.y) * (i / steps),
|
||||
origin: options.origin,
|
||||
});
|
||||
}
|
||||
actions.push({
|
||||
type: ActionType.PointerMove,
|
||||
...to,
|
||||
origin: options.origin,
|
||||
});
|
||||
// https://w3c.github.io/webdriver-bidi/#command-input-performActions:~:text=input.PointerMoveAction%20%3D%20%7B%0A%20%20type%3A%20%22pointerMove%22%2C%0A%20%20x%3A%20js%2Dint%2C
|
||||
this.#lastMovePoint = to;
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Pointer,
|
||||
id: "__puppeteer_mouse" /* InputId.Mouse */,
|
||||
actions,
|
||||
},
|
||||
]);
|
||||
}
|
||||
async down(options = {}) {
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Pointer,
|
||||
id: "__puppeteer_mouse" /* InputId.Mouse */,
|
||||
actions: [
|
||||
{
|
||||
type: ActionType.PointerDown,
|
||||
button: getBidiButton(options.button ?? MouseButton.Left),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
async up(options = {}) {
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Pointer,
|
||||
id: "__puppeteer_mouse" /* InputId.Mouse */,
|
||||
actions: [
|
||||
{
|
||||
type: ActionType.PointerUp,
|
||||
button: getBidiButton(options.button ?? MouseButton.Left),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
async click(x, y, options = {}) {
|
||||
const actions = [
|
||||
{
|
||||
type: ActionType.PointerMove,
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
origin: options.origin,
|
||||
},
|
||||
];
|
||||
const pointerDownAction = {
|
||||
type: ActionType.PointerDown,
|
||||
button: getBidiButton(options.button ?? MouseButton.Left),
|
||||
};
|
||||
const pointerUpAction = {
|
||||
type: ActionType.PointerUp,
|
||||
button: pointerDownAction.button,
|
||||
};
|
||||
for (let i = 1; i < (options.count ?? 1); ++i) {
|
||||
actions.push(pointerDownAction, pointerUpAction);
|
||||
}
|
||||
actions.push(pointerDownAction);
|
||||
if (options.delay) {
|
||||
actions.push({
|
||||
type: ActionType.Pause,
|
||||
duration: options.delay,
|
||||
});
|
||||
}
|
||||
actions.push(pointerUpAction);
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Pointer,
|
||||
id: "__puppeteer_mouse" /* InputId.Mouse */,
|
||||
actions,
|
||||
},
|
||||
]);
|
||||
}
|
||||
async wheel(options = {}) {
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Wheel,
|
||||
id: "__puppeteer_wheel" /* InputId.Wheel */,
|
||||
actions: [
|
||||
{
|
||||
type: ActionType.Scroll,
|
||||
...(this.#lastMovePoint ?? {
|
||||
x: 0,
|
||||
y: 0,
|
||||
}),
|
||||
deltaX: options.deltaX ?? 0,
|
||||
deltaY: options.deltaY ?? 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
drag() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
dragOver() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
dragEnter() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
drop() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
dragAndDrop() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class BidiTouchHandle {
|
||||
#started = false;
|
||||
#x;
|
||||
#y;
|
||||
#bidiId;
|
||||
#page;
|
||||
#touchScreen;
|
||||
#properties;
|
||||
constructor(page, touchScreen, id, x, y, properties) {
|
||||
this.#page = page;
|
||||
this.#touchScreen = touchScreen;
|
||||
this.#x = Math.round(x);
|
||||
this.#y = Math.round(y);
|
||||
this.#properties = properties;
|
||||
this.#bidiId = `${"__puppeteer_finger" /* InputId.Finger */}_${id}`;
|
||||
}
|
||||
async start(options = {}) {
|
||||
if (this.#started) {
|
||||
throw new TouchError('Touch has already started');
|
||||
}
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Pointer,
|
||||
id: this.#bidiId,
|
||||
parameters: {
|
||||
pointerType: "touch" /* Bidi.Input.PointerType.Touch */,
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
type: ActionType.PointerMove,
|
||||
x: this.#x,
|
||||
y: this.#y,
|
||||
origin: options.origin,
|
||||
},
|
||||
{
|
||||
...this.#properties,
|
||||
type: ActionType.PointerDown,
|
||||
button: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
this.#started = true;
|
||||
}
|
||||
move(x, y) {
|
||||
const newX = Math.round(x);
|
||||
const newY = Math.round(y);
|
||||
return this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Pointer,
|
||||
id: this.#bidiId,
|
||||
parameters: {
|
||||
pointerType: "touch" /* Bidi.Input.PointerType.Touch */,
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
...this.#properties,
|
||||
type: ActionType.PointerMove,
|
||||
x: newX,
|
||||
y: newY,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
async end() {
|
||||
await this.#page.mainFrame().browsingContext.performActions([
|
||||
{
|
||||
type: SourceActionsType.Pointer,
|
||||
id: this.#bidiId,
|
||||
parameters: {
|
||||
pointerType: "touch" /* Bidi.Input.PointerType.Touch */,
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
type: ActionType.PointerUp,
|
||||
button: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
this.#touchScreen.removeHandle(this);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiTouchscreen extends Touchscreen {
|
||||
#page;
|
||||
constructor(page) {
|
||||
super();
|
||||
this.#page = page;
|
||||
}
|
||||
async touchStart(x, y, options = {}) {
|
||||
const id = this.idGenerator();
|
||||
const properties = {
|
||||
width: 0.5 * 2, // 2 times default touch radius.
|
||||
height: 0.5 * 2, // 2 times default touch radius.
|
||||
pressure: 0.5,
|
||||
};
|
||||
const touch = new BidiTouchHandle(this.#page, this, id, x, y, properties);
|
||||
await touch.start(options);
|
||||
this.touches.push(touch);
|
||||
return touch;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Input.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Input.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
28
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.d.ts
generated
vendored
Normal file
28
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { ElementHandle } from '../api/ElementHandle.js';
|
||||
import { JSHandle } from '../api/JSHandle.js';
|
||||
import type { BidiRealm } from './Realm.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiJSHandle<T = unknown> extends JSHandle<T> {
|
||||
#private;
|
||||
static from<T>(value: Bidi.Script.RemoteValue, realm: BidiRealm): BidiJSHandle<T>;
|
||||
readonly realm: BidiRealm;
|
||||
constructor(value: Bidi.Script.RemoteValue, realm: BidiRealm);
|
||||
get disposed(): boolean;
|
||||
jsonValue(): Promise<T>;
|
||||
asElement(): ElementHandle<Node> | null;
|
||||
dispose(): Promise<void>;
|
||||
get isPrimitiveValue(): boolean;
|
||||
toString(): string;
|
||||
get id(): string | undefined;
|
||||
remoteValue(): Bidi.Script.RemoteValue;
|
||||
remoteObject(): never;
|
||||
}
|
||||
//# sourceMappingURL=JSHandle.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"JSHandle.d.ts","sourceRoot":"","sources":["../../../src/bidi/JSHandle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAI5C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;;IACxD,MAAM,CAAC,IAAI,CAAC,CAAC,EACX,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAC9B,KAAK,EAAE,SAAS,GACf,YAAY,CAAC,CAAC,CAAC;IAMlB,SAAkB,KAAK,EAAE,SAAS,CAAC;gBAIvB,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,SAAS;IAM5D,IAAa,QAAQ,IAAI,OAAO,CAE/B;IAEc,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC;IAM7B,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI;IAIjC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQvC,IAAI,gBAAgB,IAAI,OAAO,CAa9B;IAEQ,QAAQ,IAAI,MAAM;IAQ3B,IAAa,EAAE,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW;IAI7B,YAAY,IAAI,KAAK;CAG/B"}
|
||||
71
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.js
generated
vendored
Normal file
71
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { JSHandle } from '../api/JSHandle.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { BidiDeserializer } from './Deserializer.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiJSHandle extends JSHandle {
|
||||
static from(value, realm) {
|
||||
return new BidiJSHandle(value, realm);
|
||||
}
|
||||
#remoteValue;
|
||||
realm;
|
||||
#disposed = false;
|
||||
constructor(value, realm) {
|
||||
super();
|
||||
this.#remoteValue = value;
|
||||
this.realm = realm;
|
||||
}
|
||||
get disposed() {
|
||||
return this.#disposed;
|
||||
}
|
||||
async jsonValue() {
|
||||
return await this.evaluate(value => {
|
||||
return value;
|
||||
});
|
||||
}
|
||||
asElement() {
|
||||
return null;
|
||||
}
|
||||
async dispose() {
|
||||
if (this.#disposed) {
|
||||
return;
|
||||
}
|
||||
this.#disposed = true;
|
||||
await this.realm.destroyHandles([this]);
|
||||
}
|
||||
get isPrimitiveValue() {
|
||||
switch (this.#remoteValue.type) {
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'bigint':
|
||||
case 'boolean':
|
||||
case 'undefined':
|
||||
case 'null':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
toString() {
|
||||
if (this.isPrimitiveValue) {
|
||||
return 'JSHandle:' + BidiDeserializer.deserialize(this.#remoteValue);
|
||||
}
|
||||
return 'JSHandle@' + this.#remoteValue.type;
|
||||
}
|
||||
get id() {
|
||||
return 'handle' in this.#remoteValue ? this.#remoteValue.handle : undefined;
|
||||
}
|
||||
remoteValue() {
|
||||
return this.#remoteValue;
|
||||
}
|
||||
remoteObject() {
|
||||
throw new UnsupportedOperation('Not available in WebDriver BiDi');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=JSHandle.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/JSHandle.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"JSHandle.js","sourceRoot":"","sources":["../../../src/bidi/JSHandle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAGnD;;GAEG;AACH,MAAM,OAAO,YAA0B,SAAQ,QAAW;IACxD,MAAM,CAAC,IAAI,CACT,KAA8B,EAC9B,KAAgB;QAEhB,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAEQ,YAAY,CAA0B;IAE7B,KAAK,CAAY;IAEnC,SAAS,GAAG,KAAK,CAAC;IAElB,YAAY,KAA8B,EAAE,KAAgB;QAC1D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,IAAa,QAAQ;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEQ,KAAK,CAAC,SAAS;QACtB,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACjC,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,SAAS;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,KAAK,CAAC,OAAO;QACpB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,gBAAgB;QAClB,QAAQ,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;YAC/B,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ,CAAC;YACd,KAAK,SAAS,CAAC;YACf,KAAK,WAAW,CAAC;YACjB,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC;YAEd;gBACE,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IAEQ,QAAQ;QACf,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,OAAO,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvE,CAAC;QAED,OAAO,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;IAC9C,CAAC;IAED,IAAa,EAAE;QACb,OAAO,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAEQ,YAAY;QACnB,MAAM,IAAI,oBAAoB,CAAC,iCAAiC,CAAC,CAAC;IACpE,CAAC;CACF"}
|
||||
154
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.d.ts
generated
vendored
Normal file
154
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.d.ts
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type Protocol from 'devtools-protocol';
|
||||
import * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { BluetoothEmulation } from '../api/BluetoothEmulation.js';
|
||||
import type { WindowId } from '../api/Browser.js';
|
||||
import type { CDPSession } from '../api/CDPSession.js';
|
||||
import type { DeviceRequestPrompt } from '../api/DeviceRequestPrompt.js';
|
||||
import type { Extension } from '../api/Extension.js';
|
||||
import type { WaitForOptions } from '../api/Frame.js';
|
||||
import type { HTTPResponse } from '../api/HTTPResponse.js';
|
||||
import type { Credentials, GeolocationOptions, HeapSnapshotOptions, MediaFeature, PageEvents, ReloadOptions, WaitTimeoutOptions } from '../api/Page.js';
|
||||
import { Page, type NewDocumentScriptEvaluation, type ScreenshotOptions } from '../api/Page.js';
|
||||
import type { Target } from '../api/Target.js';
|
||||
import { Coverage } from '../cdp/Coverage.js';
|
||||
import type { NetworkConditions } from '../cdp/NetworkManager.js';
|
||||
import { Tracing } from '../cdp/Tracing.js';
|
||||
import type { WebMCP } from '../cdp/WebMCP.js';
|
||||
import type { CookiePartitionKey, Cookie, CookieParam, CookieSameSite, DeleteCookiesRequest } from '../common/Cookie.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { FileChooser } from '../common/FileChooser.js';
|
||||
import type { PDFOptions } from '../common/PDFOptions.js';
|
||||
import type { Awaitable } from '../common/types.js';
|
||||
import type { Viewport } from '../common/Viewport.js';
|
||||
import type { Realm } from '../puppeteer-core.js';
|
||||
import type { BidiBrowser } from './Browser.js';
|
||||
import type { BidiBrowserContext } from './BrowserContext.js';
|
||||
import type { BidiCdpSession } from './CDPSession.js';
|
||||
import type { BrowsingContext } from './core/BrowsingContext.js';
|
||||
import { BidiFrame } from './Frame.js';
|
||||
import type { BidiHTTPResponse } from './HTTPResponse.js';
|
||||
import { BidiKeyboard, BidiMouse, BidiTouchscreen } from './Input.js';
|
||||
import type { BidiJSHandle } from './JSHandle.js';
|
||||
import type { BidiWebWorker } from './WebWorker.js';
|
||||
/**
|
||||
* Implements Page using WebDriver BiDi.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiPage extends Page {
|
||||
#private;
|
||||
static from(browserContext: BidiBrowserContext, browsingContext: BrowsingContext): BidiPage;
|
||||
accessor trustedEmitter: EventEmitter<PageEvents>;
|
||||
readonly keyboard: BidiKeyboard;
|
||||
readonly mouse: BidiMouse;
|
||||
readonly touchscreen: BidiTouchscreen;
|
||||
readonly tracing: Tracing;
|
||||
get webmcp(): WebMCP;
|
||||
readonly coverage: Coverage;
|
||||
_client(): BidiCdpSession;
|
||||
private constructor();
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
setUserAgent(userAgentOrOptions: string | {
|
||||
userAgent?: string;
|
||||
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata;
|
||||
platform?: string;
|
||||
}, userAgentMetadata?: Protocol.Emulation.UserAgentMetadata): Promise<void>;
|
||||
setBypassCSP(enabled: boolean): Promise<void>;
|
||||
queryObjects<Prototype>(prototypeHandle: BidiJSHandle<Prototype>): Promise<BidiJSHandle<Prototype[]>>;
|
||||
browser(): BidiBrowser;
|
||||
browserContext(): BidiBrowserContext;
|
||||
mainFrame(): BidiFrame;
|
||||
triggerExtensionAction(_extension: Extension): Promise<void>;
|
||||
emulateFocusedPage(enabled: boolean): Promise<void>;
|
||||
resize(_params: {
|
||||
contentWidth: number;
|
||||
contentHeight: number;
|
||||
}): Promise<void>;
|
||||
windowId(): Promise<WindowId>;
|
||||
openDevTools(): Promise<Page>;
|
||||
hasDevTools(): Promise<boolean>;
|
||||
focusedFrame(): Promise<BidiFrame>;
|
||||
frames(): BidiFrame[];
|
||||
isClosed(): boolean;
|
||||
close(options?: {
|
||||
runBeforeUnload?: boolean;
|
||||
}): Promise<void>;
|
||||
reload(options?: ReloadOptions): Promise<BidiHTTPResponse | null>;
|
||||
setDefaultNavigationTimeout(timeout: number): void;
|
||||
setDefaultTimeout(timeout: number): void;
|
||||
getDefaultTimeout(): number;
|
||||
getDefaultNavigationTimeout(): number;
|
||||
isJavaScriptEnabled(): boolean;
|
||||
setGeolocation(options: GeolocationOptions): Promise<void>;
|
||||
setJavaScriptEnabled(enabled: boolean): Promise<void>;
|
||||
emulateMediaType(type?: string): Promise<void>;
|
||||
emulateCPUThrottling(factor: number | null): Promise<void>;
|
||||
emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
|
||||
emulateTimezone(timezoneId?: string): Promise<void>;
|
||||
emulateIdleState(overrides?: {
|
||||
isUserActive: boolean;
|
||||
isScreenUnlocked: boolean;
|
||||
}): Promise<void>;
|
||||
emulateVisionDeficiency(type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']): Promise<void>;
|
||||
setViewport(viewport: Viewport | null): Promise<void>;
|
||||
viewport(): Viewport | null;
|
||||
pdf(options?: PDFOptions): Promise<Uint8Array>;
|
||||
createPDFStream(options?: PDFOptions | undefined): Promise<ReadableStream<Uint8Array>>;
|
||||
_screenshot(options: Readonly<ScreenshotOptions>): Promise<string>;
|
||||
createCDPSession(): Promise<CDPSession>;
|
||||
bringToFront(): Promise<void>;
|
||||
evaluateOnNewDocument<Params extends unknown[], Func extends (...args: Params) => unknown = (...args: Params) => unknown>(pageFunction: Func | string, ...args: Params): Promise<NewDocumentScriptEvaluation>;
|
||||
removeScriptToEvaluateOnNewDocument(id: string): Promise<void>;
|
||||
exposeFunction<Args extends unknown[], Ret>(name: string, pptrFunction: ((...args: Args) => Awaitable<Ret>) | {
|
||||
default: (...args: Args) => Awaitable<Ret>;
|
||||
}): Promise<void>;
|
||||
isDragInterceptionEnabled(): boolean;
|
||||
setCacheEnabled(enabled?: boolean): Promise<void>;
|
||||
cookies(...urls: string[]): Promise<Cookie[]>;
|
||||
isServiceWorkerBypassed(): never;
|
||||
target(): Target;
|
||||
waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>;
|
||||
workers(): BidiWebWorker[];
|
||||
get isNetworkInterceptionEnabled(): boolean;
|
||||
setRequestInterception(enable: boolean): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_credentials: Credentials | null;
|
||||
authenticate(credentials: Credentials | null): Promise<void>;
|
||||
setDragInterception(): never;
|
||||
setBypassServiceWorker(): never;
|
||||
setOfflineMode(enabled: boolean): Promise<void>;
|
||||
emulateNetworkConditions(networkConditions: NetworkConditions | null): Promise<void>;
|
||||
setCookie(...cookies: CookieParam[]): Promise<void>;
|
||||
deleteCookie(...cookies: DeleteCookiesRequest[]): Promise<void>;
|
||||
removeExposedFunction(name: string): Promise<void>;
|
||||
metrics(): never;
|
||||
captureHeapSnapshot(_options: HeapSnapshotOptions): Promise<void>;
|
||||
goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
|
||||
goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
|
||||
waitForDevicePrompt(options?: WaitTimeoutOptions): Promise<DeviceRequestPrompt>;
|
||||
get bluetooth(): BluetoothEmulation;
|
||||
extensionRealms(): Realm[];
|
||||
}
|
||||
export declare function bidiToPuppeteerCookie(bidiCookie: Bidi.Network.Cookie, returnCompositePartitionKey?: boolean): Cookie;
|
||||
/**
|
||||
* Gets CDP-specific properties from the cookie, adds CDP-specific prefixes and returns
|
||||
* them as a new object which can be used in BiDi.
|
||||
*/
|
||||
export declare function cdpSpecificCookiePropertiesFromPuppeteerToBidi(cookieParam: CookieParam, ...propertyNames: Array<keyof CookieParam>): Record<string, unknown>;
|
||||
export declare function convertCookiesSameSiteCdpToBiDi(sameSite: CookieSameSite | undefined): Bidi.Network.SameSite;
|
||||
export declare function convertCookiesExpiryCdpToBiDi(expiry: number | undefined): number | undefined;
|
||||
export declare function convertCookiesPartitionKeyFromPuppeteerToBiDi(partitionKey: CookiePartitionKey | string | undefined): string | undefined;
|
||||
//# sourceMappingURL=Page.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
974
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.js
generated
vendored
Normal file
974
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.js
generated
vendored
Normal file
@@ -0,0 +1,974 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose, inner;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
if (async) inner = dispose;
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
};
|
||||
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
||||
return function (env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
var r, s = 0;
|
||||
function next() {
|
||||
while (r = env.stack.pop()) {
|
||||
try {
|
||||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
||||
if (r.dispose) {
|
||||
var result = r.dispose.call(r.value);
|
||||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
else s |= 1;
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
};
|
||||
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
});
|
||||
import { firstValueFrom, from, raceWith } from '../../third_party/rxjs/rxjs.js';
|
||||
import { Page, } from '../api/Page.js';
|
||||
import { Coverage } from '../cdp/Coverage.js';
|
||||
import { EmulationManager } from '../cdp/EmulationManager.js';
|
||||
import { Tracing } from '../cdp/Tracing.js';
|
||||
import { ProtocolError, UnsupportedOperation } from '../common/Errors.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { FileChooser } from '../common/FileChooser.js';
|
||||
import { evaluationString, parsePDFOptions, timeout } from '../common/util.js';
|
||||
import { assert } from '../util/assert.js';
|
||||
import { bubble } from '../util/decorators.js';
|
||||
import { Deferred } from '../util/Deferred.js';
|
||||
import { stringToTypedArray } from '../util/encoding.js';
|
||||
import { BidiElementHandle } from './ElementHandle.js';
|
||||
import { BidiFrame } from './Frame.js';
|
||||
import { BidiKeyboard, BidiMouse, BidiTouchscreen } from './Input.js';
|
||||
import { rewriteNavigationError } from './util.js';
|
||||
/**
|
||||
* Implements Page using WebDriver BiDi.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
let BidiPage = (() => {
|
||||
let _classSuper = Page;
|
||||
let _trustedEmitter_decorators;
|
||||
let _trustedEmitter_initializers = [];
|
||||
let _trustedEmitter_extraInitializers = [];
|
||||
return class BidiPage extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_trustedEmitter_decorators = [bubble()];
|
||||
__esDecorate(this, null, _trustedEmitter_decorators, { kind: "accessor", name: "trustedEmitter", static: false, private: false, access: { has: obj => "trustedEmitter" in obj, get: obj => obj.trustedEmitter, set: (obj, value) => { obj.trustedEmitter = value; } }, metadata: _metadata }, _trustedEmitter_initializers, _trustedEmitter_extraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
static from(browserContext, browsingContext) {
|
||||
const page = new BidiPage(browserContext, browsingContext);
|
||||
page.#initialize();
|
||||
return page;
|
||||
}
|
||||
#trustedEmitter_accessor_storage = __runInitializers(this, _trustedEmitter_initializers, new EventEmitter());
|
||||
get trustedEmitter() { return this.#trustedEmitter_accessor_storage; }
|
||||
set trustedEmitter(value) { this.#trustedEmitter_accessor_storage = value; }
|
||||
#browserContext = __runInitializers(this, _trustedEmitter_extraInitializers);
|
||||
#frame;
|
||||
#viewport = null;
|
||||
#workers = new Set();
|
||||
keyboard;
|
||||
mouse;
|
||||
touchscreen;
|
||||
tracing;
|
||||
get webmcp() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
coverage;
|
||||
#cdpEmulationManager;
|
||||
#emulatedNetworkConditions;
|
||||
#fileChooserDeferreds = new Set();
|
||||
_client() {
|
||||
return this.#frame.client;
|
||||
}
|
||||
constructor(browserContext, browsingContext) {
|
||||
super();
|
||||
this.#browserContext = browserContext;
|
||||
this.#frame = BidiFrame.from(this, browsingContext);
|
||||
this.#cdpEmulationManager = new EmulationManager(this.#frame.client);
|
||||
this.tracing = new Tracing(this.#frame.client);
|
||||
this.coverage = new Coverage(this.#frame.client);
|
||||
this.keyboard = new BidiKeyboard(this);
|
||||
this.mouse = new BidiMouse(this);
|
||||
this.touchscreen = new BidiTouchscreen(this);
|
||||
}
|
||||
#initialize() {
|
||||
this.#frame.browsingContext.on('closed', () => {
|
||||
this.trustedEmitter.emit("close" /* PageEvent.Close */, undefined);
|
||||
this.trustedEmitter.removeAllListeners();
|
||||
});
|
||||
this.trustedEmitter.on("workercreated" /* PageEvent.WorkerCreated */, worker => {
|
||||
this.#workers.add(worker);
|
||||
});
|
||||
this.trustedEmitter.on("workerdestroyed" /* PageEvent.WorkerDestroyed */, worker => {
|
||||
this.#workers.delete(worker);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async setUserAgent(userAgentOrOptions, userAgentMetadata) {
|
||||
let userAgent;
|
||||
let clientHints;
|
||||
let platform;
|
||||
if (typeof userAgentOrOptions === 'string') {
|
||||
userAgent = userAgentOrOptions;
|
||||
clientHints = userAgentMetadata;
|
||||
}
|
||||
else {
|
||||
userAgent = userAgentOrOptions.userAgent ?? null;
|
||||
clientHints = userAgentOrOptions.userAgentMetadata;
|
||||
// Empty string platform should be interpreted as "no override".
|
||||
platform =
|
||||
userAgentOrOptions.platform === ''
|
||||
? undefined
|
||||
: userAgentOrOptions.platform;
|
||||
}
|
||||
if (userAgent === '') {
|
||||
// In WebDriver BiDi null is used to restore the original user agent.
|
||||
userAgent = null;
|
||||
}
|
||||
await this.#frame.browsingContext.setUserAgent(userAgent);
|
||||
if (platform && platform !== '') {
|
||||
// Work-around until https://github.com/w3c/webdriver-bidi/issues/1065 is resolved.
|
||||
// Set platform via client hints override.
|
||||
clientHints = clientHints ?? {};
|
||||
clientHints.platform = platform;
|
||||
}
|
||||
await this.#frame.browsingContext.setClientHintsOverride(clientHints ?? null);
|
||||
}
|
||||
async setBypassCSP(enabled) {
|
||||
// TODO: handle CDP-specific cases such as MPArch.
|
||||
await this._client().send('Page.setBypassCSP', { enabled });
|
||||
}
|
||||
async queryObjects(prototypeHandle) {
|
||||
assert(!prototypeHandle.disposed, 'Prototype JSHandle is disposed!');
|
||||
assert(prototypeHandle.id, 'Prototype JSHandle must not be referencing primitive value');
|
||||
const response = await this.#frame.client.send('Runtime.queryObjects', {
|
||||
prototypeObjectId: prototypeHandle.id,
|
||||
});
|
||||
return this.#frame.mainRealm().createHandle({
|
||||
type: 'array',
|
||||
handle: response.objects.objectId,
|
||||
});
|
||||
}
|
||||
browser() {
|
||||
return this.browserContext().browser();
|
||||
}
|
||||
browserContext() {
|
||||
return this.#browserContext;
|
||||
}
|
||||
mainFrame() {
|
||||
return this.#frame;
|
||||
}
|
||||
async triggerExtensionAction(_extension) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async emulateFocusedPage(enabled) {
|
||||
return await this.#cdpEmulationManager.emulateFocus(enabled);
|
||||
}
|
||||
resize(_params) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async windowId() {
|
||||
return this.#frame.browsingContext.windowId;
|
||||
}
|
||||
openDevTools() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
hasDevTools() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async focusedFrame() {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_1, (await this.mainFrame()
|
||||
.isolatedRealm()
|
||||
.evaluateHandle(() => {
|
||||
let win = window;
|
||||
while (win.document.activeElement instanceof win.HTMLIFrameElement ||
|
||||
win.document.activeElement instanceof win.HTMLFrameElement) {
|
||||
if (win.document.activeElement.contentWindow === null) {
|
||||
break;
|
||||
}
|
||||
win = win.document.activeElement.contentWindow;
|
||||
}
|
||||
return win;
|
||||
})), false);
|
||||
const value = handle.remoteValue();
|
||||
assert(value.type === 'window');
|
||||
const frame = this.frames().find(frame => {
|
||||
return frame._id === value.value.context;
|
||||
});
|
||||
assert(frame);
|
||||
return frame;
|
||||
}
|
||||
catch (e_1) {
|
||||
env_1.error = e_1;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
frames() {
|
||||
const frames = [this.#frame];
|
||||
for (const frame of frames) {
|
||||
frames.push(...frame.childFrames());
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
isClosed() {
|
||||
return this.#frame.detached;
|
||||
}
|
||||
async close(options) {
|
||||
const env_2 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const _guard = __addDisposableResource(env_2, await this.#browserContext.waitForScreenshotOperations(), false);
|
||||
try {
|
||||
await this.#frame.browsingContext.close(options?.runBeforeUnload);
|
||||
}
|
||||
catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (e_2) {
|
||||
env_2.error = e_2;
|
||||
env_2.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_2);
|
||||
}
|
||||
}
|
||||
async reload(options = {}) {
|
||||
const [response] = await Promise.all([
|
||||
this.#frame.waitForNavigation(options),
|
||||
this.#frame.browsingContext.reload({
|
||||
ignoreCache: options.ignoreCache ? true : undefined,
|
||||
}),
|
||||
]).catch(rewriteNavigationError(this.url(), options.timeout ?? this._timeoutSettings.navigationTimeout()));
|
||||
return response;
|
||||
}
|
||||
setDefaultNavigationTimeout(timeout) {
|
||||
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
||||
}
|
||||
setDefaultTimeout(timeout) {
|
||||
this._timeoutSettings.setDefaultTimeout(timeout);
|
||||
}
|
||||
getDefaultTimeout() {
|
||||
return this._timeoutSettings.timeout();
|
||||
}
|
||||
getDefaultNavigationTimeout() {
|
||||
return this._timeoutSettings.navigationTimeout();
|
||||
}
|
||||
isJavaScriptEnabled() {
|
||||
return this.#frame.browsingContext.isJavaScriptEnabled();
|
||||
}
|
||||
async setGeolocation(options) {
|
||||
const { longitude, latitude, accuracy = 0 } = options;
|
||||
if (longitude < -180 || longitude > 180) {
|
||||
throw new Error(`Invalid longitude "${longitude}": precondition -180 <= LONGITUDE <= 180 failed.`);
|
||||
}
|
||||
if (latitude < -90 || latitude > 90) {
|
||||
throw new Error(`Invalid latitude "${latitude}": precondition -90 <= LATITUDE <= 90 failed.`);
|
||||
}
|
||||
if (accuracy < 0) {
|
||||
throw new Error(`Invalid accuracy "${accuracy}": precondition 0 <= ACCURACY failed.`);
|
||||
}
|
||||
return await this.#frame.browsingContext.setGeolocationOverride({
|
||||
coordinates: {
|
||||
latitude: options.latitude,
|
||||
longitude: options.longitude,
|
||||
accuracy: options.accuracy,
|
||||
},
|
||||
});
|
||||
}
|
||||
async setJavaScriptEnabled(enabled) {
|
||||
return await this.#frame.browsingContext.setJavaScriptEnabled(enabled);
|
||||
}
|
||||
async emulateMediaType(type) {
|
||||
return await this.#cdpEmulationManager.emulateMediaType(type);
|
||||
}
|
||||
async emulateCPUThrottling(factor) {
|
||||
return await this.#cdpEmulationManager.emulateCPUThrottling(factor);
|
||||
}
|
||||
async emulateMediaFeatures(features) {
|
||||
return await this.#cdpEmulationManager.emulateMediaFeatures(features);
|
||||
}
|
||||
async emulateTimezone(timezoneId) {
|
||||
return await this.#frame.browsingContext.setTimezoneOverride(timezoneId);
|
||||
}
|
||||
async emulateIdleState(overrides) {
|
||||
return await this.#cdpEmulationManager.emulateIdleState(overrides);
|
||||
}
|
||||
async emulateVisionDeficiency(type) {
|
||||
return await this.#cdpEmulationManager.emulateVisionDeficiency(type);
|
||||
}
|
||||
async setViewport(viewport) {
|
||||
let needsReload = false;
|
||||
if (!this.browser().cdpSupported) {
|
||||
const viewportSize = viewport?.width && viewport?.height
|
||||
? {
|
||||
width: viewport.width,
|
||||
height: viewport.height,
|
||||
}
|
||||
: null;
|
||||
const devicePixelRatio = viewport?.deviceScaleFactor
|
||||
? viewport.deviceScaleFactor
|
||||
: null;
|
||||
// If `viewport` is not set, remove screen orientation override.
|
||||
const screenOrientation = viewport
|
||||
? viewport.isLandscape
|
||||
? {
|
||||
natural: "landscape" /* Bidi.Emulation.ScreenOrientationNatural.Landscape */,
|
||||
type: 'landscape-primary',
|
||||
}
|
||||
: {
|
||||
natural: "portrait" /* Bidi.Emulation.ScreenOrientationNatural.Portrait */,
|
||||
type: 'portrait-primary',
|
||||
}
|
||||
: null;
|
||||
const commands = [
|
||||
this.#frame.browsingContext.setViewport({
|
||||
viewport: viewportSize,
|
||||
devicePixelRatio,
|
||||
}),
|
||||
this.#frame.browsingContext.setScreenOrientationOverride(screenOrientation),
|
||||
];
|
||||
if ((this.#viewport?.hasTouch ?? false) !== (viewport?.hasTouch ?? false)) {
|
||||
// The requested touch override state is different from the current one, meaning
|
||||
// the reload is needed.
|
||||
needsReload = true;
|
||||
// 1 touch point if touch is enabled, null otherwise.
|
||||
const maxTouchPoints = viewport?.hasTouch ? 1 : null;
|
||||
commands.push(this.#frame.browsingContext
|
||||
.setTouchOverride(maxTouchPoints)
|
||||
.catch(error => {
|
||||
if (error instanceof ProtocolError &&
|
||||
(error.message.includes('unknown command') ||
|
||||
error.message.includes('unsupported operation'))) {
|
||||
// Tolerate not implemented or not supported commands. At least until
|
||||
// the `emulation.setTouchOverride` is supported by all the supported
|
||||
// browsers.
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}));
|
||||
}
|
||||
await Promise.all(commands);
|
||||
}
|
||||
else {
|
||||
needsReload = await this.#cdpEmulationManager.emulateViewport(viewport);
|
||||
}
|
||||
this.#viewport = viewport;
|
||||
if (needsReload) {
|
||||
await this.reload();
|
||||
}
|
||||
}
|
||||
viewport() {
|
||||
return this.#viewport;
|
||||
}
|
||||
async pdf(options = {}) {
|
||||
const { timeout: ms = this._timeoutSettings.timeout(), path = undefined } = options;
|
||||
const { printBackground: background, margin, landscape, width, height, pageRanges: ranges, scale, preferCSSPageSize, } = parsePDFOptions(options, 'cm');
|
||||
const pageRanges = ranges ? ranges.split(', ') : [];
|
||||
await firstValueFrom(from(this.mainFrame()
|
||||
.isolatedRealm()
|
||||
.evaluate(() => {
|
||||
return document.fonts.ready;
|
||||
})).pipe(raceWith(timeout(ms))));
|
||||
const data = await firstValueFrom(from(this.#frame.browsingContext.print({
|
||||
background,
|
||||
margin,
|
||||
orientation: landscape ? 'landscape' : 'portrait',
|
||||
page: {
|
||||
width,
|
||||
height,
|
||||
},
|
||||
pageRanges,
|
||||
scale,
|
||||
shrinkToFit: !preferCSSPageSize,
|
||||
})).pipe(raceWith(timeout(ms))));
|
||||
const typedArray = stringToTypedArray(data, true);
|
||||
await this._maybeWriteTypedArrayToFile(path, typedArray);
|
||||
return typedArray;
|
||||
}
|
||||
async createPDFStream(options) {
|
||||
const typedArray = await this.pdf(options);
|
||||
return new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue(typedArray);
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
}
|
||||
async _screenshot(options) {
|
||||
const { clip, type, captureBeyondViewport, quality } = options;
|
||||
if (options.omitBackground !== undefined && options.omitBackground) {
|
||||
throw new UnsupportedOperation(`BiDi does not support 'omitBackground'.`);
|
||||
}
|
||||
if (options.optimizeForSpeed !== undefined && options.optimizeForSpeed) {
|
||||
throw new UnsupportedOperation(`BiDi does not support 'optimizeForSpeed'.`);
|
||||
}
|
||||
if (options.fromSurface !== undefined && !options.fromSurface) {
|
||||
throw new UnsupportedOperation(`BiDi does not support 'fromSurface'.`);
|
||||
}
|
||||
if (clip !== undefined && clip.scale !== undefined && clip.scale !== 1) {
|
||||
throw new UnsupportedOperation(`BiDi does not support 'scale' in 'clip'.`);
|
||||
}
|
||||
let box;
|
||||
if (clip) {
|
||||
if (captureBeyondViewport) {
|
||||
box = clip;
|
||||
}
|
||||
else {
|
||||
// The clip is always with respect to the document coordinates, so we
|
||||
// need to convert this to viewport coordinates when we aren't capturing
|
||||
// beyond the viewport.
|
||||
const [pageLeft, pageTop] = await this.evaluate(() => {
|
||||
if (!window.visualViewport) {
|
||||
throw new Error('window.visualViewport is not supported.');
|
||||
}
|
||||
return [
|
||||
window.visualViewport.pageLeft,
|
||||
window.visualViewport.pageTop,
|
||||
];
|
||||
});
|
||||
box = {
|
||||
...clip,
|
||||
x: clip.x - pageLeft,
|
||||
y: clip.y - pageTop,
|
||||
};
|
||||
}
|
||||
}
|
||||
const data = await this.#frame.browsingContext.captureScreenshot({
|
||||
origin: captureBeyondViewport ? 'document' : 'viewport',
|
||||
format: {
|
||||
type: `image/${type}`,
|
||||
...(quality !== undefined ? { quality: quality / 100 } : {}),
|
||||
},
|
||||
...(box ? { clip: { type: 'box', ...box } } : {}),
|
||||
});
|
||||
return data;
|
||||
}
|
||||
async createCDPSession() {
|
||||
return await this.#frame.createCDPSession();
|
||||
}
|
||||
async bringToFront() {
|
||||
await this.#frame.browsingContext.activate();
|
||||
}
|
||||
async evaluateOnNewDocument(pageFunction, ...args) {
|
||||
const expression = evaluationExpression(pageFunction, ...args);
|
||||
const script = await this.#frame.browsingContext.addPreloadScript(expression);
|
||||
return { identifier: script };
|
||||
}
|
||||
async removeScriptToEvaluateOnNewDocument(id) {
|
||||
await this.#frame.browsingContext.removePreloadScript(id);
|
||||
}
|
||||
async exposeFunction(name, pptrFunction) {
|
||||
return await this.mainFrame().exposeFunction(name, 'default' in pptrFunction ? pptrFunction.default : pptrFunction);
|
||||
}
|
||||
isDragInterceptionEnabled() {
|
||||
return false;
|
||||
}
|
||||
async setCacheEnabled(enabled) {
|
||||
if (!this.#browserContext.browser().cdpSupported) {
|
||||
await this.#frame.browsingContext.setCacheBehavior(enabled ? 'default' : 'bypass');
|
||||
return;
|
||||
}
|
||||
// TODO: handle CDP-specific cases such as MPArch.
|
||||
await this._client().send('Network.setCacheDisabled', {
|
||||
cacheDisabled: !enabled,
|
||||
});
|
||||
}
|
||||
async cookies(...urls) {
|
||||
const normalizedUrls = (urls.length ? urls : [this.url()]).map(url => {
|
||||
return new URL(url);
|
||||
});
|
||||
const cookies = await this.#frame.browsingContext.getCookies();
|
||||
return cookies
|
||||
.map(cookie => {
|
||||
return bidiToPuppeteerCookie(cookie);
|
||||
})
|
||||
.filter(cookie => {
|
||||
return normalizedUrls.some(url => {
|
||||
return testUrlMatchCookie(cookie, url);
|
||||
});
|
||||
});
|
||||
}
|
||||
isServiceWorkerBypassed() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
target() {
|
||||
const target = this.browserContext().getTargetForPage(this);
|
||||
if (!target) {
|
||||
throw new Error('Target not found for page');
|
||||
}
|
||||
return target;
|
||||
}
|
||||
async waitForFileChooser(options = {}) {
|
||||
const { timeout = this._timeoutSettings.timeout() } = options;
|
||||
const deferred = Deferred.create({
|
||||
message: `Waiting for \`FileChooser\` failed: ${timeout}ms exceeded`,
|
||||
timeout,
|
||||
});
|
||||
this.#fileChooserDeferreds.add(deferred);
|
||||
if (options.signal) {
|
||||
options.signal.addEventListener('abort', () => {
|
||||
deferred.reject(options.signal?.reason);
|
||||
}, { once: true });
|
||||
}
|
||||
this.#frame.browsingContext.once('filedialogopened', info => {
|
||||
if (!info.element) {
|
||||
return;
|
||||
}
|
||||
const chooser = new FileChooser(BidiElementHandle.from({
|
||||
sharedId: info.element.sharedId,
|
||||
handle: info.element.handle,
|
||||
type: 'node',
|
||||
}, this.#frame.mainRealm()), info.multiple);
|
||||
for (const deferred of this.#fileChooserDeferreds) {
|
||||
deferred.resolve(chooser);
|
||||
this.#fileChooserDeferreds.delete(deferred);
|
||||
}
|
||||
});
|
||||
try {
|
||||
return await deferred.valueOrThrow();
|
||||
}
|
||||
catch (error) {
|
||||
this.#fileChooserDeferreds.delete(deferred);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
workers() {
|
||||
return [...this.#workers];
|
||||
}
|
||||
get isNetworkInterceptionEnabled() {
|
||||
return (Boolean(this.#requestInterception) || Boolean(this.#authInterception));
|
||||
}
|
||||
#requestInterception;
|
||||
async setRequestInterception(enable) {
|
||||
this.#requestInterception = await this.#toggleInterception(["beforeRequestSent" /* Bidi.Network.InterceptPhase.BeforeRequestSent */], this.#requestInterception, enable);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async setExtraHTTPHeaders(headers) {
|
||||
await this.#frame.browsingContext.setExtraHTTPHeaders(headers);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_credentials = null;
|
||||
#authInterception;
|
||||
async authenticate(credentials) {
|
||||
this.#authInterception = await this.#toggleInterception(["authRequired" /* Bidi.Network.InterceptPhase.AuthRequired */], this.#authInterception, Boolean(credentials));
|
||||
this._credentials = credentials;
|
||||
}
|
||||
async #toggleInterception(phases, interception, expected) {
|
||||
if (expected && !interception) {
|
||||
return await this.#frame.browsingContext.addIntercept({
|
||||
phases,
|
||||
});
|
||||
}
|
||||
else if (!expected && interception) {
|
||||
await this.#frame.browsingContext.userContext.browser.removeIntercept(interception);
|
||||
return;
|
||||
}
|
||||
return interception;
|
||||
}
|
||||
setDragInterception() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
setBypassServiceWorker() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async setOfflineMode(enabled) {
|
||||
if (!this.#browserContext.browser().cdpSupported) {
|
||||
return await this.#frame.browsingContext.setOfflineMode(enabled);
|
||||
}
|
||||
if (!this.#emulatedNetworkConditions) {
|
||||
this.#emulatedNetworkConditions = {
|
||||
offline: false,
|
||||
upload: -1,
|
||||
download: -1,
|
||||
latency: 0,
|
||||
};
|
||||
}
|
||||
this.#emulatedNetworkConditions.offline = enabled;
|
||||
return await this.#applyNetworkConditions();
|
||||
}
|
||||
async emulateNetworkConditions(networkConditions) {
|
||||
if (!this.#browserContext.browser().cdpSupported) {
|
||||
if (!networkConditions?.offline &&
|
||||
((networkConditions?.upload ?? -1) >= 0 ||
|
||||
(networkConditions?.download ?? -1) >= 0 ||
|
||||
(networkConditions?.latency ?? 0) > 0)) {
|
||||
// WebDriver BiDi supports only offline mode.
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
return await this.#frame.browsingContext.setOfflineMode(networkConditions?.offline ?? false);
|
||||
}
|
||||
if (!this.#emulatedNetworkConditions) {
|
||||
this.#emulatedNetworkConditions = {
|
||||
offline: networkConditions?.offline ?? false,
|
||||
upload: -1,
|
||||
download: -1,
|
||||
latency: 0,
|
||||
};
|
||||
}
|
||||
this.#emulatedNetworkConditions.upload = networkConditions
|
||||
? networkConditions.upload
|
||||
: -1;
|
||||
this.#emulatedNetworkConditions.download = networkConditions
|
||||
? networkConditions.download
|
||||
: -1;
|
||||
this.#emulatedNetworkConditions.latency = networkConditions
|
||||
? networkConditions.latency
|
||||
: 0;
|
||||
this.#emulatedNetworkConditions.offline =
|
||||
networkConditions?.offline ?? false;
|
||||
return await this.#applyNetworkConditions();
|
||||
}
|
||||
async #applyNetworkConditions() {
|
||||
if (!this.#emulatedNetworkConditions) {
|
||||
return;
|
||||
}
|
||||
await this._client().send('Network.emulateNetworkConditions', {
|
||||
offline: this.#emulatedNetworkConditions.offline,
|
||||
latency: this.#emulatedNetworkConditions.latency,
|
||||
uploadThroughput: this.#emulatedNetworkConditions.upload,
|
||||
downloadThroughput: this.#emulatedNetworkConditions.download,
|
||||
});
|
||||
}
|
||||
async setCookie(...cookies) {
|
||||
const pageURL = this.url();
|
||||
const pageUrlStartsWithHTTP = pageURL.startsWith('http');
|
||||
for (const cookie of cookies) {
|
||||
let cookieUrl = cookie.url || '';
|
||||
if (!cookieUrl && pageUrlStartsWithHTTP) {
|
||||
cookieUrl = pageURL;
|
||||
}
|
||||
assert(cookieUrl !== 'about:blank', `Blank page can not have cookie "${cookie.name}"`);
|
||||
assert(!String.prototype.startsWith.call(cookieUrl || '', 'data:'), `Data URL page can not have cookie "${cookie.name}"`);
|
||||
// TODO: Support Chrome cookie partition keys
|
||||
assert(cookie.partitionKey === undefined ||
|
||||
typeof cookie.partitionKey === 'string', 'BiDi only allows domain partition keys');
|
||||
const normalizedUrl = URL.canParse(cookieUrl)
|
||||
? new URL(cookieUrl)
|
||||
: undefined;
|
||||
const domain = cookie.domain ?? normalizedUrl?.hostname;
|
||||
assert(domain !== undefined, `At least one of the url and domain needs to be specified`);
|
||||
const bidiCookie = {
|
||||
domain: domain,
|
||||
name: cookie.name,
|
||||
value: {
|
||||
type: 'string',
|
||||
value: cookie.value,
|
||||
},
|
||||
...(cookie.path !== undefined ? { path: cookie.path } : {}),
|
||||
...(cookie.httpOnly !== undefined ? { httpOnly: cookie.httpOnly } : {}),
|
||||
...(cookie.secure !== undefined ? { secure: cookie.secure } : {}),
|
||||
...(cookie.sameSite !== undefined
|
||||
? { sameSite: convertCookiesSameSiteCdpToBiDi(cookie.sameSite) }
|
||||
: {}),
|
||||
...{ expiry: convertCookiesExpiryCdpToBiDi(cookie.expires) },
|
||||
// Chrome-specific properties.
|
||||
...cdpSpecificCookiePropertiesFromPuppeteerToBidi(cookie, 'sourceScheme', 'priority', 'url'),
|
||||
};
|
||||
if (cookie.partitionKey !== undefined) {
|
||||
await this.browserContext().userContext.setCookie(bidiCookie, cookie.partitionKey);
|
||||
}
|
||||
else {
|
||||
await this.#frame.browsingContext.setCookie(bidiCookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
async deleteCookie(...cookies) {
|
||||
await Promise.all(cookies.map(async (deleteCookieRequest) => {
|
||||
const cookieUrl = deleteCookieRequest.url ?? this.url();
|
||||
const normalizedUrl = URL.canParse(cookieUrl)
|
||||
? new URL(cookieUrl)
|
||||
: undefined;
|
||||
const domain = deleteCookieRequest.domain ?? normalizedUrl?.hostname;
|
||||
assert(domain !== undefined, `At least one of the url and domain needs to be specified`);
|
||||
const filter = {
|
||||
domain: domain,
|
||||
name: deleteCookieRequest.name,
|
||||
...(deleteCookieRequest.path !== undefined
|
||||
? { path: deleteCookieRequest.path }
|
||||
: {}),
|
||||
};
|
||||
await this.#frame.browsingContext.deleteCookie(filter);
|
||||
}));
|
||||
}
|
||||
async removeExposedFunction(name) {
|
||||
await this.#frame.removeExposedFunction(name);
|
||||
}
|
||||
metrics() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async captureHeapSnapshot(_options) {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async goBack(options = {}) {
|
||||
return await this.#go(-1, options);
|
||||
}
|
||||
async goForward(options = {}) {
|
||||
return await this.#go(1, options);
|
||||
}
|
||||
async #go(delta, options) {
|
||||
const controller = new AbortController();
|
||||
try {
|
||||
const [response] = await Promise.all([
|
||||
this.waitForNavigation({
|
||||
...options,
|
||||
signal: controller.signal,
|
||||
}),
|
||||
this.#frame.browsingContext.traverseHistory(delta),
|
||||
]);
|
||||
return response;
|
||||
}
|
||||
catch (error) {
|
||||
controller.abort();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async waitForDevicePrompt(options = {}) {
|
||||
return await this.mainFrame().waitForDevicePrompt(options);
|
||||
}
|
||||
get bluetooth() {
|
||||
return this.mainFrame().browsingContext.bluetooth;
|
||||
}
|
||||
extensionRealms() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiPage };
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
function evaluationExpression(fun, ...args) {
|
||||
return `() => {${evaluationString(fun, ...args)}}`;
|
||||
}
|
||||
/**
|
||||
* Check domains match.
|
||||
*/
|
||||
function testUrlMatchCookieHostname(cookie, normalizedUrl) {
|
||||
const cookieDomain = cookie.domain.toLowerCase();
|
||||
const urlHostname = normalizedUrl.hostname.toLowerCase();
|
||||
if (cookieDomain === urlHostname) {
|
||||
return true;
|
||||
}
|
||||
// TODO: does not consider additional restrictions w.r.t to IP
|
||||
// addresses which is fine as it is for representation and does not
|
||||
// mean that cookies actually apply that way in the browser.
|
||||
// https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.3
|
||||
return cookieDomain.startsWith('.') && urlHostname.endsWith(cookieDomain);
|
||||
}
|
||||
/**
|
||||
* Check paths match.
|
||||
* Spec: https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4
|
||||
*/
|
||||
function testUrlMatchCookiePath(cookie, normalizedUrl) {
|
||||
const uriPath = normalizedUrl.pathname;
|
||||
const cookiePath = cookie.path;
|
||||
if (uriPath === cookiePath) {
|
||||
// The cookie-path and the request-path are identical.
|
||||
return true;
|
||||
}
|
||||
if (uriPath.startsWith(cookiePath)) {
|
||||
// The cookie-path is a prefix of the request-path.
|
||||
if (cookiePath.endsWith('/')) {
|
||||
// The last character of the cookie-path is %x2F ("/").
|
||||
return true;
|
||||
}
|
||||
if (uriPath[cookiePath.length] === '/') {
|
||||
// The first character of the request-path that is not included in the cookie-path
|
||||
// is a %x2F ("/") character.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Checks the cookie matches the URL according to the spec:
|
||||
*/
|
||||
function testUrlMatchCookie(cookie, url) {
|
||||
const normalizedUrl = new URL(url);
|
||||
assert(cookie !== undefined);
|
||||
if (!testUrlMatchCookieHostname(cookie, normalizedUrl)) {
|
||||
return false;
|
||||
}
|
||||
return testUrlMatchCookiePath(cookie, normalizedUrl);
|
||||
}
|
||||
export function bidiToPuppeteerCookie(bidiCookie, returnCompositePartitionKey = false) {
|
||||
const partitionKey = bidiCookie[CDP_SPECIFIC_PREFIX + 'partitionKey'];
|
||||
function getPartitionKey() {
|
||||
if (typeof partitionKey === 'string') {
|
||||
return { partitionKey };
|
||||
}
|
||||
if (typeof partitionKey === 'object' && partitionKey !== null) {
|
||||
if (returnCompositePartitionKey) {
|
||||
return {
|
||||
partitionKey: {
|
||||
sourceOrigin: partitionKey.topLevelSite,
|
||||
hasCrossSiteAncestor: partitionKey.hasCrossSiteAncestor ?? false,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
// TODO: a breaking change in Puppeteer is required to change
|
||||
// partitionKey type and report the composite partition key.
|
||||
partitionKey: partitionKey.topLevelSite,
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
name: bidiCookie.name,
|
||||
// Presents binary value as base64 string.
|
||||
value: bidiCookie.value.value,
|
||||
domain: bidiCookie.domain,
|
||||
path: bidiCookie.path,
|
||||
size: bidiCookie.size,
|
||||
httpOnly: bidiCookie.httpOnly,
|
||||
secure: bidiCookie.secure,
|
||||
sameSite: convertCookiesSameSiteBiDiToCdp(bidiCookie.sameSite),
|
||||
expires: bidiCookie.expiry ?? -1,
|
||||
session: bidiCookie.expiry === undefined || bidiCookie.expiry <= 0,
|
||||
// Extending with CDP-specific properties with `goog:` prefix.
|
||||
...cdpSpecificCookiePropertiesFromBidiToPuppeteer(bidiCookie, 'sourceScheme', 'partitionKeyOpaque', 'priority'),
|
||||
...getPartitionKey(),
|
||||
};
|
||||
}
|
||||
const CDP_SPECIFIC_PREFIX = 'goog:';
|
||||
/**
|
||||
* Gets CDP-specific properties from the BiDi cookie and returns them as a new object.
|
||||
*/
|
||||
function cdpSpecificCookiePropertiesFromBidiToPuppeteer(bidiCookie, ...propertyNames) {
|
||||
const result = {};
|
||||
for (const property of propertyNames) {
|
||||
if (bidiCookie[CDP_SPECIFIC_PREFIX + property] !== undefined) {
|
||||
result[property] = bidiCookie[CDP_SPECIFIC_PREFIX + property];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Gets CDP-specific properties from the cookie, adds CDP-specific prefixes and returns
|
||||
* them as a new object which can be used in BiDi.
|
||||
*/
|
||||
export function cdpSpecificCookiePropertiesFromPuppeteerToBidi(cookieParam, ...propertyNames) {
|
||||
const result = {};
|
||||
for (const property of propertyNames) {
|
||||
if (cookieParam[property] !== undefined) {
|
||||
result[CDP_SPECIFIC_PREFIX + property] = cookieParam[property];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function convertCookiesSameSiteBiDiToCdp(sameSite) {
|
||||
switch (sameSite) {
|
||||
case 'strict':
|
||||
return 'Strict';
|
||||
case 'lax':
|
||||
return 'Lax';
|
||||
case 'none':
|
||||
return 'None';
|
||||
default:
|
||||
return 'Default';
|
||||
}
|
||||
}
|
||||
export function convertCookiesSameSiteCdpToBiDi(sameSite) {
|
||||
switch (sameSite) {
|
||||
case 'Strict':
|
||||
return "strict" /* Bidi.Network.SameSite.Strict */;
|
||||
case 'Lax':
|
||||
return "lax" /* Bidi.Network.SameSite.Lax */;
|
||||
case 'None':
|
||||
return "none" /* Bidi.Network.SameSite.None */;
|
||||
default:
|
||||
return "default" /* Bidi.Network.SameSite.Default */;
|
||||
}
|
||||
}
|
||||
export function convertCookiesExpiryCdpToBiDi(expiry) {
|
||||
return [undefined, -1].includes(expiry) ? undefined : expiry;
|
||||
}
|
||||
export function convertCookiesPartitionKeyFromPuppeteerToBiDi(partitionKey) {
|
||||
if (partitionKey === undefined || typeof partitionKey === 'string') {
|
||||
return partitionKey;
|
||||
}
|
||||
if (partitionKey.hasCrossSiteAncestor) {
|
||||
throw new UnsupportedOperation('WebDriver BiDi does not support `hasCrossSiteAncestor` yet.');
|
||||
}
|
||||
return partitionKey.sourceOrigin;
|
||||
}
|
||||
//# sourceMappingURL=Page.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Page.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
65
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.d.ts
generated
vendored
Normal file
65
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { Extension } from '../api/Extension.js';
|
||||
import type { JSHandle } from '../api/JSHandle.js';
|
||||
import { Realm } from '../api/Realm.js';
|
||||
import type { TimeoutSettings } from '../common/TimeoutSettings.js';
|
||||
import type { EvaluateFunc, HandleFor } from '../common/types.js';
|
||||
import type { PuppeteerInjectedUtil } from '../injected/injected.js';
|
||||
import type { Realm as BidiRealmCore, DedicatedWorkerRealm, SharedWorkerRealm } from './core/Realm.js';
|
||||
import type { WindowRealm } from './core/Realm.js';
|
||||
import { BidiElementHandle } from './ElementHandle.js';
|
||||
import type { BidiFrame } from './Frame.js';
|
||||
import { BidiJSHandle } from './JSHandle.js';
|
||||
import type { BidiWebWorker } from './WebWorker.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare abstract class BidiRealm extends Realm {
|
||||
#private;
|
||||
readonly realm: BidiRealmCore;
|
||||
constructor(realm: BidiRealmCore, timeoutSettings: TimeoutSettings);
|
||||
protected initialize(): void;
|
||||
protected internalPuppeteerUtil?: Promise<BidiJSHandle<PuppeteerInjectedUtil>>;
|
||||
get puppeteerUtil(): Promise<BidiJSHandle<PuppeteerInjectedUtil>>;
|
||||
evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
createHandle(result: Bidi.Script.RemoteValue): BidiJSHandle<unknown> | BidiElementHandle<Node>;
|
||||
serializeAsync(arg: unknown): Promise<Bidi.Script.LocalValue>;
|
||||
serialize(arg: unknown): Bidi.Script.LocalValue;
|
||||
destroyHandles(handles: Array<BidiJSHandle<unknown>>): Promise<void>;
|
||||
adoptHandle<T extends JSHandle<Node>>(handle: T): Promise<T>;
|
||||
transferHandle<T extends JSHandle<Node>>(handle: T): Promise<T>;
|
||||
extension(): Promise<Extension | null>;
|
||||
get origin(): string;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiFrameRealm extends BidiRealm {
|
||||
#private;
|
||||
static from(realm: WindowRealm, frame: BidiFrame): BidiFrameRealm;
|
||||
readonly realm: WindowRealm;
|
||||
private constructor();
|
||||
get puppeteerUtil(): Promise<BidiJSHandle<PuppeteerInjectedUtil>>;
|
||||
get sandbox(): string | undefined;
|
||||
get environment(): BidiFrame;
|
||||
adoptBackendNode(backendNodeId?: number | undefined): Promise<JSHandle<Node>>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiWorkerRealm extends BidiRealm {
|
||||
#private;
|
||||
static from(realm: DedicatedWorkerRealm | SharedWorkerRealm, worker: BidiWebWorker): BidiWorkerRealm;
|
||||
readonly realm: DedicatedWorkerRealm | SharedWorkerRealm;
|
||||
private constructor();
|
||||
initialize(): void;
|
||||
get environment(): BidiWebWorker;
|
||||
adoptBackendNode(): Promise<JSHandle<Node>>;
|
||||
}
|
||||
//# sourceMappingURL=Realm.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Realm.d.ts","sourceRoot":"","sources":["../../../src/bidi/Realm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAEhD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAKtC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAUhE,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAInE,OAAO,KAAK,EACV,KAAK,IAAI,aAAa,EACtB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAQ3C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,8BAAsB,SAAU,SAAQ,KAAK;;IAC3C,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;gBAElB,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe;IAKlE,SAAS,CAAC,UAAU,IAAI,IAAI;IAW5B,SAAS,CAAC,qBAAqB,CAAC,EAAE,OA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AAO,CAAC,CAAC,CAAC;IASb,SAAS,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAItC,IAAa,MAAM,IAAI,MAAM,CAE5B;CACF;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,SAAS;;IAC3C,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,cAAc;IAKjE,SAAiB,KAAK,EAAE,WAAW,CAAC;IAIpC,OAAO;IAgBP,IAAa,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC,CAiCzE;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,IAAa,WAAW,IAAI,SAAS,CAEpC;IAEc,gBAAgB,CAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,GACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAiB3B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;;IAC5C,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,oBAAoB,GAAG,iBAAiB,EAC/C,MAAM,EAAE,aAAa,GACpB,eAAe;IAKlB,SAAiB,KAAK,EAAE,oBAAoB,GAAG,iBAAiB,CAAC;IAIjE,OAAO;IAQE,UAAU,IAAI,IAAI;IAsB3B,IAAa,WAAW,IAAI,aAAa,CAExC;IAEc,gBAAgB,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAG3D"}
|
||||
340
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.js
generated
vendored
Normal file
340
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.js
generated
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose, inner;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
if (async) inner = dispose;
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
};
|
||||
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
||||
return function (env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
var r, s = 0;
|
||||
function next() {
|
||||
while (r = env.stack.pop()) {
|
||||
try {
|
||||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
||||
if (r.dispose) {
|
||||
var result = r.dispose.call(r.value);
|
||||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
else s |= 1;
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
};
|
||||
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
});
|
||||
import { Realm } from '../api/Realm.js';
|
||||
import { WebWorkerEvent } from '../api/WebWorker.js';
|
||||
import { ARIAQueryHandler } from '../common/AriaQueryHandler.js';
|
||||
import { LazyArg } from '../common/LazyArg.js';
|
||||
import { scriptInjector } from '../common/ScriptInjector.js';
|
||||
import { debugError, getSourcePuppeteerURLIfAvailable, getSourceUrlComment, isString, PuppeteerURL, SOURCE_URL_REGEX, } from '../common/util.js';
|
||||
import { UnsupportedOperation } from '../index-browser.js';
|
||||
import { AsyncIterableUtil } from '../util/AsyncIterableUtil.js';
|
||||
import { stringifyFunction } from '../util/Function.js';
|
||||
import { BidiDeserializer } from './Deserializer.js';
|
||||
import { BidiElementHandle } from './ElementHandle.js';
|
||||
import { ExposableFunction } from './ExposedFunction.js';
|
||||
import { BidiJSHandle } from './JSHandle.js';
|
||||
import { BidiSerializer } from './Serializer.js';
|
||||
import { createEvaluationError, getConsoleMessage, isConsoleLogEntry, rewriteEvaluationError, } from './util.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiRealm extends Realm {
|
||||
realm;
|
||||
constructor(realm, timeoutSettings) {
|
||||
super(timeoutSettings);
|
||||
this.realm = realm;
|
||||
}
|
||||
initialize() {
|
||||
this.realm.on('destroyed', reason => {
|
||||
this.taskManager.terminateAll(new Error(reason));
|
||||
this.dispose();
|
||||
});
|
||||
this.realm.on('updated', () => {
|
||||
this.internalPuppeteerUtil = undefined;
|
||||
void this.taskManager.rerunAll();
|
||||
});
|
||||
}
|
||||
internalPuppeteerUtil;
|
||||
get puppeteerUtil() {
|
||||
const promise = Promise.resolve();
|
||||
scriptInjector.inject(script => {
|
||||
if (this.internalPuppeteerUtil) {
|
||||
void this.internalPuppeteerUtil.then(handle => {
|
||||
void handle.dispose();
|
||||
});
|
||||
}
|
||||
this.internalPuppeteerUtil = promise.then(() => {
|
||||
return this.evaluateHandle(script);
|
||||
});
|
||||
}, !this.internalPuppeteerUtil);
|
||||
return this.internalPuppeteerUtil;
|
||||
}
|
||||
async evaluateHandle(pageFunction, ...args) {
|
||||
return await this.#evaluate(false, pageFunction, ...args);
|
||||
}
|
||||
async evaluate(pageFunction, ...args) {
|
||||
return await this.#evaluate(true, pageFunction, ...args);
|
||||
}
|
||||
async #evaluate(returnByValue, pageFunction, ...args) {
|
||||
const sourceUrlComment = getSourceUrlComment(getSourcePuppeteerURLIfAvailable(pageFunction)?.toString() ??
|
||||
PuppeteerURL.INTERNAL_URL);
|
||||
let responsePromise;
|
||||
const resultOwnership = returnByValue
|
||||
? "none" /* Bidi.Script.ResultOwnership.None */
|
||||
: "root" /* Bidi.Script.ResultOwnership.Root */;
|
||||
const serializationOptions = returnByValue
|
||||
? {}
|
||||
: {
|
||||
maxObjectDepth: 0,
|
||||
maxDomDepth: 0,
|
||||
};
|
||||
if (isString(pageFunction)) {
|
||||
const expression = SOURCE_URL_REGEX.test(pageFunction)
|
||||
? pageFunction
|
||||
: `${pageFunction}\n${sourceUrlComment}\n`;
|
||||
responsePromise = this.realm.evaluate(expression, true, {
|
||||
resultOwnership,
|
||||
userActivation: true,
|
||||
serializationOptions,
|
||||
});
|
||||
}
|
||||
else {
|
||||
let functionDeclaration = stringifyFunction(pageFunction);
|
||||
functionDeclaration = SOURCE_URL_REGEX.test(functionDeclaration)
|
||||
? functionDeclaration
|
||||
: `${functionDeclaration}\n${sourceUrlComment}\n`;
|
||||
responsePromise = this.realm.callFunction(functionDeclaration,
|
||||
/* awaitPromise= */ true, {
|
||||
// LazyArgs are used only internally and should not affect the order
|
||||
// evaluate calls for the public APIs.
|
||||
arguments: args.some(arg => {
|
||||
return arg instanceof LazyArg;
|
||||
})
|
||||
? await Promise.all(args.map(arg => {
|
||||
return this.serializeAsync(arg);
|
||||
}))
|
||||
: args.map(arg => {
|
||||
return this.serialize(arg);
|
||||
}),
|
||||
resultOwnership,
|
||||
userActivation: true,
|
||||
serializationOptions,
|
||||
});
|
||||
}
|
||||
const result = await responsePromise.catch(rewriteEvaluationError);
|
||||
if ('type' in result && result.type === 'exception') {
|
||||
throw createEvaluationError(result.exceptionDetails);
|
||||
}
|
||||
if (returnByValue) {
|
||||
return BidiDeserializer.deserialize(result.result);
|
||||
}
|
||||
return this.createHandle(result.result);
|
||||
}
|
||||
createHandle(result) {
|
||||
if ((result.type === 'node' || result.type === 'window') &&
|
||||
this instanceof BidiFrameRealm) {
|
||||
return BidiElementHandle.from(result, this);
|
||||
}
|
||||
return BidiJSHandle.from(result, this);
|
||||
}
|
||||
async serializeAsync(arg) {
|
||||
if (arg instanceof LazyArg) {
|
||||
arg = await arg.get(this);
|
||||
}
|
||||
return this.serialize(arg);
|
||||
}
|
||||
serialize(arg) {
|
||||
if (arg instanceof BidiJSHandle || arg instanceof BidiElementHandle) {
|
||||
if (arg.realm !== this) {
|
||||
if (!(arg.realm instanceof BidiFrameRealm) ||
|
||||
!(this instanceof BidiFrameRealm)) {
|
||||
throw new Error("Trying to evaluate JSHandle from different global types. Usually this means you're using a handle from a worker in a page or vice versa.");
|
||||
}
|
||||
if (arg.realm.environment !== this.environment) {
|
||||
throw new Error("Trying to evaluate JSHandle from different frames. Usually this means you're using a handle from a page on a different page.");
|
||||
}
|
||||
}
|
||||
if (arg.disposed) {
|
||||
throw new Error('JSHandle is disposed!');
|
||||
}
|
||||
return arg.remoteValue();
|
||||
}
|
||||
return BidiSerializer.serialize(arg);
|
||||
}
|
||||
async destroyHandles(handles) {
|
||||
if (this.disposed) {
|
||||
return;
|
||||
}
|
||||
const handleIds = handles
|
||||
.map(({ id }) => {
|
||||
return id;
|
||||
})
|
||||
.filter((id) => {
|
||||
return id !== undefined;
|
||||
});
|
||||
if (handleIds.length === 0) {
|
||||
return;
|
||||
}
|
||||
await this.realm.disown(handleIds).catch(error => {
|
||||
// Exceptions might happen in case of a page been navigated or closed.
|
||||
// Swallow these since they are harmless and we don't leak anything in this case.
|
||||
debugError(error);
|
||||
});
|
||||
}
|
||||
async adoptHandle(handle) {
|
||||
return (await this.evaluateHandle(node => {
|
||||
return node;
|
||||
}, handle));
|
||||
}
|
||||
async transferHandle(handle) {
|
||||
if (handle.realm === this) {
|
||||
return handle;
|
||||
}
|
||||
const transferredHandle = this.adoptHandle(handle);
|
||||
await handle.dispose();
|
||||
return await transferredHandle;
|
||||
}
|
||||
extension() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
get origin() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiFrameRealm extends BidiRealm {
|
||||
static from(realm, frame) {
|
||||
const frameRealm = new BidiFrameRealm(realm, frame);
|
||||
frameRealm.#initialize();
|
||||
return frameRealm;
|
||||
}
|
||||
#frame;
|
||||
constructor(realm, frame) {
|
||||
super(realm, frame.timeoutSettings);
|
||||
this.#frame = frame;
|
||||
}
|
||||
#initialize() {
|
||||
super.initialize();
|
||||
// This should run first.
|
||||
this.realm.on('updated', () => {
|
||||
this.environment.clearDocumentHandle();
|
||||
this.#bindingsInstalled = false;
|
||||
});
|
||||
}
|
||||
#bindingsInstalled = false;
|
||||
get puppeteerUtil() {
|
||||
let promise = Promise.resolve();
|
||||
if (!this.#bindingsInstalled) {
|
||||
promise = Promise.all([
|
||||
ExposableFunction.from(this.environment, '__ariaQuerySelector', ARIAQueryHandler.queryOne, !!this.sandbox),
|
||||
ExposableFunction.from(this.environment, '__ariaQuerySelectorAll', async (element, selector) => {
|
||||
const results = ARIAQueryHandler.queryAll(element, selector);
|
||||
return await element.realm.evaluateHandle((...elements) => {
|
||||
return elements;
|
||||
}, ...(await AsyncIterableUtil.collect(results)));
|
||||
}, !!this.sandbox),
|
||||
]);
|
||||
this.#bindingsInstalled = true;
|
||||
}
|
||||
return promise.then(() => {
|
||||
return super.puppeteerUtil;
|
||||
});
|
||||
}
|
||||
get sandbox() {
|
||||
return this.realm.sandbox;
|
||||
}
|
||||
get environment() {
|
||||
return this.#frame;
|
||||
}
|
||||
async adoptBackendNode(backendNodeId) {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const { object } = await this.#frame.client.send('DOM.resolveNode', {
|
||||
backendNodeId,
|
||||
executionContextId: await this.realm.resolveExecutionContextId(),
|
||||
});
|
||||
const handle = __addDisposableResource(env_1, BidiElementHandle.from({
|
||||
handle: object.objectId,
|
||||
type: 'node',
|
||||
}, this), false);
|
||||
// We need the sharedId, so we perform the following to obtain it.
|
||||
return await handle.evaluateHandle(element => {
|
||||
return element;
|
||||
});
|
||||
}
|
||||
catch (e_1) {
|
||||
env_1.error = e_1;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiWorkerRealm extends BidiRealm {
|
||||
static from(realm, worker) {
|
||||
const workerRealm = new BidiWorkerRealm(realm, worker);
|
||||
workerRealm.initialize();
|
||||
return workerRealm;
|
||||
}
|
||||
#worker;
|
||||
constructor(realm, frame) {
|
||||
super(realm, frame.timeoutSettings);
|
||||
this.#worker = frame;
|
||||
}
|
||||
initialize() {
|
||||
super.initialize();
|
||||
this.realm.on('log', entry => {
|
||||
if (isConsoleLogEntry(entry) &&
|
||||
this.#worker.listenerCount(WebWorkerEvent.Console)) {
|
||||
const args = entry.args.map(arg => {
|
||||
return this.createHandle(arg);
|
||||
});
|
||||
const message = getConsoleMessage(entry, args, undefined, this.realm.id);
|
||||
this.#worker.emit(WebWorkerEvent.Console, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
get environment() {
|
||||
return this.#worker;
|
||||
}
|
||||
async adoptBackendNode() {
|
||||
throw new Error('Cannot adopt DOM nodes into a worker.');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Realm.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Realm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.d.ts
generated
vendored
Normal file
14
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiSerializer {
|
||||
#private;
|
||||
static serialize(arg: unknown): Bidi.Script.LocalValue;
|
||||
}
|
||||
//# sourceMappingURL=Serializer.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Serializer.d.ts","sourceRoot":"","sources":["../../../src/bidi/Serializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AASrD;;GAEG;AACH,qBAAa,cAAc;;IACzB,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU;CA0GvD"}
|
||||
121
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.js
generated
vendored
Normal file
121
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { isDate, isPlainObject, isRegExp } from '../common/util.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class UnserializableError extends Error {
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiSerializer {
|
||||
static serialize(arg) {
|
||||
switch (typeof arg) {
|
||||
case 'symbol':
|
||||
case 'function':
|
||||
throw new UnserializableError(`Unable to serializable ${typeof arg}`);
|
||||
case 'object':
|
||||
return this.#serializeObject(arg);
|
||||
case 'undefined':
|
||||
return {
|
||||
type: 'undefined',
|
||||
};
|
||||
case 'number':
|
||||
return this.#serializeNumber(arg);
|
||||
case 'bigint':
|
||||
return {
|
||||
type: 'bigint',
|
||||
value: arg.toString(),
|
||||
};
|
||||
case 'string':
|
||||
return {
|
||||
type: 'string',
|
||||
value: arg,
|
||||
};
|
||||
case 'boolean':
|
||||
return {
|
||||
type: 'boolean',
|
||||
value: arg,
|
||||
};
|
||||
}
|
||||
}
|
||||
static #serializeNumber(arg) {
|
||||
let value;
|
||||
if (Object.is(arg, -0)) {
|
||||
value = '-0';
|
||||
}
|
||||
else if (Object.is(arg, Infinity)) {
|
||||
value = 'Infinity';
|
||||
}
|
||||
else if (Object.is(arg, -Infinity)) {
|
||||
value = '-Infinity';
|
||||
}
|
||||
else if (Object.is(arg, NaN)) {
|
||||
value = 'NaN';
|
||||
}
|
||||
else {
|
||||
value = arg;
|
||||
}
|
||||
return {
|
||||
type: 'number',
|
||||
value,
|
||||
};
|
||||
}
|
||||
static #serializeObject(arg) {
|
||||
if (arg === null) {
|
||||
return {
|
||||
type: 'null',
|
||||
};
|
||||
}
|
||||
else if (Array.isArray(arg)) {
|
||||
const parsedArray = arg.map(subArg => {
|
||||
return this.serialize(subArg);
|
||||
});
|
||||
return {
|
||||
type: 'array',
|
||||
value: parsedArray,
|
||||
};
|
||||
}
|
||||
else if (isPlainObject(arg)) {
|
||||
try {
|
||||
JSON.stringify(arg);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof TypeError &&
|
||||
error.message.startsWith('Converting circular structure to JSON')) {
|
||||
error.message += ' Recursive objects are not allowed.';
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
const parsedObject = [];
|
||||
for (const key in arg) {
|
||||
parsedObject.push([this.serialize(key), this.serialize(arg[key])]);
|
||||
}
|
||||
return {
|
||||
type: 'object',
|
||||
value: parsedObject,
|
||||
};
|
||||
}
|
||||
else if (isRegExp(arg)) {
|
||||
return {
|
||||
type: 'regexp',
|
||||
value: {
|
||||
pattern: arg.source,
|
||||
flags: arg.flags,
|
||||
},
|
||||
};
|
||||
}
|
||||
else if (isDate(arg)) {
|
||||
return {
|
||||
type: 'date',
|
||||
value: arg.toISOString(),
|
||||
};
|
||||
}
|
||||
throw new UnserializableError('Custom object serialization not possible. Use plain objects instead.');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Serializer.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Serializer.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Serializer.js","sourceRoot":"","sources":["../../../src/bidi/Serializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAElE;;GAEG;AACH,MAAM,mBAAoB,SAAQ,KAAK;CAAG;AAE1C;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,MAAM,CAAC,SAAS,CAAC,GAAY;QAC3B,QAAQ,OAAO,GAAG,EAAE,CAAC;YACnB,KAAK,QAAQ,CAAC;YACd,KAAK,UAAU;gBACb,MAAM,IAAI,mBAAmB,CAAC,0BAA0B,OAAO,GAAG,EAAE,CAAC,CAAC;YACxE,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAEpC,KAAK,WAAW;gBACd,OAAO;oBACL,IAAI,EAAE,WAAW;iBAClB,CAAC;YACJ,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACpC,KAAK,QAAQ;gBACX,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE;iBACtB,CAAC;YACJ,KAAK,QAAQ;gBACX,OAAO;oBACL,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,GAAG;iBACX,CAAC;YACJ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AAE,CAAC;YAC9B,IAAI,CAAC;gBACH,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACtB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IACE,KAAK,YAAY,SAAS;oBAC1B,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,uCAAuC,CAAC,EACjE,CAAC;oBACD,KAAK,CAAC,OAAO,IAAI,qCAAqC,CAAC;gBACzD,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,YAAY,GAAkC,EAAE,CAAC;YACvD,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;gBACtB,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACrE,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,YAAY;aACpB,CAAC;QACJ,CAAC;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE;oBACL,OAAO,EAAE,GAAG,CAAC,MAAM;oBACnB,KAAK,EAAE,GAAG,CAAC,KAAK;iBACjB;aACF,CAAC;QACJ,CAAC;aAAM,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE;aACzB,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,mBAAmB,CAC3B,sEAAsE,CACvE,CAAC;IACJ,CAAC;CACF"}
|
||||
72
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.d.ts
generated
vendored
Normal file
72
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.d.ts
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { Target, TargetType } from '../api/Target.js';
|
||||
import type { CDPSession } from '../puppeteer-core.js';
|
||||
import type { BidiBrowser } from './Browser.js';
|
||||
import type { BidiBrowserContext } from './BrowserContext.js';
|
||||
import type { BidiFrame } from './Frame.js';
|
||||
import { BidiPage } from './Page.js';
|
||||
import type { BidiWebWorker } from './WebWorker.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiBrowserTarget extends Target {
|
||||
#private;
|
||||
constructor(browser: BidiBrowser);
|
||||
asPage(): Promise<BidiPage>;
|
||||
url(): string;
|
||||
createCDPSession(): Promise<CDPSession>;
|
||||
type(): TargetType;
|
||||
browser(): BidiBrowser;
|
||||
browserContext(): BidiBrowserContext;
|
||||
opener(): Target | undefined;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiPageTarget extends Target {
|
||||
#private;
|
||||
constructor(page: BidiPage);
|
||||
page(): Promise<BidiPage>;
|
||||
asPage(): Promise<BidiPage>;
|
||||
url(): string;
|
||||
createCDPSession(): Promise<CDPSession>;
|
||||
type(): TargetType;
|
||||
browser(): BidiBrowser;
|
||||
browserContext(): BidiBrowserContext;
|
||||
opener(): Target | undefined;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiFrameTarget extends Target {
|
||||
#private;
|
||||
constructor(frame: BidiFrame);
|
||||
page(): Promise<BidiPage>;
|
||||
asPage(): Promise<BidiPage>;
|
||||
url(): string;
|
||||
createCDPSession(): Promise<CDPSession>;
|
||||
type(): TargetType;
|
||||
browser(): BidiBrowser;
|
||||
browserContext(): BidiBrowserContext;
|
||||
opener(): Target | undefined;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiWorkerTarget extends Target {
|
||||
#private;
|
||||
constructor(worker: BidiWebWorker);
|
||||
page(): Promise<BidiPage>;
|
||||
asPage(): Promise<BidiPage>;
|
||||
url(): string;
|
||||
createCDPSession(): Promise<CDPSession>;
|
||||
type(): TargetType;
|
||||
browser(): BidiBrowser;
|
||||
browserContext(): BidiBrowserContext;
|
||||
opener(): Target | undefined;
|
||||
}
|
||||
//# sourceMappingURL=Target.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Target.d.ts","sourceRoot":"","sources":["../../../src/bidi/Target.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,MAAM;;gBAG/B,OAAO,EAAE,WAAW;IAKvB,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC;IAG3B,GAAG,IAAI,MAAM;IAGb,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAGvC,IAAI,IAAI,UAAU;IAGlB,OAAO,IAAI,WAAW;IAGtB,cAAc,IAAI,kBAAkB;IAGpC,MAAM,IAAI,MAAM,GAAG,SAAS;CAGtC;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,MAAM;;gBAG5B,IAAI,EAAE,QAAQ;IAKX,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC;IAGzB,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC;IAGjC,GAAG,IAAI,MAAM;IAGb,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAGvC,IAAI,IAAI,UAAU;IAGlB,OAAO,IAAI,WAAW;IAGtB,cAAc,IAAI,kBAAkB;IAGpC,MAAM,IAAI,MAAM,GAAG,SAAS;CAGtC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,MAAM;;gBAI7B,KAAK,EAAE,SAAS;IAKb,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC;IASzB,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC;IAGjC,GAAG,IAAI,MAAM;IAGb,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAGvC,IAAI,IAAI,UAAU;IAGlB,OAAO,IAAI,WAAW;IAGtB,cAAc,IAAI,kBAAkB;IAGpC,MAAM,IAAI,MAAM,GAAG,SAAS;CAGtC;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,MAAM;;gBAG9B,MAAM,EAAE,aAAa;IAKlB,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC;IAGzB,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC;IAGjC,GAAG,IAAI,MAAM;IAGb,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAGvC,IAAI,IAAI,UAAU;IAGlB,OAAO,IAAI,WAAW;IAGtB,cAAc,IAAI,kBAAkB;IAGpC,MAAM,IAAI,MAAM,GAAG,SAAS;CAGtC"}
|
||||
146
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.js
generated
vendored
Normal file
146
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { Target, TargetType } from '../api/Target.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { BidiPage } from './Page.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiBrowserTarget extends Target {
|
||||
#browser;
|
||||
constructor(browser) {
|
||||
super();
|
||||
this.#browser = browser;
|
||||
}
|
||||
asPage() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
url() {
|
||||
return '';
|
||||
}
|
||||
createCDPSession() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
type() {
|
||||
return TargetType.BROWSER;
|
||||
}
|
||||
browser() {
|
||||
return this.#browser;
|
||||
}
|
||||
browserContext() {
|
||||
return this.#browser.defaultBrowserContext();
|
||||
}
|
||||
opener() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiPageTarget extends Target {
|
||||
#page;
|
||||
constructor(page) {
|
||||
super();
|
||||
this.#page = page;
|
||||
}
|
||||
async page() {
|
||||
return this.#page;
|
||||
}
|
||||
async asPage() {
|
||||
return await this.page();
|
||||
}
|
||||
url() {
|
||||
return this.#page.url();
|
||||
}
|
||||
createCDPSession() {
|
||||
return this.#page.createCDPSession();
|
||||
}
|
||||
type() {
|
||||
return TargetType.PAGE;
|
||||
}
|
||||
browser() {
|
||||
return this.browserContext().browser();
|
||||
}
|
||||
browserContext() {
|
||||
return this.#page.browserContext();
|
||||
}
|
||||
opener() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiFrameTarget extends Target {
|
||||
#frame;
|
||||
#page;
|
||||
constructor(frame) {
|
||||
super();
|
||||
this.#frame = frame;
|
||||
}
|
||||
async page() {
|
||||
if (this.#page === undefined) {
|
||||
this.#page = BidiPage.from(this.browserContext(), this.#frame.browsingContext);
|
||||
}
|
||||
return this.#page;
|
||||
}
|
||||
async asPage() {
|
||||
return await this.page();
|
||||
}
|
||||
url() {
|
||||
return this.#frame.url();
|
||||
}
|
||||
createCDPSession() {
|
||||
return this.#frame.createCDPSession();
|
||||
}
|
||||
type() {
|
||||
return TargetType.PAGE;
|
||||
}
|
||||
browser() {
|
||||
return this.browserContext().browser();
|
||||
}
|
||||
browserContext() {
|
||||
return this.#frame.page().browserContext();
|
||||
}
|
||||
opener() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiWorkerTarget extends Target {
|
||||
#worker;
|
||||
constructor(worker) {
|
||||
super();
|
||||
this.#worker = worker;
|
||||
}
|
||||
async page() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
async asPage() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
url() {
|
||||
return this.#worker.url();
|
||||
}
|
||||
createCDPSession() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
type() {
|
||||
return TargetType.OTHER;
|
||||
}
|
||||
browser() {
|
||||
return this.browserContext().browser();
|
||||
}
|
||||
browserContext() {
|
||||
return this.#worker.frame.page().browserContext();
|
||||
}
|
||||
opener() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Target.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/Target.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Target.js","sourceRoot":"","sources":["../../../src/bidi/Target.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAMzD,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAC;AAGnC;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,MAAM;IAC3C,QAAQ,CAAc;IAEtB,YAAY,OAA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B,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACQ,KAAK,CAAC,MAAM;QACnB,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACQ,GAAG;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5B,CAAC;IACQ,gBAAgB;QACvB,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACQ,IAAI;QACX,OAAO,UAAU,CAAC,KAAK,CAAC;IAC1B,CAAC;IACQ,OAAO;QACd,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;IACQ,cAAc;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC;IACpD,CAAC;IACQ,MAAM;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;CACF"}
|
||||
22
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.d.ts
generated
vendored
Normal file
22
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { WebWorker } from '../api/WebWorker.js';
|
||||
import type { CDPSession } from '../puppeteer-core.js';
|
||||
import type { DedicatedWorkerRealm, SharedWorkerRealm } from './core/Realm.js';
|
||||
import type { BidiFrame } from './Frame.js';
|
||||
import { BidiWorkerRealm } from './Realm.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BidiWebWorker extends WebWorker {
|
||||
#private;
|
||||
static from(frame: BidiFrame, realm: DedicatedWorkerRealm | SharedWorkerRealm): BidiWebWorker;
|
||||
private constructor();
|
||||
get frame(): BidiFrame;
|
||||
mainRealm(): BidiWorkerRealm;
|
||||
get client(): CDPSession;
|
||||
}
|
||||
//# sourceMappingURL=WebWorker.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WebWorker.d.ts","sourceRoot":"","sources":["../../../src/bidi/WebWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;;IAC1C,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,oBAAoB,GAAG,iBAAiB,GAC9C,aAAa;IAOhB,OAAO;IASP,IAAI,KAAK,IAAI,SAAS,CAErB;IAED,SAAS,IAAI,eAAe;IAI5B,IAAI,MAAM,IAAI,UAAU,CAEvB;CACF"}
|
||||
34
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.js
generated
vendored
Normal file
34
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { WebWorker } from '../api/WebWorker.js';
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { BidiWorkerRealm } from './Realm.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class BidiWebWorker extends WebWorker {
|
||||
static from(frame, realm) {
|
||||
const worker = new BidiWebWorker(frame, realm);
|
||||
return worker;
|
||||
}
|
||||
#frame;
|
||||
#realm;
|
||||
constructor(frame, realm) {
|
||||
super(realm.origin);
|
||||
this.#frame = frame;
|
||||
this.#realm = BidiWorkerRealm.from(realm, this);
|
||||
}
|
||||
get frame() {
|
||||
return this.#frame;
|
||||
}
|
||||
mainRealm() {
|
||||
return this.#realm;
|
||||
}
|
||||
get client() {
|
||||
throw new UnsupportedOperation();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=WebWorker.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/WebWorker.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WebWorker.js","sourceRoot":"","sources":["../../../src/bidi/WebWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAKzD,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,MAAM,CAAC,IAAI,CACT,KAAgB,EAChB,KAA+C;QAE/C,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC;IAChB,CAAC;IAEQ,MAAM,CAAY;IAClB,MAAM,CAAkB;IACjC,YACE,KAAgB,EAChB,KAA+C;QAE/C,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,MAAM;QACR,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;CACF"}
|
||||
18
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.d.ts
generated
vendored
Normal file
18
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
export * from './BidiOverCdp.js';
|
||||
export * from './Browser.js';
|
||||
export * from './BrowserContext.js';
|
||||
export * from './Connection.js';
|
||||
export * from './ElementHandle.js';
|
||||
export * from './Frame.js';
|
||||
export * from './HTTPRequest.js';
|
||||
export * from './HTTPResponse.js';
|
||||
export * from './Input.js';
|
||||
export * from './JSHandle.js';
|
||||
export * from './Page.js';
|
||||
export * from './Realm.js';
|
||||
//# sourceMappingURL=bidi.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bidi.d.ts","sourceRoot":"","sources":["../../../src/bidi/bidi.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
||||
18
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.js
generated
vendored
Normal file
18
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
export * from './BidiOverCdp.js';
|
||||
export * from './Browser.js';
|
||||
export * from './BrowserContext.js';
|
||||
export * from './Connection.js';
|
||||
export * from './ElementHandle.js';
|
||||
export * from './Frame.js';
|
||||
export * from './HTTPRequest.js';
|
||||
export * from './HTTPResponse.js';
|
||||
export * from './Input.js';
|
||||
export * from './JSHandle.js';
|
||||
export * from './Page.js';
|
||||
export * from './Realm.js';
|
||||
//# sourceMappingURL=bidi.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/bidi.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bidi.js","sourceRoot":"","sources":["../../../src/bidi/bidi.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
||||
52
node_modules/puppeteer-core/lib/puppeteer/bidi/core/Browser.d.ts
generated
vendored
Normal file
52
node_modules/puppeteer-core/lib/puppeteer/bidi/core/Browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { BrowserContextOptions } from '../../api/Browser.js';
|
||||
import { EventEmitter } from '../../common/EventEmitter.js';
|
||||
import { disposeSymbol } from '../../util/disposable.js';
|
||||
import type { BrowsingContext } from './BrowsingContext.js';
|
||||
import { SharedWorkerRealm } from './Realm.js';
|
||||
import type { Session } from './Session.js';
|
||||
import { UserContext } from './UserContext.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type AddPreloadScriptOptions = Omit<Bidi.Script.AddPreloadScriptParameters, 'functionDeclaration' | 'contexts'> & {
|
||||
contexts?: [BrowsingContext, ...BrowsingContext[]];
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class Browser extends EventEmitter<{
|
||||
/** Emitted before the browser closes. */
|
||||
closed: string;
|
||||
/** Emitted after the browser disconnects. */
|
||||
disconnected: string;
|
||||
/** Emitted when a shared worker is created. */
|
||||
sharedworker: SharedWorkerRealm;
|
||||
}> {
|
||||
#private;
|
||||
static from(session: Session): Promise<Browser>;
|
||||
readonly session: Session;
|
||||
private constructor();
|
||||
get closed(): boolean;
|
||||
get defaultUserContext(): UserContext;
|
||||
get disconnected(): boolean;
|
||||
get disposed(): boolean;
|
||||
get userContexts(): Iterable<UserContext>;
|
||||
dispose(reason?: string, closed?: boolean): void;
|
||||
close(): Promise<void>;
|
||||
addPreloadScript(functionDeclaration: string, options?: AddPreloadScriptOptions): Promise<string>;
|
||||
removeIntercept(intercept: Bidi.Network.Intercept): Promise<void>;
|
||||
removePreloadScript(script: string): Promise<void>;
|
||||
createUserContext(options: BrowserContextOptions): Promise<UserContext>;
|
||||
installExtension(path: string): Promise<string>;
|
||||
uninstallExtension(id: string): Promise<void>;
|
||||
setClientWindowState(params: Bidi.Browser.SetClientWindowStateParameters): Promise<void>;
|
||||
getClientWindowInfo(windowId: string): Promise<Bidi.Browser.ClientWindowInfo>;
|
||||
[disposeSymbol](): void;
|
||||
}
|
||||
//# sourceMappingURL=Browser.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/Browser.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/Browser.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Browser.d.ts","sourceRoot":"","sources":["../../../../src/bidi/core/Browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAkB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAExE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,IAAI,CAAC,MAAM,CAAC,0BAA0B,EACtC,qBAAqB,GAAG,UAAU,CACnC,GAAG;IACF,QAAQ,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,eAAe,EAAE,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAQ,SAAQ,YAAY,CAAC;IACxC,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,YAAY,EAAE,iBAAiB,CAAC;CACjC,CAAC;;WACa,IAAI,CAAC,OAAO,EAAE,OAA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
generated
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
||||
if (value !== null && value !== void 0) {
|
||||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
||||
var dispose, inner;
|
||||
if (async) {
|
||||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
||||
dispose = value[Symbol.asyncDispose];
|
||||
}
|
||||
if (dispose === void 0) {
|
||||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
||||
dispose = value[Symbol.dispose];
|
||||
if (async) inner = dispose;
|
||||
}
|
||||
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
||||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
||||
env.stack.push({ value: value, dispose: dispose, async: async });
|
||||
}
|
||||
else if (async) {
|
||||
env.stack.push({ async: true });
|
||||
}
|
||||
return value;
|
||||
};
|
||||
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
||||
return function (env) {
|
||||
function fail(e) {
|
||||
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
||||
env.hasError = true;
|
||||
}
|
||||
var r, s = 0;
|
||||
function next() {
|
||||
while (r = env.stack.pop()) {
|
||||
try {
|
||||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
||||
if (r.dispose) {
|
||||
var result = r.dispose.call(r.value);
|
||||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
||||
}
|
||||
else s |= 1;
|
||||
}
|
||||
catch (e) {
|
||||
fail(e);
|
||||
}
|
||||
}
|
||||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
||||
if (env.hasError) throw env.error;
|
||||
}
|
||||
return next();
|
||||
};
|
||||
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
||||
var e = new Error(message);
|
||||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
||||
});
|
||||
import { UnsupportedOperation } from '../../common/Errors.js';
|
||||
import { EventEmitter } from '../../common/EventEmitter.js';
|
||||
import { inertIfDisposed, throwIfDisposed } from '../../util/decorators.js';
|
||||
import { DisposableStack, disposeSymbol } from '../../util/disposable.js';
|
||||
import { SharedWorkerRealm } from './Realm.js';
|
||||
import { UserContext } from './UserContext.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
let Browser = (() => {
|
||||
let _classSuper = EventEmitter;
|
||||
let _instanceExtraInitializers = [];
|
||||
let _dispose_decorators;
|
||||
let _close_decorators;
|
||||
let _addPreloadScript_decorators;
|
||||
let _removeIntercept_decorators;
|
||||
let _removePreloadScript_decorators;
|
||||
let _createUserContext_decorators;
|
||||
let _installExtension_decorators;
|
||||
let _uninstallExtension_decorators;
|
||||
let _setClientWindowState_decorators;
|
||||
let _getClientWindowInfo_decorators;
|
||||
return class Browser extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
__esDecorate(this, null, _dispose_decorators, { kind: "method", name: "dispose", static: false, private: false, access: { has: obj => "dispose" in obj, get: obj => obj.dispose }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _close_decorators, { kind: "method", name: "close", static: false, private: false, access: { has: obj => "close" in obj, get: obj => obj.close }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _addPreloadScript_decorators, { kind: "method", name: "addPreloadScript", static: false, private: false, access: { has: obj => "addPreloadScript" in obj, get: obj => obj.addPreloadScript }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _removeIntercept_decorators, { kind: "method", name: "removeIntercept", static: false, private: false, access: { has: obj => "removeIntercept" in obj, get: obj => obj.removeIntercept }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _removePreloadScript_decorators, { kind: "method", name: "removePreloadScript", static: false, private: false, access: { has: obj => "removePreloadScript" in obj, get: obj => obj.removePreloadScript }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _createUserContext_decorators, { kind: "method", name: "createUserContext", static: false, private: false, access: { has: obj => "createUserContext" in obj, get: obj => obj.createUserContext }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _installExtension_decorators, { kind: "method", name: "installExtension", static: false, private: false, access: { has: obj => "installExtension" in obj, get: obj => obj.installExtension }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _uninstallExtension_decorators, { kind: "method", name: "uninstallExtension", static: false, private: false, access: { has: obj => "uninstallExtension" in obj, get: obj => obj.uninstallExtension }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setClientWindowState_decorators, { kind: "method", name: "setClientWindowState", static: false, private: false, access: { has: obj => "setClientWindowState" in obj, get: obj => obj.setClientWindowState }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _getClientWindowInfo_decorators, { kind: "method", name: "getClientWindowInfo", static: false, private: false, access: { has: obj => "getClientWindowInfo" in obj, get: obj => obj.getClientWindowInfo }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
static async from(session) {
|
||||
const browser = new Browser(session);
|
||||
await browser.#initialize();
|
||||
return browser;
|
||||
}
|
||||
#closed = (__runInitializers(this, _instanceExtraInitializers), false);
|
||||
#reason;
|
||||
#disposables = new DisposableStack();
|
||||
#userContexts = new Map();
|
||||
session;
|
||||
#sharedWorkers = new Map();
|
||||
constructor(session) {
|
||||
super();
|
||||
this.session = session;
|
||||
}
|
||||
async #initialize() {
|
||||
const sessionEmitter = this.#disposables.use(new EventEmitter(this.session));
|
||||
sessionEmitter.once('ended', reason => {
|
||||
this.dispose(reason);
|
||||
});
|
||||
sessionEmitter.on('script.realmCreated', info => {
|
||||
if (info.type !== 'shared-worker') {
|
||||
return;
|
||||
}
|
||||
this.#sharedWorkers.set(info.realm, SharedWorkerRealm.from(this, info.realm, info.origin));
|
||||
});
|
||||
await this.#syncUserContexts();
|
||||
await this.#syncBrowsingContexts();
|
||||
}
|
||||
async #syncUserContexts() {
|
||||
const { result: { userContexts }, } = await this.session.send('browser.getUserContexts', {});
|
||||
for (const context of userContexts) {
|
||||
this.#createUserContext(context.userContext);
|
||||
}
|
||||
}
|
||||
async #syncBrowsingContexts() {
|
||||
// In case contexts are created or destroyed during `getTree`, we use this
|
||||
// set to detect them.
|
||||
const contextIds = new Set();
|
||||
let contexts;
|
||||
{
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const sessionEmitter = __addDisposableResource(env_1, new EventEmitter(this.session), false);
|
||||
sessionEmitter.on('browsingContext.contextCreated', info => {
|
||||
contextIds.add(info.context);
|
||||
});
|
||||
const { result } = await this.session.send('browsingContext.getTree', {});
|
||||
contexts = result.contexts;
|
||||
}
|
||||
catch (e_1) {
|
||||
env_1.error = e_1;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
// Simulating events so contexts are created naturally.
|
||||
for (const info of contexts) {
|
||||
if (!contextIds.has(info.context)) {
|
||||
this.session.emit('browsingContext.contextCreated', info);
|
||||
}
|
||||
if (info.children) {
|
||||
contexts.push(...info.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
#createUserContext(id) {
|
||||
const userContext = UserContext.create(this, id);
|
||||
this.#userContexts.set(userContext.id, userContext);
|
||||
const userContextEmitter = this.#disposables.use(new EventEmitter(userContext));
|
||||
userContextEmitter.once('closed', () => {
|
||||
userContextEmitter.removeAllListeners();
|
||||
this.#userContexts.delete(userContext.id);
|
||||
});
|
||||
return userContext;
|
||||
}
|
||||
get closed() {
|
||||
return this.#closed;
|
||||
}
|
||||
get defaultUserContext() {
|
||||
// SAFETY: A UserContext is always created for the default context.
|
||||
return this.#userContexts.get(UserContext.DEFAULT);
|
||||
}
|
||||
get disconnected() {
|
||||
return this.#reason !== undefined;
|
||||
}
|
||||
get disposed() {
|
||||
return this.disconnected;
|
||||
}
|
||||
get userContexts() {
|
||||
return this.#userContexts.values();
|
||||
}
|
||||
dispose(reason, closed = false) {
|
||||
this.#closed = closed;
|
||||
this.#reason = reason;
|
||||
this[disposeSymbol]();
|
||||
}
|
||||
async close() {
|
||||
try {
|
||||
await this.session.send('browser.close', {});
|
||||
}
|
||||
finally {
|
||||
this.dispose('Browser already closed.', true);
|
||||
}
|
||||
}
|
||||
async addPreloadScript(functionDeclaration, options = {}) {
|
||||
const { result: { script }, } = await this.session.send('script.addPreloadScript', {
|
||||
functionDeclaration,
|
||||
...options,
|
||||
contexts: options.contexts?.map(context => {
|
||||
return context.id;
|
||||
}),
|
||||
});
|
||||
return script;
|
||||
}
|
||||
async removeIntercept(intercept) {
|
||||
await this.session.send('network.removeIntercept', {
|
||||
intercept,
|
||||
});
|
||||
}
|
||||
async removePreloadScript(script) {
|
||||
await this.session.send('script.removePreloadScript', {
|
||||
script,
|
||||
});
|
||||
}
|
||||
async createUserContext(options) {
|
||||
const proxyConfig = options.proxyServer === undefined
|
||||
? undefined
|
||||
: {
|
||||
proxyType: 'manual',
|
||||
httpProxy: options.proxyServer,
|
||||
sslProxy: options.proxyServer,
|
||||
noProxy: options.proxyBypassList,
|
||||
};
|
||||
const { result: { userContext }, } = await this.session.send('browser.createUserContext', {
|
||||
proxy: proxyConfig,
|
||||
});
|
||||
if (options.downloadBehavior?.policy === 'allowAndName') {
|
||||
throw new UnsupportedOperation('`allowAndName` is not supported in WebDriver BiDi');
|
||||
}
|
||||
if (options.downloadBehavior?.policy === 'allow') {
|
||||
if (options.downloadBehavior.downloadPath === undefined) {
|
||||
throw new UnsupportedOperation('`downloadPath` is required in `allow` download behavior');
|
||||
}
|
||||
await this.session.send('browser.setDownloadBehavior', {
|
||||
downloadBehavior: {
|
||||
type: 'allowed',
|
||||
destinationFolder: options.downloadBehavior.downloadPath,
|
||||
},
|
||||
userContexts: [userContext],
|
||||
});
|
||||
}
|
||||
if (options.downloadBehavior?.policy === 'deny') {
|
||||
await this.session.send('browser.setDownloadBehavior', {
|
||||
downloadBehavior: { type: 'denied' },
|
||||
userContexts: [userContext],
|
||||
});
|
||||
}
|
||||
return this.#createUserContext(userContext);
|
||||
}
|
||||
async installExtension(path) {
|
||||
const { result: { extension }, } = await this.session.send('webExtension.install', {
|
||||
extensionData: { type: 'path', path },
|
||||
});
|
||||
return extension;
|
||||
}
|
||||
async uninstallExtension(id) {
|
||||
await this.session.send('webExtension.uninstall', { extension: id });
|
||||
}
|
||||
async setClientWindowState(params) {
|
||||
await this.session.send('browser.setClientWindowState', params);
|
||||
}
|
||||
async getClientWindowInfo(windowId) {
|
||||
const { result: { clientWindows }, } = await this.session.send('browser.getClientWindows', {});
|
||||
const window = clientWindows.find(window => {
|
||||
return window.clientWindow === windowId;
|
||||
});
|
||||
if (!window) {
|
||||
throw new Error('Window not found');
|
||||
}
|
||||
return window;
|
||||
}
|
||||
[(_dispose_decorators = [inertIfDisposed], _close_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _addPreloadScript_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _removeIntercept_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _removePreloadScript_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _createUserContext_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _installExtension_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _uninstallExtension_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _setClientWindowState_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], _getClientWindowInfo_decorators = [throwIfDisposed(browser => {
|
||||
// SAFETY: By definition of `disposed`, `#reason` is defined.
|
||||
return browser.#reason;
|
||||
})], disposeSymbol)]() {
|
||||
this.#reason ??=
|
||||
'Browser was disconnected, probably because the session ended.';
|
||||
if (this.closed) {
|
||||
this.emit('closed', this.#reason);
|
||||
}
|
||||
this.emit('disconnected', this.#reason);
|
||||
this.#disposables.dispose();
|
||||
super[disposeSymbol]();
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { Browser };
|
||||
//# sourceMappingURL=Browser.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/Browser.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/Browser.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
130
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.d.ts
generated
vendored
Normal file
130
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type * as Bidi from 'webdriver-bidi-protocol';
|
||||
import type { BluetoothEmulation } from '../../api/BluetoothEmulation.js';
|
||||
import type { DeviceRequestPrompt } from '../../api/DeviceRequestPrompt.js';
|
||||
import { EventEmitter } from '../../common/EventEmitter.js';
|
||||
import { disposeSymbol } from '../../util/disposable.js';
|
||||
import type { AddPreloadScriptOptions } from './Browser.js';
|
||||
import { Navigation } from './Navigation.js';
|
||||
import type { DedicatedWorkerRealm } from './Realm.js';
|
||||
import { WindowRealm } from './Realm.js';
|
||||
import { Request } from './Request.js';
|
||||
import type { UserContext } from './UserContext.js';
|
||||
import { UserPrompt } from './UserPrompt.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type AddInterceptOptions = Omit<Bidi.Network.AddInterceptParameters, 'contexts'>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type CaptureScreenshotOptions = Omit<Bidi.BrowsingContext.CaptureScreenshotParameters, 'context'>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type ReloadOptions = Omit<Bidi.BrowsingContext.ReloadParameters, 'context'>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type PrintOptions = Omit<Bidi.BrowsingContext.PrintParameters, 'context'>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type HandleUserPromptOptions = Omit<Bidi.BrowsingContext.HandleUserPromptParameters, 'context'>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type SetViewportOptions = Omit<Bidi.BrowsingContext.SetViewportParameters, 'context'>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type GetCookiesOptions = Omit<Bidi.Storage.GetCookiesParameters, 'partition'>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type SetGeoLocationOverrideOptions = Bidi.Emulation.SetGeolocationOverrideParameters;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class BrowsingContext extends EventEmitter<{
|
||||
/** Emitted when this context is closed. */
|
||||
closed: string;
|
||||
/** Emitted when a child browsing context is created. */
|
||||
browsingcontext: BrowsingContext;
|
||||
/** Emitted whenever a navigation occurs. */
|
||||
navigation: Navigation;
|
||||
/** Emitted whenever a file dialog is opened occurs. */
|
||||
filedialogopened: Bidi.Input.FileDialogInfo;
|
||||
/** Emitted whenever a request is made. */
|
||||
request: Request;
|
||||
/** Emitted whenever a log entry is added. */
|
||||
log: Bidi.Log.Entry;
|
||||
/** Emitted whenever a prompt is opened. */
|
||||
userprompt: UserPrompt;
|
||||
/** Emitted whenever the frame history is updated. */
|
||||
historyUpdated: void;
|
||||
/** Emitted whenever the frame emits `DOMContentLoaded` */
|
||||
DOMContentLoaded: void;
|
||||
/** Emitted whenever the frame emits `load` */
|
||||
load: void;
|
||||
/** Emitted whenever a dedicated worker is created */
|
||||
worker: DedicatedWorkerRealm;
|
||||
}> {
|
||||
#private;
|
||||
static from(userContext: UserContext, parent: BrowsingContext | undefined, id: string, url: string, originalOpener: string | null, clientWindow: string): BrowsingContext;
|
||||
readonly defaultRealm: WindowRealm;
|
||||
readonly id: string;
|
||||
readonly parent: BrowsingContext | undefined;
|
||||
readonly userContext: UserContext;
|
||||
readonly originalOpener: string | null;
|
||||
readonly windowId: string;
|
||||
private constructor();
|
||||
get children(): Iterable<BrowsingContext>;
|
||||
get closed(): boolean;
|
||||
get disposed(): boolean;
|
||||
get realms(): Iterable<WindowRealm>;
|
||||
get top(): BrowsingContext;
|
||||
get url(): string;
|
||||
private dispose;
|
||||
activate(): Promise<void>;
|
||||
captureScreenshot(options?: CaptureScreenshotOptions): Promise<string>;
|
||||
close(promptUnload?: boolean): Promise<void>;
|
||||
traverseHistory(delta: number): Promise<void>;
|
||||
navigate(url: string, wait?: Bidi.BrowsingContext.ReadinessState): Promise<void>;
|
||||
reload(options?: ReloadOptions): Promise<void>;
|
||||
setCacheBehavior(cacheBehavior: 'default' | 'bypass'): Promise<void>;
|
||||
print(options?: PrintOptions): Promise<string>;
|
||||
handleUserPrompt(options?: HandleUserPromptOptions): Promise<void>;
|
||||
setViewport(options?: SetViewportOptions): Promise<void>;
|
||||
setTouchOverride(maxTouchPoints: number | null): Promise<void>;
|
||||
performActions(actions: Bidi.Input.SourceActions[]): Promise<void>;
|
||||
releaseActions(): Promise<void>;
|
||||
createWindowRealm(sandbox: string): WindowRealm;
|
||||
addPreloadScript(functionDeclaration: string, options?: AddPreloadScriptOptions): Promise<string>;
|
||||
addIntercept(options: AddInterceptOptions): Promise<string>;
|
||||
removePreloadScript(script: string): Promise<void>;
|
||||
setGeolocationOverride(options: SetGeoLocationOverrideOptions): Promise<void>;
|
||||
setTimezoneOverride(timezoneId?: string): Promise<void>;
|
||||
setScreenOrientationOverride(screenOrientation: Bidi.Emulation.ScreenOrientation | null): Promise<void>;
|
||||
getCookies(options?: GetCookiesOptions): Promise<Bidi.Network.Cookie[]>;
|
||||
setCookie(cookie: Bidi.Storage.PartialCookie): Promise<void>;
|
||||
setFiles(element: Bidi.Script.SharedReference, files: string[]): Promise<void>;
|
||||
subscribe(events: [string, ...string[]]): Promise<void>;
|
||||
addInterception(events: [string, ...string[]]): Promise<void>;
|
||||
[disposeSymbol](): void;
|
||||
deleteCookie(...cookieFilters: Bidi.Storage.CookieFilter[]): Promise<void>;
|
||||
locateNodes(locator: Bidi.BrowsingContext.Locator, startNodes?: Bidi.Script.SharedReference[]): Promise<Bidi.Script.NodeRemoteValue[]>;
|
||||
setJavaScriptEnabled(enabled: boolean): Promise<void>;
|
||||
isJavaScriptEnabled(): boolean;
|
||||
setUserAgent(userAgent: string | null): Promise<void>;
|
||||
setClientHintsOverride(clientHints: Bidi.BidiUaClientHints.UserAgentClientHints.ClientHintsMetadata | null): Promise<void>;
|
||||
setOfflineMode(enabled: boolean): Promise<void>;
|
||||
get bluetooth(): BluetoothEmulation;
|
||||
waitForDevicePrompt(timeout: number, signal?: AbortSignal): Promise<DeviceRequestPrompt>;
|
||||
setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=BrowsingContext.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
628
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.js
generated
vendored
Normal file
628
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.js
generated
vendored
Normal file
@@ -0,0 +1,628 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
||||
var useValue = arguments.length > 2;
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
||||
}
|
||||
return useValue ? value : void 0;
|
||||
};
|
||||
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
||||
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
||||
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
||||
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
||||
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
||||
var _, done = false;
|
||||
for (var i = decorators.length - 1; i >= 0; i--) {
|
||||
var context = {};
|
||||
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
||||
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
||||
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
||||
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
||||
if (kind === "accessor") {
|
||||
if (result === void 0) continue;
|
||||
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
||||
if (_ = accept(result.get)) descriptor.get = _;
|
||||
if (_ = accept(result.set)) descriptor.set = _;
|
||||
if (_ = accept(result.init)) initializers.unshift(_);
|
||||
}
|
||||
else if (_ = accept(result)) {
|
||||
if (kind === "field") initializers.unshift(_);
|
||||
else descriptor[key] = _;
|
||||
}
|
||||
}
|
||||
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
||||
done = true;
|
||||
};
|
||||
import { EventEmitter } from '../../common/EventEmitter.js';
|
||||
import { isString } from '../../common/util.js';
|
||||
import { assert } from '../../util/assert.js';
|
||||
import { inertIfDisposed, throwIfDisposed } from '../../util/decorators.js';
|
||||
import { DisposableStack, disposeSymbol } from '../../util/disposable.js';
|
||||
import { BidiBluetoothEmulation } from '../BluetoothEmulation.js';
|
||||
import { BidiDeviceRequestPromptManager } from '../DeviceRequestPrompt.js';
|
||||
import { Navigation } from './Navigation.js';
|
||||
import { WindowRealm } from './Realm.js';
|
||||
import { Request } from './Request.js';
|
||||
import { UserPrompt } from './UserPrompt.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
let BrowsingContext = (() => {
|
||||
var _a;
|
||||
let _classSuper = EventEmitter;
|
||||
let _instanceExtraInitializers = [];
|
||||
let _dispose_decorators;
|
||||
let _activate_decorators;
|
||||
let _captureScreenshot_decorators;
|
||||
let _close_decorators;
|
||||
let _traverseHistory_decorators;
|
||||
let _navigate_decorators;
|
||||
let _reload_decorators;
|
||||
let _setCacheBehavior_decorators;
|
||||
let _print_decorators;
|
||||
let _handleUserPrompt_decorators;
|
||||
let _setViewport_decorators;
|
||||
let _setTouchOverride_decorators;
|
||||
let _performActions_decorators;
|
||||
let _releaseActions_decorators;
|
||||
let _createWindowRealm_decorators;
|
||||
let _addPreloadScript_decorators;
|
||||
let _addIntercept_decorators;
|
||||
let _removePreloadScript_decorators;
|
||||
let _setGeolocationOverride_decorators;
|
||||
let _setTimezoneOverride_decorators;
|
||||
let _setScreenOrientationOverride_decorators;
|
||||
let _getCookies_decorators;
|
||||
let _setCookie_decorators;
|
||||
let _setFiles_decorators;
|
||||
let _subscribe_decorators;
|
||||
let _addInterception_decorators;
|
||||
let _deleteCookie_decorators;
|
||||
let _locateNodes_decorators;
|
||||
return class BrowsingContext extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_deleteCookie_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})];
|
||||
_locateNodes_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})];
|
||||
__esDecorate(this, null, _dispose_decorators, { kind: "method", name: "dispose", static: false, private: false, access: { has: obj => "dispose" in obj, get: obj => obj.dispose }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _activate_decorators, { kind: "method", name: "activate", static: false, private: false, access: { has: obj => "activate" in obj, get: obj => obj.activate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _captureScreenshot_decorators, { kind: "method", name: "captureScreenshot", static: false, private: false, access: { has: obj => "captureScreenshot" in obj, get: obj => obj.captureScreenshot }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _close_decorators, { kind: "method", name: "close", static: false, private: false, access: { has: obj => "close" in obj, get: obj => obj.close }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _traverseHistory_decorators, { kind: "method", name: "traverseHistory", static: false, private: false, access: { has: obj => "traverseHistory" in obj, get: obj => obj.traverseHistory }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _navigate_decorators, { kind: "method", name: "navigate", static: false, private: false, access: { has: obj => "navigate" in obj, get: obj => obj.navigate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _reload_decorators, { kind: "method", name: "reload", static: false, private: false, access: { has: obj => "reload" in obj, get: obj => obj.reload }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setCacheBehavior_decorators, { kind: "method", name: "setCacheBehavior", static: false, private: false, access: { has: obj => "setCacheBehavior" in obj, get: obj => obj.setCacheBehavior }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _print_decorators, { kind: "method", name: "print", static: false, private: false, access: { has: obj => "print" in obj, get: obj => obj.print }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _handleUserPrompt_decorators, { kind: "method", name: "handleUserPrompt", static: false, private: false, access: { has: obj => "handleUserPrompt" in obj, get: obj => obj.handleUserPrompt }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setViewport_decorators, { kind: "method", name: "setViewport", static: false, private: false, access: { has: obj => "setViewport" in obj, get: obj => obj.setViewport }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setTouchOverride_decorators, { kind: "method", name: "setTouchOverride", static: false, private: false, access: { has: obj => "setTouchOverride" in obj, get: obj => obj.setTouchOverride }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _performActions_decorators, { kind: "method", name: "performActions", static: false, private: false, access: { has: obj => "performActions" in obj, get: obj => obj.performActions }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _releaseActions_decorators, { kind: "method", name: "releaseActions", static: false, private: false, access: { has: obj => "releaseActions" in obj, get: obj => obj.releaseActions }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _createWindowRealm_decorators, { kind: "method", name: "createWindowRealm", static: false, private: false, access: { has: obj => "createWindowRealm" in obj, get: obj => obj.createWindowRealm }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _addPreloadScript_decorators, { kind: "method", name: "addPreloadScript", static: false, private: false, access: { has: obj => "addPreloadScript" in obj, get: obj => obj.addPreloadScript }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _addIntercept_decorators, { kind: "method", name: "addIntercept", static: false, private: false, access: { has: obj => "addIntercept" in obj, get: obj => obj.addIntercept }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _removePreloadScript_decorators, { kind: "method", name: "removePreloadScript", static: false, private: false, access: { has: obj => "removePreloadScript" in obj, get: obj => obj.removePreloadScript }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setGeolocationOverride_decorators, { kind: "method", name: "setGeolocationOverride", static: false, private: false, access: { has: obj => "setGeolocationOverride" in obj, get: obj => obj.setGeolocationOverride }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setTimezoneOverride_decorators, { kind: "method", name: "setTimezoneOverride", static: false, private: false, access: { has: obj => "setTimezoneOverride" in obj, get: obj => obj.setTimezoneOverride }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setScreenOrientationOverride_decorators, { kind: "method", name: "setScreenOrientationOverride", static: false, private: false, access: { has: obj => "setScreenOrientationOverride" in obj, get: obj => obj.setScreenOrientationOverride }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _getCookies_decorators, { kind: "method", name: "getCookies", static: false, private: false, access: { has: obj => "getCookies" in obj, get: obj => obj.getCookies }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setCookie_decorators, { kind: "method", name: "setCookie", static: false, private: false, access: { has: obj => "setCookie" in obj, get: obj => obj.setCookie }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _setFiles_decorators, { kind: "method", name: "setFiles", static: false, private: false, access: { has: obj => "setFiles" in obj, get: obj => obj.setFiles }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _subscribe_decorators, { kind: "method", name: "subscribe", static: false, private: false, access: { has: obj => "subscribe" in obj, get: obj => obj.subscribe }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _addInterception_decorators, { kind: "method", name: "addInterception", static: false, private: false, access: { has: obj => "addInterception" in obj, get: obj => obj.addInterception }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _deleteCookie_decorators, { kind: "method", name: "deleteCookie", static: false, private: false, access: { has: obj => "deleteCookie" in obj, get: obj => obj.deleteCookie }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _locateNodes_decorators, { kind: "method", name: "locateNodes", static: false, private: false, access: { has: obj => "locateNodes" in obj, get: obj => obj.locateNodes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
static from(userContext, parent, id, url, originalOpener, clientWindow) {
|
||||
const browsingContext = new BrowsingContext(userContext, parent, id, url, originalOpener, clientWindow);
|
||||
browsingContext.#initialize();
|
||||
return browsingContext;
|
||||
}
|
||||
#navigation = __runInitializers(this, _instanceExtraInitializers);
|
||||
#reason;
|
||||
#url;
|
||||
// Indicated whether client hints have been set to non-default.
|
||||
#clientHintsAreSet = false;
|
||||
#children = new Map();
|
||||
#disposables = new DisposableStack();
|
||||
#realms = new Map();
|
||||
defaultRealm;
|
||||
id;
|
||||
parent;
|
||||
userContext;
|
||||
originalOpener;
|
||||
windowId;
|
||||
#emulationState = { javaScriptEnabled: true };
|
||||
#bluetoothEmulation;
|
||||
#deviceRequestPromptManager;
|
||||
constructor(userContext, parent, id, url, originalOpener, clientWindow) {
|
||||
super();
|
||||
this.#url = url;
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
this.userContext = userContext;
|
||||
this.originalOpener = originalOpener;
|
||||
this.windowId = clientWindow;
|
||||
this.defaultRealm = this.#createWindowRealm();
|
||||
this.#bluetoothEmulation = new BidiBluetoothEmulation(this.id, this.#session);
|
||||
this.#deviceRequestPromptManager = new BidiDeviceRequestPromptManager(this.id, this.#session);
|
||||
}
|
||||
#initialize() {
|
||||
const userContextEmitter = this.#disposables.use(new EventEmitter(this.userContext));
|
||||
userContextEmitter.once('closed', reason => {
|
||||
this.dispose(`Browsing context already closed: ${reason}`);
|
||||
});
|
||||
const sessionEmitter = this.#disposables.use(new EventEmitter(this.#session));
|
||||
sessionEmitter.on('input.fileDialogOpened', info => {
|
||||
if (this.id !== info.context) {
|
||||
return;
|
||||
}
|
||||
this.emit('filedialogopened', info);
|
||||
});
|
||||
sessionEmitter.on('browsingContext.contextCreated', info => {
|
||||
if (info.parent !== this.id) {
|
||||
return;
|
||||
}
|
||||
const browsingContext = BrowsingContext.from(this.userContext, this, info.context, info.url, info.originalOpener, info.clientWindow);
|
||||
this.#children.set(info.context, browsingContext);
|
||||
const browsingContextEmitter = this.#disposables.use(new EventEmitter(browsingContext));
|
||||
browsingContextEmitter.once('closed', () => {
|
||||
browsingContextEmitter.removeAllListeners();
|
||||
this.#children.delete(browsingContext.id);
|
||||
});
|
||||
this.emit('browsingcontext', browsingContext);
|
||||
});
|
||||
sessionEmitter.on('browsingContext.contextDestroyed', info => {
|
||||
if (info.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
this.dispose('Browsing context already closed.');
|
||||
});
|
||||
sessionEmitter.on('browsingContext.historyUpdated', info => {
|
||||
if (info.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
this.#url = info.url;
|
||||
this.emit('historyUpdated', undefined);
|
||||
});
|
||||
sessionEmitter.on('browsingContext.domContentLoaded', info => {
|
||||
if (info.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
this.#url = info.url;
|
||||
this.emit('DOMContentLoaded', undefined);
|
||||
});
|
||||
sessionEmitter.on('browsingContext.load', info => {
|
||||
if (info.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
this.#url = info.url;
|
||||
this.emit('load', undefined);
|
||||
});
|
||||
sessionEmitter.on('browsingContext.navigationStarted', info => {
|
||||
if (info.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
// Note: we should not update this.#url at this point since the context
|
||||
// has not finished navigating to the info.url yet.
|
||||
// If the navigation hasn't finished, then this is nested navigation. The
|
||||
// current navigation will handle this.
|
||||
if (this.#navigation !== undefined && !this.#navigation.disposed) {
|
||||
return;
|
||||
}
|
||||
// Note the navigation ID is null for this event.
|
||||
this.#navigation = Navigation.from(this);
|
||||
const navigationEmitter = this.#disposables.use(new EventEmitter(this.#navigation));
|
||||
for (const eventName of ['fragment', 'failed', 'aborted']) {
|
||||
navigationEmitter.once(eventName, ({ url }) => {
|
||||
navigationEmitter[disposeSymbol]();
|
||||
this.#url = url;
|
||||
});
|
||||
}
|
||||
this.emit('navigation', this.#navigation);
|
||||
});
|
||||
sessionEmitter.on('network.beforeRequestSent', event => {
|
||||
if (event.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
if (event.redirectCount > 0) {
|
||||
// Means the request is a redirect. This is handled in Request.
|
||||
// Or an Auth event was issued
|
||||
return;
|
||||
}
|
||||
const request = Request.from(this, event);
|
||||
this.emit('request', request);
|
||||
});
|
||||
sessionEmitter.on('log.entryAdded', entry => {
|
||||
if (entry.source.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
this.emit('log', entry);
|
||||
});
|
||||
sessionEmitter.on('browsingContext.userPromptOpened', info => {
|
||||
if (info.context !== this.id) {
|
||||
return;
|
||||
}
|
||||
const userPrompt = UserPrompt.from(this, info);
|
||||
this.emit('userprompt', userPrompt);
|
||||
});
|
||||
}
|
||||
get #session() {
|
||||
return this.userContext.browser.session;
|
||||
}
|
||||
get children() {
|
||||
return this.#children.values();
|
||||
}
|
||||
get closed() {
|
||||
return this.#reason !== undefined;
|
||||
}
|
||||
get disposed() {
|
||||
return this.closed;
|
||||
}
|
||||
get realms() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias -- Required
|
||||
const self = this;
|
||||
return (function* () {
|
||||
yield self.defaultRealm;
|
||||
yield* self.#realms.values();
|
||||
})();
|
||||
}
|
||||
get top() {
|
||||
let context = this;
|
||||
for (let { parent } = context; parent; { parent } = context) {
|
||||
context = parent;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
get url() {
|
||||
return this.#url;
|
||||
}
|
||||
#createWindowRealm(sandbox) {
|
||||
const realm = WindowRealm.from(this, sandbox);
|
||||
realm.on('worker', realm => {
|
||||
this.emit('worker', realm);
|
||||
});
|
||||
return realm;
|
||||
}
|
||||
dispose(reason) {
|
||||
this.#reason = reason;
|
||||
for (const context of this.#children.values()) {
|
||||
context.dispose('Parent browsing context was disposed');
|
||||
}
|
||||
this[disposeSymbol]();
|
||||
}
|
||||
async activate() {
|
||||
await this.#session.send('browsingContext.activate', {
|
||||
context: this.id,
|
||||
});
|
||||
}
|
||||
async captureScreenshot(options = {}) {
|
||||
const { result: { data }, } = await this.#session.send('browsingContext.captureScreenshot', {
|
||||
context: this.id,
|
||||
...options,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
async close(promptUnload) {
|
||||
// The WebDriver BiDi specification only allows closing top-level browsing contexts.
|
||||
// Closing a top-level context automatically closes all its children, so there is
|
||||
// no need to explicitly close nested contexts.
|
||||
await this.#session.send('browsingContext.close', {
|
||||
context: this.id,
|
||||
promptUnload,
|
||||
});
|
||||
}
|
||||
async traverseHistory(delta) {
|
||||
await this.#session.send('browsingContext.traverseHistory', {
|
||||
context: this.id,
|
||||
delta,
|
||||
});
|
||||
}
|
||||
async navigate(url, wait) {
|
||||
await this.#session.send('browsingContext.navigate', {
|
||||
context: this.id,
|
||||
url,
|
||||
wait,
|
||||
});
|
||||
}
|
||||
async reload(options = {}) {
|
||||
await this.#session.send('browsingContext.reload', {
|
||||
context: this.id,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
async setCacheBehavior(cacheBehavior) {
|
||||
await this.#session.send('network.setCacheBehavior', {
|
||||
contexts: [this.id],
|
||||
cacheBehavior,
|
||||
});
|
||||
}
|
||||
async print(options = {}) {
|
||||
const { result: { data }, } = await this.#session.send('browsingContext.print', {
|
||||
context: this.id,
|
||||
...options,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
async handleUserPrompt(options = {}) {
|
||||
await this.#session.send('browsingContext.handleUserPrompt', {
|
||||
context: this.id,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
async setViewport(options = {}) {
|
||||
await this.#session.send('browsingContext.setViewport', {
|
||||
context: this.id,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
async setTouchOverride(maxTouchPoints) {
|
||||
await this.#session.send('emulation.setTouchOverride', {
|
||||
contexts: [this.id],
|
||||
maxTouchPoints,
|
||||
});
|
||||
}
|
||||
async performActions(actions) {
|
||||
await this.#session.send('input.performActions', {
|
||||
context: this.id,
|
||||
actions,
|
||||
});
|
||||
}
|
||||
async releaseActions() {
|
||||
await this.#session.send('input.releaseActions', {
|
||||
context: this.id,
|
||||
});
|
||||
}
|
||||
createWindowRealm(sandbox) {
|
||||
return this.#createWindowRealm(sandbox);
|
||||
}
|
||||
async addPreloadScript(functionDeclaration, options = {}) {
|
||||
return await this.userContext.browser.addPreloadScript(functionDeclaration, {
|
||||
...options,
|
||||
contexts: [this],
|
||||
});
|
||||
}
|
||||
async addIntercept(options) {
|
||||
const { result: { intercept }, } = await this.userContext.browser.session.send('network.addIntercept', {
|
||||
...options,
|
||||
contexts: [this.id],
|
||||
});
|
||||
return intercept;
|
||||
}
|
||||
async removePreloadScript(script) {
|
||||
await this.userContext.browser.removePreloadScript(script);
|
||||
}
|
||||
async setGeolocationOverride(options) {
|
||||
if (!('coordinates' in options)) {
|
||||
throw new Error('Missing coordinates');
|
||||
}
|
||||
await this.userContext.browser.session.send('emulation.setGeolocationOverride', {
|
||||
coordinates: options.coordinates,
|
||||
contexts: [this.id],
|
||||
});
|
||||
}
|
||||
async setTimezoneOverride(timezoneId) {
|
||||
if (timezoneId?.startsWith('GMT')) {
|
||||
// CDP requires `GMT` prefix before timezone offset, while BiDi does not. Remove the
|
||||
// `GMT` for interop between CDP and BiDi.
|
||||
timezoneId = timezoneId?.replace('GMT', '');
|
||||
}
|
||||
await this.userContext.browser.session.send('emulation.setTimezoneOverride', {
|
||||
timezone: timezoneId ?? null,
|
||||
contexts: [this.id],
|
||||
});
|
||||
}
|
||||
async setScreenOrientationOverride(screenOrientation) {
|
||||
await this.#session.send('emulation.setScreenOrientationOverride', {
|
||||
screenOrientation,
|
||||
contexts: [this.id],
|
||||
});
|
||||
}
|
||||
async getCookies(options = {}) {
|
||||
const { result: { cookies }, } = await this.#session.send('storage.getCookies', {
|
||||
...options,
|
||||
partition: {
|
||||
type: 'context',
|
||||
context: this.id,
|
||||
},
|
||||
});
|
||||
return cookies;
|
||||
}
|
||||
async setCookie(cookie) {
|
||||
await this.#session.send('storage.setCookie', {
|
||||
cookie,
|
||||
partition: {
|
||||
type: 'context',
|
||||
context: this.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
async setFiles(element, files) {
|
||||
await this.#session.send('input.setFiles', {
|
||||
context: this.id,
|
||||
element,
|
||||
files,
|
||||
});
|
||||
}
|
||||
async subscribe(events) {
|
||||
await this.#session.subscribe(events, [this.id]);
|
||||
}
|
||||
async addInterception(events) {
|
||||
await this.#session.subscribe(events, [this.id]);
|
||||
}
|
||||
[(_dispose_decorators = [inertIfDisposed], _activate_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _captureScreenshot_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _close_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _traverseHistory_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _navigate_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _reload_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setCacheBehavior_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _print_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _handleUserPrompt_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setViewport_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setTouchOverride_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _performActions_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _releaseActions_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _createWindowRealm_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _addPreloadScript_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _addIntercept_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _removePreloadScript_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setGeolocationOverride_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setTimezoneOverride_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setScreenOrientationOverride_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _getCookies_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setCookie_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _setFiles_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _subscribe_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], _addInterception_decorators = [throwIfDisposed(context => {
|
||||
// SAFETY: Disposal implies this exists.
|
||||
return context.#reason;
|
||||
})], disposeSymbol)]() {
|
||||
this.#reason ??=
|
||||
'Browsing context already closed, probably because the user context closed.';
|
||||
this.emit('closed', this.#reason);
|
||||
this.#disposables.dispose();
|
||||
super[disposeSymbol]();
|
||||
}
|
||||
async deleteCookie(...cookieFilters) {
|
||||
await Promise.all(cookieFilters.map(async (filter) => {
|
||||
await this.#session.send('storage.deleteCookies', {
|
||||
filter: filter,
|
||||
partition: {
|
||||
type: 'context',
|
||||
context: this.id,
|
||||
},
|
||||
});
|
||||
}));
|
||||
}
|
||||
async locateNodes(locator, startNodes = []) {
|
||||
// TODO: add other locateNodes options if needed.
|
||||
const result = await this.#session.send('browsingContext.locateNodes', {
|
||||
context: this.id,
|
||||
locator,
|
||||
startNodes: startNodes.length
|
||||
? startNodes
|
||||
: undefined,
|
||||
});
|
||||
return result.result.nodes;
|
||||
}
|
||||
async setJavaScriptEnabled(enabled) {
|
||||
await this.userContext.browser.session.send('emulation.setScriptingEnabled', {
|
||||
// Enabled `null` means `default`, `false` means `disabled`.
|
||||
enabled: enabled ? null : false,
|
||||
contexts: [this.id],
|
||||
});
|
||||
this.#emulationState.javaScriptEnabled = enabled;
|
||||
}
|
||||
isJavaScriptEnabled() {
|
||||
return this.#emulationState.javaScriptEnabled;
|
||||
}
|
||||
async setUserAgent(userAgent) {
|
||||
await this.#session.send('emulation.setUserAgentOverride', {
|
||||
userAgent,
|
||||
contexts: [this.id],
|
||||
});
|
||||
}
|
||||
async setClientHintsOverride(clientHints) {
|
||||
if (clientHints === null && !this.#clientHintsAreSet) {
|
||||
// Ignore the call, as the client hints are not supposed to be changed. Required to
|
||||
// avoid breakage with browsers that don't support client hints emulation.
|
||||
return;
|
||||
}
|
||||
this.#clientHintsAreSet = true;
|
||||
await this.#session.send('userAgentClientHints.setClientHintsOverride', {
|
||||
clientHints,
|
||||
contexts: [this.id],
|
||||
});
|
||||
}
|
||||
async setOfflineMode(enabled) {
|
||||
await this.#session.send('emulation.setNetworkConditions', {
|
||||
networkConditions: enabled
|
||||
? {
|
||||
type: 'offline',
|
||||
}
|
||||
: null,
|
||||
contexts: [this.id],
|
||||
});
|
||||
}
|
||||
get bluetooth() {
|
||||
return this.#bluetoothEmulation;
|
||||
}
|
||||
async waitForDevicePrompt(timeout, signal) {
|
||||
return await this.#deviceRequestPromptManager.waitForDevicePrompt(timeout, signal);
|
||||
}
|
||||
async setExtraHTTPHeaders(headers) {
|
||||
await this.#session.send('network.setExtraHeaders', {
|
||||
headers: Object.entries(headers).map(([key, value]) => {
|
||||
assert(isString(value), `Expected value of header "${key}" to be String, but "${typeof value}" is found.`);
|
||||
return {
|
||||
name: key.toLowerCase(),
|
||||
value: { type: 'string', value: value },
|
||||
};
|
||||
}),
|
||||
contexts: [this.id],
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BrowsingContext };
|
||||
//# sourceMappingURL=BrowsingContext.js.map
|
||||
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/puppeteer/bidi/core/BrowsingContext.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user