Socket
Socket
Sign inDemoInstall

puppeteer-core

Package Overview
Dependencies
6
Maintainers
2
Versions
222
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 21.3.4 to 21.3.5

19

lib/cjs/puppeteer/api/Page.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.unitToPixels = exports.supportedMetrics = exports.Page = void 0;
exports.unitToPixels = exports.supportedMetrics = exports.Page = exports.setDefaultScreenshotOptions = void 0;
const rxjs_js_1 = require("../../third_party/rxjs/rxjs.js");

@@ -110,2 +110,16 @@ const NetworkManager_js_1 = require("../cdp/NetworkManager.js");

/**
* @internal
*/
function setDefaultScreenshotOptions(options) {
options.optimizeForSpeed ??= false;
options.type ??= 'png';
options.fromSurface ??= true;
options.fullPage ??= false;
options.omitBackground ??= false;
options.encoding ??= 'binary';
options.captureBeyondViewport ??= true;
options.allowViewportExpansion ??= options.captureBeyondViewport;
}
exports.setDefaultScreenshotOptions = setDefaultScreenshotOptions;
/**
* Page provides methods to interact with a single tab or

@@ -923,4 +937,3 @@ * {@link https://developer.chrome.com/extensions/background_pages | extension background page}

}
options.captureBeyondViewport ??= true;
options.allowViewportExpansion ??= options.captureBeyondViewport;
setDefaultScreenshotOptions(options);
options.clip = options.clip && roundClip(normalizeClip(options.clip));

@@ -927,0 +940,0 @@ const stack = __addDisposableResource(env_1, new disposable_js_1.AsyncDisposableStack(), true);

4

lib/cjs/puppeteer/bidi/Page.d.ts

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

createPDFStream(options?: PDFOptions | undefined): Promise<Readable>;
screenshot(options: Readonly<ScreenshotOptions> & {
encoding: 'base64';
}): Promise<string>;
screenshot(options?: Readonly<ScreenshotOptions>): Promise<Buffer>;
_screenshot(options: Readonly<ScreenshotOptions>): Promise<string>;

@@ -98,0 +94,0 @@ waitForRequest(urlOrPredicate: string | ((req: BidiHTTPRequest) => boolean | Promise<boolean>), options?: {

@@ -532,32 +532,25 @@ "use strict";

}
async screenshot(options = {}) {
const { clip, type, captureBeyondViewport, allowViewportExpansion = true, } = options;
if (captureBeyondViewport) {
throw new Error(`BiDi does not support 'captureBeyondViewport'.`);
async _screenshot(options) {
const { clip, type, captureBeyondViewport, allowViewportExpansion } = options;
if (captureBeyondViewport && !allowViewportExpansion) {
throw new Error(`BiDi does not support 'captureBeyondViewport'. Use 'allowViewportExpansion'.`);
}
const invalidOption = Object.keys(options).find(option => {
return [
'fromSurface',
'omitBackground',
'optimizeForSpeed',
'quality',
].includes(option);
});
if (invalidOption !== undefined) {
throw new Error(`BiDi does not support ${invalidOption}.`);
if (options.omitBackground !== undefined && options.omitBackground) {
throw new Error(`BiDi does not support 'omitBackground'.`);
}
if ((type ?? 'png') !== 'png') {
if (options.optimizeForSpeed !== undefined && options.optimizeForSpeed) {
throw new Error(`BiDi does not support 'optimizeForSpeed'.`);
}
if (options.fromSurface !== undefined && !options.fromSurface) {
throw new Error(`BiDi does not support 'fromSurface'.`);
}
if (options.quality !== undefined) {
throw new Error(`BiDi does not support 'quality'.`);
}
if (type === 'webp' || type === 'jpeg') {
throw new Error(`BiDi only supports 'png' type.`);
}
if (clip?.scale !== undefined) {
if (clip !== undefined && clip.scale !== undefined && clip.scale !== 1) {
throw new Error(`BiDi does not support 'scale' in 'clip'.`);
}
return await super.screenshot({
...options,
captureBeyondViewport,
allowViewportExpansion: captureBeyondViewport ?? allowViewportExpansion,
});
}
async _screenshot(options) {
const { clip } = options;
const { result: { data }, } = await this.#connection.send('browsingContext.captureScreenshot', {

@@ -564,0 +557,0 @@ context: this.mainFrame()._id,

@@ -20,3 +20,3 @@ /**

import { type Protocol } from 'devtools-protocol';
import type { Browser } from '../api/Browser.js';
import { type Browser } from '../api/Browser.js';
import type { BrowserContext } from '../api/BrowserContext.js';

@@ -23,0 +23,0 @@ import { type CDPSession } from '../api/CDPSession.js';

@@ -83,2 +83,3 @@ "use strict";

const ExecutionContext_js_1 = require("./ExecutionContext.js");
const FirefoxTargetManager_js_1 = require("./FirefoxTargetManager.js");
const FrameManager_js_1 = require("./FrameManager.js");

@@ -775,7 +776,11 @@ const Input_js_1 = require("./Input.js");

const { fromSurface, omitBackground, optimizeForSpeed, quality, clip: userClip, type, captureBeyondViewport, } = options;
const isFirefox = this.target()._targetManager() instanceof FirefoxTargetManager_js_1.FirefoxTargetManager;
const stack = __addDisposableResource(env_2, new disposable_js_1.AsyncDisposableStack(), true);
if (omitBackground && (type === 'png' || type === 'webp')) {
// Firefox omits background by default; it's not configurable.
if (!isFirefox && omitBackground && (type === 'png' || type === 'webp')) {
await this.#emulationManager.setTransparentBackgroundColor();
stack.defer(async () => {
await this.#emulationManager.resetDefaultBackgroundColor();
await this.#emulationManager
.resetDefaultBackgroundColor()
.catch(util_js_1.debugError);
});

@@ -793,6 +798,7 @@ }

}
// We need to do these spreads because Firefox doesn't allow unknown options.
const { data } = await this.#client.send('Page.captureScreenshot', {
format: type,
optimizeForSpeed,
quality,
...(optimizeForSpeed ? { optimizeForSpeed } : {}),
...(quality !== undefined ? { quality } : {}),
clip: clip && {

@@ -802,3 +808,3 @@ ...clip,

},
fromSurface,
...(!fromSurface ? { fromSurface } : {}),
captureBeyondViewport,

@@ -805,0 +811,0 @@ });

/**
* @internal
*/
export declare const packageVersion = "21.3.4";
export declare const packageVersion = "21.3.5";
//# sourceMappingURL=version.d.ts.map

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

