@browserless/screenshot 9.3.0-beta.0 → 9.3.0-beta.12
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 +7 -8
- package/src/index.js +8 -5
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@browserless/screenshot",
|
|
3
3
|
"description": "Take clean screenshot of any website",
|
|
4
4
|
"homepage": "https://browserless.js.org/#/?id=screenshoturl-options",
|
|
5
|
-
"version": "9.3.0-beta.
|
|
5
|
+
"version": "9.3.0-beta.12",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": {
|
|
8
8
|
"email": "hello@microlink.io",
|
|
@@ -28,19 +28,18 @@
|
|
|
28
28
|
"screenshot"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@browserless/goto": "^9.2.22",
|
|
31
|
+
"@browserless/goto": "^9.3.0-beta.12",
|
|
33
32
|
"debug-logfmt": "~1.0.4",
|
|
34
|
-
"got": "~11.8.
|
|
33
|
+
"got": "~11.8.3",
|
|
35
34
|
"is-html-content": "~1.0.0",
|
|
36
|
-
"is-url-http": "~2.2.
|
|
35
|
+
"is-url-http": "~2.2.5",
|
|
37
36
|
"jimp": "~0.16.1",
|
|
38
37
|
"map-values-deep": "~1.0.2",
|
|
39
|
-
"mime-types": "~2.1.
|
|
38
|
+
"mime-types": "~2.1.34",
|
|
40
39
|
"p-reflect": "~2.1.0",
|
|
41
40
|
"pretty-ms": "~7.0.1",
|
|
42
41
|
"prism-themes": "~1.9.0",
|
|
43
|
-
"sharp": "~0.29.
|
|
42
|
+
"sharp": "~0.29.3",
|
|
44
43
|
"svg-gradient": "~1.0.3",
|
|
45
44
|
"time-span": "~4.0.0"
|
|
46
45
|
},
|
|
@@ -59,5 +58,5 @@
|
|
|
59
58
|
"test": "exit 0"
|
|
60
59
|
},
|
|
61
60
|
"license": "MIT",
|
|
62
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "4c4e979c675f544b903ee5c0d6add9a8651deb0c"
|
|
63
62
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { PuppeteerPendingRequests } = require('@agabhane/puppeteer-pending-requests')
|
|
4
3
|
const debug = require('debug-logfmt')('browserless:screenshot')
|
|
5
4
|
const createGoto = require('@browserless/goto')
|
|
6
5
|
const prettyMs = require('pretty-ms')
|
|
@@ -68,7 +67,13 @@ module.exports = ({ goto, ...gotoOpts }) => {
|
|
|
68
67
|
fn: () => waitForImagesOnViewport(page),
|
|
69
68
|
debug: 'beforeScreenshot:waitForImagesOnViewport'
|
|
70
69
|
}
|
|
71
|
-
].map(({ fn, ...opts }) =>
|
|
70
|
+
].map(({ fn, ...opts }) => {
|
|
71
|
+
return goto.run({
|
|
72
|
+
fn: fn(),
|
|
73
|
+
timeout: goto.timeouts.action(goto.timeouts.base(opts.timeout)),
|
|
74
|
+
...opts
|
|
75
|
+
})
|
|
76
|
+
})
|
|
72
77
|
)
|
|
73
78
|
|
|
74
79
|
const takeScreenshot = async opts => {
|
|
@@ -94,13 +99,11 @@ module.exports = ({ goto, ...gotoOpts }) => {
|
|
|
94
99
|
screenshot = await page.screenshot({ ...opts, ...screenshotOpts })
|
|
95
100
|
debug('screenshot', { waitUntil, duration: prettyMs(timeScreenshot()) })
|
|
96
101
|
} else {
|
|
97
|
-
const puppeteerPendingRequests = new PuppeteerPendingRequests(page)
|
|
98
102
|
;({ response } = await goto(page, { ...opts, url, waitUntilAuto }))
|
|
99
103
|
async function waitUntilAuto (page, { response }) {
|
|
100
104
|
const [screenshotOpts] = await Promise.all([
|
|
101
105
|
waitForElement(page, element),
|
|
102
|
-
beforeScreenshot(response)
|
|
103
|
-
puppeteerPendingRequests.waitForNetworkIdle(100)
|
|
106
|
+
beforeScreenshot(response)
|
|
104
107
|
])
|
|
105
108
|
const { isWhite } = await takeScreenshot({ ...opts, ...screenshotOpts })
|
|
106
109
|
debug('screenshot', { waitUntil, isWhite, duration: prettyMs(timeScreenshot()) })
|