first commit

This commit is contained in:
2026-06-02 20:24:26 -03:00
commit 7b8a8d722d
3354 changed files with 627959 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { ElementHandle } from '../api/ElementHandle.js';
import { QueryHandler, type QuerySelector } from './QueryHandler.js';
import type { AwaitableIterable } from './types.js';
/**
* @internal
*/
export declare class ARIAQueryHandler extends QueryHandler {
static querySelector: QuerySelector;
static queryAll(element: ElementHandle<Node>, selector: string): AwaitableIterable<ElementHandle<Node>>;
static queryOne: (element: ElementHandle<Node>, selector: string) => Promise<ElementHandle<Node> | null>;
}
//# sourceMappingURL=AriaQueryHandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AriaQueryHandler.d.ts","sourceRoot":"","sources":["../../../src/common/AriaQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAAC,YAAY,EAAE,KAAK,aAAa,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAiDlD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAgB,aAAa,EAAE,aAAa,CAM1C;WAEqB,QAAQ,CAC7B,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,EAC5B,QAAQ,EAAE,MAAM,GACf,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAKzC,OAAgB,QAAQ,GACtB,SAAS,aAAa,CAAC,IAAI,CAAC,EAC5B,UAAU,MAAM,KACf,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAIpC;CACH"}

View File

@@ -0,0 +1,54 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { assert } from '../util/assert.js';
import { AsyncIterableUtil } from '../util/AsyncIterableUtil.js';
import { QueryHandler } from './QueryHandler.js';
const isKnownAttribute = (attribute) => {
return ['name', 'role'].includes(attribute);
};
/**
* The selectors consist of an accessible name to query for and optionally
* further aria attributes on the form `[<attribute>=<value>]`.
* Currently, we only support the `name` and `role` attribute.
* The following examples showcase how the syntax works wrt. querying:
*
* - 'title[role="heading"]' queries for elements with name 'title' and role 'heading'.
* - '[role="image"]' queries for elements with role 'image' and any name.
* - 'label' queries for elements with name 'label' and any role.
* - '[name=""][role="button"]' queries for elements with no name and role 'button'.
*/
const ATTRIBUTE_REGEXP = /\[\s*(?<attribute>\w+)\s*=\s*(?<quote>"|')(?<value>\\.|.*?(?=\k<quote>))\k<quote>\s*\]/g;
const parseARIASelector = (selector) => {
if (selector.length > 10_000) {
throw new Error(`Selector ${selector} is too long`);
}
const queryOptions = {};
const defaultName = selector.replace(ATTRIBUTE_REGEXP, (_, attribute, __, value) => {
assert(isKnownAttribute(attribute), `Unknown aria attribute "${attribute}" in selector`);
queryOptions[attribute] = value;
return '';
});
if (defaultName && !queryOptions.name) {
queryOptions.name = defaultName;
}
return queryOptions;
};
/**
* @internal
*/
export class ARIAQueryHandler extends QueryHandler {
static querySelector = async (node, selector, { ariaQuerySelector }) => {
return await ariaQuerySelector(node, selector);
};
static async *queryAll(element, selector) {
const { name, role } = parseARIASelector(selector);
yield* element.queryAXTree(name, role);
}
static queryOne = async (element, selector) => {
return ((await AsyncIterableUtil.first(this.queryAll(element, selector))) ?? null);
};
}
//# sourceMappingURL=AriaQueryHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AriaQueryHandler.js","sourceRoot":"","sources":["../../../src/common/AriaQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAC,YAAY,EAAqB,MAAM,mBAAmB,C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,IAAI,EAAC,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACjD,KAAK,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAU,QAAQ,GAAG,KAAK,EAC9B,OAA4B,EAC5B,QAAgB,EACqB,EAAE;QACvC,OAAO,CACL,CAAC,MAAM,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAC1E,CAAC;IACJ,CAAC,CAAC"}

View File

@@ -0,0 +1,20 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { Browser } from '../api/Browser.js';
import type { ConnectOptions } from './ConnectOptions.js';
/**
* Users should never call this directly; it's called when calling
* `puppeteer.connect`. This method attaches Puppeteer to an existing browser instance.
*
* @internal
*/
export declare function assertSupportedUrlRestrictions(options: {
allowlist?: string[];
blocklist?: string[];
protocol?: string;
}): void;
export declare function _connectToBrowser(options: ConnectOptions): Promise<Browser>;
//# sourceMappingURL=BrowserConnector.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BrowserConnector.d.ts","sourceRoot":"","sources":["../../../src/common/BrowserConnector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAQ/C,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AASxD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE;IACtD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,IAAI,CAYP;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,CAAC,CAoBlB"}

View File

@@ -0,0 +1,139 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { _connectToBiDiBrowser } from '../bidi/BrowserConnector.js';
import { _connectToCdpBrowser } from '../cdp/BrowserConnector.js';
import { environment, isNode } from '../environment.js';
import { assert } from '../util/assert.js';
import { isErrorLike } from '../util/ErrorLike.js';
const getWebSocketTransportClass = async () => {
return isNode
? (await import('../node/NodeWebSocketTransport.js')).NodeWebSocketTransport
: (await import('../common/BrowserWebSocketTransport.js'))
.BrowserWebSocketTransport;
};
/**
* Users should never call this directly; it's called when calling
* `puppeteer.connect`. This method attaches Puppeteer to an existing browser instance.
*
* @internal
*/
export function assertSupportedUrlRestrictions(options) {
if (options.blocklist && options.allowlist) {
throw new Error('Cannot specify both blocklist and allowlist');
}
if (options.protocol === 'webDriverBiDi' &&
(options.blocklist || options.allowlist)) {
throw new Error('blocklist and allowlist are only supported with the CDP protocol');
}
}
export async function _connectToBrowser(options) {
assertSupportedUrlRestrictions(options);
const { connectionTransport, endpointUrl } = await getConnectionTransport(options);
if (options.protocol === 'webDriverBiDi') {
const bidiBrowser = await _connectToBiDiBrowser(connectionTransport, endpointUrl, options);
return bidiBrowser;
}
else {
const cdpBrowser = await _connectToCdpBrowser(connectionTransport, endpointUrl, options);
return cdpBrowser;
}
}
/**
* Establishes a websocket connection by given options and returns both transport and
* endpoint url the transport is connected to.
*/
async function getConnectionTransport(options) {
const { browserWSEndpoint, browserURL, channel, transport, headers = {}, } = options;
assert(Number(!!browserWSEndpoint) +
Number(!!browserURL) +
Number(!!transport) +
Number(!!channel) ===
1, 'Exactly one of browserWSEndpoint, browserURL, transport or channel must be passed to puppeteer.connect');
if (transport) {
return { connectionTransport: transport, endpointUrl: '' };
}
else if (browserWSEndpoint) {
const WebSocketClass = await getWebSocketTransportClass();
const connectionTransport = await WebSocketClass.create(browserWSEndpoint, headers);
return {
connectionTransport: connectionTransport,
endpointUrl: browserWSEndpoint,
};
}
else if (browserURL) {
const connectionURL = await getWSEndpoint(browserURL);
const WebSocketClass = await getWebSocketTransportClass();
const connectionTransport = await WebSocketClass.create(connectionURL);
return {
connectionTransport: connectionTransport,
endpointUrl: connectionURL,
};
}
else if (options.channel && isNode) {
const { detectBrowserPlatform, resolveDefaultUserDataDir, Browser } = await import('@puppeteer/browsers');
const platform = detectBrowserPlatform();
if (!platform) {
throw new Error('Could not detect required browser platform');
}
const { convertPuppeteerChannelToBrowsersChannel } = await import('../node/LaunchOptions.js');
const { join } = await import('node:path');
const userDataDir = resolveDefaultUserDataDir(Browser.CHROME, platform, convertPuppeteerChannelToBrowsersChannel(options.channel));
const portPath = join(userDataDir, 'DevToolsActivePort');
try {
const fileContent = await environment.value.fs.promises.readFile(portPath, 'ascii');
const [rawPort, rawPath] = fileContent
.split('\n')
.map(line => {
return line.trim();
})
.filter(line => {
return !!line;
});
if (!rawPort || !rawPath) {
throw new Error(`Invalid DevToolsActivePort '${fileContent}' found`);
}
const port = parseInt(rawPort, 10);
if (isNaN(port) || port <= 0 || port > 65535) {
throw new Error(`Invalid port '${rawPort}' found`);
}
const browserWSEndpoint = `ws://localhost:${port}${rawPath}`;
const WebSocketClass = await getWebSocketTransportClass();
const connectionTransport = await WebSocketClass.create(browserWSEndpoint, headers);
return {
connectionTransport: connectionTransport,
endpointUrl: browserWSEndpoint,
};
}
catch (error) {
throw new Error(`Could not find DevToolsActivePort for ${options.channel} at ${portPath}`, {
cause: error,
});
}
}
throw new Error('Invalid connection options');
}
async function getWSEndpoint(browserURL) {
const endpointURL = new URL('/json/version', browserURL);
try {
const result = await globalThis.fetch(endpointURL.toString(), {
method: 'GET',
});
if (!result.ok) {
throw new Error(`HTTP ${result.statusText}`);
}
const data = await result.json();
return data.webSocketDebuggerUrl;
}
catch (error) {
if (isErrorLike(error)) {
error.message =
`Failed to fetch browser webSocket URL from ${endpointURL}: ` +
error.message;
}
throw error;
}
}
//# sourceMappingURL=BrowserConnector.js.map

View File

@@ -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G,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,KAAK,CAAC,OAAO;gBACX,8CAA8C,WAAW,IAAI;oBAC7D,KAAK,CAAC,OAAO,CAAC;QAClB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { ConnectionTransport } from './ConnectionTransport.js';
/**
* @internal
*/
export declare class BrowserWebSocketTransport implements ConnectionTransport {
#private;
static create(url: string): Promise<BrowserWebSocketTransport>;
onmessage?: (message: string) => void;
onclose?: () => void;
constructor(ws: WebSocket);
send(message: string): void;
close(): void;
}
//# sourceMappingURL=BrowserWebSocketTransport.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BrowserWebSocketTransport.d.ts","sourceRoot":"","sources":["../../../src/common/BrowserWebSocketTransport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAGlE;;GAEG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;;IACnE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAY9D,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;gBAET,EAAE,EAAE,SAAS;IAgBzB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,IAAI,IAAI;CAGd"}

View File

@@ -0,0 +1,40 @@
import { debugError } from './util.js';
/**
* @internal
*/
export class BrowserWebSocketTransport {
static create(url) {
return new Promise((resolve, reject) => {
const ws = new WebSocket(url);
ws.addEventListener('open', () => {
return resolve(new BrowserWebSocketTransport(ws));
});
ws.addEventListener('error', reject);
});
}
#ws;
onmessage;
onclose;
constructor(ws) {
this.#ws = ws;
this.#ws.addEventListener('message', event => {
if (this.onmessage) {
this.onmessage.call(null, event.data);
}
});
this.#ws.addEventListener('close', () => {
if (this.onclose) {
this.onclose.call(null);
}
});
// Silently log all errors - we don't know what to do with them.
this.#ws.addEventListener('error', debugError);
}
send(message) {
this.#ws.send(message);
}
close() {
this.#ws.close();
}
}
//# sourceMappingURL=BrowserWebSocketTransport.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BrowserWebSocketTransport.js","sourceRoot":"","sources":["../../../src/common/BrowserWebSocketTransport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACpC,MAAM,CAAC,MAAM,CAAC,GAAW;QACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;YAE9B,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;gBAC/B,OAAO,OAAO,CAAC,IAAI,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAY;IACf,SAAS,CAA6B;IACtC,OAAO,CAAc;IAErB,YAAY,EAAa;QACvB,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YAC3C,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACtC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,gEAAgE;QAChE,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACF"}

View File

@@ -0,0 +1,15 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { PuppeteerInjectedUtil } from '../injected/injected.js';
import { QueryHandler } from './QueryHandler.js';
/**
* @internal
*/
export declare class CSSQueryHandler extends QueryHandler {
static querySelector: (element: Node, selector: string, { cssQuerySelector }: PuppeteerInjectedUtil) => Node | null;
static querySelectorAll: (element: Node, selector: string, { cssQuerySelectorAll }: PuppeteerInjectedUtil) => Iterable<Node>;
}
//# sourceMappingURL=CSSQueryHandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSQueryHandler.d.ts","sourceRoot":"","sources":["../../../src/common/CSSQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,OAAgB,aAAa,GAC3B,SAAS,IAAI,EACb,UAAU,MAAM,EAChB,sBAAoB,qBAAqB,KACxC,IAAI,GAAG,IAAI,CAEZ;IACF,OAAgB,gBAAgB,GAC9B,SAAS,IAAI,EACb,UAAU,MAAM,EAChB,yBAAuB,qBAAqB,KAC3C,QAAQ,CAAC,IAAI,CAAC,CAEf;CACH"}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { QueryHandler } from './QueryHandler.js';
/**
* @internal
*/
export class CSSQueryHandler extends QueryHandler {
static querySelector = (element, selector, { cssQuerySelector }) => {
return cssQuerySelector(element, selector);
};
static querySelectorAll = (element, selector, { cssQuerySelectorAll }) => {
return cssQuerySelectorAll(element, selector);
};
}
//# sourceMappingURL=CSSQueryHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CSSQueryHandler.js","sourceRoot":"","sources":["../../../src/common/CSSQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,YAAY;IAC/C,MAAM,CAAU,aAAa,GAAG,CAC9B,OAAa,EACb,QAAgB,EAChB,EAAC,gBAAgB,EAAwB,EAC5B,EAAE;QACf,OAAO,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC;IACF,MAAM,CAAU,gBAAgB,GAAG,CACjC,OAAa,EACb,QAAgB,EAChB,EAAC,mBAAmB,EAAwB,EAC5B,EAAE;QAClB,OAAO,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC,CAAC"}

