@browserless/screenshot 13.8.0 → 13.8.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.js +10 -29
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/screenshot",
3
3
  "description": "Capture high-quality screenshots of websites with overlay support, device emulation, and automated image optimization.",
4
4
  "homepage": "https://browserless.js.org/#/?id=screenshoturl-options",
5
- "version": "13.8.0",
5
+ "version": "13.8.2",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -33,7 +33,7 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@browserless/errors": "13.6.10",
36
- "@browserless/goto": "13.8.0",
36
+ "@browserless/goto": "13.8.2",
37
37
  "@kikobeats/content-type": "~1.0.4",
38
38
  "@kikobeats/time-span": "~1.0.12",
39
39
  "automad-prism-themes": "~0.3.7",
@@ -70,5 +70,5 @@
70
70
  "timeout": "2m",
71
71
  "workerThreads": false
72
72
  },
73
- "gitHead": "c8ee02797b7f301426683171bf7132b0df695ca1"
73
+ "gitHead": "71eb0807a8f4f76993efb91976affd380f43316a"
74
74
  }
package/src/index.js CHANGED
@@ -241,33 +241,22 @@ module.exports = ({ goto, ...gotoOpts }) => {
241
241
 
242
242
  try {
243
243
  const timeScreenshot = prettyTimeSpan()
244
- const hasActionScreenshot =
245
- Array.isArray(opts.actions) && opts.actions.some(action => action.type === 'screenshot')
246
- let actionCaptures
247
244
 
248
245
  if (waitUntil !== 'auto') {
249
- ;({ response, actionCaptures } = await goto(page, { ...opts, url, waitUntil }))
250
- if (!hasActionScreenshot) {
251
- const screenshotOpts = await beforeScreenshot(page, response, opts)
252
- if (opts.fullPage) {
253
- await prepareFullDocument(page, { goto, timeout: opts.timeout })
254
- }
255
- screenshot = await captureExpanded(
256
- opts.fullPage,
257
- { ...opts, ...screenshotOpts },
258
- goto.timeouts.action(opts.timeout)
259
- )
246
+ ;({ response } = await goto(page, { ...opts, url, waitUntil }))
247
+ const screenshotOpts = await beforeScreenshot(page, response, opts)
248
+ if (opts.fullPage) {
249
+ await prepareFullDocument(page, { goto, timeout: opts.timeout })
260
250
  }
251
+ screenshot = await captureExpanded(
252
+ opts.fullPage,
253
+ { ...opts, ...screenshotOpts },
254
+ goto.timeouts.action(opts.timeout)
255
+ )
261
256
  debug('screenshot', { waitUntil, duration: timeScreenshot() })
262
257
  } else {
263
- ;({ response, actionCaptures } = await goto(page, {
264
- ...opts,
265
- url,
266
- waitUntil,
267
- waitUntilAuto
268
- }))
258
+ ;({ response } = await goto(page, { ...opts, url, waitUntil, waitUntilAuto }))
269
259
  async function waitUntilAuto (page, { response }) {
270
- if (hasActionScreenshot) return
271
260
  const screenshotOpts = await beforeScreenshot(page, response, opts)
272
261
  const { isWhite, isReady, retry } = await takeScreenshot({
273
262
  ...opts,
@@ -285,14 +274,6 @@ module.exports = ({ goto, ...gotoOpts }) => {
285
274
  }
286
275
  }
287
276
 
288
- if (hasActionScreenshot) {
289
- const last = actionCaptures?.screenshots?.at(-1)
290
- if (!last?.buffer) {
291
- throw new Error('actions: screenshot action produced no buffer')
292
- }
293
- screenshot = last.buffer
294
- }
295
-
296
277
  return Object.keys(overlayOpts).length === 0
297
278
  ? screenshot
298
279
  : overlay(screenshot, { ...opts, ...overlayOpts, viewport: page.viewport() })