Socket
Socket
Sign inDemoInstall

puppeteer-core

Package Overview
Dependencies
Maintainers
2
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-core - npm Package Compare versions

Comparing version 23.0.2 to 23.1.0

4

lib/cjs/puppeteer/api/Browser.d.ts

@@ -59,2 +59,6 @@ /**

timeout?: number;
/**
* A signal object that allows you to cancel a waitFor call.
*/
signal?: AbortSignal;
}

@@ -61,0 +65,0 @@ /**

4

lib/cjs/puppeteer/api/Browser.js

@@ -101,4 +101,4 @@ "use strict";

async waitForTarget(predicate, options = {}) {
const { timeout: ms = 30000 } = options;
return await (0, rxjs_js_1.firstValueFrom)((0, rxjs_js_1.merge)((0, util_js_1.fromEmitterEvent)(this, "targetcreated" /* BrowserEvent.TargetCreated */), (0, util_js_1.fromEmitterEvent)(this, "targetchanged" /* BrowserEvent.TargetChanged */), (0, rxjs_js_1.from)(this.targets())).pipe((0, util_js_1.filterAsync)(predicate), (0, rxjs_js_1.raceWith)((0, util_js_1.timeout)(ms))));
const { timeout: ms = 30000, signal } = options;
return await (0, rxjs_js_1.firstValueFrom)((0, rxjs_js_1.merge)((0, util_js_1.fromEmitterEvent)(this, "targetcreated" /* BrowserEvent.TargetCreated */), (0, util_js_1.fromEmitterEvent)(this, "targetchanged" /* BrowserEvent.TargetChanged */), (0, rxjs_js_1.from)(this.targets())).pipe((0, util_js_1.filterAsync)(predicate), (0, rxjs_js_1.raceWith)((0, util_js_1.fromAbortSignal)(signal), (0, util_js_1.timeout)(ms))));
}

@@ -105,0 +105,0 @@ /**

@@ -672,5 +672,9 @@ "use strict";

async #go(delta, options) {
const controller = new AbortController();
try {
const [response] = await Promise.all([
this.waitForNavigation(options),
this.waitForNavigation({
...options,
signal: controller.signal,
}),
this.#frame.browsingContext.traverseHistory(delta),

@@ -681,3 +685,3 @@ ]);

catch (error) {
// TODO: waitForNavigation should be cancelled if an error happens.
controller.abort();
if ((0, ErrorLike_js_1.isErrorLike)(error)) {

@@ -749,2 +753,16 @@ if (error.message.includes('no such history entry')) {

function bidiToPuppeteerCookie(bidiCookie) {
const partitionKey = bidiCookie[CDP_SPECIFIC_PREFIX + 'partitionKey'];
function getParitionKey() {
if (typeof partitionKey === 'string') {
return { partitionKey };
}
if (typeof partitionKey === 'object' && partitionKey !== null) {
return {
// TODO: a breaking change in Puppeteer is required to change
// partitionKey type and report the composite partition key.
partitionKey: partitionKey.topLevelSite,
};
}
return {};
}
return {

@@ -763,3 +781,4 @@ name: bidiCookie.name,

// Extending with CDP-specific properties with `goog:` prefix.
...cdpSpecificCookiePropertiesFromBidiToPuppeteer(bidiCookie, 'sameParty', 'sourceScheme', 'partitionKey', 'partitionKeyOpaque', 'priority'),
...cdpSpecificCookiePropertiesFromBidiToPuppeteer(bidiCookie, 'sameParty', 'sourceScheme', 'partitionKeyOpaque', 'priority'),
...getParitionKey(),
};

@@ -766,0 +785,0 @@ }

@@ -113,2 +113,7 @@ "use strict";

});
if (options.signal) {
options.signal.addEventListener('abort', () => {
deferred.reject(options.signal?.reason);
}, { once: true });
}
const handle = { filter, promise: deferred };

@@ -185,2 +190,7 @@ this.#waitForDevicePromises.add(handle);

});
if (options.signal) {
options.signal.addEventListener('abort', () => {
deferred.reject(options.signal?.reason);
}, { once: true });
}
this.#deviceRequestPrompDeferreds.add(deferred);

@@ -187,0 +197,0 @@ try {

@@ -340,2 +340,7 @@ "use strict";

});
if (options.signal) {
options.signal.addEventListener('abort', () => {
deferred.reject(options.signal?.reason);
}, { once: true });
}
this.#fileChooserDeferreds.add(deferred);

@@ -470,3 +475,10 @@ let enablePromise;

for (const cookie of cookies) {
const item = Object.assign({}, cookie);
const item = {
...cookie,
// TODO: a breaking change neeeded to change the partition key
// type in Puppeteer.
partitionKey: cookie.partitionKey
? { topLevelSite: cookie.partitionKey, hasCrossSiteAncestor: false }
: undefined,
};
if (!cookie.url && pageURL.startsWith('http')) {

@@ -476,2 +488,13 @@ item.url = pageURL;

await this.#primaryTargetClient.send('Network.deleteCookies', item);
if (pageURL.startsWith('http') && !item.partitionKey) {
const url = new URL(pageURL);
// Delete also cookies from the page's partition.
await this.#primaryTargetClient.send('Network.deleteCookies', {
...item,
partitionKey: {
topLevelSite: url.origin.replace(`:${url.port}`, ''),
hasCrossSiteAncestor: false,
},
});
}
}

@@ -478,0 +501,0 @@ }

@@ -96,2 +96,3 @@ /**

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -136,2 +137,3 @@ * @defaultValue https://storage.googleapis.com/chrome-for-testing-public

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -174,2 +176,3 @@ * @defaultValue https://storage.googleapis.com/chrome-for-testing-public

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -176,0 +179,0 @@ * @defaultValue https://archive.mozilla.org/pub/firefox/releases

@@ -88,4 +88,6 @@ /**

/**
* Cookie partition key. The site of the top-level URL the browser was visiting at the
* start of the request to the endpoint that set the cookie. Supported only in Chrome.
* Cookie partition key. In Chrome, it is the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/

@@ -154,5 +156,6 @@ partitionKey?: string;

/**
* Cookie partition key. The site of the top-level URL the browser was visiting at the
* start of the request to the endpoint that set the cookie. If not set, the cookie will
* be set as not partitioned.
* Cookie partition key. In Chrome, it matches the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/

@@ -182,3 +185,10 @@ partitionKey?: string;

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
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/
partitionKey?: string;
}
//# sourceMappingURL=Cookie.d.ts.map

@@ -6,2 +6,3 @@ /**

*/
import type { ParseSelector } from 'typed-query-selector/parser.js';
import type { ElementHandle } from '../api/ElementHandle.js';

