@push.rocks/smartpuppeteer 2.0.5 → 2.0.7
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/.smartconfig.json +42 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/smartpuppeteer.classes.incognitobrowser.d.ts +1 -2
- package/dist_ts/smartpuppeteer.classes.incognitobrowser.js +3 -5
- package/dist_ts/smartpuppeteer.classes.smartpuppeteer.d.ts +1 -0
- package/dist_ts/smartpuppeteer.classes.smartpuppeteer.js +18 -5
- package/license +2 -2
- package/npmextra.json +14 -8
- package/package.json +13 -10
- package/readme.md +28 -13
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/smartpuppeteer.classes.incognitobrowser.ts +3 -5
- package/ts/smartpuppeteer.classes.smartpuppeteer.ts +21 -6
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@git.zone/cli": {
|
|
3
|
+
"projectType": "npm",
|
|
4
|
+
"module": {
|
|
5
|
+
"githost": "code.foss.global",
|
|
6
|
+
"gitscope": "push.rocks",
|
|
7
|
+
"gitrepo": "smartpuppeteer",
|
|
8
|
+
"shortDescription": "simplified access to puppeteer",
|
|
9
|
+
"npmPackagename": "@push.rocks/smartpuppeteer",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"description": "Provides simplified access to Puppeteer for automation and testing purposes.",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"puppeteer",
|
|
14
|
+
"automation",
|
|
15
|
+
"browser automation",
|
|
16
|
+
"web scraping",
|
|
17
|
+
"testing",
|
|
18
|
+
"headless browsing",
|
|
19
|
+
"incognito browsing"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"release": {
|
|
23
|
+
"targets": {
|
|
24
|
+
"npm": {
|
|
25
|
+
"registries": [
|
|
26
|
+
"https://verdaccio.lossless.digital",
|
|
27
|
+
"https://registry.npmjs.org"
|
|
28
|
+
],
|
|
29
|
+
"accessLevel": "public"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"schemaVersion": 2
|
|
34
|
+
},
|
|
35
|
+
"@git.zone/tsdoc": {
|
|
36
|
+
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
|
37
|
+
},
|
|
38
|
+
"@ship.zone/szci": {
|
|
39
|
+
"npmGlobalTools": [],
|
|
40
|
+
"npmRegistryUrl": "registry.npmjs.org"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartpuppeteer',
|
|
6
|
-
version: '2.0.
|
|
6
|
+
version: '2.0.7',
|
|
7
7
|
description: 'Provides simplified access to Puppeteer for automation and testing purposes.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSw0QkFBNEI7SUFDbEMsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLDhFQUE4RTtDQUM1RixDQUFBIn0=
|
|
@@ -21,8 +21,7 @@ export declare class IncognitoBrowser {
|
|
|
21
21
|
rotateBrowser(): Promise<void>;
|
|
22
22
|
/**
|
|
23
23
|
* Returns a new incognito browser context.
|
|
24
|
-
* This uses Puppeteer's
|
|
25
|
-
* correct method for creating isolated sessions.
|
|
24
|
+
* This uses Puppeteer's current createBrowserContext() API for isolated sessions.
|
|
26
25
|
*/
|
|
27
26
|
getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext>;
|
|
28
27
|
}
|
|
@@ -51,15 +51,13 @@ export class IncognitoBrowser {
|
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Returns a new incognito browser context.
|
|
54
|
-
* This uses Puppeteer's
|
|
55
|
-
* correct method for creating isolated sessions.
|
|
54
|
+
* This uses Puppeteer's current createBrowserContext() API for isolated sessions.
|
|
56
55
|
*/
|
|
57
56
|
async getNewIncognitoContext() {
|
|
58
57
|
if (!this.browser) {
|
|
59
58
|
throw new Error('You need to start the IncognitoBrowser instance first');
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
return this.browser.createIncognitoBrowserContext();
|
|
60
|
+
return this.browser.createBrowserContext();
|
|
63
61
|
}
|
|
64
62
|
}
|
|
65
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRwdXBwZXRlZXIuY2xhc3Nlcy5pbmNvZ25pdG9icm93c2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRwdXBwZXRlZX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UFJLEdBQUcsRUFBRSxDQUFDO1lBQ1IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHLEVBQUUsU0FBUyxDQUFDLENBQUM7UUFDbkMsQ0FBQztRQUNELE1BQU0sSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUM3QixDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksS0FBSyxDQUFDLGFBQWE7UUFDeEIsSUFBSSxDQUFDO1lBQ0gsTUFBTSxJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssRUFBRSxDQUFDO1FBQzdCLENBQUM7UUFBQyxPQUFPLEdBQUcsRUFBRSxDQUFDO1lBQ2Isa0RBQWtEO1FBQ3BELENBQUM7UUFDRCxJQUFJLENBQUMsT0FBTyxHQUFHLE1BQU0sMEJBQTBCLEVBQUUsQ0FBQztJQUNwRCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksS0FBSyxDQUFDLHNCQUFzQjtRQUNqQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1lBQ2xCLE1BQU0sSUFBSSxLQUFLLENBQUMsdURBQXVELENBQUMsQ0FBQztRQUMzRSxDQUFDO1FBQ0QsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDLG9CQUFvQixFQUFFLENBQUM7SUFDN0MsQ0FBQztDQUNGIn0=
|
|
@@ -3,4 +3,5 @@ export interface IEnvAwareOptions {
|
|
|
3
3
|
forceNoSandbox?: boolean;
|
|
4
4
|
usePipe?: boolean;
|
|
5
5
|
}
|
|
6
|
+
export declare const resolveBrowserExecutablePath: (candidateNamesArg?: string[]) => string | undefined;
|
|
6
7
|
export declare const getEnvAwareBrowserInstance: (optionsArg?: IEnvAwareOptions) => Promise<plugins.puppeteer.Browser>;
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import * as plugins from './smartpuppeteer.plugins.js';
|
|
2
|
+
export const resolveBrowserExecutablePath = (candidateNamesArg = [
|
|
3
|
+
'google-chrome',
|
|
4
|
+
'chromium',
|
|
5
|
+
'chromium-browser',
|
|
6
|
+
]) => {
|
|
7
|
+
for (const candidateName of candidateNamesArg) {
|
|
8
|
+
const executablePath = plugins.smartshell.which.sync(candidateName, {
|
|
9
|
+
nothrow: true,
|
|
10
|
+
});
|
|
11
|
+
if (executablePath) {
|
|
12
|
+
return executablePath;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
};
|
|
2
17
|
export const getEnvAwareBrowserInstance = async (optionsArg = {}) => {
|
|
3
18
|
const options = {
|
|
4
19
|
forceNoSandbox: false,
|
|
@@ -14,9 +29,7 @@ export const getEnvAwareBrowserInstance = async (optionsArg = {}) => {
|
|
|
14
29
|
console.warn('********************************************************');
|
|
15
30
|
}
|
|
16
31
|
// Automatically choose an executable if available: prefer google-chrome, then chromium, then chromium-browser.
|
|
17
|
-
const execPath =
|
|
18
|
-
plugins.smartshell.which.sync('chromium') ||
|
|
19
|
-
plugins.smartshell.which.sync('chromium-browser');
|
|
32
|
+
const execPath = resolveBrowserExecutablePath();
|
|
20
33
|
const executablePathOptions = execPath ? { executablePath: execPath } : {};
|
|
21
34
|
console.log('Launching puppeteer browser with arguments:');
|
|
22
35
|
console.log(chromeArgs);
|
|
@@ -28,10 +41,10 @@ export const getEnvAwareBrowserInstance = async (optionsArg = {}) => {
|
|
|
28
41
|
}
|
|
29
42
|
const headlessBrowser = await plugins.puppeteer.launch({
|
|
30
43
|
args: chromeArgs,
|
|
31
|
-
pipe: options.usePipe
|
|
44
|
+
pipe: options.usePipe ?? true,
|
|
32
45
|
headless: true,
|
|
33
46
|
...executablePathOptions,
|
|
34
47
|
});
|
|
35
48
|
return headlessBrowser;
|
|
36
49
|
};
|
|
37
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
50
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRwdXBwZXRlZXIuY2xhc3Nl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BTyxlQUFlLENBQUM7QUFDekIsQ0FBQyxDQUFDIn0=
|
package/license
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2019
|
|
1
|
+
Copyright (c) 2019 Task Venture Capital GmbH <hello@task.vc>
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
16
16
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
17
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
18
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
-
SOFTWARE.
|
|
19
|
+
SOFTWARE.
|
package/npmextra.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"@git.zone/cli": {
|
|
3
3
|
"projectType": "npm",
|
|
4
4
|
"module": {
|
|
5
5
|
"githost": "code.foss.global",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"shortDescription": "simplified access to puppeteer",
|
|
9
9
|
"npmPackagename": "@push.rocks/smartpuppeteer",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"projectDomain": "push.rocks",
|
|
12
11
|
"description": "Provides simplified access to Puppeteer for automation and testing purposes.",
|
|
13
12
|
"keywords": [
|
|
14
13
|
"puppeteer",
|
|
@@ -19,13 +18,20 @@
|
|
|
19
18
|
"headless browsing",
|
|
20
19
|
"incognito browsing"
|
|
21
20
|
]
|
|
21
|
+
},
|
|
22
|
+
"release": {
|
|
23
|
+
"registries": [
|
|
24
|
+
"https://verdaccio.lossless.digital",
|
|
25
|
+
"https://registry.npmjs.org"
|
|
26
|
+
],
|
|
27
|
+
"accessLevel": "public"
|
|
22
28
|
}
|
|
23
29
|
},
|
|
24
|
-
"
|
|
25
|
-
"npmGlobalTools": [],
|
|
26
|
-
"npmAccessLevel": "public"
|
|
27
|
-
},
|
|
28
|
-
"tsdoc": {
|
|
30
|
+
"@git.zone/tsdoc": {
|
|
29
31
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
|
32
|
+
},
|
|
33
|
+
"@ship.zone/szci": {
|
|
34
|
+
"npmGlobalTools": [],
|
|
35
|
+
"npmRegistryUrl": "registry.npmjs.org"
|
|
30
36
|
}
|
|
31
|
-
}
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartpuppeteer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides simplified access to Puppeteer for automation and testing purposes.",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
7
7
|
"typings": "dist_ts/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"author": "
|
|
9
|
+
"author": "Task Venture Capital GmbH <hello@task.vc>",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@git.zone/tsbuild": "^
|
|
13
|
-
"@git.zone/tsrun": "^
|
|
14
|
-
"@git.zone/tstest": "^
|
|
15
|
-
"@
|
|
16
|
-
"@types/node": "^22.13.5"
|
|
12
|
+
"@git.zone/tsbuild": "^4.4.2",
|
|
13
|
+
"@git.zone/tsrun": "^2.0.5",
|
|
14
|
+
"@git.zone/tstest": "^3.6.7",
|
|
15
|
+
"@types/node": "^25.9.5"
|
|
17
16
|
},
|
|
18
17
|
"dependencies": {
|
|
19
18
|
"@push.rocks/smartdelay": "^3.0.1",
|
|
20
|
-
"@push.rocks/smartshell": "^3.0
|
|
21
|
-
"puppeteer": "^24.
|
|
19
|
+
"@push.rocks/smartshell": "^3.5.0",
|
|
20
|
+
"puppeteer": "^24.42.0",
|
|
22
21
|
"tree-kill": "^1.2.2"
|
|
23
22
|
},
|
|
24
23
|
"files": [
|
|
@@ -30,6 +29,8 @@
|
|
|
30
29
|
"dist_ts_web/**/*",
|
|
31
30
|
"assets/**/*",
|
|
32
31
|
"cli.js",
|
|
32
|
+
".smartconfig.json",
|
|
33
|
+
"license",
|
|
33
34
|
"npmextra.json",
|
|
34
35
|
"readme.md"
|
|
35
36
|
],
|
|
@@ -52,6 +53,8 @@
|
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
55
|
"test": "tstest test/",
|
|
55
|
-
"
|
|
56
|
+
"format": "gitzone format",
|
|
57
|
+
"build": "tsbuild --web",
|
|
58
|
+
"buildDocs": "tsdoc"
|
|
56
59
|
}
|
|
57
60
|
}
|
package/readme.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# @push.rocks/smartpuppeteer
|
|
2
|
-
simplified access to puppeteer
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
To install `@push.rocks/smartpuppeteer` in your project, run the following command using npm:
|
|
3
|
+
Simplified access to Puppeteer with environment-aware browser startup helpers.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
npm install @push.rocks/smartpuppeteer --save
|
|
9
|
-
```
|
|
5
|
+
## Issue Reporting and Security
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Install `@push.rocks/smartpuppeteer` with pnpm:
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
|
|
14
|
+
pnpm add @push.rocks/smartpuppeteer
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
@@ -34,6 +34,19 @@ const initializeBrowser = async () => {
|
|
|
34
34
|
};
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
`getEnvAwareBrowserInstance()` checks `google-chrome`, `chromium`, and `chromium-browser` in that order. Missing candidates are skipped safely. When none resolve, Puppeteer chooses its default executable.
|
|
38
|
+
|
|
39
|
+
Use `resolveBrowserExecutablePath()` directly when you need to inspect the selected executable or provide your own ordered candidate list:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { resolveBrowserExecutablePath } from '@push.rocks/smartpuppeteer';
|
|
43
|
+
|
|
44
|
+
const executablePath: string | undefined = resolveBrowserExecutablePath([
|
|
45
|
+
'chromium',
|
|
46
|
+
'chromium-browser',
|
|
47
|
+
]);
|
|
48
|
+
```
|
|
49
|
+
|
|
37
50
|
### Opening a Page and Navigating
|
|
38
51
|
After obtaining a browser instance, you commonly want to open a page and navigate to a URL:
|
|
39
52
|
|
|
@@ -115,19 +128,21 @@ incognitoBrowser.start()
|
|
|
115
128
|
|
|
116
129
|
## License and Legal Information
|
|
117
130
|
|
|
118
|
-
This repository contains open-source code
|
|
131
|
+
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the repository license file.
|
|
119
132
|
|
|
120
133
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
121
134
|
|
|
122
135
|
### Trademarks
|
|
123
136
|
|
|
124
|
-
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein.
|
|
137
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
|
138
|
+
|
|
139
|
+
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
|
125
140
|
|
|
126
141
|
### Company Information
|
|
127
142
|
|
|
128
|
-
Task Venture Capital GmbH
|
|
129
|
-
Registered at District
|
|
143
|
+
Task Venture Capital GmbH<br>
|
|
144
|
+
Registered at District Court Bremen HRB 35230 HB, Germany
|
|
130
145
|
|
|
131
|
-
For any legal inquiries or
|
|
146
|
+
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
|
132
147
|
|
|
133
148
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -55,14 +55,12 @@ export class IncognitoBrowser {
|
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Returns a new incognito browser context.
|
|
58
|
-
* This uses Puppeteer's
|
|
59
|
-
* correct method for creating isolated sessions.
|
|
58
|
+
* This uses Puppeteer's current createBrowserContext() API for isolated sessions.
|
|
60
59
|
*/
|
|
61
60
|
public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> {
|
|
62
61
|
if (!this.browser) {
|
|
63
62
|
throw new Error('You need to start the IncognitoBrowser instance first');
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
return this.browser.createIncognitoBrowserContext();
|
|
64
|
+
return this.browser.createBrowserContext();
|
|
67
65
|
}
|
|
68
|
-
}
|
|
66
|
+
}
|
|
@@ -5,6 +5,24 @@ export interface IEnvAwareOptions {
|
|
|
5
5
|
usePipe?: boolean;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export const resolveBrowserExecutablePath = (
|
|
9
|
+
candidateNamesArg: string[] = [
|
|
10
|
+
'google-chrome',
|
|
11
|
+
'chromium',
|
|
12
|
+
'chromium-browser',
|
|
13
|
+
],
|
|
14
|
+
): string | undefined => {
|
|
15
|
+
for (const candidateName of candidateNamesArg) {
|
|
16
|
+
const executablePath = plugins.smartshell.which.sync(candidateName, {
|
|
17
|
+
nothrow: true,
|
|
18
|
+
});
|
|
19
|
+
if (executablePath) {
|
|
20
|
+
return executablePath;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
8
26
|
export const getEnvAwareBrowserInstance = async (
|
|
9
27
|
optionsArg: IEnvAwareOptions = {}
|
|
10
28
|
): Promise<plugins.puppeteer.Browser> => {
|
|
@@ -26,10 +44,7 @@ export const getEnvAwareBrowserInstance = async (
|
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
// Automatically choose an executable if available: prefer google-chrome, then chromium, then chromium-browser.
|
|
29
|
-
const execPath =
|
|
30
|
-
plugins.smartshell.which.sync('google-chrome') ||
|
|
31
|
-
plugins.smartshell.which.sync('chromium') ||
|
|
32
|
-
plugins.smartshell.which.sync('chromium-browser');
|
|
47
|
+
const execPath = resolveBrowserExecutablePath();
|
|
33
48
|
|
|
34
49
|
const executablePathOptions = execPath ? { executablePath: execPath } : {};
|
|
35
50
|
|
|
@@ -43,10 +58,10 @@ export const getEnvAwareBrowserInstance = async (
|
|
|
43
58
|
|
|
44
59
|
const headlessBrowser = await plugins.puppeteer.launch({
|
|
45
60
|
args: chromeArgs,
|
|
46
|
-
pipe: options.usePipe
|
|
61
|
+
pipe: options.usePipe ?? true,
|
|
47
62
|
headless: true,
|
|
48
63
|
...executablePathOptions,
|
|
49
64
|
});
|
|
50
65
|
|
|
51
66
|
return headlessBrowser;
|
|
52
|
-
};
|
|
67
|
+
};
|