@browserless/pdf 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 +4 -4
  2. package/src/index.js +7 -25
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/pdf",
3
3
  "description": "Convert websites to high-quality PDFs with customizable margins, background printing, and optimized scaling.",
4
4
  "homepage": "https://browserless.js.org/#/?id=pdfurl-options",
5
- "version": "13.8.0",
5
+ "version": "13.8.2",
6
6
  "main": "src",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -30,8 +30,8 @@
30
30
  "website-to-pdf"
31
31
  ],
32
32
  "dependencies": {
33
- "@browserless/goto": "13.8.0",
34
- "@browserless/screenshot": "13.8.0",
33
+ "@browserless/goto": "13.8.2",
34
+ "@browserless/screenshot": "13.8.2",
35
35
  "@kikobeats/time-span": "~1.0.12",
36
36
  "debug-logfmt": "~1.4.10",
37
37
  "p-reflect": "~2.1.0",
@@ -47,5 +47,5 @@
47
47
  "test": "exit 0"
48
48
  },
49
49
  "license": "MIT",
50
- "gitHead": "c8ee02797b7f301426683171bf7132b0df695ca1"
50
+ "gitHead": "71eb0807a8f4f76993efb91976affd380f43316a"
51
51
  }
package/src/index.js CHANGED
@@ -73,29 +73,19 @@ module.exports = ({ goto, ...gotoOpts } = {}) => {
73
73
  ...rest
74
74
  } = opts
75
75
 
76
- const hasActionPdf =
77
- Array.isArray(rest.actions) && rest.actions.some(action => action.type === 'pdf')
78
-
79
76
  if (waitUntil !== 'auto') {
80
- const { actionCaptures } = await goto(page, { ...rest, url, waitUntil })
81
- if (!hasActionPdf) {
82
- await prepareFullDocument(page, { goto, timeout: rest.timeout })
83
- }
84
- return { actionCaptures, hasActionPdf }
77
+ await goto(page, { ...rest, url, waitUntil })
78
+ await prepareFullDocument(page, { goto, timeout: rest.timeout })
79
+ return
85
80
  }
86
81
 
87
82
  let readiness
88
83
  let isReady = false
89
84
  let didHydrateScroll = false
90
85
 
91
- const { actionCaptures } = await goto(page, {
92
- ...rest,
93
- url,
94
- waitUntil,
95
- waitUntilAuto
96
- })
86
+ await goto(page, { ...rest, url, waitUntil, waitUntilAuto })
97
87
 
98
- if (isReady && !hasActionPdf) {
88
+ if (isReady) {
99
89
  const prep = await prepareFullDocument(page, {
100
90
  goto,
101
91
  timeout: rest.timeout,
@@ -104,10 +94,9 @@ module.exports = ({ goto, ...gotoOpts } = {}) => {
104
94
  readiness = { ...readiness, ...prep }
105
95
  }
106
96
 
107
- return { readiness, actionCaptures, hasActionPdf }
97
+ return readiness
108
98
 
109
99
  async function waitUntilAuto (page, { response, timeout: autoTimeout } = {}) {
110
- if (hasActionPdf) return
111
100
  const timeout = autoTimeout ?? goto.timeouts.action(rest.timeout)
112
101
  let didHydrateAttempt = false
113
102
 
@@ -176,14 +165,7 @@ module.exports = ({ goto, ...gotoOpts } = {}) => {
176
165
  const pdf =
177
166
  page =>
178
167
  async (url, opts = {}) => {
179
- const prepared = await prepare(page, url, opts)
180
- if (prepared?.hasActionPdf) {
181
- const last = prepared.actionCaptures?.pdfs?.at(-1)
182
- if (!last?.buffer) {
183
- throw new Error('actions: pdf action produced no buffer')
184
- }
185
- return last.buffer
186
- }
168
+ await prepare(page, url, opts)
187
169
  return render(page, opts)
188
170
  }
189
171