@@ -97,21 +98,3 @@ import type { JSHandle } from '../api/JSHandle.js';

*/
export type NodeFor<ComplexSelector extends string> = TypeSelectorOfComplexSelector<ComplexSelector> extends infer TypeSelector ? TypeSelector extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap ? ElementFor<TypeSelector> : Element : never;
type TypeSelectorOfComplexSelector<ComplexSelector extends string> = CompoundSelectorsOfComplexSelector<ComplexSelector> extends infer CompoundSelectors ? CompoundSelectors extends NonEmptyReadonlyArray<string> ? Last<CompoundSelectors> extends infer LastCompoundSelector ? LastCompoundSelector extends string ? TypeSelectorOfCompoundSelector<LastCompoundSelector> : never : never : unknown : never;
type TypeSelectorOfCompoundSelector<CompoundSelector extends string> = SplitWithDelemiters<CompoundSelector, BeginSubclassSelectorTokens> extends infer CompoundSelectorTokens ? CompoundSelectorTokens extends [infer TypeSelector, ...any[]] ? TypeSelector extends '' ? unknown : TypeSelector : never : never;
type Last<Arr extends NonEmptyReadonlyArray<unknown>> = Arr extends [
infer Head,
...infer Tail
] ? Tail extends NonEmptyReadonlyArray<unknown> ? Last<Tail> : Head : never;
type NonEmptyReadonlyArray<T> = [T, ...(readonly T[])];
type CompoundSelectorsOfComplexSelector<ComplexSelector extends string> = SplitWithDelemiters<ComplexSelector, CombinatorTokens> extends infer IntermediateTokens ? IntermediateTokens extends readonly string[] ? Drop<IntermediateTokens, ''> : never : never;
type SplitWithDelemiters<Input extends string, Delemiters extends readonly string[]> = Delemiters extends [infer FirstDelemiter, ...infer RestDelemiters] ? FirstDelemiter extends string ? RestDelemiters extends readonly string[] ? FlatmapSplitWithDelemiters<Split<Input, FirstDelemiter>, RestDelemiters> : never : never : [Input];
type BeginSubclassSelectorTokens = ['.', '#', '[', ':'];
type CombinatorTokens = [' ', '>', '+', '~', '|', '|'];
type Drop<Arr extends readonly unknown[], Remove, Acc extends unknown[] = []> = Arr extends [infer Head, ...infer Tail] ? Head extends Remove ? Drop<Tail, Remove> : Drop<Tail, Remove, [...Acc, Head]> : Acc;
type FlatmapSplitWithDelemiters<Inputs extends readonly string[], Delemiters extends readonly string[], Acc extends string[] = []> = Inputs extends [infer FirstInput, ...infer RestInputs] ? FirstInput extends string ? RestInputs extends readonly string[] ? FlatmapSplitWithDelemiters<RestInputs, Delemiters, [
...Acc,
...SplitWithDelemiters<FirstInput, Delemiters>
]> : Acc : Acc : Acc;
type Split<Input extends string, Delimiter extends string, Acc extends string[] = []> = Input extends `${infer Prefix}${Delimiter}${infer Suffix}` ? Split<Suffix, Delimiter, [...Acc, Prefix]> : [...Acc, Input];
export {};
export type NodeFor<ComplexSelector extends string> = ParseSelector<ComplexSelector>;
//# sourceMappingURL=types.d.ts.map
/**
* @internal
*/
export declare const packageVersion = "23.0.2";
export declare const packageVersion = "23.1.0";
//# sourceMappingURL=version.d.ts.map

