screenshotone-api-sdk 1.0.24 → 1.0.26

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.
@@ -42,6 +79,10 @@ export declare class TakeOptions {
42
79
  * It determines the behavior of what to do when selector is not found.
43
80
  */
44
81
  errorOnSelectorNotFound(errorOn: boolean): this;
82
+ /**
83
+ * Capture beyond the viewport.
84
+ */
85
+ captureBeyondViewport(beyond: boolean): this;
45
86
  /**
46
87
  * When reduced_motion set to `true`,
47
88
  * the API will request the site to minimize the amount of non-essential motion it uses.
@@ -237,3 +278,227 @@ export declare class TakeOptions {
237
278
  storageClass(storageClass: string): TakeOptions;
238
279
  toQuery(): URLSearchParams;
239
280
  }
281
+ /**
282
+ * Represents options for animating screenshots.
283
+ */
284
+ export declare class AnimateOptions {
285
+ private readonly query;
286
+ private constructor();
287
+ /**
288
+ * Initializes take screenshot options with provided website URL.
289
+ */
290
+ static url(url: string): AnimateOptions;
291
+ /**
292
+ * Initializes take screenshot options with provided HTML.
293
+ */
294
+ static html(html: string): AnimateOptions;
295
+ /**
296
+ * Initializes take screenshot options with provided Markdown.
297
+ */
298
+ static markdown(markdown: string): AnimateOptions;
299
+ private put;
300
+ /**
301
+ * Available response types:
302
+ * 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;
303
+ * 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.
304
+ * The default value is by_format.
305
+ */
306
+ responseType(responseType: string): this;
307
+ /**
308
+ * When reduced_motion set to `true`,
309
+ * the API will request the site to minimize the amount of non-essential motion it uses.
310
+ * When the site supports it, it should use animations as least as possible.
311
+ */
312
+ reducedMotion(darkMode: boolean): AnimateOptions;
313
+ /**
314
+ * If you want to request the page and it is supported to be rendered for printers, specify `print`.
315
+ * If the page is by default rendered for printers and you want it to be rendered for screens,
316
+ * use `screen`.
317
+ */
318
+ mediaType(mediaType: string): AnimateOptions;
319
+ /**
320
+ * Set `true` to request site rendering, if supported, in the dark mode.
321
+ * Set `false` to request site rendering in the light mode if supported.
322
+ * If you don’t set the parameter. The site is rendered in the default mode.
323
+ */
324
+ darkMode(darkMode: boolean): AnimateOptions;
325
+ /**
326
+ * The `hide_selectors` option allows hiding elements before taking a screenshot.
327
+ * You can specify as many selectors as you wish.
328
+ * All elements that match each selector will be hidden by
329
+ * setting the `display` style property to none `!important`.
330
+ */
331
+ hideSelectors(...selectors: string[]): AnimateOptions;
332
+ /**
333
+ * The scripts_wain_until option allows you to wait until a given
334
+ * set of events after the scripts were executed.
335
+ * It accepts the same values as wait_until and can have multiple values:
336
+ * - `load`: the navigation is successful when the load even is fired;
337
+ * - `domcontentloaded`: the navigation is finished when the DOMContentLoaded even is fired;
338
+ * - `networkidle0`: the navigation is finished when there are no more than 0 network connections for at least 500 ms;
339
+ * _ `networkidle2`: consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
340
+ */
341
+ scriptsWaitUntil(...until: string[]): AnimateOptions;
342
+ /**
343
+ * Styles specifies custom CSS styles for the page.
344
+ */
345
+ styles(styles: string): this;
346
+ /**
347
+ * Scripts specifies custom scripts for the page.
348
+ */
349
+ scripts(scripts: string): this;
350
+ /**
351
+ * Sets response format, one of: "mp4", "avi", "webm", "mov" or "gif".
352
+ */
353
+ format(format: string): AnimateOptions;
354
+ /**
355
+ * Renders a transparent background for the image. Works only if the site has not defined background color.
356
+ * Available for the following response formats: "png", "webp".
357
+ */
358
+ omitBackground(omitBackground: boolean): AnimateOptions;
359
+ /**
360
+ * Instead of manually specifying viewport parameters like width and height,
361
+ * you can specify a device to use for emulation.
362
+ * In addition, other parameters of the viewport, including the user agent,
363
+ * will be set automatically.
364
+ */
365
+ viewportDevice(viewportDevice: string): AnimateOptions;
366
+ /**
367
+ * Sets the width of the browser viewport (pixels).
368
+ */
369
+ viewportWidth(viewportWidth: number): AnimateOptions;
370
+ /**
371
+ * Sets the height of the browser viewport (pixels).
372
+ */
373
+ viewportHeight(viewportHeight: number): AnimateOptions;
374
+ /**
375
+ * Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
376
+ */
377
+ deviceScaleFactor(deviceScaleFactor: number): AnimateOptions;
378
+ /**
379
+ * Whether the meta viewport tag is taken into account. Defaults to `false`.
380
+ */
381
+ viewportMobile(isMobile: boolean): AnimateOptions;
382
+ /**
383
+ * The default value is `false`. Set to `true` if the viewport supports touch events.
384
+ */
385
+ viewportHasTouch(hasTouch: boolean): AnimateOptions;
386
+ /**
387
+ * The default value is `false`. Set to `true` if the viewport is in landscape mode.
388
+ */
389
+ viewportLandscape(landscape: boolean): AnimateOptions;
390
+ /**
391
+ * Sets geolocation latitude for the request.
392
+ * Both latitude and longitude are required if one of them is set.
393
+ */
394
+ geolocationLatitude(latitude: number): AnimateOptions;
395
+ /**
396
+ * Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
397
+ */
398
+ geolocationLongitude(longitude: number): AnimateOptions;
399
+ /**
400
+ * Sets the geolocation accuracy in meters.
401
+ */
402
+ geolocationAccuracy(accuracy: number): AnimateOptions;
403
+ /**
404
+ * Blocks ads.
405
+ */
406
+ blockAds(blockAds: boolean): AnimateOptions;
407
+ /**
408
+ * Blocks cookie banners.
409
+ */
410
+ blockCookieBanners(block: boolean): AnimateOptions;
411
+ /**
412
+ * Blocks chats.
413
+ */
414
+ blockChats(block: boolean): AnimateOptions;
415
+ /**
416
+ * Blocks trackers.
417
+ */
418
+ blockTrackers(blockTrackers: boolean): AnimateOptions;
419
+ /**
420
+ * Blocks requests by specifying URL, domain, or even a simple pattern.
421
+ */
422
+ blockRequests(...blockRequests: string[]): AnimateOptions;
423
+ /**
424
+ * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",
425
+ * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
426
+ */
427
+ blockResources(...blockResources: string[]): AnimateOptions;
428
+ /**
429
+ * Enables caching.
430
+ */
431
+ cache(cache: boolean): AnimateOptions;
432
+ /**
433
+ * Sets cache TTL.
434
+ */
435
+ cacheTtl(cacheTTL: number): AnimateOptions;
436
+ /**
437
+ * Sets cache key.
438
+ */
439
+ cacheKey(cacheKey: string): AnimateOptions;
440
+ /**
441
+ * Sets a user agent for the request.
442
+ */
443
+ userAgent(userAgent: string): AnimateOptions;
444
+ /**
445
+ * Sets an authorization header for the request.
446
+ */
447
+ authorization(authorization: string): AnimateOptions;
448
+ /**
449
+ * Set cookies for the request.
450
+ */
451
+ cookies(...cookies: string[]): AnimateOptions;
452
+ /**
453
+ * Sets extra headers for the request.
454
+ */
455
+ headers(...headers: string[]): this;
456
+ /**
457
+ * TimeZone sets time zone for the request.
458
+ * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
459
+ * "Europe/Madrid", "Pacific/Majuro", "Asia/Kuala_Lumpur", "Pacific/Auckland", "Europe/Lisbon", "Europe/Kiev",
460
+ * "Asia/Tashkent", "Europe/London".
461
+ */
462
+ timeZone(timeZone: string): AnimateOptions;
463
+ /**
464
+ * Sets delay.
465
+ */
466
+ delay(delay: number): AnimateOptions;
467
+ /**
468
+ * Sets timeout.
469
+ */
470
+ timeout(timeout: number): AnimateOptions;
471
+ /**
472
+ * Default value is false. Use store=true to trigger upload of the taken screenshot,
473
+ * rendered HTML or PDF to the configured S3 bucket.
474
+ * Make sure you configured access to S3.
475
+ */
476
+ store(store: boolean): AnimateOptions;
477
+ /**
478
+ * The parameter is required if you set store=true.
479
+ * You must specify the key for the file, but don’t specify an extension,
480
+ * it will be added automatically based on the format you specified.
481
+ * You can also specify “subdirectories” in the path part.
482
+ */
483
+ storagePath(path: string): AnimateOptions;
484
+ /**
485
+ * You can override the default bucket you configured with storage_bucket=<bucket name>.
486
+ */
487
+ storageBucket(bucket: string): AnimateOptions;
488
+ /**
489
+ * Storage class allows you to specify the object storage class.
490
+ */
491
+ storageClass(storageClass: string): AnimateOptions;
492
+ /**
493
+ * Sets animation duration.
494
+ */
495
+ duration(duration: number): AnimateOptions;
496
+ /**
497
+ * Sets animation duration.
498
+ */
499
+ scenario(scenario: string): AnimateOptions;
500
+ scrollDelay(delay: number): AnimateOptions;
501
+ scrollDuration(duration: number): AnimateOptions;
502
+ scrollStartImmediately(startImmediately: boolean): AnimateOptions;
503
+ toQuery(): URLSearchParams;
504
+ }
package/dist/main.js CHANGED
@@ -26,12 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.TakeOptions = exports.Client = void 0;
29
+ exports.AnimateOptions = exports.TakeOptions = exports.Client = void 0;
30
30
  const crypto = __importStar(require("crypto"));
31
31
  const big_js_1 = __importDefault(require("big.js"));
32
32
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
33
33
  const API_BASE_URL = "https://api.screenshotone.com";
34
34
  const API_TAKE_PATH = "/take";
35
+ const API_ANIMATE_PATH = "/animate";
35
36
  /**
36
37
  * Represents an API client for the ScreenshotOne.com API.
37
38
  */
@@ -40,6 +41,14 @@ class Client {
40
41
  this.accessKey = accessKey;
41
42
  this.secretKey = secretKey;
42
43
  }
44
+ /**
45
+ * Generates an URL that can be used to send GET requests for taking screenshots.
46
+ *
47
+ * Warning! Don't share the link publicly generated by this method publicly.
48
+ *
49
+ * @param options Options for taking the screenshot.
50
+ * @returns An URL that will generate the screenshot if requested.
51
+ */
43
52
  generateTakeURL(options) {
44
53
  const query = options.toQuery();
45
54
  query.append("access_key", this.accessKey);
@@ -50,8 +59,63 @@ class Client {
50
59
  queryString += '&signature=' + signature;
51
60
  return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
52
61
  }
62
+ /**
63
+ * Generates the link that can be publicly available, but make sure
64
+ * you read the documentation before at https://screenshotone.com/docs/signed-requests/.
65
+ *
66
+ * @param options
67
+ * @returns A signed URL that will generate the screenshot if requested.
68
+ */
69
+ generateSignedTakeURL(options) {
70
+ const query = options.toQuery();
71
+ query.append("access_key", this.accessKey);
72
+ let queryString = query.toString();
73
+ const signature = crypto.createHmac("sha256", this.secretKey)
74
+ .update(queryString, 'utf-8')
75
+ .digest('hex');
76
+ queryString += '&signature=' + signature;
77
+ return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
78
+ }
79
+ /**
80
+ * Generates the link that can be publicly available, but make sure
81
+ * you read the documentation before at https://screenshotone.com/docs/signed-requests/.
82
+ *
83
+ * @param options
84
+ * @returns A signed URL that will generate the animated screenshot if requested.
85
+ */
86
+ generateSignedAnimateURL(options) {
87
+ const query = options.toQuery();
88
+ query.append("access_key", this.accessKey);
89
+ let queryString = query.toString();
90
+ const signature = crypto.createHmac("sha256", this.secretKey)
91
+ .update(queryString, 'utf-8')
92
+ .digest('hex');
93
+ queryString += '&signature=' + signature;
94
+ return `${API_BASE_URL}${API_ANIMATE_PATH}?${queryString}`;
95
+ }
96
+ /**
97
+ * Generates a screenshot and return the image blob.
98
+ *
99
+ * @param options
100
+ * @returns
101
+ */
53
102
  async take(options) {
54
- const url = this.generateTakeURL(options);
103
+ const url = this.generateSignedTakeURL(options);
104
+ const response = await (0, cross_fetch_1.default)(url);
105
+ if (response.ok) {
106
+ return await response.blob();
107
+ }
108
+ const data = await response.json();
109
+ throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
110
+ }
111
+ /**
112
+ * Generates an animated screenshot and return the image blob.
113
+ *
114
+ * @param options
115
+ * @returns
116
+ */
117
+ async animate(options) {
118
+ const url = this.generateSignedAnimateURL(options);
55
119
  const response = await (0, cross_fetch_1.default)(url);
56
120
  if (response.ok) {
57
121
  return await response.blob();
@@ -123,6 +187,13 @@ class TakeOptions {
123
187
  this.put("error_on_selector_not_found", errorOn ? "true" : "false");
124
188
  return this;
125
189
  }
190
+ /**
191
+ * Capture beyond the viewport.
192
+ */
193
+ captureBeyondViewport(beyond) {
194
+ this.put("capture_beyond_viewport", beyond ? "true" : "false");
195
+ return this;
196
+ }
126
197
  /**
127
198
  * When reduced_motion set to `true`,
128
199
  * the API will request the site to minimize the amount of non-essential motion it uses.
@@ -444,3 +515,384 @@ class TakeOptions {
444
515
  }
445
516
  }
446
517
  exports.TakeOptions = TakeOptions;
518
+ /**
519
+ * Represents options for animating screenshots.
520
+ */
521
+ class AnimateOptions {
522
+ constructor() {
523
+ const query = new URLSearchParams();
524
+ this.query = query;
525
+ }
526
+ /**
527
+ * Initializes take screenshot options with provided website URL.
528
+ */
529
+ static url(url) {
530
+ const options = new AnimateOptions();
531
+ options.put("url", url);
532
+ return options;
533
+ }
534
+ /**
535
+ * Initializes take screenshot options with provided HTML.
536
+ */
537
+ static html(html) {
538
+ const options = new AnimateOptions();
539
+ options.put("html", html);
540
+ return options;
541
+ }
542
+ /**
543
+ * Initializes take screenshot options with provided Markdown.
544
+ */
545
+ static markdown(markdown) {
546
+ const options = new AnimateOptions();
547
+ options.put("markdown", markdown);
548
+ return options;
549
+ }
550
+ put(key, ...values) {
551
+ for (const value of values) {
552
+ this.query.append(key, value);
553
+ }
554
+ }
555
+ ;
556
+ /**
557
+ * Available response types:
558
+ * 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;
559
+ * 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.
560
+ * The default value is by_format.
561
+ */
562
+ responseType(responseType) {
563
+ this.put("response_type", responseType);
564
+ return this;
565
+ }
566
+ /**
567
+ * When reduced_motion set to `true`,
568
+ * the API will request the site to minimize the amount of non-essential motion it uses.
569
+ * When the site supports it, it should use animations as least as possible.
570
+ */
571
+ reducedMotion(darkMode) {
572
+ this.put("reduced_motion", darkMode ? "true" : "false");
573
+ return this;
574
+ }
575
+ /**
576
+ * If you want to request the page and it is supported to be rendered for printers, specify `print`.
577
+ * If the page is by default rendered for printers and you want it to be rendered for screens,
578
+ * use `screen`.
579
+ */
580
+ mediaType(mediaType) {
581
+ this.put("media_type", mediaType);
582
+ return this;
583
+ }
584
+ /**
585
+ * Set `true` to request site rendering, if supported, in the dark mode.
586
+ * Set `false` to request site rendering in the light mode if supported.
587
+ * If you don’t set the parameter. The site is rendered in the default mode.
588
+ */
589
+ darkMode(darkMode) {
590
+ this.put("dark_mode", darkMode ? "true" : "false");
591
+ return this;
592
+ }
593
+ /**
594
+ * The `hide_selectors` option allows hiding elements before taking a screenshot.
595
+ * You can specify as many selectors as you wish.
596
+ * All elements that match each selector will be hidden by
597
+ * setting the `display` style property to none `!important`.
598
+ */
599
+ hideSelectors(...selectors) {
600
+ this.put("hide_selectors", ...selectors);
601
+ return this;
602
+ }
603
+ /**
604
+ * The scripts_wain_until option allows you to wait until a given
605
+ * set of events after the scripts were executed.
606
+ * It accepts the same values as wait_until and can have multiple values:
607
+ * - `load`: the navigation is successful when the load even is fired;
608
+ * - `domcontentloaded`: the navigation is finished when the DOMContentLoaded even is fired;
609
+ * - `networkidle0`: the navigation is finished when there are no more than 0 network connections for at least 500 ms;
610
+ * _ `networkidle2`: consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
611
+ */
612
+ scriptsWaitUntil(...until) {
613
+ this.put("scripts_wait_until", ...until);
614
+ return this;
615
+ }
616
+ /**
617
+ * Styles specifies custom CSS styles for the page.
618
+ */
619
+ styles(styles) {
620
+ this.put("styles", styles);
621
+ return this;
622
+ }
623
+ /**
624
+ * Scripts specifies custom scripts for the page.
625
+ */
626
+ scripts(scripts) {
627
+ this.put("scripts", scripts);
628
+ return this;
629
+ }
630
+ /**
631
+ * Sets response format, one of: "mp4", "avi", "webm", "mov" or "gif".
632
+ */
633
+ format(format) {
634
+ this.put("format", format);
635
+ return this;
636
+ }
637
+ /**
638
+ * Renders a transparent background for the image. Works only if the site has not defined background color.
639
+ * Available for the following response formats: "png", "webp".
640
+ */
641
+ omitBackground(omitBackground) {
642
+ this.put("omit_background", omitBackground ? "true" : "false");
643
+ return this;
644
+ }
645
+ /**
646
+ * Instead of manually specifying viewport parameters like width and height,
647
+ * you can specify a device to use for emulation.
648
+ * In addition, other parameters of the viewport, including the user agent,
649
+ * will be set automatically.
650
+ */
651
+ viewportDevice(viewportDevice) {
652
+ this.put("viewport_device", viewportDevice);
653
+ return this;
654
+ }
655
+ /**
656
+ * Sets the width of the browser viewport (pixels).
657
+ */
658
+ viewportWidth(viewportWidth) {
659
+ this.put("viewport_width", viewportWidth.toString());
660
+ return this;
661
+ }
662
+ /**
663
+ * Sets the height of the browser viewport (pixels).
664
+ */
665
+ viewportHeight(viewportHeight) {
666
+ this.put("viewport_height", viewportHeight.toString());
667
+ return this;
668
+ }
669
+ /**
670
+ * Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
671
+ */
672
+ deviceScaleFactor(deviceScaleFactor) {
673
+ this.put("device_scale_factor", deviceScaleFactor.toString());
674
+ return this;
675
+ }
676
+ /**
677
+ * Whether the meta viewport tag is taken into account. Defaults to `false`.
678
+ */
679
+ viewportMobile(isMobile) {
680
+ this.put("viewport_mobile", isMobile ? "true" : "false");
681
+ return this;
682
+ }
683
+ /**
684
+ * The default value is `false`. Set to `true` if the viewport supports touch events.
685
+ */
686
+ viewportHasTouch(hasTouch) {
687
+ this.put("viewport_has_touch", hasTouch ? "true" : "false");
688
+ return this;
689
+ }
690
+ /**
691
+ * The default value is `false`. Set to `true` if the viewport is in landscape mode.
692
+ */
693
+ viewportLandscape(landscape) {
694
+ this.put("viewport_landscape", landscape ? "true" : "false");
695
+ return this;
696
+ }
697
+ /**
698
+ * Sets geolocation latitude for the request.
699
+ * Both latitude and longitude are required if one of them is set.
700
+ */
701
+ geolocationLatitude(latitude) {
702
+ this.put("geolocation_latitude", new big_js_1.default(latitude).toFixed(20).replace(/0+$/, ""));
703
+ return this;
704
+ }
705
+ /**
706
+ * Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
707
+ */
708
+ geolocationLongitude(longitude) {
709
+ this.put("geolocation_longitude", new big_js_1.default(longitude).toFixed(20).replace(/0+$/, ""));
710
+ return this;
711
+ }
712
+ /**
713
+ * Sets the geolocation accuracy in meters.
714
+ */
715
+ geolocationAccuracy(accuracy) {
716
+ this.put("geolocation_accuracy", accuracy.toString());
717
+ return this;
718
+ }
719
+ /**
720
+ * Blocks ads.
721
+ */
722
+ blockAds(blockAds) {
723
+ this.put("block_ads", blockAds ? "true" : "false");
724
+ return this;
725
+ }
726
+ /**
727
+ * Blocks cookie banners.
728
+ */
729
+ blockCookieBanners(block) {
730
+ this.put("block_cookie_banners", block ? "true" : "false");
731
+ return this;
732
+ }
733
+ /**
734
+ * Blocks chats.
735
+ */
736
+ blockChats(block) {
737
+ this.put("block_chats", block ? "true" : "false");
738
+ return this;
739
+ }
740
+ /**
741
+ * Blocks trackers.
742
+ */
743
+ blockTrackers(blockTrackers) {
744
+ this.put("block_trackers", blockTrackers ? "true" : "false");
745
+ return this;
746
+ }
747
+ /**
748
+ * Blocks requests by specifying URL, domain, or even a simple pattern.
749
+ */
750
+ blockRequests(...blockRequests) {
751
+ this.put("block_requests", ...blockRequests);
752
+ return this;
753
+ }
754
+ /**
755
+ * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",
756
+ * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
757
+ */
758
+ blockResources(...blockResources) {
759
+ this.put("block_resources", ...blockResources);
760
+ return this;
761
+ }
762
+ /**
763
+ * Enables caching.
764
+ */
765
+ cache(cache) {
766
+ this.put("cache", cache ? "true" : "false");
767
+ return this;
768
+ }
769
+ /**
770
+ * Sets cache TTL.
771
+ */
772
+ cacheTtl(cacheTTL) {
773
+ this.put("cache_ttl", cacheTTL.toString());
774
+ return this;
775
+ }
776
+ /**
777
+ * Sets cache key.
778
+ */
779
+ cacheKey(cacheKey) {
780
+ this.put("cache_key", cacheKey);
781
+ return this;
782
+ }
783
+ /**
784
+ * Sets a user agent for the request.
785
+ */
786
+ userAgent(userAgent) {
787
+ this.put("user_agent", userAgent);
788
+ return this;
789
+ }
790
+ /**
791
+ * Sets an authorization header for the request.
792
+ */
793
+ authorization(authorization) {
794
+ this.put("authorization", authorization);
795
+ return this;
796
+ }
797
+ /**
798
+ * Set cookies for the request.
799
+ */
800
+ cookies(...cookies) {
801
+ this.put("cookies", ...cookies);
802
+ return this;
803
+ }
804
+ /**
805
+ * Sets extra headers for the request.
806
+ */
807
+ headers(...headers) {
808
+ this.put("headers", ...headers);
809
+ return this;
810
+ }
811
+ /**
812
+ * TimeZone sets time zone for the request.
813
+ * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
814
+ * "Europe/Madrid", "Pacific/Majuro", "Asia/Kuala_Lumpur", "Pacific/Auckland", "Europe/Lisbon", "Europe/Kiev",
815
+ * "Asia/Tashkent", "Europe/London".
816
+ */
817
+ timeZone(timeZone) {
818
+ this.put("time_zone", timeZone);
819
+ return this;
820
+ }
821
+ /**
822
+ * Sets delay.
823
+ */
824
+ delay(delay) {
825
+ this.put("delay", delay.toString());
826
+ return this;
827
+ }
828
+ /**
829
+ * Sets timeout.
830
+ */
831
+ timeout(timeout) {
832
+ this.put("timeout", timeout.toString());
833
+ return this;
834
+ }
835
+ /**
836
+ * Default value is false. Use store=true to trigger upload of the taken screenshot,
837
+ * rendered HTML or PDF to the configured S3 bucket.
838
+ * Make sure you configured access to S3.
839
+ */
840
+ store(store) {
841
+ this.put("store", store ? "true" : "false");
842
+ return this;
843
+ }
844
+ /**
845
+ * The parameter is required if you set store=true.
846
+ * You must specify the key for the file, but don’t specify an extension,
847
+ * it will be added automatically based on the format you specified.
848
+ * You can also specify “subdirectories” in the path part.
849
+ */
850
+ storagePath(path) {
851
+ this.put("storage_path", path);
852
+ return this;
853
+ }
854
+ /**
855
+ * You can override the default bucket you configured with storage_bucket=<bucket name>.
856
+ */
857
+ storageBucket(bucket) {
858
+ this.put("storage_bucket", bucket);
859
+ return this;
860
+ }
861
+ /**
862
+ * Storage class allows you to specify the object storage class.
863
+ */
864
+ storageClass(storageClass) {
865
+ this.put("storage_class", storageClass);
866
+ return this;
867
+ }
868
+ /**
869
+ * Sets animation duration.
870
+ */
871
+ duration(duration) {
872
+ this.put("duration", duration.toString());
873
+ return this;
874
+ }
875
+ /**
876
+ * Sets animation duration.
877
+ */
878
+ scenario(scenario) {
879
+ this.put("scenario", scenario);
880
+ return this;
881
+ }
882
+ scrollDelay(delay) {
883
+ this.put("scroll_delay", delay.toString());
884
+ return this;
885
+ }
886
+ scrollDuration(duration) {
887
+ this.put("scroll_duration", duration.toString());
888
+ return this;
889
+ }
890
+ scrollStartImmediately(startImmediately) {
891
+ this.put("scroll_start_immediately", startImmediately ? "true" : "false");
892
+ return this;
893
+ }
894
+ toQuery() {
895
+ return new URLSearchParams(this.query.toString());
896
+ }
897
+ }
898
+ exports.AnimateOptions = AnimateOptions;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "screenshotone-api-sdk",
3
3
  "homepage": "https://screenshotone.com",
4
- "version": "1.0.24",
4
+ "version": "1.0.26",
5
5
  "description": "Use ScreenshotOne.com API to generate screenshots of any website.",
6
6
  "repository": {
7
7
  "type": "git",
package/src/main.ts CHANGED
@@ -4,6 +4,7 @@ import fetch from 'cross-fetch';
4
4
 
5
5
  const API_BASE_URL = "https://api.screenshotone.com";
6
6
  const API_TAKE_PATH = "/take";
7
+ const API_ANIMATE_PATH = "/animate";
7
8
 
8
9
  /**
9
10
  * Represents an API client for the ScreenshotOne.com API.
@@ -17,6 +18,14 @@ export class Client {
17
18
  this.secretKey = secretKey;
18
19
  }
19
20
 
21
+ /**
22
+ * Generates an URL that can be used to send GET requests for taking screenshots.
23
+ *
24
+ * Warning! Don't share the link publicly generated by this method publicly.
25
+ *
26
+ * @param options Options for taking the screenshot.
27
+ * @returns An URL that will generate the screenshot if requested.
28
+ */
20
29
  generateTakeURL(options: TakeOptions): string {
21
30
  const query = options.toQuery();
22
31
  query.append("access_key", this.accessKey);
@@ -30,8 +39,72 @@ export class Client {
30
39
  return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
31
40
  }
32
41
 
42
+ /**
43
+ * Generates the link that can be publicly available, but make sure
44
+ * you read the documentation before at https://screenshotone.com/docs/signed-requests/.
45
+ *
46
+ * @param options
47
+ * @returns A signed URL that will generate the screenshot if requested.
48
+ */
49
+ generateSignedTakeURL(options: TakeOptions): string {
50
+ const query = options.toQuery();
51
+ query.append("access_key", this.accessKey);
52
+ let queryString = query.toString();
53
+
54
+ const signature = crypto.createHmac("sha256", this.secretKey)
55
+ .update(queryString, 'utf-8')
56
+ .digest('hex');
57
+ queryString += '&signature=' + signature;
58
+
59
+ return `${API_BASE_URL}${API_TAKE_PATH}?${queryString}`;
60
+ }
61
+
62
+ /**
63
+ * Generates the link that can be publicly available, but make sure
64
+ * you read the documentation before at https://screenshotone.com/docs/signed-requests/.
65
+ *
66
+ * @param options
67
+ * @returns A signed URL that will generate the animated screenshot if requested.
68
+ */
69
+ generateSignedAnimateURL(options: AnimateOptions): string {
70
+ const query = options.toQuery();
71
+ query.append("access_key", this.accessKey);
72
+ let queryString = query.toString();
73
+
74
+ const signature = crypto.createHmac("sha256", this.secretKey)
75
+ .update(queryString, 'utf-8')
76
+ .digest('hex');
77
+ queryString += '&signature=' + signature;
78
+
79
+ return `${API_BASE_URL}${API_ANIMATE_PATH}?${queryString}`;
80
+ }
81
+
82
+ /**
83
+ * Generates a screenshot and return the image blob.
84
+ *
85
+ * @param options
86
+ * @returns
87
+ */
33
88
  async take(options: TakeOptions): Promise<Blob> {
34
- const url = this.generateTakeURL(options);
89
+ const url = this.generateSignedTakeURL(options);
90
+ const response = await fetch(url);
91
+ if (response.ok) {
92
+ return await response.blob()
93
+ }
94
+
95
+ const data = await response.json();
96
+
97
+ throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
98
+ }
99
+
100
+ /**
101
+ * Generates an animated screenshot and return the image blob.
102
+ *
103
+ * @param options
104
+ * @returns
105
+ */
106
+ async animate(options: AnimateOptions): Promise<Blob> {
107
+ const url = this.generateSignedAnimateURL(options);
35
108
  const response = await fetch(url);
36
109
  if (response.ok) {
37
110
  return await response.blob()
@@ -121,6 +194,15 @@ export class TakeOptions {
121
194
  return this;
122
195
  }
123
196
 
197
+ /**
198
+ * Capture beyond the viewport.
199
+ */
200
+ captureBeyondViewport(beyond: boolean) {
201
+ this.put("capture_beyond_viewport", beyond ? "true" : "false");
202
+
203
+ return this;
204
+ }
205
+
124
206
  /**
125
207
  * When reduced_motion set to `true`,
126
208
  * the API will request the site to minimize the amount of non-essential motion it uses.
@@ -520,6 +602,486 @@ export class TakeOptions {
520
602
  return this;
521
603
  }
522
604
 
605
+ toQuery(): URLSearchParams {
606
+ return new URLSearchParams(this.query.toString());
607
+ }
608
+ }
609
+
610
+ /**
611
+ * Represents options for animating screenshots.
612
+ */
613
+ export class AnimateOptions {
614
+ private readonly query: URLSearchParams;
615
+
616
+ private constructor() {
617
+ const query = new URLSearchParams();
618
+
619
+ this.query = query;
620
+ }
621
+
622
+ /**
623
+ * Initializes take screenshot options with provided website URL.
624
+ */
625
+ static url(url: string): AnimateOptions {
626
+ const options = new AnimateOptions();
627
+ options.put("url", url);
628
+
629
+ return options;
630
+ }
631
+
632
+ /**
633
+ * Initializes take screenshot options with provided HTML.
634
+ */
635
+ static html(html: string): AnimateOptions {
636
+ const options = new AnimateOptions();
637
+ options.put("html", html);
638
+
639
+ return options;
640
+ }
641
+
642
+ /**
643
+ * Initializes take screenshot options with provided Markdown.
644
+ */
645
+ static markdown(markdown: string): AnimateOptions {
646
+ const options = new AnimateOptions();
647
+ options.put("markdown", markdown);
648
+
649
+ return options;
650
+ }
651
+
652
+ private put(key: string, ...values: string[]) {
653
+ for (const value of values) {
654
+ this.query.append(key, value);
655
+ }
656
+ };
657
+
658
+ /**
659
+ * Available response types:
660
+ * 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;
661
+ * 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.
662
+ * The default value is by_format.
663
+ */
664
+ responseType(responseType: string) {
665
+ this.put("response_type", responseType);
666
+
667
+ return this;
668
+ }
669
+
670
+ /**
671
+ * When reduced_motion set to `true`,
672
+ * the API will request the site to minimize the amount of non-essential motion it uses.
673
+ * When the site supports it, it should use animations as least as possible.
674
+ */
675
+ reducedMotion(darkMode: boolean): AnimateOptions {
676
+ this.put("reduced_motion", darkMode ? "true" : "false");
677
+
678
+ return this;
679
+ }
680
+
681
+ /**
682
+ * If you want to request the page and it is supported to be rendered for printers, specify `print`.
683
+ * If the page is by default rendered for printers and you want it to be rendered for screens,
684
+ * use `screen`.
685
+ */
686
+ mediaType(mediaType: string): AnimateOptions {
687
+ this.put("media_type", mediaType);
688
+
689
+ return this;
690
+ }
691
+
692
+ /**
693
+ * Set `true` to request site rendering, if supported, in the dark mode.
694
+ * Set `false` to request site rendering in the light mode if supported.
695
+ * If you don’t set the parameter. The site is rendered in the default mode.
696
+ */
697
+ darkMode(darkMode: boolean): AnimateOptions {
698
+ this.put("dark_mode", darkMode ? "true" : "false");
699
+
700
+ return this;
701
+ }
702
+
703
+ /**
704
+ * The `hide_selectors` option allows hiding elements before taking a screenshot.
705
+ * You can specify as many selectors as you wish.
706
+ * All elements that match each selector will be hidden by
707
+ * setting the `display` style property to none `!important`.
708
+ */
709
+ hideSelectors(...selectors: string[]): AnimateOptions {
710
+ this.put("hide_selectors", ...selectors);
711
+
712
+ return this;
713
+ }
714
+
715
+ /**
716
+ * The scripts_wain_until option allows you to wait until a given
717
+ * set of events after the scripts were executed.
718
+ * It accepts the same values as wait_until and can have multiple values:
719
+ * - `load`: the navigation is successful when the load even is fired;
720
+ * - `domcontentloaded`: the navigation is finished when the DOMContentLoaded even is fired;
721
+ * - `networkidle0`: the navigation is finished when there are no more than 0 network connections for at least 500 ms;
722
+ * _ `networkidle2`: consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
723
+ */
724
+ scriptsWaitUntil(...until: string[]): AnimateOptions {
725
+ this.put("scripts_wait_until", ...until);
726
+
727
+ return this;
728
+ }
729
+
730
+ /**
731
+ * Styles specifies custom CSS styles for the page.
732
+ */
733
+ styles(styles: string) {
734
+ this.put("styles", styles);
735
+
736
+ return this;
737
+ }
738
+
739
+ /**
740
+ * Scripts specifies custom scripts for the page.
741
+ */
742
+ scripts(scripts: string) {
743
+ this.put("scripts", scripts);
744
+
745
+ return this;
746
+ }
747
+
748
+ /**
749
+ * Sets response format, one of: "mp4", "avi", "webm", "mov" or "gif".
750
+ */
751
+ format(format: string): AnimateOptions {
752
+ this.put("format", format);
753
+
754
+ return this;
755
+ }
756
+
757
+ /**
758
+ * Renders a transparent background for the image. Works only if the site has not defined background color.
759
+ * Available for the following response formats: "png", "webp".
760
+ */
761
+ omitBackground(omitBackground: boolean): AnimateOptions {
762
+ this.put("omit_background", omitBackground ? "true" : "false");
763
+
764
+ return this;
765
+ }
766
+
767
+ /**
768
+ * Instead of manually specifying viewport parameters like width and height,
769
+ * you can specify a device to use for emulation.
770
+ * In addition, other parameters of the viewport, including the user agent,
771
+ * will be set automatically.
772
+ */
773
+ viewportDevice(viewportDevice: string): AnimateOptions {
774
+ this.put("viewport_device", viewportDevice);
775
+
776
+ return this;
777
+ }
778
+
779
+ /**
780
+ * Sets the width of the browser viewport (pixels).
781
+ */
782
+ viewportWidth(viewportWidth: number): AnimateOptions {
783
+ this.put("viewport_width", viewportWidth.toString());
784
+
785
+ return this;
786
+ }
787
+
788
+ /**
789
+ * Sets the height of the browser viewport (pixels).
790
+ */
791
+ viewportHeight(viewportHeight: number): AnimateOptions {
792
+ this.put("viewport_height", viewportHeight.toString());
793
+
794
+ return this;
795
+ }
796
+
797
+ /**
798
+ * Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
799
+ */
800
+ deviceScaleFactor(deviceScaleFactor: number): AnimateOptions {
801
+ this.put("device_scale_factor", deviceScaleFactor.toString());
802
+
803
+ return this;
804
+ }
805
+
806
+ /**
807
+ * Whether the meta viewport tag is taken into account. Defaults to `false`.
808
+ */
809
+ viewportMobile(isMobile: boolean): AnimateOptions {
810
+ this.put("viewport_mobile", isMobile ? "true" : "false");
811
+
812
+ return this;
813
+ }
814
+
815
+ /**
816
+ * The default value is `false`. Set to `true` if the viewport supports touch events.
817
+ */
818
+ viewportHasTouch(hasTouch: boolean): AnimateOptions {
819
+ this.put("viewport_has_touch", hasTouch ? "true" : "false");
820
+
821
+ return this;
822
+ }
823
+
824
+ /**
825
+ * The default value is `false`. Set to `true` if the viewport is in landscape mode.
826
+ */
827
+ viewportLandscape(landscape: boolean): AnimateOptions {
828
+ this.put("viewport_landscape", landscape ? "true" : "false");
829
+
830
+ return this;
831
+ }
832
+
833
+ /**
834
+ * Sets geolocation latitude for the request.
835
+ * Both latitude and longitude are required if one of them is set.
836
+ */
837
+ geolocationLatitude(latitude: number): AnimateOptions {
838
+ this.put("geolocation_latitude", new Big(latitude).toFixed(20).replace(/0+$/, ""));
839
+
840
+ return this;
841
+ }
842
+
843
+ /**
844
+ * Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
845
+ */
846
+ geolocationLongitude(longitude: number): AnimateOptions {
847
+ this.put("geolocation_longitude", new Big(longitude).toFixed(20).replace(/0+$/, ""));
848
+
849
+ return this;
850
+ }
851
+
852
+ /**
853
+ * Sets the geolocation accuracy in meters.
854
+ */
855
+ geolocationAccuracy(accuracy: number): AnimateOptions {
856
+ this.put("geolocation_accuracy", accuracy.toString());
857
+
858
+ return this;
859
+ }
860
+
861
+ /**
862
+ * Blocks ads.
863
+ */
864
+ blockAds(blockAds: boolean): AnimateOptions {
865
+ this.put("block_ads", blockAds ? "true" : "false");
866
+
867
+ return this;
868
+ }
869
+
870
+ /**
871
+ * Blocks cookie banners.
872
+ */
873
+ blockCookieBanners(block: boolean): AnimateOptions {
874
+ this.put("block_cookie_banners", block ? "true" : "false");
875
+
876
+ return this;
877
+ }
878
+
879
+ /**
880
+ * Blocks chats.
881
+ */
882
+ blockChats(block: boolean): AnimateOptions {
883
+ this.put("block_chats", block ? "true" : "false");
884
+
885
+ return this;
886
+ }
887
+
888
+ /**
889
+ * Blocks trackers.
890
+ */
891
+ blockTrackers(blockTrackers: boolean): AnimateOptions {
892
+ this.put("block_trackers", blockTrackers ? "true" : "false");
893
+
894
+ return this;
895
+ }
896
+
897
+ /**
898
+ * Blocks requests by specifying URL, domain, or even a simple pattern.
899
+ */
900
+ blockRequests(...blockRequests: string[]): AnimateOptions {
901
+ this.put("block_requests", ...blockRequests);
902
+
903
+ return this;
904
+ }
905
+
906
+ /**
907
+ * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",
908
+ * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
909
+ */
910
+ blockResources(...blockResources: string[]): AnimateOptions {
911
+ this.put("block_resources", ...blockResources);
912
+
913
+ return this;
914
+ }
915
+
916
+ /**
917
+ * Enables caching.
918
+ */
919
+ cache(cache: boolean): AnimateOptions {
920
+ this.put("cache", cache ? "true" : "false");
921
+
922
+ return this;
923
+ }
924
+
925
+ /**
926
+ * Sets cache TTL.
927
+ */
928
+ cacheTtl(cacheTTL: number): AnimateOptions {
929
+ this.put("cache_ttl", cacheTTL.toString());
930
+
931
+ return this;
932
+ }
933
+
934
+ /**
935
+ * Sets cache key.
936
+ */
937
+ cacheKey(cacheKey: string): AnimateOptions {
938
+ this.put("cache_key", cacheKey);
939
+
940
+ return this;
941
+ }
942
+
943
+ /**
944
+ * Sets a user agent for the request.
945
+ */
946
+ userAgent(userAgent: string): AnimateOptions {
947
+ this.put("user_agent", userAgent);
948
+
949
+ return this;
950
+ }
951
+
952
+ /**
953
+ * Sets an authorization header for the request.
954
+ */
955
+ authorization(authorization: string): AnimateOptions {
956
+ this.put("authorization", authorization);
957
+
958
+ return this;
959
+ }
960
+
961
+ /**
962
+ * Set cookies for the request.
963
+ */
964
+ cookies(...cookies: string[]): AnimateOptions {
965
+ this.put("cookies", ...cookies);
966
+
967
+ return this;
968
+ }
969
+
970
+ /**
971
+ * Sets extra headers for the request.
972
+ */
973
+ headers(...headers: string[]) {
974
+ this.put("headers", ...headers);
975
+
976
+ return this;
977
+ }
978
+
979
+ /**
980
+ * TimeZone sets time zone for the request.
981
+ * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
982
+ * "Europe/Madrid", "Pacific/Majuro", "Asia/Kuala_Lumpur", "Pacific/Auckland", "Europe/Lisbon", "Europe/Kiev",
983
+ * "Asia/Tashkent", "Europe/London".
984
+ */
985
+ timeZone(timeZone: string): AnimateOptions {
986
+ this.put("time_zone", timeZone);
987
+
988
+ return this;
989
+ }
990
+
991
+ /**
992
+ * Sets delay.
993
+ */
994
+ delay(delay: number): AnimateOptions {
995
+ this.put("delay", delay.toString());
996
+
997
+ return this;
998
+ }
999
+
1000
+ /**
1001
+ * Sets timeout.
1002
+ */
1003
+ timeout(timeout: number): AnimateOptions {
1004
+ this.put("timeout", timeout.toString());
1005
+
1006
+ return this;
1007
+ }
1008
+
1009
+ /**
1010
+ * Default value is false. Use store=true to trigger upload of the taken screenshot,
1011
+ * rendered HTML or PDF to the configured S3 bucket.
1012
+ * Make sure you configured access to S3.
1013
+ */
1014
+ store(store: boolean): AnimateOptions {
1015
+ this.put("store", store ? "true" : "false");
1016
+
1017
+ return this;
1018
+ }
1019
+
1020
+ /**
1021
+ * The parameter is required if you set store=true.
1022
+ * You must specify the key for the file, but don’t specify an extension,
1023
+ * it will be added automatically based on the format you specified.
1024
+ * You can also specify “subdirectories” in the path part.
1025
+ */
1026
+ storagePath(path: string): AnimateOptions {
1027
+ this.put("storage_path", path);
1028
+
1029
+ return this;
1030
+ }
1031
+
1032
+ /**
1033
+ * You can override the default bucket you configured with storage_bucket=<bucket name>.
1034
+ */
1035
+ storageBucket(bucket: string): AnimateOptions {
1036
+ this.put("storage_bucket", bucket);
1037
+
1038
+ return this;
1039
+ }
1040
+
1041
+ /**
1042
+ * Storage class allows you to specify the object storage class.
1043
+ */
1044
+ storageClass(storageClass: string): AnimateOptions {
1045
+ this.put("storage_class", storageClass);
1046
+
1047
+ return this;
1048
+ }
1049
+
1050
+ /**
1051
+ * Sets animation duration.
1052
+ */
1053
+ duration(duration: number): AnimateOptions {
1054
+ this.put("duration", duration.toString());
1055
+
1056
+ return this;
1057
+ }
1058
+
1059
+ /**
1060
+ * Sets animation duration.
1061
+ */
1062
+ scenario(scenario: string): AnimateOptions {
1063
+ this.put("scenario", scenario);
1064
+
1065
+ return this;
1066
+ }
1067
+
1068
+ scrollDelay(delay: number): AnimateOptions {
1069
+ this.put("scroll_delay", delay.toString());
1070
+
1071
+ return this;
1072
+ }
1073
+
1074
+ scrollDuration(duration: number): AnimateOptions {
1075
+ this.put("scroll_duration", duration.toString());
1076
+
1077
+ return this;
1078
+ }
1079
+
1080
+ scrollStartImmediately(startImmediately: boolean): AnimateOptions {
1081
+ this.put("scroll_start_immediately", startImmediately ? "true" : "false");
1082
+ return this;
1083
+ }
1084
+
523
1085
  toQuery(): URLSearchParams {
524
1086
  return new URLSearchParams(this.query.toString());
525
1087
  }