View File

@@ -0,0 +1,41 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { GetIdFn } from '../util/incremental-id-generator.js';
import { ProtocolError } from './Errors.js';
/**
* Manages callbacks and their IDs for the protocol request/response communication.
*
* @internal
*/
export declare class CallbackRegistry {
#private;
constructor(idGenerator: GetIdFn);
has(id: number): boolean;
create(label: string, timeout: number | undefined, request: (id: number) => void): Promise<unknown>;
reject(id: number, message: string, originalMessage?: string): void;
rejectRaw(id: number, error: object): void;
_reject(callback: Callback, errorMessage: string | ProtocolError, originalMessage?: string): void;
resolve(id: number, value: unknown): void;
clear(): void;
/**
* @internal
*/
getPendingProtocolErrors(): Error[];
}
/**
* @internal
*/
export declare class Callback {
#private;
constructor(id: number, label: string, timeout?: number);
resolve(value: unknown): void;
reject(error: Error): void;
get id(): number;
get promise(): Promise<unknown>;
get error(): ProtocolError;
get label(): string;
}
//# sourceMappingURL=CallbackRegistry.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CallbackRegistry.d.ts","sourceRoot":"","sources":["../../../src/common/CallbackRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EAAC,aAAa,EAAmB,MAAM,aAAa,CAAC;AAG5D;;;;GAIG;AACH,qBAAa,gBAAgB;;gBAIf,WAAW,EAAE,OAAO;IAIhC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAC5B,OAAO,CAAC,OAAO,CAAC;IAoBnB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI;IAQnE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ1C,OAAO,CACL,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,MAAM,GAAG,aAAa,EACpC,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI;IAqBP,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAQzC,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,wBAAwB,IAAI,KAAK,EAAE;CAWpC;AACD;;GAEG;AAEH,qBAAa,QAAQ;;gBAOP,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAevD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK7B,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK1B,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAE9B;IAED,IAAI,KAAK,IAAI,aAAa,CAEzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}

View File

@@ -0,0 +1,136 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { Deferred } from '../util/Deferred.js';
import { rewriteError } from '../util/ErrorLike.js';
import { ProtocolError, TargetCloseError } from './Errors.js';
import { debugError } from './util.js';
/**
* Manages callbacks and their IDs for the protocol request/response communication.
*
* @internal
*/
export class CallbackRegistry {
#callbacks = new Map();
#idGenerator;
constructor(idGenerator) {
this.#idGenerator = idGenerator;
}
has(id) {
return this.#callbacks.has(id);
}
create(label, timeout, request) {
const callback = new Callback(this.#idGenerator(), label, timeout);
this.#callbacks.set(callback.id, callback);
try {
request(callback.id);
}
catch (error) {
// We still throw sync errors synchronously and clean up the scheduled
// callback.
callback.promise.catch(debugError).finally(() => {
this.#callbacks.delete(callback.id);
});
callback.reject(error);
throw error;
}
// Must only have sync code up until here.
return callback.promise.finally(() => {
this.#callbacks.delete(callback.id);
});
}
reject(id, message, originalMessage) {
const callback = this.#callbacks.get(id);
if (!callback) {
return;
}
this._reject(callback, message, originalMessage);
}
rejectRaw(id, error) {
const callback = this.#callbacks.get(id);
if (!callback) {
return;
}
callback.reject(error);
}
_reject(callback, errorMessage, originalMessage) {
let error;
let message;
if (errorMessage instanceof ProtocolError) {
error = errorMessage;
error.cause = callback.error;
message = errorMessage.message;
}
else {
error = callback.error;
message = errorMessage;
}
callback.reject(rewriteError(error, `Protocol error (${callback.label}): ${message}`, originalMessage));
}
resolve(id, value) {
const callback = this.#callbacks.get(id);
if (!callback) {
return;
}
callback.resolve(value);
}
clear() {
for (const callback of this.#callbacks.values()) {
// TODO: probably we can accept error messages as params.
this._reject(callback, new TargetCloseError('Target closed'));
}
this.#callbacks.clear();
}
/**
* @internal
*/
getPendingProtocolErrors() {
const result = [];
for (const callback of this.#callbacks.values()) {
result.push(new Error(`${callback.label} timed out. Trace: ${callback.error.stack}`));
}
return result;
}
}
/**
* @internal
*/
export class Callback {
#id;
#error = new ProtocolError();
#deferred = Deferred.create();
#timer;
#label;
constructor(id, label, timeout) {
this.#id = id;
this.#label = label;
if (timeout) {
this.#timer = setTimeout(() => {
this.#deferred.reject(rewriteError(this.#error, `${label} timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.`));
}, timeout);
}
}
resolve(value) {
clearTimeout(this.#timer);
this.#deferred.resolve(value);
}
reject(error) {
clearTimeout(this.#timer);
this.#deferred.reject(error);
}
get id() {
return this.#id;
}
get promise() {
return this.#deferred.valueOrThrow();
}
get error() {
return this.#error;
}
get label() {
return this.#label;
}
}
//# sourceMappingURL=CallbackRegistry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CallbackRegistry.js","sourceRoot":"","sources":["../../../src/common/CallbackRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AAErC;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Y,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}

View File

@@ -0,0 +1,193 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { SupportedBrowser } from './SupportedBrowser.js';
/**
* Defines experiment options for Puppeteer.
*
* See individual properties for more information.
*
* @public
*/
export type ExperimentsConfiguration = Record<string, never>;
/**
* Defines options to configure Puppeteer's behavior during installation and
* runtime.
*
* See individual properties for more information.
*
* @public
*/
export interface Configuration {
/**
* Defines the directory to be used by Puppeteer for caching.
*
* Can be overridden by `PUPPETEER_CACHE_DIR`.
*
* @defaultValue `path.join(os.homedir(), '.cache', 'puppeteer')`
*/
cacheDirectory?: string;
/**
* Specifies an executable path to be used in
* {@link PuppeteerNode.launch | puppeteer.launch}.
*
* Can be overridden by `PUPPETEER_EXECUTABLE_PATH`.
*
* @defaultValue **Auto-computed.**
*/
executablePath?: string;
/**
* Specifies which browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_BROWSER`.
*
* @defaultValue `chrome`
*/
defaultBrowser?: SupportedBrowser;
/**
* Defines the directory to be used by Puppeteer for creating temporary files.
*
* Can be overridden by `PUPPETEER_TMP_DIR`.
*
* @defaultValue `os.tmpdir()`
*/
temporaryDirectory?: string;
/**
* Tells Puppeteer to not download during installation.
*
* Can be overridden by `PUPPETEER_SKIP_DOWNLOAD`.
*/
skipDownload?: boolean;
/**
* Tells Puppeteer to log at the given level.
*
* @defaultValue `warn`
*/
logLevel?: 'silent' | 'error' | 'warn';
/**
* Defines experimental options for Puppeteer.
*/
experiments?: ExperimentsConfiguration;
chrome?: ChromeSettings;
['chrome-headless-shell']?: ChromeHeadlessShellSettings;
firefox?: FirefoxSettings;
}
/**
* @public
*/
export interface ChromeSettings {
/**
* Tells Puppeteer to not download the browser during installation.
*
* Can be overridden by `PUPPETEER_CHROME_SKIP_DOWNLOAD`.
*
* @defaultValue false
*/
skipDownload?: boolean;
/**
* Specifies the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_CHROME_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*
* @defaultValue https://storage.googleapis.com/chrome-for-testing-public
*/
downloadBaseUrl?: string;
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_CHROME_VERSION`
* or `PUPPETEER_SKIP_CHROME_DOWNLOAD`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @example 119.0.6045.105
* @defaultValue The pinned browser version supported by the current Puppeteer
* version.
*/
version?: string;
}
/**
* @public
*/
export interface ChromeHeadlessShellSettings {
/**
* Tells Puppeteer to not download the browser during installation.
*
* Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_SKIP_DOWNLOAD`
* or `PUPPETEER_SKIP_CHROME_HEADLESS_SHELL_DOWNLOAD`.
*
* @defaultValue false
*/
skipDownload?: boolean;
/**
* Specifies the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*
* @defaultValue https://storage.googleapis.com/chrome-for-testing-public
*/
downloadBaseUrl?: string;
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_CHROME_HEADLESS_SHELL_VERSION`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @example 119.0.6045.105
* @defaultValue The pinned browser version supported by the current Puppeteer
* version.
*/
version?: string;
}
/**
* @public
*/
export interface FirefoxSettings {
/**
* Tells Puppeteer to not download the browser during installation.
*
* Can be overridden by `PUPPETEER_FIREFOX_SKIP_DOWNLOAD`.
*
* @defaultValue true
*/
skipDownload?: boolean;
/**
* Specifies the URL prefix that is used to download the browser.
*
* Can be overridden by `PUPPETEER_FIREFOX_DOWNLOAD_BASE_URL`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*
* @defaultValue https://archive.mozilla.org/pub/firefox/releases
*/
downloadBaseUrl?: string;
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_FIREFOX_VERSION`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @example stable_129.0
* @defaultValue The pinned browser version supported by the current Puppeteer
* version.
*/
version?: string;
}
//# sourceMappingURL=Configuration.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../../src/common/Configuration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IACvC;;OAEG;IACH,WAAW,CAAC,EAAE,wBAAwB,CAAC;IAEvC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,CAAC,uBAAuB,CAAC,CAAC,EAAE,2BAA2B,CAAC;IACxD,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}

View File

@@ -0,0 +1,7 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=Configuration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/common/Configuration.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}

View File