*/
exports.packageVersion = '21.3.4';
exports.packageVersion = '21.3.5';
//# sourceMappingURL=version.js.map

@@ -40,3 +40,3 @@ /**

customQuerySelectors: {
"__#48680@#selectors": Map<string, CustomQuerySelectors.CustomQuerySelector>;
"__#48671@#selectors": Map<string, CustomQuerySelectors.CustomQuerySelector>;
register(name: string, handler: import("../puppeteer-core.js").CustomQueryHandler): void;

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

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

new (mutex: Mutex): {
"__#48670@#mutex": Mutex;
"__#48661@#mutex": Mutex;
[Symbol.dispose](): void;

@@ -12,0 +12,0 @@ };

@@ -106,2 +106,15 @@ /**

/**
* @internal
*/
export function setDefaultScreenshotOptions(options) {
options.optimizeForSpeed ??= false;
options.type ??= 'png';
options.fromSurface ??= true;
options.fullPage ??= false;
options.omitBackground ??= false;
options.encoding ??= 'binary';
options.captureBeyondViewport ??= true;
options.allowViewportExpansion ??= options.captureBeyondViewport;
}
/**
* Page provides methods to interact with a single tab or

@@ -919,4 +932,3 @@ * {@link https://developer.chrome.com/extensions/background_pages | extension background page}

}
options.captureBeyondViewport ??= true;
options.allowViewportExpansion ??= options.captureBeyondViewport;
setDefaultScreenshotOptions(options);
options.clip = options.clip && roundClip(normalizeClip(options.clip));

@@ -923,0 +935,0 @@ const stack = __addDisposableResource(env_1, new AsyncDisposableStack(), true);

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

createPDFStream(options?: PDFOptions | undefined): Promise<Readable>;
screenshot(options: Readonly<ScreenshotOptions> & {
encoding: 'base64';
}): Promise<string>;
screenshot(options?: Readonly<ScreenshotOptions>): Promise<Buffer>;
_screenshot(options: Readonly<ScreenshotOptions>): Promise<string>;

@@ -98,0 +94,0 @@ waitForRequest(urlOrPredicate: string | ((req: BidiHTTPRequest) => boolean | Promise<boolean>), options?: {

@@ -506,32 +506,25 @@ /**

}
async screenshot(options = {}) {
const { clip, type, captureBeyondViewport, allowViewportExpansion = true, } = options;
if (captureBeyondViewport) {
throw new Error(`BiDi does not support 'captureBeyondViewport'.`);
async _screenshot(options) {
const { clip, type, captureBeyondViewport, allowViewportExpansion } = options;
if (captureBeyondViewport && !allowViewportExpansion) {
throw new Error(`BiDi does not support 'captureBeyondViewport'. Use 'allowViewportExpansion'.`);
}
const invalidOption = Object.keys(options).find(option => {
return [
'fromSurface',
'omitBackground',
'optimizeForSpeed',
'quality',
].includes(option);
});
if (invalidOption !== undefined) {
throw new Error(`BiDi does not support ${invalidOption}.`);
if (options.omitBackground !== undefined && options.omitBackground) {
throw new Error(`BiDi does not support 'omitBackground'.`);
}
if ((type ?? 'png') !== 'png') {
if (options.optimizeForSpeed !== undefined && options.optimizeForSpeed) {
throw new Error(`BiDi does not support 'optimizeForSpeed'.`);
}
if (options.fromSurface !== undefined && !options.fromSurface) {
throw new Error(`BiDi does not support 'fromSurface'.`);
}
if (options.quality !== undefined) {
throw new Error(`BiDi does not support 'quality'.`);
}
if (type === 'webp' || type === 'jpeg') {
throw new Error(`BiDi only supports 'png' type.`);
}
if (clip?.scale !== undefined) {
if (clip !== undefined && clip.scale !== undefined && clip.scale !== 1) {
throw new Error(`BiDi does not support 'scale' in 'clip'.`);
}
return await super.screenshot({
...options,
captureBeyondViewport,
allowViewportExpansion: captureBeyondViewport ?? allowViewportExpansion,
});
}
async _screenshot(options) {
const { clip } = options;
const { result: { data }, } = await this.#connection.send('browsingContext.captureScreenshot', {

@@ -538,0 +531,0 @@ context: this.mainFrame()._id,

@@ -20,3 +20,3 @@ /**

import { type Protocol } from 'devtools-protocol';
import type { Browser } from '../api/Browser.js';
import { type Browser } from '../api/Browser.js';
import type { BrowserContext } from '../api/BrowserContext.js';

@@ -23,0 +23,0 @@ import { type CDPSession } from '../api/CDPSession.js';

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

import { createCdpHandle, releaseObject } from './ExecutionContext.js';
import { FirefoxTargetManager } from './FirefoxTargetManager.js';
import { FrameManager, FrameManagerEvent } from './FrameManager.js';

@@ -772,7 +773,11 @@ import { CdpKeyboard, CdpMouse, CdpTouchscreen } from './Input.js';

const { fromSurface, omitBackground, optimizeForSpeed, quality, clip: userClip, type, captureBeyondViewport, } = options;
const isFirefox = this.target()._targetManager() instanceof FirefoxTargetManager;
const stack = __addDisposableResource(env_2, new AsyncDisposableStack(), true);
if (omitBackground && (type === 'png' || type === 'webp')) {
// Firefox omits background by default; it's not configurable.
if (!isFirefox && omitBackground && (type === 'png' || type === 'webp')) {
await this.#emulationManager.setTransparentBackgroundColor();
stack.defer(async () => {
await this.#emulationManager.resetDefaultBackgroundColor();
await this.#emulationManager
.resetDefaultBackgroundColor()
.catch(debugError);
});

@@ -790,6 +795,7 @@ }

}
// We need to do these spreads because Firefox doesn't allow unknown options.
const { data } = await this.#client.send('Page.captureScreenshot', {
format: type,
optimizeForSpeed,
quality,
...(optimizeForSpeed ? { optimizeForSpeed } : {}),
...(quality !== undefined ? { quality } : {}),
clip: clip && {

@@ -799,3 +805,3 @@ ...clip,

},
fromSurface,
...(!fromSurface ? { fromSurface } : {}),
captureBeyondViewport,

@@ -802,0 +808,0 @@ });

/**
* @internal
*/
export declare const packageVersion = "21.3.4";
export declare const packageVersion = "21.3.5";
//# sourceMappingURL=version.d.ts.map
/**
* @internal
*/
export const packageVersion = '21.3.4';
export const packageVersion = '21.3.5';
//# sourceMappingURL=version.js.map
{
"name": "puppeteer-core",
"version": "21.3.4",
"version": "21.3.5",
"description": "A high-level API to control headless Chrome over the DevTools Protocol",

@@ -5,0 +5,0 @@ "keywords": [

@@ -650,48 +650,29 @@ /**

override async screenshot(
options: Readonly<ScreenshotOptions> & {encoding: 'base64'}
): Promise<string>;
override async screenshot(
options?: Readonly<ScreenshotOptions>
): Promise<Buffer>;
override async screenshot(
options: Readonly<ScreenshotOptions> = {}
): Promise<Buffer | string> {
const {
clip,
type,
captureBeyondViewport,
allowViewportExpansion = true,
} = options;
if (captureBeyondViewport) {
throw new Error(`BiDi does not support 'captureBeyondViewport'.`);
override async _screenshot(
options: Readonly<ScreenshotOptions>
): Promise<string> {
const {clip, type, captureBeyondViewport, allowViewportExpansion} = options;
if (captureBeyondViewport && !allowViewportExpansion) {
throw new Error(
`BiDi does not support 'captureBeyondViewport'. Use 'allowViewportExpansion'.`
);
}
const invalidOption = Object.keys(options).find(option => {
return [
'fromSurface',
'omitBackground',
'optimizeForSpeed',
'quality',
].includes(option);
});
if (invalidOption !== undefined) {
throw new Error(`BiDi does not support ${invalidOption}.`);
if (options.omitBackground !== undefined && options.omitBackground) {
throw new Error(`BiDi does not support 'omitBackground'.`);
}
if ((type ?? 'png') !== 'png') {
if (options.optimizeForSpeed !== undefined && options.optimizeForSpeed) {
throw new Error(`BiDi does not support 'optimizeForSpeed'.`);
}
if (options.fromSurface !== undefined && !options.fromSurface) {
throw new Error(`BiDi does not support 'fromSurface'.`);
}
if (options.quality !== undefined) {
throw new Error(`BiDi does not support 'quality'.`);
}
if (type === 'webp' || type === 'jpeg') {
throw new Error(`BiDi only supports 'png' type.`);
}
if (clip?.scale !== undefined) {
if (clip !== undefined && clip.scale !== undefined && clip.scale !== 1) {
throw new Error(`BiDi does not support 'scale' in 'clip'.`);
}
return await super.screenshot({
...options,
captureBeyondViewport,
allowViewportExpansion: captureBeyondViewport ?? allowViewportExpansion,
});
}
override async _screenshot(
options: Readonly<ScreenshotOptions>
): Promise<string> {
const {clip} = options;
const {

@@ -698,0 +679,0 @@ result: {data},

@@ -21,3 +21,3 @@ /**

import type {Browser} from '../api/Browser.js';
import {type Browser} from '../api/Browser.js';
import type {BrowserContext} from '../api/BrowserContext.js';

@@ -37,5 +37,5 @@ import {CDPSessionEvent, type CDPSession} from '../api/CDPSession.js';

type NewDocumentScriptEvaluation,
type ScreenshotClip,
type ScreenshotOptions,
type WaitTimeoutOptions,
type ScreenshotClip,
} from '../api/Page.js';

@@ -79,2 +79,3 @@ import {

import {createCdpHandle, releaseObject} from './ExecutionContext.js';
import {FirefoxTargetManager} from './FirefoxTargetManager.js';
import {type CdpFrame} from './Frame.js';

@@ -1045,3 +1046,5 @@ import {FrameManager, FrameManagerEvent} from './FrameManager.js';

async _screenshot(options: Readonly<ScreenshotOptions>): Promise<string> {
override async _screenshot(
options: Readonly<ScreenshotOptions>
): Promise<string> {
const {

@@ -1057,7 +1060,13 @@ fromSurface,

const isFirefox =
this.target()._targetManager() instanceof FirefoxTargetManager;
await using stack = new AsyncDisposableStack();
if (omitBackground && (type === 'png' || type === 'webp')) {
// Firefox omits background by default; it's not configurable.
if (!isFirefox && omitBackground && (type === 'png' || type === 'webp')) {
await this.#emulationManager.setTransparentBackgroundColor();
stack.defer(async () => {
await this.#emulationManager.resetDefaultBackgroundColor();
await this.#emulationManager
.resetDefaultBackgroundColor()
.catch(debugError);
});

@@ -1082,6 +1091,7 @@ }

// We need to do these spreads because Firefox doesn't allow unknown options.
const {data} = await this.#client.send('Page.captureScreenshot', {
format: type,
optimizeForSpeed,
quality,
...(optimizeForSpeed ? {optimizeForSpeed} : {}),
...(quality !== undefined ? {quality} : {}),
clip: clip && {

@@ -1091,3 +1101,3 @@ ...clip,

},
fromSurface,
...(!fromSurface ? {fromSurface} : {}),
captureBeyondViewport,

@@ -1094,0 +1104,0 @@ });

/**
* @internal
*/
export const packageVersion = '21.3.4';
export const packageVersion = '21.3.5';

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

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

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc