|
| 1 | +--- a/src/cdp/Browser.ts |
| 2 | ++++ b/src/cdp/Browser.ts |
| 3 | +@@ -338,6 +338,11 @@ |
| 4 | + return await this.#defaultContext.newPage(); |
| 5 | + } |
| 6 | + |
| 7 | ++ // rebrowser-patches: expose browser CDP session |
| 8 | ++ _connection(): Connection { |
| 9 | ++ return this.#connection; |
| 10 | ++ } |
| 11 | ++ |
| 12 | + async _createPageInContext(contextId?: string): Promise<Page> { |
| 13 | + const {targetId} = await this.#connection.send('Target.createTarget', { |
| 14 | + url: 'about:blank', |
| 15 | + |
1 | 16 | --- a/src/cdp/ExecutionContext.ts |
2 | 17 | +++ b/src/cdp/ExecutionContext.ts |
3 | 18 | @@ -78,6 +78,7 @@ |
|
290 | 305 |
|
291 | 306 | mainRealm(): Realm { |
292 | 307 |
|
| 308 | +--- a/src/common/util.ts |
| 309 | ++++ b/src/common/util.ts |
| 310 | +@@ -328,7 +328,9 @@ |
| 311 | + * @internal |
| 312 | + */ |
| 313 | + export const UTILITY_WORLD_NAME = |
| 314 | +- '__puppeteer_utility_world__' + packageVersion; |
| 315 | ++ // rebrowser-patches: change utility world name |
| 316 | ++ process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] !== '0' ? (process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] || 'util') : |
| 317 | ++ '__puppeteer_utility_world__' + packageVersion; |
| 318 | + |
| 319 | + /** |
| 320 | + * @internal |
| 321 | +@@ -338,6 +340,10 @@ |
| 322 | + * @internal |
| 323 | + */ |
| 324 | + export function getSourceUrlComment(url: string): string { |
| 325 | ++ // rebrowser-patches: change sourceUrl to generic script name |
| 326 | ++ if (process.env['REBROWSER_PATCHES_SOURCE_URL'] !== '0') { |
| 327 | ++ url = process.env['REBROWSER_PATCHES_SOURCE_URL'] || 'app.js' |
| 328 | ++ } |
| 329 | + return `//# sourceURL=${url}`; |
| 330 | + } |
| 331 | + |
| 332 | + |
| 333 | +--- a/lib/cjs/puppeteer/cdp/Browser.d.ts |
| 334 | ++++ b/lib/cjs/puppeteer/cdp/Browser.d.ts |
| 335 | +@@ -32,6 +32,7 @@ |
| 336 | + _disposeContext(contextId?: string): Promise<void>; |
| 337 | + wsEndpoint(): string; |
| 338 | + newPage(): Promise<Page>; |
| 339 | ++ _connection(): Connection; |
| 340 | + _createPageInContext(contextId?: string): Promise<Page>; |
| 341 | + targets(): CdpTarget[]; |
| 342 | + target(): CdpTarget; |
| 343 | + |
| 344 | +--- a/lib/cjs/puppeteer/cdp/Browser.js |
| 345 | ++++ b/lib/cjs/puppeteer/cdp/Browser.js |
| 346 | +@@ -176,6 +176,10 @@ |
| 347 | + async newPage() { |
| 348 | + return await this.#defaultContext.newPage(); |
| 349 | + } |
| 350 | ++ // rebrowser-patches: expose browser CDP session |
| 351 | ++ _connection() { |
| 352 | ++ return this.#connection; |
| 353 | ++ } |
| 354 | + async _createPageInContext(contextId) { |
| 355 | + const { targetId } = await this.#connection.send('Target.createTarget', { |
| 356 | + url: 'about:blank', |
| 357 | + |
293 | 358 | --- a/lib/cjs/puppeteer/cdp/ExecutionContext.d.ts |
294 | 359 | +++ b/lib/cjs/puppeteer/cdp/ExecutionContext.d.ts |
295 | 360 | @@ -22,6 +22,7 @@ |
|
585 | 650 | mainRealm() { |
586 | 651 | return this.#world; |
587 | 652 |
|
| 653 | +--- a/lib/cjs/puppeteer/common/util.js |
| 654 | ++++ b/lib/cjs/puppeteer/common/util.js |
| 655 | +@@ -294,7 +294,10 @@ |
| 656 | + /** |
| 657 | + * @internal |
| 658 | + */ |
| 659 | +-exports.UTILITY_WORLD_NAME = '__puppeteer_utility_world__' + version_js_1.packageVersion; |
| 660 | ++exports.UTILITY_WORLD_NAME = |
| 661 | ++// rebrowser-patches: change utility world name |
| 662 | ++process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] !== '0' ? (process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] || 'util') : |
| 663 | ++ '__puppeteer_utility_world__' + version_js_1.packageVersion; |
| 664 | + /** |
| 665 | + * @internal |
| 666 | + */ |
| 667 | +@@ -303,6 +306,10 @@ |
| 668 | + * @internal |
| 669 | + */ |
| 670 | + function getSourceUrlComment(url) { |
| 671 | ++ // rebrowser-patches: change sourceUrl to generic script name |
| 672 | ++ if (process.env['REBROWSER_PATCHES_SOURCE_URL'] !== '0') { |
| 673 | ++ url = process.env['REBROWSER_PATCHES_SOURCE_URL'] || 'app.js'; |
| 674 | ++ } |
| 675 | + return `//# sourceURL=${url}`; |
| 676 | + } |
| 677 | + exports.getSourceUrlComment = getSourceUrlComment; |
| 678 | + |
| 679 | +--- a/lib/esm/puppeteer/cdp/Browser.d.ts |
| 680 | ++++ b/lib/esm/puppeteer/cdp/Browser.d.ts |
| 681 | +@@ -32,6 +32,7 @@ |
| 682 | + _disposeContext(contextId?: string): Promise<void>; |
| 683 | + wsEndpoint(): string; |
| 684 | + newPage(): Promise<Page>; |
| 685 | ++ _connection(): Connection; |
| 686 | + _createPageInContext(contextId?: string): Promise<Page>; |
| 687 | + targets(): CdpTarget[]; |
| 688 | + target(): CdpTarget; |
| 689 | + |
| 690 | +--- a/lib/esm/puppeteer/cdp/Browser.js |
| 691 | ++++ b/lib/esm/puppeteer/cdp/Browser.js |
| 692 | +@@ -173,6 +173,10 @@ |
| 693 | + async newPage() { |
| 694 | + return await this.#defaultContext.newPage(); |
| 695 | + } |
| 696 | ++ // rebrowser-patches: expose browser CDP session |
| 697 | ++ _connection() { |
| 698 | ++ return this.#connection; |
| 699 | ++ } |
| 700 | + async _createPageInContext(contextId) { |
| 701 | + const { targetId } = await this.#connection.send('Target.createTarget', { |
| 702 | + url: 'about:blank', |
| 703 | + |
588 | 704 | --- a/lib/esm/puppeteer/cdp/ExecutionContext.d.ts |
589 | 705 | +++ b/lib/esm/puppeteer/cdp/ExecutionContext.d.ts |
590 | 706 | @@ -22,6 +22,7 @@ |
|
879 | 995 | } |
880 | 996 | mainRealm() { |
881 | 997 | return this.#world; |
| 998 | + |
| 999 | +--- a/lib/esm/puppeteer/common/util.js |
| 1000 | ++++ b/lib/esm/puppeteer/common/util.js |
| 1001 | +@@ -254,7 +254,10 @@ |
| 1002 | + /** |
| 1003 | + * @internal |
| 1004 | + */ |
| 1005 | +-export const UTILITY_WORLD_NAME = '__puppeteer_utility_world__' + packageVersion; |
| 1006 | ++export const UTILITY_WORLD_NAME = |
| 1007 | ++// rebrowser-patches: change utility world name |
| 1008 | ++process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] !== '0' ? (process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] || 'util') : |
| 1009 | ++ '__puppeteer_utility_world__' + packageVersion; |
| 1010 | + /** |
| 1011 | + * @internal |
| 1012 | + */ |
| 1013 | +@@ -263,6 +266,10 @@ |
| 1014 | + * @internal |
| 1015 | + */ |
| 1016 | + export function getSourceUrlComment(url) { |
| 1017 | ++ // rebrowser-patches: change sourceUrl to generic script name |
| 1018 | ++ if (process.env['REBROWSER_PATCHES_SOURCE_URL'] !== '0') { |
| 1019 | ++ url = process.env['REBROWSER_PATCHES_SOURCE_URL'] || 'app.js'; |
| 1020 | ++ } |
| 1021 | + return `//# sourceURL=${url}`; |
| 1022 | + } |
| 1023 | + /** |
0 commit comments