@@ -0,0 +1,203 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { Session } from 'webdriver-bidi-protocol';
import type { IsPageTargetCallback, TargetFilterCallback } from '../api/Browser.js';
import type { ConnectionTransport } from './ConnectionTransport.js';
import type { DownloadBehavior } from './DownloadBehavior.js';
import type { Viewport } from './Viewport.js';
/**
* @public
*/
export type ProtocolType = 'cdp' | 'webDriverBiDi';
/**
* @public
*/
export type SupportedWebDriverCapability = Exclude<Session.CapabilityRequest, 'unhandledPromptBehavior' | 'acceptInsecureCerts'>;
/**
* WebDriver BiDi capabilities that are not set by Puppeteer itself.
*
* @public
*/
export interface SupportedWebDriverCapabilities {
firstMatch?: SupportedWebDriverCapability[];
alwaysMatch?: SupportedWebDriverCapability;
}
/**
* @public
*/
export type ChromeReleaseChannel = 'chrome' | 'chrome-beta' | 'chrome-canary' | 'chrome-dev';
/**
* Generic browser options that can be passed when launching any browser or when
* connecting to an existing browser instance.
* @public
*/
export interface ConnectOptions {
/**
* Whether to ignore HTTPS errors during navigation.
* @defaultValue `false`
*/
acceptInsecureCerts?: boolean;
/**
* If specified, puppeteer looks for an open WebSocket at the well-known
* default user data directory for the specified channel and attempts to
* connect to it using ws://localhost:$ActivePort/devtools/browser. Only works
* for Chrome and when run in Node.js.
*
* This option is experimental when used with puppeteer.connect().
*
* @experimental
*/
channel?: ChromeReleaseChannel;
/**
* Experimental setting to disable monitoring network events by default. When
* set to `false`, parts of Puppeteer that depend on network events would not
* work such as HTTPRequest and HTTPResponse.
*
* @experimental
* @defaultValue `true`
*/
networkEnabled?: boolean;
/**
* Experimental setting to disable monitoring issue events by default.
*
* @experimental
* @defaultValue `true`
*/
issuesEnabled?: boolean;
/**
* Sets the viewport for each page.
*
* @defaultValue '\{width: 800, height: 600\}'
*/
defaultViewport?: Viewport | null;
/**
* Sets the download behavior for the context.
*/
downloadBehavior?: DownloadBehavior;
/**
* Slows down Puppeteer operations by the specified amount of milliseconds to
* aid debugging.
*/
slowMo?: number;
/**
* Callback to decide if Puppeteer should connect to a given target or not.
*/
targetFilter?: TargetFilterCallback;
/**
* @internal
*/
_isPageTarget?: IsPageTargetCallback;
/**
* Whether to handle the DevTools windows as pages in Puppeteer. Supported
* only in Chrome with CDP.
*
* @defaultValue 'false'
*/
handleDevToolsAsPage?: boolean;
/**
* @defaultValue Determined at run time:
*
* - Launching Chrome - 'cdp'.
*
* - Launching Firefox - 'webDriverBiDi'.
*
* - Connecting to a browser - 'cdp'.
*
* @public
*/
protocol?: ProtocolType;
/**
* Timeout setting for individual protocol (CDP) calls.
*
* @defaultValue `180_000`
*/
protocolTimeout?: number;
browserWSEndpoint?: string;
browserURL?: string;
transport?: ConnectionTransport;
/**
* @internal
*
* Custom ID generator for CDP / BiDi messages. Useful if the same transport
* is shared for multiple connections.
*/
idGenerator?: () => number;
/**
* Headers to use for the web socket connection.
* @remarks
* Only works in the Node.js environment.
*/
headers?: Record<string, string>;
/**
* WebDriver BiDi capabilities passed to BiDi `session.new`.
*
* @remarks
* Only works for `protocol="webDriverBiDi"` and {@link Puppeteer.connect}.
*/
capabilities?: SupportedWebDriverCapabilities;
/**
* A list of URL patterns to block.
*
* This option allows you to restrict the browser from accessing specific
* URLs or origins. It uses the standard [URLPattern](https://urlpattern.spec.whatwg.org/) API to match URLs.
*
* When connecting to an existing browser, Puppeteer will silently detach from any
* already open targets that violate the patterns.
*
* For any network requests made by the browser (including navigations and
* subresources like images or scripts), the request will fail with an error
* if the URL matches a blocked pattern.
*
* @example Pattern to block a specific domain:
* `*://example.com/*`
*
* @example Pattern to block all subdomains:
* `*://*.evil.com/*`
*
* @remarks
* Currently only supported for CDP connections.
*
* Inner `<iframe>` content loading is currently not blocked.
*
* Cannot be used along with {@link ConnectOptions.allowlist}.
*
* @experimental
*/
blocklist?: string[];
/**
* A list of URL patterns to allow.
*
* **Requires Chrome 149+.**
*
* This option allows you to restrict the browser from accessing any URLs
* except for those that match the patterns in the allowList.
* It uses the standard [URLPattern](https://urlpattern.spec.whatwg.org/) API to match URLs.
*
* When connecting to an existing browser, Puppeteer will silently detach from any
* already open targets that violate the patterns.
*
* For any network requests made by the browser (including navigations and
* subresources like images or scripts), the request will fail with an error
* if the URL does not match any pattern in the allowlist.
*
* @example Pattern to allow a specific domain:
* `*://example.com/*`
*
* @example Pattern to allow all subdomains:
* `*://*.example.com/*`
*
* @remarks
* Currently only supported for CDP connections.
*
* Inner `<iframe>` content loading is currently not blocked.
*
* Cannot be used along with {@link ConnectOptions.blocklist}.
*
* @experimental
*/
allowlist?: string[];
}
//# sourceMappingURL=ConnectOptions.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConnectOptions.d.ts","sourceRoot":"","sources":["../../../src/common/ConnectOptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,eAAe,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAChD,OAAO,CAAC,iBAAiB,EACzB,yBAAyB,GAAG,qBAAqB,CAClD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;IAC5C,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,GACR,aAAa,GACb,eAAe,GACf,YAAY,CAAC;AAEjB;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC;;OAEG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC;IAErC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IAE3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,8BAA8B,CAAC;IAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB"}

View File

@@ -0,0 +1,7 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=ConnectOptions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConnectOptions.js","sourceRoot":"","sources":["../../../src/common/ConnectOptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}

View File

@@ -0,0 +1,15 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @public
*/
export interface ConnectionTransport {
send(message: string): void;
close(): void;
onmessage?: (message: string) => void;
onclose?: () => void;
}
//# sourceMappingURL=ConnectionTransport.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConnectionTransport.d.ts","sourceRoot":"","sources":["../../../src/common/ConnectionTransport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,IAAI,IAAI,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB"}

View File

@@ -0,0 +1,7 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=ConnectionTransport.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConnectionTransport.js","sourceRoot":"","sources":["../../../src/common/ConnectionTransport.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}

View File

@@ -0,0 +1,74 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { Protocol } from 'devtools-protocol';
import type { Frame } from '../api/Frame.js';
import type { JSHandle } from '../api/JSHandle.js';
/**
* @public
*/
export interface ConsoleMessageLocation {
/**
* URL of the resource if known or `undefined` otherwise.
*/
url?: string;
/**
* 0-based line number in the resource if known or `undefined` otherwise.
*/
lineNumber?: number;
/**
* 0-based column number in the resource if known or `undefined` otherwise.
*/
columnNumber?: number;
}
/**
* The supported types for console messages.
* @public
*/
export type ConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warn' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd' | 'verbose';
/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
export declare class ConsoleMessage {
#private;
/**
* @internal
*/
constructor(type: ConsoleMessageType, text: string, args: JSHandle[], stackTraceLocations: ConsoleMessageLocation[], frame?: Frame, rawStackTrace?: Protocol.Runtime.StackTrace, targetId?: string);
/**
* The type of the console message.
*/
type(): ConsoleMessageType;
/**
* The text of the console message.
*/
text(): string;
/**
* An array of arguments passed to the console.
*/
args(): JSHandle[];
/**
* The location of the console message.
*/
location(): ConsoleMessageLocation;
/**
* The array of locations on the stack of the console message.
*/
stackTrace(): ConsoleMessageLocation[];
/**
* The underlying protocol stack trace if available.
*
* @internal
*/
_rawStackTrace(): Protocol.Runtime.StackTrace | undefined;
/**
* The targetId from which this console message originated.
*
* @internal
*/
_targetId(): string | undefined;
}
//# sourceMappingURL=ConsoleMessage.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConsoleMessage.d.ts","sourceRoot":"","sources":["../../../src/common/ConsoleMessage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC1B,KAAK,GACL,OAAO,GACP,MAAM,GACN,OAAO,GACP,MAAM,GACN,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,YAAY,GACZ,qBAAqB,GACrB,UAAU,GACV,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,OAAO,GACP,SAAS,GACT,SAAS,CAAC;AAEd;;;GAGG;AACH,qBAAa,cAAc;;IASzB;;OAEG;gBAED,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EAAE,EAChB,mBAAmB,EAAE,sBAAsB,EAAE,EAC7C,KAAK,CAAC,EAAE,KAAK,EACb,aAAa,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,EAC3C,QAAQ,CAAC,EAAE,MAAM;IAWnB;;OAEG;IACH,IAAI,IAAI,kBAAkB;IAI1B;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,IAAI,IAAI,QAAQ,EAAE;IAIlB;;OAEG;IACH,QAAQ,IAAI,sBAAsB;IAOlC;;OAEG;IACH,UAAU,IAAI,sBAAsB,EAAE;IAItC;;;;OAIG;IACH,cAAc,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,SAAS;IAIzD;;;;OAIG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS;CAGhC"}

View File

