browserless 9.7.1-beta.0 → 9.7.2
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/package.json +11 -10
- package/src/index.js +6 -16
- package/LICENSE.md +0 -21
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "browserless",
|
|
3
3
|
"description": "The headless Chrome/Chromium performance driver for Node.js",
|
|
4
4
|
"homepage": "https://browserless.js.org",
|
|
5
|
-
"version": "9.7.
|
|
5
|
+
"version": "9.7.2",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"text"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@browserless/errors": "9.
|
|
35
|
-
"@browserless/goto": "9.7.
|
|
36
|
-
"@browserless/pdf": "9.7.
|
|
37
|
-
"@browserless/screenshot": "9.7.
|
|
34
|
+
"@browserless/errors": "9.7.2",
|
|
35
|
+
"@browserless/goto": "9.7.2",
|
|
36
|
+
"@browserless/pdf": "9.7.2",
|
|
37
|
+
"@browserless/screenshot": "9.7.2",
|
|
38
38
|
"debug-logfmt": "~1.0.4",
|
|
39
39
|
"kill-process-group": "~1.0.3",
|
|
40
40
|
"p-reflect": "~2.1.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"superlock": "~1.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@browserless/test": "9.7.
|
|
47
|
+
"@browserless/test": "9.7.2",
|
|
48
48
|
"ava": "3"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
@@ -53,13 +53,14 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"src"
|
|
55
55
|
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"test": "ava"
|
|
58
|
+
},
|
|
56
59
|
"license": "MIT",
|
|
57
60
|
"ava": {
|
|
58
61
|
"serial": true,
|
|
59
62
|
"timeout": "30s",
|
|
60
63
|
"verbose": true
|
|
61
64
|
},
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
65
|
+
"gitHead": "49eb374d4c0a2f735ae2a536d4e3d011abbed6a6"
|
|
66
|
+
}
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,6 @@ const debug = require('debug-logfmt')('browserless')
|
|
|
6
6
|
const createGoto = require('@browserless/goto')
|
|
7
7
|
const createPdf = require('@browserless/pdf')
|
|
8
8
|
const { withLock } = require('superlock')
|
|
9
|
-
const { randomUUID } = require('crypto')
|
|
10
9
|
const pReflect = require('p-reflect')
|
|
11
10
|
const pTimeout = require('p-timeout')
|
|
12
11
|
const pRetry = require('p-retry')
|
|
@@ -24,13 +23,8 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
24
23
|
let isClosed = false
|
|
25
24
|
|
|
26
25
|
const close = opts => {
|
|
27
|
-
debug('close', { isClosed })
|
|
28
26
|
isClosed = true
|
|
29
|
-
return browserProcessPromise
|
|
30
|
-
.then(browserProcess => driver.close(browserProcess, opts))
|
|
31
|
-
.catch(error => {
|
|
32
|
-
throw ensureError(error)
|
|
33
|
-
})
|
|
27
|
+
return browserProcessPromise.then(browserProcess => driver.close(browserProcess, opts))
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
const respawn = () =>
|
|
@@ -51,7 +45,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
51
45
|
})
|
|
52
46
|
|
|
53
47
|
promise.then(async browser => {
|
|
54
|
-
browser.once('disconnected', getBrowser)
|
|
48
|
+
if (launchOpts.mode !== 'connect') browser.once('disconnected', getBrowser)
|
|
55
49
|
debug('spawn', {
|
|
56
50
|
respawn: isRespawn,
|
|
57
51
|
pid: driver.pid(browser) || launchOpts.mode,
|
|
@@ -65,9 +59,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
65
59
|
let browserProcessPromise = spawn()
|
|
66
60
|
|
|
67
61
|
const createBrowserContext = contextOpts =>
|
|
68
|
-
getBrowser()
|
|
69
|
-
.then(browser => browser.createIncognitoBrowserContext(contextOpts))
|
|
70
|
-
.then(context => (context._id = randomUUID()) && context)
|
|
62
|
+
getBrowser().then(browser => browser.createIncognitoBrowserContext(contextOpts))
|
|
71
63
|
|
|
72
64
|
const getBrowser = async () => {
|
|
73
65
|
if (isClosed) return browserProcessPromise
|
|
@@ -100,7 +92,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
100
92
|
getBrowserContext()
|
|
101
93
|
])
|
|
102
94
|
const page = await browserContext.newPage()
|
|
103
|
-
debug('createPage', { pid: driver.pid(browserProcess), id: browserContext.
|
|
95
|
+
debug('createPage', { pid: driver.pid(browserProcess), id: browserContext.id })
|
|
104
96
|
return page
|
|
105
97
|
}
|
|
106
98
|
|
|
@@ -111,7 +103,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
111
103
|
getBrowserContext(),
|
|
112
104
|
pReflect(page.close())
|
|
113
105
|
])
|
|
114
|
-
debug('closePage', { pid: driver.pid(browserProcess), id: browserContext.
|
|
106
|
+
debug('closePage', { pid: driver.pid(browserProcess), id: browserContext.id })
|
|
115
107
|
}
|
|
116
108
|
}
|
|
117
109
|
|
|
@@ -170,10 +162,8 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
170
162
|
getBrowser(),
|
|
171
163
|
getBrowserContext()
|
|
172
164
|
])
|
|
173
|
-
const id = browserContext._id
|
|
174
165
|
await pReflect(browserContext.close())
|
|
175
|
-
|
|
176
|
-
debug('destroyContext', { pid: driver.pid(browserProcess), id })
|
|
166
|
+
debug('destroyContext', { pid: driver.pid(browserProcess), id: browserContext.id })
|
|
177
167
|
}
|
|
178
168
|
|
|
179
169
|
return {
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright © 2019 Microlink <hello@microlink.io> (microlink.io)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|