Compare commits

..

10 Commits

Author SHA1 Message Date
1b72af4702 1.0.16 2021-01-08 21:14:01 +00:00
44314c9894 fix(core): update 2021-01-08 21:14:01 +00:00
35129df11c 1.0.15 2020-02-25 01:38:24 +00:00
5dd6450347 fix(core): update 2020-02-25 01:38:24 +00:00
190d57bbe2 1.0.14 2019-11-16 17:51:13 +01:00
8d4519d615 fix(cli logs): now correctly stating when WSL is detected. 2019-11-16 17:51:11 +01:00
42a68434c0 1.0.13 2019-11-16 01:22:10 +01:00
35fd4678d1 fix(core): update 2019-11-16 01:22:08 +01:00
01a4122529 1.0.12 2019-11-16 01:15:10 +01:00
fbb94fe51e fix(core): update 2019-11-16 01:15:08 +01:00
8 changed files with 10164 additions and 669 deletions

View File

@@ -1,5 +1,6 @@
{
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",

10743
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartpuppeteer",
"version": "1.0.11",
"version": "1.0.16",
"private": false,
"description": "simplified access to puppeteer",
"main": "dist/index.js",
@@ -13,18 +13,18 @@
"format": "(gitzone format)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.12.7",
"tslint": "^5.20.1",
"@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": "^1.20.2",
"puppeteer": "^2.0.0"
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartenv": "^4.0.16",
"@types/puppeteer": "^5.4.2",
"puppeteer": "^5.5.0"
},
"files": [
"ts/**/*",

View File

@@ -18,10 +18,14 @@ simplified access to puppeteer
## Usage
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
Use TypeScript for best in class intellisense.
```typescript
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: true // if you really want no sandbox, you can do this. Otherwise its starting things as necessary
});
await headlessBrowser.close();
```
## Contribution

View File

@@ -1,7 +1,7 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartpuppeteer from '../ts/index';
tap.test('first test', async (tools) => {
tap.test('first test', async tools => {
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: true
});

View 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');
}
}
}

View File

@@ -16,14 +16,8 @@ export const getEnvAwareBrowserInstance = async (
};
let chromeArgs: string[] = [];
if ((process.env.CI || options.forceNoSandbox) && !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. Using chromium.');
chromeArgs = chromeArgs.concat([
'--no-sandbox',
'--single-process'
]);
}
let headlessBrowser: plugins.puppeteer.Browser;

View File

@@ -1,3 +1,10 @@
// node native scope
import * as os from 'os';
export {
os
};
// @pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartenv from '@pushrocks/smartenv';