@@ -0,0 +1,78 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
export class ConsoleMessage {
#type;
#text;
#args;
#stackTraceLocations;
#frame;
#rawStackTrace;
#targetId;
/**
* @internal
*/
constructor(type, text, args, stackTraceLocations, frame, rawStackTrace, targetId) {
this.#type = type;
this.#text = text;
this.#args = args;
this.#stackTraceLocations = stackTraceLocations;
this.#frame = frame;
this.#rawStackTrace = rawStackTrace;
this.#targetId = targetId;
}
/**
* The type of the console message.
*/
type() {
return this.#type;
}
/**
* The text of the console message.
*/
text() {
return this.#text;
}
/**
* An array of arguments passed to the console.
*/
args() {
return this.#args;
}
/**
* The location of the console message.
*/
location() {
return (this.#stackTraceLocations[0] ??
(this.#frame ? { url: this.#frame.url() } : {}));
}
/**
* The array of locations on the stack of the console message.
*/
stackTrace() {
return this.#stackTraceLocations;
}
/**
* The underlying protocol stack trace if available.
*
* @internal
*/
_rawStackTrace() {
return this.#rawStackTrace;
}
/**
* The targetId from which this console message originated.
*
* @internal
*/
_targetId() {
return this.#targetId;
}
}
//# sourceMappingURL=ConsoleMessage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConsoleMessage.js","sourceRoot":"","sources":["../../../src/common/ConsoleMessage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoDH;;;GAGG;AACH,MAAM,OAAO,cAAc;IACzB,KAAK,CAAqB;IAC1B,KAAK,CAAS;IACd,KAAK,CAAa;IAClB,oBAAoB,CAA2B;IAC/C,MAAM,CAAS;IACf,cAAc,CAA+B;IAC7C,SAAS,CAAU;IAEnB;;OAEG;IACH,YACE,IAAwB,EACxB,IAAY,EACZ,IAAgB,EAChB,mBAA6C,EAC7C,KAAa,EACb,aAA2C,EAC3C,QAAiB;QAEjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;QAChD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,CACL,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC5B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}

View File

@@ -0,0 +1,226 @@
/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* Represents the cookie's 'SameSite' status:
* https://tools.ietf.org/html/draft-west-first-party-cookies
*
* @public
*/
export type CookieSameSite = 'Strict' | 'Lax' | 'None' | 'Default';
/**
* Represents the cookie's 'Priority' status:
* https://tools.ietf.org/html/draft-west-cookie-priority-00
*
* @public
*/
export type CookiePriority = 'Low' | 'Medium' | 'High';
/**
* Represents the source scheme of the origin that originally set the cookie. A value of
* "Unset" allows protocol clients to emulate legacy cookie scope for the scheme.
* This is a temporary ability and it will be removed in the future.
*
* @public
*/
export type CookieSourceScheme = 'Unset' | 'NonSecure' | 'Secure';
/**
* Represents a cookie partition key in Chrome.
*
* @public
*/
export interface CookiePartitionKey {
/**
* The site of the top-level URL the browser was visiting at the start of the request
* to the endpoint that set the cookie.
*
* In Chrome, maps to the CDP's `topLevelSite` partition key.
*/
sourceOrigin: string;
/**
* Indicates if the cookie has any ancestors that are cross-site to
* the topLevelSite.
*
* Supported only in Chrome.
*/
hasCrossSiteAncestor?: boolean;
}
/**
* Represents a cookie object.
*
* @public
*/
export interface Cookie extends CookieData {
/**
* Cookie path.
*/
path: string;
/**
* Cookie expiration date as the number of seconds since the UNIX epoch. Set to `-1` for
* session cookies
*/
expires: number;
/**
* Cookie size.
*/
size: number;
/**
* True if cookie is secure.
*/
secure: boolean;
/**
* True in case of session cookie.
*/
session: boolean;
/**
* True if cookie partition key is opaque. Supported only in Chrome.
*/
partitionKeyOpaque?: boolean;
}
/**
* Cookie parameter object used to set cookies in the page-level cookies
* API.
*
* @public
*/
export interface CookieParam {
/**
* Cookie name.
*/
name: string;
/**
* Cookie value.
*/
value: string;
/**
* The request-URI to associate with the setting of the cookie. This value can affect
* the default domain, path, and source scheme values of the created cookie.
*/
url?: string;
/**
* Cookie domain.
*/
domain?: string;
/**
* Cookie path.
*/
path?: string;
/**
* True if cookie is secure.
*/
secure?: boolean;
/**
* True if cookie is http-only.
*/
httpOnly?: boolean;
/**
* Cookie SameSite type.
*/
sameSite?: CookieSameSite;
/**
* Cookie expiration date, session cookie if not set
*/
expires?: number;
/**
* Cookie Priority. Supported only in Chrome.
*/
priority?: CookiePriority;
/**
* Cookie source scheme type. Supported only in Chrome.
*/
sourceScheme?: CookieSourceScheme;
/**
* Cookie partition key. In Chrome, it matches the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin in the
* {@link https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey | PartitionKey }.
*/
partitionKey?: CookiePartitionKey | string;
}
/**
* Cookie parameter object used to set cookies in the browser-level cookies
* API.
*
* @public
*/
export interface CookieData {
/**
* Cookie name.
*/
name: string;
/**
* Cookie value.
*/
value: string;
/**
* Cookie domain.
*/
domain: string;
/**
* Cookie path.
*/
path?: string;
/**
* True if cookie is secure.
*/
secure?: boolean;
/**
* True if cookie is http-only.
*/
httpOnly?: boolean;
/**
* Cookie SameSite type.
*/
sameSite?: CookieSameSite;
/**
* Cookie expiration date, session cookie if not set
*/
expires?: number;
/**
* Cookie Priority. Supported only in Chrome.
*/
priority?: CookiePriority;
/**
* Cookie source scheme type. Supported only in Chrome.
*/
sourceScheme?: CookieSourceScheme;
/**
* Cookie partition key. In Chrome, it matches the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin in the
* {@link https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey | PartitionKey }.
*/
partitionKey?: CookiePartitionKey | string;
}
/**
* @public
*/
export interface DeleteCookiesRequest {
/**
* Name of the cookies to remove.
*/
name: string;
/**
* If specified, deletes all the cookies with the given name where domain and path match
* provided URL. Otherwise, deletes only cookies related to the current page's domain.
*/
url?: string;
/**
* If specified, deletes only cookies with the exact domain.
*/
domain?: string;
/**
* If specified, deletes only cookies with the exact path.
*/
path?: string;
/**
* If specified, deletes cookies in the given partition key. In
* Chrome, partitionKey matches the top-level site the partitioned
* cookie is available in.
* In Firefox, it matches the source origin in the
* {@link https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey | PartitionKey }.
*/
partitionKey?: CookiePartitionKey | string;
}
//# sourceMappingURL=Cookie.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Cookie.d.ts","sourceRoot":"","sources":["../../../src/common/Cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,CAAC;AAElE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,E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,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC;CAC5C"}

View File

@@ -0,0 +1,7 @@
/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=Cookie.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Cookie.js","sourceRoot":"","sources":["../../../src/common/Cookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}

View File

@@ -0,0 +1,75 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { QueryHandler } from './QueryHandler.js';
/**
* @public
*/
export interface CustomQueryHandler {
/**
* Searches for a {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Node} matching the given `selector` from {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | node}.
*/
queryOne?: (node: Node, selector: string) => Node | null;
/**
* Searches for some {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | Nodes} matching the given `selector` from {@link https://developer.mozilla.org/en-US/docs/Web/API/Node | node}.
*/
queryAll?: (node: Node, selector: string) => Iterable<Node>;
}
/**
* The registry of {@link CustomQueryHandler | custom query handlers}.
*
* @example
*
* ```ts
* Puppeteer.customQueryHandlers.register('lit', { … });
* const aHandle = await page.$('lit/…');
* ```
*
* @internal
*/
export declare class CustomQueryHandlerRegistry {
#private;
get(name: string): typeof QueryHandler | undefined;
/**
* Registers a {@link CustomQueryHandler | custom query handler}.
*
* @remarks
* After registration, the handler can be used everywhere where a selector is
* expected by prepending the selection string with `<name>/`. The name is
* only allowed to consist of lower- and upper case latin letters.
*
* @example
*
* ```ts
* Puppeteer.customQueryHandlers.register('lit', { … });
* const aHandle = await page.$('lit/…');
* ```
*
* @param name - Name to register under.
* @param queryHandler - {@link CustomQueryHandler | Custom query handler} to
* register.
*/
register(name: string, handler: CustomQueryHandler): void;
/**
* Unregisters the {@link CustomQueryHandler | custom query handler} for the
* given name.
*
* @throws `Error` if there is no handler under the given name.
*/
unregister(name: string): void;
/**
* Gets the names of all {@link CustomQueryHandler | custom query handlers}.
*/
names(): string[];
/**
* Unregisters all custom query handlers.
*/
clear(): void;
}
/**
* @internal
*/
export declare const customQueryHandlers: CustomQueryHandlerRegistry;
//# sourceMappingURL=CustomQueryHandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CustomQueryHandler.d.ts","sourceRoot":"","sources":["../../../src/common/CustomQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EACL,YAAY,EAGb,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;IACzD;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,0BAA0B;;IAMrC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,YAAY,GAAG,SAAS;IAKlD;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAsDzD;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS9B;;OAEG;IACH,KAAK,IAAI,MAAM,EAAE;IAIjB;;OAEG;IACH,KAAK,IAAI,IAAI;CAMd;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,4BAAmC,CAAC"}

View File

@@ -0,0 +1,114 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { assert } from '../util/assert.js';
import { interpolateFunction, stringifyFunction } from '../util/Function.js';
import { QueryHandler, } from './QueryHandler.js';
import { scriptInjector } from './ScriptInjector.js';
/**
* The registry of {@link CustomQueryHandler | custom query handlers}.
*
* @example
*
* ```ts
* Puppeteer.customQueryHandlers.register('lit', { … });
* const aHandle = await page.$('lit/…');
* ```
*
* @internal
*/
export class CustomQueryHandlerRegistry {
#handlers = new Map();
get(name) {
const handler = this.#handlers.get(name);
return handler ? handler[1] : undefined;
}
/**
* Registers a {@link CustomQueryHandler | custom query handler}.
*
* @remarks
* After registration, the handler can be used everywhere where a selector is
* expected by prepending the selection string with `<name>/`. The name is
* only allowed to consist of lower- and upper case latin letters.
*
* @example
*
* ```ts
* Puppeteer.customQueryHandlers.register('lit', { … });
* const aHandle = await page.$('lit/…');
* ```
*
* @param name - Name to register under.
* @param queryHandler - {@link CustomQueryHandler | Custom query handler} to
* register.
*/
register(name, handler) {
assert(!this.#handlers.has(name), `Cannot register over existing handler: ${name}`);
assert(/^[a-zA-Z]+$/.test(name), `Custom query handler names may only contain [a-zA-Z]`);
assert(handler.queryAll || handler.queryOne, `At least one query method must be implemented.`);
const Handler = class extends QueryHandler {
static querySelectorAll = interpolateFunction((node, selector, PuppeteerUtil) => {
return PuppeteerUtil.customQuerySelectors
.get(PLACEHOLDER('name'))
.querySelectorAll(node, selector);
}, { name: JSON.stringify(name) });
static querySelector = interpolateFunction((node, selector, PuppeteerUtil) => {
return PuppeteerUtil.customQuerySelectors
.get(PLACEHOLDER('name'))
.querySelector(node, selector);
}, { name: JSON.stringify(name) });
};
const registerScript = interpolateFunction((PuppeteerUtil) => {
PuppeteerUtil.customQuerySelectors.register(PLACEHOLDER('name'), {
queryAll: PLACEHOLDER('queryAll'),
queryOne: PLACEHOLDER('queryOne'),
});
}, {
name: JSON.stringify(name),
queryAll: handler.queryAll
? stringifyFunction(handler.queryAll)
: String(undefined),
queryOne: handler.queryOne
? stringifyFunction(handler.queryOne)
: String(undefined),
}).toString();
this.#handlers.set(name, [registerScript, Handler]);
scriptInjector.append(registerScript);
}
/**
* Unregisters the {@link CustomQueryHandler | custom query handler} for the
* given name.
*
* @throws `Error` if there is no handler under the given name.
*/
unregister(name) {
const handler = this.#handlers.get(name);
if (!handler) {
throw new Error(`Cannot unregister unknown handler: ${name}`);
}
scriptInjector.pop(handler[0]);
this.#handlers.delete(name);
}
/**
* Gets the names of all {@link CustomQueryHandler | custom query handlers}.
*/
names() {
return [...this.#handlers.keys()];
}
/**
* Unregisters all custom query handlers.
*/
clear() {
for (const [registerScript] of this.#handlers) {
scriptInjector.pop(registerScript);
}
this.#handlers.clear();
}
}
/**
* @internal
*/
export const customQueryHandlers = new CustomQueryHandlerRegistry();
//# sourceMappingURL=CustomQueryHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CustomQueryHandler.js","sourceRoot":"","sources":["../../../src/common/CustomQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAC,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EACL,YAAY,GAGb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAgBnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,0BAA0B;IACrC,SAAS,GAAG,IAAI,GAAG,EA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AI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,KAAK,MAAM,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC9C,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,0BAA0B,EAAE,CAAC"}

View File

@@ -0,0 +1,61 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type Debug from 'debug';
declare global {
const __PUPPETEER_DEBUG: string;
}
/**
* @internal
*/
export declare function importDebug(): Promise<typeof Debug>;
/**
* A debug function that can be used in any environment.
*
* @remarks
* If used in Node, it falls back to the
* {@link https://www.npmjs.com/package/debug | debug module}. In the browser it
* uses `console.log`.
*
* In Node, use the `DEBUG` environment variable to control logging:
*
* ```
* DEBUG=* // logs all channels
* DEBUG=foo // logs the `foo` channel
* DEBUG=foo* // logs any channels starting with `foo`
* ```
*
* In the browser, set `window.__PUPPETEER_DEBUG` to a string:
*
* ```
* window.__PUPPETEER_DEBUG='*'; // logs all channels
* window.__PUPPETEER_DEBUG='foo'; // logs the `foo` channel
* window.__PUPPETEER_DEBUG='foo*'; // logs any channels starting with `foo`
* ```
*
* @example
*
* ```
* const log = debug('Page');
*
* log('new page created')
* // logs "Page: new page created"
* ```
*
* @param prefix - this will be prefixed to each log.
* @returns a function that can be called to log to that debug channel.
*
* @internal
*/
export declare const debug: (prefix: string) => ((...args: unknown[]) => void);
/**
* @internal
*/
export declare function setLogCapture(value: boolean): void;
/**
* @internal
*/
export declare function getCapturedLogs(): string[];
//# sourceMappingURL=Debug.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Debug.d.ts","sourceRoot":"","sources":["../../../src/common/Debug.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,iBAAiB,EAAE,MAAM,CAAC;CACjC;AAMD;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,KAAK,CAAC,CAKzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,KAAG,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAmCnE,CAAC;AAWF;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAGlD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C"}

View File

@@ -0,0 +1,109 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { isNode } from '../environment.js';
/**
* @internal
*/
let debugModule = null;
/**
* @internal
*/
export async function importDebug() {
if (!debugModule) {
debugModule = (await import('debug')).default;
}
return debugModule;
}
/**
* A debug function that can be used in any environment.
*
* @remarks
* If used in Node, it falls back to the
* {@link https://www.npmjs.com/package/debug | debug module}. In the browser it
* uses `console.log`.
*
* In Node, use the `DEBUG` environment variable to control logging:
*
* ```
* DEBUG=* // logs all channels
* DEBUG=foo // logs the `foo` channel
* DEBUG=foo* // logs any channels starting with `foo`
* ```
*
* In the browser, set `window.__PUPPETEER_DEBUG` to a string:
*
* ```
* window.__PUPPETEER_DEBUG='*'; // logs all channels
* window.__PUPPETEER_DEBUG='foo'; // logs the `foo` channel
* window.__PUPPETEER_DEBUG='foo*'; // logs any channels starting with `foo`
* ```
*
* @example
*
* ```
* const log = debug('Page');
*
* log('new page created')
* // logs "Page: new page created"
* ```
*
* @param prefix - this will be prefixed to each log.
* @returns a function that can be called to log to that debug channel.
*
* @internal
*/
export const debug = (prefix) => {
if (isNode) {
return async (...logArgs) => {
if (captureLogs) {
capturedLogs.push(prefix + logArgs);
}
(await importDebug())(prefix)(logArgs);
};
}
return (...logArgs) => {
const debugLevel = globalThis.__PUPPETEER_DEBUG;
if (!debugLevel) {
return;
}
const everythingShouldBeLogged = debugLevel === '*';
const prefixMatchesDebugLevel = everythingShouldBeLogged ||
/**
* If the debug level is `foo*`, that means we match any prefix that
* starts with `foo`. If the level is `foo`, we match only the prefix
* `foo`.
*/
(debugLevel.endsWith('*')
? prefix.startsWith(debugLevel)
: prefix === debugLevel);
if (!prefixMatchesDebugLevel) {
return;
}
console.log(`${prefix}:`, ...logArgs);
};
};
/**
* @internal
*/
let capturedLogs = [];
/**
* @internal
*/
let captureLogs = false;
/**
* @internal
*/
export function setLogCapture(value) {
capturedLogs = [];
captureLogs = value;
}
/**
* @internal
*/
export function getCapturedLogs() {
return capturedLogs;
}
//# sourceMappingURL=Debug.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Debug.js","sourceRoot":"","sources":["../../../src/common/Debug.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAMzC;;GAEG;AACH,IAAI,WAAW,GAAwB,IAAI,CAAC;AAC5C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAc,EAAkC,EAAE;IACtE,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,KAAK,EAAE,GAAG,OAAkB,EAAE,EAAE;YACrC,IAAI,WAAW,EAAE,CAAC;gBAChB,YAAY,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;YACtC,CAAC;YACD,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,OAAkB,EAAQ,EAAE;QACrC,MAAM,UAAU,GAAI,UAAkB,CAAC,iBAAiB,CAAC;QACzD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QAED,MAAM,wBAAwB,GAAG,UAAU,KAAK,GAAG,CAAC;QAEpD,MAAM,uBAAuB,GAC3B,wBAAwB;YACxB;;;;eAIG;YACH,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;gBACvB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;gBAC/B,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;QAE7B,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,IAAI,YAAY,GAAa,EAAE,CAAC;AAChC;;GAEG;AACH,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,YAAY,GAAG,EAAE,CAAC;IAClB,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,YAAY,CAAC;AACtB,CAAC"}

View File

@@ -0,0 +1,34 @@
/**
* @license
* Copyright 2017 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { Viewport } from './Viewport.js';
/**
* @public
*/
export interface Device {
userAgent: string;
viewport: Viewport;
}
/**
* A list of devices to be used with {@link Page.emulate}.
*
* @example
*
* ```ts
* import {KnownDevices} from 'puppeteer';
* const iPhone = KnownDevices['iPhone 15 Pro'];
*
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.emulate(iPhone);
* await page.goto('https://www.google.com');
* // other actions...
* await browser.close();
* ```
*
* @public
*/
export declare const KnownDevices: Readonly<Record<"Blackberry PlayBook" | "Blackberry PlayBook landscape" | "BlackBerry Z30" | "BlackBerry Z30 landscape" | "Galaxy Note 3" | "Galaxy Note 3 landscape" | "Galaxy Note II" | "Galaxy Note II landscape" | "Galaxy S III" | "Galaxy S III landscape" | "Galaxy S5" | "Galaxy S5 landscape" | "Galaxy S8" | "Galaxy S8 landscape" | "Galaxy S9+" | "Galaxy S9+ landscape" | "Galaxy Tab S4" | "Galaxy Tab S4 landscape" | "iPad" | "iPad landscape" | "iPad (gen 6)" | "iPad (gen 6) landscape" | "iPad (gen 7)" | "iPad (gen 7) landscape" | "iPad Mini" | "iPad Mini landscape" | "iPad Pro" | "iPad Pro landscape" | "iPad Pro 11" | "iPad Pro 11 landscape" | "iPhone 4" | "iPhone 4 landscape" | "iPhone 5" | "iPhone 5 landscape" | "iPhone 6" | "iPhone 6 landscape" | "iPhone 6 Plus" | "iPhone 6 Plus landscape" | "iPhone 7" | "iPhone 7 landscape" | "iPhone 7 Plus" | "iPhone 7 Plus landscape" | "iPhone 8" | "iPhone 8 landscape" | "iPhone 8 Plus" | "iPhone 8 Plus landscape" | "iPhone SE" | "iPhone SE landscape" | "iPhone X" | "iPhone X landscape" | "iPhone XR" | "iPhone XR landscape" | "iPhone 11" | "iPhone 11 landscape" | "iPhone 11 Pro" | "iPhone 11 Pro landscape" | "iPhone 11 Pro Max" | "iPhone 11 Pro Max landscape" | "iPhone 12" | "iPhone 12 landscape" | "iPhone 12 Pro" | "iPhone 12 Pro landscape" | "iPhone 12 Pro Max" | "iPhone 12 Pro Max landscape" | "iPhone 12 Mini" | "iPhone 12 Mini landscape" | "iPhone 13" | "iPhone 13 landscape" | "iPhone 13 Pro" | "iPhone 13 Pro landscape" | "iPhone 13 Pro Max" | "iPhone 13 Pro Max landscape" | "iPhone 13 Mini" | "iPhone 13 Mini landscape" | "iPhone 14" | "iPhone 14 landscape" | "iPhone 14 Plus" | "iPhone 14 Plus landscape" | "iPhone 14 Pro" | "iPhone 14 Pro landscape" | "iPhone 14 Pro Max" | "iPhone 14 Pro Max landscape" | "iPhone 15" | "iPhone 15 landscape" | "iPhone 15 Plus" | "iPhone 15 Plus landscape" | "iPhone 15 Pro" | "iPhone 15 Pro landscape" | "iPhone 15 Pro Max" | "iPhone 15 Pro Max landscape" | "JioPhone 2" | "JioPhone 2 landscape" | "Kindle Fire HDX" | "Kindle Fire HDX landscape" | "LG Optimus L70" | "LG Optimus L70 landscape" | "Microsoft Lumia 550" | "Microsoft Lumia 950" | "Microsoft Lumia 950 landscape" | "Nexus 10" | "Nexus 10 landscape" | "Nexus 4" | "Nexus 4 landscape" | "Nexus 5" | "Nexus 5 landscape" | "Nexus 5X" | "Nexus 5X landscape" | "Nexus 6" | "Nexus 6 landscape" | "Nexus 6P" | "Nexus 6P landscape" | "Nexus 7" | "Nexus 7 landscape" | "Nokia Lumia 520" | "Nokia Lumia 520 landscape" | "Nokia N9" | "Nokia N9 landscape" | "Pixel 2" | "Pixel 2 landscape" | "Pixel 2 XL" | "Pixel 2 XL landscape" | "Pixel 3" | "Pixel 3 landscape" | "Pixel 4" | "Pixel 4 landscape" | "Pixel 4a (5G)" | "Pixel 4a (5G) landscape" | "Pixel 5" | "Pixel 5 landscape" | "Moto G4" | "Moto G4 landscape", Device>>;
//# sourceMappingURL=Device.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../../src/common/Device.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAqrDD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,6tFAAoC,CAAC"}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,30 @@
/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @public
*/
export type DownloadPolicy = 'deny' | 'allow' | 'allowAndName' | 'default';
/**
* @public
*/
export interface DownloadBehavior {
/**
* Whether to allow all or deny all download requests, or use default behavior if
* available.
*
* @remarks
* Setting this to `allowAndName` will name all files according to their download guids.
*/
policy: DownloadPolicy;
/**
* The default path to save downloaded files to.
*
* @remarks
* Setting this is required if behavior is set to `allow` or `allowAndName`.
*/
downloadPath?: string;
}
//# sourceMappingURL=DownloadBehavior.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DownloadBehavior.d.ts","sourceRoot":"","sources":["../../../src/common/DownloadBehavior.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,SAAS,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;OAMG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}

View File

@@ -0,0 +1,7 @@
/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
export {};
//# sourceMappingURL=DownloadBehavior.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DownloadBehavior.js","sourceRoot":"","sources":["../../../src/common/DownloadBehavior.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}

View File

@@ -0,0 +1,80 @@
/**
* @license
* Copyright 2018 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* The base class for all Puppeteer-specific errors
*
* @public
*/
export declare class PuppeteerError extends Error {
/**
* @internal
*/
constructor(message?: string, options?: ErrorOptions);
/**
* @internal
*/
get [Symbol.toStringTag](): string;
}
/**
* TimeoutError is emitted whenever certain operations are terminated due to
* timeout.
*
* @remarks
* Example operations are {@link Page.waitForSelector | page.waitForSelector} or
* {@link PuppeteerNode.launch | puppeteer.launch}.
*
* @public
*/
export declare class TimeoutError extends PuppeteerError {
}
/**
* TouchError is thrown when an attempt is made to move or end a touch that does
* not exist.
* @public
*/
export declare class TouchError extends PuppeteerError {
}
/**
* ProtocolError is emitted whenever there is an error from the protocol.
*
* @public
*/
export declare class ProtocolError extends PuppeteerError {
#private;
set code(code: number | undefined);
/**
* @readonly
* @public
*/
get code(): number | undefined;
set originalMessage(originalMessage: string);
/**
* @readonly
* @public
*/
get originalMessage(): string;
}
/**
* Puppeteer will throw this error if a method is not
* supported by the currently used protocol
*
* @public
*/
export declare class UnsupportedOperation extends PuppeteerError {
}
/**
* @internal
*/
export declare class TargetCloseError extends ProtocolError {
}
/**
* Thrown if underlying protocol connection has been closed.
*
* @public
*/
export declare class ConnectionClosedError extends ProtocolError {
}
//# sourceMappingURL=Errors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../../../src/common/Errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;OAEG;gBACS,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;IAKpD;;OAEG;IACH,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;CACF;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAa,SAAQ,cAAc;CAAG;AAEnD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,cAAc;CAAG;AAEjD;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,cAAc;;IAI/C,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAEhC;IACD;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED,IAAI,eAAe,CAAC,eAAe,EAAE,MAAM,EAE1C;IACD;;;OAGG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;CACF;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,cAAc;CAAG;AAE3D;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;CAAG;AAEtD;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;CAAG"}

View File

@@ -0,0 +1,94 @@
/**
* @license
* Copyright 2018 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* The base class for all Puppeteer-specific errors
*
* @public
*/
export class PuppeteerError extends Error {
/**
* @internal
*/
constructor(message, options) {
super(message, options);
this.name = this.constructor.name;
}
/**
* @internal
*/
get [Symbol.toStringTag]() {
return this.constructor.name;
}
}
/**
* TimeoutError is emitted whenever certain operations are terminated due to
* timeout.
*
* @remarks
* Example operations are {@link Page.waitForSelector | page.waitForSelector} or
* {@link PuppeteerNode.launch | puppeteer.launch}.
*
* @public
*/
export class TimeoutError extends PuppeteerError {
}
/**
* TouchError is thrown when an attempt is made to move or end a touch that does
* not exist.
* @public
*/
export class TouchError extends PuppeteerError {
}
/**
* ProtocolError is emitted whenever there is an error from the protocol.
*
* @public
*/
export class ProtocolError extends PuppeteerError {
#code;
#originalMessage = '';
set code(code) {
this.#code = code;
}
/**
* @readonly
* @public
*/
get code() {
return this.#code;
}
set originalMessage(originalMessage) {
this.#originalMessage = originalMessage;
}
/**
* @readonly
* @public
*/
get originalMessage() {
return this.#originalMessage;
}
}
/**
* Puppeteer will throw this error if a method is not
* supported by the currently used protocol
*
* @public
*/
export class UnsupportedOperation extends PuppeteerError {
}
/**
* @internal
*/
export class TargetCloseError extends ProtocolError {
}
/**
* Thrown if underlying protocol connection has been closed.
*
* @public
*/
export class ConnectionClosedError extends ProtocolError {
}
//# sourceMappingURL=Errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../../../src/common/Errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC;;OAEG;IACH,YAAY,OAAgB,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAa,SAAQ,cAAc;CAAG;AAEnD;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,cAAc;CAAG;AAEjD;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IAC/C,KAAK,CAAU;IACf,gBAAgB,GAAG,EAAE,CAAC;IAEtB,IAAI,IAAI,CAAC,IAAwB;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IACD;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,eAAe,CAAC,eAAuB;QACzC,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IACD;;;OAGG;IACH,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAAc;CAAG;AAE3D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,aAAa;CAAG;AAEtD;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;CAAG"}

View File

@@ -0,0 +1,106 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { type Emitter } from '../../third_party/mitt/mitt.js';
import { asyncDisposeSymbol, disposeSymbol } from '../util/disposable.js';
/**
* @public
*/
export type EventType = string | symbol;
/**
* @public
*/
export type Handler<T = unknown> = (event: T) => void;
/**
* @public
*/
export interface CommonEventEmitter<Events extends Record<EventType, unknown>> {
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): this;
off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): this;
emit<Key extends keyof Events>(type: Key, event: Events[Key]): boolean;
once<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): this;
listenerCount(event: keyof Events): number;
removeAllListeners(event?: keyof Events): this;
}
/**
* @public
*/
export type EventsWithWildcard<Events extends Record<EventType, unknown>> = Events & {
'*': Events[keyof Events];
};
/**
* The EventEmitter class that many Puppeteer classes extend.
*
* @remarks
*
* This allows you to listen to events that Puppeteer classes fire and act
* accordingly. Therefore you'll mostly use {@link EventEmitter.on | on} and
* {@link EventEmitter.off | off} to bind
* and unbind to event listeners.
*
* @public
*/
export declare class EventEmitter<Events extends Record<EventType, unknown>> implements CommonEventEmitter<EventsWithWildcard<Events>> {
#private;
/**
* If you pass an emitter, the returned emitter will wrap the passed emitter.
*
* @internal
*/
constructor(emitter?: Emitter<EventsWithWildcard<Events>> | EventEmitter<Events>);
/**
* Bind an event listener to fire when an event occurs.
* @param type - the event type you'd like to listen to. Can be a string or symbol.
* @param handler - the function to be called when the event occurs.
* @returns `this` to enable you to chain method calls.
*/
on<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this;
/**
* Remove an event listener from firing.
* @param type - the event type you'd like to stop listening to.
* @param handler - the function that should be removed.
* @returns `this` to enable you to chain method calls.
*/
off<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler?: Handler<EventsWithWildcard<Events>[Key]>): this;
/**
* Emit an event and call any associated listeners.
*
* @param type - the event you'd like to emit
* @param eventData - any data you'd like to emit with the event
* @returns `true` if there are any listeners, `false` if there are not.
*/
emit<Key extends keyof EventsWithWildcard<Events>>(type: Key, event: EventsWithWildcard<Events>[Key]): boolean;
/**
* Like `on` but the listener will only be fired once and then it will be removed.
* @param type - the event you'd like to listen to
* @param handler - the handler function to run when the event occurs
* @returns `this` to enable you to chain method calls.
*/
once<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this;
/**
* Gets the number of listeners for a given event.
*
* @param type - the event to get the listener count for
* @returns the number of listeners bound to the given event
*/
listenerCount(type: keyof EventsWithWildcard<Events>): number;
/**
* Removes all listeners. If given an event argument, it will remove only
* listeners for that event.
*
* @param type - the event to remove listeners for.
* @returns `this` to enable you to chain method calls.
*/
removeAllListeners(type?: keyof EventsWithWildcard<Events>): this;
/**
* @internal
*/
[disposeSymbol](): void;
/**
* @internal
*/
[asyncDisposeSymbol](): Promise<void>;
}
//# sourceMappingURL=EventEmitter.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../../src/common/EventEmitter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAa,EAAC,KAAK,OAAO,EAAC,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAIxE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,MAAM,SAAS,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC;IAC3E,EAAE,CAAC,GAAG,SAAS,MAAM,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,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,GAChD,IAAI;IAYP;;;;;OAKG;IACH,GAAG,CAAC,GAAG,SAAS,MAAM,kBAAkB,CAAC,MAAM,CAAC,EAC9C,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GACjD,IAAI;IAgBP;;;;;;OAMG;IACH,IAAI,CAAC,GAAG,SAAS,MAAM,kBAAkB,CAAC,MAAM,CAAC,EAC/C,IAAI,EAAE,GAAG,EACT,KAAK,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GACrC,OAAO;IAKV;;;;;OAKG;IACH,IAAI,CAAC,GAAG,SAAS,MAAM,kBAAkB,CAAC,MAAM,CAAC,EAC/C,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAChD,IAAI;IASP;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,kBAAkB,CAAC,MAAM,CAAC,GAAG,MAAM;IAI7D;;;;;;OAMG;IACH,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,kBAAkB,CAAC,MAAM,CAAC,GAAG,IAAI;IAQjE;;OAEG;IACH,CAAC,aAAa,CAAC,IAAI,IAAI;IAIvB;;OAEG;IACG,CAAC,kBAAkB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5C"}

