browserless 9.8.4 → 9.9.0
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 +2 -2
- package/src/index.js +7 -5
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.
|
|
5
|
+
"version": "9.9.0",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"timeout": "30s",
|
|
63
63
|
"verbose": true
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "a563e7bc8f30e8d5a2c3d19e8a50ca0bf7bfad3e"
|
|
66
66
|
}
|
package/src/index.js
CHANGED
|
@@ -107,7 +107,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const
|
|
110
|
+
const withPage = (fn, { timeout: evaluateTimeout } = {}) => async (...args) => {
|
|
111
111
|
let isRejected = false
|
|
112
112
|
|
|
113
113
|
async function run () {
|
|
@@ -140,6 +140,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
140
140
|
}
|
|
141
141
|
})
|
|
142
142
|
|
|
143
|
+
console.log({ evaluateTimeout, contextTimeout, globalTimeout })
|
|
143
144
|
const timeout = evaluateTimeout || contextTimeout || globalTimeout
|
|
144
145
|
|
|
145
146
|
return pTimeout(task(), timeout, () => {
|
|
@@ -149,7 +150,7 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
const evaluate = (fn, gotoOpts) =>
|
|
152
|
-
|
|
153
|
+
withPage(
|
|
153
154
|
page => async (url, opts) => {
|
|
154
155
|
const { response, error } = await goto(page, { url, ...gotoOpts, ...opts })
|
|
155
156
|
return fn(page, response, error)
|
|
@@ -174,11 +175,12 @@ module.exports = ({ timeout: globalTimeout = 30000, ...launchOpts } = {}) => {
|
|
|
174
175
|
goto,
|
|
175
176
|
html: evaluate(page => page.content(), { animations: true }),
|
|
176
177
|
page: createPage,
|
|
177
|
-
pdf:
|
|
178
|
-
screenshot:
|
|
178
|
+
pdf: withPage(createPdf({ goto })),
|
|
179
|
+
screenshot: withPage(createScreenshot({ goto })),
|
|
179
180
|
text: evaluate(page => page.evaluate(() => document.body.innerText)),
|
|
180
181
|
getDevice: goto.getDevice,
|
|
181
|
-
destroyContext
|
|
182
|
+
destroyContext,
|
|
183
|
+
withPage
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
|