Add Brave CDP automation, replace Oracle browser mode
Connects to user's running Brave via Chrome DevTools Protocol to automate ChatGPT interaction. Uses puppeteer-core to open a tab, send the prompt, wait for response, and extract the result. No cookies, no separate profiles, no copy/paste. Just connects to the browser where the user is already logged in. One-time setup: relaunch Brave with --remote-debugging-port=9222 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1
node_modules/puppeteer-core/lib/esm/package.json
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
96
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.d.ts
generated
vendored
Normal file
96
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @public
|
||||
* Emulated bluetooth adapter state.
|
||||
*/
|
||||
export type AdapterState = 'absent' | 'powered-off' | 'powered-on';
|
||||
/**
|
||||
* @public
|
||||
* Represents the simulated bluetooth peripheral's manufacturer data.
|
||||
*/
|
||||
export interface BluetoothManufacturerData {
|
||||
/**
|
||||
* The company identifier, as defined by the {@link https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/|Bluetooth SIG}.
|
||||
*/
|
||||
key: number;
|
||||
/**
|
||||
* The manufacturer-specific data as a base64-encoded string.
|
||||
*/
|
||||
data: string;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
* A bluetooth peripheral to be simulated.
|
||||
*/
|
||||
export interface PreconnectedPeripheral {
|
||||
address: string;
|
||||
name: string;
|
||||
manufacturerData: BluetoothManufacturerData[];
|
||||
knownServiceUuids: string[];
|
||||
}
|
||||
/**
|
||||
* Exposes the bluetooth emulation abilities.
|
||||
*
|
||||
* @remarks {@link https://webbluetoothcg.github.io/web-bluetooth/#simulated-bluetooth-adapter|Web Bluetooth specification}
|
||||
* requires the emulated adapters should be isolated per top-level navigable. However,
|
||||
* at the moment Chromium's bluetooth emulation implementation is tight to the browser
|
||||
* context, not the page. This means the bluetooth emulation exposed from different pages
|
||||
* of the same browser context would interfere their states.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* await page.bluetooth.emulateAdapter('powered-on');
|
||||
* await page.bluetooth.simulatePreconnectedPeripheral({
|
||||
* address: '09:09:09:09:09:09',
|
||||
* name: 'SOME_NAME',
|
||||
* manufacturerData: [
|
||||
* {
|
||||
* key: 17,
|
||||
* data: 'AP8BAX8=',
|
||||
* },
|
||||
* ],
|
||||
* knownServiceUuids: ['12345678-1234-5678-9abc-def123456789'],
|
||||
* });
|
||||
* await page.bluetooth.disableEmulation();
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
* @public
|
||||
*/
|
||||
export interface BluetoothEmulation {
|
||||
/**
|
||||
* Emulate Bluetooth adapter. Required for bluetooth simulations
|
||||
* See {@link https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateAdapter-command|bluetooth.simulateAdapter}.
|
||||
*
|
||||
* @param state - The desired bluetooth adapter state.
|
||||
* @param leSupported - Mark if the adapter supports low-energy bluetooth.
|
||||
*
|
||||
* @experimental
|
||||
* @public
|
||||
*/
|
||||
emulateAdapter(state: AdapterState, leSupported?: boolean): Promise<void>;
|
||||
/**
|
||||
* Disable emulated bluetooth adapter.
|
||||
* See {@link https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-disableSimulation-command|bluetooth.disableSimulation}.
|
||||
*
|
||||
* @experimental
|
||||
* @public
|
||||
*/
|
||||
disableEmulation(): Promise<void>;
|
||||
/**
|
||||
* Simulated preconnected Bluetooth Peripheral.
|
||||
* See {@link https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateconnectedperipheral-command|bluetooth.simulatePreconnectedPeripheral}.
|
||||
*
|
||||
* @param preconnectedPeripheral - The peripheral to simulate.
|
||||
*
|
||||
* @experimental
|
||||
* @public
|
||||
*/
|
||||
simulatePreconnectedPeripheral(preconnectedPeripheral: PreconnectedPeripheral): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=BluetoothEmulation.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BluetoothEmulation.d.ts","sourceRoot":"","sources":["../../../../src/api/BluetoothEmulation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,YAAY,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,yBAAyB,EAAE,CAAC;IAC9C,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;OASG;IACH,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1E;;;;;;OAMG;IACH,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;;;;;;;OAQG;IACH,8BAA8B,CAC5B,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
|
||||
7
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.js
generated
vendored
Normal file
7
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
export {};
|
||||
//# sourceMappingURL=BluetoothEmulation.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BluetoothEmulation.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BluetoothEmulation.js","sourceRoot":"","sources":["../../../../src/api/BluetoothEmulation.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
||||
549
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.d.ts
generated
vendored
Normal file
549
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,549 @@
|
||||
/// <reference types="node" preserve="true" />
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { ChildProcess } from 'node:child_process';
|
||||
import type { Protocol } from 'devtools-protocol';
|
||||
import type { ProtocolType } from '../common/ConnectOptions.js';
|
||||
import type { Cookie, CookieData, DeleteCookiesRequest } from '../common/Cookie.js';
|
||||
import type { DownloadBehavior } from '../common/DownloadBehavior.js';
|
||||
import { EventEmitter, type EventType } from '../common/EventEmitter.js';
|
||||
import { asyncDisposeSymbol, disposeSymbol } from '../util/disposable.js';
|
||||
import type { BrowserContext } from './BrowserContext.js';
|
||||
import type { Page } from './Page.js';
|
||||
import type { Target } from './Target.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface BrowserContextOptions {
|
||||
/**
|
||||
* Proxy server with optional port to use for all requests.
|
||||
* Username and password can be set in `Page.authenticate`.
|
||||
*/
|
||||
proxyServer?: string;
|
||||
/**
|
||||
* Bypass the proxy for the given list of hosts.
|
||||
*/
|
||||
proxyBypassList?: string[];
|
||||
/**
|
||||
* Behavior definition for when downloading a file.
|
||||
*
|
||||
* @remarks
|
||||
* If not set, the default behavior will be used.
|
||||
*/
|
||||
downloadBehavior?: DownloadBehavior;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type BrowserCloseCallback = () => Promise<void> | void;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type TargetFilterCallback = (target: Target) => boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type IsPageTargetCallback = (target: Target) => boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare const WEB_PERMISSION_TO_PROTOCOL_PERMISSION: Map<Permission, Protocol.Browser.PermissionType>;
|
||||
/**
|
||||
* @public
|
||||
* @deprecated in favor of {@link PermissionDescriptor}.
|
||||
*/
|
||||
export type Permission = 'accelerometer' | 'ambient-light-sensor' | 'background-sync' | 'camera' | 'clipboard-read' | 'clipboard-sanitized-write' | 'clipboard-write' | 'geolocation' | 'gyroscope' | 'idle-detection' | 'keyboard-lock' | 'magnetometer' | 'microphone' | 'midi-sysex' | 'midi' | 'notifications' | 'payment-handler' | 'persistent-storage' | 'pointer-lock';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface PermissionDescriptor {
|
||||
name: string;
|
||||
userVisibleOnly?: boolean;
|
||||
sysex?: boolean;
|
||||
panTiltZoom?: boolean;
|
||||
allowWithoutSanitization?: boolean;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type PermissionState = 'granted' | 'denied' | 'prompt';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface WaitForTargetOptions {
|
||||
/**
|
||||
* Maximum wait time in milliseconds. Pass `0` to disable the timeout.
|
||||
*
|
||||
* @defaultValue `30_000`
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* A signal object that allows you to cancel a waitFor call.
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
/**
|
||||
* All the events a {@link Browser | browser instance} may emit.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const enum BrowserEvent {
|
||||
/**
|
||||
* Emitted when Puppeteer gets disconnected from the browser instance. This
|
||||
* might happen because either:
|
||||
*
|
||||
* - The browser closes/crashes or
|
||||
* - {@link Browser.disconnect} was called.
|
||||
*/
|
||||
Disconnected = "disconnected",
|
||||
/**
|
||||
* Emitted when the URL of a target changes. Contains a {@link Target}
|
||||
* instance.
|
||||
*
|
||||
* @remarks Note that this includes target changes in all browser
|
||||
* contexts.
|
||||
*/
|
||||
TargetChanged = "targetchanged",
|
||||
/**
|
||||
* Emitted when a target is created, for example when a new page is opened by
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
|
||||
* or by {@link Browser.newPage | browser.newPage}
|
||||
*
|
||||
* Contains a {@link Target} instance.
|
||||
*
|
||||
* @remarks Note that this includes target creations in all browser
|
||||
* contexts.
|
||||
*/
|
||||
TargetCreated = "targetcreated",
|
||||
/**
|
||||
* Emitted when a target is destroyed, for example when a page is closed.
|
||||
* Contains a {@link Target} instance.
|
||||
*
|
||||
* @remarks Note that this includes target destructions in all browser
|
||||
* contexts.
|
||||
*/
|
||||
TargetDestroyed = "targetdestroyed",
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
TargetDiscovered = "targetdiscovered"
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface BrowserEvents extends Record<EventType, unknown> {
|
||||
[BrowserEvent.Disconnected]: undefined;
|
||||
[BrowserEvent.TargetCreated]: Target;
|
||||
[BrowserEvent.TargetDestroyed]: Target;
|
||||
[BrowserEvent.TargetChanged]: Target;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
[BrowserEvent.TargetDiscovered]: Protocol.Target.TargetInfo;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
* @experimental
|
||||
*/
|
||||
export interface DebugInfo {
|
||||
pendingProtocolErrors: Error[];
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type WindowState = 'normal' | 'minimized' | 'maximized' | 'fullscreen';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface WindowBounds {
|
||||
left?: number;
|
||||
top?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
windowState?: WindowState;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type WindowId = string;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type CreatePageOptions = ({
|
||||
type?: 'tab';
|
||||
} | {
|
||||
type: 'window';
|
||||
windowBounds?: WindowBounds;
|
||||
}) & {
|
||||
/**
|
||||
* Whether to create the page in the background.
|
||||
*
|
||||
* @defaultValue `false`
|
||||
*/
|
||||
background?: boolean;
|
||||
};
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ScreenOrientation {
|
||||
angle: number;
|
||||
type: string;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ScreenInfo {
|
||||
left: number;
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
availLeft: number;
|
||||
availTop: number;
|
||||
availWidth: number;
|
||||
availHeight: number;
|
||||
devicePixelRatio: number;
|
||||
colorDepth: number;
|
||||
orientation: ScreenOrientation;
|
||||
isExtended: boolean;
|
||||
isInternal: boolean;
|
||||
isPrimary: boolean;
|
||||
label: string;
|
||||
id: string;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface WorkAreaInsets {
|
||||
top?: number;
|
||||
left?: number;
|
||||
bottom?: number;
|
||||
right?: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface AddScreenParams {
|
||||
left: number;
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
workAreaInsets?: WorkAreaInsets;
|
||||
devicePixelRatio?: number;
|
||||
rotation?: number;
|
||||
colorDepth?: number;
|
||||
label?: string;
|
||||
isInternal?: boolean;
|
||||
}
|
||||
/**
|
||||
* {@link Browser} represents a browser instance that is either:
|
||||
*
|
||||
* - connected to via {@link Puppeteer.connect} or
|
||||
* - launched by {@link PuppeteerNode.launch}.
|
||||
*
|
||||
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
|
||||
* documented in the {@link BrowserEvent} enum.
|
||||
*
|
||||
* @example Using a {@link Browser} to create a {@link Page}:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* await page.goto('https://example.com');
|
||||
* await browser.close();
|
||||
* ```
|
||||
*
|
||||
* @example Disconnecting from and reconnecting to a {@link Browser}:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* // Store the endpoint to be able to reconnect to the browser.
|
||||
* const browserWSEndpoint = browser.wsEndpoint();
|
||||
* // Disconnect puppeteer from the browser.
|
||||
* await browser.disconnect();
|
||||
*
|
||||
* // Use the endpoint to reestablish a connection
|
||||
* const browser2 = await puppeteer.connect({browserWSEndpoint});
|
||||
* // Close the browser.
|
||||
* await browser2.close();
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Browser extends EventEmitter<BrowserEvents> {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Gets the associated
|
||||
* {@link https://nodejs.org/api/child_process.html#class-childprocess | ChildProcess}.
|
||||
*
|
||||
* @returns `null` if this instance was connected to via
|
||||
* {@link Puppeteer.connect}.
|
||||
*/
|
||||
abstract process(): ChildProcess | null;
|
||||
/**
|
||||
* Creates a new {@link BrowserContext | browser context}.
|
||||
*
|
||||
* This won't share cookies/cache with other {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* // Create a new browser context.
|
||||
* const context = await browser.createBrowserContext();
|
||||
* // Create a new page in a pristine context.
|
||||
* const page = await context.newPage();
|
||||
* // Do stuff
|
||||
* await page.goto('https://example.com');
|
||||
* ```
|
||||
*/
|
||||
abstract createBrowserContext(options?: BrowserContextOptions): Promise<BrowserContext>;
|
||||
/**
|
||||
* Gets a list of open {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* In a newly-created {@link Browser | browser}, this will return a single
|
||||
* instance of {@link BrowserContext}.
|
||||
*/
|
||||
abstract browserContexts(): BrowserContext[];
|
||||
/**
|
||||
* Gets the default {@link BrowserContext | browser context}.
|
||||
*
|
||||
* @remarks The default {@link BrowserContext | browser context} cannot be
|
||||
* closed.
|
||||
*/
|
||||
abstract defaultBrowserContext(): BrowserContext;
|
||||
/**
|
||||
* Gets the WebSocket URL to connect to this {@link Browser | browser}.
|
||||
*
|
||||
* This is usually used with {@link Puppeteer.connect}.
|
||||
*
|
||||
* You can find the debugger URL (`webSocketDebuggerUrl`) from
|
||||
* `http://HOST:PORT/json/version`.
|
||||
*
|
||||
* See {@link https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target | browser endpoint}
|
||||
* for more information.
|
||||
*
|
||||
* @remarks The format is always `ws://HOST:PORT/devtools/browser/<id>`.
|
||||
*/
|
||||
abstract wsEndpoint(): string;
|
||||
/**
|
||||
* Creates a new {@link Page | page} in the
|
||||
* {@link Browser.defaultBrowserContext | default browser context}.
|
||||
*/
|
||||
abstract newPage(options?: CreatePageOptions): Promise<Page>;
|
||||
/**
|
||||
* Gets the specified window {@link WindowBounds | bounds}.
|
||||
*/
|
||||
abstract getWindowBounds(windowId: WindowId): Promise<WindowBounds>;
|
||||
/**
|
||||
* Sets the specified window {@link WindowBounds | bounds}.
|
||||
*/
|
||||
abstract setWindowBounds(windowId: WindowId, windowBounds: WindowBounds): Promise<void>;
|
||||
/**
|
||||
* Gets all active {@link Target | targets}.
|
||||
*
|
||||
* In case of multiple {@link BrowserContext | browser contexts}, this returns
|
||||
* all {@link Target | targets} in all
|
||||
* {@link BrowserContext | browser contexts}.
|
||||
*/
|
||||
abstract targets(): Target[];
|
||||
/**
|
||||
* Gets the {@link Target | target} associated with the
|
||||
* {@link Browser.defaultBrowserContext | default browser context}).
|
||||
*/
|
||||
abstract target(): Target;
|
||||
/**
|
||||
* Waits until a {@link Target | target} matching the given `predicate`
|
||||
* appears and returns it.
|
||||
*
|
||||
* This will look all open {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* @example Finding a target for a page opened via `window.open`:
|
||||
*
|
||||
* ```ts
|
||||
* await page.evaluate(() => window.open('https://www.example.com/'));
|
||||
* const newWindowTarget = await browser.waitForTarget(
|
||||
* target => target.url() === 'https://www.example.com/',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: WaitForTargetOptions): Promise<Target>;
|
||||
/**
|
||||
* Gets a list of all open {@link Page | pages} inside this {@link Browser}.
|
||||
*
|
||||
* If there are multiple {@link BrowserContext | browser contexts}, this
|
||||
* returns all {@link Page | pages} in all
|
||||
* {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* @param includeAll - experimental, setting to true includes all kinds of pages.
|
||||
*
|
||||
* @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
|
||||
* will not be listed here. You can find them using {@link Target.page}.
|
||||
*/
|
||||
pages(includeAll?: boolean): Promise<Page[]>;
|
||||
/**
|
||||
* Gets a string representing this {@link Browser | browser's} name and
|
||||
* version.
|
||||
*
|
||||
* For headless browser, this is similar to `"HeadlessChrome/61.0.3153.0"`. For
|
||||
* non-headless or new-headless, this is similar to `"Chrome/61.0.3153.0"`. For
|
||||
* Firefox, it is similar to `"Firefox/116.0a1"`.
|
||||
*
|
||||
* The format of {@link Browser.version} might change with future releases of
|
||||
* browsers.
|
||||
*/
|
||||
abstract version(): Promise<string>;
|
||||
/**
|
||||
* Gets this {@link Browser | browser's} original user agent.
|
||||
*
|
||||
* {@link Page | Pages} can override the user agent with
|
||||
* {@link Page.(setUserAgent:2) }.
|
||||
*
|
||||
*/
|
||||
abstract userAgent(): Promise<string>;
|
||||
/**
|
||||
* Closes this {@link Browser | browser} and all associated
|
||||
* {@link Page | pages}.
|
||||
*/
|
||||
abstract close(): Promise<void>;
|
||||
/**
|
||||
* Disconnects Puppeteer from this {@link Browser | browser}, but leaves the
|
||||
* process running.
|
||||
*/
|
||||
abstract disconnect(): Promise<void>;
|
||||
/**
|
||||
* Returns all cookies in the default {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.cookies | browser.defaultBrowserContext().cookies()}.
|
||||
*/
|
||||
cookies(): Promise<Cookie[]>;
|
||||
/**
|
||||
* Sets cookies in the default {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.setCookie | browser.defaultBrowserContext().setCookie()}.
|
||||
*/
|
||||
setCookie(...cookies: CookieData[]): Promise<void>;
|
||||
/**
|
||||
* Removes cookies from the default {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.deleteCookie | browser.defaultBrowserContext().deleteCookie()}.
|
||||
*/
|
||||
deleteCookie(...cookies: Cookie[]): Promise<void>;
|
||||
/**
|
||||
* Deletes cookies matching the provided filters from the default
|
||||
* {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.deleteMatchingCookies |
|
||||
* browser.defaultBrowserContext().deleteMatchingCookies()}.
|
||||
*/
|
||||
deleteMatchingCookies(...filters: DeleteCookiesRequest[]): Promise<void>;
|
||||
/**
|
||||
* Sets the permission for a specific origin in the default
|
||||
* {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.setPermission |
|
||||
* browser.defaultBrowserContext().setPermission()}.
|
||||
*
|
||||
* @param origin - The origin to set the permission for.
|
||||
* @param permission - The permission descriptor.
|
||||
* @param state - The state of the permission.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
setPermission(origin: string, ...permissions: Array<{
|
||||
permission: PermissionDescriptor;
|
||||
state: PermissionState;
|
||||
}>): Promise<void>;
|
||||
/**
|
||||
* Installs an extension and returns the ID. In Chrome, this is only
|
||||
* available if the browser was created using `pipe: true` and the
|
||||
* `--enable-unsafe-extension-debugging` flag is set.
|
||||
*/
|
||||
abstract installExtension(path: string): Promise<string>;
|
||||
/**
|
||||
* Uninstalls an extension. In Chrome, this is only available if the browser
|
||||
* was created using `pipe: true` and the
|
||||
* `--enable-unsafe-extension-debugging` flag is set.
|
||||
*/
|
||||
abstract uninstallExtension(id: string): Promise<void>;
|
||||
/**
|
||||
* Gets a list of {@link ScreenInfo | screen information objects}.
|
||||
*/
|
||||
abstract screens(): Promise<ScreenInfo[]>;
|
||||
/**
|
||||
* Adds a new screen, returns the added {@link ScreenInfo | screen information object}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Only supported in headless mode.
|
||||
*/
|
||||
abstract addScreen(params: AddScreenParams): Promise<ScreenInfo>;
|
||||
/**
|
||||
* Removes a screen.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Only supported in headless mode. Fails if the primary screen id is specified.
|
||||
*/
|
||||
abstract removeScreen(screenId: string): Promise<void>;
|
||||
/**
|
||||
* Whether Puppeteer is connected to this {@link Browser | browser}.
|
||||
*
|
||||
* @deprecated Use {@link Browser | Browser.connected}.
|
||||
*/
|
||||
isConnected(): boolean;
|
||||
/**
|
||||
* Whether Puppeteer is connected to this {@link Browser | browser}.
|
||||
*/
|
||||
abstract get connected(): boolean;
|
||||
/** @internal */
|
||||
[disposeSymbol](): void;
|
||||
/** @internal */
|
||||
[asyncDisposeSymbol](): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract get protocol(): ProtocolType;
|
||||
/**
|
||||
* Get debug information from Puppeteer.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Currently, includes pending protocol calls. In the future, we might add more info.
|
||||
*
|
||||
* @public
|
||||
* @experimental
|
||||
*/
|
||||
abstract get debugInfo(): DebugInfo;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract isNetworkEnabled(): boolean;
|
||||
}
|
||||
//# sourceMappingURL=Browser.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
204
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.js
generated
vendored
Normal file
204
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.js
generated
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
import { firstValueFrom, from, merge, raceWith, } from '../../third_party/rxjs/rxjs.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { debugError, fromEmitterEvent, filterAsync, timeout, fromAbortSignal, } from '../common/util.js';
|
||||
import { asyncDisposeSymbol, disposeSymbol } from '../util/disposable.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const WEB_PERMISSION_TO_PROTOCOL_PERMISSION = new Map([
|
||||
['accelerometer', 'sensors'],
|
||||
['ambient-light-sensor', 'sensors'],
|
||||
['background-sync', 'backgroundSync'],
|
||||
['camera', 'videoCapture'],
|
||||
['clipboard-read', 'clipboardReadWrite'],
|
||||
['clipboard-sanitized-write', 'clipboardSanitizedWrite'],
|
||||
['clipboard-write', 'clipboardReadWrite'],
|
||||
['geolocation', 'geolocation'],
|
||||
['gyroscope', 'sensors'],
|
||||
['idle-detection', 'idleDetection'],
|
||||
['keyboard-lock', 'keyboardLock'],
|
||||
['magnetometer', 'sensors'],
|
||||
['microphone', 'audioCapture'],
|
||||
['midi', 'midi'],
|
||||
['notifications', 'notifications'],
|
||||
['payment-handler', 'paymentHandler'],
|
||||
['persistent-storage', 'durableStorage'],
|
||||
['pointer-lock', 'pointerLock'],
|
||||
// chrome-specific permissions we have.
|
||||
['midi-sysex', 'midiSysex'],
|
||||
]);
|
||||
/**
|
||||
* {@link Browser} represents a browser instance that is either:
|
||||
*
|
||||
* - connected to via {@link Puppeteer.connect} or
|
||||
* - launched by {@link PuppeteerNode.launch}.
|
||||
*
|
||||
* {@link Browser} {@link EventEmitter.emit | emits} various events which are
|
||||
* documented in the {@link BrowserEvent} enum.
|
||||
*
|
||||
* @example Using a {@link Browser} to create a {@link Page}:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* await page.goto('https://example.com');
|
||||
* await browser.close();
|
||||
* ```
|
||||
*
|
||||
* @example Disconnecting from and reconnecting to a {@link Browser}:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* // Store the endpoint to be able to reconnect to the browser.
|
||||
* const browserWSEndpoint = browser.wsEndpoint();
|
||||
* // Disconnect puppeteer from the browser.
|
||||
* await browser.disconnect();
|
||||
*
|
||||
* // Use the endpoint to reestablish a connection
|
||||
* const browser2 = await puppeteer.connect({browserWSEndpoint});
|
||||
* // Close the browser.
|
||||
* await browser2.close();
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class Browser extends EventEmitter {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* Waits until a {@link Target | target} matching the given `predicate`
|
||||
* appears and returns it.
|
||||
*
|
||||
* This will look all open {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* @example Finding a target for a page opened via `window.open`:
|
||||
*
|
||||
* ```ts
|
||||
* await page.evaluate(() => window.open('https://www.example.com/'));
|
||||
* const newWindowTarget = await browser.waitForTarget(
|
||||
* target => target.url() === 'https://www.example.com/',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
async waitForTarget(predicate, options = {}) {
|
||||
const { timeout: ms = 30000, signal } = options;
|
||||
return await firstValueFrom(merge(fromEmitterEvent(this, "targetcreated" /* BrowserEvent.TargetCreated */), fromEmitterEvent(this, "targetchanged" /* BrowserEvent.TargetChanged */), from(this.targets())).pipe(filterAsync(predicate), raceWith(fromAbortSignal(signal), timeout(ms))));
|
||||
}
|
||||
/**
|
||||
* Gets a list of all open {@link Page | pages} inside this {@link Browser}.
|
||||
*
|
||||
* If there are multiple {@link BrowserContext | browser contexts}, this
|
||||
* returns all {@link Page | pages} in all
|
||||
* {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* @param includeAll - experimental, setting to true includes all kinds of pages.
|
||||
*
|
||||
* @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
|
||||
* will not be listed here. You can find them using {@link Target.page}.
|
||||
*/
|
||||
async pages(includeAll = false) {
|
||||
const contextPages = await Promise.all(this.browserContexts().map(context => {
|
||||
return context.pages(includeAll);
|
||||
}));
|
||||
// Flatten array.
|
||||
return contextPages.reduce((acc, x) => {
|
||||
return acc.concat(x);
|
||||
}, []);
|
||||
}
|
||||
/**
|
||||
* Returns all cookies in the default {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.cookies | browser.defaultBrowserContext().cookies()}.
|
||||
*/
|
||||
async cookies() {
|
||||
return await this.defaultBrowserContext().cookies();
|
||||
}
|
||||
/**
|
||||
* Sets cookies in the default {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.setCookie | browser.defaultBrowserContext().setCookie()}.
|
||||
*/
|
||||
async setCookie(...cookies) {
|
||||
return await this.defaultBrowserContext().setCookie(...cookies);
|
||||
}
|
||||
/**
|
||||
* Removes cookies from the default {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.deleteCookie | browser.defaultBrowserContext().deleteCookie()}.
|
||||
*/
|
||||
async deleteCookie(...cookies) {
|
||||
return await this.defaultBrowserContext().deleteCookie(...cookies);
|
||||
}
|
||||
/**
|
||||
* Deletes cookies matching the provided filters from the default
|
||||
* {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.deleteMatchingCookies |
|
||||
* browser.defaultBrowserContext().deleteMatchingCookies()}.
|
||||
*/
|
||||
async deleteMatchingCookies(...filters) {
|
||||
return await this.defaultBrowserContext().deleteMatchingCookies(...filters);
|
||||
}
|
||||
/**
|
||||
* Sets the permission for a specific origin in the default
|
||||
* {@link BrowserContext}.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Shortcut for
|
||||
* {@link BrowserContext.setPermission |
|
||||
* browser.defaultBrowserContext().setPermission()}.
|
||||
*
|
||||
* @param origin - The origin to set the permission for.
|
||||
* @param permission - The permission descriptor.
|
||||
* @param state - The state of the permission.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
async setPermission(origin, ...permissions) {
|
||||
return await this.defaultBrowserContext().setPermission(origin, ...permissions);
|
||||
}
|
||||
/**
|
||||
* Whether Puppeteer is connected to this {@link Browser | browser}.
|
||||
*
|
||||
* @deprecated Use {@link Browser | Browser.connected}.
|
||||
*/
|
||||
isConnected() {
|
||||
return this.connected;
|
||||
}
|
||||
/** @internal */
|
||||
[disposeSymbol]() {
|
||||
if (this.process()) {
|
||||
return void this.close().catch(debugError);
|
||||
}
|
||||
return void this.disconnect().catch(debugError);
|
||||
}
|
||||
/** @internal */
|
||||
[asyncDisposeSymbol]() {
|
||||
if (this.process()) {
|
||||
return this.close();
|
||||
}
|
||||
return this.disconnect();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Browser.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Browser.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Browser.js","sourceRoot":"","sources":["../../../../src/api/Browser.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,cAAc,EACd,IAAI,EACJ,KAAK,EACL,QAAQ,GACT,MAAM,gCAAgC,CAAC;AAQxC,OAAO,EAAC,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC;AA0CxE;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,IAAI,GAAG,CAG1D;IACA,CAAC,eAAe,EAAE,SAAS,CAAC;IAC5B,CAAC,sBAAsB,EAAE,SAAS,CAAC;IACnC,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;IACrC,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1B,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;IACxC,CAAC,2BAA2B,EAAE,yBAAyB,CAAC;IACxD,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;IACzC,CAAC,aAAa,EAAE,aAAa,CAAC;IAC9B,CAAC,WAAW,EAAE,SAAS,CAAC;IACxB,CAAC,gBAAgB,EAAE,eAAe,CAAC;IACnC,CAAC,eAAe,EAAE,cAAc,CAAC;IACjC,CAAC,cAAc,EAAE,SAAS,CAAC;IAC3B,CAAC,YAAY,EAAE,cAAc,CAAC;IAC9B,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,eAAe,EAAE,eAAe,CAAC;IAClC,CAAC,iBAAiB,EAAE,gBAA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C;YACnB,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;CAuBF"}
|
||||
230
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.d.ts
generated
vendored
Normal file
230
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Cookie, CookieData, DeleteCookiesRequest } from '../common/Cookie.js';
|
||||
import { EventEmitter, type EventType } from '../common/EventEmitter.js';
|
||||
import { asyncDisposeSymbol, disposeSymbol } from '../util/disposable.js';
|
||||
import { Mutex } from '../util/Mutex.js';
|
||||
import type { Browser, CreatePageOptions, Permission, PermissionDescriptor, PermissionState, WaitForTargetOptions } from './Browser.js';
|
||||
import type { Page } from './Page.js';
|
||||
import type { Target } from './Target.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export declare const enum BrowserContextEvent {
|
||||
/**
|
||||
* Emitted when the url of a target inside the browser context changes.
|
||||
* Contains a {@link Target} instance.
|
||||
*/
|
||||
TargetChanged = "targetchanged",
|
||||
/**
|
||||
* Emitted when a target is created within the browser context, for example
|
||||
* when a new page is opened by
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
|
||||
* or by {@link BrowserContext.newPage | browserContext.newPage}
|
||||
*
|
||||
* Contains a {@link Target} instance.
|
||||
*/
|
||||
TargetCreated = "targetcreated",
|
||||
/**
|
||||
* Emitted when a target is destroyed within the browser context, for example
|
||||
* when a page is closed. Contains a {@link Target} instance.
|
||||
*/
|
||||
TargetDestroyed = "targetdestroyed"
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface BrowserContextEvents extends Record<EventType, unknown> {
|
||||
[BrowserContextEvent.TargetChanged]: Target;
|
||||
[BrowserContextEvent.TargetCreated]: Target;
|
||||
[BrowserContextEvent.TargetDestroyed]: Target;
|
||||
}
|
||||
/**
|
||||
* {@link BrowserContext} represents individual user contexts within a
|
||||
* {@link Browser | browser}.
|
||||
*
|
||||
* When a {@link Browser | browser} is launched, it has at least one default
|
||||
* {@link BrowserContext | browser context}. Others can be created
|
||||
* using {@link Browser.createBrowserContext}. Each context has isolated storage
|
||||
* (cookies/localStorage/etc.)
|
||||
*
|
||||
* {@link BrowserContext} {@link EventEmitter | emits} various events which are
|
||||
* documented in the {@link BrowserContextEvent} enum.
|
||||
*
|
||||
* If a {@link Page | page} opens another {@link Page | page}, e.g. using
|
||||
* `window.open`, the popup will belong to the parent {@link Page.browserContext
|
||||
* | page's browser context}.
|
||||
*
|
||||
* @example Creating a new {@link BrowserContext | browser context}:
|
||||
*
|
||||
* ```ts
|
||||
* // Create a new browser context
|
||||
* const context = await browser.createBrowserContext();
|
||||
* // Create a new page inside context.
|
||||
* const page = await context.newPage();
|
||||
* // ... do stuff with page ...
|
||||
* await page.goto('https://example.com');
|
||||
* // Dispose context once it's no longer needed.
|
||||
* await context.close();
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* In Chrome all non-default contexts are incognito,
|
||||
* and {@link Browser.defaultBrowserContext | default browser context}
|
||||
* might be incognito if you provide the `--incognito` argument when launching
|
||||
* the browser.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class BrowserContext extends EventEmitter<BrowserContextEvents> {
|
||||
#private;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Gets all active {@link Target | targets} inside this
|
||||
* {@link BrowserContext | browser context}.
|
||||
*/
|
||||
abstract targets(): Target[];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
startScreenshot(): Promise<InstanceType<typeof Mutex.Guard>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
waitForScreenshotOperations(): Promise<InstanceType<typeof Mutex.Guard>> | undefined;
|
||||
/**
|
||||
* Waits until a {@link Target | target} matching the given `predicate`
|
||||
* appears and returns it.
|
||||
*
|
||||
* This will look all open {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* @example Finding a target for a page opened via `window.open`:
|
||||
*
|
||||
* ```ts
|
||||
* await page.evaluate(() => window.open('https://www.example.com/'));
|
||||
* const newWindowTarget = await browserContext.waitForTarget(
|
||||
* target => target.url() === 'https://www.example.com/',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: WaitForTargetOptions): Promise<Target>;
|
||||
/**
|
||||
* Gets a list of all open {@link Page | pages} inside this
|
||||
* {@link BrowserContext | browser context}.
|
||||
*
|
||||
* @param includeAll - experimental, setting to true includes all kinds of pages.
|
||||
*
|
||||
* @remarks Non-visible {@link Page | pages}, such as `"background_page"`,
|
||||
* will not be listed here. You can find them using {@link Target.page}.
|
||||
*/
|
||||
abstract pages(includeAll?: boolean): Promise<Page[]>;
|
||||
/**
|
||||
* Grants this {@link BrowserContext | browser context} the given
|
||||
* `permissions` within the given `origin`.
|
||||
*
|
||||
* @example Overriding permissions in the
|
||||
* {@link Browser.defaultBrowserContext | default browser context}:
|
||||
*
|
||||
* ```ts
|
||||
* const context = browser.defaultBrowserContext();
|
||||
* await context.overridePermissions('https://html5demos.com', [
|
||||
* 'geolocation',
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* @param origin - The origin to grant permissions to, e.g.
|
||||
* "https://example.com".
|
||||
* @param permissions - An array of permissions to grant. All permissions that
|
||||
* are not listed here will be automatically denied.
|
||||
*
|
||||
* @deprecated in favor of {@link BrowserContext.setPermission}.
|
||||
*/
|
||||
abstract overridePermissions(origin: string, permissions: Permission[]): Promise<void>;
|
||||
/**
|
||||
* Sets the permission for a specific origin.
|
||||
*
|
||||
* @param origin - The origin to set the permission for.
|
||||
* @param permission - The permission descriptor.
|
||||
* @param state - The state of the permission.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
abstract setPermission(origin: string | '*', ...permissions: Array<{
|
||||
permission: PermissionDescriptor;
|
||||
state: PermissionState;
|
||||
}>): Promise<void>;
|
||||
/**
|
||||
* Clears all permission overrides for this
|
||||
* {@link BrowserContext | browser context}.
|
||||
*
|
||||
* @example Clearing overridden permissions in the
|
||||
* {@link Browser.defaultBrowserContext | default browser context}:
|
||||
*
|
||||
* ```ts
|
||||
* const context = browser.defaultBrowserContext();
|
||||
* context.overridePermissions('https://example.com', ['clipboard-read']);
|
||||
* // do stuff ..
|
||||
* context.clearPermissionOverrides();
|
||||
* ```
|
||||
*/
|
||||
abstract clearPermissionOverrides(): Promise<void>;
|
||||
/**
|
||||
* Creates a new {@link Page | page} in this
|
||||
* {@link BrowserContext | browser context}.
|
||||
*/
|
||||
abstract newPage(options?: CreatePageOptions): Promise<Page>;
|
||||
/**
|
||||
* Gets the {@link Browser | browser} associated with this
|
||||
* {@link BrowserContext | browser context}.
|
||||
*/
|
||||
abstract browser(): Browser;
|
||||
/**
|
||||
* Closes this {@link BrowserContext | browser context} and all associated
|
||||
* {@link Page | pages}.
|
||||
*
|
||||
* @remarks The
|
||||
* {@link Browser.defaultBrowserContext | default browser context} cannot be
|
||||
* closed.
|
||||
*/
|
||||
abstract close(): Promise<void>;
|
||||
/**
|
||||
* Gets all cookies in the browser context.
|
||||
*/
|
||||
abstract cookies(): Promise<Cookie[]>;
|
||||
/**
|
||||
* Sets a cookie in the browser context.
|
||||
*/
|
||||
abstract setCookie(...cookies: CookieData[]): Promise<void>;
|
||||
/**
|
||||
* Removes cookie in this browser context.
|
||||
*
|
||||
* @param cookies - Complete {@link Cookie | cookie} object to be removed.
|
||||
*/
|
||||
deleteCookie(...cookies: Cookie[]): Promise<void>;
|
||||
/**
|
||||
* Deletes cookies matching the provided filters in this browser context.
|
||||
*
|
||||
* @param filters - {@link DeleteCookiesRequest}
|
||||
*/
|
||||
deleteMatchingCookies(...filters: DeleteCookiesRequest[]): Promise<void>;
|
||||
/**
|
||||
* Whether this {@link BrowserContext | browser context} is closed.
|
||||
*/
|
||||
get closed(): boolean;
|
||||
/**
|
||||
* Identifier for this {@link BrowserContext | browser context}.
|
||||
*/
|
||||
get id(): string | undefined;
|
||||
/** @internal */
|
||||
[disposeSymbol](): void;
|
||||
/** @internal */
|
||||
[asyncDisposeSymbol](): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=BrowserContext.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserContext.d.ts","sourceRoot":"","sources":["../../../../src/api/BrowserContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,YAAY,EAAE,KAAK,SAAS,EAAC,MAAM,2BAA2B,CAAC;AAOvE,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAC;AAEvC,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,0BAAkB,mBAAmB;IACnC;;;OAGG;IACH,aAAa,kBAAkB;IAE/B;;;;;;;OAOG;IACH,aAAa,kBAAkB;IAC/B;;;OAGG;IACH,eAAe,oBAAoB;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,MAAM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,CAAC,IAAI,CAAC;IAEhB;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAElD;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAE5D;;;OAGG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO;IAE3B;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;;;OAIG;IACG,YAAY,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvD;;;;OAIG;IACG,qBAAqB,CACzB,GAAG,OAAO,EAAE,oBAAoB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC;IAiDhB;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,GAAG,SAAS,CAE3B;IAED,gBAAgB;IACP,CAAC,aAAa,CAAC,IAAI,IAAI;IAIhC,gBAAgB;IAChB,CAAC,kBAAkB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
|
||||
182
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.js
generated
vendored
Normal file
182
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { firstValueFrom, from, merge, raceWith, } from '../../third_party/rxjs/rxjs.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { debugError, fromEmitterEvent, filterAsync, timeout, } from '../common/util.js';
|
||||
import { asyncDisposeSymbol, disposeSymbol } from '../util/disposable.js';
|
||||
import { Mutex } from '../util/Mutex.js';
|
||||
/**
|
||||
* {@link BrowserContext} represents individual user contexts within a
|
||||
* {@link Browser | browser}.
|
||||
*
|
||||
* When a {@link Browser | browser} is launched, it has at least one default
|
||||
* {@link BrowserContext | browser context}. Others can be created
|
||||
* using {@link Browser.createBrowserContext}. Each context has isolated storage
|
||||
* (cookies/localStorage/etc.)
|
||||
*
|
||||
* {@link BrowserContext} {@link EventEmitter | emits} various events which are
|
||||
* documented in the {@link BrowserContextEvent} enum.
|
||||
*
|
||||
* If a {@link Page | page} opens another {@link Page | page}, e.g. using
|
||||
* `window.open`, the popup will belong to the parent {@link Page.browserContext
|
||||
* | page's browser context}.
|
||||
*
|
||||
* @example Creating a new {@link BrowserContext | browser context}:
|
||||
*
|
||||
* ```ts
|
||||
* // Create a new browser context
|
||||
* const context = await browser.createBrowserContext();
|
||||
* // Create a new page inside context.
|
||||
* const page = await context.newPage();
|
||||
* // ... do stuff with page ...
|
||||
* await page.goto('https://example.com');
|
||||
* // Dispose context once it's no longer needed.
|
||||
* await context.close();
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* In Chrome all non-default contexts are incognito,
|
||||
* and {@link Browser.defaultBrowserContext | default browser context}
|
||||
* might be incognito if you provide the `--incognito` argument when launching
|
||||
* the browser.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class BrowserContext extends EventEmitter {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* If defined, indicates an ongoing screenshot opereation.
|
||||
*/
|
||||
#pageScreenshotMutex;
|
||||
#screenshotOperationsCount = 0;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
startScreenshot() {
|
||||
const mutex = this.#pageScreenshotMutex || new Mutex();
|
||||
this.#pageScreenshotMutex = mutex;
|
||||
this.#screenshotOperationsCount++;
|
||||
return mutex.acquire(() => {
|
||||
this.#screenshotOperationsCount--;
|
||||
if (this.#screenshotOperationsCount === 0) {
|
||||
// Remove the mutex to indicate no ongoing screenshot operation.
|
||||
this.#pageScreenshotMutex = undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
waitForScreenshotOperations() {
|
||||
return this.#pageScreenshotMutex?.acquire();
|
||||
}
|
||||
/**
|
||||
* Waits until a {@link Target | target} matching the given `predicate`
|
||||
* appears and returns it.
|
||||
*
|
||||
* This will look all open {@link BrowserContext | browser contexts}.
|
||||
*
|
||||
* @example Finding a target for a page opened via `window.open`:
|
||||
*
|
||||
* ```ts
|
||||
* await page.evaluate(() => window.open('https://www.example.com/'));
|
||||
* const newWindowTarget = await browserContext.waitForTarget(
|
||||
* target => target.url() === 'https://www.example.com/',
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
async waitForTarget(predicate, options = {}) {
|
||||
const { timeout: ms = 30000 } = options;
|
||||
return await firstValueFrom(merge(fromEmitterEvent(this, "targetcreated" /* BrowserContextEvent.TargetCreated */), fromEmitterEvent(this, "targetchanged" /* BrowserContextEvent.TargetChanged */), from(this.targets())).pipe(filterAsync(predicate), raceWith(timeout(ms))));
|
||||
}
|
||||
/**
|
||||
* Removes cookie in this browser context.
|
||||
*
|
||||
* @param cookies - Complete {@link Cookie | cookie} object to be removed.
|
||||
*/
|
||||
async deleteCookie(...cookies) {
|
||||
return await this.setCookie(...cookies.map(cookie => {
|
||||
return {
|
||||
...cookie,
|
||||
expires: 1,
|
||||
};
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* Deletes cookies matching the provided filters in this browser context.
|
||||
*
|
||||
* @param filters - {@link DeleteCookiesRequest}
|
||||
*/
|
||||
async deleteMatchingCookies(...filters) {
|
||||
const cookies = await this.cookies();
|
||||
const cookiesToDelete = cookies.filter(cookie => {
|
||||
return filters.some(filter => {
|
||||
if (filter.name === cookie.name) {
|
||||
if (filter.domain !== undefined && filter.domain === cookie.domain) {
|
||||
return true;
|
||||
}
|
||||
if (filter.path !== undefined && filter.path === cookie.path) {
|
||||
return true;
|
||||
}
|
||||
if (filter.partitionKey !== undefined &&
|
||||
cookie.partitionKey !== undefined) {
|
||||
if (typeof cookie.partitionKey !== 'object') {
|
||||
throw new Error('Unexpected string partition key');
|
||||
}
|
||||
if (typeof filter.partitionKey === 'string') {
|
||||
if (filter.partitionKey === cookie.partitionKey?.sourceOrigin) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (filter.partitionKey.sourceOrigin ===
|
||||
cookie.partitionKey?.sourceOrigin) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filter.url !== undefined) {
|
||||
const url = new URL(filter.url);
|
||||
if (url.hostname === cookie.domain &&
|
||||
url.pathname === cookie.path) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
await this.deleteCookie(...cookiesToDelete);
|
||||
}
|
||||
/**
|
||||
* Whether this {@link BrowserContext | browser context} is closed.
|
||||
*/
|
||||
get closed() {
|
||||
return !this.browser().browserContexts().includes(this);
|
||||
}
|
||||
/**
|
||||
* Identifier for this {@link BrowserContext | browser context}.
|
||||
*/
|
||||
get id() {
|
||||
return undefined;
|
||||
}
|
||||
/** @internal */
|
||||
[disposeSymbol]() {
|
||||
return void this.close().catch(debugError);
|
||||
}
|
||||
/** @internal */
|
||||
[asyncDisposeSymbol]() {
|
||||
return this.close();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=BrowserContext.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/BrowserContext.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":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IAED,gBAAgB;IACP,CAAC,aAAa,CAAC;QACtB,OAAO,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,gBAAgB;IAChB,CAAC,kBAAkB,CAAC;QAClB,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
||||
116
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.d.ts
generated
vendored
Normal file
116
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.d.ts
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
|
||||
import type { Connection } from '../cdp/Connection.js';
|
||||
import { EventEmitter, type EventType } from '../common/EventEmitter.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type CDPEvents = {
|
||||
[Property in keyof ProtocolMapping.Events]: ProtocolMapping.Events[Property][0];
|
||||
};
|
||||
/**
|
||||
* Events that the CDPSession class emits.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare namespace CDPSessionEvent {
|
||||
/** @internal */
|
||||
const Disconnected: unique symbol;
|
||||
/** @internal */
|
||||
const Swapped: unique symbol;
|
||||
/**
|
||||
* Emitted when the session is ready to be configured during the auto-attach
|
||||
* process. Right after the event is handled, the session will be resumed.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const Ready: unique symbol;
|
||||
const SessionAttached: "sessionattached";
|
||||
const SessionDetached: "sessiondetached";
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface CDPSessionEvents extends CDPEvents, Record<EventType, unknown> {
|
||||
/** @internal */
|
||||
[CDPSessionEvent.Disconnected]: undefined;
|
||||
/** @internal */
|
||||
[CDPSessionEvent.Swapped]: CDPSession;
|
||||
/** @internal */
|
||||
[CDPSessionEvent.Ready]: CDPSession;
|
||||
[CDPSessionEvent.SessionAttached]: CDPSession;
|
||||
[CDPSessionEvent.SessionDetached]: CDPSession;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface CommandOptions {
|
||||
timeout: number;
|
||||
}
|
||||
/**
|
||||
* The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Protocol methods can be called with {@link CDPSession.send} method and protocol
|
||||
* events can be subscribed to with `CDPSession.on` method.
|
||||
*
|
||||
* Useful links: {@link https://chromedevtools.github.io/devtools-protocol/ | DevTools Protocol Viewer}
|
||||
* and {@link https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md | Getting Started with DevTools Protocol}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const client = await page.createCDPSession();
|
||||
* await client.send('Animation.enable');
|
||||
* client.on('Animation.animationCreated', () =>
|
||||
* console.log('Animation created!'),
|
||||
* );
|
||||
* const response = await client.send('Animation.getPlaybackRate');
|
||||
* console.log('playback rate is ' + response.playbackRate);
|
||||
* await client.send('Animation.setPlaybackRate', {
|
||||
* playbackRate: response.playbackRate / 2,
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class CDPSession extends EventEmitter<CDPSessionEvents> {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* The underlying connection for this session, if any.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
abstract connection(): Connection | undefined;
|
||||
/**
|
||||
* True if the session has been detached, false otherwise.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
abstract get detached(): boolean;
|
||||
/**
|
||||
* Parent session in terms of CDP's auto-attach mechanism.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
parentSession(): CDPSession | undefined;
|
||||
abstract send<T extends keyof ProtocolMapping.Commands>(method: T, params?: ProtocolMapping.Commands[T]['paramsType'][0], options?: CommandOptions): Promise<ProtocolMapping.Commands[T]['returnType']>;
|
||||
/**
|
||||
* Detaches the cdpSession from the target. Once detached, the cdpSession object
|
||||
* won't emit any events and can't be used to send messages.
|
||||
*/
|
||||
abstract detach(): Promise<void>;
|
||||
/**
|
||||
* Returns the session's id.
|
||||
*/
|
||||
abstract id(): string;
|
||||
}
|
||||
//# sourceMappingURL=CDPSession.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CDPSession.d.ts","sourceRoot":"","sources":["../../../../src/api/CDPSession.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,6CAA6C,CAAC;AAEjF,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAC,YAAY,EAAE,KAAK,SAAS,EAAC,MAAM,2BAA2B,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;KACrB,QAAQ,IAAI,MAAM,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;CAChF,CAAC;AAEF;;;;GAIG;AAEH,yBAAiB,eAAe,CAAC;IAC/B,gBAAgB;IACT,MAAM,YAAY,eAAoC,CAAC;IAC9D,gBAAgB;IACT,MAAM,OAAO,eAA+B,CAAC;IACpD;;;;;OAKG;IACI,MAAM,KAAK,eAA6B,CAAC;IACzC,MAAM,eAAe,EAAG,iBAA0B,CAAC;IACnD,MAAM,eAAe,EAAG,iBAA0B,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,WAAW,gBACf,SAAQ,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC;IAC7C,gBAAgB;IAChB,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC;IAC1C,gBAAgB;IAChB,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;IACtC,gBAAgB;IAChB,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACpC,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;IAC9C,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,8BAAsB,UAAW,SAAQ,YAAY,CAAC,gBAAgB,CAAC;IACrE;;OAEG;;IAKH;;;;OAIG;IACH,QAAQ,CAAC,UAAU,IAAI,UAAU,GAAG,SAAS;IAE7C;;;;OAIG;IACH,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC;IAEjC;;;;OAIG;IACH,aAAa,IAAI,UAAU,GAAG,SAAS;IAIvC,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,MAAM,eAAe,CAAC,QAAQ,EACpD,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;IAErD;;;OAGG;IACH,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,EAAE,IAAI,MAAM;CACtB"}
|
||||
68
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.js
generated
vendored
Normal file
68
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
/**
|
||||
* Events that the CDPSession class emits.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export var CDPSessionEvent;
|
||||
(function (CDPSessionEvent) {
|
||||
/** @internal */
|
||||
CDPSessionEvent.Disconnected = Symbol('CDPSession.Disconnected');
|
||||
/** @internal */
|
||||
CDPSessionEvent.Swapped = Symbol('CDPSession.Swapped');
|
||||
/**
|
||||
* Emitted when the session is ready to be configured during the auto-attach
|
||||
* process. Right after the event is handled, the session will be resumed.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
CDPSessionEvent.Ready = Symbol('CDPSession.Ready');
|
||||
CDPSessionEvent.SessionAttached = 'sessionattached';
|
||||
CDPSessionEvent.SessionDetached = 'sessiondetached';
|
||||
})(CDPSessionEvent || (CDPSessionEvent = {}));
|
||||
/**
|
||||
* The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Protocol methods can be called with {@link CDPSession.send} method and protocol
|
||||
* events can be subscribed to with `CDPSession.on` method.
|
||||
*
|
||||
* Useful links: {@link https://chromedevtools.github.io/devtools-protocol/ | DevTools Protocol Viewer}
|
||||
* and {@link https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md | Getting Started with DevTools Protocol}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const client = await page.createCDPSession();
|
||||
* await client.send('Animation.enable');
|
||||
* client.on('Animation.animationCreated', () =>
|
||||
* console.log('Animation created!'),
|
||||
* );
|
||||
* const response = await client.send('Animation.getPlaybackRate');
|
||||
* console.log('playback rate is ' + response.playbackRate);
|
||||
* await client.send('Animation.setPlaybackRate', {
|
||||
* playbackRate: response.playbackRate / 2,
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class CDPSession extends EventEmitter {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* Parent session in terms of CDP's auto-attach mechanism.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
parentSession() {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=CDPSession.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/CDPSession.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CDPSession.js","sourceRoot":"","sources":["../../../../src/api/CDPSession.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AASvE;;;;GAIG;AACH,2DAA2D;AAC3D,MAAM,KAAW,eAAe,CAc/B;AAdD,WAAiB,eAAe;IAC9B,gBAAgB;IACH,4BAAY,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAC9D,gBAAgB;IACH,uBAAO,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACpD;;;;;OAKG;IACU,qBAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACnC,+BAAe,GAAG,iBAA0B,CAAC;IAC7C,+BAAe,GAAG,iBAA0B,CAAC;AAC5D,CAAC,EAdgB,eAAe,KAAf,eAAe,QAc/B;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAgB,UAAW,SAAQ,YAA8B;IACrE;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAgBD;;;;OAIG;IACH,aAAa;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;CAkBF"}
|
||||
62
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts
generated
vendored
Normal file
62
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { WaitTimeoutOptions } from './Page.js';
|
||||
/**
|
||||
* Device in a request prompt.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface DeviceRequestPromptDevice {
|
||||
/**
|
||||
* Device id during a prompt.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Device name as it appears in a prompt.
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
/**
|
||||
* Device request prompts let you respond to the page requesting for a device
|
||||
* through an API like WebBluetooth.
|
||||
*
|
||||
* @remarks
|
||||
* `DeviceRequestPrompt` instances are returned via the
|
||||
* {@link Page.waitForDevicePrompt} method.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const [devicePrompt] = Promise.all([
|
||||
* page.waitForDevicePrompt(),
|
||||
* page.click('#connect-bluetooth'),
|
||||
* ]);
|
||||
* await devicePrompt.select(
|
||||
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class DeviceRequestPrompt {
|
||||
/**
|
||||
* Current list of selectable devices.
|
||||
*/
|
||||
readonly devices: DeviceRequestPromptDevice[];
|
||||
/**
|
||||
* Resolve to the first device in the prompt matching a filter.
|
||||
*/
|
||||
abstract waitForDevice(filter: (device: DeviceRequestPromptDevice) => boolean, options?: WaitTimeoutOptions): Promise<DeviceRequestPromptDevice>;
|
||||
/**
|
||||
* Select a device in the prompt's list.
|
||||
*/
|
||||
abstract select(device: DeviceRequestPromptDevice): Promise<void>;
|
||||
/**
|
||||
* Cancel the prompt.
|
||||
*/
|
||||
abstract cancel(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=DeviceRequestPrompt.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DeviceRequestPrompt.d.ts","sourceRoot":"","sources":["../../../../src/api/DeviceRequestPrompt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8BAAsB,mBAAmB;IACvC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,yBAAyB,EAAE,CAAM;IAEnD;;OAEG;IACH,QAAQ,CAAC,aAAa,CACpB,MAAM,EAAE,CAAC,MAAM,EAAE,yBAAyB,KAAK,OAAO,EACtD,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,yBAAyB,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjE;;OAEG;IACH,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CACjC"}
|
||||
34
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.js
generated
vendored
Normal file
34
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* Device request prompts let you respond to the page requesting for a device
|
||||
* through an API like WebBluetooth.
|
||||
*
|
||||
* @remarks
|
||||
* `DeviceRequestPrompt` instances are returned via the
|
||||
* {@link Page.waitForDevicePrompt} method.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const [devicePrompt] = Promise.all([
|
||||
* page.waitForDevicePrompt(),
|
||||
* page.click('#connect-bluetooth'),
|
||||
* ]);
|
||||
* await devicePrompt.select(
|
||||
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class DeviceRequestPrompt {
|
||||
/**
|
||||
* Current list of selectable devices.
|
||||
*/
|
||||
devices = [];
|
||||
}
|
||||
//# sourceMappingURL=DeviceRequestPrompt.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/DeviceRequestPrompt.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DeviceRequestPrompt.js","sourceRoot":"","sources":["../../../../src/api/DeviceRequestPrompt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAgB,mBAAmB;IACvC;;OAEG;IACM,OAAO,GAAgC,EAAE,CAAC;CAmBpD"}
|
||||
72
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.d.ts
generated
vendored
Normal file
72
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.d.ts
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Protocol } from 'devtools-protocol';
|
||||
/**
|
||||
* Dialog instances are dispatched by the {@link Page} via the `dialog` event.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* page.on('dialog', async dialog => {
|
||||
* console.log(dialog.message());
|
||||
* await dialog.dismiss();
|
||||
* await browser.close();
|
||||
* });
|
||||
* await page.evaluate(() => alert('1'));
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Dialog {
|
||||
#private;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected handled: boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(type: Protocol.Page.DialogType, message: string, defaultValue?: string);
|
||||
/**
|
||||
* The type of the dialog.
|
||||
*/
|
||||
type(): Protocol.Page.DialogType;
|
||||
/**
|
||||
* The message displayed in the dialog.
|
||||
*/
|
||||
message(): string;
|
||||
/**
|
||||
* The default value of the prompt, or an empty string if the dialog
|
||||
* is not a `prompt`.
|
||||
*/
|
||||
defaultValue(): string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected abstract handle(options: {
|
||||
accept: boolean;
|
||||
text?: string;
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* A promise that resolves when the dialog has been accepted.
|
||||
*
|
||||
* @param promptText - optional text that will be entered in the dialog
|
||||
* prompt. Has no effect if the dialog's type is not `prompt`.
|
||||
*
|
||||
*/
|
||||
accept(promptText?: string): Promise<void>;
|
||||
/**
|
||||
* A promise which will resolve once the dialog has been dismissed
|
||||
*/
|
||||
dismiss(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=Dialog.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../src/api/Dialog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8BAAsB,MAAM;;IAI1B;;OAEG;IACH,SAAS,CAAC,OAAO,UAAS;IAE1B;;OAEG;gBAED,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAC9B,OAAO,EAAE,MAAM,EACf,YAAY,SAAK;IAOnB;;OAEG;IACH,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU;IAIhC;;OAEG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjB;;;;;;OAMG;IACG,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}
|
||||
90
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.js
generated
vendored
Normal file
90
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { assert } from '../util/assert.js';
|
||||
/**
|
||||
* Dialog instances are dispatched by the {@link Page} via the `dialog` event.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* page.on('dialog', async dialog => {
|
||||
* console.log(dialog.message());
|
||||
* await dialog.dismiss();
|
||||
* await browser.close();
|
||||
* });
|
||||
* await page.evaluate(() => alert('1'));
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class Dialog {
|
||||
#type;
|
||||
#message;
|
||||
#defaultValue;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
handled = false;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(type, message, defaultValue = '') {
|
||||
this.#type = type;
|
||||
this.#message = message;
|
||||
this.#defaultValue = defaultValue;
|
||||
}
|
||||
/**
|
||||
* The type of the dialog.
|
||||
*/
|
||||
type() {
|
||||
return this.#type;
|
||||
}
|
||||
/**
|
||||
* The message displayed in the dialog.
|
||||
*/
|
||||
message() {
|
||||
return this.#message;
|
||||
}
|
||||
/**
|
||||
* The default value of the prompt, or an empty string if the dialog
|
||||
* is not a `prompt`.
|
||||
*/
|
||||
defaultValue() {
|
||||
return this.#defaultValue;
|
||||
}
|
||||
/**
|
||||
* A promise that resolves when the dialog has been accepted.
|
||||
*
|
||||
* @param promptText - optional text that will be entered in the dialog
|
||||
* prompt. Has no effect if the dialog's type is not `prompt`.
|
||||
*
|
||||
*/
|
||||
async accept(promptText) {
|
||||
assert(!this.handled, 'Cannot accept dialog which is already handled!');
|
||||
this.handled = true;
|
||||
await this.handle({
|
||||
accept: true,
|
||||
text: promptText,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* A promise which will resolve once the dialog has been dismissed
|
||||
*/
|
||||
async dismiss() {
|
||||
assert(!this.handled, 'Cannot dismiss dialog which is already handled!');
|
||||
this.handled = true;
|
||||
await this.handle({
|
||||
accept: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Dialog.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Dialog.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/api/Dialog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAgB,MAAM;IAC1B,KAAK,CAA2B;IAChC,QAAQ,CAAS;IACjB,aAAa,CAAS;IACtB;;OAEG;IACO,OAAO,GAAG,KAAK,CAAC;IAE1B;;OAEG;IACH,YACE,IAA8B,EAC9B,OAAe,EACf,YAAY,GAAG,EAAE;QAEjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAUD;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,UAAmB;QAC9B,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,gDAAgD,CAAC,CAAC;QACxE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,MAAM,IAAI,CAAC,MAAM,CAAC;YAChB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,iDAAiD,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,MAAM,IAAI,CAAC,MAAM,CAAC;YAChB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;CACF"}
|
||||
666
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.d.ts
generated
vendored
Normal file
666
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,666 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Protocol } from 'devtools-protocol';
|
||||
import type { Frame } from '../api/Frame.js';
|
||||
import type { AwaitableIterable, ElementFor, EvaluateFuncWith, HandleFor, HandleOr, NodeFor } from '../common/types.js';
|
||||
import type { KeyInput } from '../common/USKeyboardLayout.js';
|
||||
import { _isElementHandle } from './ElementHandleSymbol.js';
|
||||
import type { KeyboardTypeOptions, KeyPressOptions, MouseClickOptions, TouchHandle } from './Input.js';
|
||||
import { JSHandle } from './JSHandle.js';
|
||||
import type { Locator } from './locators/locators.js';
|
||||
import type { QueryOptions, ScreenshotOptions, WaitForSelectorOptions } from './Page.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type Quad = [Point, Point, Point, Point];
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface BoxModel {
|
||||
content: Quad;
|
||||
padding: Quad;
|
||||
border: Quad;
|
||||
margin: Quad;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface BoundingBox extends Point {
|
||||
/**
|
||||
* the width of the element in pixels.
|
||||
*/
|
||||
width: number;
|
||||
/**
|
||||
* the height of the element in pixels.
|
||||
*/
|
||||
height: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface Offset {
|
||||
/**
|
||||
* x-offset for the clickable point relative to the top-left corner of the border box.
|
||||
*/
|
||||
x: number;
|
||||
/**
|
||||
* y-offset for the clickable point relative to the top-left corner of the border box.
|
||||
*/
|
||||
y: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ClickOptions extends MouseClickOptions {
|
||||
/**
|
||||
* Offset for the clickable point relative to the top-left corner of the border box.
|
||||
*/
|
||||
offset?: Offset;
|
||||
/**
|
||||
* An experimental debugging feature. If true, inserts an element into the
|
||||
* page to highlight the click location for 10 seconds. Might not work on all
|
||||
* pages and does not persist across navigations.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
debugHighlight?: boolean;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ElementScreenshotOptions extends ScreenshotOptions {
|
||||
/**
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
scrollIntoView?: boolean;
|
||||
}
|
||||
/**
|
||||
* A given method will have it's `this` replaced with an isolated version of
|
||||
* `this` when decorated with this decorator.
|
||||
*
|
||||
* All changes of isolated `this` are reflected on the actual `this`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare function bindIsolatedHandle<This extends ElementHandle<Node>>(target: (this: This, ...args: any[]) => Promise<any>, _: unknown): typeof target;
|
||||
/**
|
||||
* ElementHandle represents an in-page DOM element.
|
||||
*
|
||||
* @remarks
|
||||
* ElementHandles can be created with the {@link Page.$} method.
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* await page.goto('https://example.com');
|
||||
* const hrefElement = await page.$('a');
|
||||
* await hrefElement.click();
|
||||
* // ...
|
||||
* ```
|
||||
*
|
||||
* ElementHandle prevents the DOM element from being garbage-collected unless the
|
||||
* handle is {@link JSHandle.dispose | disposed}. ElementHandles are auto-disposed
|
||||
* when their associated frame is navigated away or the parent
|
||||
* context gets destroyed.
|
||||
*
|
||||
* ElementHandle instances can be used as arguments in {@link Page.$eval} and
|
||||
* {@link Page.evaluate} methods.
|
||||
*
|
||||
* If you're using TypeScript, ElementHandle takes a generic argument that
|
||||
* denotes the type of element the handle is holding within. For example, if you
|
||||
* have a handle to a `<select>` element, you can type it as
|
||||
* `ElementHandle<HTMLSelectElement>` and you get some nicer type checks.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class ElementHandle<ElementType extends Node = Element> extends JSHandle<ElementType> {
|
||||
#private;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
[_isElementHandle]: boolean;
|
||||
/**
|
||||
* @internal
|
||||
* Cached isolatedHandle to prevent
|
||||
* trying to adopt it multiple times
|
||||
*/
|
||||
isolatedHandle?: typeof this;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected readonly handle: JSHandle<ElementType>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(handle: JSHandle<ElementType>);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
get id(): string | undefined;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
get disposed(): boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
getProperty<K extends keyof ElementType>(propertyName: HandleOr<K>): Promise<HandleFor<ElementType[K]>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
getProperties(): Promise<Map<string, JSHandle>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
evaluate<Params extends unknown[], Func extends EvaluateFuncWith<ElementType, Params> = EvaluateFuncWith<ElementType, Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
evaluateHandle<Params extends unknown[], Func extends EvaluateFuncWith<ElementType, Params> = EvaluateFuncWith<ElementType, Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
jsonValue(): Promise<ElementType>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
remoteObject(): Protocol.Runtime.RemoteObject;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
dispose(): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
asElement(): ElementHandle<ElementType>;
|
||||
/**
|
||||
* Frame corresponding to the current handle.
|
||||
*/
|
||||
abstract get frame(): Frame;
|
||||
/**
|
||||
* Queries the current element for an element matching the given selector.
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @returns A {@link ElementHandle | element handle} to the first element
|
||||
* matching the given selector. Otherwise, `null`.
|
||||
*/
|
||||
$<Selector extends string>(selector: Selector): Promise<ElementHandle<NodeFor<Selector>> | null>;
|
||||
/**
|
||||
* Queries the current element for all elements matching the given selector.
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @returns An array of {@link ElementHandle | element handles} that point to
|
||||
* elements matching the given selector.
|
||||
*/
|
||||
$$<Selector extends string>(selector: Selector, options?: QueryOptions): Promise<Array<ElementHandle<NodeFor<Selector>>>>;
|
||||
/**
|
||||
* Runs the given function on the first element matching the given selector in
|
||||
* the current element.
|
||||
*
|
||||
* If the given function returns a promise, then this method will wait till
|
||||
* the promise resolves.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const tweetHandle = await page.$('.tweet');
|
||||
* expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe(
|
||||
* '100',
|
||||
* );
|
||||
* expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe(
|
||||
* '10',
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @param pageFunction - The function to be evaluated in this element's page's
|
||||
* context. The first element matching the selector will be passed in as the
|
||||
* first argument.
|
||||
* @param args - Additional arguments to pass to `pageFunction`.
|
||||
* @returns A promise to the result of the function.
|
||||
*/
|
||||
$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<NodeFor<Selector>, Params>>(selector: Selector, pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* Runs the given function on an array of elements matching the given selector
|
||||
* in the current element.
|
||||
*
|
||||
* If the given function returns a promise, then this method will wait till
|
||||
* the promise resolves.
|
||||
*
|
||||
* @example
|
||||
* HTML:
|
||||
*
|
||||
* ```html
|
||||
* <div class="feed">
|
||||
* <div class="tweet">Hello!</div>
|
||||
* <div class="tweet">Hi!</div>
|
||||
* </div>
|
||||
* ```
|
||||
*
|
||||
* JavaScript:
|
||||
*
|
||||
* ```ts
|
||||
* const feedHandle = await page.$('.feed');
|
||||
*
|
||||
* const listOfTweets = await feedHandle.$$eval('.tweet', nodes =>
|
||||
* nodes.map(n => n.innerText),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @param pageFunction - The function to be evaluated in the element's page's
|
||||
* context. An array of elements matching the given selector will be passed to
|
||||
* the function as its first argument.
|
||||
* @param args - Additional arguments to pass to `pageFunction`.
|
||||
* @returns A promise to the result of the function.
|
||||
*/
|
||||
$$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<Array<NodeFor<Selector>>, Params> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>>(selector: Selector, pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* Wait for an element matching the given selector to appear in the current
|
||||
* element.
|
||||
*
|
||||
* Unlike {@link Frame.waitForSelector}, this method does not work across
|
||||
* navigations or if the element is detached from DOM.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* let currentURL;
|
||||
* page
|
||||
* .mainFrame()
|
||||
* .waitForSelector('img')
|
||||
* .then(() => console.log('First URL with image: ' + currentURL));
|
||||
*
|
||||
* for (currentURL of [
|
||||
* 'https://example.com',
|
||||
* 'https://google.com',
|
||||
* 'https://bbc.com',
|
||||
* ]) {
|
||||
* await page.goto(currentURL);
|
||||
* }
|
||||
* await browser.close();
|
||||
* ```
|
||||
*
|
||||
* @param selector - The selector to query and wait for.
|
||||
* @param options - Options for customizing waiting behavior.
|
||||
* @returns An element matching the given selector.
|
||||
* @throws Throws if an element matching the given selector doesn't appear.
|
||||
*/
|
||||
waitForSelector<Selector extends string>(selector: Selector, options?: WaitForSelectorOptions): Promise<ElementHandle<NodeFor<Selector>> | null>;
|
||||
/**
|
||||
* An element is considered to be visible if all of the following is
|
||||
* true:
|
||||
*
|
||||
* - the element has
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
|
||||
*
|
||||
* - the element has a non-empty
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
|
||||
*
|
||||
* - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
|
||||
* is not `hidden` or `collapse`.
|
||||
*/
|
||||
isVisible(): Promise<boolean>;
|
||||
/**
|
||||
* An element is considered to be hidden if at least one of the following is true:
|
||||
*
|
||||
* - the element has no
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | computed styles}.
|
||||
*
|
||||
* - the element has an empty
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect | bounding client rect}.
|
||||
*
|
||||
* - the element's {@link https://developer.mozilla.org/en-US/docs/Web/CSS/visibility | visibility}
|
||||
* is `hidden` or `collapse`.
|
||||
*/
|
||||
isHidden(): Promise<boolean>;
|
||||
/**
|
||||
* Converts the current handle to the given element type.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const element: ElementHandle<Element> = await page.$(
|
||||
* '.class-name-of-anchor',
|
||||
* );
|
||||
* // DO NOT DISPOSE `element`, this will be always be the same handle.
|
||||
* const anchor: ElementHandle<HTMLAnchorElement> =
|
||||
* await element.toElement('a');
|
||||
* ```
|
||||
*
|
||||
* @param tagName - The tag name of the desired element type.
|
||||
* @throws An error if the handle does not match. **The handle will not be
|
||||
* automatically disposed.**
|
||||
*/
|
||||
toElement<K extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap>(tagName: K): Promise<HandleFor<ElementFor<K>>>;
|
||||
/**
|
||||
* Resolves the frame associated with the element, if any. Always exists for
|
||||
* HTMLIFrameElements.
|
||||
*/
|
||||
abstract contentFrame(this: ElementHandle<HTMLIFrameElement>): Promise<Frame>;
|
||||
abstract contentFrame(): Promise<Frame | null>;
|
||||
/**
|
||||
* Returns the middle point within an element unless a specific offset is provided.
|
||||
*/
|
||||
clickablePoint(offset?: Offset): Promise<Point>;
|
||||
/**
|
||||
* This method scrolls element into view if needed, and then
|
||||
* uses {@link Page.mouse} to hover over the center of the element.
|
||||
* If the element is detached from DOM, the method throws an error.
|
||||
*/
|
||||
hover(this: ElementHandle<Element>): Promise<void>;
|
||||
/**
|
||||
* This method scrolls element into view if needed, and then
|
||||
* uses {@link Page.mouse} to click in the center of the element.
|
||||
* If the element is detached from DOM, the method throws an error.
|
||||
*/
|
||||
click(this: ElementHandle<Element>, options?: Readonly<ClickOptions>): Promise<void>;
|
||||
/**
|
||||
* Drags an element over the given element or point.
|
||||
*
|
||||
* @returns DEPRECATED. When drag interception is enabled, the drag payload is
|
||||
* returned.
|
||||
*/
|
||||
drag(this: ElementHandle<Element>, target: Point | ElementHandle<Element>): Promise<Protocol.Input.DragData | void>;
|
||||
/**
|
||||
* @deprecated Do not use. `dragenter` will automatically be performed during dragging.
|
||||
*/
|
||||
dragEnter(this: ElementHandle<Element>, data?: Protocol.Input.DragData): Promise<void>;
|
||||
/**
|
||||
* @deprecated Do not use. `dragover` will automatically be performed during dragging.
|
||||
*/
|
||||
dragOver(this: ElementHandle<Element>, data?: Protocol.Input.DragData): Promise<void>;
|
||||
/**
|
||||
* Drops the given element onto the current one.
|
||||
*/
|
||||
drop(this: ElementHandle<Element>, element: ElementHandle<Element>): Promise<void>;
|
||||
/**
|
||||
* @deprecated No longer supported.
|
||||
*/
|
||||
drop(this: ElementHandle<Element>, data?: Protocol.Input.DragData): Promise<void>;
|
||||
/**
|
||||
* @deprecated Use `ElementHandle.drop` instead.
|
||||
*/
|
||||
dragAndDrop(this: ElementHandle<Element>, target: ElementHandle<Node>, options?: {
|
||||
delay: number;
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* Triggers a `change` and `input` event once all the provided options have been
|
||||
* selected. If there's no `<select>` element matching `selector`, the method
|
||||
* throws an error.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* handle.select('blue'); // single selection
|
||||
* handle.select('red', 'green', 'blue'); // multiple selections
|
||||
* ```
|
||||
*
|
||||
* @param values - Values of options to select. If the `<select>` has the
|
||||
* `multiple` attribute, all values are considered, otherwise only the first
|
||||
* one is taken into account.
|
||||
*/
|
||||
select(...values: string[]): Promise<string[]>;
|
||||
/**
|
||||
* Sets the value of an
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input | input element}
|
||||
* to the given file paths.
|
||||
*
|
||||
* @remarks This will not validate whether the file paths exists. Also, if a
|
||||
* path is relative, then it is resolved against the
|
||||
* {@link https://nodejs.org/api/process.html#process_process_cwd | current working directory}.
|
||||
* For locals script connecting to remote chrome environments, paths must be
|
||||
* absolute.
|
||||
*/
|
||||
abstract uploadFile(this: ElementHandle<HTMLInputElement>, ...paths: string[]): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract queryAXTree(name?: string, role?: string): AwaitableIterable<ElementHandle<Node>>;
|
||||
/**
|
||||
* This method scrolls element into view if needed, and then uses
|
||||
* {@link Touchscreen.tap} to tap in the center of the element.
|
||||
* If the element is detached from DOM, the method throws an error.
|
||||
*/
|
||||
tap(this: ElementHandle<Element>): Promise<void>;
|
||||
/**
|
||||
* This method scrolls the element into view if needed, and then
|
||||
* starts a touch in the center of the element.
|
||||
* @returns A {@link TouchHandle} representing the touch that was started
|
||||
*/
|
||||
touchStart(this: ElementHandle<Element>): Promise<TouchHandle>;
|
||||
/**
|
||||
* This method scrolls the element into view if needed, and then
|
||||
* moves the touch to the center of the element.
|
||||
* @param touch - An optional {@link TouchHandle}. If provided, this touch
|
||||
* will be moved. If not provided, the first active touch will be moved.
|
||||
*/
|
||||
touchMove(this: ElementHandle<Element>, touch?: TouchHandle): Promise<void>;
|
||||
touchEnd(this: ElementHandle<Element>): Promise<void>;
|
||||
/**
|
||||
* Calls {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus | focus} on the element.
|
||||
*/
|
||||
focus(): Promise<void>;
|
||||
/**
|
||||
* Focuses the element, and then sends a `keydown`, `keypress`/`input`, and
|
||||
* `keyup` event for each character in the text.
|
||||
*
|
||||
* To press a special key, like `Control` or `ArrowDown`,
|
||||
* use {@link ElementHandle.press}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* await elementHandle.type('Hello'); // Types instantly
|
||||
* await elementHandle.type('World', {delay: 100}); // Types slower, like a user
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* An example of typing into a text field and then submitting the form:
|
||||
*
|
||||
* ```ts
|
||||
* const elementHandle = await page.$('input');
|
||||
* await elementHandle.type('some text');
|
||||
* await elementHandle.press('Enter');
|
||||
* ```
|
||||
*
|
||||
* @param options - Delay in milliseconds. Defaults to 0.
|
||||
*/
|
||||
type(text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
|
||||
/**
|
||||
* Focuses the element, and then uses {@link Keyboard.down} and {@link Keyboard.up}.
|
||||
*
|
||||
* @remarks
|
||||
* If `key` is a single character and no modifier keys besides `Shift`
|
||||
* are being held down, a `keypress`/`input` event will also be generated.
|
||||
* The `text` option can be specified to force an input event to be generated.
|
||||
*
|
||||
* **NOTE** Modifier keys DO affect `elementHandle.press`. Holding down `Shift`
|
||||
* will type the text in upper case.
|
||||
*
|
||||
* @param key - Name of key to press, such as `ArrowLeft`.
|
||||
* See {@link KeyInput} for a list of all key names.
|
||||
*/
|
||||
press(key: KeyInput, options?: Readonly<KeyPressOptions>): Promise<void>;
|
||||
/**
|
||||
* This method returns the bounding box of the element (relative to the main frame),
|
||||
* or `null` if the element is {@link https://drafts.csswg.org/css-display-4/#box-generation | not part of the layout}
|
||||
* (example: `display: none`).
|
||||
*/
|
||||
boundingBox(): Promise<BoundingBox | null>;
|
||||
/**
|
||||
* This method returns boxes of the element,
|
||||
* or `null` if the element is {@link https://drafts.csswg.org/css-display-4/#box-generation | not part of the layout}
|
||||
* (example: `display: none`).
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Boxes are represented as an array of points;
|
||||
* Each Point is an object `{x, y}`. Box points are sorted clock-wise.
|
||||
*/
|
||||
boxModel(): Promise<BoxModel | null>;
|
||||
/**
|
||||
* This method scrolls element into view if needed, and then uses
|
||||
* {@link Page.(screenshot:2) } to take a screenshot of the element.
|
||||
* If the element is detached from DOM, the method throws an error.
|
||||
*/
|
||||
screenshot(options: Readonly<ScreenshotOptions> & {
|
||||
encoding: 'base64';
|
||||
}): Promise<string>;
|
||||
screenshot(options?: Readonly<ScreenshotOptions>): Promise<Uint8Array>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected assertConnectedElement(): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected scrollIntoViewIfNeeded(this: ElementHandle<Element>): Promise<void>;
|
||||
/**
|
||||
* Resolves to true if the element is visible in the current viewport. If an
|
||||
* element is an SVG, we check if the svg owner element is in the viewport
|
||||
* instead. See https://crbug.com/963246.
|
||||
*
|
||||
* @param options - Threshold for the intersection between 0 (no intersection) and 1
|
||||
* (full intersection). Defaults to 1.
|
||||
*/
|
||||
isIntersectingViewport(this: ElementHandle<Element>, options?: {
|
||||
threshold?: number;
|
||||
}): Promise<boolean>;
|
||||
/**
|
||||
* Scrolls the element into view using either the automation protocol client
|
||||
* or by calling element.scrollIntoView.
|
||||
*/
|
||||
scrollIntoView(this: ElementHandle<Element>): Promise<void>;
|
||||
/**
|
||||
* Creates a locator based on an ElementHandle. This would not allow
|
||||
* refreshing the element handle if it is stale but it allows re-using other
|
||||
* locator pre-conditions.
|
||||
*/
|
||||
asLocator(this: ElementHandle<Element>): Locator<Element>;
|
||||
/**
|
||||
* If the element is a form input, you can use {@link ElementHandle.autofill}
|
||||
* to test if the form is compatible with the browser's autofill
|
||||
* implementation. Throws an error if the form cannot be autofilled.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Currently, Puppeteer supports auto-filling credit card information only and
|
||||
* in Chrome in the new headless and headful modes only.
|
||||
*
|
||||
* ```ts
|
||||
* // Select an input on the credit card form.
|
||||
* const name = await page.waitForSelector('form #name');
|
||||
* // Trigger autofill with the desired data.
|
||||
* await name.autofill({
|
||||
* creditCard: {
|
||||
* number: '4444444444444444',
|
||||
* name: 'John Smith',
|
||||
* expiryMonth: '01',
|
||||
* expiryYear: '2030',
|
||||
* cvc: '123',
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
abstract autofill(data: AutofillData): Promise<void>;
|
||||
/**
|
||||
* When connected using Chrome DevTools Protocol, it returns a
|
||||
* DOM.BackendNodeId for the element.
|
||||
*/
|
||||
abstract backendNodeId(): Promise<number>;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface AutofillData {
|
||||
/**
|
||||
* See {@link https://chromedevtools.github.io/devtools-protocol/tot/Autofill/#type-CreditCard | Autofill.CreditCard}.
|
||||
*/
|
||||
creditCard: {
|
||||
number: string;
|
||||
name: string;
|
||||
expiryMonth: string;
|
||||
expiryYear: string;
|
||||
cvc: string;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=ElementHandle.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1406
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.js
generated
vendored
Normal file
1406
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandle.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.d.ts
generated
vendored
Normal file
10
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare const _isElementHandle: unique symbol;
|
||||
//# sourceMappingURL=ElementHandleSymbol.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ElementHandleSymbol.d.ts","sourceRoot":"","sources":["../../../../src/api/ElementHandleSymbol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAA6B,CAAC"}
|
||||
10
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.js
generated
vendored
Normal file
10
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const _isElementHandle = Symbol('_isElementHandle');
|
||||
//# sourceMappingURL=ElementHandleSymbol.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/ElementHandleSymbol.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ElementHandleSymbol.js","sourceRoot":"","sources":["../../../../src/api/ElementHandleSymbol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
|
||||
15
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.d.ts
generated
vendored
Normal file
15
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { CDPSession } from './CDPSession.js';
|
||||
import type { Realm } from './Realm.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface Environment {
|
||||
get client(): CDPSession;
|
||||
mainRealm(): Realm;
|
||||
}
|
||||
//# sourceMappingURL=Environment.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Environment.d.ts","sourceRoot":"","sources":["../../../../src/api/Environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,MAAM,IAAI,UAAU,CAAC;IACzB,SAAS,IAAI,KAAK,CAAC;CACpB"}
|
||||
7
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.js
generated
vendored
Normal file
7
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
export {};
|
||||
//# sourceMappingURL=Environment.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Environment.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Environment.js","sourceRoot":"","sources":["../../../../src/api/Environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
||||
775
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.d.ts
generated
vendored
Normal file
775
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.d.ts
generated
vendored
Normal file
@@ -0,0 +1,775 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type Protocol from 'devtools-protocol';
|
||||
import type { ClickOptions, ElementHandle } from '../api/ElementHandle.js';
|
||||
import type { HTTPResponse } from '../api/HTTPResponse.js';
|
||||
import type { Page, QueryOptions, WaitForSelectorOptions, WaitTimeoutOptions } from '../api/Page.js';
|
||||
import type { Accessibility } from '../cdp/Accessibility.js';
|
||||
import type { PuppeteerLifeCycleEvent } from '../cdp/LifecycleWatcher.js';
|
||||
import { EventEmitter, type EventType } from '../common/EventEmitter.js';
|
||||
import type { Awaitable, EvaluateFunc, EvaluateFuncWith, HandleFor, NodeFor } from '../common/types.js';
|
||||
import type { CDPSession } from './CDPSession.js';
|
||||
import type { DeviceRequestPrompt } from './DeviceRequestPrompt.js';
|
||||
import type { KeyboardTypeOptions } from './Input.js';
|
||||
import { type Locator } from './locators/locators.js';
|
||||
import type { Realm } from './Realm.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface WaitForOptions {
|
||||
/**
|
||||
* Maximum wait time in milliseconds. Pass 0 to disable the timeout.
|
||||
*
|
||||
* The default value can be changed by using the
|
||||
* {@link Page.setDefaultTimeout} or {@link Page.setDefaultNavigationTimeout}
|
||||
* methods.
|
||||
*
|
||||
* @defaultValue `30000`
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* When to consider waiting succeeds. Given an array of event strings, waiting
|
||||
* is considered to be successful after all events have been fired.
|
||||
*
|
||||
* @defaultValue `'load'`
|
||||
*/
|
||||
waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
ignoreSameDocumentNavigation?: boolean;
|
||||
/**
|
||||
* A signal object that allows you to cancel the call.
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface GoToOptions extends WaitForOptions {
|
||||
/**
|
||||
* If provided, it will take preference over the referer header value set by
|
||||
* {@link Page.setExtraHTTPHeaders | page.setExtraHTTPHeaders()}.
|
||||
*/
|
||||
referer?: string;
|
||||
/**
|
||||
* If provided, it will take preference over the referer-policy header value
|
||||
* set by {@link Page.setExtraHTTPHeaders | page.setExtraHTTPHeaders()}.
|
||||
*/
|
||||
referrerPolicy?: string;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface FrameWaitForFunctionOptions {
|
||||
/**
|
||||
* An interval at which the `pageFunction` is executed, defaults to `raf`. If
|
||||
* `polling` is a number, then it is treated as an interval in milliseconds at
|
||||
* which the function would be executed. If `polling` is a string, then it can
|
||||
* be one of the following values:
|
||||
*
|
||||
* - `raf` - to constantly execute `pageFunction` in `requestAnimationFrame`
|
||||
* callback. This is the tightest polling mode which is suitable to observe
|
||||
* styling changes.
|
||||
*
|
||||
* - `mutation` - to execute `pageFunction` on every DOM mutation.
|
||||
*/
|
||||
polling?: 'raf' | 'mutation' | number;
|
||||
/**
|
||||
* Maximum time to wait in milliseconds. Defaults to `30000` (30 seconds).
|
||||
* Pass `0` to disable the timeout. Puppeteer's default timeout can be changed
|
||||
* using {@link Page.setDefaultTimeout}.
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* A signal object that allows you to cancel a waitForFunction call.
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface FrameAddScriptTagOptions {
|
||||
/**
|
||||
* URL of the script to be added.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Path to a JavaScript file to be injected into the frame.
|
||||
*
|
||||
* @remarks
|
||||
* If `path` is a relative path, it is resolved relative to the current
|
||||
* working directory (`process.cwd()` in Node.js).
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* JavaScript to be injected into the frame.
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* Sets the `type` of the script. Use `module` in order to load an ES2015 module.
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* Sets the `id` of the script.
|
||||
*/
|
||||
id?: string;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface FrameAddStyleTagOptions {
|
||||
/**
|
||||
* the URL of the CSS file to be added.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* The path to a CSS file to be injected into the frame.
|
||||
* @remarks
|
||||
* If `path` is a relative path, it is resolved relative to the current
|
||||
* working directory (`process.cwd()` in Node.js).
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* Raw CSS content to be injected into the frame.
|
||||
*/
|
||||
content?: string;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface FrameEvents extends Record<EventType, unknown> {
|
||||
/** @internal */
|
||||
[FrameEvent.FrameNavigated]: Protocol.Page.NavigationType;
|
||||
/** @internal */
|
||||
[FrameEvent.FrameSwapped]: undefined;
|
||||
/** @internal */
|
||||
[FrameEvent.LifecycleEvent]: undefined;
|
||||
/** @internal */
|
||||
[FrameEvent.FrameNavigatedWithinDocument]: undefined;
|
||||
/** @internal */
|
||||
[FrameEvent.FrameDetached]: Frame;
|
||||
/** @internal */
|
||||
[FrameEvent.FrameSwappedByActivation]: undefined;
|
||||
}
|
||||
/**
|
||||
* We use symbols to prevent external parties listening to these events.
|
||||
* They are internal to Puppeteer.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare namespace FrameEvent {
|
||||
const FrameNavigated: unique symbol;
|
||||
const FrameSwapped: unique symbol;
|
||||
const LifecycleEvent: unique symbol;
|
||||
const FrameNavigatedWithinDocument: unique symbol;
|
||||
const FrameDetached: unique symbol;
|
||||
const FrameSwappedByActivation: unique symbol;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare const throwIfDetached: (target: (this: Frame, ...args: any[]) => any, _: unknown) => (this: Frame, ...args: any[]) => any;
|
||||
/**
|
||||
* Represents a DOM frame.
|
||||
*
|
||||
* To understand frames, you can think of frames as `<iframe>` elements. Just
|
||||
* like iframes, frames can be nested, and when JavaScript is executed in a
|
||||
* frame, the JavaScript does not affect frames inside the ambient frame the
|
||||
* JavaScript executes in.
|
||||
*
|
||||
* @example
|
||||
* At any point in time, {@link Page | pages} expose their current frame
|
||||
* tree via the {@link Page.mainFrame} and {@link Frame.childFrames} methods.
|
||||
*
|
||||
* @example
|
||||
* An example of dumping frame tree:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* await page.goto('https://www.google.com/chrome/browser/canary.html');
|
||||
* dumpFrameTree(page.mainFrame(), '');
|
||||
* await browser.close();
|
||||
*
|
||||
* function dumpFrameTree(frame, indent) {
|
||||
* console.log(indent + frame.url());
|
||||
* for (const child of frame.childFrames()) {
|
||||
* dumpFrameTree(child, indent + ' ');
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* An example of getting text from an iframe element:
|
||||
*
|
||||
* ```ts
|
||||
* const frames = page.frames();
|
||||
* let frame = null;
|
||||
* for (const currentFrame of frames) {
|
||||
* const frameElement = await currentFrame.frameElement();
|
||||
* const name = await frameElement.evaluate(el => el.getAttribute('name'));
|
||||
* if (name === 'myframe') {
|
||||
* frame = currentFrame;
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
* if (frame) {
|
||||
* const text = await frame.$eval(
|
||||
* '.selector',
|
||||
* element => element.textContent,
|
||||
* );
|
||||
* console.log(text);
|
||||
* } else {
|
||||
* console.error('Frame with name "myframe" not found.');
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* Frame lifecycles are controlled by three events that are all dispatched on
|
||||
* the parent {@link Frame.page | page}:
|
||||
*
|
||||
* - {@link PageEvent.FrameAttached}
|
||||
* - {@link PageEvent.FrameNavigated}
|
||||
* - {@link PageEvent.FrameDetached}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Frame extends EventEmitter<FrameEvents> {
|
||||
#private;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_id: string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_parentId?: string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_name?: string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_hasStartedLoading: boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* The page associated with the frame.
|
||||
*/
|
||||
abstract page(): Page;
|
||||
/**
|
||||
* Navigates the frame or page to the given `url`.
|
||||
*
|
||||
* @remarks
|
||||
* Navigation to `about:blank` or navigation to the same URL with a different
|
||||
* hash will succeed and return `null`.
|
||||
*
|
||||
* :::warning
|
||||
*
|
||||
* Headless shell mode doesn't support navigation to a PDF document. See the
|
||||
* {@link https://crbug.com/761295 | upstream issue}.
|
||||
*
|
||||
* :::
|
||||
*
|
||||
* In headless shell, this method will not throw an error when any valid HTTP
|
||||
* status code is returned by the remote server, including 404 "Not Found" and
|
||||
* 500 "Internal Server Error". The status code for such responses can be
|
||||
* retrieved by calling {@link HTTPResponse.status}.
|
||||
*
|
||||
* @param url - URL to navigate the frame to. The URL should include scheme,
|
||||
* e.g. `https://`
|
||||
* @param options - Options to configure waiting behavior.
|
||||
* @returns A promise which resolves to the main resource response. In case of
|
||||
* multiple redirects, the navigation will resolve with the response of the
|
||||
* last redirect.
|
||||
* @throws If:
|
||||
*
|
||||
* - there's an SSL error (e.g. in case of self-signed certificates).
|
||||
*
|
||||
* - target URL is invalid.
|
||||
*
|
||||
* - the timeout is exceeded during navigation.
|
||||
*
|
||||
* - the remote server does not respond or is unreachable.
|
||||
*
|
||||
* - the main resource failed to load.
|
||||
*/
|
||||
abstract goto(url: string, options?: GoToOptions): Promise<HTTPResponse | null>;
|
||||
/**
|
||||
* Waits for the frame to navigate. It is useful for when you run code which
|
||||
* will indirectly cause the frame to navigate.
|
||||
*
|
||||
* Usage of the
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/History_API | History API}
|
||||
* to change the URL is considered a navigation.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const [response] = await Promise.all([
|
||||
* // The navigation promise resolves after navigation has finished
|
||||
* frame.waitForNavigation(),
|
||||
* // Clicking the link will indirectly cause a navigation
|
||||
* frame.click('a.my-link'),
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* @param options - Options to configure waiting behavior.
|
||||
* @returns A promise which resolves to the main resource response.
|
||||
*/
|
||||
abstract waitForNavigation(options?: WaitForOptions): Promise<HTTPResponse | null>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract get client(): CDPSession;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract get accessibility(): Accessibility;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract mainRealm(): Realm;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract isolatedRealm(): Realm;
|
||||
/**
|
||||
* Used to clear the document handle that has been destroyed.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
clearDocumentHandle(): void;
|
||||
/**
|
||||
* @returns The frame element associated with this frame (if any).
|
||||
*/
|
||||
frameElement(): Promise<HandleFor<HTMLIFrameElement> | null>;
|
||||
/**
|
||||
* Behaves identically to {@link Page.evaluateHandle} except it's run within
|
||||
* the context of this frame.
|
||||
*
|
||||
* See {@link Page.evaluateHandle} for details.
|
||||
*/
|
||||
evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
/**
|
||||
* Behaves identically to {@link Page.evaluate} except it's run within
|
||||
* the context of this frame.
|
||||
*
|
||||
* See {@link Page.evaluate} for details.
|
||||
*/
|
||||
evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* Creates a locator for the provided selector. See {@link Locator} for
|
||||
* details and supported actions.
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
*/
|
||||
locator<Selector extends string>(selector: Selector): Locator<NodeFor<Selector>>;
|
||||
/**
|
||||
* Creates a locator for the provided function. See {@link Locator} for
|
||||
* details and supported actions.
|
||||
*/
|
||||
locator<Ret>(func: () => Awaitable<Ret>): Locator<Ret>;
|
||||
/**
|
||||
* Queries the frame for an element matching the given selector.
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
*
|
||||
* @returns A {@link ElementHandle | element handle} to the first element
|
||||
* matching the given selector. Otherwise, `null`.
|
||||
*/
|
||||
$<Selector extends string>(selector: Selector): Promise<ElementHandle<NodeFor<Selector>> | null>;
|
||||
/**
|
||||
* Queries the frame for all elements matching the given selector.
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
*
|
||||
* @returns An array of {@link ElementHandle | element handles} that point to
|
||||
* elements matching the given selector.
|
||||
*/
|
||||
$$<Selector extends string>(selector: Selector, options?: QueryOptions): Promise<Array<ElementHandle<NodeFor<Selector>>>>;
|
||||
/**
|
||||
* Runs the given function on the first element matching the given selector in
|
||||
* the frame.
|
||||
*
|
||||
* If the given function returns a promise, then this method will wait till
|
||||
* the promise resolves.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const searchValue = await frame.$eval('#search', el => el.value);
|
||||
* ```
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @param pageFunction - The function to be evaluated in the frame's context.
|
||||
* The first element matching the selector will be passed to the function as
|
||||
* its first argument.
|
||||
* @param args - Additional arguments to pass to `pageFunction`.
|
||||
* @returns A promise to the result of the function.
|
||||
*/
|
||||
$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<NodeFor<Selector>, Params>>(selector: Selector, pageFunction: string | Func, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* Runs the given function on an array of elements matching the given selector
|
||||
* in the frame.
|
||||
*
|
||||
* If the given function returns a promise, then this method will wait till
|
||||
* the promise resolves.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const divsCounts = await frame.$$eval('div', divs => divs.length);
|
||||
* ```
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @param pageFunction - The function to be evaluated in the frame's context.
|
||||
* An array of elements matching the given selector will be passed to the
|
||||
* function as its first argument.
|
||||
* @param args - Additional arguments to pass to `pageFunction`.
|
||||
* @returns A promise to the result of the function.
|
||||
*/
|
||||
$$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<Array<NodeFor<Selector>>, Params> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>>(selector: Selector, pageFunction: string | Func, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* Waits for an element matching the given selector to appear in the frame.
|
||||
*
|
||||
* This method works across navigations.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* let currentURL;
|
||||
* page
|
||||
* .mainFrame()
|
||||
* .waitForSelector('img')
|
||||
* .then(() => console.log('First URL with image: ' + currentURL));
|
||||
*
|
||||
* for (currentURL of [
|
||||
* 'https://example.com',
|
||||
* 'https://google.com',
|
||||
* 'https://bbc.com',
|
||||
* ]) {
|
||||
* await page.goto(currentURL);
|
||||
* }
|
||||
* await browser.close();
|
||||
* ```
|
||||
*
|
||||
* @param selector - The selector to query and wait for.
|
||||
* @param options - Options for customizing waiting behavior.
|
||||
* @returns An element matching the given selector.
|
||||
* @throws Throws if an element matching the given selector doesn't appear.
|
||||
*/
|
||||
waitForSelector<Selector extends string>(selector: Selector, options?: WaitForSelectorOptions): Promise<ElementHandle<NodeFor<Selector>> | null>;
|
||||
/**
|
||||
* @example
|
||||
* The `waitForFunction` can be used to observe viewport size change:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* const watchDog = page
|
||||
* .mainFrame()
|
||||
* .waitForFunction('window.innerWidth < 100');
|
||||
* page.setViewport({width: 50, height: 50});
|
||||
* await watchDog;
|
||||
* await browser.close();
|
||||
* ```
|
||||
*
|
||||
* To pass arguments from Node.js to the predicate of `page.waitForFunction` function:
|
||||
*
|
||||
* ```ts
|
||||
* const selector = '.foo';
|
||||
* await frame.waitForFunction(
|
||||
* selector => !!document.querySelector(selector),
|
||||
* {}, // empty options object
|
||||
* selector,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param pageFunction - the function to evaluate in the frame context.
|
||||
* @param options - options to configure the polling method, timeout and signal.
|
||||
* @param args - arguments to pass to the `pageFunction`.
|
||||
* @returns the promise which resolve when the `pageFunction` returns a truthy value.
|
||||
*/
|
||||
waitForFunction<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, options?: FrameWaitForFunctionOptions, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
/**
|
||||
* The full HTML contents of the frame, including the DOCTYPE.
|
||||
*/
|
||||
content(): Promise<string>;
|
||||
/**
|
||||
* Set the content of the frame.
|
||||
*
|
||||
* @param html - HTML markup to assign to the page.
|
||||
* @param options - Options to configure how long before timing out and at
|
||||
* what point to consider the content setting successful.
|
||||
*/
|
||||
abstract setContent(html: string, options?: WaitForOptions): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
setFrameContent(content: string): Promise<void>;
|
||||
/**
|
||||
* The frame's `name` attribute as specified in the tag.
|
||||
*
|
||||
* @remarks
|
||||
* If the name is empty, it returns the `id` attribute instead.
|
||||
*
|
||||
* @remarks
|
||||
* This value is calculated once when the frame is created, and will not
|
||||
* update if the attribute is changed later.
|
||||
*
|
||||
* @deprecated Use
|
||||
*
|
||||
* ```ts
|
||||
* const element = await frame.frameElement();
|
||||
* const nameOrId = await element.evaluate(frame => frame.name ?? frame.id);
|
||||
* ```
|
||||
*/
|
||||
name(): string;
|
||||
/**
|
||||
* The frame's URL.
|
||||
*/
|
||||
abstract url(): string;
|
||||
/**
|
||||
* The parent frame, if any. Detached and main frames return `null`.
|
||||
*/
|
||||
abstract parentFrame(): Frame | null;
|
||||
/**
|
||||
* An array of child frames.
|
||||
*/
|
||||
abstract childFrames(): Frame[];
|
||||
/**
|
||||
* @returns `true` if the frame has detached. `false` otherwise.
|
||||
*/
|
||||
abstract get detached(): boolean;
|
||||
/**
|
||||
* Is`true` if the frame has been detached. Otherwise, `false`.
|
||||
*
|
||||
* @deprecated Use the `detached` getter.
|
||||
*/
|
||||
isDetached(): boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
get disposed(): boolean;
|
||||
/**
|
||||
* Adds a `<script>` tag into the page with the desired url or content.
|
||||
*
|
||||
* @param options - Options for the script.
|
||||
* @returns An {@link ElementHandle | element handle} to the injected
|
||||
* `<script>` element.
|
||||
*/
|
||||
addScriptTag(options: FrameAddScriptTagOptions): Promise<ElementHandle<HTMLScriptElement>>;
|
||||
/**
|
||||
* Adds a `HTMLStyleElement` into the frame with the desired URL
|
||||
*
|
||||
* @returns An {@link ElementHandle | element handle} to the loaded `<style>`
|
||||
* element.
|
||||
*/
|
||||
addStyleTag(options: Omit<FrameAddStyleTagOptions, 'url'>): Promise<ElementHandle<HTMLStyleElement>>;
|
||||
/**
|
||||
* Adds a `HTMLLinkElement` into the frame with the desired URL
|
||||
*
|
||||
* @returns An {@link ElementHandle | element handle} to the loaded `<link>`
|
||||
* element.
|
||||
*/
|
||||
addStyleTag(options: FrameAddStyleTagOptions): Promise<ElementHandle<HTMLLinkElement>>;
|
||||
/**
|
||||
* Clicks the first element found that matches `selector`.
|
||||
*
|
||||
* @remarks
|
||||
* If `click()` triggers a navigation event and there's a separate
|
||||
* `page.waitForNavigation()` promise to be resolved, you may end up with a
|
||||
* race condition that yields unexpected results. The correct pattern for
|
||||
* click and wait for navigation is the following:
|
||||
*
|
||||
* ```ts
|
||||
* const [response] = await Promise.all([
|
||||
* page.waitForNavigation(waitOptions),
|
||||
* frame.click(selector, clickOptions),
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
*/
|
||||
click(selector: string, options?: Readonly<ClickOptions>): Promise<void>;
|
||||
/**
|
||||
* Focuses the first element that matches the `selector`.
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @throws Throws if there's no element matching `selector`.
|
||||
*/
|
||||
focus(selector: string): Promise<void>;
|
||||
/**
|
||||
* Hovers the pointer over the center of the first element that matches the
|
||||
* `selector`.
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @throws Throws if there's no element matching `selector`.
|
||||
*/
|
||||
hover(selector: string): Promise<void>;
|
||||
/**
|
||||
* Selects a set of value on the first `<select>` element that matches the
|
||||
* `selector`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* frame.select('select#colors', 'blue'); // single selection
|
||||
* frame.select('select#colors', 'red', 'green', 'blue'); // multiple selections
|
||||
* ```
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @param values - The array of values to select. If the `<select>` has the
|
||||
* `multiple` attribute, all values are considered, otherwise only the first
|
||||
* one is taken into account.
|
||||
* @returns the list of values that were successfully selected.
|
||||
* @throws Throws if there's no `<select>` matching `selector`.
|
||||
*/
|
||||
select(selector: string, ...values: string[]): Promise<string[]>;
|
||||
/**
|
||||
* Taps the first element that matches the `selector`.
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @throws Throws if there's no element matching `selector`.
|
||||
*/
|
||||
tap(selector: string): Promise<void>;
|
||||
/**
|
||||
* Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character
|
||||
* in the text.
|
||||
*
|
||||
* @remarks
|
||||
* To press a special key, like `Control` or `ArrowDown`, use
|
||||
* {@link Keyboard.press}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* await frame.type('#mytextarea', 'Hello'); // Types instantly
|
||||
* await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
|
||||
* ```
|
||||
*
|
||||
* @param selector - the selector for the element to type into. If there are
|
||||
* multiple the first will be used.
|
||||
* @param text - text to type into the element
|
||||
* @param options - takes one option, `delay`, which sets the time to wait
|
||||
* between key presses in milliseconds. Defaults to `0`.
|
||||
*/
|
||||
type(selector: string, text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
|
||||
/**
|
||||
* The frame's title.
|
||||
*/
|
||||
title(): Promise<string>;
|
||||
/**
|
||||
* This method is typically coupled with an action that triggers a device
|
||||
* request from an api such as WebBluetooth.
|
||||
*
|
||||
* :::caution
|
||||
*
|
||||
* This must be called before the device request is made. It will not return a
|
||||
* currently active device prompt.
|
||||
*
|
||||
* :::
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const [devicePrompt] = Promise.all([
|
||||
* frame.waitForDevicePrompt(),
|
||||
* frame.click('#connect-bluetooth'),
|
||||
* ]);
|
||||
* await devicePrompt.select(
|
||||
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract waitForDevicePrompt(options?: WaitTimeoutOptions): Promise<DeviceRequestPrompt>;
|
||||
}
|
||||
//# sourceMappingURL=Frame.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
904
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.js
generated
vendored
Normal file
904
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.js
generated
vendored
Normal file
@@ -0,0 +1,904 @@
|
||||
/**
|
||||
* @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 { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { getQueryHandlerAndSelector } from '../common/GetQueryHandler.js';
|
||||
import { transposeIterableHandle } from '../common/HandleIterator.js';
|
||||
import { withSourcePuppeteerURLIfNone } from '../common/util.js';
|
||||
import { environment } from '../environment.js';
|
||||
import { assert } from '../util/assert.js';
|
||||
import { throwIfDisposed } from '../util/decorators.js';
|
||||
import { FunctionLocator, NodeLocator, } from './locators/locators.js';
|
||||
/**
|
||||
* We use symbols to prevent external parties listening to these events.
|
||||
* They are internal to Puppeteer.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
export var FrameEvent;
|
||||
(function (FrameEvent) {
|
||||
FrameEvent.FrameNavigated = Symbol('Frame.FrameNavigated');
|
||||
FrameEvent.FrameSwapped = Symbol('Frame.FrameSwapped');
|
||||
FrameEvent.LifecycleEvent = Symbol('Frame.LifecycleEvent');
|
||||
FrameEvent.FrameNavigatedWithinDocument = Symbol('Frame.FrameNavigatedWithinDocument');
|
||||
FrameEvent.FrameDetached = Symbol('Frame.FrameDetached');
|
||||
FrameEvent.FrameSwappedByActivation = Symbol('Frame.FrameSwappedByActivation');
|
||||
})(FrameEvent || (FrameEvent = {}));
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const throwIfDetached = throwIfDisposed(frame => {
|
||||
return `Attempted to use detached Frame '${frame._id}'.`;
|
||||
});
|
||||
/**
|
||||
* Represents a DOM frame.
|
||||
*
|
||||
* To understand frames, you can think of frames as `<iframe>` elements. Just
|
||||
* like iframes, frames can be nested, and when JavaScript is executed in a
|
||||
* frame, the JavaScript does not affect frames inside the ambient frame the
|
||||
* JavaScript executes in.
|
||||
*
|
||||
* @example
|
||||
* At any point in time, {@link Page | pages} expose their current frame
|
||||
* tree via the {@link Page.mainFrame} and {@link Frame.childFrames} methods.
|
||||
*
|
||||
* @example
|
||||
* An example of dumping frame tree:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* await page.goto('https://www.google.com/chrome/browser/canary.html');
|
||||
* dumpFrameTree(page.mainFrame(), '');
|
||||
* await browser.close();
|
||||
*
|
||||
* function dumpFrameTree(frame, indent) {
|
||||
* console.log(indent + frame.url());
|
||||
* for (const child of frame.childFrames()) {
|
||||
* dumpFrameTree(child, indent + ' ');
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* An example of getting text from an iframe element:
|
||||
*
|
||||
* ```ts
|
||||
* const frames = page.frames();
|
||||
* let frame = null;
|
||||
* for (const currentFrame of frames) {
|
||||
* const frameElement = await currentFrame.frameElement();
|
||||
* const name = await frameElement.evaluate(el => el.getAttribute('name'));
|
||||
* if (name === 'myframe') {
|
||||
* frame = currentFrame;
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
* if (frame) {
|
||||
* const text = await frame.$eval(
|
||||
* '.selector',
|
||||
* element => element.textContent,
|
||||
* );
|
||||
* console.log(text);
|
||||
* } else {
|
||||
* console.error('Frame with name "myframe" not found.');
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* Frame lifecycles are controlled by three events that are all dispatched on
|
||||
* the parent {@link Frame.page | page}:
|
||||
*
|
||||
* - {@link PageEvent.FrameAttached}
|
||||
* - {@link PageEvent.FrameNavigated}
|
||||
* - {@link PageEvent.FrameDetached}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
let Frame = (() => {
|
||||
let _classSuper = EventEmitter;
|
||||
let _instanceExtraInitializers = [];
|
||||
let _frameElement_decorators;
|
||||
let _evaluateHandle_decorators;
|
||||
let _evaluate_decorators;
|
||||
let _locator_decorators;
|
||||
let _$_decorators;
|
||||
let _$$_decorators;
|
||||
let _$eval_decorators;
|
||||
let _$$eval_decorators;
|
||||
let _waitForSelector_decorators;
|
||||
let _waitForFunction_decorators;
|
||||
let _content_decorators;
|
||||
let _addScriptTag_decorators;
|
||||
let _addStyleTag_decorators;
|
||||
let _click_decorators;
|
||||
let _focus_decorators;
|
||||
let _hover_decorators;
|
||||
let _select_decorators;
|
||||
let _tap_decorators;
|
||||
let _type_decorators;
|
||||
let _title_decorators;
|
||||
return class Frame extends _classSuper {
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
||||
_frameElement_decorators = [throwIfDetached];
|
||||
_evaluateHandle_decorators = [throwIfDetached];
|
||||
_evaluate_decorators = [throwIfDetached];
|
||||
_locator_decorators = [throwIfDetached];
|
||||
_$_decorators = [throwIfDetached];
|
||||
_$$_decorators = [throwIfDetached];
|
||||
_$eval_decorators = [throwIfDetached];
|
||||
_$$eval_decorators = [throwIfDetached];
|
||||
_waitForSelector_decorators = [throwIfDetached];
|
||||
_waitForFunction_decorators = [throwIfDetached];
|
||||
_content_decorators = [throwIfDetached];
|
||||
_addScriptTag_decorators = [throwIfDetached];
|
||||
_addStyleTag_decorators = [throwIfDetached];
|
||||
_click_decorators = [throwIfDetached];
|
||||
_focus_decorators = [throwIfDetached];
|
||||
_hover_decorators = [throwIfDetached];
|
||||
_select_decorators = [throwIfDetached];
|
||||
_tap_decorators = [throwIfDetached];
|
||||
_type_decorators = [throwIfDetached];
|
||||
_title_decorators = [throwIfDetached];
|
||||
__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, _evaluateHandle_decorators, { kind: "method", name: "evaluateHandle", static: false, private: false, access: { has: obj => "evaluateHandle" in obj, get: obj => obj.evaluateHandle }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _evaluate_decorators, { kind: "method", name: "evaluate", static: false, private: false, access: { has: obj => "evaluate" in obj, get: obj => obj.evaluate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _locator_decorators, { kind: "method", name: "locator", static: false, private: false, access: { has: obj => "locator" in obj, get: obj => obj.locator }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _$_decorators, { kind: "method", name: "$", static: false, private: false, access: { has: obj => "$" in obj, get: obj => obj.$ }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _$$_decorators, { kind: "method", name: "$$", static: false, private: false, access: { has: obj => "$$" in obj, get: obj => obj.$$ }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _$eval_decorators, { kind: "method", name: "$eval", static: false, private: false, access: { has: obj => "$eval" in obj, get: obj => obj.$eval }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _$$eval_decorators, { kind: "method", name: "$$eval", static: false, private: false, access: { has: obj => "$$eval" in obj, get: obj => obj.$$eval }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _waitForSelector_decorators, { kind: "method", name: "waitForSelector", static: false, private: false, access: { has: obj => "waitForSelector" in obj, get: obj => obj.waitForSelector }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _waitForFunction_decorators, { kind: "method", name: "waitForFunction", static: false, private: false, access: { has: obj => "waitForFunction" in obj, get: obj => obj.waitForFunction }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _content_decorators, { kind: "method", name: "content", static: false, private: false, access: { has: obj => "content" in obj, get: obj => obj.content }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _addScriptTag_decorators, { kind: "method", name: "addScriptTag", static: false, private: false, access: { has: obj => "addScriptTag" in obj, get: obj => obj.addScriptTag }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _addStyleTag_decorators, { kind: "method", name: "addStyleTag", static: false, private: false, access: { has: obj => "addStyleTag" in obj, get: obj => obj.addStyleTag }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _click_decorators, { kind: "method", name: "click", static: false, private: false, access: { has: obj => "click" in obj, get: obj => obj.click }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _focus_decorators, { kind: "method", name: "focus", static: false, private: false, access: { has: obj => "focus" in obj, get: obj => obj.focus }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _hover_decorators, { kind: "method", name: "hover", static: false, private: false, access: { has: obj => "hover" in obj, get: obj => obj.hover }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _select_decorators, { kind: "method", name: "select", static: false, private: false, access: { has: obj => "select" in obj, get: obj => obj.select }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _tap_decorators, { kind: "method", name: "tap", static: false, private: false, access: { has: obj => "tap" in obj, get: obj => obj.tap }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _type_decorators, { kind: "method", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _title_decorators, { kind: "method", name: "title", static: false, private: false, access: { has: obj => "title" in obj, get: obj => obj.title }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_id = __runInitializers(this, _instanceExtraInitializers);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_parentId;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_name;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_hasStartedLoading = false;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
#_document;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
#document() {
|
||||
if (!this.#_document) {
|
||||
this.#_document = this.mainRealm().evaluateHandle(() => {
|
||||
return document;
|
||||
});
|
||||
}
|
||||
return this.#_document;
|
||||
}
|
||||
/**
|
||||
* Used to clear the document handle that has been destroyed.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
clearDocumentHandle() {
|
||||
this.#_document = undefined;
|
||||
}
|
||||
/**
|
||||
* @returns The frame element associated with this frame (if any).
|
||||
*/
|
||||
async frameElement() {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const parentFrame = this.parentFrame();
|
||||
if (!parentFrame) {
|
||||
return null;
|
||||
}
|
||||
const list = __addDisposableResource(env_1, await parentFrame.isolatedRealm().evaluateHandle(() => {
|
||||
return document.querySelectorAll('iframe,frame');
|
||||
}), false);
|
||||
for await (const iframe_1 of transposeIterableHandle(list)) {
|
||||
const env_2 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const iframe = __addDisposableResource(env_2, iframe_1, false);
|
||||
const frame = await iframe.contentFrame();
|
||||
if (frame?._id === this._id) {
|
||||
return (await parentFrame
|
||||
.mainRealm()
|
||||
.adoptHandle(iframe));
|
||||
}
|
||||
}
|
||||
catch (e_1) {
|
||||
env_2.error = e_1;
|
||||
env_2.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_2);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (e_2) {
|
||||
env_1.error = e_2;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Behaves identically to {@link Page.evaluateHandle} except it's run within
|
||||
* the context of this frame.
|
||||
*
|
||||
* See {@link Page.evaluateHandle} for details.
|
||||
*/
|
||||
async evaluateHandle(pageFunction, ...args) {
|
||||
pageFunction = withSourcePuppeteerURLIfNone(this.evaluateHandle.name, pageFunction);
|
||||
return await this.mainRealm().evaluateHandle(pageFunction, ...args);
|
||||
}
|
||||
/**
|
||||
* Behaves identically to {@link Page.evaluate} except it's run within
|
||||
* the context of this frame.
|
||||
*
|
||||
* See {@link Page.evaluate} for details.
|
||||
*/
|
||||
async evaluate(pageFunction, ...args) {
|
||||
pageFunction = withSourcePuppeteerURLIfNone(this.evaluate.name, pageFunction);
|
||||
return await this.mainRealm().evaluate(pageFunction, ...args);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
locator(input) {
|
||||
if (typeof input === 'string') {
|
||||
return NodeLocator.create(this, input);
|
||||
}
|
||||
else {
|
||||
return FunctionLocator.create(this, input);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Queries the frame for an element matching the given selector.
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
*
|
||||
* @returns A {@link ElementHandle | element handle} to the first element
|
||||
* matching the given selector. Otherwise, `null`.
|
||||
*/
|
||||
async $(selector) {
|
||||
// eslint-disable-next-line @puppeteer/use-using -- This is cached.
|
||||
const document = await this.#document();
|
||||
return await document.$(selector);
|
||||
}
|
||||
/**
|
||||
* Queries the frame for all elements matching the given selector.
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
*
|
||||
* @returns An array of {@link ElementHandle | element handles} that point to
|
||||
* elements matching the given selector.
|
||||
*/
|
||||
async $$(selector, options) {
|
||||
// eslint-disable-next-line @puppeteer/use-using -- This is cached.
|
||||
const document = await this.#document();
|
||||
return await document.$$(selector, options);
|
||||
}
|
||||
/**
|
||||
* Runs the given function on the first element matching the given selector in
|
||||
* the frame.
|
||||
*
|
||||
* If the given function returns a promise, then this method will wait till
|
||||
* the promise resolves.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const searchValue = await frame.$eval('#search', el => el.value);
|
||||
* ```
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @param pageFunction - The function to be evaluated in the frame's context.
|
||||
* The first element matching the selector will be passed to the function as
|
||||
* its first argument.
|
||||
* @param args - Additional arguments to pass to `pageFunction`.
|
||||
* @returns A promise to the result of the function.
|
||||
*/
|
||||
async $eval(selector, pageFunction, ...args) {
|
||||
pageFunction = withSourcePuppeteerURLIfNone(this.$eval.name, pageFunction);
|
||||
// eslint-disable-next-line @puppeteer/use-using -- This is cached.
|
||||
const document = await this.#document();
|
||||
return await document.$eval(selector, pageFunction, ...args);
|
||||
}
|
||||
/**
|
||||
* Runs the given function on an array of elements matching the given selector
|
||||
* in the frame.
|
||||
*
|
||||
* If the given function returns a promise, then this method will wait till
|
||||
* the promise resolves.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const divsCounts = await frame.$$eval('div', divs => divs.length);
|
||||
* ```
|
||||
*
|
||||
* @param selector -
|
||||
* {@link https://pptr.dev/guides/page-interactions#selectors | selector}
|
||||
* to query the page for.
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | CSS selectors}
|
||||
* can be passed as-is and a
|
||||
* {@link https://pptr.dev/guides/page-interactions#non-css-selectors | Puppeteer-specific selector syntax}
|
||||
* allows querying by
|
||||
* {@link https://pptr.dev/guides/page-interactions#text-selectors--p-text | text},
|
||||
* {@link https://pptr.dev/guides/page-interactions#aria-selectors--p-aria | a11y role and name},
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath | xpath}
|
||||
* and
|
||||
* {@link https://pptr.dev/guides/page-interactions#querying-elements-in-shadow-dom | combining these queries across shadow roots}.
|
||||
* Alternatively, you can specify the selector type using a
|
||||
* {@link https://pptr.dev/guides/page-interactions#prefixed-selector-syntax | prefix}.
|
||||
* @param pageFunction - The function to be evaluated in the frame's context.
|
||||
* An array of elements matching the given selector will be passed to the
|
||||
* function as its first argument.
|
||||
* @param args - Additional arguments to pass to `pageFunction`.
|
||||
* @returns A promise to the result of the function.
|
||||
*/
|
||||
async $$eval(selector, pageFunction, ...args) {
|
||||
pageFunction = withSourcePuppeteerURLIfNone(this.$$eval.name, pageFunction);
|
||||
// eslint-disable-next-line @puppeteer/use-using -- This is cached.
|
||||
const document = await this.#document();
|
||||
return await document.$$eval(selector, pageFunction, ...args);
|
||||
}
|
||||
/**
|
||||
* Waits for an element matching the given selector to appear in the frame.
|
||||
*
|
||||
* This method works across navigations.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* let currentURL;
|
||||
* page
|
||||
* .mainFrame()
|
||||
* .waitForSelector('img')
|
||||
* .then(() => console.log('First URL with image: ' + currentURL));
|
||||
*
|
||||
* for (currentURL of [
|
||||
* 'https://example.com',
|
||||
* 'https://google.com',
|
||||
* 'https://bbc.com',
|
||||
* ]) {
|
||||
* await page.goto(currentURL);
|
||||
* }
|
||||
* await browser.close();
|
||||
* ```
|
||||
*
|
||||
* @param selector - The selector to query and wait for.
|
||||
* @param options - Options for customizing waiting behavior.
|
||||
* @returns An element matching the given selector.
|
||||
* @throws Throws if an element matching the given selector doesn't appear.
|
||||
*/
|
||||
async waitForSelector(selector, options = {}) {
|
||||
const { updatedSelector, QueryHandler, polling } = getQueryHandlerAndSelector(selector);
|
||||
return (await QueryHandler.waitFor(this, updatedSelector, {
|
||||
polling,
|
||||
...options,
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* @example
|
||||
* The `waitForFunction` can be used to observe viewport size change:
|
||||
*
|
||||
* ```ts
|
||||
* import puppeteer from 'puppeteer';
|
||||
*
|
||||
* const browser = await puppeteer.launch();
|
||||
* const page = await browser.newPage();
|
||||
* const watchDog = page
|
||||
* .mainFrame()
|
||||
* .waitForFunction('window.innerWidth < 100');
|
||||
* page.setViewport({width: 50, height: 50});
|
||||
* await watchDog;
|
||||
* await browser.close();
|
||||
* ```
|
||||
*
|
||||
* To pass arguments from Node.js to the predicate of `page.waitForFunction` function:
|
||||
*
|
||||
* ```ts
|
||||
* const selector = '.foo';
|
||||
* await frame.waitForFunction(
|
||||
* selector => !!document.querySelector(selector),
|
||||
* {}, // empty options object
|
||||
* selector,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @param pageFunction - the function to evaluate in the frame context.
|
||||
* @param options - options to configure the polling method, timeout and signal.
|
||||
* @param args - arguments to pass to the `pageFunction`.
|
||||
* @returns the promise which resolve when the `pageFunction` returns a truthy value.
|
||||
*/
|
||||
async waitForFunction(pageFunction, options = {}, ...args) {
|
||||
return await this.mainRealm().waitForFunction(pageFunction, options, ...args);
|
||||
}
|
||||
/**
|
||||
* The full HTML contents of the frame, including the DOCTYPE.
|
||||
*/
|
||||
async content() {
|
||||
return await this.evaluate(() => {
|
||||
let content = '';
|
||||
for (const node of document.childNodes) {
|
||||
switch (node) {
|
||||
case document.documentElement:
|
||||
content += document.documentElement.outerHTML;
|
||||
break;
|
||||
default:
|
||||
content += new XMLSerializer().serializeToString(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return content;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async setFrameContent(content) {
|
||||
return await this.evaluate(html => {
|
||||
document.open();
|
||||
document.write(html);
|
||||
document.close();
|
||||
}, content);
|
||||
}
|
||||
/**
|
||||
* The frame's `name` attribute as specified in the tag.
|
||||
*
|
||||
* @remarks
|
||||
* If the name is empty, it returns the `id` attribute instead.
|
||||
*
|
||||
* @remarks
|
||||
* This value is calculated once when the frame is created, and will not
|
||||
* update if the attribute is changed later.
|
||||
*
|
||||
* @deprecated Use
|
||||
*
|
||||
* ```ts
|
||||
* const element = await frame.frameElement();
|
||||
* const nameOrId = await element.evaluate(frame => frame.name ?? frame.id);
|
||||
* ```
|
||||
*/
|
||||
name() {
|
||||
return this._name || '';
|
||||
}
|
||||
/**
|
||||
* Is`true` if the frame has been detached. Otherwise, `false`.
|
||||
*
|
||||
* @deprecated Use the `detached` getter.
|
||||
*/
|
||||
isDetached() {
|
||||
return this.detached;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
get disposed() {
|
||||
return this.detached;
|
||||
}
|
||||
/**
|
||||
* Adds a `<script>` tag into the page with the desired url or content.
|
||||
*
|
||||
* @param options - Options for the script.
|
||||
* @returns An {@link ElementHandle | element handle} to the injected
|
||||
* `<script>` element.
|
||||
*/
|
||||
async addScriptTag(options) {
|
||||
let { content = '', type } = options;
|
||||
const { path } = options;
|
||||
if (+!!options.url + +!!path + +!!content !== 1) {
|
||||
throw new Error('Exactly one of `url`, `path`, or `content` must be specified.');
|
||||
}
|
||||
if (path) {
|
||||
content = await environment.value.fs.promises.readFile(path, 'utf8');
|
||||
content += `//# sourceURL=${path.replace(/\n/g, '')}`;
|
||||
}
|
||||
type = type ?? 'text/javascript';
|
||||
return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, id, type, content }) => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const script = document.createElement('script');
|
||||
script.type = type;
|
||||
script.text = content;
|
||||
script.addEventListener('error', event => {
|
||||
reject(new Error(event.message ?? 'Could not load script'));
|
||||
}, { once: true });
|
||||
if (id) {
|
||||
script.id = id;
|
||||
}
|
||||
if (url) {
|
||||
script.src = url;
|
||||
script.addEventListener('load', () => {
|
||||
resolve(script);
|
||||
}, { once: true });
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
else {
|
||||
document.head.appendChild(script);
|
||||
resolve(script);
|
||||
}
|
||||
});
|
||||
}, { ...options, type, content }));
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async addStyleTag(options) {
|
||||
let { content = '' } = options;
|
||||
const { path } = options;
|
||||
if (+!!options.url + +!!path + +!!content !== 1) {
|
||||
throw new Error('Exactly one of `url`, `path`, or `content` must be specified.');
|
||||
}
|
||||
if (path) {
|
||||
content = await environment.value.fs.promises.readFile(path, 'utf8');
|
||||
content += '/*# sourceURL=' + path.replace(/\n/g, '') + '*/';
|
||||
options.content = content;
|
||||
}
|
||||
return await this.mainRealm().transferHandle(await this.isolatedRealm().evaluateHandle(async ({ url, content }) => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
let element;
|
||||
if (!url) {
|
||||
element = document.createElement('style');
|
||||
element.appendChild(document.createTextNode(content));
|
||||
}
|
||||
else {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = url;
|
||||
element = link;
|
||||
}
|
||||
element.addEventListener('load', () => {
|
||||
resolve(element);
|
||||
}, { once: true });
|
||||
element.addEventListener('error', event => {
|
||||
reject(new Error(event.message ?? 'Could not load style'));
|
||||
}, { once: true });
|
||||
document.head.appendChild(element);
|
||||
return element;
|
||||
});
|
||||
}, options));
|
||||
}
|
||||
/**
|
||||
* Clicks the first element found that matches `selector`.
|
||||
*
|
||||
* @remarks
|
||||
* If `click()` triggers a navigation event and there's a separate
|
||||
* `page.waitForNavigation()` promise to be resolved, you may end up with a
|
||||
* race condition that yields unexpected results. The correct pattern for
|
||||
* click and wait for navigation is the following:
|
||||
*
|
||||
* ```ts
|
||||
* const [response] = await Promise.all([
|
||||
* page.waitForNavigation(waitOptions),
|
||||
* frame.click(selector, clickOptions),
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
*/
|
||||
async click(selector, options = {}) {
|
||||
const env_3 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_3, await this.$(selector), false);
|
||||
assert(handle, `No element found for selector: ${selector}`);
|
||||
await handle.click(options);
|
||||
await handle.dispose();
|
||||
}
|
||||
catch (e_3) {
|
||||
env_3.error = e_3;
|
||||
env_3.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_3);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Focuses the first element that matches the `selector`.
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @throws Throws if there's no element matching `selector`.
|
||||
*/
|
||||
async focus(selector) {
|
||||
const env_4 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_4, await this.$(selector), false);
|
||||
assert(handle, `No element found for selector: ${selector}`);
|
||||
await handle.focus();
|
||||
}
|
||||
catch (e_4) {
|
||||
env_4.error = e_4;
|
||||
env_4.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_4);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Hovers the pointer over the center of the first element that matches the
|
||||
* `selector`.
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @throws Throws if there's no element matching `selector`.
|
||||
*/
|
||||
async hover(selector) {
|
||||
const env_5 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_5, await this.$(selector), false);
|
||||
assert(handle, `No element found for selector: ${selector}`);
|
||||
await handle.hover();
|
||||
}
|
||||
catch (e_5) {
|
||||
env_5.error = e_5;
|
||||
env_5.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_5);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Selects a set of value on the first `<select>` element that matches the
|
||||
* `selector`.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* frame.select('select#colors', 'blue'); // single selection
|
||||
* frame.select('select#colors', 'red', 'green', 'blue'); // multiple selections
|
||||
* ```
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @param values - The array of values to select. If the `<select>` has the
|
||||
* `multiple` attribute, all values are considered, otherwise only the first
|
||||
* one is taken into account.
|
||||
* @returns the list of values that were successfully selected.
|
||||
* @throws Throws if there's no `<select>` matching `selector`.
|
||||
*/
|
||||
async select(selector, ...values) {
|
||||
const env_6 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_6, await this.$(selector), false);
|
||||
assert(handle, `No element found for selector: ${selector}`);
|
||||
return await handle.select(...values);
|
||||
}
|
||||
catch (e_6) {
|
||||
env_6.error = e_6;
|
||||
env_6.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_6);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Taps the first element that matches the `selector`.
|
||||
*
|
||||
* @param selector - The selector to query for.
|
||||
* @throws Throws if there's no element matching `selector`.
|
||||
*/
|
||||
async tap(selector) {
|
||||
const env_7 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_7, await this.$(selector), false);
|
||||
assert(handle, `No element found for selector: ${selector}`);
|
||||
await handle.tap();
|
||||
}
|
||||
catch (e_7) {
|
||||
env_7.error = e_7;
|
||||
env_7.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_7);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character
|
||||
* in the text.
|
||||
*
|
||||
* @remarks
|
||||
* To press a special key, like `Control` or `ArrowDown`, use
|
||||
* {@link Keyboard.press}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* await frame.type('#mytextarea', 'Hello'); // Types instantly
|
||||
* await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
|
||||
* ```
|
||||
*
|
||||
* @param selector - the selector for the element to type into. If there are
|
||||
* multiple the first will be used.
|
||||
* @param text - text to type into the element
|
||||
* @param options - takes one option, `delay`, which sets the time to wait
|
||||
* between key presses in milliseconds. Defaults to `0`.
|
||||
*/
|
||||
async type(selector, text, options) {
|
||||
const env_8 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_8, await this.$(selector), false);
|
||||
assert(handle, `No element found for selector: ${selector}`);
|
||||
await handle.type(text, options);
|
||||
}
|
||||
catch (e_8) {
|
||||
env_8.error = e_8;
|
||||
env_8.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_8);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The frame's title.
|
||||
*/
|
||||
async title() {
|
||||
return await this.isolatedRealm().evaluate(() => {
|
||||
return document.title;
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { Frame };
|
||||
//# sourceMappingURL=Frame.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
429
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.d.ts
generated
vendored
Normal file
429
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.d.ts
generated
vendored
Normal file
@@ -0,0 +1,429 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Protocol } from 'devtools-protocol';
|
||||
import type { ProtocolError } from '../common/Errors.js';
|
||||
import type { CDPSession } from './CDPSession.js';
|
||||
import type { Frame } from './Frame.js';
|
||||
import type { HTTPResponse } from './HTTPResponse.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ContinueRequestOverrides {
|
||||
/**
|
||||
* If set, the request URL will change. This is not a redirect.
|
||||
*/
|
||||
url?: string;
|
||||
method?: string;
|
||||
postData?: string;
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface InterceptResolutionState {
|
||||
action: InterceptResolutionAction;
|
||||
priority?: number;
|
||||
}
|
||||
/**
|
||||
* Required response data to fulfill a request with.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ResponseForRequest {
|
||||
status: number;
|
||||
/**
|
||||
* Optional response headers.
|
||||
*
|
||||
* The record values will be converted to string following:
|
||||
* Arrays' values will be mapped to String
|
||||
* (Used when you need multiple headers with the same name).
|
||||
* Non-arrays will be converted to String.
|
||||
*/
|
||||
headers: Record<string, string | string[] | unknown>;
|
||||
contentType: string;
|
||||
body: string | Uint8Array;
|
||||
}
|
||||
/**
|
||||
* Resource types for HTTPRequests as perceived by the rendering engine.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type ResourceType = Lowercase<Protocol.Network.ResourceType>;
|
||||
/**
|
||||
* The default cooperative request interception resolution priority
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const DEFAULT_INTERCEPT_RESOLUTION_PRIORITY = 0;
|
||||
/**
|
||||
* Represents an HTTP request sent by a page.
|
||||
* @remarks
|
||||
*
|
||||
* Whenever the page sends a request, such as for a network resource, the
|
||||
* following events are emitted by Puppeteer's `page`:
|
||||
*
|
||||
* - `request`: emitted when the request is issued by the page.
|
||||
*
|
||||
* - `requestfinished` - emitted when the response body is downloaded and the
|
||||
* request is complete.
|
||||
*
|
||||
* If request fails at some point, then instead of `requestfinished` event the
|
||||
* `requestfailed` event is emitted.
|
||||
*
|
||||
* All of these events provide an instance of `HTTPRequest` representing the
|
||||
* request that occurred:
|
||||
*
|
||||
* ```
|
||||
* page.on('request', request => ...)
|
||||
* ```
|
||||
*
|
||||
* NOTE: HTTP Error responses, such as 404 or 503, are still successful
|
||||
* responses from HTTP standpoint, so request will complete with
|
||||
* `requestfinished` event.
|
||||
*
|
||||
* If request gets a 'redirect' response, the request is successfully finished
|
||||
* with the `requestfinished` event, and a new request is issued to a
|
||||
* redirected url.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class HTTPRequest {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract get id(): string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_interceptionId: string | undefined;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_failureText: string | null;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_response: HTTPResponse | null;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_fromMemoryCache: boolean;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_redirectChain: HTTPRequest[];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected interception: {
|
||||
enabled: boolean;
|
||||
handled: boolean;
|
||||
handlers: Array<() => void | PromiseLike<any>>;
|
||||
resolutionState: InterceptResolutionState;
|
||||
requestOverrides: ContinueRequestOverrides;
|
||||
response: Partial<ResponseForRequest> | null;
|
||||
abortReason: Protocol.Network.ErrorReason | null;
|
||||
};
|
||||
/**
|
||||
* Warning! Using this client can break Puppeteer. Use with caution.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
abstract get client(): CDPSession;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* The URL of the request
|
||||
*/
|
||||
abstract url(): string;
|
||||
/**
|
||||
* The `ContinueRequestOverrides` that will be used
|
||||
* if the interception is allowed to continue (ie, `abort()` and
|
||||
* `respond()` aren't called).
|
||||
*/
|
||||
continueRequestOverrides(): ContinueRequestOverrides;
|
||||
/**
|
||||
* The `ResponseForRequest` that gets used if the
|
||||
* interception is allowed to respond (ie, `abort()` is not called).
|
||||
*/
|
||||
responseForRequest(): Partial<ResponseForRequest> | null;
|
||||
/**
|
||||
* The most recent reason for aborting the request
|
||||
*/
|
||||
abortErrorReason(): Protocol.Network.ErrorReason | null;
|
||||
/**
|
||||
* An InterceptResolutionState object describing the current resolution
|
||||
* action and priority.
|
||||
*
|
||||
* InterceptResolutionState contains:
|
||||
* action: InterceptResolutionAction
|
||||
* priority?: number
|
||||
*
|
||||
* InterceptResolutionAction is one of: `abort`, `respond`, `continue`,
|
||||
* `disabled`, `none`, or `already-handled`.
|
||||
*/
|
||||
interceptResolutionState(): InterceptResolutionState;
|
||||
/**
|
||||
* Is `true` if the intercept resolution has already been handled,
|
||||
* `false` otherwise.
|
||||
*/
|
||||
isInterceptResolutionHandled(): boolean;
|
||||
/**
|
||||
* Adds an async request handler to the processing queue.
|
||||
* Deferred handlers are not guaranteed to execute in any particular order,
|
||||
* but they are guaranteed to resolve before the request interception
|
||||
* is finalized.
|
||||
*/
|
||||
enqueueInterceptAction(pendingHandler: () => void | PromiseLike<unknown>): void;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract _abort(errorReason: Protocol.Network.ErrorReason | null): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract _respond(response: Partial<ResponseForRequest>): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract _continue(overrides: ContinueRequestOverrides): Promise<void>;
|
||||
/**
|
||||
* Awaits pending interception handlers and then decides how to fulfill
|
||||
* the request interception.
|
||||
*/
|
||||
finalizeInterceptions(): Promise<void>;
|
||||
/**
|
||||
* Contains the request's resource type as it was perceived by the rendering
|
||||
* engine.
|
||||
*/
|
||||
abstract resourceType(): ResourceType;
|
||||
/**
|
||||
* The method used (`GET`, `POST`, etc.)
|
||||
*/
|
||||
abstract method(): string;
|
||||
/**
|
||||
* @deprecated Use {@link HTTPRequest.fetchPostData}.
|
||||
*/
|
||||
abstract postData(): string | undefined;
|
||||
/**
|
||||
* True when the request has POST data. Note that {@link HTTPRequest.postData}
|
||||
* might still be undefined when this flag is true when the data is too long
|
||||
* or not readily available in the decoded form. In that case, use
|
||||
* {@link HTTPRequest.fetchPostData}.
|
||||
*/
|
||||
abstract hasPostData(): boolean;
|
||||
/**
|
||||
* Fetches the POST data for the request from the browser.
|
||||
*/
|
||||
abstract fetchPostData(): Promise<string | undefined>;
|
||||
/**
|
||||
* An object with HTTP headers associated with the request. All
|
||||
* header names are lower-case.
|
||||
*/
|
||||
abstract headers(): Record<string, string>;
|
||||
/**
|
||||
* A matching `HTTPResponse` object, or null if the response has not
|
||||
* been received yet.
|
||||
*/
|
||||
abstract response(): HTTPResponse | null;
|
||||
/**
|
||||
* The frame that initiated the request, or null if navigating to
|
||||
* error pages.
|
||||
*/
|
||||
abstract frame(): Frame | null;
|
||||
/**
|
||||
* True if the request is the driver of the current frame's navigation.
|
||||
*/
|
||||
abstract isNavigationRequest(): boolean;
|
||||
/**
|
||||
* The initiator of the request.
|
||||
*/
|
||||
abstract initiator(): Protocol.Network.Initiator | undefined;
|
||||
/**
|
||||
* A `redirectChain` is a chain of requests initiated to fetch a resource.
|
||||
* @remarks
|
||||
*
|
||||
* `redirectChain` is shared between all the requests of the same chain.
|
||||
*
|
||||
* For example, if the website `http://example.com` has a single redirect to
|
||||
* `https://example.com`, then the chain will contain one request:
|
||||
*
|
||||
* ```ts
|
||||
* const response = await page.goto('http://example.com');
|
||||
* const chain = response.request().redirectChain();
|
||||
* console.log(chain.length); // 1
|
||||
* console.log(chain[0].url()); // 'http://example.com'
|
||||
* ```
|
||||
*
|
||||
* If the website `https://google.com` has no redirects, then the chain will be empty:
|
||||
*
|
||||
* ```ts
|
||||
* const response = await page.goto('https://google.com');
|
||||
* const chain = response.request().redirectChain();
|
||||
* console.log(chain.length); // 0
|
||||
* ```
|
||||
*
|
||||
* @returns the chain of requests - if a server responds with at least a
|
||||
* single redirect, this chain will contain all requests that were redirected.
|
||||
*/
|
||||
abstract redirectChain(): HTTPRequest[];
|
||||
/**
|
||||
* Access information about the request's failure.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* Example of logging all failed requests:
|
||||
*
|
||||
* ```ts
|
||||
* page.on('requestfailed', request => {
|
||||
* console.log(request.url() + ' ' + request.failure().errorText);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @returns `null` unless the request failed. If the request fails this can
|
||||
* return an object with `errorText` containing a human-readable error
|
||||
* message, e.g. `net::ERR_FAILED`. It is not guaranteed that there will be
|
||||
* failure text if the request fails.
|
||||
*/
|
||||
abstract failure(): {
|
||||
errorText: string;
|
||||
} | null;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected verifyInterception(): void;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected abstract canBeIntercepted(): boolean;
|
||||
/**
|
||||
* Continues request with optional request overrides.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* await page.setRequestInterception(true);
|
||||
* page.on('request', request => {
|
||||
* // Override headers
|
||||
* const headers = Object.assign({}, request.headers(), {
|
||||
* foo: 'bar', // set "foo" header
|
||||
* origin: undefined, // remove "origin" header
|
||||
* });
|
||||
* request.continue({headers});
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param overrides - optional overrides to apply to the request.
|
||||
* @param priority - If provided, intercept is resolved using cooperative
|
||||
* handling rules. Otherwise, intercept is resolved immediately.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* To use this, request interception should be enabled with
|
||||
* {@link Page.setRequestInterception}.
|
||||
*
|
||||
* Exception is immediately thrown if the request interception is not enabled.
|
||||
*/
|
||||
continue(overrides?: ContinueRequestOverrides, priority?: number): Promise<void>;
|
||||
/**
|
||||
* Fulfills a request with the given response.
|
||||
*
|
||||
* @example
|
||||
* An example of fulfilling all requests with 404 responses:
|
||||
*
|
||||
* ```ts
|
||||
* await page.setRequestInterception(true);
|
||||
* page.on('request', request => {
|
||||
* request.respond({
|
||||
* status: 404,
|
||||
* contentType: 'text/plain',
|
||||
* body: 'Not Found!',
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* NOTE: Mocking responses for dataURL requests is not supported.
|
||||
* Calling `request.respond` for a dataURL request is a noop.
|
||||
*
|
||||
* @param response - the response to fulfill the request with.
|
||||
* @param priority - If provided, intercept is resolved using
|
||||
* cooperative handling rules. Otherwise, intercept is resolved
|
||||
* immediately.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* To use this, request
|
||||
* interception should be enabled with {@link Page.setRequestInterception}.
|
||||
*
|
||||
* Exception is immediately thrown if the request interception is not enabled.
|
||||
*/
|
||||
respond(response: Partial<ResponseForRequest>, priority?: number): Promise<void>;
|
||||
/**
|
||||
* Aborts a request.
|
||||
*
|
||||
* @param errorCode - optional error code to provide.
|
||||
* @param priority - If provided, intercept is resolved using
|
||||
* cooperative handling rules. Otherwise, intercept is resolved
|
||||
* immediately.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* To use this, request interception should be enabled with
|
||||
* {@link Page.setRequestInterception}. If it is not enabled, this method will
|
||||
* throw an exception immediately.
|
||||
*/
|
||||
abort(errorCode?: ErrorCode, priority?: number): Promise<void>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
static getResponse(body: string | Uint8Array): {
|
||||
contentLength: number;
|
||||
base64: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export declare enum InterceptResolutionAction {
|
||||
Abort = "abort",
|
||||
Respond = "respond",
|
||||
Continue = "continue",
|
||||
Disabled = "disabled",
|
||||
None = "none",
|
||||
AlreadyHandled = "already-handled"
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ErrorCode = 'aborted' | 'accessdenied' | 'addressunreachable' | 'blockedbyclient' | 'blockedbyresponse' | 'connectionaborted' | 'connectionclosed' | 'connectionfailed' | 'connectionrefused' | 'connectionreset' | 'internetdisconnected' | 'namenotresolved' | 'timedout' | 'failed';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ActionResult = 'continue' | 'abort' | 'respond';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare function headersArray(headers: Record<string, string | string[]>): Array<{
|
||||
name: string;
|
||||
value: string;
|
||||
}>;
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @remarks
|
||||
* List taken from {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml}
|
||||
* with extra 306 and 418 codes.
|
||||
*/
|
||||
export declare const STATUS_TEXTS: Record<string, string>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare function handleError(error: ProtocolError): void;
|
||||
//# sourceMappingURL=HTTPRequest.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTTPRequest.d.ts","sourceRoot":"","sources":["../../../../src/api/HTTPRequest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAKvD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AAC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AI,CAAC;IA4BhB;;;;;;;;;;;;;OAaG;IACG,KAAK,CACT,SAAS,GAAE,SAAoB,EAC/B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG;QAC7C,aAAa,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;KAChB;CAWF;AAED;;GAEG;AACH,oBAAY,yBAAyB;IACnC,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,cAAc,oBAAoB;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,cAAc,GACd,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,GACjB,sBAAsB,GACtB,iBAAiB,GACjB,UAAU,GACV,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5D;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,GACzC,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC,CAgBtC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgEtC,CAAC;AAmBX;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAgBtD"}
|
||||
461
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.js
generated
vendored
Normal file
461
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.js
generated
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
import { debugError, isString } from '../common/util.js';
|
||||
import { assert } from '../util/assert.js';
|
||||
import { typedArrayToBase64 } from '../util/encoding.js';
|
||||
/**
|
||||
* The default cooperative request interception resolution priority
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const DEFAULT_INTERCEPT_RESOLUTION_PRIORITY = 0;
|
||||
/**
|
||||
* Represents an HTTP request sent by a page.
|
||||
* @remarks
|
||||
*
|
||||
* Whenever the page sends a request, such as for a network resource, the
|
||||
* following events are emitted by Puppeteer's `page`:
|
||||
*
|
||||
* - `request`: emitted when the request is issued by the page.
|
||||
*
|
||||
* - `requestfinished` - emitted when the response body is downloaded and the
|
||||
* request is complete.
|
||||
*
|
||||
* If request fails at some point, then instead of `requestfinished` event the
|
||||
* `requestfailed` event is emitted.
|
||||
*
|
||||
* All of these events provide an instance of `HTTPRequest` representing the
|
||||
* request that occurred:
|
||||
*
|
||||
* ```
|
||||
* page.on('request', request => ...)
|
||||
* ```
|
||||
*
|
||||
* NOTE: HTTP Error responses, such as 404 or 503, are still successful
|
||||
* responses from HTTP standpoint, so request will complete with
|
||||
* `requestfinished` event.
|
||||
*
|
||||
* If request gets a 'redirect' response, the request is successfully finished
|
||||
* with the `requestfinished` event, and a new request is issued to a
|
||||
* redirected url.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class HTTPRequest {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_interceptionId;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_failureText = null;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_response = null;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_fromMemoryCache = false;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_redirectChain = [];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interception = {
|
||||
enabled: false,
|
||||
handled: false,
|
||||
handlers: [],
|
||||
resolutionState: {
|
||||
action: InterceptResolutionAction.None,
|
||||
},
|
||||
requestOverrides: {},
|
||||
response: null,
|
||||
abortReason: null,
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() { }
|
||||
/**
|
||||
* The `ContinueRequestOverrides` that will be used
|
||||
* if the interception is allowed to continue (ie, `abort()` and
|
||||
* `respond()` aren't called).
|
||||
*/
|
||||
continueRequestOverrides() {
|
||||
return this.interception.requestOverrides;
|
||||
}
|
||||
/**
|
||||
* The `ResponseForRequest` that gets used if the
|
||||
* interception is allowed to respond (ie, `abort()` is not called).
|
||||
*/
|
||||
responseForRequest() {
|
||||
return this.interception.response;
|
||||
}
|
||||
/**
|
||||
* The most recent reason for aborting the request
|
||||
*/
|
||||
abortErrorReason() {
|
||||
return this.interception.abortReason;
|
||||
}
|
||||
/**
|
||||
* An InterceptResolutionState object describing the current resolution
|
||||
* action and priority.
|
||||
*
|
||||
* InterceptResolutionState contains:
|
||||
* action: InterceptResolutionAction
|
||||
* priority?: number
|
||||
*
|
||||
* InterceptResolutionAction is one of: `abort`, `respond`, `continue`,
|
||||
* `disabled`, `none`, or `already-handled`.
|
||||
*/
|
||||
interceptResolutionState() {
|
||||
if (!this.interception.enabled) {
|
||||
return { action: InterceptResolutionAction.Disabled };
|
||||
}
|
||||
if (this.interception.handled) {
|
||||
return { action: InterceptResolutionAction.AlreadyHandled };
|
||||
}
|
||||
return { ...this.interception.resolutionState };
|
||||
}
|
||||
/**
|
||||
* Is `true` if the intercept resolution has already been handled,
|
||||
* `false` otherwise.
|
||||
*/
|
||||
isInterceptResolutionHandled() {
|
||||
return this.interception.handled;
|
||||
}
|
||||
/**
|
||||
* Adds an async request handler to the processing queue.
|
||||
* Deferred handlers are not guaranteed to execute in any particular order,
|
||||
* but they are guaranteed to resolve before the request interception
|
||||
* is finalized.
|
||||
*/
|
||||
enqueueInterceptAction(pendingHandler) {
|
||||
this.interception.handlers.push(pendingHandler);
|
||||
}
|
||||
/**
|
||||
* Awaits pending interception handlers and then decides how to fulfill
|
||||
* the request interception.
|
||||
*/
|
||||
async finalizeInterceptions() {
|
||||
await this.interception.handlers.reduce((promiseChain, interceptAction) => {
|
||||
return promiseChain.then(interceptAction);
|
||||
}, Promise.resolve());
|
||||
this.interception.handlers = [];
|
||||
const { action } = this.interceptResolutionState();
|
||||
switch (action) {
|
||||
case 'abort':
|
||||
return await this._abort(this.interception.abortReason);
|
||||
case 'respond':
|
||||
if (this.interception.response === null) {
|
||||
throw new Error('Response is missing for the interception');
|
||||
}
|
||||
return await this._respond(this.interception.response);
|
||||
case 'continue':
|
||||
return await this._continue(this.interception.requestOverrides);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
verifyInterception() {
|
||||
assert(this.interception.enabled, 'Request Interception is not enabled!');
|
||||
assert(!this.interception.handled, 'Request is already handled!');
|
||||
}
|
||||
/**
|
||||
* Continues request with optional request overrides.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* await page.setRequestInterception(true);
|
||||
* page.on('request', request => {
|
||||
* // Override headers
|
||||
* const headers = Object.assign({}, request.headers(), {
|
||||
* foo: 'bar', // set "foo" header
|
||||
* origin: undefined, // remove "origin" header
|
||||
* });
|
||||
* request.continue({headers});
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param overrides - optional overrides to apply to the request.
|
||||
* @param priority - If provided, intercept is resolved using cooperative
|
||||
* handling rules. Otherwise, intercept is resolved immediately.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* To use this, request interception should be enabled with
|
||||
* {@link Page.setRequestInterception}.
|
||||
*
|
||||
* Exception is immediately thrown if the request interception is not enabled.
|
||||
*/
|
||||
async continue(overrides = {}, priority) {
|
||||
this.verifyInterception();
|
||||
if (!this.canBeIntercepted()) {
|
||||
return;
|
||||
}
|
||||
if (priority === undefined) {
|
||||
return await this._continue(overrides);
|
||||
}
|
||||
this.interception.requestOverrides = overrides;
|
||||
if (this.interception.resolutionState.priority === undefined ||
|
||||
priority > this.interception.resolutionState.priority) {
|
||||
this.interception.resolutionState = {
|
||||
action: InterceptResolutionAction.Continue,
|
||||
priority,
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (priority === this.interception.resolutionState.priority) {
|
||||
if (this.interception.resolutionState.action === 'abort' ||
|
||||
this.interception.resolutionState.action === 'respond') {
|
||||
return;
|
||||
}
|
||||
this.interception.resolutionState.action =
|
||||
InterceptResolutionAction.Continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Fulfills a request with the given response.
|
||||
*
|
||||
* @example
|
||||
* An example of fulfilling all requests with 404 responses:
|
||||
*
|
||||
* ```ts
|
||||
* await page.setRequestInterception(true);
|
||||
* page.on('request', request => {
|
||||
* request.respond({
|
||||
* status: 404,
|
||||
* contentType: 'text/plain',
|
||||
* body: 'Not Found!',
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* NOTE: Mocking responses for dataURL requests is not supported.
|
||||
* Calling `request.respond` for a dataURL request is a noop.
|
||||
*
|
||||
* @param response - the response to fulfill the request with.
|
||||
* @param priority - If provided, intercept is resolved using
|
||||
* cooperative handling rules. Otherwise, intercept is resolved
|
||||
* immediately.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* To use this, request
|
||||
* interception should be enabled with {@link Page.setRequestInterception}.
|
||||
*
|
||||
* Exception is immediately thrown if the request interception is not enabled.
|
||||
*/
|
||||
async respond(response, priority) {
|
||||
this.verifyInterception();
|
||||
if (!this.canBeIntercepted()) {
|
||||
return;
|
||||
}
|
||||
if (priority === undefined) {
|
||||
return await this._respond(response);
|
||||
}
|
||||
this.interception.response = response;
|
||||
if (this.interception.resolutionState.priority === undefined ||
|
||||
priority > this.interception.resolutionState.priority) {
|
||||
this.interception.resolutionState = {
|
||||
action: InterceptResolutionAction.Respond,
|
||||
priority,
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (priority === this.interception.resolutionState.priority) {
|
||||
if (this.interception.resolutionState.action === 'abort') {
|
||||
return;
|
||||
}
|
||||
this.interception.resolutionState.action =
|
||||
InterceptResolutionAction.Respond;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Aborts a request.
|
||||
*
|
||||
* @param errorCode - optional error code to provide.
|
||||
* @param priority - If provided, intercept is resolved using
|
||||
* cooperative handling rules. Otherwise, intercept is resolved
|
||||
* immediately.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* To use this, request interception should be enabled with
|
||||
* {@link Page.setRequestInterception}. If it is not enabled, this method will
|
||||
* throw an exception immediately.
|
||||
*/
|
||||
async abort(errorCode = 'failed', priority) {
|
||||
this.verifyInterception();
|
||||
if (!this.canBeIntercepted()) {
|
||||
return;
|
||||
}
|
||||
const errorReason = errorReasons[errorCode];
|
||||
assert(errorReason, 'Unknown error code: ' + errorCode);
|
||||
if (priority === undefined) {
|
||||
return await this._abort(errorReason);
|
||||
}
|
||||
this.interception.abortReason = errorReason;
|
||||
if (this.interception.resolutionState.priority === undefined ||
|
||||
priority >= this.interception.resolutionState.priority) {
|
||||
this.interception.resolutionState = {
|
||||
action: InterceptResolutionAction.Abort,
|
||||
priority,
|
||||
};
|
||||
return;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
static getResponse(body) {
|
||||
// Needed to get the correct byteLength
|
||||
const byteBody = isString(body)
|
||||
? new TextEncoder().encode(body)
|
||||
: body;
|
||||
return {
|
||||
contentLength: byteBody.byteLength,
|
||||
base64: typedArrayToBase64(byteBody),
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export var InterceptResolutionAction;
|
||||
(function (InterceptResolutionAction) {
|
||||
InterceptResolutionAction["Abort"] = "abort";
|
||||
InterceptResolutionAction["Respond"] = "respond";
|
||||
InterceptResolutionAction["Continue"] = "continue";
|
||||
InterceptResolutionAction["Disabled"] = "disabled";
|
||||
InterceptResolutionAction["None"] = "none";
|
||||
InterceptResolutionAction["AlreadyHandled"] = "already-handled";
|
||||
})(InterceptResolutionAction || (InterceptResolutionAction = {}));
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function headersArray(headers) {
|
||||
const result = [];
|
||||
for (const name in headers) {
|
||||
const value = headers[name];
|
||||
if (!Object.is(value, undefined)) {
|
||||
const values = Array.isArray(value) ? value : [value];
|
||||
result.push(...values.map(value => {
|
||||
return { name, value: value + '' };
|
||||
}));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @remarks
|
||||
* List taken from {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml}
|
||||
* with extra 306 and 418 codes.
|
||||
*/
|
||||
export const STATUS_TEXTS = {
|
||||
'100': 'Continue',
|
||||
'101': 'Switching Protocols',
|
||||
'102': 'Processing',
|
||||
'103': 'Early Hints',
|
||||
'200': 'OK',
|
||||
'201': 'Created',
|
||||
'202': 'Accepted',
|
||||
'203': 'Non-Authoritative Information',
|
||||
'204': 'No Content',
|
||||
'205': 'Reset Content',
|
||||
'206': 'Partial Content',
|
||||
'207': 'Multi-Status',
|
||||
'208': 'Already Reported',
|
||||
'226': 'IM Used',
|
||||
'300': 'Multiple Choices',
|
||||
'301': 'Moved Permanently',
|
||||
'302': 'Found',
|
||||
'303': 'See Other',
|
||||
'304': 'Not Modified',
|
||||
'305': 'Use Proxy',
|
||||
'306': 'Switch Proxy',
|
||||
'307': 'Temporary Redirect',
|
||||
'308': 'Permanent Redirect',
|
||||
'400': 'Bad Request',
|
||||
'401': 'Unauthorized',
|
||||
'402': 'Payment Required',
|
||||
'403': 'Forbidden',
|
||||
'404': 'Not Found',
|
||||
'405': 'Method Not Allowed',
|
||||
'406': 'Not Acceptable',
|
||||
'407': 'Proxy Authentication Required',
|
||||
'408': 'Request Timeout',
|
||||
'409': 'Conflict',
|
||||
'410': 'Gone',
|
||||
'411': 'Length Required',
|
||||
'412': 'Precondition Failed',
|
||||
'413': 'Payload Too Large',
|
||||
'414': 'URI Too Long',
|
||||
'415': 'Unsupported Media Type',
|
||||
'416': 'Range Not Satisfiable',
|
||||
'417': 'Expectation Failed',
|
||||
'418': "I'm a teapot",
|
||||
'421': 'Misdirected Request',
|
||||
'422': 'Unprocessable Entity',
|
||||
'423': 'Locked',
|
||||
'424': 'Failed Dependency',
|
||||
'425': 'Too Early',
|
||||
'426': 'Upgrade Required',
|
||||
'428': 'Precondition Required',
|
||||
'429': 'Too Many Requests',
|
||||
'431': 'Request Header Fields Too Large',
|
||||
'451': 'Unavailable For Legal Reasons',
|
||||
'500': 'Internal Server Error',
|
||||
'501': 'Not Implemented',
|
||||
'502': 'Bad Gateway',
|
||||
'503': 'Service Unavailable',
|
||||
'504': 'Gateway Timeout',
|
||||
'505': 'HTTP Version Not Supported',
|
||||
'506': 'Variant Also Negotiates',
|
||||
'507': 'Insufficient Storage',
|
||||
'508': 'Loop Detected',
|
||||
'510': 'Not Extended',
|
||||
'511': 'Network Authentication Required',
|
||||
};
|
||||
const errorReasons = {
|
||||
aborted: 'Aborted',
|
||||
accessdenied: 'AccessDenied',
|
||||
addressunreachable: 'AddressUnreachable',
|
||||
blockedbyclient: 'BlockedByClient',
|
||||
blockedbyresponse: 'BlockedByResponse',
|
||||
connectionaborted: 'ConnectionAborted',
|
||||
connectionclosed: 'ConnectionClosed',
|
||||
connectionfailed: 'ConnectionFailed',
|
||||
connectionrefused: 'ConnectionRefused',
|
||||
connectionreset: 'ConnectionReset',
|
||||
internetdisconnected: 'InternetDisconnected',
|
||||
namenotresolved: 'NameNotResolved',
|
||||
timedout: 'TimedOut',
|
||||
failed: 'Failed',
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function handleError(error) {
|
||||
// Firefox throws an invalid argument error with a message starting with
|
||||
// 'Expected "header" [...]'.
|
||||
if (error.originalMessage.includes('Invalid header') ||
|
||||
error.originalMessage.includes('Unsafe header') ||
|
||||
error.originalMessage.includes('Expected "header"') ||
|
||||
// WebDriver BiDi error for invalid values, for example, headers.
|
||||
error.originalMessage.includes('invalid argument')) {
|
||||
throw error;
|
||||
}
|
||||
// In certain cases, protocol will return error if the request was
|
||||
// already canceled or the page was closed. We should tolerate these
|
||||
// errors.
|
||||
debugError(error);
|
||||
}
|
||||
//# sourceMappingURL=HTTPRequest.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPRequest.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
116
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.d.ts
generated
vendored
Normal file
116
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type Protocol from 'devtools-protocol';
|
||||
import type { SecurityDetails } from '../common/SecurityDetails.js';
|
||||
import type { Frame } from './Frame.js';
|
||||
import type { HTTPRequest } from './HTTPRequest.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface RemoteAddress {
|
||||
ip?: string;
|
||||
port?: number;
|
||||
}
|
||||
/**
|
||||
* The HTTPResponse class represents responses which are received by the
|
||||
* {@link Page} class.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class HTTPResponse {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* The IP address and port number used to connect to the remote
|
||||
* server.
|
||||
*/
|
||||
abstract remoteAddress(): RemoteAddress;
|
||||
/**
|
||||
* The URL of the response.
|
||||
*/
|
||||
abstract url(): string;
|
||||
/**
|
||||
* True if the response was successful (status in the range 200-299).
|
||||
*/
|
||||
ok(): boolean;
|
||||
/**
|
||||
* The status code of the response (e.g., 200 for a success).
|
||||
*/
|
||||
abstract status(): number;
|
||||
/**
|
||||
* The status text of the response (e.g. usually an "OK" for a
|
||||
* success).
|
||||
*/
|
||||
abstract statusText(): string;
|
||||
/**
|
||||
* An object with HTTP headers associated with the response. All
|
||||
* header names are lower-case.
|
||||
*/
|
||||
abstract headers(): Record<string, string>;
|
||||
/**
|
||||
* {@link SecurityDetails} if the response was received over the
|
||||
* secure connection, or `null` otherwise.
|
||||
*/
|
||||
abstract securityDetails(): SecurityDetails | null;
|
||||
/**
|
||||
* Timing information related to the response.
|
||||
*/
|
||||
abstract timing(): Protocol.Network.ResourceTiming | null;
|
||||
/**
|
||||
* Promise which resolves to a buffer with response body.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* The buffer might be re-encoded by the browser
|
||||
* based on HTTP-headers or other heuristics. If the browser
|
||||
* failed to detect the correct encoding, the buffer might
|
||||
* be encoded incorrectly. See
|
||||
* https://github.com/puppeteer/puppeteer/issues/6478.
|
||||
*/
|
||||
abstract content(): Promise<Uint8Array>;
|
||||
/**
|
||||
* {@inheritDoc HTTPResponse.content}
|
||||
*/
|
||||
buffer(): Promise<Buffer>;
|
||||
/**
|
||||
* Promise which resolves to a text (utf8) representation of response body.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This method will throw if the content is not utf-8 string
|
||||
*/
|
||||
text(): Promise<string>;
|
||||
/**
|
||||
* Promise which resolves to a JSON representation of response body.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This method will throw if the response body is not parsable via
|
||||
* `JSON.parse`.
|
||||
*/
|
||||
json(): Promise<any>;
|
||||
/**
|
||||
* A matching {@link HTTPRequest} object.
|
||||
*/
|
||||
abstract request(): HTTPRequest;
|
||||
/**
|
||||
* True if the response was served from either the browser's disk
|
||||
* cache or memory cache.
|
||||
*/
|
||||
abstract fromCache(): boolean;
|
||||
/**
|
||||
* True if the response was served by a service worker.
|
||||
*/
|
||||
abstract fromServiceWorker(): boolean;
|
||||
/**
|
||||
* A {@link Frame} that initiated this response, or `null` if
|
||||
* navigating to error pages.
|
||||
*/
|
||||
abstract frame(): Frame | null;
|
||||
}
|
||||
//# sourceMappingURL=HTTPResponse.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTTPResponse.d.ts","sourceRoot":"","sources":["../../../../src/api/HTTPResponse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,8BAAsB,YAAY;IAChC;;OAEG;;IAGH;;;OAGG;IACH,QAAQ,CAAC,aAAa,IAAI,aAAa;IAEvC;;OAEG;IACH,QAAQ,CAAC,GAAG,IAAI,MAAM;IAEtB;;OAEG;IACH,EAAE,IAAI,OAAO;IAMb;;OAEG;IACH,QAAQ,CAAC,MAAM,IAAI,MAAM;IAEzB;;;OAGG;IACH,QAAQ,CAAC,UAAU,IAAI,MAAM;IAE7B;;;OAGG;IACH,QAAQ,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAE1C;;;OAGG;IACH,QAAQ,CAAC,eAAe,IAAI,eAAe,GAAG,IAAI;IAElD;;OAEG;IACH,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,cAAc,GAAG,IAAI;IAEzD;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAEvC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAK7B;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAK1B;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,WAAW;IAE/B;;;OAGG;IACH,QAAQ,CAAC,SAAS,IAAI,OAAO;IAE7B;;OAEG;IACH,QAAQ,CAAC,iBAAiB,IAAI,OAAO;IAErC;;;OAGG;IACH,QAAQ,CAAC,KAAK,IAAI,KAAK,GAAG,IAAI;CAC/B"}
|
||||
56
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.js
generated
vendored
Normal file
56
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* The HTTPResponse class represents responses which are received by the
|
||||
* {@link Page} class.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class HTTPResponse {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() { }
|
||||
/**
|
||||
* True if the response was successful (status in the range 200-299).
|
||||
*/
|
||||
ok() {
|
||||
// TODO: document === 0 case?
|
||||
const status = this.status();
|
||||
return status === 0 || (status >= 200 && status <= 299);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc HTTPResponse.content}
|
||||
*/
|
||||
async buffer() {
|
||||
const content = await this.content();
|
||||
return Buffer.from(content);
|
||||
}
|
||||
/**
|
||||
* Promise which resolves to a text (utf8) representation of response body.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This method will throw if the content is not utf-8 string
|
||||
*/
|
||||
async text() {
|
||||
const content = await this.content();
|
||||
return new TextDecoder('utf-8', { fatal: true }).decode(content);
|
||||
}
|
||||
/**
|
||||
* Promise which resolves to a JSON representation of response body.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This method will throw if the response body is not parsable via
|
||||
* `JSON.parse`.
|
||||
*/
|
||||
async json() {
|
||||
const content = await this.text();
|
||||
return JSON.parse(content);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=HTTPResponse.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/HTTPResponse.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTTPResponse.js","sourceRoot":"","sources":["../../../../src/api/HTTPResponse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH;;;;;GAKG;AACH,MAAM,OAAgB,YAAY;IAChC;;OAEG;IACH,gBAAe,CAAC;IAahB;;OAEG;IACH,EAAE;QACA,6BAA6B;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7B,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC,CAAC;IAC1D,CAAC;IA2CD;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IACD;;;;;;OAMG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrC,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;CAuBF"}
|
||||
485
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.d.ts
generated
vendored
Normal file
485
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.d.ts
generated
vendored
Normal file
@@ -0,0 +1,485 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Protocol } from 'devtools-protocol';
|
||||
import type { KeyInput } from '../common/USKeyboardLayout.js';
|
||||
import type { Point } from './ElementHandle.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface KeyDownOptions {
|
||||
/**
|
||||
* @deprecated Do not use. This is automatically handled.
|
||||
*/
|
||||
text?: string;
|
||||
/**
|
||||
* @deprecated Do not use. This is automatically handled.
|
||||
*/
|
||||
commands?: string[];
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface KeyboardTypeOptions {
|
||||
delay?: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type KeyPressOptions = KeyDownOptions & KeyboardTypeOptions;
|
||||
/**
|
||||
* Keyboard provides an api for managing a virtual keyboard.
|
||||
* The high level api is {@link Keyboard."type"},
|
||||
* which takes raw characters and generates proper keydown, keypress/input,
|
||||
* and keyup events on your page.
|
||||
*
|
||||
* @remarks
|
||||
* For finer control, you can use {@link Keyboard.down},
|
||||
* {@link Keyboard.up}, and {@link Keyboard.sendCharacter}
|
||||
* to manually fire events as if they were generated from a real keyboard.
|
||||
*
|
||||
* On macOS, keyboard shortcuts like `⌘ A` -\> Select All do not work.
|
||||
* See {@link https://github.com/puppeteer/puppeteer/issues/1313 | #1313}.
|
||||
*
|
||||
* @example
|
||||
* An example of holding down `Shift` in order to select and delete some text:
|
||||
*
|
||||
* ```ts
|
||||
* await page.keyboard.type('Hello World!');
|
||||
* await page.keyboard.press('ArrowLeft');
|
||||
*
|
||||
* await page.keyboard.down('Shift');
|
||||
* for (let i = 0; i < ' World'.length; i++)
|
||||
* await page.keyboard.press('ArrowLeft');
|
||||
* await page.keyboard.up('Shift');
|
||||
*
|
||||
* await page.keyboard.press('Backspace');
|
||||
* // Result text will end up saying 'Hello!'
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* An example of pressing `A`
|
||||
*
|
||||
* ```ts
|
||||
* await page.keyboard.down('Shift');
|
||||
* await page.keyboard.press('KeyA');
|
||||
* await page.keyboard.up('Shift');
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Keyboard {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Dispatches a `keydown` event.
|
||||
*
|
||||
* @remarks
|
||||
* If `key` is a single character and no modifier keys besides `Shift`
|
||||
* are being held down, a `keypress`/`input` event will also generated.
|
||||
* The `text` option can be specified to force an input event to be generated.
|
||||
* If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`,
|
||||
* subsequent key presses will be sent with that modifier active.
|
||||
* To release the modifier key, use {@link Keyboard.up}.
|
||||
*
|
||||
* After the key is pressed once, subsequent calls to
|
||||
* {@link Keyboard.down} will have
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat | repeat}
|
||||
* set to true. To release the key, use {@link Keyboard.up}.
|
||||
*
|
||||
* Modifier keys DO influence {@link Keyboard.down}.
|
||||
* Holding down `Shift` will type the text in upper case.
|
||||
*
|
||||
* @param key - Name of key to press, such as `ArrowLeft`.
|
||||
* See {@link KeyInput} for a list of all key names.
|
||||
*
|
||||
* @param options - An object of options. Accepts text which, if specified,
|
||||
* generates an input event with this text. Accepts commands which, if specified,
|
||||
* is the commands of keyboard shortcuts,
|
||||
* see {@link https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h | Chromium Source Code} for valid command names.
|
||||
*/
|
||||
abstract down(key: KeyInput, options?: Readonly<KeyDownOptions>): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `keyup` event.
|
||||
*
|
||||
* @param key - Name of key to release, such as `ArrowLeft`.
|
||||
* See {@link KeyInput | KeyInput}
|
||||
* for a list of all key names.
|
||||
*/
|
||||
abstract up(key: KeyInput): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `keypress` and `input` event.
|
||||
* This does not send a `keydown` or `keyup` event.
|
||||
*
|
||||
* @remarks
|
||||
* Modifier keys DO NOT effect {@link Keyboard.sendCharacter | Keyboard.sendCharacter}.
|
||||
* Holding down `Shift` will not type the text in upper case.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* page.keyboard.sendCharacter('嗨');
|
||||
* ```
|
||||
*
|
||||
* @param char - Character to send into the page.
|
||||
*/
|
||||
abstract sendCharacter(char: string): Promise<void>;
|
||||
/**
|
||||
* Sends a `keydown`, `keypress`/`input`,
|
||||
* and `keyup` event for each character in the text.
|
||||
*
|
||||
* @remarks
|
||||
* To press a special key, like `Control` or `ArrowDown`,
|
||||
* use {@link Keyboard.press}.
|
||||
*
|
||||
* Modifier keys DO NOT effect `keyboard.type`.
|
||||
* Holding down `Shift` will not type the text in upper case.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* await page.keyboard.type('Hello'); // Types instantly
|
||||
* await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
|
||||
* ```
|
||||
*
|
||||
* @param text - A text to type into a focused element.
|
||||
* @param options - An object of options. Accepts delay which,
|
||||
* if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
|
||||
* Defaults to 0.
|
||||
*/
|
||||
abstract type(text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>;
|
||||
/**
|
||||
* Shortcut for {@link Keyboard.down}
|
||||
* and {@link Keyboard.up}.
|
||||
*
|
||||
* @remarks
|
||||
* If `key` is a single character and no modifier keys besides `Shift`
|
||||
* are being held down, a `keypress`/`input` event will also generated.
|
||||
* The `text` option can be specified to force an input event to be generated.
|
||||
*
|
||||
* Modifier keys DO effect {@link Keyboard.press}.
|
||||
* Holding down `Shift` will type the text in upper case.
|
||||
*
|
||||
* @param key - Name of key to press, such as `ArrowLeft`.
|
||||
* See {@link KeyInput} for a list of all key names.
|
||||
*
|
||||
* @param options - An object of options. Accepts text which, if specified,
|
||||
* generates an input event with this text. Accepts delay which,
|
||||
* if specified, is the time to wait between `keydown` and `keyup` in milliseconds.
|
||||
* Defaults to 0. Accepts commands which, if specified,
|
||||
* is the commands of keyboard shortcuts,
|
||||
* see {@link https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h | Chromium Source Code} for valid command names.
|
||||
*/
|
||||
abstract press(key: KeyInput, options?: Readonly<KeyPressOptions>): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface MouseOptions {
|
||||
/**
|
||||
* Determines which button will be pressed.
|
||||
*
|
||||
* @defaultValue `'left'`
|
||||
*/
|
||||
button?: MouseButton;
|
||||
/**
|
||||
* Determines the click count for the mouse event. This does not perform
|
||||
* multiple clicks.
|
||||
*
|
||||
* @deprecated Use {@link MouseClickOptions.count}.
|
||||
* @defaultValue `1`
|
||||
*/
|
||||
clickCount?: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface MouseClickOptions extends MouseOptions {
|
||||
/**
|
||||
* Time (in ms) to delay the mouse release after the mouse press.
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
* Number of clicks to perform.
|
||||
*
|
||||
* @defaultValue `1`
|
||||
*/
|
||||
count?: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface MouseWheelOptions {
|
||||
deltaX?: number;
|
||||
deltaY?: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface MouseMoveOptions {
|
||||
/**
|
||||
* Determines the number of movements to make from the current mouse position
|
||||
* to the new one.
|
||||
*
|
||||
* @defaultValue `1`
|
||||
*/
|
||||
steps?: number;
|
||||
}
|
||||
/**
|
||||
* Enum of valid mouse buttons.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare const MouseButton: Readonly<{
|
||||
Left: "left";
|
||||
Right: "right";
|
||||
Middle: "middle";
|
||||
Back: "back";
|
||||
Forward: "forward";
|
||||
}>;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type MouseButton = (typeof MouseButton)[keyof typeof MouseButton];
|
||||
/**
|
||||
* The Mouse class operates in main-frame CSS pixels
|
||||
* relative to the top-left corner of the viewport.
|
||||
*
|
||||
* @remarks
|
||||
* Every `page` object has its own Mouse, accessible with {@link Page.mouse}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Using ‘page.mouse’ to trace a 100x100 square.
|
||||
* await page.mouse.move(0, 0);
|
||||
* await page.mouse.down();
|
||||
* await page.mouse.move(0, 100);
|
||||
* await page.mouse.move(100, 100);
|
||||
* await page.mouse.move(100, 0);
|
||||
* await page.mouse.move(0, 0);
|
||||
* await page.mouse.up();
|
||||
* ```
|
||||
*
|
||||
* **Note**: The mouse events trigger synthetic `MouseEvent`s.
|
||||
* This means that it does not fully replicate the functionality of what a normal user
|
||||
* would be able to do with their mouse.
|
||||
*
|
||||
* For example, dragging and selecting text is not possible using `page.mouse`.
|
||||
* Instead, you can use the {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/getSelection | `DocumentOrShadowRoot.getSelection()`} functionality implemented in the platform.
|
||||
*
|
||||
* @example
|
||||
* For example, if you want to select all content between nodes:
|
||||
*
|
||||
* ```ts
|
||||
* await page.evaluate(
|
||||
* (from, to) => {
|
||||
* const selection = from.getRootNode().getSelection();
|
||||
* const range = document.createRange();
|
||||
* range.setStartBefore(from);
|
||||
* range.setEndAfter(to);
|
||||
* selection.removeAllRanges();
|
||||
* selection.addRange(range);
|
||||
* },
|
||||
* fromJSHandle,
|
||||
* toJSHandle,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* If you then would want to copy-paste your selection, you can use the clipboard api:
|
||||
*
|
||||
* ```ts
|
||||
* // The clipboard api does not allow you to copy, unless the tab is focused.
|
||||
* await page.bringToFront();
|
||||
* await page.evaluate(() => {
|
||||
* // Copy the selected content to the clipboard
|
||||
* document.execCommand('copy');
|
||||
* // Obtain the content of the clipboard as a string
|
||||
* return navigator.clipboard.readText();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* **Note**: If you want access to the clipboard API,
|
||||
* you have to give it permission to do so:
|
||||
*
|
||||
* ```ts
|
||||
* await browser
|
||||
* .defaultBrowserContext()
|
||||
* .overridePermissions('<your origin>', [
|
||||
* 'clipboard-read',
|
||||
* 'clipboard-write',
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Mouse {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Resets the mouse to the default state: No buttons pressed; position at
|
||||
* (0,0).
|
||||
*/
|
||||
abstract reset(): Promise<void>;
|
||||
/**
|
||||
* Moves the mouse to the given coordinate.
|
||||
*
|
||||
* @param x - Horizontal position of the mouse.
|
||||
* @param y - Vertical position of the mouse.
|
||||
* @param options - Options to configure behavior.
|
||||
*/
|
||||
abstract move(x: number, y: number, options?: Readonly<MouseMoveOptions>): Promise<void>;
|
||||
/**
|
||||
* Presses the mouse.
|
||||
*
|
||||
* @param options - Options to configure behavior.
|
||||
*/
|
||||
abstract down(options?: Readonly<MouseOptions>): Promise<void>;
|
||||
/**
|
||||
* Releases the mouse.
|
||||
*
|
||||
* @param options - Options to configure behavior.
|
||||
*/
|
||||
abstract up(options?: Readonly<MouseOptions>): Promise<void>;
|
||||
/**
|
||||
* Shortcut for `mouse.move`, `mouse.down` and `mouse.up`.
|
||||
*
|
||||
* @param x - Horizontal position of the mouse.
|
||||
* @param y - Vertical position of the mouse.
|
||||
* @param options - Options to configure behavior.
|
||||
*/
|
||||
abstract click(x: number, y: number, options?: Readonly<MouseClickOptions>): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `mousewheel` event.
|
||||
* @param options - Optional: `MouseWheelOptions`.
|
||||
*
|
||||
* @example
|
||||
* An example of zooming into an element:
|
||||
*
|
||||
* ```ts
|
||||
* await page.goto(
|
||||
* 'https://mdn.mozillademos.org/en-US/docs/Web/API/Element/wheel_event$samples/Scaling_an_element_via_the_wheel?revision=1587366',
|
||||
* );
|
||||
*
|
||||
* const elem = await page.$('div');
|
||||
* const boundingBox = await elem.boundingBox();
|
||||
* await page.mouse.move(
|
||||
* boundingBox.x + boundingBox.width / 2,
|
||||
* boundingBox.y + boundingBox.height / 2,
|
||||
* );
|
||||
*
|
||||
* await page.mouse.wheel({deltaY: -100});
|
||||
* ```
|
||||
*/
|
||||
abstract wheel(options?: Readonly<MouseWheelOptions>): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `drag` event.
|
||||
* @param start - starting point for drag
|
||||
* @param target - point to drag to
|
||||
*/
|
||||
abstract drag(start: Point, target: Point): Promise<Protocol.Input.DragData>;
|
||||
/**
|
||||
* Dispatches a `dragenter` event.
|
||||
* @param target - point for emitting `dragenter` event
|
||||
* @param data - drag data containing items and operations mask
|
||||
*/
|
||||
abstract dragEnter(target: Point, data: Protocol.Input.DragData): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `dragover` event.
|
||||
* @param target - point for emitting `dragover` event
|
||||
* @param data - drag data containing items and operations mask
|
||||
*/
|
||||
abstract dragOver(target: Point, data: Protocol.Input.DragData): Promise<void>;
|
||||
/**
|
||||
* Performs a dragenter, dragover, and drop in sequence.
|
||||
* @param target - point to drop on
|
||||
* @param data - drag data containing items and operations mask
|
||||
*/
|
||||
abstract drop(target: Point, data: Protocol.Input.DragData): Promise<void>;
|
||||
/**
|
||||
* Performs a drag, dragenter, dragover, and drop in sequence.
|
||||
* @param start - point to drag from
|
||||
* @param target - point to drop on
|
||||
* @param options - An object of options. Accepts delay which,
|
||||
* if specified, is the time to wait between `dragover` and `drop` in milliseconds.
|
||||
* Defaults to 0.
|
||||
*/
|
||||
abstract dragAndDrop(start: Point, target: Point, options?: {
|
||||
delay?: number;
|
||||
}): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* The TouchHandle interface exposes methods to manipulate touches that have been started
|
||||
* @public
|
||||
*/
|
||||
export interface TouchHandle {
|
||||
/**
|
||||
* Dispatches a `touchMove` event for this touch.
|
||||
* @param x - Horizontal position of the move.
|
||||
* @param y - Vertical position of the move.
|
||||
*/
|
||||
move(x: number, y: number): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `touchend` event for this touch.
|
||||
*/
|
||||
end(): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* The Touchscreen class exposes touchscreen events.
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Touchscreen {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
idGenerator: import("../index.js").GetIdFn;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
touches: TouchHandle[];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
removeHandle(handle: TouchHandle): void;
|
||||
/**
|
||||
* Dispatches a `touchstart` and `touchend` event.
|
||||
* @param x - Horizontal position of the tap.
|
||||
* @param y - Vertical position of the tap.
|
||||
*/
|
||||
tap(x: number, y: number): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `touchstart` event.
|
||||
* @param x - Horizontal position of the tap.
|
||||
* @param y - Vertical position of the tap.
|
||||
* @returns A handle for the touch that was started.
|
||||
*/
|
||||
abstract touchStart(x: number, y: number): Promise<TouchHandle>;
|
||||
/**
|
||||
* Dispatches a `touchMove` event on the first touch that is active.
|
||||
* @param x - Horizontal position of the move.
|
||||
* @param y - Vertical position of the move.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Not every `touchMove` call results in a `touchmove` event being emitted,
|
||||
* depending on the browser's optimizations. For example, Chrome
|
||||
* {@link https://developer.chrome.com/blog/a-more-compatible-smoother-touch/#chromes-new-model-the-throttled-async-touchmove-model | throttles}
|
||||
* touch move events.
|
||||
*/
|
||||
touchMove(x: number, y: number): Promise<void>;
|
||||
/**
|
||||
* Dispatches a `touchend` event on the first touch that is active.
|
||||
*/
|
||||
touchEnd(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=Input.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../../src/api/Input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAC;AAG5D,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,mBAAmB,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,8BAAsB,QAAQ;IAC5B;;OAEG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,QAAQ,CAAC,IAAI,CACX,GAAG,EAAE,QAAQ,EACb,OAAO,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;IAEh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AAO,CAAC,IAAI,CAAC;CAOhC"}
|
||||
211
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.js
generated
vendored
Normal file
211
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { TouchError } from '../common/Errors.js';
|
||||
import { createIncrementalIdGenerator } from '../util/incremental-id-generator.js';
|
||||
/**
|
||||
* Keyboard provides an api for managing a virtual keyboard.
|
||||
* The high level api is {@link Keyboard."type"},
|
||||
* which takes raw characters and generates proper keydown, keypress/input,
|
||||
* and keyup events on your page.
|
||||
*
|
||||
* @remarks
|
||||
* For finer control, you can use {@link Keyboard.down},
|
||||
* {@link Keyboard.up}, and {@link Keyboard.sendCharacter}
|
||||
* to manually fire events as if they were generated from a real keyboard.
|
||||
*
|
||||
* On macOS, keyboard shortcuts like `⌘ A` -\> Select All do not work.
|
||||
* See {@link https://github.com/puppeteer/puppeteer/issues/1313 | #1313}.
|
||||
*
|
||||
* @example
|
||||
* An example of holding down `Shift` in order to select and delete some text:
|
||||
*
|
||||
* ```ts
|
||||
* await page.keyboard.type('Hello World!');
|
||||
* await page.keyboard.press('ArrowLeft');
|
||||
*
|
||||
* await page.keyboard.down('Shift');
|
||||
* for (let i = 0; i < ' World'.length; i++)
|
||||
* await page.keyboard.press('ArrowLeft');
|
||||
* await page.keyboard.up('Shift');
|
||||
*
|
||||
* await page.keyboard.press('Backspace');
|
||||
* // Result text will end up saying 'Hello!'
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* An example of pressing `A`
|
||||
*
|
||||
* ```ts
|
||||
* await page.keyboard.down('Shift');
|
||||
* await page.keyboard.press('KeyA');
|
||||
* await page.keyboard.up('Shift');
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class Keyboard {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() { }
|
||||
}
|
||||
/**
|
||||
* Enum of valid mouse buttons.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const MouseButton = Object.freeze({
|
||||
Left: 'left',
|
||||
Right: 'right',
|
||||
Middle: 'middle',
|
||||
Back: 'back',
|
||||
Forward: 'forward',
|
||||
});
|
||||
/**
|
||||
* The Mouse class operates in main-frame CSS pixels
|
||||
* relative to the top-left corner of the viewport.
|
||||
*
|
||||
* @remarks
|
||||
* Every `page` object has its own Mouse, accessible with {@link Page.mouse}.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Using ‘page.mouse’ to trace a 100x100 square.
|
||||
* await page.mouse.move(0, 0);
|
||||
* await page.mouse.down();
|
||||
* await page.mouse.move(0, 100);
|
||||
* await page.mouse.move(100, 100);
|
||||
* await page.mouse.move(100, 0);
|
||||
* await page.mouse.move(0, 0);
|
||||
* await page.mouse.up();
|
||||
* ```
|
||||
*
|
||||
* **Note**: The mouse events trigger synthetic `MouseEvent`s.
|
||||
* This means that it does not fully replicate the functionality of what a normal user
|
||||
* would be able to do with their mouse.
|
||||
*
|
||||
* For example, dragging and selecting text is not possible using `page.mouse`.
|
||||
* Instead, you can use the {@link https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/getSelection | `DocumentOrShadowRoot.getSelection()`} functionality implemented in the platform.
|
||||
*
|
||||
* @example
|
||||
* For example, if you want to select all content between nodes:
|
||||
*
|
||||
* ```ts
|
||||
* await page.evaluate(
|
||||
* (from, to) => {
|
||||
* const selection = from.getRootNode().getSelection();
|
||||
* const range = document.createRange();
|
||||
* range.setStartBefore(from);
|
||||
* range.setEndAfter(to);
|
||||
* selection.removeAllRanges();
|
||||
* selection.addRange(range);
|
||||
* },
|
||||
* fromJSHandle,
|
||||
* toJSHandle,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* If you then would want to copy-paste your selection, you can use the clipboard api:
|
||||
*
|
||||
* ```ts
|
||||
* // The clipboard api does not allow you to copy, unless the tab is focused.
|
||||
* await page.bringToFront();
|
||||
* await page.evaluate(() => {
|
||||
* // Copy the selected content to the clipboard
|
||||
* document.execCommand('copy');
|
||||
* // Obtain the content of the clipboard as a string
|
||||
* return navigator.clipboard.readText();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* **Note**: If you want access to the clipboard API,
|
||||
* you have to give it permission to do so:
|
||||
*
|
||||
* ```ts
|
||||
* await browser
|
||||
* .defaultBrowserContext()
|
||||
* .overridePermissions('<your origin>', [
|
||||
* 'clipboard-read',
|
||||
* 'clipboard-write',
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class Mouse {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() { }
|
||||
}
|
||||
/**
|
||||
* The Touchscreen class exposes touchscreen events.
|
||||
* @public
|
||||
*/
|
||||
export class Touchscreen {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
idGenerator = createIncrementalIdGenerator();
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
touches = [];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() { }
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
removeHandle(handle) {
|
||||
const index = this.touches.indexOf(handle);
|
||||
if (index === -1) {
|
||||
return;
|
||||
}
|
||||
this.touches.splice(index, 1);
|
||||
}
|
||||
/**
|
||||
* Dispatches a `touchstart` and `touchend` event.
|
||||
* @param x - Horizontal position of the tap.
|
||||
* @param y - Vertical position of the tap.
|
||||
*/
|
||||
async tap(x, y) {
|
||||
const touch = await this.touchStart(x, y);
|
||||
await touch.end();
|
||||
}
|
||||
/**
|
||||
* Dispatches a `touchMove` event on the first touch that is active.
|
||||
* @param x - Horizontal position of the move.
|
||||
* @param y - Vertical position of the move.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Not every `touchMove` call results in a `touchmove` event being emitted,
|
||||
* depending on the browser's optimizations. For example, Chrome
|
||||
* {@link https://developer.chrome.com/blog/a-more-compatible-smoother-touch/#chromes-new-model-the-throttled-async-touchmove-model | throttles}
|
||||
* touch move events.
|
||||
*/
|
||||
async touchMove(x, y) {
|
||||
const touch = this.touches[0];
|
||||
if (!touch) {
|
||||
throw new TouchError('Must start a new Touch first');
|
||||
}
|
||||
return await touch.move(x, y);
|
||||
}
|
||||
/**
|
||||
* Dispatches a `touchend` event on the first touch that is active.
|
||||
*/
|
||||
async touchEnd() {
|
||||
const touch = this.touches.shift();
|
||||
if (!touch) {
|
||||
throw new TouchError('Must start a new Touch first');
|
||||
}
|
||||
await touch.end();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Input.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Input.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/api/Input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAC,4BAA4B,EAAC,MAAM,qCAAqC,CAAC;AA8BjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,OAAgB,QAAQ;IAC5B;;OAEG;IACH,gBAAe,CAAC;CAmHjB;AA2DD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACnB,CAAsD,CAAC;AAOxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,MAAM,OAAgB,KAAK;IACzB;;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AC;IACpB,CAAC;CACF"}
|
||||
123
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.d.ts
generated
vendored
Normal file
123
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type Protocol from 'devtools-protocol';
|
||||
import type { EvaluateFuncWith, HandleFor, HandleOr } from '../common/types.js';
|
||||
import { disposeSymbol, asyncDisposeSymbol } from '../util/disposable.js';
|
||||
import type { ElementHandle } from './ElementHandle.js';
|
||||
import type { Realm } from './Realm.js';
|
||||
/**
|
||||
* Represents a reference to a JavaScript object. Instances can be created using
|
||||
* {@link Page.evaluateHandle}.
|
||||
*
|
||||
* Handles prevent the referenced JavaScript object from being garbage-collected
|
||||
* unless the handle is purposely {@link JSHandle.dispose | disposed}. JSHandles
|
||||
* are auto-disposed when their associated frame is navigated away or the parent
|
||||
* context gets destroyed.
|
||||
*
|
||||
* Handles can be used as arguments for any evaluation function such as
|
||||
* {@link Page.$eval}, {@link Page.evaluate}, and {@link Page.evaluateHandle}.
|
||||
* They are resolved to their referenced object.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const windowHandle = await page.evaluateHandle(() => window);
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class JSHandle<T = unknown> {
|
||||
move: () => this;
|
||||
/**
|
||||
* Used for nominally typing {@link JSHandle}.
|
||||
*/
|
||||
_?: T;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract get realm(): Realm;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract get disposed(): boolean;
|
||||
/**
|
||||
* Evaluates the given function with the current handle as its first argument.
|
||||
*/
|
||||
evaluate<Params extends unknown[], Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* Evaluates the given function with the current handle as its first argument.
|
||||
*
|
||||
*/
|
||||
evaluateHandle<Params extends unknown[], Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
/**
|
||||
* Fetches a single property from the referenced object.
|
||||
*/
|
||||
getProperty<K extends keyof T>(propertyName: HandleOr<K>): Promise<HandleFor<T[K]>>;
|
||||
getProperty(propertyName: string): Promise<JSHandle<unknown>>;
|
||||
/**
|
||||
* Gets a map of handles representing the properties of the current handle.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const listHandle = await page.evaluateHandle(() => document.body.children);
|
||||
* const properties = await listHandle.getProperties();
|
||||
* const children = [];
|
||||
* for (const property of properties.values()) {
|
||||
* const element = property.asElement();
|
||||
* if (element) {
|
||||
* children.push(element);
|
||||
* }
|
||||
* }
|
||||
* children; // holds elementHandles to all children of document.body
|
||||
* ```
|
||||
*/
|
||||
getProperties(): Promise<Map<string, JSHandle>>;
|
||||
/**
|
||||
* A vanilla object representing the serializable portions of the
|
||||
* referenced object.
|
||||
* @throws Throws if the object cannot be serialized due to circularity.
|
||||
*
|
||||
* @remarks
|
||||
* If the object has a `toJSON` function, it **will not** be called.
|
||||
*/
|
||||
abstract jsonValue(): Promise<T>;
|
||||
/**
|
||||
* Either `null` or the handle itself if the handle is an
|
||||
* instance of {@link ElementHandle}.
|
||||
*/
|
||||
abstract asElement(): ElementHandle<Node> | null;
|
||||
/**
|
||||
* Releases the object referenced by the handle for garbage collection.
|
||||
*/
|
||||
abstract dispose(): Promise<void>;
|
||||
/**
|
||||
* Returns a string representation of the JSHandle.
|
||||
*
|
||||
* @remarks
|
||||
* Useful during debugging.
|
||||
*/
|
||||
abstract toString(): string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract get id(): string | undefined;
|
||||
/**
|
||||
* Provides access to the
|
||||
* {@link https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#type-RemoteObject | Protocol.Runtime.RemoteObject}
|
||||
* backing this handle.
|
||||
*/
|
||||
abstract remoteObject(): Protocol.Runtime.RemoteObject;
|
||||
/** @internal */
|
||||
[disposeSymbol](): void;
|
||||
/** @internal */
|
||||
[asyncDisposeSymbol](): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=JSHandle.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"JSHandle.d.ts","sourceRoot":"","sources":["../../../../src/api/JSHandle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,EAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAG9E,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAExE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8BACsB,QAAQ,CAAC,CAAC,GAAG,OAAO;IAChC,IAAI,EAAE,MAAM,IAAI,CAAC;IAEzB;;OAEG;IACK,CAAC,CAAC,EAAE,CAAC,CAAC;IAEd;;OAEG;;IAGH;;OAEG;IACH,QAAQ,KAAK,KAAK,IAAI,KAAK,CAAC;IAE5B;;OAEG;IACH,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC;IAEjC;;OAEG;IACG,QAAQ,CACZ,MAAM,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AK,EAAE,IAAI,MAAM,GAAG,SAAS,CAAC;IAEtC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,OAAO,CAAC,YAAY;IAEtD,gBAAgB;IAChB,CAAC,aAAa,CAAC,IAAI,IAAI;IAIvB,gBAAgB;IAChB,CAAC,kBAAkB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
|
||||
227
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.js
generated
vendored
Normal file
227
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.js
generated
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* @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 { debugError, withSourcePuppeteerURLIfNone } from '../common/util.js';
|
||||
import { moveable, throwIfDisposed } from '../util/decorators.js';
|
||||
import { disposeSymbol, asyncDisposeSymbol } from '../util/disposable.js';
|
||||
/**
|
||||
* Represents a reference to a JavaScript object. Instances can be created using
|
||||
* {@link Page.evaluateHandle}.
|
||||
*
|
||||
* Handles prevent the referenced JavaScript object from being garbage-collected
|
||||
* unless the handle is purposely {@link JSHandle.dispose | disposed}. JSHandles
|
||||
* are auto-disposed when their associated frame is navigated away or the parent
|
||||
* context gets destroyed.
|
||||
*
|
||||
* Handles can be used as arguments for any evaluation function such as
|
||||
* {@link Page.$eval}, {@link Page.evaluate}, and {@link Page.evaluateHandle}.
|
||||
* They are resolved to their referenced object.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const windowHandle = await page.evaluateHandle(() => window);
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
let JSHandle = (() => {
|
||||
let _classDecorators = [moveable];
|
||||
let _classDescriptor;
|
||||
let _classExtraInitializers = [];
|
||||
let _classThis;
|
||||
let _instanceExtraInitializers = [];
|
||||
let _getProperty_decorators;
|
||||
let _getProperties_decorators;
|
||||
var JSHandle = class {
|
||||
static { _classThis = this; }
|
||||
static {
|
||||
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
||||
__esDecorate(this, null, _getProperty_decorators, { kind: "method", name: "getProperty", static: false, private: false, access: { has: obj => "getProperty" in obj, get: obj => obj.getProperty }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(this, null, _getProperties_decorators, { kind: "method", name: "getProperties", static: false, private: false, access: { has: obj => "getProperties" in obj, get: obj => obj.getProperties }, metadata: _metadata }, null, _instanceExtraInitializers);
|
||||
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
||||
JSHandle = _classThis = _classDescriptor.value;
|
||||
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
||||
__runInitializers(_classThis, _classExtraInitializers);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() {
|
||||
__runInitializers(this, _instanceExtraInitializers);
|
||||
}
|
||||
/**
|
||||
* Evaluates the given function with the current handle as its first argument.
|
||||
*/
|
||||
async evaluate(pageFunction, ...args) {
|
||||
pageFunction = withSourcePuppeteerURLIfNone(this.evaluate.name, pageFunction);
|
||||
return await this.realm.evaluate(pageFunction, this, ...args);
|
||||
}
|
||||
/**
|
||||
* Evaluates the given function with the current handle as its first argument.
|
||||
*
|
||||
*/
|
||||
async evaluateHandle(pageFunction, ...args) {
|
||||
pageFunction = withSourcePuppeteerURLIfNone(this.evaluateHandle.name, pageFunction);
|
||||
return await this.realm.evaluateHandle(pageFunction, this, ...args);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async getProperty(propertyName) {
|
||||
return await this.evaluateHandle((object, propertyName) => {
|
||||
return object[propertyName];
|
||||
}, propertyName);
|
||||
}
|
||||
/**
|
||||
* Gets a map of handles representing the properties of the current handle.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* const listHandle = await page.evaluateHandle(() => document.body.children);
|
||||
* const properties = await listHandle.getProperties();
|
||||
* const children = [];
|
||||
* for (const property of properties.values()) {
|
||||
* const element = property.asElement();
|
||||
* if (element) {
|
||||
* children.push(element);
|
||||
* }
|
||||
* }
|
||||
* children; // holds elementHandles to all children of document.body
|
||||
* ```
|
||||
*/
|
||||
async getProperties() {
|
||||
const propertyNames = await this.evaluate(object => {
|
||||
const enumerableProperties = [];
|
||||
const descriptors = Object.getOwnPropertyDescriptors(object);
|
||||
for (const propertyName in descriptors) {
|
||||
if (descriptors[propertyName]?.enumerable) {
|
||||
enumerableProperties.push(propertyName);
|
||||
}
|
||||
}
|
||||
return enumerableProperties;
|
||||
});
|
||||
const map = new Map();
|
||||
const results = await Promise.all(propertyNames.map(key => {
|
||||
return this.getProperty(key);
|
||||
}));
|
||||
for (const [key, value] of Object.entries(propertyNames)) {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_1, results[key], false);
|
||||
if (handle) {
|
||||
map.set(value, handle.move());
|
||||
}
|
||||
}
|
||||
catch (e_1) {
|
||||
env_1.error = e_1;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
/** @internal */
|
||||
[(_getProperty_decorators = [throwIfDisposed()], _getProperties_decorators = [throwIfDisposed()], disposeSymbol)]() {
|
||||
return void this.dispose().catch(debugError);
|
||||
}
|
||||
/** @internal */
|
||||
[asyncDisposeSymbol]() {
|
||||
return this.dispose();
|
||||
}
|
||||
};
|
||||
return JSHandle = _classThis;
|
||||
})();
|
||||
export { JSHandle };
|
||||
//# sourceMappingURL=JSHandle.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/JSHandle.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"JSHandle.js","sour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aAAa,EAAC;YACb,OAAO,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QAED,gBAAgB;QAChB,CAAC,kBAAkB,CAAC;YAClB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;;;;SA5KmB,QAAQ"}
|
||||
2428
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.d.ts
generated
vendored
Normal file
2428
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1511
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js
generated
vendored
Normal file
1511
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
39
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.d.ts
generated
vendored
Normal file
39
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { TimeoutSettings } from '../common/TimeoutSettings.js';
|
||||
import type { EvaluateFunc, HandleFor, InnerLazyParams } from '../common/types.js';
|
||||
import { TaskManager } from '../common/WaitTask.js';
|
||||
import { disposeSymbol } from '../util/disposable.js';
|
||||
import type { ElementHandle } from './ElementHandle.js';
|
||||
import type { Environment } from './Environment.js';
|
||||
import type { JSHandle } from './JSHandle.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare abstract class Realm implements Disposable {
|
||||
#private;
|
||||
protected readonly timeoutSettings: TimeoutSettings;
|
||||
readonly taskManager: TaskManager;
|
||||
constructor(timeoutSettings: TimeoutSettings);
|
||||
abstract get environment(): Environment;
|
||||
abstract adoptHandle<T extends JSHandle<Node>>(handle: T): Promise<T>;
|
||||
abstract transferHandle<T extends JSHandle<Node>>(handle: T): Promise<T>;
|
||||
abstract evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
abstract evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
waitForFunction<Params extends unknown[], Func extends EvaluateFunc<InnerLazyParams<Params>> = EvaluateFunc<InnerLazyParams<Params>>>(pageFunction: Func | string, options?: {
|
||||
polling?: 'raf' | 'mutation' | number;
|
||||
timeout?: number;
|
||||
root?: ElementHandle<Node>;
|
||||
signal?: AbortSignal;
|
||||
}, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
abstract adoptBackendNode(backendNodeId?: number): Promise<JSHandle<Node>>;
|
||||
get disposed(): boolean;
|
||||
/** @internal */
|
||||
dispose(): void;
|
||||
/** @internal */
|
||||
[disposeSymbol](): void;
|
||||
}
|
||||
//# sourceMappingURL=Realm.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Realm.d.ts","sourceRoot":"","sources":["../../../../src/api/Realm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,eAA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CAAC,EAExD,YAAY,EAAE,IAAI,GAAG,MAAM,EAC3B,GAAG,IAAI,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAE/B,eAAe,CACnB,MAAM,SAAS,OAAO,EAAE,EACxB,IAAI,SAAS,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAC/D,eAAe,CAAC,MAAM,CAAC,CACxB,EAED,YAAY,EAAE,IAAI,GAAG,MAAM,EAC3B,OAAO,GAAE;QACP,OAAO,CAAC,EAAE,KAAK,GAAG,UAAU,GAAG,MAAM,CAAC;QACtC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;KACjB,EACN,GAAG,IAAI,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IA0BhD,QAAQ,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE1E,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAGD,gBAAgB;IAChB,OAAO,IAAI,IAAI;IAMf,gBAAgB;IAChB,CAAC,aAAa,CAAC,IAAI,IAAI;CAGxB"}
|
||||
44
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.js
generated
vendored
Normal file
44
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { TaskManager, WaitTask } from '../common/WaitTask.js';
|
||||
import { disposeSymbol } from '../util/disposable.js';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class Realm {
|
||||
timeoutSettings;
|
||||
taskManager = new TaskManager();
|
||||
constructor(timeoutSettings) {
|
||||
this.timeoutSettings = timeoutSettings;
|
||||
}
|
||||
async waitForFunction(pageFunction, options = {}, ...args) {
|
||||
const { polling = 'raf', timeout = this.timeoutSettings.timeout(), root, signal, } = options;
|
||||
if (typeof polling === 'number' && polling < 0) {
|
||||
throw new Error('Cannot poll with non-positive interval');
|
||||
}
|
||||
const waitTask = new WaitTask(this, {
|
||||
polling,
|
||||
root,
|
||||
timeout,
|
||||
signal,
|
||||
}, pageFunction, ...args);
|
||||
return await waitTask.result;
|
||||
}
|
||||
get disposed() {
|
||||
return this.#disposed;
|
||||
}
|
||||
#disposed = false;
|
||||
/** @internal */
|
||||
dispose() {
|
||||
this.#disposed = true;
|
||||
this.taskManager.terminateAll(new Error('waitForFunction failed: frame got detached.'));
|
||||
}
|
||||
/** @internal */
|
||||
[disposeSymbol]() {
|
||||
this.dispose();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Realm.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Realm.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Realm.js","sourceRoot":"","sources":["../../../../src/api/Realm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAMpD;;GAEG;AACH,MAAM,OAAgB,KAAK;IACN,eAAe,CAAkB;IAC3C,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IAEzC,YAAY,eAAgC;QAC1C,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAqBD,KAAK,CAAC,eAAe,CAMnB,YAA2B,EAC3B,UAKI,EAAE,EACN,GAAG,IAAY;QAEf,MAAM,EACJ,OAAO,GAAG,KAAK,EACf,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EACxC,IAAI,EACJ,MAAM,GACP,GAAG,OAAO,CAAC;QACZ,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAC3B,IAAI,EACJ;YACE,OAAO;YACP,IAAI;YACJ,OAAO;YACP,MAAM;SACP,EACD,YAEU,EACV,GAAG,IAAI,CACR,CAAC;QACF,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC;IAC/B,CAAC;IAID,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,SAAS,GAAG,KAAK,CAAC;IAClB,gBAAgB;IAChB,OAAO;QACL,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,WAAW,CAAC,YAAY,CAC3B,IAAI,KAAK,CAAC,6CAA6C,CAAC,CACzD,CAAC;IACJ,CAAC;IACD,gBAAgB;IAChB,CAAC,aAAa,CAAC;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACF"}
|
||||
80
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.d.ts
generated
vendored
Normal file
80
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.d.ts
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Browser } from './Browser.js';
|
||||
import type { BrowserContext } from './BrowserContext.js';
|
||||
import type { CDPSession } from './CDPSession.js';
|
||||
import type { Page } from './Page.js';
|
||||
import type { WebWorker } from './WebWorker.js';
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export declare enum TargetType {
|
||||
PAGE = "page",
|
||||
BACKGROUND_PAGE = "background_page",
|
||||
SERVICE_WORKER = "service_worker",
|
||||
SHARED_WORKER = "shared_worker",
|
||||
BROWSER = "browser",
|
||||
WEBVIEW = "webview",
|
||||
OTHER = "other",
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
TAB = "tab"
|
||||
}
|
||||
/**
|
||||
* Target represents a
|
||||
* {@link https://chromedevtools.github.io/devtools-protocol/tot/Target/ | CDP target}.
|
||||
* In CDP a target is something that can be debugged such a frame, a page or a
|
||||
* worker.
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Target {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected constructor();
|
||||
/**
|
||||
* If the target is not of type `"service_worker"` or `"shared_worker"`, returns `null`.
|
||||
*/
|
||||
worker(): Promise<WebWorker | null>;
|
||||
/**
|
||||
* If the target is not of type `"page"`, `"webview"` or `"background_page"`,
|
||||
* returns `null`.
|
||||
*/
|
||||
page(): Promise<Page | null>;
|
||||
/**
|
||||
* Forcefully creates a page for a target of any type. It is useful if you
|
||||
* want to handle a CDP target of type `other` as a page. If you deal with a
|
||||
* regular page target, use {@link Target.page}.
|
||||
*/
|
||||
abstract asPage(): Promise<Page>;
|
||||
abstract url(): string;
|
||||
/**
|
||||
* Creates a Chrome Devtools Protocol session attached to the target.
|
||||
*/
|
||||
abstract createCDPSession(): Promise<CDPSession>;
|
||||
/**
|
||||
* Identifies what kind of target this is.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* See {@link https://developer.chrome.com/extensions/background_pages | docs} for more info about background pages.
|
||||
*/
|
||||
abstract type(): TargetType;
|
||||
/**
|
||||
* Get the browser the target belongs to.
|
||||
*/
|
||||
abstract browser(): Browser;
|
||||
/**
|
||||
* Get the browser context the target belongs to.
|
||||
*/
|
||||
abstract browserContext(): BrowserContext;
|
||||
/**
|
||||
* Get the target that opened this target. Top-level targets return `null`.
|
||||
*/
|
||||
abstract opener(): Target | undefined;
|
||||
}
|
||||
//# sourceMappingURL=Target.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Target.d.ts","sourceRoot":"","sources":["../../../../src/api/Target.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf;;OAEG;IACH,GAAG,QAAQ;CACZ;AAED;;;;;;GAMG;AACH,8BAAsB,MAAM;IAC1B;;OAEG;IACH,SAAS;IAET;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAIzC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAIlC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC,QAAQ,CAAC,GAAG,IAAI,MAAM;IAEtB;;OAEG;IACH,QAAQ,CAAC,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;IAEhD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,IAAI,UAAU;IAE3B;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO;IAE3B;;OAEG;IACH,QAAQ,CAAC,cAAc,IAAI,cAAc;IAEzC;;OAEG;IACH,QAAQ,CAAC,MAAM,IAAI,MAAM,GAAG,SAAS;CACtC"}
|
||||
49
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.js
generated
vendored
Normal file
49
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export var TargetType;
|
||||
(function (TargetType) {
|
||||
TargetType["PAGE"] = "page";
|
||||
TargetType["BACKGROUND_PAGE"] = "background_page";
|
||||
TargetType["SERVICE_WORKER"] = "service_worker";
|
||||
TargetType["SHARED_WORKER"] = "shared_worker";
|
||||
TargetType["BROWSER"] = "browser";
|
||||
TargetType["WEBVIEW"] = "webview";
|
||||
TargetType["OTHER"] = "other";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
TargetType["TAB"] = "tab";
|
||||
})(TargetType || (TargetType = {}));
|
||||
/**
|
||||
* Target represents a
|
||||
* {@link https://chromedevtools.github.io/devtools-protocol/tot/Target/ | CDP target}.
|
||||
* In CDP a target is something that can be debugged such a frame, a page or a
|
||||
* worker.
|
||||
* @public
|
||||
*/
|
||||
export class Target {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor() { }
|
||||
/**
|
||||
* If the target is not of type `"service_worker"` or `"shared_worker"`, returns `null`.
|
||||
*/
|
||||
async worker() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* If the target is not of type `"page"`, `"webview"` or `"background_page"`,
|
||||
* returns `null`.
|
||||
*/
|
||||
async page() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Target.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/Target.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Target.js","sourceRoot":"","sources":["../../../../src/api/Target.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,MAAM,CAAN,IAAY,UAYX;AAZD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,iDAAmC,CAAA;IACnC,+CAAiC,CAAA;IACjC,6CAA+B,CAAA;IAC/B,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IACf;;OAEG;IACH,yBAAW,CAAA;AACb,CAAC,EAZW,UAAU,KAAV,UAAU,QAYrB;AAED;;;;;;GAMG;AACH,MAAM,OAAgB,MAAM;IAC1B;;OAEG;IACH,gBAAyB,CAAC;IAE1B;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC;IACd,CAAC;CAuCF"}
|
||||
102
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.d.ts
generated
vendored
Normal file
102
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { EventEmitter, type EventType } from '../common/EventEmitter.js';
|
||||
import { TimeoutSettings } from '../common/TimeoutSettings.js';
|
||||
import type { EvaluateFunc, HandleFor } from '../common/types.js';
|
||||
import type { CDPSession } from './CDPSession.js';
|
||||
import type { Realm } from './Realm.js';
|
||||
/**
|
||||
* This class represents a
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}.
|
||||
*
|
||||
* @remarks
|
||||
* The events `workercreated` and `workerdestroyed` are emitted on the page
|
||||
* object to signal the worker lifecycle.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* page.on('workercreated', worker =>
|
||||
* console.log('Worker created: ' + worker.url()),
|
||||
* );
|
||||
* page.on('workerdestroyed', worker =>
|
||||
* console.log('Worker destroyed: ' + worker.url()),
|
||||
* );
|
||||
*
|
||||
* console.log('Current workers:');
|
||||
* for (const worker of page.workers()) {
|
||||
* console.log(' ' + worker.url());
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class WebWorker extends EventEmitter<Record<EventType, unknown>> {
|
||||
#private;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
readonly timeoutSettings: TimeoutSettings;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(url: string);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract mainRealm(): Realm;
|
||||
/**
|
||||
* The URL of this web worker.
|
||||
*/
|
||||
url(): string;
|
||||
/**
|
||||
* The CDP session client the WebWorker belongs to.
|
||||
*/
|
||||
abstract get client(): CDPSession;
|
||||
/**
|
||||
* Evaluates a given function in the {@link WebWorker | worker}.
|
||||
*
|
||||
* @remarks If the given function returns a promise,
|
||||
* {@link WebWorker.evaluate | evaluate} will wait for the promise to resolve.
|
||||
*
|
||||
* As a rule of thumb, if the return value of the given function is more
|
||||
* complicated than a JSON object (e.g. most classes), then
|
||||
* {@link WebWorker.evaluate | evaluate} will _likely_ return some truncated
|
||||
* value (or `{}`). This is because we are not returning the actual return
|
||||
* value, but a deserialized version as a result of transferring the return
|
||||
* value through a protocol to Puppeteer.
|
||||
*
|
||||
* In general, you should use
|
||||
* {@link WebWorker.evaluateHandle | evaluateHandle} if
|
||||
* {@link WebWorker.evaluate | evaluate} cannot serialize the return value
|
||||
* properly or you need a mutable {@link JSHandle | handle} to the return
|
||||
* object.
|
||||
*
|
||||
* @param func - Function to be evaluated.
|
||||
* @param args - Arguments to pass into `func`.
|
||||
* @returns The result of `func`.
|
||||
*/
|
||||
evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(func: Func | string, ...args: Params): Promise<Awaited<ReturnType<Func>>>;
|
||||
/**
|
||||
* Evaluates a given function in the {@link WebWorker | worker}.
|
||||
*
|
||||
* @remarks If the given function returns a promise,
|
||||
* {@link WebWorker.evaluate | evaluate} will wait for the promise to resolve.
|
||||
*
|
||||
* In general, you should use
|
||||
* {@link WebWorker.evaluateHandle | evaluateHandle} if
|
||||
* {@link WebWorker.evaluate | evaluate} cannot serialize the return value
|
||||
* properly or you need a mutable {@link JSHandle | handle} to the return
|
||||
* object.
|
||||
*
|
||||
* @param func - Function to be evaluated.
|
||||
* @param args - Arguments to pass into `func`.
|
||||
* @returns A {@link JSHandle | handle} to the return value of `func`.
|
||||
*/
|
||||
evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(func: Func | string, ...args: Params): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
|
||||
close(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=WebWorker.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WebWorker.d.ts","sourceRoot":"","sources":["../../../../src/api/WebWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,YAAY,EAAE,KAAK,SAAS,EAAC,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAGhE,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,SAAU,SAAQ,YAAY,CAClD,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAC3B;;IACC;;OAEG;IACH,QAAQ,CAAC,eAAe,kBAAyB;IAIjD;;OAEG;gBACS,GAAG,EAAE,MAAM;IAMvB;;OAEG;IACH,QAAQ,CAAC,SAAS,IAAI,KAAK;IAE3B;;OAEG;IACH,GAAG,IAAI,MAAM;IAIb;;OAEG;IACH,QAAQ,KAAK,MAAM,IAAI,UAAU,CAAC;IAElC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,QAAQ,CACZ,MAAM,SAAS,OAAO,EAAE,EACxB,IAAI,SAAS,YAAY,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EACxD,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAK3E;;;;;;;;;;;;;;;OAeG;IACG,cAAc,CAClB,MAAM,SAAS,OAAO,EAAE,EACxB,IAAI,SAAS,YAAY,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EAExD,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,GAAG,IAAI,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAK1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
||||
106
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.js
generated
vendored
Normal file
106
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { UnsupportedOperation } from '../common/Errors.js';
|
||||
import { EventEmitter } from '../common/EventEmitter.js';
|
||||
import { TimeoutSettings } from '../common/TimeoutSettings.js';
|
||||
import { withSourcePuppeteerURLIfNone } from '../common/util.js';
|
||||
/**
|
||||
* This class represents a
|
||||
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorker}.
|
||||
*
|
||||
* @remarks
|
||||
* The events `workercreated` and `workerdestroyed` are emitted on the page
|
||||
* object to signal the worker lifecycle.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* page.on('workercreated', worker =>
|
||||
* console.log('Worker created: ' + worker.url()),
|
||||
* );
|
||||
* page.on('workerdestroyed', worker =>
|
||||
* console.log('Worker destroyed: ' + worker.url()),
|
||||
* );
|
||||
*
|
||||
* console.log('Current workers:');
|
||||
* for (const worker of page.workers()) {
|
||||
* console.log(' ' + worker.url());
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class WebWorker extends EventEmitter {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
timeoutSettings = new TimeoutSettings();
|
||||
#url;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
constructor(url) {
|
||||
super();
|
||||
this.#url = url;
|
||||
}
|
||||
/**
|
||||
* The URL of this web worker.
|
||||
*/
|
||||
url() {
|
||||
return this.#url;
|
||||
}
|
||||
/**
|
||||
* Evaluates a given function in the {@link WebWorker | worker}.
|
||||
*
|
||||
* @remarks If the given function returns a promise,
|
||||
* {@link WebWorker.evaluate | evaluate} will wait for the promise to resolve.
|
||||
*
|
||||
* As a rule of thumb, if the return value of the given function is more
|
||||
* complicated than a JSON object (e.g. most classes), then
|
||||
* {@link WebWorker.evaluate | evaluate} will _likely_ return some truncated
|
||||
* value (or `{}`). This is because we are not returning the actual return
|
||||
* value, but a deserialized version as a result of transferring the return
|
||||
* value through a protocol to Puppeteer.
|
||||
*
|
||||
* In general, you should use
|
||||
* {@link WebWorker.evaluateHandle | evaluateHandle} if
|
||||
* {@link WebWorker.evaluate | evaluate} cannot serialize the return value
|
||||
* properly or you need a mutable {@link JSHandle | handle} to the return
|
||||
* object.
|
||||
*
|
||||
* @param func - Function to be evaluated.
|
||||
* @param args - Arguments to pass into `func`.
|
||||
* @returns The result of `func`.
|
||||
*/
|
||||
async evaluate(func, ...args) {
|
||||
func = withSourcePuppeteerURLIfNone(this.evaluate.name, func);
|
||||
return await this.mainRealm().evaluate(func, ...args);
|
||||
}
|
||||
/**
|
||||
* Evaluates a given function in the {@link WebWorker | worker}.
|
||||
*
|
||||
* @remarks If the given function returns a promise,
|
||||
* {@link WebWorker.evaluate | evaluate} will wait for the promise to resolve.
|
||||
*
|
||||
* In general, you should use
|
||||
* {@link WebWorker.evaluateHandle | evaluateHandle} if
|
||||
* {@link WebWorker.evaluate | evaluate} cannot serialize the return value
|
||||
* properly or you need a mutable {@link JSHandle | handle} to the return
|
||||
* object.
|
||||
*
|
||||
* @param func - Function to be evaluated.
|
||||
* @param args - Arguments to pass into `func`.
|
||||
* @returns A {@link JSHandle | handle} to the return value of `func`.
|
||||
*/
|
||||
async evaluateHandle(func, ...args) {
|
||||
func = withSourcePuppeteerURLIfNone(this.evaluateHandle.name, func);
|
||||
return await this.mainRealm().evaluateHandle(func, ...args);
|
||||
}
|
||||
async close() {
|
||||
throw new UnsupportedOperation('WebWorker.close() is not supported');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=WebWorker.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/WebWorker.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WebWorker.js","sourceRoot":"","sources":["../../../../src/api/WebWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAC,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAC,4BAA4B,EAAC,MAAM,mBAAmB,CAAC;AAK/D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAgB,SAAU,SAAQ,YAEvC;IACC;;OAEG;IACM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAExC,IAAI,CAAS;IAEtB;;OAEG;IACH,YAAY,GAAW;QACrB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAOD;;OAEG;IACH,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAOD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,QAAQ,CAGZ,IAAmB,EAAE,GAAG,IAAY;QACpC,IAAI,GAAG,4BAA4B,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9D,OAAO,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,cAAc,CAIlB,IAAmB,EACnB,GAAG,IAAY;QAEf,IAAI,GAAG,4BAA4B,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACpE,OAAO,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,oBAAoB,CAAC,oCAAoC,CAAC,CAAC;IACvE,CAAC;CACF"}
|
||||
24
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.d.ts
generated
vendored
Normal file
24
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
export type * from './BluetoothEmulation.js';
|
||||
export * from './Browser.js';
|
||||
export * from './BrowserContext.js';
|
||||
export * from './CDPSession.js';
|
||||
export * from './DeviceRequestPrompt.js';
|
||||
export * from './Dialog.js';
|
||||
export * from './ElementHandle.js';
|
||||
export type * from './Environment.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';
|
||||
export * from './Target.js';
|
||||
export * from './WebWorker.js';
|
||||
export * from './locators/locators.js';
|
||||
//# sourceMappingURL=api.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/api/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB,yBAAyB,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,mBAAmB,kBAAkB,CAAC;AACtC,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;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
|
||||
22
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.js
generated
vendored
Normal file
22
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
export * from './Browser.js';
|
||||
export * from './BrowserContext.js';
|
||||
export * from './CDPSession.js';
|
||||
export * from './DeviceRequestPrompt.js';
|
||||
export * from './Dialog.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';
|
||||
export * from './Target.js';
|
||||
export * from './WebWorker.js';
|
||||
export * from './locators/locators.js';
|
||||
//# sourceMappingURL=api.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/api.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/api/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AAEnC,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;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
|
||||
325
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.d.ts
generated
vendored
Normal file
325
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.d.ts
generated
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import type { Observable, OperatorFunction } from '../../../third_party/rxjs/rxjs.js';
|
||||
import type { EventType } from '../../common/EventEmitter.js';
|
||||
import { EventEmitter } from '../../common/EventEmitter.js';
|
||||
import type { Awaitable, HandleFor, NodeFor } from '../../common/types.js';
|
||||
import type { ClickOptions, ElementHandle } from '../ElementHandle.js';
|
||||
import type { Frame } from '../Frame.js';
|
||||
import type { Page } from '../Page.js';
|
||||
/**
|
||||
* Whether to wait for the element to be
|
||||
* {@link ElementHandle.isVisible | visible} or
|
||||
* {@link ElementHandle.isHidden | hidden}.
|
||||
* `null` to disable visibility checks.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type VisibilityOption = 'hidden' | 'visible' | null;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ActionOptions {
|
||||
/**
|
||||
* A signal to abort the locator action.
|
||||
*/
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type LocatorClickOptions = ClickOptions & ActionOptions;
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface LocatorFillOptions extends ActionOptions {
|
||||
/**
|
||||
* The number of characters to type before switching to a faster fill-out
|
||||
* method.
|
||||
*
|
||||
* @defaultValue `100`
|
||||
*/
|
||||
typingThreshold?: number;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface LocatorScrollOptions extends ActionOptions {
|
||||
scrollTop?: number;
|
||||
scrollLeft?: number;
|
||||
}
|
||||
/**
|
||||
* All the events that a locator instance may emit.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare enum LocatorEvent {
|
||||
/**
|
||||
* Emitted every time before the locator performs an action on the located element(s).
|
||||
*/
|
||||
Action = "action"
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface LocatorEvents extends Record<EventType, unknown> {
|
||||
[LocatorEvent.Action]: undefined;
|
||||
}
|
||||
/**
|
||||
* Locators describe a strategy of locating objects and performing an action on
|
||||
* them. If the action fails because the object is not ready for the action, the
|
||||
* whole operation is retried. Various preconditions for a successful action are
|
||||
* checked automatically.
|
||||
*
|
||||
* See {@link https://pptr.dev/guides/page-interactions#locators} for details.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export declare abstract class Locator<T> extends EventEmitter<LocatorEvents> {
|
||||
#private;
|
||||
/**
|
||||
* Creates a race between multiple locators trying to locate elements in
|
||||
* parallel but ensures that only a single element receives the action.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static race<Locators extends readonly unknown[] | []>(locators: Locators): Locator<AwaitedLocator<Locators[number]>>;
|
||||
/**
|
||||
* Used for nominally typing {@link Locator}.
|
||||
*/
|
||||
_?: T;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected visibility: VisibilityOption;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected _timeout: number;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected operators: {
|
||||
conditions: (conditions: Array<Action<T, never>>, signal?: AbortSignal) => OperatorFunction<HandleFor<T>, HandleFor<T>>;
|
||||
retryAndRaceWithSignalAndTimer: <T_1>(signal?: AbortSignal, cause?: Error) => OperatorFunction<T_1, T_1>;
|
||||
};
|
||||
get timeout(): number;
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and setting
|
||||
* the total timeout for the locator actions.
|
||||
*
|
||||
* Pass `0` to disable timeout.
|
||||
*
|
||||
* @defaultValue `Page.getDefaultTimeout()`
|
||||
*/
|
||||
setTimeout(timeout: number): Locator<T>;
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator with the
|
||||
* visibility property changed to the specified value.
|
||||
*/
|
||||
setVisibility<NodeType extends Node>(this: Locator<NodeType>, visibility: VisibilityOption): Locator<NodeType>;
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and
|
||||
* specifying whether to wait for input elements to become enabled before the
|
||||
* action. Applicable to `click` and `fill` actions.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
setWaitForEnabled<NodeType extends Node>(this: Locator<NodeType>, value: boolean): Locator<NodeType>;
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and
|
||||
* specifying whether the locator should scroll the element into viewport if
|
||||
* it is not in the viewport already.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
setEnsureElementIsInTheViewport<ElementType extends Element>(this: Locator<ElementType>, value: boolean): Locator<ElementType>;
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and
|
||||
* specifying whether the locator has to wait for the element's bounding box
|
||||
* to be same between two consecutive animation frames.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
setWaitForStableBoundingBox<ElementType extends Element>(this: Locator<ElementType>, value: boolean): Locator<ElementType>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
copyOptions<T>(locator: Locator<T>): this;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract _clone(): Locator<T>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
abstract _wait(options?: Readonly<ActionOptions>): Observable<HandleFor<T>>;
|
||||
/**
|
||||
* Clones the locator.
|
||||
*/
|
||||
clone(): Locator<T>;
|
||||
/**
|
||||
* Waits for the locator to get a handle from the page.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
waitHandle(options?: Readonly<ActionOptions>): Promise<HandleFor<T>>;
|
||||
/**
|
||||
* Waits for the locator to get the serialized value from the page.
|
||||
*
|
||||
* Note this requires the value to be JSON-serializable.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
wait(options?: Readonly<ActionOptions>): Promise<T>;
|
||||
/**
|
||||
* Maps the locator using the provided mapper.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
map<To>(mapper: Mapper<T, To>): Locator<To>;
|
||||
/**
|
||||
* Creates an expectation that is evaluated against located values.
|
||||
*
|
||||
* If the expectations do not match, then the locator will retry.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
filter<S extends T>(predicate: Predicate<T, S>): Locator<S>;
|
||||
/**
|
||||
* Creates an expectation that is evaluated against located handles.
|
||||
*
|
||||
* If the expectations do not match, then the locator will retry.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
filterHandle<S extends T>(predicate: Predicate<HandleFor<T>, HandleFor<S>>): Locator<S>;
|
||||
/**
|
||||
* Maps the locator using the provided mapper.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
mapHandle<To>(mapper: HandleMapper<T, To>): Locator<To>;
|
||||
/**
|
||||
* Clicks the located element.
|
||||
*/
|
||||
click<ElementType extends Element>(this: Locator<ElementType>, options?: Readonly<LocatorClickOptions>): Promise<void>;
|
||||
/**
|
||||
* Fills out the input identified by the locator using the provided value. The
|
||||
* type of the input is determined at runtime and the appropriate fill-out
|
||||
* method is chosen based on the type. `contenteditable`, select, textarea and
|
||||
* input elements are supported.
|
||||
*/
|
||||
fill<ElementType extends Element>(this: Locator<ElementType>, value: string, options?: Readonly<LocatorFillOptions>): Promise<void>;
|
||||
/**
|
||||
* Hovers over the located element.
|
||||
*/
|
||||
hover<ElementType extends Element>(this: Locator<ElementType>, options?: Readonly<ActionOptions>): Promise<void>;
|
||||
/**
|
||||
* Scrolls the located element.
|
||||
*/
|
||||
scroll<ElementType extends Element>(this: Locator<ElementType>, options?: Readonly<LocatorScrollOptions>): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class FunctionLocator<T> extends Locator<T> {
|
||||
#private;
|
||||
static create<Ret>(pageOrFrame: Page | Frame, func: () => Awaitable<Ret>): Locator<Ret>;
|
||||
private constructor();
|
||||
_clone(): FunctionLocator<T>;
|
||||
_wait(options?: Readonly<ActionOptions>): Observable<HandleFor<T>>;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type Predicate<From, To extends From = From> = ((value: From) => value is To) | ((value: From) => Awaitable<boolean>);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type HandlePredicate<From, To extends From = From> = ((value: HandleFor<From>, signal?: AbortSignal) => value is HandleFor<To>) | ((value: HandleFor<From>, signal?: AbortSignal) => Awaitable<boolean>);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare abstract class DelegatedLocator<T, U> extends Locator<U> {
|
||||
#private;
|
||||
constructor(delegate: Locator<T>);
|
||||
protected get delegate(): Locator<T>;
|
||||
setTimeout(timeout: number): DelegatedLocator<T, U>;
|
||||
setVisibility<ValueType extends Node, NodeType extends Node>(this: DelegatedLocator<ValueType, NodeType>, visibility: VisibilityOption): DelegatedLocator<ValueType, NodeType>;
|
||||
setWaitForEnabled<ValueType extends Node, NodeType extends Node>(this: DelegatedLocator<ValueType, NodeType>, value: boolean): DelegatedLocator<ValueType, NodeType>;
|
||||
setEnsureElementIsInTheViewport<ValueType extends Element, ElementType extends Element>(this: DelegatedLocator<ValueType, ElementType>, value: boolean): DelegatedLocator<ValueType, ElementType>;
|
||||
setWaitForStableBoundingBox<ValueType extends Element, ElementType extends Element>(this: DelegatedLocator<ValueType, ElementType>, value: boolean): DelegatedLocator<ValueType, ElementType>;
|
||||
abstract _clone(): DelegatedLocator<T, U>;
|
||||
abstract _wait(): Observable<HandleFor<U>>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class FilteredLocator<From, To extends From> extends DelegatedLocator<From, To> {
|
||||
#private;
|
||||
constructor(base: Locator<From>, predicate: HandlePredicate<From, To>);
|
||||
_clone(): FilteredLocator<From, To>;
|
||||
_wait(options?: Readonly<ActionOptions>): Observable<HandleFor<To>>;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type Mapper<From, To> = (value: From) => Awaitable<To>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type HandleMapper<From, To> = (value: HandleFor<From>, signal?: AbortSignal) => Awaitable<HandleFor<To>>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class MappedLocator<From, To> extends DelegatedLocator<From, To> {
|
||||
#private;
|
||||
constructor(base: Locator<From>, mapper: HandleMapper<From, To>);
|
||||
_clone(): MappedLocator<From, To>;
|
||||
_wait(options?: Readonly<ActionOptions>): Observable<HandleFor<To>>;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type Action<T, U> = (element: HandleFor<T>, signal?: AbortSignal) => Observable<U>;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class NodeLocator<T extends Node> extends Locator<T> {
|
||||
#private;
|
||||
static create<Selector extends string>(pageOrFrame: Page | Frame, selector: Selector): Locator<NodeFor<Selector>>;
|
||||
static createFromHandle<T extends Node>(pageOrFrame: Page | Frame, handle: ElementHandle<T>): Locator<T>;
|
||||
private constructor();
|
||||
private constructor();
|
||||
_clone(): NodeLocator<T>;
|
||||
_wait(options?: Readonly<ActionOptions>): Observable<HandleFor<T>>;
|
||||
}
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type AwaitedLocator<T> = T extends Locator<infer S> ? S : never;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare class RaceLocator<T> extends Locator<T> {
|
||||
#private;
|
||||
static create<T extends readonly unknown[]>(locators: T): Locator<AwaitedLocator<T[number]>>;
|
||||
constructor(locators: ReadonlyArray<Locator<T>>);
|
||||
_clone(): RaceLocator<T>;
|
||||
_wait(options?: Readonly<ActionOptions>): Observable<HandleFor<T>>;
|
||||
}
|
||||
/**
|
||||
* For observables coming from promises, a delay is needed, otherwise RxJS will
|
||||
* never yield in a permanent failure for a promise.
|
||||
*
|
||||
* We also don't want RxJS to do promise operations to often, so we bump the
|
||||
* delay up to 100ms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare const RETRY_DELAY = 100;
|
||||
//# sourceMappingURL=locators.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
769
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.js
generated
vendored
Normal file
769
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.js
generated
vendored
Normal file
@@ -0,0 +1,769 @@
|
||||
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 { EMPTY, catchError, defaultIfEmpty, defer, filter, first, firstValueFrom, from, identity, ignoreElements, map, merge, mergeMap, noop, of, pipe, race, raceWith, retry, tap, throwIfEmpty, } from '../../../third_party/rxjs/rxjs.js';
|
||||
import { EventEmitter } from '../../common/EventEmitter.js';
|
||||
import { debugError, fromAbortSignal, timeout } from '../../common/util.js';
|
||||
/**
|
||||
* All the events that a locator instance may emit.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export var LocatorEvent;
|
||||
(function (LocatorEvent) {
|
||||
/**
|
||||
* Emitted every time before the locator performs an action on the located element(s).
|
||||
*/
|
||||
LocatorEvent["Action"] = "action";
|
||||
})(LocatorEvent || (LocatorEvent = {}));
|
||||
/**
|
||||
* Locators describe a strategy of locating objects and performing an action on
|
||||
* them. If the action fails because the object is not ready for the action, the
|
||||
* whole operation is retried. Various preconditions for a successful action are
|
||||
* checked automatically.
|
||||
*
|
||||
* See {@link https://pptr.dev/guides/page-interactions#locators} for details.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class Locator extends EventEmitter {
|
||||
/**
|
||||
* Creates a race between multiple locators trying to locate elements in
|
||||
* parallel but ensures that only a single element receives the action.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
static race(locators) {
|
||||
return RaceLocator.create(locators);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
visibility = null;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_timeout = 30000;
|
||||
#ensureElementIsInTheViewport = true;
|
||||
#waitForEnabled = true;
|
||||
#waitForStableBoundingBox = true;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
operators = {
|
||||
conditions: (conditions, signal) => {
|
||||
return mergeMap((handle) => {
|
||||
return merge(...conditions.map(condition => {
|
||||
return condition(handle, signal);
|
||||
})).pipe(defaultIfEmpty(handle));
|
||||
});
|
||||
},
|
||||
retryAndRaceWithSignalAndTimer: (signal, cause) => {
|
||||
const candidates = [];
|
||||
if (signal) {
|
||||
candidates.push(fromAbortSignal(signal, cause));
|
||||
}
|
||||
candidates.push(timeout(this._timeout, cause));
|
||||
return pipe(retry({ delay: RETRY_DELAY }), raceWith(...candidates));
|
||||
},
|
||||
};
|
||||
// Determines when the locator will timeout for actions.
|
||||
get timeout() {
|
||||
return this._timeout;
|
||||
}
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and setting
|
||||
* the total timeout for the locator actions.
|
||||
*
|
||||
* Pass `0` to disable timeout.
|
||||
*
|
||||
* @defaultValue `Page.getDefaultTimeout()`
|
||||
*/
|
||||
setTimeout(timeout) {
|
||||
const locator = this._clone();
|
||||
locator._timeout = timeout;
|
||||
return locator;
|
||||
}
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator with the
|
||||
* visibility property changed to the specified value.
|
||||
*/
|
||||
setVisibility(visibility) {
|
||||
const locator = this._clone();
|
||||
locator.visibility = visibility;
|
||||
return locator;
|
||||
}
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and
|
||||
* specifying whether to wait for input elements to become enabled before the
|
||||
* action. Applicable to `click` and `fill` actions.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
setWaitForEnabled(value) {
|
||||
const locator = this._clone();
|
||||
locator.#waitForEnabled = value;
|
||||
return locator;
|
||||
}
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and
|
||||
* specifying whether the locator should scroll the element into viewport if
|
||||
* it is not in the viewport already.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
setEnsureElementIsInTheViewport(value) {
|
||||
const locator = this._clone();
|
||||
locator.#ensureElementIsInTheViewport = value;
|
||||
return locator;
|
||||
}
|
||||
/**
|
||||
* Creates a new locator instance by cloning the current locator and
|
||||
* specifying whether the locator has to wait for the element's bounding box
|
||||
* to be same between two consecutive animation frames.
|
||||
*
|
||||
* @defaultValue `true`
|
||||
*/
|
||||
setWaitForStableBoundingBox(value) {
|
||||
const locator = this._clone();
|
||||
locator.#waitForStableBoundingBox = value;
|
||||
return locator;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
copyOptions(locator) {
|
||||
this._timeout = locator._timeout;
|
||||
this.visibility = locator.visibility;
|
||||
this.#waitForEnabled = locator.#waitForEnabled;
|
||||
this.#ensureElementIsInTheViewport = locator.#ensureElementIsInTheViewport;
|
||||
this.#waitForStableBoundingBox = locator.#waitForStableBoundingBox;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* If the element has a "disabled" property, wait for the element to be
|
||||
* enabled.
|
||||
*/
|
||||
#waitForEnabledIfNeeded = (handle, signal) => {
|
||||
if (!this.#waitForEnabled) {
|
||||
return EMPTY;
|
||||
}
|
||||
return from(handle.frame.waitForFunction(element => {
|
||||
if (!(element instanceof HTMLElement)) {
|
||||
return true;
|
||||
}
|
||||
const isNativeFormControl = [
|
||||
'BUTTON',
|
||||
'INPUT',
|
||||
'SELECT',
|
||||
'TEXTAREA',
|
||||
'OPTION',
|
||||
'OPTGROUP',
|
||||
].includes(element.nodeName);
|
||||
return !isNativeFormControl || !element.hasAttribute('disabled');
|
||||
}, {
|
||||
timeout: this._timeout,
|
||||
signal,
|
||||
}, handle)).pipe(ignoreElements());
|
||||
};
|
||||
/**
|
||||
* Compares the bounding box of the element for two consecutive animation
|
||||
* frames and waits till they are the same.
|
||||
*/
|
||||
#waitForStableBoundingBoxIfNeeded = (handle) => {
|
||||
if (!this.#waitForStableBoundingBox) {
|
||||
return EMPTY;
|
||||
}
|
||||
return defer(() => {
|
||||
// Note we don't use waitForFunction because that relies on RAF.
|
||||
return from(handle.evaluate(element => {
|
||||
return new Promise(resolve => {
|
||||
window.requestAnimationFrame(() => {
|
||||
const rect1 = element.getBoundingClientRect();
|
||||
window.requestAnimationFrame(() => {
|
||||
const rect2 = element.getBoundingClientRect();
|
||||
resolve([
|
||||
{
|
||||
x: rect1.x,
|
||||
y: rect1.y,
|
||||
width: rect1.width,
|
||||
height: rect1.height,
|
||||
},
|
||||
{
|
||||
x: rect2.x,
|
||||
y: rect2.y,
|
||||
width: rect2.width,
|
||||
height: rect2.height,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
}));
|
||||
}).pipe(first(([rect1, rect2]) => {
|
||||
return (rect1.x === rect2.x &&
|
||||
rect1.y === rect2.y &&
|
||||
rect1.width === rect2.width &&
|
||||
rect1.height === rect2.height);
|
||||
}), retry({ delay: RETRY_DELAY }), ignoreElements());
|
||||
};
|
||||
/**
|
||||
* Checks if the element is in the viewport and auto-scrolls it if it is not.
|
||||
*/
|
||||
#ensureElementIsInTheViewportIfNeeded = (handle) => {
|
||||
if (!this.#ensureElementIsInTheViewport) {
|
||||
return EMPTY;
|
||||
}
|
||||
return from(handle.isIntersectingViewport({ threshold: 0 })).pipe(filter(isIntersectingViewport => {
|
||||
return !isIntersectingViewport;
|
||||
}), mergeMap(() => {
|
||||
return from(handle.scrollIntoView());
|
||||
}), mergeMap(() => {
|
||||
return defer(() => {
|
||||
return from(handle.isIntersectingViewport({ threshold: 0 }));
|
||||
}).pipe(first(identity), retry({ delay: RETRY_DELAY }), ignoreElements());
|
||||
}));
|
||||
};
|
||||
#click(options) {
|
||||
const signal = options?.signal;
|
||||
const cause = new Error('Locator.click');
|
||||
return this._wait(options).pipe(this.operators.conditions([
|
||||
this.#ensureElementIsInTheViewportIfNeeded,
|
||||
this.#waitForStableBoundingBoxIfNeeded,
|
||||
this.#waitForEnabledIfNeeded,
|
||||
], signal), tap(() => {
|
||||
return this.emit(LocatorEvent.Action, undefined);
|
||||
}), mergeMap(handle => {
|
||||
return from(handle.click(options)).pipe(catchError(err => {
|
||||
void handle.dispose().catch(debugError);
|
||||
throw err;
|
||||
}));
|
||||
}), this.operators.retryAndRaceWithSignalAndTimer(signal, cause));
|
||||
}
|
||||
#fill(value, options) {
|
||||
const signal = options?.signal;
|
||||
const typingThreshold = options?.typingThreshold ?? 100;
|
||||
const cause = new Error('Locator.fill');
|
||||
return this._wait(options).pipe(this.operators.conditions([
|
||||
this.#ensureElementIsInTheViewportIfNeeded,
|
||||
this.#waitForStableBoundingBoxIfNeeded,
|
||||
this.#waitForEnabledIfNeeded,
|
||||
], signal), tap(() => {
|
||||
return this.emit(LocatorEvent.Action, undefined);
|
||||
}), mergeMap(handle => {
|
||||
return from(handle.evaluate(el => {
|
||||
if (el instanceof HTMLSelectElement) {
|
||||
return 'select';
|
||||
}
|
||||
if (el instanceof HTMLTextAreaElement) {
|
||||
return 'typeable-input';
|
||||
}
|
||||
if (el instanceof HTMLInputElement) {
|
||||
if (new Set([
|
||||
'textarea',
|
||||
'text',
|
||||
'url',
|
||||
'tel',
|
||||
'search',
|
||||
'password',
|
||||
'number',
|
||||
'email',
|
||||
]).has(el.type)) {
|
||||
return 'typeable-input';
|
||||
}
|
||||
else {
|
||||
return 'other-input';
|
||||
}
|
||||
}
|
||||
if (el.isContentEditable) {
|
||||
return 'contenteditable';
|
||||
}
|
||||
return 'unknown';
|
||||
}))
|
||||
.pipe(mergeMap(inputType => {
|
||||
const fillDirectly = () => {
|
||||
return from(handle.focus()).pipe(mergeMap(() => {
|
||||
return from(handle.evaluate((input, newValue) => {
|
||||
const element = input;
|
||||
const currentValue = element.isContentEditable
|
||||
? element.innerText
|
||||
: element.value;
|
||||
if (currentValue === newValue) {
|
||||
return;
|
||||
}
|
||||
if (element.isContentEditable) {
|
||||
element.innerText = newValue;
|
||||
}
|
||||
else {
|
||||
element.value = newValue;
|
||||
}
|
||||
element.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
element.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
}, value));
|
||||
}));
|
||||
};
|
||||
switch (inputType) {
|
||||
case 'select':
|
||||
return from(handle.select(value).then(noop));
|
||||
case 'contenteditable':
|
||||
case 'typeable-input':
|
||||
if (value.length < typingThreshold) {
|
||||
return from(handle.evaluate((input, newValue) => {
|
||||
const element = input;
|
||||
const currentValue = element.isContentEditable
|
||||
? element.innerText
|
||||
: input.value;
|
||||
// Clear the input if the current value does not match the filled
|
||||
// out value.
|
||||
if (newValue.length <= currentValue.length ||
|
||||
!newValue.startsWith(currentValue)) {
|
||||
if (element.isContentEditable) {
|
||||
element.innerText = '';
|
||||
}
|
||||
else {
|
||||
input.value = '';
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
// If the value is partially filled out, only type the rest. Move
|
||||
// cursor to the end of the common prefix.
|
||||
if (element.isContentEditable) {
|
||||
element.innerText = '';
|
||||
element.innerText = currentValue;
|
||||
}
|
||||
else {
|
||||
input.value = '';
|
||||
input.value = currentValue;
|
||||
}
|
||||
return newValue.substring(currentValue.length);
|
||||
}, value)).pipe(mergeMap(textToType => {
|
||||
if (!textToType) {
|
||||
return of(undefined);
|
||||
}
|
||||
return from(handle.type(textToType));
|
||||
}));
|
||||
}
|
||||
return fillDirectly();
|
||||
case 'other-input':
|
||||
return fillDirectly();
|
||||
case 'unknown':
|
||||
throw new Error(`Element cannot be filled out.`);
|
||||
}
|
||||
}))
|
||||
.pipe(catchError(err => {
|
||||
void handle.dispose().catch(debugError);
|
||||
throw err;
|
||||
}));
|
||||
}), this.operators.retryAndRaceWithSignalAndTimer(signal, cause));
|
||||
}
|
||||
#hover(options) {
|
||||
const signal = options?.signal;
|
||||
const cause = new Error('Locator.hover');
|
||||
return this._wait(options).pipe(this.operators.conditions([
|
||||
this.#ensureElementIsInTheViewportIfNeeded,
|
||||
this.#waitForStableBoundingBoxIfNeeded,
|
||||
], signal), tap(() => {
|
||||
return this.emit(LocatorEvent.Action, undefined);
|
||||
}), mergeMap(handle => {
|
||||
return from(handle.hover()).pipe(catchError(err => {
|
||||
void handle.dispose().catch(debugError);
|
||||
throw err;
|
||||
}));
|
||||
}), this.operators.retryAndRaceWithSignalAndTimer(signal, cause));
|
||||
}
|
||||
#scroll(options) {
|
||||
const signal = options?.signal;
|
||||
const cause = new Error('Locator.scroll');
|
||||
return this._wait(options).pipe(this.operators.conditions([
|
||||
this.#ensureElementIsInTheViewportIfNeeded,
|
||||
this.#waitForStableBoundingBoxIfNeeded,
|
||||
], signal), tap(() => {
|
||||
return this.emit(LocatorEvent.Action, undefined);
|
||||
}), mergeMap(handle => {
|
||||
return from(handle.evaluate((el, scrollTop, scrollLeft) => {
|
||||
if (scrollTop !== undefined) {
|
||||
el.scrollTop = scrollTop;
|
||||
}
|
||||
if (scrollLeft !== undefined) {
|
||||
el.scrollLeft = scrollLeft;
|
||||
}
|
||||
}, options?.scrollTop, options?.scrollLeft)).pipe(catchError(err => {
|
||||
void handle.dispose().catch(debugError);
|
||||
throw err;
|
||||
}));
|
||||
}), this.operators.retryAndRaceWithSignalAndTimer(signal, cause));
|
||||
}
|
||||
/**
|
||||
* Clones the locator.
|
||||
*/
|
||||
clone() {
|
||||
return this._clone();
|
||||
}
|
||||
/**
|
||||
* Waits for the locator to get a handle from the page.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
async waitHandle(options) {
|
||||
const cause = new Error('Locator.waitHandle');
|
||||
return await firstValueFrom(this._wait(options).pipe(this.operators.retryAndRaceWithSignalAndTimer(options?.signal, cause)));
|
||||
}
|
||||
/**
|
||||
* Waits for the locator to get the serialized value from the page.
|
||||
*
|
||||
* Note this requires the value to be JSON-serializable.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
async wait(options) {
|
||||
const env_1 = { stack: [], error: void 0, hasError: false };
|
||||
try {
|
||||
const handle = __addDisposableResource(env_1, await this.waitHandle(options), false);
|
||||
return await handle.jsonValue();
|
||||
}
|
||||
catch (e_1) {
|
||||
env_1.error = e_1;
|
||||
env_1.hasError = true;
|
||||
}
|
||||
finally {
|
||||
__disposeResources(env_1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Maps the locator using the provided mapper.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
map(mapper) {
|
||||
return new MappedLocator(this._clone(), handle => {
|
||||
// SAFETY: TypeScript cannot deduce the type.
|
||||
return handle.evaluateHandle(mapper);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Creates an expectation that is evaluated against located values.
|
||||
*
|
||||
* If the expectations do not match, then the locator will retry.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
filter(predicate) {
|
||||
return new FilteredLocator(this._clone(), async (handle, signal) => {
|
||||
await handle.frame.waitForFunction(predicate, { signal, timeout: this._timeout }, handle);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Creates an expectation that is evaluated against located handles.
|
||||
*
|
||||
* If the expectations do not match, then the locator will retry.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
filterHandle(predicate) {
|
||||
return new FilteredLocator(this._clone(), predicate);
|
||||
}
|
||||
/**
|
||||
* Maps the locator using the provided mapper.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
mapHandle(mapper) {
|
||||
return new MappedLocator(this._clone(), mapper);
|
||||
}
|
||||
/**
|
||||
* Clicks the located element.
|
||||
*/
|
||||
click(options) {
|
||||
return firstValueFrom(this.#click(options));
|
||||
}
|
||||
/**
|
||||
* Fills out the input identified by the locator using the provided value. The
|
||||
* type of the input is determined at runtime and the appropriate fill-out
|
||||
* method is chosen based on the type. `contenteditable`, select, textarea and
|
||||
* input elements are supported.
|
||||
*/
|
||||
fill(value, options) {
|
||||
return firstValueFrom(this.#fill(value, options));
|
||||
}
|
||||
/**
|
||||
* Hovers over the located element.
|
||||
*/
|
||||
hover(options) {
|
||||
return firstValueFrom(this.#hover(options));
|
||||
}
|
||||
/**
|
||||
* Scrolls the located element.
|
||||
*/
|
||||
scroll(options) {
|
||||
return firstValueFrom(this.#scroll(options));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class FunctionLocator extends Locator {
|
||||
static create(pageOrFrame, func) {
|
||||
return new FunctionLocator(pageOrFrame, func).setTimeout('getDefaultTimeout' in pageOrFrame
|
||||
? pageOrFrame.getDefaultTimeout()
|
||||
: pageOrFrame.page().getDefaultTimeout());
|
||||
}
|
||||
#pageOrFrame;
|
||||
#func;
|
||||
constructor(pageOrFrame, func) {
|
||||
super();
|
||||
this.#pageOrFrame = pageOrFrame;
|
||||
this.#func = func;
|
||||
}
|
||||
_clone() {
|
||||
return new FunctionLocator(this.#pageOrFrame, this.#func);
|
||||
}
|
||||
_wait(options) {
|
||||
const signal = options?.signal;
|
||||
return defer(() => {
|
||||
return from(this.#pageOrFrame.waitForFunction(this.#func, {
|
||||
timeout: this.timeout,
|
||||
signal,
|
||||
}));
|
||||
}).pipe(throwIfEmpty());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class DelegatedLocator extends Locator {
|
||||
#delegate;
|
||||
constructor(delegate) {
|
||||
super();
|
||||
this.#delegate = delegate;
|
||||
this.copyOptions(this.#delegate);
|
||||
}
|
||||
get delegate() {
|
||||
return this.#delegate;
|
||||
}
|
||||
setTimeout(timeout) {
|
||||
const locator = super.setTimeout(timeout);
|
||||
locator.#delegate = this.#delegate.setTimeout(timeout);
|
||||
return locator;
|
||||
}
|
||||
setVisibility(visibility) {
|
||||
const locator = super.setVisibility(visibility);
|
||||
locator.#delegate = locator.#delegate.setVisibility(visibility);
|
||||
return locator;
|
||||
}
|
||||
setWaitForEnabled(value) {
|
||||
const locator = super.setWaitForEnabled(value);
|
||||
locator.#delegate = this.#delegate.setWaitForEnabled(value);
|
||||
return locator;
|
||||
}
|
||||
setEnsureElementIsInTheViewport(value) {
|
||||
const locator = super.setEnsureElementIsInTheViewport(value);
|
||||
locator.#delegate = this.#delegate.setEnsureElementIsInTheViewport(value);
|
||||
return locator;
|
||||
}
|
||||
setWaitForStableBoundingBox(value) {
|
||||
const locator = super.setWaitForStableBoundingBox(value);
|
||||
locator.#delegate = this.#delegate.setWaitForStableBoundingBox(value);
|
||||
return locator;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class FilteredLocator extends DelegatedLocator {
|
||||
#predicate;
|
||||
constructor(base, predicate) {
|
||||
super(base);
|
||||
this.#predicate = predicate;
|
||||
}
|
||||
_clone() {
|
||||
return new FilteredLocator(this.delegate.clone(), this.#predicate).copyOptions(this);
|
||||
}
|
||||
_wait(options) {
|
||||
return this.delegate._wait(options).pipe(mergeMap(handle => {
|
||||
return from(Promise.resolve(this.#predicate(handle, options?.signal))).pipe(filter(value => {
|
||||
return value;
|
||||
}), map(() => {
|
||||
// SAFETY: It passed the predicate, so this is correct.
|
||||
return handle;
|
||||
}));
|
||||
}), throwIfEmpty());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class MappedLocator extends DelegatedLocator {
|
||||
#mapper;
|
||||
constructor(base, mapper) {
|
||||
super(base);
|
||||
this.#mapper = mapper;
|
||||
}
|
||||
_clone() {
|
||||
return new MappedLocator(this.delegate.clone(), this.#mapper).copyOptions(this);
|
||||
}
|
||||
_wait(options) {
|
||||
return this.delegate._wait(options).pipe(mergeMap(handle => {
|
||||
return from(Promise.resolve(this.#mapper(handle, options?.signal)));
|
||||
}));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class NodeLocator extends Locator {
|
||||
static create(pageOrFrame, selector) {
|
||||
return new NodeLocator(pageOrFrame, selector).setTimeout('getDefaultTimeout' in pageOrFrame
|
||||
? pageOrFrame.getDefaultTimeout()
|
||||
: pageOrFrame.page().getDefaultTimeout());
|
||||
}
|
||||
static createFromHandle(pageOrFrame, handle) {
|
||||
return new NodeLocator(pageOrFrame, handle).setTimeout('getDefaultTimeout' in pageOrFrame
|
||||
? pageOrFrame.getDefaultTimeout()
|
||||
: pageOrFrame.page().getDefaultTimeout());
|
||||
}
|
||||
#pageOrFrame;
|
||||
#selectorOrHandle;
|
||||
constructor(pageOrFrame, selectorOrHandle) {
|
||||
super();
|
||||
this.#pageOrFrame = pageOrFrame;
|
||||
this.#selectorOrHandle = selectorOrHandle;
|
||||
}
|
||||
/**
|
||||
* Waits for the element to become visible or hidden. visibility === 'visible'
|
||||
* means that the element has a computed style, the visibility property other
|
||||
* than 'hidden' or 'collapse' and non-empty bounding box. visibility ===
|
||||
* 'hidden' means the opposite of that.
|
||||
*/
|
||||
#waitForVisibilityIfNeeded = (handle) => {
|
||||
if (!this.visibility) {
|
||||
return EMPTY;
|
||||
}
|
||||
return (() => {
|
||||
switch (this.visibility) {
|
||||
case 'hidden':
|
||||
return defer(() => {
|
||||
return from(handle.isHidden());
|
||||
});
|
||||
case 'visible':
|
||||
return defer(() => {
|
||||
return from(handle.isVisible());
|
||||
});
|
||||
}
|
||||
})().pipe(first(identity), retry({ delay: RETRY_DELAY }), ignoreElements());
|
||||
};
|
||||
_clone() {
|
||||
return new NodeLocator(this.#pageOrFrame,
|
||||
// @ts-expect-error TSC does cannot parse private overloads.
|
||||
this.#selectorOrHandle).copyOptions(this);
|
||||
}
|
||||
_wait(options) {
|
||||
const signal = options?.signal;
|
||||
return defer(() => {
|
||||
if (typeof this.#selectorOrHandle === 'string') {
|
||||
return from(this.#pageOrFrame.waitForSelector(this.#selectorOrHandle, {
|
||||
visible: false,
|
||||
timeout: this._timeout,
|
||||
signal,
|
||||
}));
|
||||
}
|
||||
else {
|
||||
return of(this.#selectorOrHandle);
|
||||
}
|
||||
}).pipe(filter((value) => {
|
||||
return value !== null;
|
||||
}), throwIfEmpty(), this.operators.conditions([this.#waitForVisibilityIfNeeded], signal));
|
||||
}
|
||||
}
|
||||
function checkLocatorArray(locators) {
|
||||
for (const locator of locators) {
|
||||
if (!(locator instanceof Locator)) {
|
||||
throw new Error('Unknown locator for race candidate');
|
||||
}
|
||||
}
|
||||
return locators;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class RaceLocator extends Locator {
|
||||
static create(locators) {
|
||||
const array = checkLocatorArray(locators);
|
||||
return new RaceLocator(array);
|
||||
}
|
||||
#locators;
|
||||
constructor(locators) {
|
||||
super();
|
||||
this.#locators = locators;
|
||||
}
|
||||
_clone() {
|
||||
return new RaceLocator(this.#locators.map(locator => {
|
||||
return locator.clone();
|
||||
})).copyOptions(this);
|
||||
}
|
||||
_wait(options) {
|
||||
return race(...this.#locators.map(locator => {
|
||||
return locator._wait(options);
|
||||
}));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* For observables coming from promises, a delay is needed, otherwise RxJS will
|
||||
* never yield in a permanent failure for a promise.
|
||||
*
|
||||
* We also don't want RxJS to do promise operations to often, so we bump the
|
||||
* delay up to 100ms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const RETRY_DELAY = 100;
|
||||
//# sourceMappingURL=locators.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/api/locators/locators.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BidiOverCdp.d.ts
generated
vendored
Normal file
12
node_modules/puppeteer-core/lib/esm/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/esm/puppeteer/bidi/BidiOverCdp.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/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/esm/puppeteer/bidi/BidiOverCdp.js
generated
vendored
Normal file
146
node_modules/puppeteer-core/lib/esm/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/cjs/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/esm/puppeteer/bidi/BidiOverCdp.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BidiOverCdp.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BidiOverCdp.js","sourceR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AE,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/esm/puppeteer/bidi/BluetoothEmulation.d.ts
generated
vendored
Normal file
18
node_modules/puppeteer-core/lib/esm/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/esm/puppeteer/bidi/BluetoothEmulation.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/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/esm/puppeteer/bidi/BluetoothEmulation.js
generated
vendored
Normal file
38
node_modules/puppeteer-core/lib/esm/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/esm/puppeteer/bidi/BluetoothEmulation.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/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"}
|
||||
66
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Browser.d.ts
generated
vendored
Normal file
66
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @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 { 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;
|
||||
}
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
//# sourceMappingURL=Browser.d.ts.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Browser.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/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,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,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAC,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAC,cAAc,EAAE,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AAI9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,UAAU,EAAE,cAAc,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,eAAe,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,8BAA8B,CA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AAC,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;CAGrC"}
|
||||
334
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Browser.js
generated
vendored
Normal file
334
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Browser.js
generated
vendored
Normal file
@@ -0,0 +1,334 @@
|
||||
/**
|
||||
* @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;
|
||||
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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiBrowser };
|
||||
//# sourceMappingURL=Browser.js.map
|
||||
1
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Browser.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/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/esm/puppeteer/bidi/BrowserConnector.d.ts
generated
vendored
Normal file
18
node_modules/puppeteer-core/lib/esm/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/esm/puppeteer/bidi/BrowserConnector.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/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,CAqBtB"}
|
||||
83
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BrowserConnector.js
generated
vendored
Normal file
83
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BrowserConnector.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @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, 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,
|
||||
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/esm/puppeteer/bidi/BrowserConnector.js.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BrowserConnector.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||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,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"}
|
||||
47
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BrowserContext.d.ts
generated
vendored
Normal file
47
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BrowserContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @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';
|
||||
/**
|
||||
* @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[];
|
||||
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/esm/puppeteer/bidi/BrowserContext.d.ts.map
generated
vendored
Normal file
1
node_modules/puppeteer-core/lib/esm/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,EA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bidi/BrowserContext.js
generated
vendored
Normal file
376
node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BrowserContext.js
generated
vendored
Normal file
@@ -0,0 +1,376 @@
|
||||
/**
|
||||
* @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()];
|
||||
});
|
||||
}
|
||||
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, 'sameParty', 'sourceScheme', 'priority', 'url'),
|
||||
};
|
||||
return await this.userContext.setCookie(bidiCookie, convertCookiesPartitionKeyFromPuppeteerToBiDi(cookie.partitionKey));
|
||||
}));
|
||||
}
|
||||
};
|
||||
})();
|
||||
export { BidiBrowserContext };
|
||||
//# sourceMappingURL=BrowserContext.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user