View File

@@ -0,0 +1,135 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import mitt from '../../third_party/mitt/mitt.js';
import { asyncDisposeSymbol, disposeSymbol } from '../util/disposable.js';
import { debugError } from './util.js';
/**
* The EventEmitter class that many Puppeteer classes extend.
*
* @remarks
*
* This allows you to listen to events that Puppeteer classes fire and act
* accordingly. Therefore you'll mostly use {@link EventEmitter.on | on} and
* {@link EventEmitter.off | off} to bind
* and unbind to event listeners.
*
* @public
*/
export class EventEmitter {
#emitter;
#handlers = new Map();
/**
* If you pass an emitter, the returned emitter will wrap the passed emitter.
*
* @internal
*/
constructor(emitter = mitt(new Map())) {
this.#emitter = emitter;
}
/**
* Bind an event listener to fire when an event occurs.
* @param type - the event type you'd like to listen to. Can be a string or symbol.
* @param handler - the function to be called when the event occurs.
* @returns `this` to enable you to chain method calls.
*/
on(type, handler) {
const handlers = this.#handlers.get(type);
if (handlers === undefined) {
this.#handlers.set(type, [handler]);
}
else {
handlers.push(handler);
}
this.#emitter.on(type, handler);
return this;
}
/**
* Remove an event listener from firing.
* @param type - the event type you'd like to stop listening to.
* @param handler - the function that should be removed.
* @returns `this` to enable you to chain method calls.
*/
off(type, handler) {
const handlers = this.#handlers.get(type) ?? [];
if (handler === undefined) {
for (const handler of handlers) {
this.#emitter.off(type, handler);
}
this.#handlers.delete(type);
return this;
}
const index = handlers.lastIndexOf(handler);
if (index > -1) {
this.#emitter.off(type, ...handlers.splice(index, 1));
}
return this;
}
/**
* Emit an event and call any associated listeners.
*
* @param type - the event you'd like to emit
* @param eventData - any data you'd like to emit with the event
* @returns `true` if there are any listeners, `false` if there are not.
*/
emit(type, event) {
this.#emitter.emit(type, event);
return this.listenerCount(type) > 0;
}
/**
* Like `on` but the listener will only be fired once and then it will be removed.
* @param type - the event you'd like to listen to
* @param handler - the handler function to run when the event occurs
* @returns `this` to enable you to chain method calls.
*/
once(type, handler) {
const onceHandler = eventData => {
handler(eventData);
this.off(type, onceHandler);
};
return this.on(type, onceHandler);
}
/**
* Gets the number of listeners for a given event.
*
* @param type - the event to get the listener count for
* @returns the number of listeners bound to the given event
*/
listenerCount(type) {
return this.#handlers.get(type)?.length || 0;
}
/**
* Removes all listeners. If given an event argument, it will remove only
* listeners for that event.
*
* @param type - the event to remove listeners for.
* @returns `this` to enable you to chain method calls.
*/
removeAllListeners(type) {
if (type !== undefined) {
return this.off(type);
}
this[disposeSymbol]();
return this;
}
/**
* @internal
*/
[disposeSymbol]() {
return void this[asyncDisposeSymbol]().catch(debugError);
}
/**
* @internal
*/
async [asyncDisposeSymbol]() {
for (const [type, handlers] of this.#handlers) {
for (const handler of handlers) {
this.#emitter.off(type, handler);
}
}
this.#handlers.clear();
}
}
//# sourceMappingURL=EventEmitter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EventEmitter.js","sourceRoot":"","sources":["../../../src/common/EventEmitter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAoB,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AAuCrC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IAGvB,QAAQ,CAA6D;IACrE,SAAS,GAAG,IAAI,GAAG,EAA2C,CAAC;IAE/D;;;;OAIG;IACH,YACE,UAAsE,IAAI,CACxE,IAAI,GAAG,EAAE,CACV;QAED,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,EAAE,CACA,IAAS,EACT,OAAiD;QAEjD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,GAAG,CACD,IAAS,EACT,OAAkD;QAElD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,C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IACH,kBAAkB,CAAC,IAAuC;QACxD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,CAAC,aAAa,CAAC;QACb,OAAO,KAAK,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,CAAC,kBAAkB,CAAC;QACxB,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC9C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}

