renderscreenshot 1.0.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 +21 -0
- package/README.md +366 -0
- package/dist/cjs/cache.js +125 -0
- package/dist/cjs/cache.js.map +1 -0
- package/dist/cjs/client.js +304 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.js +85 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/options.js +659 -0
- package/dist/cjs/options.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/webhooks.js +152 -0
- package/dist/cjs/webhooks.js.map +1 -0
- package/dist/esm/cache.js +121 -0
- package/dist/esm/cache.js.map +1 -0
- package/dist/esm/client.js +300 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.js +81 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/options.js +655 -0
- package/dist/esm/options.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/webhooks.js +147 -0
- package/dist/esm/webhooks.js.map +1 -0
- package/dist/types/cache.d.ts +96 -0
- package/dist/types/cache.d.ts.map +1 -0
- package/dist/types/client.d.ts +147 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/errors.d.ts +51 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/options.d.ts +265 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/types.d.ts +249 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/webhooks.d.ts +60 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TakeOptions = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Fluent builder for screenshot options
|
|
6
|
+
*/
|
|
7
|
+
class TakeOptions {
|
|
8
|
+
config;
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
this.config = { ...config };
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create options with a URL target
|
|
14
|
+
*/
|
|
15
|
+
static url(url) {
|
|
16
|
+
return new TakeOptions({ url });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create options with HTML content
|
|
20
|
+
*/
|
|
21
|
+
static html(html) {
|
|
22
|
+
return new TakeOptions({ html });
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create options from an existing config
|
|
26
|
+
*/
|
|
27
|
+
static from(config) {
|
|
28
|
+
return new TakeOptions(config);
|
|
29
|
+
}
|
|
30
|
+
// --- Viewport ---
|
|
31
|
+
/**
|
|
32
|
+
* Set viewport width in pixels
|
|
33
|
+
*/
|
|
34
|
+
width(value) {
|
|
35
|
+
return new TakeOptions({ ...this.config, width: value });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set viewport height in pixels
|
|
39
|
+
*/
|
|
40
|
+
height(value) {
|
|
41
|
+
return new TakeOptions({ ...this.config, height: value });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Set device scale factor (1-3)
|
|
45
|
+
*/
|
|
46
|
+
scale(value) {
|
|
47
|
+
return new TakeOptions({ ...this.config, scale: value });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Enable mobile emulation
|
|
51
|
+
*/
|
|
52
|
+
mobile(value = true) {
|
|
53
|
+
return new TakeOptions({ ...this.config, mobile: value });
|
|
54
|
+
}
|
|
55
|
+
// --- Capture ---
|
|
56
|
+
/**
|
|
57
|
+
* Capture full scrollable page
|
|
58
|
+
*/
|
|
59
|
+
fullPage(value = true) {
|
|
60
|
+
return new TakeOptions({ ...this.config, fullPage: value });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Capture specific element by CSS selector
|
|
64
|
+
*/
|
|
65
|
+
element(selector) {
|
|
66
|
+
return new TakeOptions({ ...this.config, element: selector });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Set output format
|
|
70
|
+
*/
|
|
71
|
+
format(value) {
|
|
72
|
+
return new TakeOptions({ ...this.config, format: value });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Set JPEG/WebP quality (1-100)
|
|
76
|
+
*/
|
|
77
|
+
quality(value) {
|
|
78
|
+
return new TakeOptions({ ...this.config, quality: value });
|
|
79
|
+
}
|
|
80
|
+
// --- Wait ---
|
|
81
|
+
/**
|
|
82
|
+
* Set wait condition
|
|
83
|
+
*/
|
|
84
|
+
waitFor(value) {
|
|
85
|
+
return new TakeOptions({ ...this.config, waitFor: value });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Add delay after page load (milliseconds)
|
|
89
|
+
*/
|
|
90
|
+
delay(value) {
|
|
91
|
+
return new TakeOptions({ ...this.config, delay: value });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Wait for CSS selector to appear
|
|
95
|
+
*/
|
|
96
|
+
waitForSelector(selector) {
|
|
97
|
+
return new TakeOptions({ ...this.config, waitForSelector: selector });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Maximum wait time in milliseconds
|
|
101
|
+
*/
|
|
102
|
+
waitForTimeout(value) {
|
|
103
|
+
return new TakeOptions({ ...this.config, waitForTimeout: value });
|
|
104
|
+
}
|
|
105
|
+
// --- Presets ---
|
|
106
|
+
/**
|
|
107
|
+
* Use a preset configuration
|
|
108
|
+
*/
|
|
109
|
+
preset(value) {
|
|
110
|
+
return new TakeOptions({ ...this.config, preset: value });
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Emulate a specific device
|
|
114
|
+
*/
|
|
115
|
+
device(value) {
|
|
116
|
+
return new TakeOptions({ ...this.config, device: value });
|
|
117
|
+
}
|
|
118
|
+
// --- Blocking ---
|
|
119
|
+
/**
|
|
120
|
+
* Block ad network domains
|
|
121
|
+
*/
|
|
122
|
+
blockAds(value = true) {
|
|
123
|
+
return new TakeOptions({ ...this.config, blockAds: value });
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Block analytics/tracking
|
|
127
|
+
*/
|
|
128
|
+
blockTrackers(value = true) {
|
|
129
|
+
return new TakeOptions({ ...this.config, blockTrackers: value });
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Auto-dismiss cookie popups
|
|
133
|
+
*/
|
|
134
|
+
blockCookieBanners(value = true) {
|
|
135
|
+
return new TakeOptions({ ...this.config, blockCookieBanners: value });
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Block chat widgets
|
|
139
|
+
*/
|
|
140
|
+
blockChatWidgets(value = true) {
|
|
141
|
+
return new TakeOptions({ ...this.config, blockChatWidgets: value });
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Block URLs matching patterns (glob)
|
|
145
|
+
*/
|
|
146
|
+
blockUrls(patterns) {
|
|
147
|
+
return new TakeOptions({ ...this.config, blockUrls: patterns });
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Block specific resource types
|
|
151
|
+
*/
|
|
152
|
+
blockResources(types) {
|
|
153
|
+
return new TakeOptions({ ...this.config, blockResources: types });
|
|
154
|
+
}
|
|
155
|
+
// --- Page manipulation ---
|
|
156
|
+
/**
|
|
157
|
+
* Inject JavaScript (inline or URL)
|
|
158
|
+
*/
|
|
159
|
+
injectScript(script) {
|
|
160
|
+
return new TakeOptions({ ...this.config, injectScript: script });
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Inject CSS (inline or URL)
|
|
164
|
+
*/
|
|
165
|
+
injectStyle(style) {
|
|
166
|
+
return new TakeOptions({ ...this.config, injectStyle: style });
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Click element before capture
|
|
170
|
+
*/
|
|
171
|
+
click(selector) {
|
|
172
|
+
return new TakeOptions({ ...this.config, click: selector });
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Hide elements (visibility: hidden)
|
|
176
|
+
*/
|
|
177
|
+
hide(selectors) {
|
|
178
|
+
return new TakeOptions({ ...this.config, hide: selectors });
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Remove elements from DOM
|
|
182
|
+
*/
|
|
183
|
+
remove(selectors) {
|
|
184
|
+
return new TakeOptions({ ...this.config, remove: selectors });
|
|
185
|
+
}
|
|
186
|
+
// --- Browser emulation ---
|
|
187
|
+
/**
|
|
188
|
+
* Enable dark mode (prefers-color-scheme: dark)
|
|
189
|
+
*/
|
|
190
|
+
darkMode(value = true) {
|
|
191
|
+
return new TakeOptions({ ...this.config, darkMode: value });
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Enable reduced motion preference
|
|
195
|
+
*/
|
|
196
|
+
reducedMotion(value = true) {
|
|
197
|
+
return new TakeOptions({ ...this.config, reducedMotion: value });
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Set media type emulation
|
|
201
|
+
*/
|
|
202
|
+
mediaType(value) {
|
|
203
|
+
return new TakeOptions({ ...this.config, mediaType: value });
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Set custom user agent
|
|
207
|
+
*/
|
|
208
|
+
userAgent(value) {
|
|
209
|
+
return new TakeOptions({ ...this.config, userAgent: value });
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Set timezone (IANA format)
|
|
213
|
+
*/
|
|
214
|
+
timezone(value) {
|
|
215
|
+
return new TakeOptions({ ...this.config, timezone: value });
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Set locale (BCP 47 format)
|
|
219
|
+
*/
|
|
220
|
+
locale(value) {
|
|
221
|
+
return new TakeOptions({ ...this.config, locale: value });
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Set geolocation coordinates
|
|
225
|
+
*/
|
|
226
|
+
geolocation(latitude, longitude, accuracy) {
|
|
227
|
+
const geo = { latitude, longitude };
|
|
228
|
+
if (accuracy !== undefined) {
|
|
229
|
+
geo.accuracy = accuracy;
|
|
230
|
+
}
|
|
231
|
+
return new TakeOptions({ ...this.config, geolocation: geo });
|
|
232
|
+
}
|
|
233
|
+
// --- Network ---
|
|
234
|
+
/**
|
|
235
|
+
* Set custom HTTP headers
|
|
236
|
+
*/
|
|
237
|
+
headers(value) {
|
|
238
|
+
return new TakeOptions({ ...this.config, headers: value });
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Set cookies
|
|
242
|
+
*/
|
|
243
|
+
cookies(value) {
|
|
244
|
+
return new TakeOptions({ ...this.config, cookies: value });
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Set HTTP Basic authentication
|
|
248
|
+
*/
|
|
249
|
+
authBasic(username, password) {
|
|
250
|
+
return new TakeOptions({ ...this.config, authBasic: { username, password } });
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Set Bearer token authentication
|
|
254
|
+
*/
|
|
255
|
+
authBearer(token) {
|
|
256
|
+
return new TakeOptions({ ...this.config, authBearer: token });
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Bypass Content Security Policy
|
|
260
|
+
*/
|
|
261
|
+
bypassCsp(value = true) {
|
|
262
|
+
return new TakeOptions({ ...this.config, bypassCsp: value });
|
|
263
|
+
}
|
|
264
|
+
// --- Cache ---
|
|
265
|
+
/**
|
|
266
|
+
* Set cache TTL in seconds (3600-2592000)
|
|
267
|
+
*/
|
|
268
|
+
cacheTtl(value) {
|
|
269
|
+
return new TakeOptions({ ...this.config, cacheTtl: value });
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Force cache refresh
|
|
273
|
+
*/
|
|
274
|
+
cacheRefresh(value = true) {
|
|
275
|
+
return new TakeOptions({ ...this.config, cacheRefresh: value });
|
|
276
|
+
}
|
|
277
|
+
// --- PDF options ---
|
|
278
|
+
/**
|
|
279
|
+
* Set PDF paper size
|
|
280
|
+
*/
|
|
281
|
+
pdfPaperSize(value) {
|
|
282
|
+
return new TakeOptions({ ...this.config, pdfPaperSize: value });
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Set custom PDF width (CSS units)
|
|
286
|
+
*/
|
|
287
|
+
pdfWidth(value) {
|
|
288
|
+
return new TakeOptions({ ...this.config, pdfWidth: value });
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Set custom PDF height (CSS units)
|
|
292
|
+
*/
|
|
293
|
+
pdfHeight(value) {
|
|
294
|
+
return new TakeOptions({ ...this.config, pdfHeight: value });
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Set PDF landscape orientation
|
|
298
|
+
*/
|
|
299
|
+
pdfLandscape(value = true) {
|
|
300
|
+
return new TakeOptions({ ...this.config, pdfLandscape: value });
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Set uniform PDF margin (CSS units)
|
|
304
|
+
*/
|
|
305
|
+
pdfMargin(value) {
|
|
306
|
+
return new TakeOptions({ ...this.config, pdfMargin: value });
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Set PDF top margin
|
|
310
|
+
*/
|
|
311
|
+
pdfMarginTop(value) {
|
|
312
|
+
return new TakeOptions({ ...this.config, pdfMarginTop: value });
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Set PDF right margin
|
|
316
|
+
*/
|
|
317
|
+
pdfMarginRight(value) {
|
|
318
|
+
return new TakeOptions({ ...this.config, pdfMarginRight: value });
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Set PDF bottom margin
|
|
322
|
+
*/
|
|
323
|
+
pdfMarginBottom(value) {
|
|
324
|
+
return new TakeOptions({ ...this.config, pdfMarginBottom: value });
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Set PDF left margin
|
|
328
|
+
*/
|
|
329
|
+
pdfMarginLeft(value) {
|
|
330
|
+
return new TakeOptions({ ...this.config, pdfMarginLeft: value });
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Set PDF scale factor (0.1-2.0)
|
|
334
|
+
*/
|
|
335
|
+
pdfScale(value) {
|
|
336
|
+
return new TakeOptions({ ...this.config, pdfScale: value });
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Include background graphics in PDF
|
|
340
|
+
*/
|
|
341
|
+
pdfPrintBackground(value = true) {
|
|
342
|
+
return new TakeOptions({ ...this.config, pdfPrintBackground: value });
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Set PDF page ranges (e.g., "1-5, 8")
|
|
346
|
+
*/
|
|
347
|
+
pdfPageRanges(value) {
|
|
348
|
+
return new TakeOptions({ ...this.config, pdfPageRanges: value });
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Set PDF header HTML template
|
|
352
|
+
*/
|
|
353
|
+
pdfHeader(value) {
|
|
354
|
+
return new TakeOptions({ ...this.config, pdfHeader: value });
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Set PDF footer HTML template
|
|
358
|
+
*/
|
|
359
|
+
pdfFooter(value) {
|
|
360
|
+
return new TakeOptions({ ...this.config, pdfFooter: value });
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Fit content to single PDF page
|
|
364
|
+
*/
|
|
365
|
+
pdfFitOnePage(value = true) {
|
|
366
|
+
return new TakeOptions({ ...this.config, pdfFitOnePage: value });
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Use CSS-defined page size for PDF
|
|
370
|
+
*/
|
|
371
|
+
pdfPreferCssPageSize(value = true) {
|
|
372
|
+
return new TakeOptions({ ...this.config, pdfPreferCssPageSize: value });
|
|
373
|
+
}
|
|
374
|
+
// --- Storage (BYOS) ---
|
|
375
|
+
/**
|
|
376
|
+
* Enable custom storage upload
|
|
377
|
+
*/
|
|
378
|
+
storageEnabled(value = true) {
|
|
379
|
+
return new TakeOptions({ ...this.config, storageEnabled: value });
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Set storage path template
|
|
383
|
+
*/
|
|
384
|
+
storagePath(value) {
|
|
385
|
+
return new TakeOptions({ ...this.config, storagePath: value });
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Set storage ACL
|
|
389
|
+
*/
|
|
390
|
+
storageAcl(value) {
|
|
391
|
+
return new TakeOptions({ ...this.config, storageAcl: value });
|
|
392
|
+
}
|
|
393
|
+
// --- Output ---
|
|
394
|
+
/**
|
|
395
|
+
* Get the raw configuration object
|
|
396
|
+
*/
|
|
397
|
+
toConfig() {
|
|
398
|
+
return { ...this.config };
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Convert to API request parameters (for POST body)
|
|
402
|
+
*/
|
|
403
|
+
toParams() {
|
|
404
|
+
const params = {};
|
|
405
|
+
// Target
|
|
406
|
+
if (this.config.url !== undefined)
|
|
407
|
+
params['url'] = this.config.url;
|
|
408
|
+
if (this.config.html !== undefined)
|
|
409
|
+
params['html'] = this.config.html;
|
|
410
|
+
// Viewport
|
|
411
|
+
if (this.config.width !== undefined)
|
|
412
|
+
params['viewport'] = { ...(params['viewport'] ?? {}), width: this.config.width };
|
|
413
|
+
if (this.config.height !== undefined)
|
|
414
|
+
params['viewport'] = {
|
|
415
|
+
...(params['viewport'] ?? {}),
|
|
416
|
+
height: this.config.height,
|
|
417
|
+
};
|
|
418
|
+
if (this.config.scale !== undefined)
|
|
419
|
+
params['viewport'] = { ...(params['viewport'] ?? {}), scale: this.config.scale };
|
|
420
|
+
if (this.config.mobile !== undefined)
|
|
421
|
+
params['viewport'] = {
|
|
422
|
+
...(params['viewport'] ?? {}),
|
|
423
|
+
mobile: this.config.mobile,
|
|
424
|
+
};
|
|
425
|
+
// Capture
|
|
426
|
+
if (this.config.fullPage !== undefined)
|
|
427
|
+
params['full_page'] = this.config.fullPage;
|
|
428
|
+
if (this.config.element !== undefined)
|
|
429
|
+
params['element'] = this.config.element;
|
|
430
|
+
if (this.config.format !== undefined)
|
|
431
|
+
params['format'] = this.config.format;
|
|
432
|
+
if (this.config.quality !== undefined)
|
|
433
|
+
params['quality'] = this.config.quality;
|
|
434
|
+
// Wait
|
|
435
|
+
if (this.config.waitFor !== undefined)
|
|
436
|
+
params['wait_for'] = this.config.waitFor;
|
|
437
|
+
if (this.config.delay !== undefined)
|
|
438
|
+
params['delay'] = this.config.delay;
|
|
439
|
+
if (this.config.waitForSelector !== undefined)
|
|
440
|
+
params['wait_for_selector'] = this.config.waitForSelector;
|
|
441
|
+
if (this.config.waitForTimeout !== undefined)
|
|
442
|
+
params['wait_for_timeout'] = this.config.waitForTimeout;
|
|
443
|
+
// Presets
|
|
444
|
+
if (this.config.preset !== undefined)
|
|
445
|
+
params['preset'] = this.config.preset;
|
|
446
|
+
if (this.config.device !== undefined)
|
|
447
|
+
params['device'] = this.config.device;
|
|
448
|
+
// Blocking
|
|
449
|
+
if (this.config.blockAds !== undefined)
|
|
450
|
+
params['block_ads'] = this.config.blockAds;
|
|
451
|
+
if (this.config.blockTrackers !== undefined)
|
|
452
|
+
params['block_trackers'] = this.config.blockTrackers;
|
|
453
|
+
if (this.config.blockCookieBanners !== undefined)
|
|
454
|
+
params['block_cookie_banners'] = this.config.blockCookieBanners;
|
|
455
|
+
if (this.config.blockChatWidgets !== undefined)
|
|
456
|
+
params['block_chat_widgets'] = this.config.blockChatWidgets;
|
|
457
|
+
if (this.config.blockUrls !== undefined)
|
|
458
|
+
params['block_urls'] = this.config.blockUrls;
|
|
459
|
+
if (this.config.blockResources !== undefined)
|
|
460
|
+
params['block_resources'] = this.config.blockResources;
|
|
461
|
+
// Page manipulation
|
|
462
|
+
if (this.config.injectScript !== undefined)
|
|
463
|
+
params['inject_script'] = this.config.injectScript;
|
|
464
|
+
if (this.config.injectStyle !== undefined)
|
|
465
|
+
params['inject_style'] = this.config.injectStyle;
|
|
466
|
+
if (this.config.click !== undefined)
|
|
467
|
+
params['click'] = this.config.click;
|
|
468
|
+
if (this.config.hide !== undefined)
|
|
469
|
+
params['hide'] = this.config.hide;
|
|
470
|
+
if (this.config.remove !== undefined)
|
|
471
|
+
params['remove'] = this.config.remove;
|
|
472
|
+
// Browser emulation
|
|
473
|
+
if (this.config.darkMode !== undefined)
|
|
474
|
+
params['dark_mode'] = this.config.darkMode;
|
|
475
|
+
if (this.config.reducedMotion !== undefined)
|
|
476
|
+
params['reduced_motion'] = this.config.reducedMotion;
|
|
477
|
+
if (this.config.mediaType !== undefined)
|
|
478
|
+
params['media_type'] = this.config.mediaType;
|
|
479
|
+
if (this.config.userAgent !== undefined)
|
|
480
|
+
params['user_agent'] = this.config.userAgent;
|
|
481
|
+
if (this.config.timezone !== undefined)
|
|
482
|
+
params['timezone'] = this.config.timezone;
|
|
483
|
+
if (this.config.locale !== undefined)
|
|
484
|
+
params['locale'] = this.config.locale;
|
|
485
|
+
if (this.config.geolocation !== undefined)
|
|
486
|
+
params['geolocation'] = this.config.geolocation;
|
|
487
|
+
// Network
|
|
488
|
+
if (this.config.headers !== undefined)
|
|
489
|
+
params['headers'] = this.config.headers;
|
|
490
|
+
if (this.config.cookies !== undefined)
|
|
491
|
+
params['cookies'] = this.config.cookies;
|
|
492
|
+
if (this.config.authBasic !== undefined)
|
|
493
|
+
params['auth_basic'] = this.config.authBasic;
|
|
494
|
+
if (this.config.authBearer !== undefined)
|
|
495
|
+
params['auth_bearer'] = this.config.authBearer;
|
|
496
|
+
if (this.config.bypassCsp !== undefined)
|
|
497
|
+
params['bypass_csp'] = this.config.bypassCsp;
|
|
498
|
+
// Cache
|
|
499
|
+
if (this.config.cacheTtl !== undefined)
|
|
500
|
+
params['cache_ttl'] = this.config.cacheTtl;
|
|
501
|
+
if (this.config.cacheRefresh !== undefined)
|
|
502
|
+
params['cache_refresh'] = this.config.cacheRefresh;
|
|
503
|
+
// PDF
|
|
504
|
+
if (this.config.pdfPaperSize !== undefined)
|
|
505
|
+
params['pdf'] = {
|
|
506
|
+
...(params['pdf'] ?? {}),
|
|
507
|
+
paper_size: this.config.pdfPaperSize,
|
|
508
|
+
};
|
|
509
|
+
if (this.config.pdfWidth !== undefined)
|
|
510
|
+
params['pdf'] = { ...(params['pdf'] ?? {}), width: this.config.pdfWidth };
|
|
511
|
+
if (this.config.pdfHeight !== undefined)
|
|
512
|
+
params['pdf'] = { ...(params['pdf'] ?? {}), height: this.config.pdfHeight };
|
|
513
|
+
if (this.config.pdfLandscape !== undefined)
|
|
514
|
+
params['pdf'] = { ...(params['pdf'] ?? {}), landscape: this.config.pdfLandscape };
|
|
515
|
+
if (this.config.pdfMargin !== undefined)
|
|
516
|
+
params['pdf'] = { ...(params['pdf'] ?? {}), margin: this.config.pdfMargin };
|
|
517
|
+
if (this.config.pdfMarginTop !== undefined)
|
|
518
|
+
params['pdf'] = {
|
|
519
|
+
...(params['pdf'] ?? {}),
|
|
520
|
+
margin_top: this.config.pdfMarginTop,
|
|
521
|
+
};
|
|
522
|
+
if (this.config.pdfMarginRight !== undefined)
|
|
523
|
+
params['pdf'] = {
|
|
524
|
+
...(params['pdf'] ?? {}),
|
|
525
|
+
margin_right: this.config.pdfMarginRight,
|
|
526
|
+
};
|
|
527
|
+
if (this.config.pdfMarginBottom !== undefined)
|
|
528
|
+
params['pdf'] = {
|
|
529
|
+
...(params['pdf'] ?? {}),
|
|
530
|
+
margin_bottom: this.config.pdfMarginBottom,
|
|
531
|
+
};
|
|
532
|
+
if (this.config.pdfMarginLeft !== undefined)
|
|
533
|
+
params['pdf'] = {
|
|
534
|
+
...(params['pdf'] ?? {}),
|
|
535
|
+
margin_left: this.config.pdfMarginLeft,
|
|
536
|
+
};
|
|
537
|
+
if (this.config.pdfScale !== undefined)
|
|
538
|
+
params['pdf'] = { ...(params['pdf'] ?? {}), scale: this.config.pdfScale };
|
|
539
|
+
if (this.config.pdfPrintBackground !== undefined)
|
|
540
|
+
params['pdf'] = {
|
|
541
|
+
...(params['pdf'] ?? {}),
|
|
542
|
+
print_background: this.config.pdfPrintBackground,
|
|
543
|
+
};
|
|
544
|
+
if (this.config.pdfPageRanges !== undefined)
|
|
545
|
+
params['pdf'] = {
|
|
546
|
+
...(params['pdf'] ?? {}),
|
|
547
|
+
page_ranges: this.config.pdfPageRanges,
|
|
548
|
+
};
|
|
549
|
+
if (this.config.pdfHeader !== undefined)
|
|
550
|
+
params['pdf'] = { ...(params['pdf'] ?? {}), header: this.config.pdfHeader };
|
|
551
|
+
if (this.config.pdfFooter !== undefined)
|
|
552
|
+
params['pdf'] = { ...(params['pdf'] ?? {}), footer: this.config.pdfFooter };
|
|
553
|
+
if (this.config.pdfFitOnePage !== undefined)
|
|
554
|
+
params['pdf'] = {
|
|
555
|
+
...(params['pdf'] ?? {}),
|
|
556
|
+
fit_one_page: this.config.pdfFitOnePage,
|
|
557
|
+
};
|
|
558
|
+
if (this.config.pdfPreferCssPageSize !== undefined)
|
|
559
|
+
params['pdf'] = {
|
|
560
|
+
...(params['pdf'] ?? {}),
|
|
561
|
+
prefer_css_page_size: this.config.pdfPreferCssPageSize,
|
|
562
|
+
};
|
|
563
|
+
// Storage
|
|
564
|
+
if (this.config.storageEnabled !== undefined)
|
|
565
|
+
params['storage'] = {
|
|
566
|
+
...(params['storage'] ?? {}),
|
|
567
|
+
enabled: this.config.storageEnabled,
|
|
568
|
+
};
|
|
569
|
+
if (this.config.storagePath !== undefined)
|
|
570
|
+
params['storage'] = {
|
|
571
|
+
...(params['storage'] ?? {}),
|
|
572
|
+
path: this.config.storagePath,
|
|
573
|
+
};
|
|
574
|
+
if (this.config.storageAcl !== undefined)
|
|
575
|
+
params['storage'] = { ...(params['storage'] ?? {}), acl: this.config.storageAcl };
|
|
576
|
+
return params;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Convert to query string (for GET requests)
|
|
580
|
+
*/
|
|
581
|
+
toQueryString() {
|
|
582
|
+
const params = new URLSearchParams();
|
|
583
|
+
// Target
|
|
584
|
+
if (this.config.url !== undefined)
|
|
585
|
+
params.set('url', this.config.url);
|
|
586
|
+
// Viewport (flat for GET)
|
|
587
|
+
if (this.config.width !== undefined)
|
|
588
|
+
params.set('width', String(this.config.width));
|
|
589
|
+
if (this.config.height !== undefined)
|
|
590
|
+
params.set('height', String(this.config.height));
|
|
591
|
+
if (this.config.scale !== undefined)
|
|
592
|
+
params.set('scale', String(this.config.scale));
|
|
593
|
+
if (this.config.mobile !== undefined)
|
|
594
|
+
params.set('mobile', String(this.config.mobile));
|
|
595
|
+
// Capture
|
|
596
|
+
if (this.config.fullPage !== undefined)
|
|
597
|
+
params.set('full_page', String(this.config.fullPage));
|
|
598
|
+
if (this.config.element !== undefined)
|
|
599
|
+
params.set('element', this.config.element);
|
|
600
|
+
if (this.config.format !== undefined)
|
|
601
|
+
params.set('format', this.config.format);
|
|
602
|
+
if (this.config.quality !== undefined)
|
|
603
|
+
params.set('quality', String(this.config.quality));
|
|
604
|
+
// Wait
|
|
605
|
+
if (this.config.waitFor !== undefined)
|
|
606
|
+
params.set('wait_for', this.config.waitFor);
|
|
607
|
+
if (this.config.delay !== undefined)
|
|
608
|
+
params.set('delay', String(this.config.delay));
|
|
609
|
+
if (this.config.waitForSelector !== undefined)
|
|
610
|
+
params.set('wait_for_selector', this.config.waitForSelector);
|
|
611
|
+
if (this.config.waitForTimeout !== undefined)
|
|
612
|
+
params.set('wait_for_timeout', String(this.config.waitForTimeout));
|
|
613
|
+
// Presets
|
|
614
|
+
if (this.config.preset !== undefined)
|
|
615
|
+
params.set('preset', this.config.preset);
|
|
616
|
+
if (this.config.device !== undefined)
|
|
617
|
+
params.set('device', this.config.device);
|
|
618
|
+
// Blocking
|
|
619
|
+
if (this.config.blockAds !== undefined)
|
|
620
|
+
params.set('block_ads', String(this.config.blockAds));
|
|
621
|
+
if (this.config.blockTrackers !== undefined)
|
|
622
|
+
params.set('block_trackers', String(this.config.blockTrackers));
|
|
623
|
+
if (this.config.blockCookieBanners !== undefined)
|
|
624
|
+
params.set('block_cookie_banners', String(this.config.blockCookieBanners));
|
|
625
|
+
if (this.config.blockChatWidgets !== undefined)
|
|
626
|
+
params.set('block_chat_widgets', String(this.config.blockChatWidgets));
|
|
627
|
+
if (this.config.blockUrls !== undefined) {
|
|
628
|
+
this.config.blockUrls.forEach((url) => {
|
|
629
|
+
params.append('block_urls', url);
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
if (this.config.blockResources !== undefined) {
|
|
633
|
+
this.config.blockResources.forEach((r) => {
|
|
634
|
+
params.append('block_resources', r);
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
// Browser emulation
|
|
638
|
+
if (this.config.darkMode !== undefined)
|
|
639
|
+
params.set('dark_mode', String(this.config.darkMode));
|
|
640
|
+
if (this.config.reducedMotion !== undefined)
|
|
641
|
+
params.set('reduced_motion', String(this.config.reducedMotion));
|
|
642
|
+
if (this.config.mediaType !== undefined)
|
|
643
|
+
params.set('media_type', this.config.mediaType);
|
|
644
|
+
if (this.config.userAgent !== undefined)
|
|
645
|
+
params.set('user_agent', this.config.userAgent);
|
|
646
|
+
if (this.config.timezone !== undefined)
|
|
647
|
+
params.set('timezone', this.config.timezone);
|
|
648
|
+
if (this.config.locale !== undefined)
|
|
649
|
+
params.set('locale', this.config.locale);
|
|
650
|
+
// Cache
|
|
651
|
+
if (this.config.cacheTtl !== undefined)
|
|
652
|
+
params.set('cache_ttl', String(this.config.cacheTtl));
|
|
653
|
+
if (this.config.cacheRefresh !== undefined)
|
|
654
|
+
params.set('cache_refresh', String(this.config.cacheRefresh));
|
|
655
|
+
return params.toString();
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
exports.TakeOptions = TakeOptions;
|
|
659
|
+
//# sourceMappingURL=options.js.map
|