brave-real-puppeteer-core 24.20.0 → 24.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/advanced-stealth.js +1 -1
- package/lib/cjs/puppeteer/api/Browser.d.ts +1 -1
- package/lib/cjs/puppeteer/api/Dialog.d.ts +8 -10
- package/lib/cjs/puppeteer/api/Dialog.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/Dialog.js +8 -10
- package/lib/cjs/puppeteer/api/Dialog.js.map +1 -1
- package/lib/cjs/puppeteer/api/ElementHandle.d.ts +28 -30
- package/lib/cjs/puppeteer/api/ElementHandle.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/ElementHandle.js +27 -29
- package/lib/cjs/puppeteer/api/ElementHandle.js.map +1 -1
- package/lib/cjs/puppeteer/api/Frame.d.ts +34 -38
- package/lib/cjs/puppeteer/api/Frame.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/Frame.js +34 -38
- package/lib/cjs/puppeteer/api/Frame.js.map +1 -1
- package/lib/cjs/puppeteer/api/HTTPRequest.d.ts +8 -1
- package/lib/cjs/puppeteer/api/HTTPRequest.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/HTTPRequest.js +12 -14
- package/lib/cjs/puppeteer/api/HTTPRequest.js.map +1 -1
- package/lib/cjs/puppeteer/api/Page.d.ts +103 -109
- package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
- package/lib/cjs/puppeteer/api/Page.js +35 -41
- package/lib/cjs/puppeteer/api/Page.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/Browser.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/Browser.js +5 -3
- package/lib/cjs/puppeteer/bidi/Browser.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/Frame.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/Frame.js +1 -1
- package/lib/cjs/puppeteer/bidi/Frame.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/HTTPRequest.d.ts +4 -2
- package/lib/cjs/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/HTTPRequest.js +14 -5
- package/lib/cjs/puppeteer/bidi/HTTPRequest.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/Page.d.ts +6 -1
- package/lib/cjs/puppeteer/bidi/Page.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/Page.js +42 -14
- package/lib/cjs/puppeteer/bidi/Page.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/Browser.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/Browser.js +24 -2
- package/lib/cjs/puppeteer/bidi/core/Browser.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +1 -3
- package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/lib/cjs/puppeteer/bidi/core/Realm.d.ts +2 -2
- package/lib/cjs/puppeteer/cdp/Accessibility.js +0 -20
- package/lib/cjs/puppeteer/cdp/Accessibility.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts +1 -0
- package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/HTTPRequest.js +3 -0
- package/lib/cjs/puppeteer/cdp/HTTPRequest.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts +1 -1
- package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/NetworkManager.js +8 -2
- package/lib/cjs/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/Page.d.ts +5 -1
- package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/Page.js +8 -2
- package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.d.ts +13 -22
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.d.ts.map +1 -1
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.js +13 -22
- package/lib/cjs/puppeteer/cdp/PredefinedNetworkConditions.js.map +1 -1
- package/lib/cjs/puppeteer/common/Device.d.ts +6 -8
- package/lib/cjs/puppeteer/common/Device.d.ts.map +1 -1
- package/lib/cjs/puppeteer/common/Device.js +6 -8
- package/lib/cjs/puppeteer/common/Device.js.map +1 -1
- package/lib/cjs/puppeteer/generated/injected.d.ts +1 -1
- package/lib/cjs/puppeteer/generated/injected.js +1 -1
- package/lib/cjs/puppeteer/generated/version.d.ts +1 -1
- package/lib/cjs/puppeteer/generated/version.js +1 -1
- package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts +1 -1
- package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/BrowserLauncher.js +12 -4
- package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/ChromeLauncher.js +1 -0
- package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/lib/cjs/puppeteer/node/PipeTransport.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/PipeTransport.js +15 -16
- package/lib/cjs/puppeteer/node/PipeTransport.js.map +1 -1
- package/lib/cjs/puppeteer/node/PuppeteerNode.d.ts +5 -7
- package/lib/cjs/puppeteer/node/PuppeteerNode.d.ts.map +1 -1
- package/lib/cjs/puppeteer/node/PuppeteerNode.js +5 -7
- package/lib/cjs/puppeteer/node/PuppeteerNode.js.map +1 -1
- package/lib/cjs/puppeteer/revisions.d.ts +3 -3
- package/lib/cjs/puppeteer/revisions.js +3 -3
- package/lib/cjs/puppeteer/util/Function.d.ts.map +1 -1
- package/lib/cjs/puppeteer/util/Function.js +16 -25
- package/lib/cjs/puppeteer/util/Function.js.map +1 -1
- package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/lib/es5-iife/puppeteer-core-browser.d.ts +201 -227
- package/lib/es5-iife/puppeteer-core-browser.js +176 -218
- package/lib/esm/puppeteer/api/Browser.d.ts +1 -1
- package/lib/esm/puppeteer/api/Dialog.d.ts +8 -10
- package/lib/esm/puppeteer/api/Dialog.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/Dialog.js +8 -10
- package/lib/esm/puppeteer/api/Dialog.js.map +1 -1
- package/lib/esm/puppeteer/api/ElementHandle.d.ts +28 -30
- package/lib/esm/puppeteer/api/ElementHandle.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/ElementHandle.js +27 -29
- package/lib/esm/puppeteer/api/ElementHandle.js.map +1 -1
- package/lib/esm/puppeteer/api/Frame.d.ts +34 -38
- package/lib/esm/puppeteer/api/Frame.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/Frame.js +34 -38
- package/lib/esm/puppeteer/api/Frame.js.map +1 -1
- package/lib/esm/puppeteer/api/HTTPRequest.d.ts +8 -1
- package/lib/esm/puppeteer/api/HTTPRequest.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/HTTPRequest.js +12 -14
- package/lib/esm/puppeteer/api/HTTPRequest.js.map +1 -1
- package/lib/esm/puppeteer/api/Page.d.ts +103 -109
- package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
- package/lib/esm/puppeteer/api/Page.js +35 -41
- package/lib/esm/puppeteer/api/Page.js.map +1 -1
- package/lib/esm/puppeteer/bidi/Browser.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/Browser.js +5 -3
- package/lib/esm/puppeteer/bidi/Browser.js.map +1 -1
- package/lib/esm/puppeteer/bidi/Frame.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/Frame.js +1 -1
- package/lib/esm/puppeteer/bidi/Frame.js.map +1 -1
- package/lib/esm/puppeteer/bidi/HTTPRequest.d.ts +4 -2
- package/lib/esm/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/HTTPRequest.js +15 -6
- package/lib/esm/puppeteer/bidi/HTTPRequest.js.map +1 -1
- package/lib/esm/puppeteer/bidi/Page.d.ts +6 -1
- package/lib/esm/puppeteer/bidi/Page.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/Page.js +42 -14
- package/lib/esm/puppeteer/bidi/Page.js.map +1 -1
- package/lib/esm/puppeteer/bidi/core/Browser.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/core/Browser.js +24 -2
- package/lib/esm/puppeteer/bidi/core/Browser.js.map +1 -1
- package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +1 -3
- package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/lib/esm/puppeteer/cdp/Accessibility.js +0 -20
- package/lib/esm/puppeteer/cdp/Accessibility.js.map +1 -1
- package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts +1 -0
- package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/HTTPRequest.js +3 -0
- package/lib/esm/puppeteer/cdp/HTTPRequest.js.map +1 -1
- package/lib/esm/puppeteer/cdp/NetworkManager.d.ts +1 -1
- package/lib/esm/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/NetworkManager.js +8 -2
- package/lib/esm/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/lib/esm/puppeteer/cdp/Page.d.ts +5 -1
- package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/Page.js +8 -2
- package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.d.ts +13 -22
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.d.ts.map +1 -1
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.js +13 -22
- package/lib/esm/puppeteer/cdp/PredefinedNetworkConditions.js.map +1 -1
- package/lib/esm/puppeteer/common/Device.d.ts +6 -8
- package/lib/esm/puppeteer/common/Device.d.ts.map +1 -1
- package/lib/esm/puppeteer/common/Device.js +6 -8
- package/lib/esm/puppeteer/common/Device.js.map +1 -1
- package/lib/esm/puppeteer/generated/injected.d.ts +1 -1
- package/lib/esm/puppeteer/generated/injected.js +1 -1
- package/lib/esm/puppeteer/generated/version.d.ts +1 -1
- package/lib/esm/puppeteer/generated/version.js +1 -1
- package/lib/esm/puppeteer/node/BrowserLauncher.d.ts +1 -1
- package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/BrowserLauncher.js +12 -4
- package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/ChromeLauncher.js +1 -0
- package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/lib/esm/puppeteer/node/PipeTransport.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/PipeTransport.js +15 -16
- package/lib/esm/puppeteer/node/PipeTransport.js.map +1 -1
- package/lib/esm/puppeteer/node/PuppeteerNode.d.ts +5 -7
- package/lib/esm/puppeteer/node/PuppeteerNode.d.ts.map +1 -1
- package/lib/esm/puppeteer/node/PuppeteerNode.js +5 -7
- package/lib/esm/puppeteer/node/PuppeteerNode.js.map +1 -1
- package/lib/esm/puppeteer/revisions.d.ts +3 -3
- package/lib/esm/puppeteer/revisions.js +3 -3
- package/lib/esm/puppeteer/util/Function.d.ts.map +1 -1
- package/lib/esm/puppeteer/util/Function.js +16 -25
- package/lib/esm/puppeteer/util/Function.js.map +1 -1
- package/lib/types.d.ts +201 -227
- package/package.json +16 -16
- package/src/api/Browser.ts +1 -1
- package/src/api/Dialog.ts +8 -10
- package/src/api/ElementHandle.ts +27 -29
- package/src/api/Frame.ts +34 -38
- package/src/api/HTTPRequest.ts +17 -14
- package/src/api/Page.ts +105 -110
- package/src/bidi/Browser.ts +5 -3
- package/src/bidi/Frame.ts +5 -1
- package/src/bidi/HTTPRequest.ts +28 -3
- package/src/bidi/Page.ts +66 -15
- package/src/bidi/core/Browser.ts +28 -2
- package/src/bidi/core/BrowsingContext.ts +0 -1
- package/src/cdp/Accessibility.ts +1 -21
- package/src/cdp/HTTPRequest.ts +4 -0
- package/src/cdp/NetworkManager.ts +8 -1
- package/src/cdp/Page.ts +21 -5
- package/src/cdp/PredefinedNetworkConditions.ts +13 -22
- package/src/common/Device.ts +6 -8
- package/src/generated/injected.ts +1 -1
- package/src/generated/version.ts +1 -1
- package/src/node/BrowserLauncher.ts +19 -4
- package/src/node/ChromeLauncher.ts +1 -0
- package/src/node/PipeTransport.ts +15 -17
- package/src/node/PuppeteerNode.ts +5 -7
- package/src/revisions.ts +3 -3
- package/src/util/Function.ts +22 -30
package/src/cdp/HTTPRequest.ts
CHANGED
|
@@ -77,11 +77,12 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
|
|
|
77
77
|
#credentials: Credentials | null = null;
|
|
78
78
|
#attemptedAuthentications = new Set<string>();
|
|
79
79
|
#userRequestInterceptionEnabled = false;
|
|
80
|
-
#protocolRequestInterceptionEnabled
|
|
80
|
+
#protocolRequestInterceptionEnabled?: boolean;
|
|
81
81
|
#userCacheDisabled?: boolean;
|
|
82
82
|
#emulatedNetworkConditions?: InternalNetworkConditions;
|
|
83
83
|
#userAgent?: string;
|
|
84
84
|
#userAgentMetadata?: Protocol.Emulation.UserAgentMetadata;
|
|
85
|
+
#platform?: string;
|
|
85
86
|
|
|
86
87
|
readonly #handlers = [
|
|
87
88
|
['Fetch.requestPaused', this.#onRequestPaused],
|
|
@@ -265,9 +266,11 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
|
|
|
265
266
|
async setUserAgent(
|
|
266
267
|
userAgent: string,
|
|
267
268
|
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata,
|
|
269
|
+
platform?: string,
|
|
268
270
|
): Promise<void> {
|
|
269
271
|
this.#userAgent = userAgent;
|
|
270
272
|
this.#userAgentMetadata = userAgentMetadata;
|
|
273
|
+
this.#platform = platform;
|
|
271
274
|
await this.#applyToAllClients(this.#applyUserAgent.bind(this));
|
|
272
275
|
}
|
|
273
276
|
|
|
@@ -279,6 +282,7 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
|
|
|
279
282
|
await client.send('Network.setUserAgentOverride', {
|
|
280
283
|
userAgent: this.#userAgent,
|
|
281
284
|
userAgentMetadata: this.#userAgentMetadata,
|
|
285
|
+
platform: this.#platform,
|
|
282
286
|
});
|
|
283
287
|
} catch (error) {
|
|
284
288
|
if (this.#canIgnoreError(error)) {
|
|
@@ -306,6 +310,9 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
|
|
|
306
310
|
}
|
|
307
311
|
|
|
308
312
|
async #applyProtocolRequestInterception(client: CDPSession): Promise<void> {
|
|
313
|
+
if (this.#protocolRequestInterceptionEnabled === undefined) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
309
316
|
if (this.#userCacheDisabled === undefined) {
|
|
310
317
|
this.#userCacheDisabled = false;
|
|
311
318
|
}
|
package/src/cdp/Page.ts
CHANGED
|
@@ -747,13 +747,29 @@ export class CdpPage extends Page {
|
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
override async setUserAgent(
|
|
750
|
-
|
|
750
|
+
userAgentOrOptions:
|
|
751
|
+
| string
|
|
752
|
+
| {
|
|
753
|
+
userAgent?: string;
|
|
754
|
+
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata;
|
|
755
|
+
platform?: string;
|
|
756
|
+
},
|
|
751
757
|
userAgentMetadata?: Protocol.Emulation.UserAgentMetadata,
|
|
752
758
|
): Promise<void> {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
759
|
+
if (typeof userAgentOrOptions === 'string') {
|
|
760
|
+
return await this.#frameManager.networkManager.setUserAgent(
|
|
761
|
+
userAgentOrOptions,
|
|
762
|
+
userAgentMetadata,
|
|
763
|
+
);
|
|
764
|
+
} else {
|
|
765
|
+
const userAgent =
|
|
766
|
+
userAgentOrOptions.userAgent ?? (await this.browser().userAgent());
|
|
767
|
+
return await this.#frameManager.networkManager.setUserAgent(
|
|
768
|
+
userAgent,
|
|
769
|
+
userAgentOrOptions.userAgentMetadata,
|
|
770
|
+
userAgentOrOptions.platform,
|
|
771
|
+
);
|
|
772
|
+
}
|
|
757
773
|
}
|
|
758
774
|
|
|
759
775
|
override async metrics(): Promise<Metrics> {
|
|
@@ -14,28 +14,19 @@ import type {NetworkConditions} from './NetworkManager.js';
|
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
16
|
* import {PredefinedNetworkConditions} from 'puppeteer';
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* ); // alias to Fast 3G.
|
|
31
|
-
* await page.goto('https://www.google.com');
|
|
32
|
-
* await page.emulateNetworkConditions(
|
|
33
|
-
* PredefinedNetworkConditions['Fast 4G'],
|
|
34
|
-
* );
|
|
35
|
-
* await page.goto('https://www.google.com');
|
|
36
|
-
* // other actions...
|
|
37
|
-
* await browser.close();
|
|
38
|
-
* })();
|
|
17
|
+
* const browser = await puppeteer.launch();
|
|
18
|
+
* const page = await browser.newPage();
|
|
19
|
+
* await page.emulateNetworkConditions(PredefinedNetworkConditions['Slow 3G']);
|
|
20
|
+
* await page.goto('https://www.google.com');
|
|
21
|
+
* await page.emulateNetworkConditions(PredefinedNetworkConditions['Fast 3G']);
|
|
22
|
+
* await page.goto('https://www.google.com');
|
|
23
|
+
* // alias to Fast 3G.
|
|
24
|
+
* await page.emulateNetworkConditions(PredefinedNetworkConditions['Slow 4G']);
|
|
25
|
+
* await page.goto('https://www.google.com');
|
|
26
|
+
* await page.emulateNetworkConditions(PredefinedNetworkConditions['Fast 4G']);
|
|
27
|
+
* await page.goto('https://www.google.com');
|
|
28
|
+
* // other actions...
|
|
29
|
+
* await browser.close();
|
|
39
30
|
* ```
|
|
40
31
|
*
|
|
41
32
|
* @public
|
package/src/common/Device.ts
CHANGED
|
@@ -1738,14 +1738,12 @@ for (const device of knownDevices) {
|
|
|
1738
1738
|
* import {KnownDevices} from 'puppeteer';
|
|
1739
1739
|
* const iPhone = KnownDevices['iPhone 15 Pro'];
|
|
1740
1740
|
*
|
|
1741
|
-
*
|
|
1742
|
-
*
|
|
1743
|
-
*
|
|
1744
|
-
*
|
|
1745
|
-
*
|
|
1746
|
-
*
|
|
1747
|
-
* await browser.close();
|
|
1748
|
-
* })();
|
|
1741
|
+
* const browser = await puppeteer.launch();
|
|
1742
|
+
* const page = await browser.newPage();
|
|
1743
|
+
* await page.emulate(iPhone);
|
|
1744
|
+
* await page.goto('https://www.google.com');
|
|
1745
|
+
* // other actions...
|
|
1746
|
+
* await browser.close();
|
|
1749
1747
|
* ```
|
|
1750
1748
|
*
|
|
1751
1749
|
* @public
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export const source = "\"use strict\";var g=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var
|
|
8
|
+
export const source = "\"use strict\";var g=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var r in e)g(t,r,{get:e[r],enumerable:!0})},G=(t,e,r,o)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let s of B(e))!Y.call(t,s)&&s!==r&&g(t,s,{get:()=>e[s],enumerable:!(o=X(e,s))||o.enumerable});return t};var J=t=>G(g({},\"__esModule\",{value:!0}),t);var pe={};l(pe,{default:()=>he});module.exports=J(pe);var N=class extends Error{constructor(e,r){super(e,r),this.name=this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}},p=class extends N{};var c=class t{static create(e){return new t(e)}static async race(e){let r=new Set;try{let o=e.map(s=>s instanceof t?(s.#s&&r.add(s),s.valueOrThrow()):s);return await Promise.race(o)}finally{for(let o of r)o.reject(new Error(\"Timeout cleared\"))}}#e=!1;#r=!1;#o;#t;#a=new Promise(e=>{this.#t=e});#s;#i;constructor(e){e&&e.timeout>0&&(this.#i=new p(e.message),this.#s=setTimeout(()=>{this.reject(this.#i)},e.timeout))}#l(e){clearTimeout(this.#s),this.#o=e,this.#t()}resolve(e){this.#r||this.#e||(this.#e=!0,this.#l(e))}reject(e){this.#r||this.#e||(this.#r=!0,this.#l(e))}resolved(){return this.#e}finished(){return this.#e||this.#r}value(){return this.#o}#n;valueOrThrow(){return this.#n||(this.#n=(async()=>{if(await this.#a,this.#r)throw this.#o;return this.#o})()),this.#n}};var L=new Map,W=t=>{let e=L.get(t);return e||(e=new Function(`return ${t}`)(),L.set(t,e),e)};var b={};l(b,{ariaQuerySelector:()=>z,ariaQuerySelectorAll:()=>x});var z=(t,e)=>globalThis.__ariaQuerySelector(t,e),x=async function*(t,e){yield*await globalThis.__ariaQuerySelectorAll(t,e)};var E={};l(E,{cssQuerySelector:()=>K,cssQuerySelectorAll:()=>Z});var K=(t,e)=>t.querySelector(e),Z=function(t,e){return t.querySelectorAll(e)};var A={};l(A,{customQuerySelectors:()=>P});var v=class{#e=new Map;register(e,r){if(!r.queryOne&&r.queryAll){let o=r.queryAll;r.queryOne=(s,i)=>{for(let n of o(s,i))return n;return null}}else if(r.queryOne&&!r.queryAll){let o=r.queryOne;r.queryAll=(s,i)=>{let n=o(s,i);return n?[n]:[]}}else if(!r.queryOne||!r.queryAll)throw new Error(\"At least one query method must be defined.\");this.#e.set(e,{querySelector:r.queryOne,querySelectorAll:r.queryAll})}unregister(e){this.#e.delete(e)}get(e){return this.#e.get(e)}clear(){this.#e.clear()}},P=new v;var R={};l(R,{pierceQuerySelector:()=>ee,pierceQuerySelectorAll:()=>te});var ee=(t,e)=>{let r=null,o=s=>{let i=document.createTreeWalker(s,NodeFilter.SHOW_ELEMENT);do{let n=i.currentNode;n.shadowRoot&&o(n.shadowRoot),!(n instanceof ShadowRoot)&&n!==s&&!r&&n.matches(e)&&(r=n)}while(!r&&i.nextNode())};return t instanceof Document&&(t=t.documentElement),o(t),r},te=(t,e)=>{let r=[],o=s=>{let i=document.createTreeWalker(s,NodeFilter.SHOW_ELEMENT);do{let n=i.currentNode;n.shadowRoot&&o(n.shadowRoot),!(n instanceof ShadowRoot)&&n!==s&&n.matches(e)&&r.push(n)}while(i.nextNode())};return t instanceof Document&&(t=t.documentElement),o(t),r};var u=(t,e)=>{if(!t)throw new Error(e)};var y=class{#e;#r;#o;#t;constructor(e,r){this.#e=e,this.#r=r}async start(){let e=this.#t=c.create(),r=await this.#e();if(r){e.resolve(r);return}this.#o=new MutationObserver(async()=>{let o=await this.#e();o&&(e.resolve(o),await this.stop())}),this.#o.observe(this.#r,{childList:!0,subtree:!0,attributes:!0})}async stop(){u(this.#t,\"Polling never started.\"),this.#t.finished()||this.#t.reject(new Error(\"Polling stopped\")),this.#o&&(this.#o.disconnect(),this.#o=void 0)}result(){return u(this.#t,\"Polling never started.\"),this.#t.valueOrThrow()}},w=class{#e;#r;constructor(e){this.#e=e}async start(){let e=this.#r=c.create(),r=await this.#e();if(r){e.resolve(r);return}let o=async()=>{if(e.finished())return;let s=await this.#e();if(!s){window.requestAnimationFrame(o);return}e.resolve(s),await this.stop()};window.requestAnimationFrame(o)}async stop(){u(this.#r,\"Polling never started.\"),this.#r.finished()||this.#r.reject(new Error(\"Polling stopped\"))}result(){return u(this.#r,\"Polling never started.\"),this.#r.valueOrThrow()}},T=class{#e;#r;#o;#t;constructor(e,r){this.#e=e,this.#r=r}async start(){let e=this.#t=c.create(),r=await this.#e();if(r){e.resolve(r);return}this.#o=setInterval(async()=>{let o=await this.#e();o&&(e.resolve(o),await this.stop())},this.#r)}async stop(){u(this.#t,\"Polling never started.\"),this.#t.finished()||this.#t.reject(new Error(\"Polling stopped\")),this.#o&&(clearInterval(this.#o),this.#o=void 0)}result(){return u(this.#t,\"Polling never started.\"),this.#t.valueOrThrow()}};var _={};l(_,{PCombinator:()=>H,pQuerySelector:()=>fe,pQuerySelectorAll:()=>$});var a=class{static async*map(e,r){for await(let o of e)yield await r(o)}static async*flatMap(e,r){for await(let o of e)yield*r(o)}static async collect(e){let r=[];for await(let o of e)r.push(o);return r}static async first(e){for await(let r of e)return r}};var C={};l(C,{textQuerySelectorAll:()=>m});var re=new Set([\"checkbox\",\"image\",\"radio\"]),oe=t=>t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement&&!re.has(t.type),se=new Set([\"SCRIPT\",\"STYLE\"]),f=t=>!se.has(t.nodeName)&&!document.head?.contains(t),I=new WeakMap,F=t=>{for(;t;)I.delete(t),t instanceof ShadowRoot?t=t.host:t=t.parentNode},j=new WeakSet,ne=new MutationObserver(t=>{for(let e of t)F(e.target)}),d=t=>{let e=I.get(t);if(e||(e={full:\"\",immediate:[]},!f(t)))return e;let r=\"\";if(oe(t))e.full=t.value,e.immediate.push(t.value),t.addEventListener(\"input\",o=>{F(o.target)},{once:!0,capture:!0});else{for(let o=t.firstChild;o;o=o.nextSibling){if(o.nodeType===Node.TEXT_NODE){e.full+=o.nodeValue??\"\",r+=o.nodeValue??\"\";continue}r&&e.immediate.push(r),r=\"\",o.nodeType===Node.ELEMENT_NODE&&(e.full+=d(o).full)}r&&e.immediate.push(r),t instanceof Element&&t.shadowRoot&&(e.full+=d(t.shadowRoot).full),j.has(t)||(ne.observe(t,{childList:!0,characterData:!0,subtree:!0}),j.add(t))}return I.set(t,e),e};var m=function*(t,e){let r=!1;for(let o of t.childNodes)if(o instanceof Element&&f(o)){let s;o.shadowRoot?s=m(o.shadowRoot,e):s=m(o,e);for(let i of s)yield i,r=!0}r||t instanceof Element&&f(t)&&d(t).full.includes(e)&&(yield t)};var k={};l(k,{checkVisibility:()=>le,pierce:()=>S,pierceAll:()=>O});var ie=[\"hidden\",\"collapse\"],le=(t,e)=>{if(!t)return e===!1;if(e===void 0)return t;let r=t.nodeType===Node.TEXT_NODE?t.parentElement:t,o=window.getComputedStyle(r),s=o&&!ie.includes(o.visibility)&&!ae(r);return e===s?t:!1};function ae(t){let e=t.getBoundingClientRect();return e.width===0||e.height===0}var ce=t=>\"shadowRoot\"in t&&t.shadowRoot instanceof ShadowRoot;function*S(t){ce(t)?yield t.shadowRoot:yield t}function*O(t){t=S(t).next().value,yield t;let e=[document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT)];for(let r of e){let o;for(;o=r.nextNode();)o.shadowRoot&&(yield o.shadowRoot,e.push(document.createTreeWalker(o.shadowRoot,NodeFilter.SHOW_ELEMENT)))}}var D={};l(D,{xpathQuerySelectorAll:()=>q});var q=function*(t,e,r=-1){let s=(t.ownerDocument||document).evaluate(e,t,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE),i=[],n;for(;(n=s.iterateNext())&&(i.push(n),!(r&&i.length===r)););for(let h=0;h<i.length;h++)n=i[h],yield n,delete i[h]};var ue=/[-\\w\\P{ASCII}*]/u,H=(r=>(r.Descendent=\">>>\",r.Child=\">>>>\",r))(H||{}),V=t=>\"querySelectorAll\"in t,Q=class{#e;#r=[];#o=void 0;elements;constructor(e,r){this.elements=[e],this.#e=r,this.#t()}async run(){if(typeof this.#o==\"string\")switch(this.#o.trimStart()){case\":scope\":this.#t();break}for(;this.#o!==void 0;this.#t()){let e=this.#o;typeof e==\"string\"?e[0]&&ue.test(e[0])?this.elements=a.flatMap(this.elements,async function*(r){V(r)&&(yield*r.querySelectorAll(e))}):this.elements=a.flatMap(this.elements,async function*(r){if(!r.parentElement){if(!V(r))return;yield*r.querySelectorAll(e);return}let o=0;for(let s of r.parentElement.children)if(++o,s===r)break;yield*r.parentElement.querySelectorAll(`:scope>:nth-child(${o})${e}`)}):this.elements=a.flatMap(this.elements,async function*(r){switch(e.name){case\"text\":yield*m(r,e.value);break;case\"xpath\":yield*q(r,e.value);break;case\"aria\":yield*x(r,e.value);break;default:let o=P.get(e.name);if(!o)throw new Error(`Unknown selector type: ${e.name}`);yield*o.querySelectorAll(r,e.value)}})}}#t(){if(this.#r.length!==0){this.#o=this.#r.shift();return}if(this.#e.length===0){this.#o=void 0;return}let e=this.#e.shift();switch(e){case\">>>>\":{this.elements=a.flatMap(this.elements,S),this.#t();break}case\">>>\":{this.elements=a.flatMap(this.elements,O),this.#t();break}default:this.#r=e,this.#t();break}}},M=class{#e=new WeakMap;calculate(e,r=[]){if(e===null)return r;e instanceof ShadowRoot&&(e=e.host);let o=this.#e.get(e);if(o)return[...o,...r];let s=0;for(let n=e.previousSibling;n;n=n.previousSibling)++s;let i=this.calculate(e.parentNode,[s]);return this.#e.set(e,i),[...i,...r]}},U=(t,e)=>{if(t.length+e.length===0)return 0;let[r=-1,...o]=t,[s=-1,...i]=e;return r===s?U(o,i):r<s?-1:1},de=async function*(t){let e=new Set;for await(let o of t)e.add(o);let r=new M;yield*[...e.values()].map(o=>[o,r.calculate(o)]).sort(([,o],[,s])=>U(o,s)).map(([o])=>o)},$=function(t,e){let r=JSON.parse(e);if(r.some(o=>{let s=0;return o.some(i=>(typeof i==\"string\"?++s:s=0,s>1))}))throw new Error(\"Multiple deep combinators found in sequence.\");return de(a.flatMap(r,o=>{let s=new Q(t,o);return s.run(),s.elements}))},fe=async function(t,e){for await(let r of $(t,e))return r;return null};var me=Object.freeze({...b,...A,...R,..._,...C,...k,...D,...E,Deferred:c,createFunction:W,createTextContent:d,IntervalPoller:T,isSuitableNodeForTextMatching:f,MutationPoller:y,RAFPoller:w}),he=me;\n";
|
package/src/generated/version.ts
CHANGED
|
@@ -154,7 +154,7 @@ export abstract class BrowserLauncher {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
try {
|
|
157
|
-
if (this.#browser === 'firefox'
|
|
157
|
+
if (this.#browser === 'firefox') {
|
|
158
158
|
browser = await this.createBiDiBrowser(
|
|
159
159
|
browserProcess,
|
|
160
160
|
browserCloseCallback,
|
|
@@ -181,6 +181,7 @@ export abstract class BrowserLauncher {
|
|
|
181
181
|
slowMo,
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
+
|
|
184
185
|
if (protocol === 'webDriverBiDi') {
|
|
185
186
|
browser = await this.createBiDiOverCdpBrowser(
|
|
186
187
|
browserProcess,
|
|
@@ -210,6 +211,17 @@ export abstract class BrowserLauncher {
|
|
|
210
211
|
}
|
|
211
212
|
} catch (error) {
|
|
212
213
|
void browserCloseCallback();
|
|
214
|
+
if (
|
|
215
|
+
browserProcess.getRecentLogs().some(line => {
|
|
216
|
+
return line.includes(
|
|
217
|
+
'Failed to create a ProcessSingleton for your profile directory',
|
|
218
|
+
);
|
|
219
|
+
})
|
|
220
|
+
) {
|
|
221
|
+
throw new Error(
|
|
222
|
+
`The browser is already running for ${launchArgs.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
213
225
|
if (error instanceof BrowsersTimeoutError) {
|
|
214
226
|
throw new TimeoutError(error.message);
|
|
215
227
|
}
|
|
@@ -360,7 +372,7 @@ export abstract class BrowserLauncher {
|
|
|
360
372
|
*/
|
|
361
373
|
protected async createBiDiOverCdpBrowser(
|
|
362
374
|
browserProcess: ReturnType<typeof launch>,
|
|
363
|
-
|
|
375
|
+
cdpConnection: Connection,
|
|
364
376
|
closeCallback: BrowserCloseCallback,
|
|
365
377
|
opts: {
|
|
366
378
|
defaultViewport: Viewport | null;
|
|
@@ -368,11 +380,14 @@ export abstract class BrowserLauncher {
|
|
|
368
380
|
networkEnabled: boolean;
|
|
369
381
|
},
|
|
370
382
|
): Promise<Browser> {
|
|
383
|
+
const bidiOnly = process.env['PUPPETEER_WEBDRIVER_BIDI_ONLY'] === 'true';
|
|
371
384
|
const BiDi = await import(/* webpackIgnore: true */ '../bidi/bidi.js');
|
|
372
|
-
const bidiConnection = await BiDi.connectBidiOverCdp(
|
|
385
|
+
const bidiConnection = await BiDi.connectBidiOverCdp(cdpConnection);
|
|
373
386
|
return await BiDi.BidiBrowser.create({
|
|
374
387
|
connection: bidiConnection,
|
|
375
|
-
|
|
388
|
+
// Do not provide CDP connection to Browser, if BiDi-only mode is enabled. This
|
|
389
|
+
// would restrict Browser to use only BiDi endpoint.
|
|
390
|
+
cdpConnection: bidiOnly ? undefined : cdpConnection,
|
|
376
391
|
closeCallback,
|
|
377
392
|
process: browserProcess.nodeProcess,
|
|
378
393
|
defaultViewport: opts.defaultViewport,
|
|
@@ -17,7 +17,7 @@ export class PipeTransport implements ConnectionTransport {
|
|
|
17
17
|
#subscriptions = new DisposableStack();
|
|
18
18
|
|
|
19
19
|
#isClosed = false;
|
|
20
|
-
#pendingMessage =
|
|
20
|
+
#pendingMessage: Buffer[] = [];
|
|
21
21
|
|
|
22
22
|
onclose?: () => void;
|
|
23
23
|
onmessage?: (value: string) => void;
|
|
@@ -34,7 +34,7 @@ export class PipeTransport implements ConnectionTransport {
|
|
|
34
34
|
pipeRead as unknown as EventEmitter<Record<string, any>>,
|
|
35
35
|
),
|
|
36
36
|
);
|
|
37
|
-
pipeReadEmitter.on('data',
|
|
37
|
+
pipeReadEmitter.on('data', buffer => {
|
|
38
38
|
return this.#dispatch(buffer);
|
|
39
39
|
});
|
|
40
40
|
pipeReadEmitter.on('close', () => {
|
|
@@ -60,34 +60,32 @@ export class PipeTransport implements ConnectionTransport {
|
|
|
60
60
|
this.#pipeWrite.write('\0');
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
#dispatch(buffer: Buffer): void {
|
|
63
|
+
#dispatch(buffer: Buffer<ArrayBuffer>): void {
|
|
64
64
|
assert(!this.#isClosed, '`PipeTransport` is closed.');
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
this.#pendingMessage += buffer.toString();
|
|
66
|
+
this.#pendingMessage.push(buffer);
|
|
67
|
+
if (buffer.indexOf('\0') === -1) {
|
|
69
68
|
return;
|
|
70
69
|
}
|
|
71
|
-
const
|
|
72
|
-
setImmediate(() => {
|
|
73
|
-
if (this.onmessage) {
|
|
74
|
-
this.onmessage.call(null, message);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
70
|
+
const concatBuffer = Buffer.concat(this.#pendingMessage);
|
|
77
71
|
|
|
78
|
-
let start =
|
|
79
|
-
end =
|
|
72
|
+
let start = 0;
|
|
73
|
+
let end = concatBuffer.indexOf('\0');
|
|
80
74
|
while (end !== -1) {
|
|
81
|
-
const message =
|
|
75
|
+
const message = concatBuffer.toString(undefined, start, end);
|
|
82
76
|
setImmediate(() => {
|
|
83
77
|
if (this.onmessage) {
|
|
84
78
|
this.onmessage.call(null, message);
|
|
85
79
|
}
|
|
86
80
|
});
|
|
87
81
|
start = end + 1;
|
|
88
|
-
end =
|
|
82
|
+
end = concatBuffer.indexOf('\0', start);
|
|
83
|
+
}
|
|
84
|
+
if (start >= concatBuffer.length) {
|
|
85
|
+
this.#pendingMessage = [];
|
|
86
|
+
} else {
|
|
87
|
+
this.#pendingMessage = [concatBuffer.subarray(start)];
|
|
89
88
|
}
|
|
90
|
-
this.#pendingMessage = buffer.toString(undefined, start);
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
close(): void {
|
|
@@ -44,13 +44,11 @@ import type {ChromeReleaseChannel, LaunchOptions} from './LaunchOptions.js';
|
|
|
44
44
|
* ```ts
|
|
45
45
|
* import puppeteer from 'puppeteer';
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* await browser.close();
|
|
53
|
-
* })();
|
|
47
|
+
* const browser = await puppeteer.launch();
|
|
48
|
+
* const page = await browser.newPage();
|
|
49
|
+
* await page.goto('https://www.google.com');
|
|
50
|
+
* // other actions...
|
|
51
|
+
* await browser.close();
|
|
54
52
|
* ```
|
|
55
53
|
*
|
|
56
54
|
* Once you have created a `page` you have access to a large API to interact
|
package/src/revisions.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export const PUPPETEER_REVISIONS = Object.freeze({
|
|
11
|
-
chrome: '
|
|
12
|
-
'chrome-headless-shell': '
|
|
13
|
-
firefox: '
|
|
11
|
+
chrome: '141.0.7390.54',
|
|
12
|
+
'chrome-headless-shell': '141.0.7390.54',
|
|
13
|
+
firefox: 'stable_143.0.3',
|
|
14
14
|
});
|
package/src/util/Function.ts
CHANGED
|
@@ -29,37 +29,29 @@ export const createFunction = (
|
|
|
29
29
|
*/
|
|
30
30
|
export function stringifyFunction(fn: (...args: never) => unknown): string {
|
|
31
31
|
let value = fn.toString();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive`,
|
|
38
|
-
) ||
|
|
39
|
-
(err as Error).message.includes(
|
|
40
|
-
'Evaluating a string as JavaScript violates the following Content Security Policy',
|
|
41
|
-
)
|
|
42
|
-
) {
|
|
43
|
-
// The content security policy does not allow Function eval. Let's
|
|
44
|
-
// assume the value might be valid as is.
|
|
45
|
-
return value;
|
|
46
|
-
}
|
|
47
|
-
// This means we might have a function shorthand (e.g. `test(){}`). Let's
|
|
48
|
-
// try prefixing.
|
|
49
|
-
let prefix = 'function ';
|
|
50
|
-
if (value.startsWith('async ')) {
|
|
51
|
-
prefix = `async ${prefix}`;
|
|
52
|
-
value = value.substring('async '.length);
|
|
53
|
-
}
|
|
54
|
-
value = `${prefix}${value}`;
|
|
55
|
-
try {
|
|
56
|
-
new Function(`(${value})`);
|
|
57
|
-
} catch {
|
|
58
|
-
// We tried hard to serialize, but there's a weird beast here.
|
|
59
|
-
throw new Error('Passed function cannot be serialized!');
|
|
60
|
-
}
|
|
32
|
+
if (
|
|
33
|
+
value.match(/^(async )*function(\(|\s)/) ||
|
|
34
|
+
value.match(/^(async )*function\s*\*\s*/)
|
|
35
|
+
) {
|
|
36
|
+
return value;
|
|
61
37
|
}
|
|
62
|
-
|
|
38
|
+
const isArrow =
|
|
39
|
+
value.startsWith('(') ||
|
|
40
|
+
value.match(/^async\s*\(/) ||
|
|
41
|
+
value.match(
|
|
42
|
+
/^(async)*\s*(?:[$_\p{ID_Start}])(?:[$\u200C\u200D\p{ID_Continue}])*\s*=>/u,
|
|
43
|
+
);
|
|
44
|
+
if (isArrow) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
// This means we might have a function shorthand (e.g. `test(){}`). Let's
|
|
48
|
+
// try prefixing.
|
|
49
|
+
let prefix = 'function ';
|
|
50
|
+
if (value.startsWith('async ')) {
|
|
51
|
+
prefix = `async ${prefix}`;
|
|
52
|
+
value = value.substring('async '.length);
|
|
53
|
+
}
|
|
54
|
+
return `${prefix}${value}`;
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
/**
|