View File

@@ -0,0 +1,56 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { ElementHandle } from '../api/ElementHandle.js';
/**
* File choosers let you react to the page requesting for a file.
*
* @remarks
* `FileChooser` instances are returned via the {@link Page.waitForFileChooser} method.
*
* In browsers, only one file chooser can be opened at a time.
* All file choosers must be accepted or canceled. Not doing so will prevent
* subsequent file choosers from appearing.
*
* @example
*
* ```ts
* const [fileChooser] = await Promise.all([
* page.waitForFileChooser(),
* page.click('#upload-file-button'), // some button that triggers file selection
* ]);
* await fileChooser.accept(['/tmp/myfile.pdf']);
* ```
*
* @public
*/
export declare class FileChooser {
#private;
/**
* @internal
*/
constructor(element: ElementHandle<HTMLInputElement>, multiple: boolean);
/**
* Whether file chooser allow for
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-multiple | multiple}
* file selection.
*/
isMultiple(): boolean;
/**
* Accept the file chooser request with 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.
*/
accept(paths: string[]): Promise<void>;
/**
* Closes the file chooser without selecting any files.
*/
cancel(): Promise<void>;
}
//# sourceMappingURL=FileChooser.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FileChooser.d.ts","sourceRoot":"","sources":["../../../src/common/FileChooser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAW;;IAKtB;;OAEG;gBACS,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,OAAO;IAKvE;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAIrB;;;;;;;;OAQG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAY9B"}

View File

@@ -0,0 +1,75 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { assert } from '../util/assert.js';
/**
* File choosers let you react to the page requesting for a file.
*
* @remarks
* `FileChooser` instances are returned via the {@link Page.waitForFileChooser} method.
*
* In browsers, only one file chooser can be opened at a time.
* All file choosers must be accepted or canceled. Not doing so will prevent
* subsequent file choosers from appearing.
*
* @example
*
* ```ts
* const [fileChooser] = await Promise.all([
* page.waitForFileChooser(),
* page.click('#upload-file-button'), // some button that triggers file selection
* ]);
* await fileChooser.accept(['/tmp/myfile.pdf']);
* ```
*
* @public
*/
export class FileChooser {
#element;
#multiple;
#handled = false;
/**
* @internal
*/
constructor(element, multiple) {
this.#element = element;
this.#multiple = multiple;
}
/**
* Whether file chooser allow for
* {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-multiple | multiple}
* file selection.
*/
isMultiple() {
return this.#multiple;
}
/**
* Accept the file chooser request with 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.
*/
async accept(paths) {
assert(!this.#handled, 'Cannot accept FileChooser which is already handled!');
this.#handled = true;
await this.#element.uploadFile(...paths);
}
/**
* Closes the file chooser without selecting any files.
*/
async cancel() {
assert(!this.#handled, 'Cannot cancel FileChooser which is already handled!');
this.#handled = true;
// XXX: These events should converted to trusted events. Perhaps do this
// in `DOM.setFileInputFiles`?
await this.#element.evaluate(element => {
element.dispatchEvent(new Event('cancel', { bubbles: true }));
});
}
}
//# sourceMappingURL=FileChooser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FileChooser.js","sourceRoot":"","sources":["../../../src/common/FileChooser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,WAAW;IACtB,QAAQ,CAAkC;IAC1C,SAAS,CAAU;IACnB,QAAQ,GAAG,KAAK,CAAC;IAEjB;;OAEG;IACH,YAAY,OAAwC,EAAE,QAAiB;QACrE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,KAAe;QAC1B,MAAM,CACJ,CAAC,IAAI,CAAC,QAAQ,EACd,qDAAqD,CACtD,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,CACJ,CAAC,IAAI,CAAC,QAAQ,EACd,qDAAqD,CACtD,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,wEAAwE;QACxE,8BAA8B;QAC9B,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACrC,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}

View File

@@ -0,0 +1,16 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { QueryHandler } from './QueryHandler.js';
import { PollingOptions } from './QueryHandler.js';
/**
* @internal
*/
export declare function getQueryHandlerAndSelector(selector: string): {
updatedSelector: string;
polling: PollingOptions;
QueryHandler: typeof QueryHandler;
};
//# sourceMappingURL=GetQueryHandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GetQueryHandler.d.ts","sourceRoot":"","sources":["../../../src/common/GetQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAajD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;IACxB,YAAY,EAAE,OAAO,YAAY,CAAC;CACnC,CA8CA"}

View File

@@ -0,0 +1,70 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { ARIAQueryHandler } from './AriaQueryHandler.js';
import { CSSQueryHandler } from './CSSQueryHandler.js';
import { customQueryHandlers } from './CustomQueryHandler.js';
import { PierceQueryHandler } from './PierceQueryHandler.js';
import { PQueryHandler } from './PQueryHandler.js';
import { parsePSelectors } from './PSelectorParser.js';
import { TextQueryHandler } from './TextQueryHandler.js';
import { XPathQueryHandler } from './XPathQueryHandler.js';
const BUILTIN_QUERY_HANDLERS = {
aria: ARIAQueryHandler,
pierce: PierceQueryHandler,
xpath: XPathQueryHandler,
text: TextQueryHandler,
};
const QUERY_SEPARATORS = ['=', '/'];
/**
* @internal
*/
export function getQueryHandlerAndSelector(selector) {
for (const handlerMap of [
customQueryHandlers.names().map(name => {
return [name, customQueryHandlers.get(name)];
}),
Object.entries(BUILTIN_QUERY_HANDLERS),
]) {
for (const [name, QueryHandler] of handlerMap) {
for (const separator of QUERY_SEPARATORS) {
const prefix = `${name}${separator}`;
if (selector.startsWith(prefix)) {
selector = selector.slice(prefix.length);
return {
updatedSelector: selector,
polling: name === 'aria' ? "raf" /* PollingOptions.RAF */ : "mutation" /* PollingOptions.MUTATION */,
QueryHandler,
};
}
}
}
}
try {
const [pSelector, isPureCSS, hasPseudoClasses, hasAria] = parsePSelectors(selector);
if (isPureCSS) {
return {
updatedSelector: selector,
polling: hasPseudoClasses
? "raf" /* PollingOptions.RAF */
: "mutation" /* PollingOptions.MUTATION */,
QueryHandler: CSSQueryHandler,
};
}
return {
updatedSelector: JSON.stringify(pSelector),
polling: hasAria ? "raf" /* PollingOptions.RAF */ : "mutation" /* PollingOptions.MUTATION */,
QueryHandler: PQueryHandler,
};
}
catch {
return {
updatedSelector: selector,
polling: "mutation" /* PollingOptions.MUTATION */,
QueryHandler: CSSQueryHandler,
};
}
}
//# sourceMappingURL=GetQueryHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GetQueryHandler.js","sourceRoot":"","sources":["../../../src/common/GetQuery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C,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBACzC,OAAO;wBACL,eAAe,EAAE,QAAQ;wBACzB,OAAO,EACL,IAAI,KAAK,MAAM,CAAC,CAAC,gCAAoB,CAAC,yCAAwB;wBAChE,YAAY;qBACb,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACH,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,GACrD,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC5B,IAAI,SAAS,EAAE,CAAC;YACd,OAAO;gBACL,eAAe,EAAE,QAAQ;gBACzB,OAAO,EAAE,gBAAgB;oBACvB,CAAC;oBACD,CAAC,yCAAwB;gBAC3B,YAAY,EAAE,eAAe;aAC9B,CAAC;QACJ,CAAC;QACD,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;YAC1C,OAAO,EAAE,OAAO,CAAC,CAAC,gCAAoB,CAAC,yCAAwB;YAC/D,YAAY,EAAE,aAAa;SAC5B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,eAAe,EAAE,QAAQ;YACzB,OAAO,0CAAyB;YAChC,YAAY,EAAE,eAAe;SAC9B,CAAC;IACJ,CAAC;AACH,CAAC"}