@@ -7,3 +7,3 @@ "use strict";

*/
exports.packageVersion = '23.0.2';
exports.packageVersion = '23.1.0';
//# sourceMappingURL=version.js.map

@@ -34,3 +34,3 @@ /**

customQuerySelectors: {
"__#55337@#selectors": Map<string, CustomQuerySelectors.CustomQuerySelector>;
"__#55299@#selectors": Map<string, CustomQuerySelectors.CustomQuerySelector>;
register(name: string, handler: import("../index.js").CustomQueryHandler): void;

@@ -37,0 +37,0 @@ unregister(name: string): void;

@@ -91,2 +91,7 @@ "use strict";

}
if (this.#browser === 'firefox' &&
protocol === 'webDriverBiDi' &&
usePipe) {
throw new Error('Pipe connections are not supported wtih Firefox and WebDriver BiDi');
}
const browserProcess = (0, browsers_1.launch)({

@@ -93,0 +98,0 @@ executablePath: launchArgs.executablePath,

@@ -135,10 +135,16 @@ "use strict";

try {
// When an existing user profile has been used remove the user
// preferences file and restore possibly backuped preferences.
await (0, promises_1.unlink)(path_1.default.join(userDataDir, 'user.js'));
const prefsBackupPath = path_1.default.join(userDataDir, 'prefs.js.puppeteer');
if (fs_1.default.existsSync(prefsBackupPath)) {
const prefsPath = path_1.default.join(userDataDir, 'prefs.js');
await (0, promises_1.unlink)(prefsPath);
await (0, promises_1.rename)(prefsBackupPath, prefsPath);
const backupSuffix = '.puppeteer';
const backupFiles = ['prefs.js', 'user.js'];
const results = await Promise.allSettled(backupFiles.map(async (file) => {
const prefsBackupPath = path_1.default.join(userDataDir, file + backupSuffix);
if (fs_1.default.existsSync(prefsBackupPath)) {
const prefsPath = path_1.default.join(userDataDir, file);
await (0, promises_1.unlink)(prefsPath);
await (0, promises_1.rename)(prefsBackupPath, prefsPath);
}
}));
for (const result of results) {
if (result.status === 'rejected') {
throw result.reason;
}
}

@@ -145,0 +151,0 @@ }

@@ -110,3 +110,5 @@ /**

/**
* Connect to a browser over a pipe instead of a WebSocket.
* Connect to a browser over a pipe instead of a WebSocket. Only supported
* with Chrome.
*
* @defaultValue `false`

@@ -113,0 +115,0 @@ */

@@ -10,6 +10,6 @@ /**

export declare const PUPPETEER_REVISIONS: Readonly<{
chrome: "127.0.6533.99";
'chrome-headless-shell': "127.0.6533.99";
chrome: "127.0.6533.119";
'chrome-headless-shell': "127.0.6533.119";
firefox: "stable_129.0";
}>;
//# sourceMappingURL=revisions.d.ts.map

@@ -13,6 +13,6 @@ "use strict";

exports.PUPPETEER_REVISIONS = Object.freeze({
chrome: '127.0.6533.99',
'chrome-headless-shell': '127.0.6533.99',
chrome: '127.0.6533.119',
'chrome-headless-shell': '127.0.6533.119',
firefox: 'stable_129.0',
});
//# sourceMappingURL=revisions.js.map

@@ -9,4 +9,4 @@ import { disposeSymbol } from './disposable.js';

new (mutex: Mutex, onRelease?: () => void): {
"__#55325@#mutex": Mutex;
"__#55325@#onRelease"?: (() => void) | undefined;
"__#55287@#mutex": Mutex;
"__#55287@#onRelease"?: (() => void) | undefined;
[Symbol.dispose](): void;

@@ -13,0 +13,0 @@ };

@@ -59,2 +59,6 @@ /**

timeout?: number;
/**
* A signal object that allows you to cancel a waitFor call.
*/
signal?: AbortSignal;
}

