screenshotone-api-sdk 1.0.25 → 1.0.27

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.
@@ -5,8 +5,45 @@ export declare class Client {
5
5
  private readonly accessKey;
6
6
  private readonly secretKey;
7
7
  constructor(accessKey: string, secretKey: string);
8
+ /**
9
+ * Generates an URL that can be used to send GET requests for taking screenshots.
10
+ *
11
+ * Warning! Don't share the link publicly generated by this method publicly.
12
+ *
13
+ * @param options Options for taking the screenshot.
14
+ * @returns An URL that will generate the screenshot if requested.
15
+ */
8
16
  generateTakeURL(options: TakeOptions): string;
17
+ /**
18
+ * Generates the link that can be publicly available, but make sure
19
+ * you read the documentation before at https://screenshotone.com/docs/signed-requests/.
20
+ *
21
+ * @param options
22
+ * @returns A signed URL that will generate the screenshot if requested.
23
+ */
24
+ generateSignedTakeURL(options: TakeOptions): string;
25
+ /**
26
+ * Generates the link that can be publicly available, but make sure
27
+ * you read the documentation before at https://screenshotone.com/docs/signed-requests/.
28
+ *
29
+ * @param options
30
+ * @returns A signed URL that will generate the animated screenshot if requested.
31
+ */
32
+ generateSignedAnimateURL(options: AnimateOptions): string;
33
+ /**
34
+ * Generates a screenshot and return the image blob.
35
+ *
36
+ * @param options
37
+ * @returns
38
+ */
9
39
  take(options: TakeOptions): Promise<Blob>;
40
+ /**
41
+ * Generates an animated screenshot and return the image blob.
42
+ *
43
+ * @param options
44
+ * @returns
45
+ */
46
+ animate(options: AnimateOptions): Promise<Blob>;
10
47
  }
11
48
  /**
12
49
  * Represents options for taking screenshots.
@@ -195,6 +232,18 @@ export declare class TakeOptions {
195
232
  * Sets an authorization header for the request.
196
233
  */
197
234
  authorization(authorization: string): TakeOptions;
235
+ /**
236
+ * It scrolls the page if needed and ensures that the given
237
+ * selector is present in the view when taking a screenshot.
238
+ */
239
+ scrollIntoView(selector: string): TakeOptions;
240
+ /**
241
+ * You can use your custom proxy to take screenshots
242
+ * or render HTML with the proxy option.
243
+ *
244
+ * The https, http, socks4 and socks5 proxies are supported.
245
+ */
246
+ proxy(proxy: string): TakeOptions;
198
247
  /**
199
248
  * Set cookies for the request.
200
249
  */
@@ -241,3 +290,234 @@ export declare class TakeOptions {
241
290
  storageClass(storageClass: string): TakeOptions;
242
291
  toQuery(): URLSearchParams;
243
292
  }
