Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

puppeteer-extra

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

puppeteer-extra - npm Package Compare versions

Comparing version 2.0.6 to 2.0.7

test/connect.js

66

index.js

@@ -82,3 +82,3 @@ 'use strict'

/**
* Main launch method.
* Launch a new browser instance with given arguments.
*

@@ -88,7 +88,7 @@ * Augments the original `puppeteer.launch` method with plugin lifecycle methods.

* All registered plugins that have a `beforeLaunch` method will be called
* in sequence to potentially update the `options` Object before launching puppeteer.
* in sequence to potentially update the `options` Object before launching the browser.
*
* @todo Implement support for 'connect' as well.
* @todo pass `defaultArgs` to `beforeLaunch` calls to plugins.
*
* @param {Object=} options - Regular Puppeteer options
* @param {Object=} options - Regular [Puppeteer launch options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions)
* @return {Puppeteer.Browser}

@@ -103,9 +103,13 @@ */

options = await this.callPluginsWithValue('beforeLaunch', options)
const opts = { context: 'launch', options, defaultArgs: this.defaultArgs }
// Let's check requirements after plugin had the chance to modify the options
this.checkPluginRequirements(options)
this.checkPluginRequirements(opts)
const browser = await Puppeteer.launch(options)
this._patchPageCreationMethods(browser)
await this.callPlugins('_bindBrowserEvents', browser, options)
await this.callPlugins('_bindBrowserEvents', browser, opts)
return browser

@@ -115,2 +119,33 @@ }

/**
* Attach Puppeteer to an existing Chromium instance.
*
* Augments the original `puppeteer.connect` method with plugin lifecycle methods.
*
* All registered plugins that have a `beforeConnect` method will be called
* in sequence to potentially update the `options` Object before launching the browser.
*
* @param {{browserWSEndpoint: string, ignoreHTTPSErrors: boolean}} options
* @return {Promise<!Puppeteer.Browser>}
*/
async connect (options = {}) {
this.resolvePluginDependencies()
this.orderPlugins()
// Give plugins the chance to modify the options before connect
options = await this.callPluginsWithValue('beforeConnect', options)
const opts = { context: 'connect', options }
// Let's check requirements after plugin had the chance to modify the options
this.checkPluginRequirements(opts)
const browser = await Puppeteer.connect(options)
this._patchPageCreationMethods(browser)
await this.callPlugins('_bindBrowserEvents', browser, opts)
return browser
}
/**
* Patch page creation methods (both regular and incognito contexts).

@@ -286,8 +321,11 @@ *

*/
checkPluginRequirements (options = {}) {
checkPluginRequirements (opts = {}) {
for (const plugin of this._plugins) {
for (const requirement of plugin.requirements) {
if ((requirement === 'headful') && options.headless) {
if ((opts.context === 'launch') && (requirement === 'headful') && opts.options.headless) {
console.warn(`Warning: Plugin '${plugin.name}' is not supported in headless mode.`)
}
if ((opts.context === 'connect') && (requirement === 'launch')) {
console.warn(`Warning: Plugin '${plugin.name}' doesn't support puppeteer.connect().`)
}
}

@@ -334,14 +372,2 @@ }

*
* @todo Add `puppeteer-extra` plugin support for `connect` as well.
*
* @param {{browserWSEndpoint: string, ignoreHTTPSErrors: boolean}} options
* @return {Promise<!Puppeteer.Browser>}
*/
connect (options) {
return Puppeteer.connect(options)
}
/**
* Regular Puppeteer method that is being passed through.
*
* @return {string}

@@ -348,0 +374,0 @@ */

{
"name": "puppeteer-extra",
"version": "2.0.6",
"version": "2.0.7",
"description": "Teach puppeteer new tricks through plugins.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -53,2 +53,6 @@ # puppeteer-extra

#### [`puppeteer-extra-plugin-repl`](/packages/puppeteer-extra-plugin-repl)
- Makes quick puppeteer debugging and exploration fun with an interactive REPL.
#### [`puppeteer-extra-plugin-block-resources`](/packages/puppeteer-extra-plugin-block-resources)

@@ -103,5 +107,5 @@

- [launch](#launch)
- [connect](#connect)
- [plugins](#plugins)
- [getPluginData](#getplugindata)
- [connect](#connect)
- [executablePath](#executablepath)

@@ -111,3 +115,3 @@ - [defaultArgs](#defaultargs)

### [PuppeteerExtra](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L43-L370)
### [PuppeteerExtra](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L43-L391)

@@ -140,3 +144,3 @@ Modular plugin framework to teach `puppeteer` new tricks.

#### [use](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L63-L79)
#### [use](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L63-L79)

@@ -160,5 +164,5 @@ Outside interface to register plugins.

#### [launch](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L94-L109)
#### [launch](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L94-L113)
Main launch method.
Launch a new browser instance with given arguments.

@@ -168,12 +172,27 @@ Augments the original `puppeteer.launch` method with plugin lifecycle methods.

All registered plugins that have a `beforeLaunch` method will be called
in sequence to potentially update the `options` Object before launching puppeteer.
in sequence to potentially update the `options` Object before launching the browser.
Type: `function (options): Puppeteer.Browser`
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Regular Puppeteer options (optional, default `{}`)
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Regular [Puppeteer launch options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions) (optional, default `{}`)
* * *
#### [plugins](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L157-L157)
#### [connect](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L126-L144)
Attach Puppeteer to an existing Chromium instance.
Augments the original `puppeteer.connect` method with plugin lifecycle methods.
All registered plugins that have a `beforeConnect` method will be called
in sequence to potentially update the `options` Object before launching the browser.
Type: `function (options)`
- `options` **{browserWSEndpoint: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), ignoreHTTPSErrors: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)}** (optional, default `{}`)
* * *
#### [plugins](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L187-L187)
Get all registered plugins.

@@ -185,3 +204,3 @@

#### [getPluginData](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L179-L184)
#### [getPluginData](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L209-L214)

@@ -203,16 +222,6 @@ - **See: puppeteer-extra-plugin/data**

#### [connect](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L339-L341)
#### [executablePath](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L369-L371)
Regular Puppeteer method that is being passed through.
Type: `function (options)`
- `options` **{browserWSEndpoint: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), ignoreHTTPSErrors: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)}**
* * *
#### [executablePath](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L348-L350)
Regular Puppeteer method that is being passed through.
Type: `function (): string`

@@ -222,3 +231,3 @@

#### [defaultArgs](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L357-L359)
#### [defaultArgs](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L378-L380)

@@ -231,3 +240,3 @@ Regular Puppeteer method that is being passed through.

#### [createBrowserFetcher](https://github.com/berstend/puppeteer-extra/blob/c112368eba0738093e5244452d93b6c24e422b7c/packages/puppeteer-extra/index.js#L367-L369)
#### [createBrowserFetcher](https://github.com/berstend/puppeteer-extra/blob/4ab951dbe6ff6a49e7bc5a23a794eeda76eceafe/packages/puppeteer-extra/index.js#L388-L390)

@@ -234,0 +243,0 @@ Regular Puppeteer method that is being passed through.

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