@@ -61,0 +65,0 @@ /**

@@ -8,3 +8,3 @@ /**

import { EventEmitter } from '../common/EventEmitter.js';
import { debugError, fromEmitterEvent, filterAsync, timeout, } from '../common/util.js';
import { debugError, fromEmitterEvent, filterAsync, timeout, fromAbortSignal, } from '../common/util.js';
import { asyncDisposeSymbol, disposeSymbol } from '../util/disposable.js';

@@ -99,4 +99,4 @@ /**

async waitForTarget(predicate, options = {}) {
const { timeout: ms = 30000 } = options;
return await firstValueFrom(merge(fromEmitterEvent(this, "targetcreated" /* BrowserEvent.TargetCreated */), fromEmitterEvent(this, "targetchanged" /* BrowserEvent.TargetChanged */), from(this.targets())).pipe(filterAsync(predicate), raceWith(timeout(ms))));
const { timeout: ms = 30000, signal } = options;
return await firstValueFrom(merge(fromEmitterEvent(this, "targetcreated" /* BrowserEvent.TargetCreated */), fromEmitterEvent(this, "targetchanged" /* BrowserEvent.TargetChanged */), from(this.targets())).pipe(filterAsync(predicate), raceWith(fromAbortSignal(signal), timeout(ms))));
}

@@ -103,0 +103,0 @@ /**

@@ -669,5 +669,9 @@ /**

async #go(delta, options) {
const controller = new AbortController();
try {
const [response] = await Promise.all([
this.waitForNavigation(options),
this.waitForNavigation({
...options,
signal: controller.signal,
}),
this.#frame.browsingContext.traverseHistory(delta),

@@ -678,3 +682,3 @@ ]);

catch (error) {
// TODO: waitForNavigation should be cancelled if an error happens.
controller.abort();
if (isErrorLike(error)) {

@@ -746,2 +750,16 @@ if (error.message.includes('no such history entry')) {

function bidiToPuppeteerCookie(bidiCookie) {
const partitionKey = bidiCookie[CDP_SPECIFIC_PREFIX + 'partitionKey'];
function getParitionKey() {
if (typeof partitionKey === 'string') {
return { partitionKey };
}
if (typeof partitionKey === 'object' && partitionKey !== null) {
return {
// TODO: a breaking change in Puppeteer is required to change
// partitionKey type and report the composite partition key.
partitionKey: partitionKey.topLevelSite,
};
}
return {};
}
return {

@@ -760,3 +778,4 @@ name: bidiCookie.name,

// Extending with CDP-specific properties with `goog:` prefix.
...cdpSpecificCookiePropertiesFromBidiToPuppeteer(bidiCookie, 'sameParty', 'sourceScheme', 'partitionKey', 'partitionKeyOpaque', 'priority'),
...cdpSpecificCookiePropertiesFromBidiToPuppeteer(bidiCookie, 'sameParty', 'sourceScheme', 'partitionKeyOpaque', 'priority'),
...getParitionKey(),
};

@@ -763,0 +782,0 @@ }

@@ -109,2 +109,7 @@ /**

});
if (options.signal) {
options.signal.addEventListener('abort', () => {
deferred.reject(options.signal?.reason);
}, { once: true });
}
const handle = { filter, promise: deferred };

@@ -180,2 +185,7 @@ this.#waitForDevicePromises.add(handle);

});
if (options.signal) {
options.signal.addEventListener('abort', () => {
deferred.reject(options.signal?.reason);
}, { once: true });
}
this.#deviceRequestPrompDeferreds.add(deferred);

@@ -182,0 +192,0 @@ try {

@@ -337,2 +337,7 @@ /**

});
if (options.signal) {
options.signal.addEventListener('abort', () => {
deferred.reject(options.signal?.reason);
}, { once: true });
}
this.#fileChooserDeferreds.add(deferred);

@@ -467,3 +472,10 @@ let enablePromise;

for (const cookie of cookies) {
const item = Object.assign({}, cookie);
const item = {
...cookie,
// TODO: a breaking change neeeded to change the partition key
// type in Puppeteer.
partitionKey: cookie.partitionKey
? { topLevelSite: cookie.partitionKey, hasCrossSiteAncestor: false }
: undefined,
};
if (!cookie.url && pageURL.startsWith('http')) {

@@ -473,2 +485,13 @@ item.url = pageURL;

await this.#primaryTargetClient.send('Network.deleteCookies', item);
if (pageURL.startsWith('http') && !item.partitionKey) {
const url = new URL(pageURL);
// Delete also cookies from the page's partition.
await this.#primaryTargetClient.send('Network.deleteCookies', {
...item,
partitionKey: {
topLevelSite: url.origin.replace(`:${url.port}`, ''),
hasCrossSiteAncestor: false,
},
});
}
}

@@ -475,0 +498,0 @@ }

@@ -96,2 +96,3 @@ /**

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -136,2 +137,3 @@ * @defaultValue https://storage.googleapis.com/chrome-for-testing-public

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -174,2 +176,3 @@ * @defaultValue https://storage.googleapis.com/chrome-for-testing-public

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -176,0 +179,0 @@ * @defaultValue https://archive.mozilla.org/pub/firefox/releases

@@ -88,4 +88,6 @@ /**

/**
* Cookie partition key. The site of the top-level URL the browser was visiting at the
* start of the request to the endpoint that set the cookie. Supported only in Chrome.
* Cookie partition key. In Chrome, it is the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/

@@ -154,5 +156,6 @@ partitionKey?: string;

/**
* Cookie partition key. The site of the top-level URL the browser was visiting at the
* start of the request to the endpoint that set the cookie. If not set, the cookie will
* be set as not partitioned.
* Cookie partition key. In Chrome, it matches the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/

@@ -182,3 +185,10 @@ partitionKey?: string;

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
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/
partitionKey?: string;
}
//# sourceMappingURL=Cookie.d.ts.map

@@ -6,2 +6,3 @@ /**

*/
import type { ParseSelector } from 'typed-query-selector/parser.js';
import type { ElementHandle } from '../api/ElementHandle.js';