293
+ /**
294
+ * Represents options for animating screenshots.
295
+ */
296
+ export declare class AnimateOptions {
297
+ private readonly query;
298
+ private constructor();
299
+ /**
300
+ * Initializes take screenshot options with provided website URL.
301
+ */
302
+ static url(url: string): AnimateOptions;
303
+ /**
304
+ * Initializes take screenshot options with provided HTML.
305
+ */
306
+ static html(html: string): AnimateOptions;
307
+ /**
308
+ * Initializes take screenshot options with provided Markdown.
309
+ */
310
+ static markdown(markdown: string): AnimateOptions;
311
+ private put;
312
+ /**
313
+ * Available response types:
314
+ * by_format — return exactly the response defined in the format option. If format=png, the response will be the binary representation of the png with the content type header image/png;
315
+ * empty — return only status or error. It is suitable when you want to upload the screenshot to storage and don’t care about the results. It also speeds up the response since there are no networking costs involved.
316
+ * The default value is by_format.
317
+ */
318
+ responseType(responseType: string): this;
319
+ /**
320
+ * When reduced_motion set to `true`,
321
+ * the API will request the site to minimize the amount of non-essential motion it uses.
322
+ * When the site supports it, it should use animations as least as possible.
323
+ */
324
+ reducedMotion(darkMode: boolean): AnimateOptions;
325
+ /**
326
+ * If you want to request the page and it is supported to be rendered for printers, specify `print`.
327
+ * If the page is by default rendered for printers and you want it to be rendered for screens,
328
+ * use `screen`.
329
+ */
330
+ mediaType(mediaType: string): AnimateOptions;
331
+ /**
332
+ * Set `true` to request site rendering, if supported, in the dark mode.
333
+ * Set `false` to request site rendering in the light mode if supported.
334
+ * If you don’t set the parameter. The site is rendered in the default mode.
335
+ */
336
+ darkMode(darkMode: boolean): AnimateOptions;
337
+ /**
338
+ * The `hide_selectors` option allows hiding elements before taking a screenshot.
339
+ * You can specify as many selectors as you wish.
340
+ * All elements that match each selector will be hidden by
341
+ * setting the `display` style property to none `!important`.
342
+ */
343
+ hideSelectors(...selectors: string[]): AnimateOptions;
344
+ /**
345
+ * The scripts_wain_until option allows you to wait until a given
346
+ * set of events after the scripts were executed.
347
+ * It accepts the same values as wait_until and can have multiple values:
348
+ * - `load`: the navigation is successful when the load even is fired;
349
+ * - `domcontentloaded`: the navigation is finished when the DOMContentLoaded even is fired;
350
+ * - `networkidle0`: the navigation is finished when there are no more than 0 network connections for at least 500 ms;
351
+ * _ `networkidle2`: consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
352
+ */
353
+ scriptsWaitUntil(...until: string[]): AnimateOptions;
354
+ /**
355
+ * Styles specifies custom CSS styles for the page.
356
+ */
357
+ styles(styles: string): this;
358
+ /**
359
+ * You can use your custom proxy to take screenshots
360
+ * or render HTML with the proxy option.
361
+ *
362
+ * The https, http, socks4 and socks5 proxies are supported.
363
+ */
364
+ proxy(proxy: string): AnimateOptions;
365
+ /**
366
+ * Scripts specifies custom scripts for the page.
367
+ */
368
+ scripts(scripts: string): this;
369
+ /**
370
+ * Sets response format, one of: "mp4", "avi", "webm", "mov" or "gif".
371
+ */
372
+ format(format: string): AnimateOptions;
373
+ /**
374
+ * Renders a transparent background for the image. Works only if the site has not defined background color.
375
+ * Available for the following response formats: "png", "webp".
376
+ */
377
+ omitBackground(omitBackground: boolean): AnimateOptions;
378
+ /**
379
+ * Instead of manually specifying viewport parameters like width and height,
380
+ * you can specify a device to use for emulation.
381
+ * In addition, other parameters of the viewport, including the user agent,
382
+ * will be set automatically.
383
+ */
384
+ viewportDevice(viewportDevice: string): AnimateOptions;
385
+ /**
386
+ * Sets the width of the browser viewport (pixels).
387
+ */
388
+ viewportWidth(viewportWidth: number): AnimateOptions;
389
+ /**
390
+ * Sets the height of the browser viewport (pixels).
391
+ */
392
+ viewportHeight(viewportHeight: number): AnimateOptions;
393
+ /**
394
+ * Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
395
+ */
396
+ deviceScaleFactor(deviceScaleFactor: number): AnimateOptions;
397
+ /**
398
+ * Whether the meta viewport tag is taken into account. Defaults to `false`.
399
+ */
400
+ viewportMobile(isMobile: boolean): AnimateOptions;
401
+ /**
402
+ * The default value is `false`. Set to `true` if the viewport supports touch events.
403
+ */
404
+ viewportHasTouch(hasTouch: boolean): AnimateOptions;
405
+ /**
406
+ * The default value is `false`. Set to `true` if the viewport is in landscape mode.
407
+ */
408
+ viewportLandscape(landscape: boolean): AnimateOptions;
409
+ /**
410
+ * Sets geolocation latitude for the request.
411
+ * Both latitude and longitude are required if one of them is set.
412
+ */
413
+ geolocationLatitude(latitude: number): AnimateOptions;
414
+ /**
415
+ * Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
416
+ */
417
+ geolocationLongitude(longitude: number): AnimateOptions;
418
+ /**
419
+ * Sets the geolocation accuracy in meters.
420
+ */
421
+ geolocationAccuracy(accuracy: number): AnimateOptions;
422
+ /**
423
+ * Blocks ads.
424
+ */
425
+ blockAds(blockAds: boolean): AnimateOptions;
426
+ /**
427
+ * Blocks cookie banners.
428
+ */
429
+ blockCookieBanners(block: boolean): AnimateOptions;
430
+ /**
431
+ * Blocks chats.
432
+ */
433
+ blockChats(block: boolean): AnimateOptions;
434
+ /**
435
+ * Blocks trackers.
436
+ */
437
+ blockTrackers(blockTrackers: boolean): AnimateOptions;
438
+ /**
439
+ * Blocks requests by specifying URL, domain, or even a simple pattern.
440
+ */
441
+ blockRequests(...blockRequests: string[]): AnimateOptions;
442
+ /**
443
+ * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",
444
+ * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
445
+ */
446
+ blockResources(...blockResources: string[]): AnimateOptions;
447
+ /**
448
+ * Enables caching.
449
+ */
450
+ cache(cache: boolean): AnimateOptions;
451
+ /**
452
+ * Sets cache TTL.
453
+ */
454
+ cacheTtl(cacheTTL: number): AnimateOptions;
455
+ /**
456
+ * Sets cache key.
457
+ */
458
+ cacheKey(cacheKey: string): AnimateOptions;
459
+ /**
460
+ * Sets a user agent for the request.
461
+ */
462
+ userAgent(userAgent: string): AnimateOptions;
463
+ /**
464
+ * Sets an authorization header for the request.
465
+ */
466
+ authorization(authorization: string): AnimateOptions;
467
+ /**
468
+ * Set cookies for the request.
469
+ */
470
+ cookies(...cookies: string[]): AnimateOptions;
471
+ /**
472
+ * Sets extra headers for the request.
473
+ */
474
+ headers(...headers: string[]): this;
475
+ /**
476
+ * TimeZone sets time zone for the request.
477
+ * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
478
+ * "Europe/Madrid", "Pacific/Majuro", "Asia/Kuala_Lumpur", "Pacific/Auckland", "Europe/Lisbon", "Europe/Kiev",
479
+ * "Asia/Tashkent", "Europe/London".
480
+ */
481
+ timeZone(timeZone: string): AnimateOptions;
482
+ /**
483
+ * Sets delay.
484
+ */
485
+ delay(delay: number): AnimateOptions;
486
+ /**
487
+ * Sets timeout.
488
+ */
489
+ timeout(timeout: number): AnimateOptions;
490
+ /**
491
+ * Default value is false. Use store=true to trigger upload of the taken screenshot,
492
+ * rendered HTML or PDF to the configured S3 bucket.
493
+ * Make sure you configured access to S3.
494
+ */
495
+ store(store: boolean): AnimateOptions;
496
+ /**
497
+ * The parameter is required if you set store=true.
498
+ * You must specify the key for the file, but don’t specify an extension,
499
+ * it will be added automatically based on the format you specified.
500
+ * You can also specify “subdirectories” in the path part.
501
+ */
502
+ storagePath(path: string): AnimateOptions;
503
+ /**
504
+ * You can override the default bucket you configured with storage_bucket=<bucket name>.
505
+ */
506
+ storageBucket(bucket: string): AnimateOptions;
507
+ /**
508
+ * Storage class allows you to specify the object storage class.
509
+ */
510
+ storageClass(storageClass: string): AnimateOptions;
511
+ /**
512
+ * Sets animation duration.
513
+ */
514
+ duration(duration: number): AnimateOptions;
515
+ /**
516
+ * Sets animation duration.
517
+ */
518
+ scenario(scenario: string): AnimateOptions;
519
+ scrollDelay(delay: number): AnimateOptions;
520
+ scrollDuration(duration: number): AnimateOptions;
521
+ scrollStartImmediately(startImmediately: boolean): AnimateOptions;
522
+ toQuery(): URLSearchParams;
523
+ }