fix(core): update
This commit is contained in:
parent
35129df11c
commit
44314c9894
@ -1,5 +1,6 @@
|
||||
{
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
|
10728
package-lock.json
generated
10728
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -13,18 +13,18 @@
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.2.0",
|
||||
"@types/node": "^13.7.4",
|
||||
"tslint": "^6.0.0",
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.14.20",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.6",
|
||||
"@pushrocks/smartenv": "^4.0.8",
|
||||
"@types/puppeteer": "^2.0.0",
|
||||
"puppeteer": "^2.1.1"
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@types/puppeteer": "^5.4.2",
|
||||
"puppeteer": "^5.5.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
42
ts/smartpuppeteer.classes.incognitobrowser.ts
Normal file
42
ts/smartpuppeteer.classes.incognitobrowser.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { getEnvAwareBrowserInstance } from './smartpuppeteer.classes.smartpuppeteer';
|
||||
import * as plugins from './smartpuppeteer.plugins';
|
||||
|
||||
export class IncognitoBrowser {
|
||||
public status: 'started' | 'stopped' = 'stopped';
|
||||
public browser: plugins.puppeteer.Browser;
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* starts the IncognitoBrowser
|
||||
*/
|
||||
public async start() {
|
||||
this.status = 'started';
|
||||
this.browser = await getEnvAwareBrowserInstance();
|
||||
this.browser.addListener('disconnected', async eventArg => {
|
||||
try {
|
||||
this.browser.removeAllListeners();
|
||||
} catch(err) {}
|
||||
if (this.status === 'started') {
|
||||
this.browser = await getEnvAwareBrowserInstance();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the IncognitoBrowser
|
||||
*/
|
||||
public async stop() {
|
||||
this.status = 'stopped';
|
||||
}
|
||||
|
||||
public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> {
|
||||
if (this.browser) {
|
||||
return this.browser.createIncognitoBrowserContext();
|
||||
} else {
|
||||
throw new Error('you need to start the IncognitoBrowser instance first');
|
||||
}
|
||||
}
|
||||
}
|
@ -16,11 +16,8 @@ export const getEnvAwareBrowserInstance = async (
|
||||
};
|
||||
|
||||
let chromeArgs: string[] = [];
|
||||
if ((process.env.CI || options.forceNoSandbox || plugins.os.userInfo().username === 'root') && !smartenv.isWsl) {
|
||||
if ((process.env.CI || options.forceNoSandbox || plugins.os.userInfo().username === 'root')) {
|
||||
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
|
||||
} else if (smartenv.isWsl) {
|
||||
console.log('Detected WSL.');
|
||||
chromeArgs = chromeArgs.concat(['--no-sandbox', '--single-process']);
|
||||
}
|
||||
|
||||
let headlessBrowser: plugins.puppeteer.Browser;
|
||||
|
Loading…
Reference in New Issue
Block a user