@@ -97,21 +98,3 @@ import type { JSHandle } from '../api/JSHandle.js';

*/
export type NodeFor<ComplexSelector extends string> = TypeSelectorOfComplexSelector<ComplexSelector> extends infer TypeSelector ? TypeSelector extends keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap ? ElementFor<TypeSelector> : Element : never;
type TypeSelectorOfComplexSelector<ComplexSelector extends string> = CompoundSelectorsOfComplexSelector<ComplexSelector> extends infer CompoundSelectors ? CompoundSelectors extends NonEmptyReadonlyArray<string> ? Last<CompoundSelectors> extends infer LastCompoundSelector ? LastCompoundSelector extends string ? TypeSelectorOfCompoundSelector<LastCompoundSelector> : never : never : unknown : never;
type TypeSelectorOfCompoundSelector<CompoundSelector extends string> = SplitWithDelemiters<CompoundSelector, BeginSubclassSelectorTokens> extends infer CompoundSelectorTokens ? CompoundSelectorTokens extends [infer TypeSelector, ...any[]] ? TypeSelector extends '' ? unknown : TypeSelector : never : never;
type Last<Arr extends NonEmptyReadonlyArray<unknown>> = Arr extends [
infer Head,
...infer Tail
] ? Tail extends NonEmptyReadonlyArray<unknown> ? Last<Tail> : Head : never;
type NonEmptyReadonlyArray<T> = [T, ...(readonly T[])];
type CompoundSelectorsOfComplexSelector<ComplexSelector extends string> = SplitWithDelemiters<ComplexSelector, CombinatorTokens> extends infer IntermediateTokens ? IntermediateTokens extends readonly string[] ? Drop<IntermediateTokens, ''> : never : never;
type SplitWithDelemiters<Input extends string, Delemiters extends readonly string[]> = Delemiters extends [infer FirstDelemiter, ...infer RestDelemiters] ? FirstDelemiter extends string ? RestDelemiters extends readonly string[] ? FlatmapSplitWithDelemiters<Split<Input, FirstDelemiter>, RestDelemiters> : never : never : [Input];
type BeginSubclassSelectorTokens = ['.', '#', '[', ':'];
type CombinatorTokens = [' ', '>', '+', '~', '|', '|'];
type Drop<Arr extends readonly unknown[], Remove, Acc extends unknown[] = []> = Arr extends [infer Head, ...infer Tail] ? Head extends Remove ? Drop<Tail, Remove> : Drop<Tail, Remove, [...Acc, Head]> : Acc;
type FlatmapSplitWithDelemiters<Inputs extends readonly string[], Delemiters extends readonly string[], Acc extends string[] = []> = Inputs extends [infer FirstInput, ...infer RestInputs] ? FirstInput extends string ? RestInputs extends readonly string[] ? FlatmapSplitWithDelemiters<RestInputs, Delemiters, [
...Acc,
...SplitWithDelemiters<FirstInput, Delemiters>
]> : Acc : Acc : Acc;
type Split<Input extends string, Delimiter extends string, Acc extends string[] = []> = Input extends `${infer Prefix}${Delimiter}${infer Suffix}` ? Split<Suffix, Delimiter, [...Acc, Prefix]> : [...Acc, Input];
export {};
export type NodeFor<ComplexSelector extends string> = ParseSelector<ComplexSelector>;
//# sourceMappingURL=types.d.ts.map
/**
* @internal
*/
export declare const packageVersion = "23.0.2";
export declare const packageVersion = "23.1.0";
//# sourceMappingURL=version.d.ts.map
/**
* @internal
*/
export const packageVersion = '23.0.2';
export const packageVersion = '23.1.0';
//# sourceMappingURL=version.js.map

@@ -65,2 +65,7 @@ /**

}
if (this.#browser === 'firefox' &&
protocol === 'webDriverBiDi' &&
usePipe) {
throw new Error('Pipe connections are not supported wtih Firefox and WebDriver BiDi');
}
const browserProcess = launch({

@@ -67,0 +72,0 @@ executablePath: launchArgs.executablePath,

@@ -129,10 +129,16 @@ /**

try {
// When an existing user profile has been used remove the user
// preferences file and restore possibly backuped preferences.
await unlink(path.join(userDataDir, 'user.js'));
const prefsBackupPath = path.join(userDataDir, 'prefs.js.puppeteer');
if (fs.existsSync(prefsBackupPath)) {
const prefsPath = path.join(userDataDir, 'prefs.js');
await unlink(prefsPath);
await rename(prefsBackupPath, prefsPath);
const backupSuffix = '.puppeteer';
const backupFiles = ['prefs.js', 'user.js'];
const results = await Promise.allSettled(backupFiles.map(async (file) => {
const prefsBackupPath = path.join(userDataDir, file + backupSuffix);
if (fs.existsSync(prefsBackupPath)) {
const prefsPath = path.join(userDataDir, file);
await unlink(prefsPath);
await rename(prefsBackupPath, prefsPath);
}
}));
for (const result of results) {
if (result.status === 'rejected') {
throw result.reason;
}
}

@@ -139,0 +145,0 @@ }

@@ -110,3 +110,5 @@ /**

/**
* Connect to a browser over a pipe instead of a WebSocket.
* Connect to a browser over a pipe instead of a WebSocket. Only supported
* with Chrome.
*
* @defaultValue `false`

@@ -113,0 +115,0 @@ */

@@ -10,6 +10,6 @@ /**

export declare const PUPPETEER_REVISIONS: Readonly<{
chrome: "127.0.6533.99";
'chrome-headless-shell': "127.0.6533.99";
chrome: "127.0.6533.119";
'chrome-headless-shell': "127.0.6533.119";
firefox: "stable_129.0";
}>;
//# sourceMappingURL=revisions.d.ts.map

@@ -10,6 +10,6 @@ /**

export const PUPPETEER_REVISIONS = Object.freeze({
chrome: '127.0.6533.99',
'chrome-headless-shell': '127.0.6533.99',
chrome: '127.0.6533.119',
'chrome-headless-shell': '127.0.6533.119',
firefox: 'stable_129.0',
});
//# sourceMappingURL=revisions.js.map
{
"name": "puppeteer-core",
"version": "23.0.2",
"version": "23.1.0",
"description": "A high-level API to control headless Chrome over the DevTools Protocol",

@@ -123,12 +123,13 @@ "keywords": [

"dependencies": {
"@puppeteer/browsers": "2.3.0",
"@puppeteer/browsers": "2.3.1",
"chromium-bidi": "0.6.4",
"debug": "^4.3.6",
"devtools-protocol": "0.0.1312386",
"typed-query-selector": "^2.12.0",
"ws": "^8.18.0"
},
"devDependencies": {
"@types/chrome": "0.0.269",
"@types/debug": "4.1.12",
"@types/node": "18.17.15",
"@types/chrome": "0.0.269",
"@types/ws": "8.5.11",

@@ -135,0 +136,0 @@ "mitt": "3.0.1",

@@ -24,2 +24,3 @@ /**

timeout,
fromAbortSignal,
} from '../common/util.js';

@@ -124,2 +125,7 @@ import {asyncDisposeSymbol, disposeSymbol} from '../util/disposable.js';

timeout?: number;
/**
* A signal object that allows you to cancel a waitFor call.
*/
signal?: AbortSignal;
}

@@ -347,3 +353,3 @@

): Promise<Target> {
const {timeout: ms = 30000} = options;
const {timeout: ms = 30000, signal} = options;
return await firstValueFrom(

@@ -354,3 +360,6 @@ merge(

from(this.targets())
).pipe(filterAsync(predicate), raceWith(timeout(ms)))
).pipe(
filterAsync(predicate),
raceWith(fromAbortSignal(signal), timeout(ms))
)
);

@@ -357,0 +366,0 @@ }

