@browserless/screenshot 10.10.2 → 10.11.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/LICENSE.md CHANGED
File without changes
package/README.md CHANGED
@@ -69,7 +69,7 @@ const buffer = await browserless.screenshot('https://example.com', {
69
69
  | `element` | `string` | — | CSS selector for element screenshot |
70
70
  | `codeScheme` | `string` | `'atom-dark'` | Prism.js theme for code highlighting |
71
71
  | `waitUntil` | `string` | `'auto'` | When to consider navigation done |
72
- | `waitForDom` | `number` | `1000` | DOM stability window in ms (idle is `waitForDom / 10`) |
72
+ | `waitForDom` | `number` | `0` | DOM stability window in ms (idle is `waitForDom / 10`, `0` disables DOM wait) |
73
73
  | `isPageReady` | `function` | `({ isWhite }) => !isWhite` | Custom readiness predicate for retry loop |
74
74
  | `overlay` | `object` | `{}` | Browser overlay options |
75
75
 
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": "10.10.2",
5
+ "version": "10.11.0",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -32,7 +32,7 @@
32
32
  "jpeg"
33
33
  ],
34
34
  "dependencies": {
35
- "@browserless/goto": "^10.10.2",
35
+ "@browserless/goto": "^10.11.0",
36
36
  "@kikobeats/content-type": "~1.0.3",
37
37
  "@kikobeats/time-span": "~1.0.11",
38
38
  "debug-logfmt": "~1.4.7",
@@ -61,15 +61,14 @@
61
61
  "scripts",
62
62
  "src"
63
63
  ],
64
- "scripts": {
65
- "coverage": "exit 0",
66
- "test": "ava"
67
- },
68
64
  "license": "MIT",
69
65
  "ava": {
70
66
  "serial": true,
71
67
  "timeout": "2m",
72
68
  "workerThreads": false
73
69
  },
74
- "gitHead": "ec6a614923a1a692bd717ecc8e6f1b09417801d9"
75
- }
70
+ "scripts": {
71
+ "coverage": "exit 0",
72
+ "test": "ava"
73
+ }
74
+ }
package/src/index.js CHANGED
@@ -117,10 +117,6 @@ module.exports = ({ goto, ...gotoOpts }) => {
117
117
 
118
118
  let screenshotOpts = {}
119
119
  const tasks = [
120
- {
121
- fn: () => page.evaluate(waitForDomStability, waitForDomOpts),
122
- debug: 'beforeScreenshot:waitForDomStability'
123
- },
124
120
  {
125
121
  fn: () => page.evaluate('document.fonts.ready'),
126
122
  debug: 'beforeScreenshot:fontsReady'
@@ -131,6 +127,13 @@ module.exports = ({ goto, ...gotoOpts }) => {
131
127
  }
132
128
  ]
133
129
 
130
+ if (waitForDomOpts) {
131
+ tasks.push({
132
+ fn: () => page.evaluate(waitForDomStability, waitForDomOpts),
133
+ debug: 'beforeScreenshot:waitForDomStability'
134
+ })
135
+ }
136
+
134
137
  if (codeScheme && response) {
135
138
  tasks.push({
136
139
  fn: () => waitForPrism(page, response, { codeScheme, ...opts }),
@@ -1,10 +1,12 @@
1
1
  'use strict'
2
2
 
3
- const DEFAULT_WAIT_FOR_DOM = 1000
3
+ const DEFAULT_WAIT_FOR_DOM = 0
4
4
  const WAIT_FOR_DOM_IDLE_RATIO = 10
5
5
 
6
6
  const resolveWaitForDom = waitForDom => {
7
- const timeout = Number.isFinite(waitForDom) && waitForDom > 0 ? waitForDom : DEFAULT_WAIT_FOR_DOM
7
+ const timeout = Number.isFinite(waitForDom) && waitForDom >= 0 ? waitForDom : DEFAULT_WAIT_FOR_DOM
8
+
9
+ if (timeout === 0) return undefined
8
10
 
9
11
  return {
10
12
  timeout,