pupeteerextra 0.0.1-security → 3.3.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pupeteerextra might be problematic. Click here for more details.

@@ -0,0 +1,459 @@
1
+ /*!
2
+ * puppeteer-extra v3.3.5 by berstend
3
+ * https://github.com/berstend/puppeteer-extra
4
+ * @license MIT
5
+ */
6
+ import Debug from 'debug';
7
+ import merge from 'deepmerge';
8
+
9
+ const debug = Debug('puppeteer-extra');
10
+ /**
11
+ * Modular plugin framework to teach `puppeteer` new tricks.
12
+ *
13
+ * This module acts as a drop-in replacement for `puppeteer`.
14
+ *
15
+ * Allows PuppeteerExtraPlugin's to register themselves and
16
+ * to extend puppeteer with additional functionality.
17
+ *
18
+ * @class PuppeteerExtra
19
+ * @implements {VanillaPuppeteer}
20
+ *
21
+ * @example
22
+ * const puppeteer = require('puppeteer-extra')
23
+ * puppeteer.use(require('puppeteer-extra-plugin-anonymize-ua')())
24
+ * puppeteer.use(require('puppeteer-extra-plugin-font-size')({defaultFontSize: 18}))
25
+ *
26
+ * ;(async () => {
27
+ * const browser = await puppeteer.launch({headless: false})
28
+ * const page = await browser.newPage()
29
+ * await page.goto('http://example.com', {waitUntil: 'domcontentloaded'})
30
+ * await browser.close()
31
+ * })()
32
+ */
33
+ class PuppeteerExtra {
34
+ constructor(_pptr, _requireError) {
35
+ this._pptr = _pptr;
36
+ this._requireError = _requireError;
37
+ this._plugins = [];
38
+ }
39
+ /**
40
+ * The **main interface** to register `puppeteer-extra` plugins.
41
+ *
42
+ * @example
43
+ * puppeteer.use(plugin1).use(plugin2)
44
+ *
45
+ * @see [PuppeteerExtraPlugin]
46
+ *
47
+ * @return The same `PuppeteerExtra` instance (for optional chaining)
48
+ */
49
+ use(plugin) {
50
+ if (typeof plugin !== 'object' || !plugin._isPuppeteerExtraPlugin) {
51
+ console.error(`Warning: Plugin is not derived from PuppeteerExtraPlugin, ignoring.`, plugin);
52
+ return this;
53
+ }
54
+ if (!plugin.name) {
55
+ console.error(`Warning: Plugin with no name registering, ignoring.`, plugin);
56
+ return this;
57
+ }
58
+ if (plugin.requirements.has('dataFromPlugins')) {
59
+ plugin.getDataFromPlugins = this.getPluginData.bind(this);
60
+ }
61
+ plugin._register(Object.getPrototypeOf(plugin));
62
+ this._plugins.push(plugin);
63
+ debug('plugin registered', plugin.name);
64
+ return this;
65
+ }
66
+ /**
67
+ * To stay backwards compatible with puppeteer's (and our) default export after adding `addExtra`
68
+ * we need to defer the check if we have a puppeteer instance to work with.
69
+ * Otherwise we would throw even if the user intends to use their non-standard puppeteer implementation.
70
+ *
71
+ * @private
72
+ */
73
+ get pptr() {
74
+ if (this._pptr) {
75
+ return this._pptr;
76
+ }
77
+ // Whoopsie
78
+ console.warn(`
79
+ Puppeteer is missing. :-)
80
+
81
+ Note: puppeteer is a peer dependency of puppeteer-extra,
82
+ which means you can install your own preferred version.
83
+
84
+ - To get the latest stable version run: 'yarn add puppeteer' or 'npm i puppeteer'
85
+
86
+ Alternatively:
87
+ - To get puppeteer without the bundled Chromium browser install 'puppeteer-core'
88
+ `);
89
+ throw this._requireError || new Error('No puppeteer instance provided.');
90
+ }
91
+ /**
92
+ * The method launches a browser instance with given arguments. The browser will be closed when the parent node.js process is closed.
93
+ *
94
+ * Augments the original `puppeteer.launch` method with plugin lifecycle methods.
95
+ *
96
+ * All registered plugins that have a `beforeLaunch` method will be called
97
+ * in sequence to potentially update the `options` Object before launching the browser.
98
+ *
99
+ * @example
100
+ * const browser = await puppeteer.launch({
101
+ * headless: false,
102
+ * defaultViewport: null
103
+ * })
104
+ *
105
+ * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
106
+ */
107
+ async launch(options) {
108
+ // Ensure there are certain properties (e.g. the `options.args` array)
109
+ const defaultLaunchOptions = { args: [] };
110
+ options = merge(defaultLaunchOptions, options || {});
111
+ this.resolvePluginDependencies();
112
+ this.orderPlugins();
113
+ // Give plugins the chance to modify the options before launch
114
+ options = await this.callPluginsWithValue('beforeLaunch', options);
115
+ const opts = {
116
+ context: 'launch',
117
+ options,
118
+ defaultArgs: this.defaultArgs
119
+ };
120
+ // Let's check requirements after plugin had the chance to modify the options
121
+ this.checkPluginRequirements(opts);
122
+ const browser = await this.pptr.launch(options);
123
+ this._patchPageCreationMethods(browser);
124
+ await this.callPlugins('_bindBrowserEvents', browser, opts);
125
+ return browser;
126
+ }
127
+ /**
128
+ * Attach Puppeteer to an existing Chromium instance.
129
+ *
130
+ * Augments the original `puppeteer.connect` method with plugin lifecycle methods.
131
+ *
132
+ * All registered plugins that have a `beforeConnect` method will be called
133
+ * in sequence to potentially update the `options` Object before launching the browser.
134
+ *
135
+ * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerconnectoptions).
136
+ */
137
+ async connect(options) {
138
+ this.resolvePluginDependencies();
139
+ this.orderPlugins();
140
+ // Give plugins the chance to modify the options before connect
141
+ options = await this.callPluginsWithValue('beforeConnect', options);
142
+ const opts = { context: 'connect', options };
143
+ // Let's check requirements after plugin had the chance to modify the options
144
+ this.checkPluginRequirements(opts);
145
+ const browser = await this.pptr.connect(options);
146
+ this._patchPageCreationMethods(browser);
147
+ await this.callPlugins('_bindBrowserEvents', browser, opts);
148
+ return browser;
149
+ }
150
+ /**
151
+ * The default flags that Chromium will be launched with.
152
+ *
153
+ * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerdefaultargsoptions).
154
+ */
155
+ defaultArgs(options) {
156
+ return this.pptr.defaultArgs(options);
157
+ }
158
+ /** Path where Puppeteer expects to find bundled Chromium. */
159
+ executablePath() {
160
+ return this.pptr.executablePath();
161
+ }
162
+ /**
163
+ * This methods attaches Puppeteer to an existing Chromium instance.
164
+ *
165
+ * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteercreatebrowserfetcheroptions).
166
+ */
167
+ createBrowserFetcher(options) {
168
+ return this.pptr.createBrowserFetcher(options);
169
+ }
170
+ /**
171
+ * Patch page creation methods (both regular and incognito contexts).
172
+ *
173
+ * Unfortunately it's possible that the `targetcreated` events are not triggered
174
+ * early enough for listeners (e.g. plugins using `onPageCreated`) to be able to
175
+ * modify the page instance (e.g. user-agent) before the browser request occurs.
176
+ *
177
+ * This only affects the first request of a newly created page target.
178
+ *
179
+ * As a workaround I've noticed that navigating to `about:blank` (again),
180
+ * right after a page has been created reliably fixes this issue and adds
181
+ * no noticable delay or side-effects.
182
+ *
183
+ * This problem is not specific to `puppeteer-extra` but default Puppeteer behaviour.
184
+ *
185
+ * Note: This patch only fixes explicitly created pages, implicitly created ones
186
+ * (e.g. through `window.open`) are still subject to this issue. I didn't find a
187
+ * reliable mitigation for implicitly created pages yet.
188
+ *
189
+ * Puppeteer issues:
190
+ * https://github.com/GoogleChrome/puppeteer/issues/2669
191
+ * https://github.com/puppeteer/puppeteer/issues/3667
192
+ * https://github.com/GoogleChrome/puppeteer/issues/386#issuecomment-343059315
193
+ * https://github.com/GoogleChrome/puppeteer/issues/1378#issue-273733905
194
+ *
195
+ * @private
196
+ */
197
+ _patchPageCreationMethods(browser) {
198
+ if (!browser._createPageInContext) {
199
+ debug('warning: _patchPageCreationMethods failed (no browser._createPageInContext)');
200
+ return;
201
+ }
202
+ browser._createPageInContext = (function (originalMethod, context) {
203
+ return async function () {
204
+ const page = await originalMethod.apply(context, arguments);
205
+ await page.goto('about:blank');
206
+ return page;
207
+ };
208
+ })(browser._createPageInContext, browser);
209
+ }
210
+ /**
211
+ * Get a list of all registered plugins.
212
+ *
213
+ * @member {Array<PuppeteerExtraPlugin>}
214
+ */
215
+ get plugins() {
216
+ return this._plugins;
217
+ }
218
+ /**
219
+ * Get the names of all registered plugins.
220
+ *
221
+ * @member {Array<string>}
222
+ * @private
223
+ */
224
+ get pluginNames() {
225
+ return this._plugins.map(p => p.name);
226
+ }
227
+ /**
228
+ * Collects the exposed `data` property of all registered plugins.
229
+ * Will be reduced/flattened to a single array.
230
+ *
231
+ * Can be accessed by plugins that listed the `dataFromPlugins` requirement.
232
+ *
233
+ * Implemented mainly for plugins that need data from other plugins (e.g. `user-preferences`).
234
+ *
235
+ * @see [PuppeteerExtraPlugin]/data
236
+ * @param name - Filter data by optional plugin name
237
+ *
238
+ * @private
239
+ */
240
+ getPluginData(name) {
241
+ const data = this._plugins
242
+ .map(p => (Array.isArray(p.data) ? p.data : [p.data]))
243
+ .reduce((acc, arr) => [...acc, ...arr], []);
244
+ return name ? data.filter((d) => d.name === name) : data;
245
+ }
246
+ /**
247
+ * Get all plugins that feature a given property/class method.
248
+ *
249
+ * @private
250
+ */
251
+ getPluginsByProp(prop) {
252
+ return this._plugins.filter(plugin => prop in plugin);
253
+ }
254
+ /**
255
+ * Lightweight plugin dependency management to require plugins and code mods on demand.
256
+ *
257
+ * This uses the `dependencies` stanza (a `Set`) exposed by `puppeteer-extra` plugins.
258
+ *
259
+ * @todo Allow objects as depdencies that contains opts for the requested plugin.
260
+ *
261
+ * @private
262
+ */
263
+ resolvePluginDependencies() {
264
+ // Request missing dependencies from all plugins and flatten to a single Set
265
+ const missingPlugins = this._plugins
266
+ .map(p => p._getMissingDependencies(this._plugins))
267
+ .reduce((combined, list) => {
268
+ return new Set([...combined, ...list]);
269
+ }, new Set());
270
+ if (!missingPlugins.size) {
271
+ debug('no dependencies are missing');
272
+ return;
273
+ }
274
+ debug('dependencies missing', missingPlugins);
275
+ // Loop through all dependencies declared missing by plugins
276
+ for (let name of [...missingPlugins]) {
277
+ // Check if the dependency hasn't been registered as plugin already.
278
+ // This might happen when multiple plugins have nested dependencies.
279
+ if (this.pluginNames.includes(name)) {
280
+ debug(`ignoring dependency '${name}', which has been required already.`);
281
+ continue;
282
+ }
283
+ // We follow a plugin naming convention, but let's rather enforce it <3
284
+ name = name.startsWith('puppeteer-extra-plugin')
285
+ ? name
286
+ : `puppeteer-extra-plugin-${name}`;
287
+ // In case a module sub resource is requested print out the main package name
288
+ // e.g. puppeteer-extra-plugin-stealth/evasions/console.debug => puppeteer-extra-plugin-stealth
289
+ const packageName = name.split('/')[0];
290
+ let dep = null;
291
+ try {
292
+ // Try to require and instantiate the stated dependency
293
+ dep = require(name)();
294
+ // Register it with `puppeteer-extra` as plugin
295
+ this.use(dep);
296
+ }
297
+ catch (err) {
298
+ console.warn(`
299
+ A plugin listed '${name}' as dependency,
300
+ which is currently missing. Please install it:
301
+
302
+ yarn add ${packageName}
303
+
304
+ Note: You don't need to require the plugin yourself,
305
+ unless you want to modify it's default settings.
306
+ `);
307
+ throw err;
308
+ }
309
+ // Handle nested dependencies :D
310
+ if (dep.dependencies.size) {
311
+ this.resolvePluginDependencies();
312
+ }
313
+ }
314
+ }
315
+ /**
316
+ * Order plugins that have expressed a special placement requirement.
317
+ *
318
+ * This is useful/necessary for e.g. plugins that depend on the data from other plugins.
319
+ *
320
+ * @todo Support more than 'runLast'.
321
+ * @todo If there are multiple plugins defining 'runLast', sort them depending on who depends on whom. :D
322
+ *
323
+ * @private
324
+ */
325
+ orderPlugins() {
326
+ debug('orderPlugins:before', this.pluginNames);
327
+ const runLast = this._plugins
328
+ .filter(p => p.requirements.has('runLast'))
329
+ .map(p => p.name);
330
+ for (const name of runLast) {
331
+ const index = this._plugins.findIndex(p => p.name === name);
332
+ this._plugins.push(this._plugins.splice(index, 1)[0]);
333
+ }
334
+ debug('orderPlugins:after', this.pluginNames);
335
+ }
336
+ /**
337
+ * Lightweight plugin requirement checking.
338
+ *
339
+ * The main intent is to notify the user when a plugin won't work as expected.
340
+ *
341
+ * @todo This could be improved, e.g. be evaluated by the plugin base class.
342
+ *
343
+ * @private
344
+ */
345
+ checkPluginRequirements(opts = {}) {
346
+ for (const plugin of this._plugins) {
347
+ for (const requirement of plugin.requirements) {
348
+ if (opts.context === 'launch' &&
349
+ requirement === 'headful' &&
350
+ opts.options.headless) {
351
+ console.warn(`Warning: Plugin '${plugin.name}' is not supported in headless mode.`);
352
+ }
353
+ if (opts.context === 'connect' && requirement === 'launch') {
354
+ console.warn(`Warning: Plugin '${plugin.name}' doesn't support puppeteer.connect().`);
355
+ }
356
+ }
357
+ }
358
+ }
359
+ /**
360
+ * Call plugins sequentially with the same values.
361
+ * Plugins that expose the supplied property will be called.
362
+ *
363
+ * @param prop - The plugin property to call
364
+ * @param values - Any number of values
365
+ * @private
366
+ */
367
+ async callPlugins(prop, ...values) {
368
+ for (const plugin of this.getPluginsByProp(prop)) {
369
+ await plugin[prop].apply(plugin, values);
370
+ }
371
+ }
372
+ /**
373
+ * Call plugins sequentially and pass on a value (waterfall style).
374
+ * Plugins that expose the supplied property will be called.
375
+ *
376
+ * The plugins can either modify the value or return an updated one.
377
+ * Will return the latest, updated value which ran through all plugins.
378
+ *
379
+ * @param prop - The plugin property to call
380
+ * @param value - Any value
381
+ * @return The new updated value
382
+ * @private
383
+ */
384
+ async callPluginsWithValue(prop, value) {
385
+ for (const plugin of this.getPluginsByProp(prop)) {
386
+ const newValue = await plugin[prop](value);
387
+ if (newValue) {
388
+ value = newValue;
389
+ }
390
+ }
391
+ return value;
392
+ }
393
+ }
394
+ /**
395
+ * The **default export** will behave exactly the same as the regular puppeteer
396
+ * (just with extra plugin functionality) and can be used as a drop-in replacement.
397
+ *
398
+ * Behind the scenes it will try to require either `puppeteer`
399
+ * or [`puppeteer-core`](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteer-vs-puppeteer-core)
400
+ * from the installed dependencies.
401
+ *
402
+ * @example
403
+ * // javascript import
404
+ * const puppeteer = require('puppeteer-extra')
405
+ *
406
+ * // typescript/es6 module import
407
+ * import puppeteer from 'puppeteer-extra'
408
+ *
409
+ * // Add plugins
410
+ * puppeteer.use(...)
411
+ */
412
+ const defaultExport = (() => {
413
+ return new PuppeteerExtra(...requireVanillaPuppeteer());
414
+ })();
415
+ /**
416
+ * An **alternative way** to use `puppeteer-extra`: Augments the provided puppeteer with extra plugin functionality.
417
+ *
418
+ * This is useful in case you need multiple puppeteer instances with different plugins or to add plugins to a non-standard puppeteer package.
419
+ *
420
+ * @example
421
+ * // js import
422
+ * const { addExtra } = require('puppeteer-extra')
423
+ *
424
+ * // ts/es6 import
425
+ * import { addExtra } from 'puppeteer-extra'
426
+ *
427
+ * // Patch e.g. puppeteer-firefox and add plugins
428
+ * const puppeteer = addExtra(require('puppeteer-firefox'))
429
+ * puppeteer.use(...)
430
+ *
431
+ * @param puppeteer Any puppeteer API-compatible puppeteer implementation or version.
432
+ * @return A fresh PuppeteerExtra instance using the provided puppeteer
433
+ */
434
+ const addExtra = (puppeteer) => new PuppeteerExtra(puppeteer);
435
+ /**
436
+ * Attempt to require puppeteer or puppeteer-core from dependencies.
437
+ * To stay backwards compatible with the existing default export we have to do some gymnastics here.
438
+ *
439
+ * @return Either a Puppeteer instance or an Error, which we'll throw later if need be.
440
+ * @private
441
+ */
442
+ function requireVanillaPuppeteer() {
443
+ try {
444
+ return [require('puppeteer'), undefined];
445
+ }
446
+ catch (_) {
447
+ // noop
448
+ }
449
+ try {
450
+ return [require('puppeteer-core'), undefined];
451
+ }
452
+ catch (err) {
453
+ return [undefined, err];
454
+ }
455
+ }
456
+
457
+ export default defaultExport;
458
+ export { PuppeteerExtra, addExtra };
459
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["/// <reference path=\"./puppeteer-legacy.d.ts\" />\nimport { PuppeteerNode, Browser, Page } from 'puppeteer'\n\nimport Debug from 'debug'\nconst debug = Debug('puppeteer-extra')\n\nimport merge from 'deepmerge'\n\n/**\n * Original Puppeteer API\n * @private\n */\nexport interface VanillaPuppeteer\n extends Pick<\n PuppeteerNode,\n | 'connect'\n | 'defaultArgs'\n | 'executablePath'\n | 'launch'\n | 'createBrowserFetcher'\n > {}\n\n/**\n * Minimal plugin interface\n * @private\n */\nexport interface PuppeteerExtraPlugin {\n _isPuppeteerExtraPlugin: boolean\n [propName: string]: any\n}\n\n/**\n * We need to hook into non-public APIs in rare occasions to fix puppeteer bugs. :(\n * @private\n */\ninterface BrowserInternals extends Browser {\n _createPageInContext(contextId?: string): Promise<Page>\n}\n\n/**\n * Modular plugin framework to teach `puppeteer` new tricks.\n *\n * This module acts as a drop-in replacement for `puppeteer`.\n *\n * Allows PuppeteerExtraPlugin's to register themselves and\n * to extend puppeteer with additional functionality.\n *\n * @class PuppeteerExtra\n * @implements {VanillaPuppeteer}\n *\n * @example\n * const puppeteer = require('puppeteer-extra')\n * puppeteer.use(require('puppeteer-extra-plugin-anonymize-ua')())\n * puppeteer.use(require('puppeteer-extra-plugin-font-size')({defaultFontSize: 18}))\n *\n * ;(async () => {\n * const browser = await puppeteer.launch({headless: false})\n * const page = await browser.newPage()\n * await page.goto('http://example.com', {waitUntil: 'domcontentloaded'})\n * await browser.close()\n * })()\n */\nexport class PuppeteerExtra implements VanillaPuppeteer {\n private _plugins: PuppeteerExtraPlugin[] = []\n\n constructor(\n private _pptr?: VanillaPuppeteer,\n private _requireError?: Error\n ) {}\n\n /**\n * The **main interface** to register `puppeteer-extra` plugins.\n *\n * @example\n * puppeteer.use(plugin1).use(plugin2)\n *\n * @see [PuppeteerExtraPlugin]\n *\n * @return The same `PuppeteerExtra` instance (for optional chaining)\n */\n use(plugin: PuppeteerExtraPlugin): this {\n if (typeof plugin !== 'object' || !plugin._isPuppeteerExtraPlugin) {\n console.error(\n `Warning: Plugin is not derived from PuppeteerExtraPlugin, ignoring.`,\n plugin\n )\n return this\n }\n if (!plugin.name) {\n console.error(\n `Warning: Plugin with no name registering, ignoring.`,\n plugin\n )\n return this\n }\n if (plugin.requirements.has('dataFromPlugins')) {\n plugin.getDataFromPlugins = this.getPluginData.bind(this)\n }\n plugin._register(Object.getPrototypeOf(plugin))\n this._plugins.push(plugin)\n debug('plugin registered', plugin.name)\n return this\n }\n\n /**\n * To stay backwards compatible with puppeteer's (and our) default export after adding `addExtra`\n * we need to defer the check if we have a puppeteer instance to work with.\n * Otherwise we would throw even if the user intends to use their non-standard puppeteer implementation.\n *\n * @private\n */\n get pptr(): VanillaPuppeteer {\n if (this._pptr) {\n return this._pptr\n }\n\n // Whoopsie\n console.warn(`\n Puppeteer is missing. :-)\n\n Note: puppeteer is a peer dependency of puppeteer-extra,\n which means you can install your own preferred version.\n\n - To get the latest stable version run: 'yarn add puppeteer' or 'npm i puppeteer'\n\n Alternatively:\n - To get puppeteer without the bundled Chromium browser install 'puppeteer-core'\n `)\n throw this._requireError || new Error('No puppeteer instance provided.')\n }\n\n /**\n * The method launches a browser instance with given arguments. The browser will be closed when the parent node.js process is closed.\n *\n * Augments the original `puppeteer.launch` method with plugin lifecycle methods.\n *\n * All registered plugins that have a `beforeLaunch` method will be called\n * in sequence to potentially update the `options` Object before launching the browser.\n *\n * @example\n * const browser = await puppeteer.launch({\n * headless: false,\n * defaultViewport: null\n * })\n *\n * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).\n */\n async launch(\n options?: Parameters<VanillaPuppeteer['launch']>[0]\n ): ReturnType<VanillaPuppeteer['launch']> {\n // Ensure there are certain properties (e.g. the `options.args` array)\n const defaultLaunchOptions = { args: [] }\n options = merge(defaultLaunchOptions, options || {})\n this.resolvePluginDependencies()\n this.orderPlugins()\n\n // Give plugins the chance to modify the options before launch\n options = await this.callPluginsWithValue('beforeLaunch', options)\n\n const opts = {\n context: 'launch',\n options,\n defaultArgs: this.defaultArgs\n }\n\n // Let's check requirements after plugin had the chance to modify the options\n this.checkPluginRequirements(opts)\n\n const browser = await this.pptr.launch(options)\n this._patchPageCreationMethods(browser as BrowserInternals)\n\n await this.callPlugins('_bindBrowserEvents', browser, opts)\n return browser\n }\n\n /**\n * Attach Puppeteer to an existing Chromium instance.\n *\n * Augments the original `puppeteer.connect` method with plugin lifecycle methods.\n *\n * All registered plugins that have a `beforeConnect` method will be called\n * in sequence to potentially update the `options` Object before launching the browser.\n *\n * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerconnectoptions).\n */\n async connect(\n options: Parameters<VanillaPuppeteer['connect']>[0]\n ): ReturnType<VanillaPuppeteer['connect']> {\n this.resolvePluginDependencies()\n this.orderPlugins()\n\n // Give plugins the chance to modify the options before connect\n options = await this.callPluginsWithValue('beforeConnect', options)\n\n const opts = { context: 'connect', options }\n\n // Let's check requirements after plugin had the chance to modify the options\n this.checkPluginRequirements(opts)\n\n const browser = await this.pptr.connect(options)\n this._patchPageCreationMethods(browser as BrowserInternals)\n\n await this.callPlugins('_bindBrowserEvents', browser, opts)\n return browser\n }\n\n /**\n * The default flags that Chromium will be launched with.\n *\n * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerdefaultargsoptions).\n */\n defaultArgs(\n options?: Parameters<VanillaPuppeteer['defaultArgs']>[0]\n ): ReturnType<VanillaPuppeteer['defaultArgs']> {\n return this.pptr.defaultArgs(options)\n }\n\n /** Path where Puppeteer expects to find bundled Chromium. */\n executablePath(): string {\n return this.pptr.executablePath()\n }\n\n /**\n * This methods attaches Puppeteer to an existing Chromium instance.\n *\n * @param options - See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteercreatebrowserfetcheroptions).\n */\n createBrowserFetcher(\n options: Parameters<VanillaPuppeteer['createBrowserFetcher']>[0]\n ): ReturnType<VanillaPuppeteer['createBrowserFetcher']> {\n return this.pptr.createBrowserFetcher(options)\n }\n\n /**\n * Patch page creation methods (both regular and incognito contexts).\n *\n * Unfortunately it's possible that the `targetcreated` events are not triggered\n * early enough for listeners (e.g. plugins using `onPageCreated`) to be able to\n * modify the page instance (e.g. user-agent) before the browser request occurs.\n *\n * This only affects the first request of a newly created page target.\n *\n * As a workaround I've noticed that navigating to `about:blank` (again),\n * right after a page has been created reliably fixes this issue and adds\n * no noticable delay or side-effects.\n *\n * This problem is not specific to `puppeteer-extra` but default Puppeteer behaviour.\n *\n * Note: This patch only fixes explicitly created pages, implicitly created ones\n * (e.g. through `window.open`) are still subject to this issue. I didn't find a\n * reliable mitigation for implicitly created pages yet.\n *\n * Puppeteer issues:\n * https://github.com/GoogleChrome/puppeteer/issues/2669\n * https://github.com/puppeteer/puppeteer/issues/3667\n * https://github.com/GoogleChrome/puppeteer/issues/386#issuecomment-343059315\n * https://github.com/GoogleChrome/puppeteer/issues/1378#issue-273733905\n *\n * @private\n */\n private _patchPageCreationMethods(browser: BrowserInternals) {\n if (!browser._createPageInContext) {\n debug(\n 'warning: _patchPageCreationMethods failed (no browser._createPageInContext)'\n )\n return\n }\n browser._createPageInContext = (function(originalMethod, context) {\n return async function() {\n const page = await originalMethod.apply(context, arguments as any)\n await page.goto('about:blank')\n return page\n }\n })(browser._createPageInContext, browser)\n }\n\n /**\n * Get a list of all registered plugins.\n *\n * @member {Array<PuppeteerExtraPlugin>}\n */\n get plugins() {\n return this._plugins\n }\n\n /**\n * Get the names of all registered plugins.\n *\n * @member {Array<string>}\n * @private\n */\n get pluginNames() {\n return this._plugins.map(p => p.name)\n }\n\n /**\n * Collects the exposed `data` property of all registered plugins.\n * Will be reduced/flattened to a single array.\n *\n * Can be accessed by plugins that listed the `dataFromPlugins` requirement.\n *\n * Implemented mainly for plugins that need data from other plugins (e.g. `user-preferences`).\n *\n * @see [PuppeteerExtraPlugin]/data\n * @param name - Filter data by optional plugin name\n *\n * @private\n */\n public getPluginData(name?: string) {\n const data = this._plugins\n .map(p => (Array.isArray(p.data) ? p.data : [p.data]))\n .reduce((acc, arr) => [...acc, ...arr], [])\n return name ? data.filter((d: any) => d.name === name) : data\n }\n\n /**\n * Get all plugins that feature a given property/class method.\n *\n * @private\n */\n private getPluginsByProp(prop: string): PuppeteerExtraPlugin[] {\n return this._plugins.filter(plugin => prop in plugin)\n }\n\n /**\n * Lightweight plugin dependency management to require plugins and code mods on demand.\n *\n * This uses the `dependencies` stanza (a `Set`) exposed by `puppeteer-extra` plugins.\n *\n * @todo Allow objects as depdencies that contains opts for the requested plugin.\n *\n * @private\n */\n private resolvePluginDependencies() {\n // Request missing dependencies from all plugins and flatten to a single Set\n const missingPlugins = this._plugins\n .map(p => p._getMissingDependencies(this._plugins))\n .reduce((combined, list) => {\n return new Set([...combined, ...list])\n }, new Set())\n if (!missingPlugins.size) {\n debug('no dependencies are missing')\n return\n }\n debug('dependencies missing', missingPlugins)\n // Loop through all dependencies declared missing by plugins\n for (let name of [...missingPlugins]) {\n // Check if the dependency hasn't been registered as plugin already.\n // This might happen when multiple plugins have nested dependencies.\n if (this.pluginNames.includes(name)) {\n debug(`ignoring dependency '${name}', which has been required already.`)\n continue\n }\n // We follow a plugin naming convention, but let's rather enforce it <3\n name = name.startsWith('puppeteer-extra-plugin')\n ? name\n : `puppeteer-extra-plugin-${name}`\n // In case a module sub resource is requested print out the main package name\n // e.g. puppeteer-extra-plugin-stealth/evasions/console.debug => puppeteer-extra-plugin-stealth\n const packageName = name.split('/')[0]\n let dep = null\n try {\n // Try to require and instantiate the stated dependency\n dep = require(name)()\n // Register it with `puppeteer-extra` as plugin\n this.use(dep)\n } catch (err) {\n console.warn(`\n A plugin listed '${name}' as dependency,\n which is currently missing. Please install it:\n\n yarn add ${packageName}\n\n Note: You don't need to require the plugin yourself,\n unless you want to modify it's default settings.\n `)\n throw err\n }\n // Handle nested dependencies :D\n if (dep.dependencies.size) {\n this.resolvePluginDependencies()\n }\n }\n }\n\n /**\n * Order plugins that have expressed a special placement requirement.\n *\n * This is useful/necessary for e.g. plugins that depend on the data from other plugins.\n *\n * @todo Support more than 'runLast'.\n * @todo If there are multiple plugins defining 'runLast', sort them depending on who depends on whom. :D\n *\n * @private\n */\n private orderPlugins() {\n debug('orderPlugins:before', this.pluginNames)\n const runLast = this._plugins\n .filter(p => p.requirements.has('runLast'))\n .map(p => p.name)\n for (const name of runLast) {\n const index = this._plugins.findIndex(p => p.name === name)\n this._plugins.push(this._plugins.splice(index, 1)[0])\n }\n debug('orderPlugins:after', this.pluginNames)\n }\n\n /**\n * Lightweight plugin requirement checking.\n *\n * The main intent is to notify the user when a plugin won't work as expected.\n *\n * @todo This could be improved, e.g. be evaluated by the plugin base class.\n *\n * @private\n */\n private checkPluginRequirements(opts = {} as any) {\n for (const plugin of this._plugins) {\n for (const requirement of plugin.requirements) {\n if (\n opts.context === 'launch' &&\n requirement === 'headful' &&\n opts.options.headless\n ) {\n console.warn(\n `Warning: Plugin '${plugin.name}' is not supported in headless mode.`\n )\n }\n if (opts.context === 'connect' && requirement === 'launch') {\n console.warn(\n `Warning: Plugin '${plugin.name}' doesn't support puppeteer.connect().`\n )\n }\n }\n }\n }\n\n /**\n * Call plugins sequentially with the same values.\n * Plugins that expose the supplied property will be called.\n *\n * @param prop - The plugin property to call\n * @param values - Any number of values\n * @private\n */\n private async callPlugins(prop: string, ...values: any[]) {\n for (const plugin of this.getPluginsByProp(prop)) {\n await plugin[prop].apply(plugin, values)\n }\n }\n\n /**\n * Call plugins sequentially and pass on a value (waterfall style).\n * Plugins that expose the supplied property will be called.\n *\n * The plugins can either modify the value or return an updated one.\n * Will return the latest, updated value which ran through all plugins.\n *\n * @param prop - The plugin property to call\n * @param value - Any value\n * @return The new updated value\n * @private\n */\n private async callPluginsWithValue(prop: string, value: any) {\n for (const plugin of this.getPluginsByProp(prop)) {\n const newValue = await plugin[prop](value)\n if (newValue) {\n value = newValue\n }\n }\n return value\n }\n}\n\n/**\n * The **default export** will behave exactly the same as the regular puppeteer\n * (just with extra plugin functionality) and can be used as a drop-in replacement.\n *\n * Behind the scenes it will try to require either `puppeteer`\n * or [`puppeteer-core`](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteer-vs-puppeteer-core)\n * from the installed dependencies.\n *\n * @example\n * // javascript import\n * const puppeteer = require('puppeteer-extra')\n *\n * // typescript/es6 module import\n * import puppeteer from 'puppeteer-extra'\n *\n * // Add plugins\n * puppeteer.use(...)\n */\nconst defaultExport: PuppeteerExtra = (() => {\n return new PuppeteerExtra(...requireVanillaPuppeteer())\n})()\n\nexport default defaultExport\n\n/**\n * An **alternative way** to use `puppeteer-extra`: Augments the provided puppeteer with extra plugin functionality.\n *\n * This is useful in case you need multiple puppeteer instances with different plugins or to add plugins to a non-standard puppeteer package.\n *\n * @example\n * // js import\n * const { addExtra } = require('puppeteer-extra')\n *\n * // ts/es6 import\n * import { addExtra } from 'puppeteer-extra'\n *\n * // Patch e.g. puppeteer-firefox and add plugins\n * const puppeteer = addExtra(require('puppeteer-firefox'))\n * puppeteer.use(...)\n *\n * @param puppeteer Any puppeteer API-compatible puppeteer implementation or version.\n * @return A fresh PuppeteerExtra instance using the provided puppeteer\n */\nexport const addExtra = (puppeteer: VanillaPuppeteer): PuppeteerExtra =>\n new PuppeteerExtra(puppeteer)\n\n/**\n * Attempt to require puppeteer or puppeteer-core from dependencies.\n * To stay backwards compatible with the existing default export we have to do some gymnastics here.\n *\n * @return Either a Puppeteer instance or an Error, which we'll throw later if need be.\n * @private\n */\nfunction requireVanillaPuppeteer(): [VanillaPuppeteer?, Error?] {\n try {\n return [require('puppeteer'), undefined]\n } catch (_) {\n // noop\n }\n try {\n return [require('puppeteer-core'), undefined]\n } catch (err) {\n return [undefined, err as Error]\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAIA,MAAM,KAAK,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAA;AAmCtC;;;;;;;;;;;;;;;;;;;;;;;MAuBa,cAAc;IAGzB,YACU,KAAwB,EACxB,aAAqB;QADrB,UAAK,GAAL,KAAK,CAAmB;QACxB,kBAAa,GAAb,aAAa,CAAQ;QAJvB,aAAQ,GAA2B,EAAE,CAAA;KAKzC;;;;;;;;;;;IAYJ,GAAG,CAAC,MAA4B;QAC9B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE;YACjE,OAAO,CAAC,KAAK,CACX,qEAAqE,EACrE,MAAM,CACP,CAAA;YACD,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAChB,OAAO,CAAC,KAA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