@@ -831,5 +831,10 @@ /**

): Promise<HTTPResponse | null> {
const controller = new AbortController();
try {
const [response] = await Promise.all([
this.waitForNavigation(options),
this.waitForNavigation({
...options,
signal: controller.signal,
}),
this.#frame.browsingContext.traverseHistory(delta),

@@ -839,3 +844,3 @@ ]);

} catch (error) {
// TODO: waitForNavigation should be cancelled if an error happens.
controller.abort();
if (isErrorLike(error)) {

@@ -915,2 +920,18 @@ if (error.message.includes('no such history entry')) {

function bidiToPuppeteerCookie(bidiCookie: Bidi.Network.Cookie): Cookie {
const partitionKey = bidiCookie[CDP_SPECIFIC_PREFIX + 'partitionKey'];
function getParitionKey(): {partitionKey?: string} {
if (typeof partitionKey === 'string') {
return {partitionKey};
}
if (typeof partitionKey === 'object' && partitionKey !== null) {
return {
// TODO: a breaking change in Puppeteer is required to change
// partitionKey type and report the composite partition key.
partitionKey: partitionKey.topLevelSite,
};
}
return {};
}
return {

@@ -933,6 +954,6 @@ name: bidiCookie.name,

'sourceScheme',
'partitionKey',
'partitionKeyOpaque',
'priority'
),
...getParitionKey(),
};

@@ -939,0 +960,0 @@ }

@@ -147,2 +147,13 @@ /**

});
if (options.signal) {
options.signal.addEventListener(
'abort',
() => {
deferred.reject(options.signal?.reason);
},
{once: true}
);
}
const handle = {filter, promise: deferred};

@@ -247,2 +258,12 @@ this.#waitForDevicePromises.add(handle);

});
if (options.signal) {
options.signal.addEventListener(
'abort',
() => {
deferred.reject(options.signal?.reason);
},
{once: true}
);
}
this.#deviceRequestPrompDeferreds.add(deferred);

@@ -249,0 +270,0 @@

@@ -409,2 +409,13 @@ /**

});
if (options.signal) {
options.signal.addEventListener(
'abort',
() => {
deferred.reject(options.signal?.reason);
},
{once: true}
);
}
this.#fileChooserDeferreds.add(deferred);

@@ -597,3 +608,10 @@ let enablePromise: Promise<void> | undefined;

for (const cookie of cookies) {
const item = Object.assign({}, cookie);
const item = {
...cookie,
// TODO: a breaking change neeeded to change the partition key
// type in Puppeteer.
partitionKey: cookie.partitionKey
? {topLevelSite: cookie.partitionKey, hasCrossSiteAncestor: false}
: undefined,
};
if (!cookie.url && pageURL.startsWith('http')) {

@@ -603,2 +621,13 @@ item.url = pageURL;

await this.#primaryTargetClient.send('Network.deleteCookies', item);
if (pageURL.startsWith('http') && !item.partitionKey) {
const url = new URL(pageURL);
// Delete also cookies from the page's partition.
await this.#primaryTargetClient.send('Network.deleteCookies', {
...item,
partitionKey: {
topLevelSite: url.origin.replace(`:${url.port}`, ''),
hasCrossSiteAncestor: false,
},
});
}
}

@@ -605,0 +634,0 @@ }

@@ -101,2 +101,3 @@ /**

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -142,2 +143,3 @@ * @defaultValue https://storage.googleapis.com/chrome-for-testing-public

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -181,2 +183,3 @@ * @defaultValue https://storage.googleapis.com/chrome-for-testing-public

* This must include the protocol and may even need a path prefix.
* This must **not** include a trailing slash similar to the default.
*

@@ -183,0 +186,0 @@ * @defaultValue https://archive.mozilla.org/pub/firefox/releases

@@ -92,4 +92,6 @@ /**

/**
* Cookie partition key. The site of the top-level URL the browser was visiting at the
* start of the request to the endpoint that set the cookie. Supported only in Chrome.
* Cookie partition key. In Chrome, it is the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/

@@ -159,5 +161,6 @@ partitionKey?: string;

/**
* Cookie partition key. The site of the top-level URL the browser was visiting at the
* start of the request to the endpoint that set the cookie. If not set, the cookie will
* be set as not partitioned.
* Cookie partition key. In Chrome, it matches the top-level site the
* partitioned cookie is available in. In Firefox, it matches the
* source origin
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/

@@ -188,2 +191,9 @@ partitionKey?: string;

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
* (https://w3c.github.io/webdriver-bidi/#type-storage-PartitionKey).
*/
partitionKey?: string;
}