View File

@@ -0,0 +1,12 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { JSHandle } from '../api/JSHandle.js';
import type { AwaitableIterable, HandleFor } from './types.js';
/**
* @internal
*/
export declare function transposeIterableHandle<T>(handle: JSHandle<AwaitableIterable<T>>): AsyncIterableIterator<HandleFor<T>>;
//# sourceMappingURL=HandleIterator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"HandleIterator.d.ts","sourceRoot":"","sources":["../../../src/common/HandleIterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAGjD,OAAO,KAAK,EAAC,iBAAiB,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAsD7D;;GAEG;AACH,wBAAuB,uBAAuB,CAAC,CAAC,EAC9C,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GACrC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAOrC"}

View File

@@ -0,0 +1,142 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
if (value !== null && value !== void 0) {
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
var dispose, inner;
if (async) {
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
dispose = value[Symbol.asyncDispose];
}
if (dispose === void 0) {
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
dispose = value[Symbol.dispose];
if (async) inner = dispose;
}
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
env.stack.push({ value: value, dispose: dispose, async: async });
}
else if (async) {
env.stack.push({ async: true });
}
return value;
};
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
return function (env) {
function fail(e) {
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
env.hasError = true;
}
var r, s = 0;
function next() {
while (r = env.stack.pop()) {
try {
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
if (r.dispose) {
var result = r.dispose.call(r.value);
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
}
else s |= 1;
}
catch (e) {
fail(e);
}
}
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
if (env.hasError) throw env.error;
}
return next();
};
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
});
import { DisposableStack, disposeSymbol } from '../util/disposable.js';
const DEFAULT_BATCH_SIZE = 20;
/**
* This will transpose an iterator JSHandle into a fast, Puppeteer-side iterator
* of JSHandles.
*
* @param size - The number of elements to transpose. This should be something
* reasonable.
*/
async function* fastTransposeIteratorHandle(iterator, size) {
const env_1 = { stack: [], error: void 0, hasError: false };
try {
const array = __addDisposableResource(env_1, await iterator.evaluateHandle(async (iterator, size) => {
const results = [];
while (results.length < size) {
const result = await iterator.next();
if (result.done) {
break;
}
results.push(result.value);
}
return results;
}, size), false);
const properties = (await array.getProperties());
const handles = properties.values();
const stack = __addDisposableResource(env_1, new DisposableStack(), false);
stack.defer(() => {
for (const handle_1 of handles) {
const env_2 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_2, handle_1, false);
handle[disposeSymbol]();
}
catch (e_2) {
env_2.error = e_2;
env_2.hasError = true;
}
finally {
__disposeResources(env_2);
}
}
});
yield* handles;
return properties.size === 0;
}
catch (e_1) {
env_1.error = e_1;
env_1.hasError = true;
}
finally {
__disposeResources(env_1);
}
}
/**
* This will transpose an iterator JSHandle in batches based on the default size
* of {@link fastTransposeIteratorHandle}.
*/
async function* transposeIteratorHandle(iterator) {
let size = DEFAULT_BATCH_SIZE;
while (!(yield* fastTransposeIteratorHandle(iterator, size))) {
size <<= 1;
}
}
/**
* @internal
*/
export async function* transposeIterableHandle(handle) {
const env_3 = { stack: [], error: void 0, hasError: false };
try {
const generatorHandle = __addDisposableResource(env_3, await handle.evaluateHandle(iterable => {
return (async function* () {
yield* iterable;
})();
}), false);
yield* transposeIteratorHandle(generatorHandle);
}
catch (e_3) {
env_3.error = e_3;
env_3.hasError = true;
}
finally {
__disposeResources(env_3);
}
}
//# sourceMappingURL=HandleIterator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"HandleIterator.js","sourceRoot":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;;GAGG;AAEH,KAAK,SAAS,CAAC,CAAC,uBAAuB,CACrC,QAAwC;IAExC,IAAI,IAAI,GAAG,kBAAkB,CAAC;IAC9B,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,2BAA2B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;QAC7D,IAAI,KAAK,CAAC,CAAC;IACb,CAAC;AACH,CAAC;AAID;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,uBAAuB,CAC5C,MAAsC;;;QAEtC,MAAM,eAAe,kCAAG,MAAM,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;YAC7D,OAAO,CAAC,KAAK,SAAS,CAAC;gBACrB,KAAK,CAAC,CAAC,QAAQ,CAAC;YAClB,CAAC,CAAC,EAAE,CAAC;QACP,CAAC,CAAC,QAAA,CAAC;QACH,KAAK,CAAC,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;;;;;;;;;CACjD"}

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { JSHandle } from '../api/JSHandle.js';
import type { PuppeteerInjectedUtil } from '../injected/injected.js';
/**
* @internal
*/
export interface PuppeteerUtilWrapper {
puppeteerUtil: Promise<JSHandle<PuppeteerInjectedUtil>>;
}
/**
* @internal
*/
export declare class LazyArg<T, Context = PuppeteerUtilWrapper> {
#private;
static create: <T_1>(get: (context: PuppeteerUtilWrapper) => Promise<T_1> | T_1) => T_1;
private constructor();
get(context: Context): Promise<T>;
}
//# sourceMappingURL=LazyArg.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LazyArg.d.ts","sourceRoot":"","sources":["../../../src/common/LazyArg.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,qBAAa,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,oBAAoB;;IACpD,MAAM,CAAC,MAAM,GAAI,GAAC,EAChB,KAAK,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,GAAC,CAAC,GAAG,GAAC,KACrD,GAAC,CAIF;IAGF,OAAO;IAID,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;CAGxC"}

View File

@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @internal
*/
export class LazyArg {
static create = (get) => {
// We don't want to introduce LazyArg to the type system, otherwise we would
// have to make it public.
return new LazyArg(get);
};
#get;
constructor(get) {
this.#get = get;
}
async get(context) {
return await this.#get(context);
}
}
//# sourceMappingURL=LazyArg.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LazyArg.js","sourceRoot":"","sources":["../../../src/common/LazyArg.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH;;GAEG;AACH,MAAM,OAAO,OAAO;IAClB,MAAM,CAAC,MAAM,GAAG,CACd,GAAsD,EACnD,EAAE;QACL,4EAA4E;QAC5E,0BAA0B;QAC1B,OAAO,IAAI,OAAO,CAAC,GAAG,CAAiB,CAAC;IAC1C,CAAC,CAAC;IAEF,IAAI,CAAuC;IAC3C,YAAoB,GAAyC;QAC3D,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAAgB;QACxB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC"}

View File

@@ -0,0 +1,32 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { HTTPRequest } from '../api/HTTPRequest.js';
import type { HTTPResponse } from '../api/HTTPResponse.js';
import type { EventType } from './EventEmitter.js';
/**
* We use symbols to prevent any external parties listening to these events.
* They are internal to Puppeteer.
*
* @internal
*/
export declare namespace NetworkManagerEvent {
const Request: unique symbol;
const RequestServedFromCache: unique symbol;
const Response: unique symbol;
const RequestFailed: unique symbol;
const RequestFinished: unique symbol;
}
/**
* @internal
*/
export interface NetworkManagerEvents extends Record<EventType, unknown> {
[NetworkManagerEvent.Request]: HTTPRequest;
[NetworkManagerEvent.RequestServedFromCache]: HTTPRequest;
[NetworkManagerEvent.Response]: HTTPResponse;
[NetworkManagerEvent.RequestFailed]: HTTPRequest;
[NetworkManagerEvent.RequestFinished]: HTTPRequest;
}
//# sourceMappingURL=NetworkManagerEvents.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NetworkManagerEvents.d.ts","sourceRoot":"","sources":["../../../src/common/NetworkManagerEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAEjD;;;;;GAKG;AAEH,yBAAiB,mBAAmB,CAAC;IAC5B,MAAM,OAAO,eAAmC,CAAC;IACjD,MAAM,sBAAsB,eAElC,CAAC;IACK,MAAM,QAAQ,eAAoC,CAAC;IACnD,MAAM,aAAa,eAAyC,CAAC;IAC7D,MAAM,eAAe,eAA2C,CAAC;CACzE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC;IACtE,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAC3C,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC;IAC1D,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;IAC7C,CAAC,mBAAmB,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC;IACjD,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC;CACpD"}

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2022 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* We use symbols to prevent any external parties listening to these events.
* They are internal to Puppeteer.
*
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-namespace
export var NetworkManagerEvent;
(function (NetworkManagerEvent) {
NetworkManagerEvent.Request = Symbol('NetworkManager.Request');
NetworkManagerEvent.RequestServedFromCache = Symbol('NetworkManager.RequestServedFromCache');
NetworkManagerEvent.Response = Symbol('NetworkManager.Response');
NetworkManagerEvent.RequestFailed = Symbol('NetworkManager.RequestFailed');
NetworkManagerEvent.RequestFinished = Symbol('NetworkManager.RequestFinished');
})(NetworkManagerEvent || (NetworkManagerEvent = {}));
//# sourceMappingURL=NetworkManagerEvents.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NetworkManagerEvents.js","sourceRoot":"","sources":["../../../src/common/NetworkManagerEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;;;;GAKG;AACH,2DAA2D;AAC3D,MAAM,KAAW,mBAAmB,CAQnC;AARD,WAAiB,mBAAmB;IACrB,2BAAO,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAC3C,0CAAsB,GAAG,MAAM,CAC1C,uCAAuC,CACxC,CAAC;IACW,4BAAQ,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAC7C,iCAAa,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;IACvD,mCAAe,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAC1E,CAAC,EARgB,mBAAmB,KAAnB,mBAAmB,QAQnC"}

View File

