screenshotone-api-sdk 1.0.26 → 1.0.29

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.
@@ -44,6 +44,13 @@ export declare class Client {
44
44
  * @returns
45
45
  */
46
46
  animate(options: AnimateOptions): Promise<Blob>;
47
+ /**
48
+ * Generates an animated screenshot and return the image blob.
49
+ *
50
+ * @param options
51
+ * @returns
52
+ */
53
+ store(options: AnimateOptions | TakeOptions, path: string, bucket?: string, acl?: "public-read" | "", storageClass?: string): Promise<void>;
47
54
  }
48
55
  /**
49
56
  * Represents options for taking screenshots.
@@ -191,6 +198,10 @@ export declare class TakeOptions {
191
198
  * Blocks ads.
192
199
  */
193
200
  blockAds(blockAds: boolean): TakeOptions;
201
+ /**
202
+ * Blocks banners by heuristics.
203
+ */
204
+ blockBannersByHeuristics(block: boolean): TakeOptions;
194
205
  /**
195
206
  * Blocks cookie banners.
196
207
  */
@@ -232,6 +243,18 @@ export declare class TakeOptions {
232
243
  * Sets an authorization header for the request.
233
244
  */
234
245
  authorization(authorization: string): TakeOptions;
246
+ /**
247
+ * It scrolls the page if needed and ensures that the given
248
+ * selector is present in the view when taking a screenshot.
249
+ */
250
+ scrollIntoView(selector: string): TakeOptions;
251
+ /**
252
+ * You can use your custom proxy to take screenshots
253
+ * or render HTML with the proxy option.
254
+ *
255
+ * The https, http, socks4 and socks5 proxies are supported.
256
+ */
257
+ proxy(proxy: string): TakeOptions;
235
258
  /**
236
259
  * Set cookies for the request.
237
260
  */
@@ -268,6 +291,7 @@ export declare class TakeOptions {
268
291
  * You can also specify “subdirectories” in the path part.
269
292
  */
270
293
  storagePath(path: string): TakeOptions;
294
+ storageACL(acl: string): TakeOptions;
271
295
  /**
272
296
  * You can override the default bucket you configured with storage_bucket=<bucket name>.
273
297
  */
@@ -343,6 +367,13 @@ export declare class AnimateOptions {
343
367
  * Styles specifies custom CSS styles for the page.
344
368
  */
345
369
  styles(styles: string): this;
370
+ /**
371
+ * You can use your custom proxy to take screenshots
372
+ * or render HTML with the proxy option.
373
+ *
374
+ * The https, http, socks4 and socks5 proxies are supported.
375
+ */
376
+ proxy(proxy: string): AnimateOptions;
346
377
  /**
347
378
  * Scripts specifies custom scripts for the page.
348
379
  */
@@ -489,6 +520,7 @@ export declare class AnimateOptions {
489
520
  * Storage class allows you to specify the object storage class.
490
521
  */
491
522
  storageClass(storageClass: string): AnimateOptions;
523
+ storageACL(acl: string): AnimateOptions;
492
524
  /**
493
525
  * Sets animation duration.
494
526
  */
package/dist/main.js CHANGED
@@ -123,6 +123,29 @@ class Client {
123
123
  const data = await response.json();
124
124
  throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
125
125
  }
126
+ /**
127
+ * Generates an animated screenshot and return the image blob.
128
+ *
129
+ * @param options
130
+ * @returns
131
+ */
132
+ async store(options, path, bucket, acl, storageClass) {
133
+ options
134
+ .store(true)
135
+ .storagePath(path);
136
+ if (bucket) {
137
+ options.storageBucket(bucket);
138
+ }
139
+ if (acl) {
140
+ options.storageACL(acl);
141
+ }
142
+ if (storageClass) {
143
+ options.storageClass(storageClass);
144
+ }
145
+ const url = (options instanceof TakeOptions)
146
+ ? this.generateSignedTakeURL(options)
147
+ : this.generateSignedAnimateURL(options);
148
+ }
126
149
  }
127
150
  exports.Client = Client;
128
151
  /**
@@ -368,6 +391,13 @@ class TakeOptions {
368
391
  this.put("block_ads", blockAds ? "true" : "false");
369
392
  return this;
370
393
  }
394
+ /**
395
+ * Blocks banners by heuristics.
396
+ */
397
+ blockBannersByHeuristics(block) {
398
+ this.put("block_banners_by_heuristics", block ? "true" : "false");
399
+ return this;
400
+ }
371
401
  /**
372
402
  * Blocks cookie banners.
373
403
  */
@@ -439,6 +469,24 @@ class TakeOptions {
439
469
  this.put("authorization", authorization);
440
470
  return this;
441
471
  }
472
+ /**
473
+ * It scrolls the page if needed and ensures that the given
474
+ * selector is present in the view when taking a screenshot.
475
+ */
476
+ scrollIntoView(selector) {
477
+ this.put("scroll_into_view", selector);
478
+ return this;
479
+ }
480
+ /**
481
+ * You can use your custom proxy to take screenshots
482
+ * or render HTML with the proxy option.
483
+ *
484
+ * The https, http, socks4 and socks5 proxies are supported.
485
+ */
486
+ proxy(proxy) {
487
+ this.put("proxy", proxy);
488
+ return this;
489
+ }
442
490
  /**
443
491
  * Set cookies for the request.
444
492
  */
@@ -496,6 +544,10 @@ class TakeOptions {
496
544
  this.put("storage_path", path);
497
545
  return this;
498
546
  }
547
+ storageACL(acl) {
548
+ this.put("storage_acl", acl);
549
+ return this;
550
+ }
499
551
  /**
500
552
  * You can override the default bucket you configured with storage_bucket=<bucket name>.
501
553
  */
@@ -620,6 +672,16 @@ class AnimateOptions {
620
672
  this.put("styles", styles);
621
673
  return this;
622
674
  }
675
+ /**
676
+ * You can use your custom proxy to take screenshots
677
+ * or render HTML with the proxy option.
678
+ *
679
+ * The https, http, socks4 and socks5 proxies are supported.
680
+ */
681
+ proxy(proxy) {
682
+ this.put("proxy", proxy);
683
+ return this;
684
+ }
623
685
  /**
624
686
  * Scripts specifies custom scripts for the page.
625
687
  */
@@ -865,6 +927,10 @@ class AnimateOptions {
865
927
  this.put("storage_class", storageClass);
866
928
  return this;
867
929
  }
930
+ storageACL(acl) {
931
+ this.put("storage_acl", acl);
932
+ return this;
933
+ }
868
934
  /**
869
935
  * Sets animation duration.
870
936
  */
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.26",
4
+ "version": "1.0.29",
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
@@ -114,6 +114,32 @@ export class Client {
114
114
 
115
115
  throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
116
116
  }
117
+
118
+ /**
119
+ * Generates an animated screenshot and return the image blob.
120
+ *
121
+ * @param options
122
+ * @returns
123
+ */
124
+ async store(options: AnimateOptions | TakeOptions, path: string, bucket?: string, acl?: "public-read" | "", storageClass?: string) {
125
+ options
126
+ .store(true)
127
+ .storagePath(path);
128
+
129
+ if (bucket) {
130
+ options.storageBucket(bucket);
131
+ }
132
+ if (acl) {
133
+ options.storageACL(acl);
134
+ }
135
+ if (storageClass) {
136
+ options.storageClass(storageClass)
137
+ }
138
+
139
+ const url = (options instanceof TakeOptions)
140
+ ? this.generateSignedTakeURL(options)
141
+ : this.generateSignedAnimateURL(options);
142
+ }
117
143
  }
118
144
 
119
145
  /**
@@ -422,6 +448,15 @@ export class TakeOptions {
422
448
  return this;
423
449
  }
424
450
 
451
+ /**
452
+ * Blocks banners by heuristics.
453
+ */
454
+ blockBannersByHeuristics(block: boolean): TakeOptions {
455
+ this.put("block_banners_by_heuristics", block ? "true" : "false");
456
+
457
+ return this;
458
+ }
459
+
425
460
  /**
426
461
  * Blocks cookie banners.
427
462
  */
@@ -513,6 +548,28 @@ export class TakeOptions {
513
548
  return this;
514
549
  }
515
550
 
551
+ /**
552
+ * It scrolls the page if needed and ensures that the given
553
+ * selector is present in the view when taking a screenshot.
554
+ */
555
+ scrollIntoView(selector: string): TakeOptions {
556
+ this.put("scroll_into_view", selector);
557
+
558
+ return this;
559
+ }
560
+
561
+ /**
562
+ * You can use your custom proxy to take screenshots
563
+ * or render HTML with the proxy option.
564
+ *
565
+ * The https, http, socks4 and socks5 proxies are supported.
566
+ */
567
+ proxy(proxy: string): TakeOptions {
568
+ this.put("proxy", proxy);
569
+
570
+ return this;
571
+ }
572
+
516
573
  /**
517
574
  * Set cookies for the request.
518
575
  */
@@ -531,6 +588,7 @@ export class TakeOptions {
531
588
  return this;
532
589
  }
533
590
 
591
+
534
592
  /**
535
593
  * TimeZone sets time zone for the request.
536
594
  * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
@@ -584,6 +642,12 @@ export class TakeOptions {
584
642
  return this;
585
643
  }
586
644
 
645
+ storageACL(acl: string): TakeOptions {
646
+ this.put("storage_acl", acl);
647
+
648
+ return this;
649
+ }
650
+
587
651
  /**
588
652
  * You can override the default bucket you configured with storage_bucket=<bucket name>.
589
653
  */
@@ -736,6 +800,18 @@ export class AnimateOptions {
736
800
  return this;
737
801
  }
738
802
 
803
+ /**
804
+ * You can use your custom proxy to take screenshots
805
+ * or render HTML with the proxy option.
806
+ *
807
+ * The https, http, socks4 and socks5 proxies are supported.
808
+ */
809
+ proxy(proxy: string): AnimateOptions {
810
+ this.put("proxy", proxy);
811
+
812
+ return this;
813
+ }
814
+
739
815
  /**
740
816
  * Scripts specifies custom scripts for the page.
741
817
  */
@@ -1047,6 +1123,12 @@ export class AnimateOptions {
1047
1123
  return this;
1048
1124
  }
1049
1125
 
1126
+ storageACL(acl: string): AnimateOptions {
1127
+ this.put("storage_acl", acl);
1128
+
1129
+ return this;
1130
+ }
1131
+
1050
1132
  /**
1051
1133
  * Sets animation duration.
1052
1134
  */