@@ -7,2 +7,4 @@ /**

import type {ParseSelector} from 'typed-query-selector/parser.js';
import type {ElementHandle} from '../api/ElementHandle.js';

@@ -127,101 +129,2 @@ import type {JSHandle} from '../api/JSHandle.js';

export type NodeFor<ComplexSelector extends string> =
TypeSelectorOfComplexSelector<ComplexSelector> extends infer TypeSelector
? TypeSelector extends
| keyof HTMLElementTagNameMap
| keyof SVGElementTagNameMap
? ElementFor<TypeSelector>
: Element
: never;
type TypeSelectorOfComplexSelector<ComplexSelector extends string> =
CompoundSelectorsOfComplexSelector<ComplexSelector> extends infer CompoundSelectors
? CompoundSelectors extends NonEmptyReadonlyArray<string>
? Last<CompoundSelectors> extends infer LastCompoundSelector
? LastCompoundSelector extends string
? TypeSelectorOfCompoundSelector<LastCompoundSelector>
: never
: never
: unknown
: never;
type TypeSelectorOfCompoundSelector<CompoundSelector extends string> =
SplitWithDelemiters<
CompoundSelector,
BeginSubclassSelectorTokens
> extends infer CompoundSelectorTokens
? CompoundSelectorTokens extends [infer TypeSelector, ...any[]]
? TypeSelector extends ''
? unknown
: TypeSelector
: never
: never;
type Last<Arr extends NonEmptyReadonlyArray<unknown>> = Arr extends [
infer Head,
...infer Tail,
]
? Tail extends NonEmptyReadonlyArray<unknown>
? Last<Tail>
: Head
: never;
type NonEmptyReadonlyArray<T> = [T, ...(readonly T[])];
type CompoundSelectorsOfComplexSelector<ComplexSelector extends string> =
SplitWithDelemiters<
ComplexSelector,
CombinatorTokens
> extends infer IntermediateTokens
? IntermediateTokens extends readonly string[]
? Drop<IntermediateTokens, ''>
: never
: never;
type SplitWithDelemiters<
Input extends string,
Delemiters extends readonly string[],
> = Delemiters extends [infer FirstDelemiter, ...infer RestDelemiters]
? FirstDelemiter extends string
? RestDelemiters extends readonly string[]
? FlatmapSplitWithDelemiters<Split<Input, FirstDelemiter>, RestDelemiters>
: never
: never
: [Input];
type BeginSubclassSelectorTokens = ['.', '#', '[', ':'];
type CombinatorTokens = [' ', '>', '+', '~', '|', '|'];
type Drop<
Arr extends readonly unknown[],
Remove,
Acc extends unknown[] = [],
> = Arr extends [infer Head, ...infer Tail]
? Head extends Remove
? Drop<Tail, Remove>
: Drop<Tail, Remove, [...Acc, Head]>
: Acc;
type FlatmapSplitWithDelemiters<
Inputs extends readonly string[],
Delemiters extends readonly string[],
Acc extends string[] = [],
> = Inputs extends [infer FirstInput, ...infer RestInputs]
? FirstInput extends string
? RestInputs extends readonly string[]
? FlatmapSplitWithDelemiters<
RestInputs,
Delemiters,
[...Acc, ...SplitWithDelemiters<FirstInput, Delemiters>]
>
: Acc
: Acc
: Acc;
type Split<
Input extends string,
Delimiter extends string,
Acc extends string[] = [],
> = Input extends `${infer Prefix}${Delimiter}${infer Suffix}`
? Split<Suffix, Delimiter, [...Acc, Prefix]>
: [...Acc, Input];
ParseSelector<ComplexSelector>;
/**
* @internal
*/
export const packageVersion = '23.0.2';
export const packageVersion = '23.1.0';

@@ -131,2 +131,12 @@ /**

if (
this.#browser === 'firefox' &&
protocol === 'webDriverBiDi' &&
usePipe
) {
throw new Error(
'Pipe connections are not supported wtih Firefox and WebDriver BiDi'
);
}
const browserProcess = launch({

@@ -133,0 +143,0 @@ executablePath: launchArgs.executablePath,

@@ -173,11 +173,19 @@ /**

try {
// When an existing user profile has been used remove the user
// preferences file and restore possibly backuped preferences.
await unlink(path.join(userDataDir, 'user.js'));
const backupSuffix = '.puppeteer';
const backupFiles = ['prefs.js', 'user.js'];
const prefsBackupPath = path.join(userDataDir, 'prefs.js.puppeteer');
if (fs.existsSync(prefsBackupPath)) {
const prefsPath = path.join(userDataDir, 'prefs.js');
await unlink(prefsPath);
await rename(prefsBackupPath, prefsPath);
const results = await Promise.allSettled(
backupFiles.map(async file => {
const prefsBackupPath = path.join(userDataDir, file + backupSuffix);
if (fs.existsSync(prefsBackupPath)) {
const prefsPath = path.join(userDataDir, file);
await unlink(prefsPath);
await rename(prefsBackupPath, prefsPath);
}
})
);
for (const result of results) {
if (result.status === 'rejected') {
throw result.reason;
}
}

@@ -184,0 +192,0 @@ } catch (error) {

@@ -117,3 +117,5 @@ /**

/**
* Connect to a browser over a pipe instead of a WebSocket.
* Connect to a browser over a pipe instead of a WebSocket. Only supported
* with Chrome.
*
* @defaultValue `false`

@@ -120,0 +122,0 @@ */

@@ -11,5 +11,5 @@ /**

export const PUPPETEER_REVISIONS = Object.freeze({
chrome: '127.0.6533.99',
'chrome-headless-shell': '127.0.6533.99',
chrome: '127.0.6533.119',
'chrome-headless-shell': '127.0.6533.119',
firefox: 'stable_129.0',
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc