Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 01a4122529 | |||
| fbb94fe51e | |||
| 656e21c8fd | |||
| 53b5cca687 |
3
package-lock.json
generated
3
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpuppeteer",
|
"name": "@pushrocks/smartpuppeteer",
|
||||||
"version": "1.0.10",
|
"version": "1.0.12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -140,7 +140,6 @@
|
|||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz",
|
||||||
"integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==",
|
"integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smartpromise": "^3.0.6"
|
"@pushrocks/smartpromise": "^3.0.6"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpuppeteer",
|
"name": "@pushrocks/smartpuppeteer",
|
||||||
"version": "1.0.10",
|
"version": "1.0.12",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "simplified access to puppeteer",
|
"description": "simplified access to puppeteer",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@pushrocks/smartdelay": "^2.0.6",
|
||||||
"@pushrocks/smartenv": "^4.0.8",
|
"@pushrocks/smartenv": "^4.0.8",
|
||||||
"@types/puppeteer": "^1.20.2",
|
"@types/puppeteer": "^1.20.2",
|
||||||
"puppeteer": "^2.0.0"
|
"puppeteer": "^2.0.0"
|
||||||
|
|||||||
@@ -18,10 +18,7 @@ simplified access to puppeteer
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
## Contribution
|
Use TypeScript for best in class intellisense.
|
||||||
|
|
||||||
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). :)
|
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartpuppeteer from '../ts/index';
|
import * as smartpuppeteer from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async tools => {
|
||||||
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||||
forceNoSandbox: true
|
forceNoSandbox: true
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,34 +17,18 @@ export const getEnvAwareBrowserInstance = async (
|
|||||||
|
|
||||||
let chromeArgs: string[] = [];
|
let chromeArgs: string[] = [];
|
||||||
if ((process.env.CI || options.forceNoSandbox) && !smartenv.isWsl) {
|
if ((process.env.CI || options.forceNoSandbox) && !smartenv.isWsl) {
|
||||||
chromeArgs = chromeArgs.concat([
|
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
|
||||||
'--no-sandbox',
|
} else if (smartenv.isWsl) {
|
||||||
'--disable-setuid-sandbox',
|
console.log('Detected WSL. Using chromium.');
|
||||||
// '--disable-dev-shm-usage'
|
chromeArgs = chromeArgs.concat(['--no-sandbox', '--single-process']);
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let headlessBrowser: plugins.puppeteer.Browser;
|
let headlessBrowser: plugins.puppeteer.Browser;
|
||||||
if (!smartenv.isWsl) {
|
console.log('launching puppeteer bundled chrome with arguments:');
|
||||||
// lets get the actual instance
|
console.log(chromeArgs);
|
||||||
console.log('launching puppeteer bundled chrome');
|
headlessBrowser = await plugins.puppeteer.launch({
|
||||||
headlessBrowser = await plugins.puppeteer.launch({
|
args: chromeArgs
|
||||||
args: chromeArgs
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('Detected WSL. Using chromium.');
|
|
||||||
headlessBrowser = await plugins.puppeteer.launch({
|
|
||||||
args: [
|
|
||||||
'--disable-gpu',
|
|
||||||
'--disable-dev-shm-usage',
|
|
||||||
'--disable-setuid-sandbox',
|
|
||||||
'--no-first-run',
|
|
||||||
'--no-sandbox',
|
|
||||||
'--no-zygote',
|
|
||||||
'--single-process'
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return headlessBrowser;
|
return headlessBrowser;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartenv from '@pushrocks/smartenv';
|
import * as smartenv from '@pushrocks/smartenv';
|
||||||
|
|
||||||
export { smartenv };
|
export { smartdelay, smartenv };
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import puppeteer from 'puppeteer';
|
import puppeteer from 'puppeteer';
|
||||||
|
|||||||
Reference in New Issue
Block a user