screenshotone-api-sdk 1.0.33 → 1.0.35

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.
@@ -281,6 +281,10 @@ export declare class TakeOptions {
281
281
  * Sets timeout.
282
282
  */
283
283
  timeout(timeout: number): TakeOptions;
284
+ /**
285
+ * Sets navigation timeout.
286
+ */
287
+ navigationTimeout(timeout: number): TakeOptions;
284
288
  /**
285
289
  * Default value is false. Use store=true to trigger upload of the taken screenshot,
286
290
  * rendered HTML or PDF to the configured S3 bucket.
@@ -506,6 +510,10 @@ export declare class AnimateOptions {
506
510
  * Sets timeout.
507
511
  */
508
512
  timeout(timeout: number): AnimateOptions;
513
+ /**
514
+ * Sets navigation timeout.
515
+ */
516
+ navigationTimeout(timeout: number): AnimateOptions;
509
517
  /**
510
518
  * Default value is false. Use store=true to trigger upload of the taken screenshot,
511
519
  * rendered HTML or PDF to the configured S3 bucket.
package/dist/main.js CHANGED
@@ -105,8 +105,13 @@ class Client {
105
105
  if (response.ok) {
106
106
  return await response.blob();
107
107
  }
108
- const data = await response.json();
109
- throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
108
+ try {
109
+ const data = await response.json();
110
+ throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
111
+ }
112
+ catch (e) {
113
+ throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}`);
114
+ }
110
115
  }
111
116
  /**
112
117
  * Generates an animated screenshot and return the image blob.
@@ -120,8 +125,13 @@ class Client {
120
125
  if (response.ok) {
121
126
  return await response.blob();
122
127
  }
123
- const data = await response.json();
124
- throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
128
+ try {
129
+ const data = await response.json();
130
+ throw new Error(`failed to generate animation, response returned ${response.status} ${response.statusText}: ${data?.message}`);
131
+ }
132
+ catch (e) {
133
+ throw new Error(`failed to generate animation, response returned ${response.status} ${response.statusText}`);
134
+ }
125
135
  }
126
136
  /**
127
137
  * Generates an animated screenshot and return the image blob.
@@ -540,6 +550,13 @@ class TakeOptions {
540
550
  this.put("timeout", timeout.toString());
541
551
  return this;
542
552
  }
553
+ /**
554
+ * Sets navigation timeout.
555
+ */
556
+ navigationTimeout(timeout) {
557
+ this.put("navigation_timeout", timeout.toString());
558
+ return this;
559
+ }
543
560
  /**
544
561
  * Default value is false. Use store=true to trigger upload of the taken screenshot,
545
562
  * rendered HTML or PDF to the configured S3 bucket.
@@ -921,6 +938,13 @@ class AnimateOptions {
921
938
  this.put("timeout", timeout.toString());
922
939
  return this;
923
940
  }
941
+ /**
942
+ * Sets navigation timeout.
943
+ */
944
+ navigationTimeout(timeout) {
945
+ this.put("navigation_timeout", timeout.toString());
946
+ return this;
947
+ }
924
948
  /**
925
949
  * Default value is false. Use store=true to trigger upload of the taken screenshot,
926
950
  * rendered HTML or PDF to the configured S3 bucket.
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.33",
4
+ "version": "1.0.35",
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
@@ -92,9 +92,13 @@ export class Client {
92
92
  return await response.blob()
93
93
  }
94
94
 
95
- const data = await response.json();
95
+ try {
96
+ const data = await response.json();
96
97
 
97
- throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
98
+ throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
99
+ } catch (e) {
100
+ throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}`);
101
+ }
98
102
  }
99
103
 
100
104
  /**
@@ -110,9 +114,13 @@ export class Client {
110
114
  return await response.blob()
111
115
  }
112
116
 
113
- const data = await response.json();
117
+ try {
118
+ const data = await response.json();
114
119
 
115
- throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
120
+ throw new Error(`failed to generate animation, response returned ${response.status} ${response.statusText}: ${data?.message}`);
121
+ } catch (e) {
122
+ throw new Error(`failed to generate animation, response returned ${response.status} ${response.statusText}`);
123
+ }
116
124
  }
117
125
 
118
126
  /**
@@ -643,6 +651,15 @@ export class TakeOptions {
643
651
  return this;
644
652
  }
645
653
 
654
+ /**
655
+ * Sets navigation timeout.
656
+ */
657
+ navigationTimeout(timeout: number): TakeOptions {
658
+ this.put("navigation_timeout", timeout.toString());
659
+
660
+ return this;
661
+ }
662
+
646
663
  /**
647
664
  * Default value is false. Use store=true to trigger upload of the taken screenshot,
648
665
  * rendered HTML or PDF to the configured S3 bucket.
@@ -1119,6 +1136,15 @@ export class AnimateOptions {
1119
1136
  return this;
1120
1137
  }
1121
1138
 
1139
+ /**
1140
+ * Sets navigation timeout.
1141
+ */
1142
+ navigationTimeout(timeout: number): AnimateOptions {
1143
+ this.put("navigation_timeout", timeout.toString());
1144
+
1145
+ return this;
1146
+ }
1147
+
1122
1148
  /**
1123
1149
  * Default value is false. Use store=true to trigger upload of the taken screenshot,
1124
1150
  * rendered HTML or PDF to the configured S3 bucket.