@@ -0,0 +1,203 @@
/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @public
*/
export interface PDFMargin {
top?: string | number;
bottom?: string | number;
left?: string | number;
right?: string | number;
}
/**
* @public
*/
export type LowerCasePaperFormat = 'letter' | 'legal' | 'tabloid' | 'ledger' | 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6';
/**
* All the valid paper format types when printing a PDF.
*
* @remarks
*
* The sizes of each format are as follows:
*
* - `Letter`: 8.5in x 11in / 21.59cm x 27.94cm
*
* - `Legal`: 8.5in x 14in / 21.59cm x 35.56cm
*
* - `Tabloid`: 11in x 17in / 27.94cm x 43.18cm
*
* - `Ledger`: 17in x 11in / 43.18cm x 27.94cm
*
* - `A0`: 33.1102in x 46.811in / 84.1cm x 118.9cm
*
* - `A1`: 23.3858in x 33.1102in / 59.4cm x 84.1cm
*
* - `A2`: 16.5354in x 23.3858in / 42cm x 59.4cm
*
* - `A3`: 11.6929in x 16.5354in / 29.7cm x 42cm
*
* - `A4`: 8.2677in x 11.6929in / 21cm x 29.7cm
*
* - `A5`: 5.8268in x 8.2677in / 14.8cm x 21cm
*
* - `A6`: 4.1339in x 5.8268in / 10.5cm x 14.8cm
*
* @public
*/
export type PaperFormat = Uppercase<LowerCasePaperFormat> | Capitalize<LowerCasePaperFormat> | LowerCasePaperFormat;
/**
* Valid options to configure PDF generation via {@link Page.pdf}.
* @public
*/
export interface PDFOptions {
/**
* Scales the rendering of the web page. Amount must be between `0.1` and `2`.
* @defaultValue `1`
*/
scale?: number;
/**
* Whether to show the header and footer.
* @defaultValue `false`
*/
displayHeaderFooter?: boolean;
/**
* HTML template for the print header. Should be valid HTML with the following
* classes used to inject values into them:
*
* - `date` formatted print date
*
* - `title` document title
*
* - `url` document location
*
* - `pageNumber` current page number
*
* - `totalPages` total pages in the document
*/
headerTemplate?: string;
/**
* HTML template for the print footer. Has the same constraints and support
* for special classes as {@link PDFOptions.headerTemplate}.
*/
footerTemplate?: string;
/**
* Set to `true` to print background graphics.
* @defaultValue `false`
*/
printBackground?: boolean;
/**
* Whether to print in landscape orientation.
* @defaultValue `false`
*/
landscape?: boolean;
/**
* Paper ranges to print, e.g. `1-5, 8, 11-13`.
* @defaultValue The empty string, which means all pages are printed.
*/
pageRanges?: string;
/**
* @remarks
* If set, this takes priority over the `width` and `height` options.
* @defaultValue `letter`.
*/
format?: PaperFormat;
/**
* Sets the width of paper. You can pass in a number or a string with a unit.
*/
width?: string | number;
/**
* Sets the height of paper. You can pass in a number or a string with a unit.
*/
height?: string | number;
/**
* Give any CSS `@page` size declared in the page priority over what is
* declared in the `width` or `height` or `format` option.
* @defaultValue `false`, which will scale the content to fit the paper size.
*/
preferCSSPageSize?: boolean;
/**
* Set the PDF margins.
* @defaultValue `undefined` no margins are set.
*/
margin?: PDFMargin;
/**
* The path to save the file to.
*
* @remarks
*
* If the path is relative, it's resolved relative to the current working directory.
*
* @defaultValue `undefined`, which means the PDF will not be written to disk.
*/
path?: string;
/**
* Hides default white background and allows generating pdfs with transparency.
* @defaultValue `false`
*/
omitBackground?: boolean;
/**
* Generate tagged (accessible) PDF.
*
* @defaultValue `true`
* @experimental
*/
tagged?: boolean;
/**
* Generate document outline.
*
* @defaultValue `false`
* @experimental
*/
outline?: boolean;
/**
* Timeout in milliseconds. Pass `0` to disable timeout.
*
* The default value can be changed by using {@link Page.setDefaultTimeout}
*
* @defaultValue `30_000`
*/
timeout?: number;
/**
* If true, waits for `document.fonts.ready` to resolve. This might require
* activating the page using {@link Page.bringToFront} if the page is in the
* background.
*
* @defaultValue `true`
*/
waitForFonts?: boolean;
}
/**
* @internal
*/
export interface PaperFormatDimensions {
width: number;
height: number;
}
/**
* @internal
*/
export interface ParsedPDFOptionsInterface {
width: number;
height: number;
margin: {
top: number;
bottom: number;
left: number;
right: number;
};
}
/**
* @internal
*/
export type ParsedPDFOptions = Required<Omit<PDFOptions, 'path' | 'format' | 'timeout'> & ParsedPDFOptionsInterface>;
/**
* @internal
*
* @remarks All A series paper format sizes in inches are calculated from centimeters
* rounded mathematically to four decimal places.
*/
export declare const paperFormats: Record<LowerCasePaperFormat, Record<'cm' | 'in', PaperFormatDimensions>>;
//# sourceMappingURL=PDFOptions.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFOptions.d.ts","sourceRoot":"","sources":["../../../src/common/PDFOptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,GACR,OAAO,GACP,SAAS,GACT,QAAQ,GACR,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAC;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,WAAW,GACnB,SAAS,CAAC,oBAAoB,CAAC,GAC/B,UAAU,CAAC,oBAAoB,CAAC,GAChC,oBAAoB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,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
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @internal
*
* @remarks All A series paper format sizes in inches are calculated from centimeters
* rounded mathematically to four decimal places.
*/
export const paperFormats = {
letter: {
cm: { width: 21.59, height: 27.94 },
in: { width: 8.5, height: 11 },
},
legal: {
cm: { width: 21.59, height: 35.56 },
in: { width: 8.5, height: 14 },
},
tabloid: {
cm: { width: 27.94, height: 43.18 },
in: { width: 11, height: 17 },
},
ledger: {
cm: { width: 43.18, height: 27.94 },
in: { width: 17, height: 11 },
},
a0: {
cm: { width: 84.1, height: 118.9 },
in: { width: 33.1102, height: 46.811 },
},
a1: {
cm: { width: 59.4, height: 84.1 },
in: { width: 23.3858, height: 33.1102 },
},
a2: {
cm: { width: 42, height: 59.4 },
in: { width: 16.5354, height: 23.3858 },
},
a3: {
cm: { width: 29.7, height: 42 },
in: { width: 11.6929, height: 16.5354 },
},
a4: {
cm: { width: 21, height: 29.7 },
in: { width: 8.2677, height: 11.6929 },
},
a5: {
cm: { width: 14.8, height: 21 },
in: { width: 5.8268, height: 8.2677 },
},
a6: {
cm: { width: 10.5, height: 14.8 },
in: { width: 4.1339, height: 5.8268 },
},
};
//# sourceMappingURL=PDFOptions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PDFOptions.js","sourceRoot":"","sources":["../../../src/common/PDFOptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuNH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAGrB;IACF,MAAM,EAAE;QACN,EAAE,EAAE,EAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAC;QACjC,EAAE,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAC;KAC7B;IACD,KAAK,EAAE;QACL,EAAE,EAAE,EAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAC;QACjC,EAAE,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAC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AI,EAAE,MAAM,EAAE,EAAE,EAAC;QAC7B,EAAE,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAC;KACpC;IACD,EAAE,EAAE;QACF,EAAE,EAAE,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC;QAC/B,EAAE,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAC;KACpC;CACO,CAAC"}

View File

@@ -0,0 +1,14 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { QueryHandler, type QuerySelector, type QuerySelectorAll } from './QueryHandler.js';
/**
* @internal
*/
export declare class PQueryHandler extends QueryHandler {
static querySelectorAll: QuerySelectorAll;
static querySelector: QuerySelector;
}
//# sourceMappingURL=PQueryHandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PQueryHandler.d.ts","sourceRoot":"","sources":["../../../src/common/PQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,qBAAa,aAAc,SAAQ,YAAY;IAC7C,OAAgB,gBAAgB,EAAE,gBAAgB,CAMhD;IACF,OAAgB,aAAa,EAAE,aAAa,CAM1C;CACH"}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { QueryHandler, } from './QueryHandler.js';
/**
* @internal
*/
export class PQueryHandler extends QueryHandler {
static querySelectorAll = (element, selector, { pQuerySelectorAll }) => {
return pQuerySelectorAll(element, selector);
};
static querySelector = (element, selector, { pQuerySelector }) => {
return pQuerySelector(element, selector);
};
}
//# sourceMappingURL=PQueryHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PQueryHandler.js","sourceRoot":"","sources":["../../../src/common/PQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,GAGb,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C,MAAM,CAAU,gBAAgB,GAAqB,CACnD,OAAO,EACP,QAAQ,EACR,EAAC,iBAAiB,EAAC,EACnB,EAAE;QACF,OAAO,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC;IACF,MAAM,CAAU,aAAa,GAAkB,CAC7C,OAAO,EACP,QAAQ,EACR,EAAC,cAAc,EAAC,EAChB,EAAE;QACF,OAAO,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC,CAAC"}

View File

@@ -0,0 +1,16 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { ComplexPSelectorList } from '../injected/PQuerySelector.js';
/**
* @internal
*/
export declare function parsePSelectors(selector: string): [
selector: ComplexPSelectorList,
isPureCSS: boolean,
hasPseudoClasses: boolean,
hasAria: boolean
];
//# sourceMappingURL=PSelectorParser.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PSelectorParser.d.ts","sourceRoot":"","sources":["../../../src/common/PSelectorParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,+BAA+B,CAAC;AAmBvC;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GACf;IACD,QAAQ,EAAE,oBAAoB;IAC9B,SAAS,EAAE,OAAO;IAClB,gBAAgB,EAAE,OAAO;IACzB,OAAO,EAAE,OAAO;CACjB,CA2EA"}

View File

@@ -0,0 +1,100 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { tokenize, TOKENS, stringify, } from '../../third_party/parsel-js/parsel-js.js';
TOKENS['nesting'] = /&/g;
TOKENS['combinator'] = /\s*(>>>>?|[\s>+~])\s*/g;
const ESCAPE_REGEXP = /\\[\s\S]/g;
const unquote = (text) => {
if (text.length <= 1) {
return text;
}
if ((text[0] === '"' || text[0] === "'") && text.endsWith(text[0])) {
text = text.slice(1, -1);
}
return text.replace(ESCAPE_REGEXP, match => {
return match[1];
});
};
/**
* @internal
*/
export function parsePSelectors(selector) {
let isPureCSS = true;
let hasAria = false;
let hasPseudoClasses = false;
const tokens = tokenize(selector);
if (tokens.length === 0) {
return [[], isPureCSS, hasPseudoClasses, false];
}
let compoundSelector = [];
let complexSelector = [compoundSelector];
const selectors = [complexSelector];
const storage = [];
for (const token of tokens) {
switch (token.type) {
case 'combinator':
switch (token.content) {
case ">>>" /* PCombinator.Descendent */:
isPureCSS = false;
if (storage.length) {
compoundSelector.push(stringify(storage));
storage.splice(0);
}
compoundSelector = [];
complexSelector.push(">>>" /* PCombinator.Descendent */);
complexSelector.push(compoundSelector);
continue;
case ">>>>" /* PCombinator.Child */:
isPureCSS = false;
if (storage.length) {
compoundSelector.push(stringify(storage));
storage.splice(0);
}
compoundSelector = [];
complexSelector.push(">>>>" /* PCombinator.Child */);
complexSelector.push(compoundSelector);
continue;
}
break;
case 'pseudo-element':
if (!token.name.startsWith('-p-')) {
break;
}
isPureCSS = false;
if (storage.length) {
compoundSelector.push(stringify(storage));
storage.splice(0);
}
const name = token.name.slice(3);
if (name === 'aria') {
hasAria = true;
}
compoundSelector.push({
name,
value: unquote(token.argument ?? ''),
});
continue;
case 'pseudo-class':
hasPseudoClasses = true;
break;
case 'comma':
if (storage.length) {
compoundSelector.push(stringify(storage));
storage.splice(0);
}
compoundSelector = [];
complexSelector = [compoundSelector];
selectors.push(complexSelector);
continue;
}
storage.push(token);
}
if (storage.length) {
compoundSelector.push(stringify(storage));
}
return [selectors, isPureCSS, hasPseudoClasses, hasAria];
}
//# sourceMappingURL=PSelectorParser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PSelectorParser.js","source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C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;oBAC1C,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACpB,CAAC;gBACD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;oBACpB,OAAO,GAAG,IAAI,CAAC;gBACjB,CAAC;gBACD,gBAAgB,CAAC,IAAI,CAAC;oBACpB,IAAI;oBACJ,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;iBACrC,CAAC,CAAC;gBACH,SAAS;YACX,KAAK,cAAc;gBACjB,gBAAgB,GAAG,IAAI,CAAC;gBACxB,MAAM;YACR,KAAK,OAAO;gBACV,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;oBACnB,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;oBAC1C,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACpB,CAAC;gBACD,gBAAgB,GAAG,EAAE,CAAC;gBACtB,eAAe,GAAG,CAAC,gBAAgB,CAAC,CAAC;gBACrC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAChC,SAAS;QACb,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC"}

View File

@@ -0,0 +1,15 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type { PuppeteerInjectedUtil } from '../injected/injected.js';
import { QueryHandler } from './QueryHandler.js';
/**
* @internal
*/
export declare class PierceQueryHandler extends QueryHandler {
static querySelector: (element: Node, selector: string, { pierceQuerySelector }: PuppeteerInjectedUtil) => Node | null;
static querySelectorAll: (element: Node, selector: string, { pierceQuerySelectorAll }: PuppeteerInjectedUtil) => Iterable<Node>;
}
//# sourceMappingURL=PierceQueryHandler.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PierceQueryHandler.d.ts","sourceRoot":"","sources":["../../../src/common/PierceQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;IAClD,OAAgB,aAAa,GAC3B,SAAS,IAAI,EACb,UAAU,MAAM,EAChB,yBAAuB,qBAAqB,KAC3C,IAAI,GAAG,IAAI,CAEZ;IACF,OAAgB,gBAAgB,GAC9B,SAAS,IAAI,EACb,UAAU,MAAM,EAChB,4BAA0B,qBAAqB,KAC9C,QAAQ,CAAC,IAAI,CAAC,CAEf;CACH"}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright 2023 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import { QueryHandler } from './QueryHandler.js';
/**
* @internal
*/
export class PierceQueryHandler extends QueryHandler {
static querySelector = (element, selector, { pierceQuerySelector }) => {
return pierceQuerySelector(element, selector);
};
static querySelectorAll = (element, selector, { pierceQuerySelectorAll }) => {
return pierceQuerySelectorAll(element, selector);
};
}
//# sourceMappingURL=PierceQueryHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PierceQueryHandler.js","sourceRoot":"","sources":["../../../src/common/PierceQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAClD,MAAM,CAAU,aAAa,GAAG,CAC9B,OAAa,EACb,QAAgB,EAChB,EAAC,mBAAmB,EAAwB,EAC/B,EAAE;QACf,OAAO,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC,CAAC;IACF,MAAM,CAAU,gBAAgB,GAAG,CACjC,OAAa,EACb,QAAgB,EAChB,EAAC,sBAAsB,EAAwB,EAC/B,EAAE;QAClB,OAAO,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC,CAAC"}

Some files were not shown because too many files have changed in this diff Show More