browserless 9.3.14-alpha.2 → 9.3.15
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/README.md +27 -0
- package/package.json +7 -8
- package/src/driver.js +12 -10
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# browserless
|
|
2
|
+
|
|
3
|
+
<h1 align="center">
|
|
4
|
+
<img style="width: 500px; margin:3rem 0 1.5rem;" src="https://browserless.js.org/static/logo-banner.png" alt="browserless">
|
|
5
|
+
<br>
|
|
6
|
+
</h1>
|
|
7
|
+
|
|
8
|
+
> The headless Chrome/Chromium performance driver for Node.js
|
|
9
|
+
|
|
10
|
+
See our [website](https://browserless.js.org) for more information.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Using npm:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install browserless puppeteer --save
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
**browserless** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/browserless/blob/master/LICENSE.md) License.<br>
|
|
23
|
+
Authored and maintained by [Microlink](https://microlink.io) with help from [contributors](https://github.com/microlinkhq/browserless/contributors).
|
|
24
|
+
|
|
25
|
+
The [logo](https://thenounproject.com/term/browser/288309/) has been designed by [xinh studio](https://xinh.studio).
|
|
26
|
+
|
|
27
|
+
> [microlink.io](https://microlink.io) · GitHub [@MicrolinkHQ](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq)
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browserless",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "The headless Chrome/Chromium performance driver for Node.js",
|
|
4
4
|
"homepage": "https://browserless.js.org",
|
|
5
|
-
"version": "9.3.
|
|
5
|
+
"version": "9.3.15",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -31,16 +31,15 @@
|
|
|
31
31
|
"text"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@browserless/errors": "^9.3.
|
|
35
|
-
"@browserless/goto": "^9.3.
|
|
36
|
-
"@browserless/pdf": "^9.3.
|
|
37
|
-
"@browserless/screenshot": "^9.3.
|
|
34
|
+
"@browserless/errors": "^9.3.15",
|
|
35
|
+
"@browserless/goto": "^9.3.15",
|
|
36
|
+
"@browserless/pdf": "^9.3.15",
|
|
37
|
+
"@browserless/screenshot": "^9.3.15",
|
|
38
38
|
"debug-logfmt": "~1.0.4",
|
|
39
39
|
"mutexify": "~1.4.0",
|
|
40
40
|
"p-reflect": "~2.1.0",
|
|
41
41
|
"p-retry": "~4.6.1",
|
|
42
42
|
"p-timeout": "~4.1.0",
|
|
43
|
-
"pidtree": "~0.5.0",
|
|
44
43
|
"require-one-of": "~1.0.15"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
@@ -61,5 +60,5 @@
|
|
|
61
60
|
"timeout": "2m",
|
|
62
61
|
"verbose": true
|
|
63
62
|
},
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "b901fa38dd8d4f501b0b9fed5579fe0c29f5b097"
|
|
65
64
|
}
|
package/src/driver.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
const debug = require('debug-logfmt')('browserless')
|
|
4
4
|
const requireOneOf = require('require-one-of')
|
|
5
5
|
const pReflect = require('p-reflect')
|
|
6
|
-
const
|
|
6
|
+
const { promisify } = require('util')
|
|
7
|
+
|
|
8
|
+
const exec = promisify(require('child_process').exec)
|
|
7
9
|
|
|
8
10
|
// flags explained: https://peter.sh/experiments/chromium-command-line-switches
|
|
9
11
|
// default flags: https://github.com/puppeteer/puppeteer/blob/edb01972b9606d8b05b979a588eda0d622315981/src/node/Launcher.ts#L183
|
|
@@ -58,23 +60,23 @@ const getPid = childProcess => {
|
|
|
58
60
|
return browserProcess.pid
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
const
|
|
63
|
+
const killProcesssGroupPID = (pid, signal) =>
|
|
64
|
+
process.platform === 'win32'
|
|
65
|
+
? exec(`taskkill /pid ${this.proc.pid} /T /F`)
|
|
66
|
+
: Promise.resolve(process.kill(-pid, signal))
|
|
62
67
|
|
|
63
68
|
const close = async (childProcess, { signal = 'SIGKILL', ...debugOpts } = {}) => {
|
|
64
69
|
const pid = getPid(childProcess)
|
|
65
70
|
if (!pid) return
|
|
66
71
|
|
|
67
72
|
// It's necessary to call `browser.close` for removing temporal files associated
|
|
68
|
-
// and remove listeners attached to the main process
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
: [...(await getChildrenPids(pid)), pid].map(pid =>
|
|
73
|
-
pReflect(Promise.resolve(process.kill(pid, signal)))
|
|
74
|
-
))
|
|
73
|
+
// and remove listeners attached to the main process; check
|
|
74
|
+
// - https://github.com/puppeteer/puppeteer/blob/778ac92469d66c542c3c12fe0aa23703dd6315c2/src/node/BrowserRunner.ts#L146
|
|
75
|
+
// - https://github.com/puppeteer/puppeteer/blob/69d85e874416d62de6e821bef30e5cebcfd42f15/src/node/BrowserRunner.ts#L189
|
|
76
|
+
await pReflect(childProcess.close ? childProcess.close() : killProcesssGroupPID(pid, signal))
|
|
75
77
|
|
|
76
78
|
debug('close', { pid, signal, ...debugOpts })
|
|
77
79
|
return { pid }
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
module.exports = { spawn,
|
|
82
|
+
module.exports = { spawn, getPid, close, defaultArgs }
|