screenshotone-api-sdk 1.0.27 → 1.0.30
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/dist/@types/main.d.ts +16 -0
- package/dist/main.js +48 -0
- package/package.json +1 -1
- package/src/main.ts +66 -0
package/dist/@types/main.d.ts
CHANGED
|
@@ -44,6 +44,16 @@ 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<{
|
|
54
|
+
bucket: string | null;
|
|
55
|
+
key: string | null;
|
|
56
|
+
}>;
|
|
47
57
|
}
|
|
48
58
|
/**
|
|
49
59
|
* Represents options for taking screenshots.
|
|
@@ -191,6 +201,10 @@ export declare class TakeOptions {
|
|
|
191
201
|
* Blocks ads.
|
|
192
202
|
*/
|
|
193
203
|
blockAds(blockAds: boolean): TakeOptions;
|
|
204
|
+
/**
|
|
205
|
+
* Blocks banners by heuristics.
|
|
206
|
+
*/
|
|
207
|
+
blockBannersByHeuristics(block: boolean): TakeOptions;
|
|
194
208
|
/**
|
|
195
209
|
* Blocks cookie banners.
|
|
196
210
|
*/
|
|
@@ -280,6 +294,7 @@ export declare class TakeOptions {
|
|
|
280
294
|
* You can also specify “subdirectories” in the path part.
|
|
281
295
|
*/
|
|
282
296
|
storagePath(path: string): TakeOptions;
|
|
297
|
+
storageACL(acl: string): TakeOptions;
|
|
283
298
|
/**
|
|
284
299
|
* You can override the default bucket you configured with storage_bucket=<bucket name>.
|
|
285
300
|
*/
|
|
@@ -508,6 +523,7 @@ export declare class AnimateOptions {
|
|
|
508
523
|
* Storage class allows you to specify the object storage class.
|
|
509
524
|
*/
|
|
510
525
|
storageClass(storageClass: string): AnimateOptions;
|
|
526
|
+
storageACL(acl: string): AnimateOptions;
|
|
511
527
|
/**
|
|
512
528
|
* Sets animation duration.
|
|
513
529
|
*/
|
package/dist/main.js
CHANGED
|
@@ -123,6 +123,39 @@ 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
|
+
.responseType('empty');
|
|
137
|
+
if (bucket) {
|
|
138
|
+
options.storageBucket(bucket);
|
|
139
|
+
}
|
|
140
|
+
if (acl) {
|
|
141
|
+
options.storageACL(acl);
|
|
142
|
+
}
|
|
143
|
+
if (storageClass) {
|
|
144
|
+
options.storageClass(storageClass);
|
|
145
|
+
}
|
|
146
|
+
const url = (options instanceof TakeOptions)
|
|
147
|
+
? this.generateSignedTakeURL(options)
|
|
148
|
+
: this.generateSignedAnimateURL(options);
|
|
149
|
+
const response = await (0, cross_fetch_1.default)(url);
|
|
150
|
+
if (response.ok) {
|
|
151
|
+
return {
|
|
152
|
+
key: response.headers.get('X-ScreenshotOne-Store-Key'),
|
|
153
|
+
bucket: response.headers.get('X-ScreenshotOne-Store-Bucket'),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const data = await response.json();
|
|
157
|
+
throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
|
|
158
|
+
}
|
|
126
159
|
}
|
|
127
160
|
exports.Client = Client;
|
|
128
161
|
/**
|
|
@@ -368,6 +401,13 @@ class TakeOptions {
|
|
|
368
401
|
this.put("block_ads", blockAds ? "true" : "false");
|
|
369
402
|
return this;
|
|
370
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Blocks banners by heuristics.
|
|
406
|
+
*/
|
|
407
|
+
blockBannersByHeuristics(block) {
|
|
408
|
+
this.put("block_banners_by_heuristics", block ? "true" : "false");
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
371
411
|
/**
|
|
372
412
|
* Blocks cookie banners.
|
|
373
413
|
*/
|
|
@@ -514,6 +554,10 @@ class TakeOptions {
|
|
|
514
554
|
this.put("storage_path", path);
|
|
515
555
|
return this;
|
|
516
556
|
}
|
|
557
|
+
storageACL(acl) {
|
|
558
|
+
this.put("storage_acl", acl);
|
|
559
|
+
return this;
|
|
560
|
+
}
|
|
517
561
|
/**
|
|
518
562
|
* You can override the default bucket you configured with storage_bucket=<bucket name>.
|
|
519
563
|
*/
|
|
@@ -893,6 +937,10 @@ class AnimateOptions {
|
|
|
893
937
|
this.put("storage_class", storageClass);
|
|
894
938
|
return this;
|
|
895
939
|
}
|
|
940
|
+
storageACL(acl) {
|
|
941
|
+
this.put("storage_acl", acl);
|
|
942
|
+
return this;
|
|
943
|
+
}
|
|
896
944
|
/**
|
|
897
945
|
* Sets animation duration.
|
|
898
946
|
*/
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -114,6 +114,51 @@ 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(
|
|
125
|
+
options: AnimateOptions | TakeOptions,
|
|
126
|
+
path: string,
|
|
127
|
+
bucket?: string,
|
|
128
|
+
acl?: "public-read" | "",
|
|
129
|
+
storageClass?: string
|
|
130
|
+
): Promise<{ bucket: string | null, key: string | null }> {
|
|
131
|
+
options
|
|
132
|
+
.store(true)
|
|
133
|
+
.storagePath(path)
|
|
134
|
+
.responseType('empty');
|
|
135
|
+
|
|
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
|
+
|
|
146
|
+
const url = (options instanceof TakeOptions)
|
|
147
|
+
? this.generateSignedTakeURL(options)
|
|
148
|
+
: this.generateSignedAnimateURL(options);
|
|
149
|
+
|
|
150
|
+
const response = await fetch(url);
|
|
151
|
+
if (response.ok) {
|
|
152
|
+
return {
|
|
153
|
+
key: response.headers.get('X-ScreenshotOne-Store-Key'),
|
|
154
|
+
bucket: response.headers.get('X-ScreenshotOne-Store-Bucket'),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const data = await response.json();
|
|
159
|
+
|
|
160
|
+
throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
|
|
161
|
+
}
|
|
117
162
|
}
|
|
118
163
|
|
|
119
164
|
/**
|
|
@@ -422,6 +467,15 @@ export class TakeOptions {
|
|
|
422
467
|
return this;
|
|
423
468
|
}
|
|
424
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Blocks banners by heuristics.
|
|
472
|
+
*/
|
|
473
|
+
blockBannersByHeuristics(block: boolean): TakeOptions {
|
|
474
|
+
this.put("block_banners_by_heuristics", block ? "true" : "false");
|
|
475
|
+
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
|
|
425
479
|
/**
|
|
426
480
|
* Blocks cookie banners.
|
|
427
481
|
*/
|
|
@@ -607,6 +661,12 @@ export class TakeOptions {
|
|
|
607
661
|
return this;
|
|
608
662
|
}
|
|
609
663
|
|
|
664
|
+
storageACL(acl: string): TakeOptions {
|
|
665
|
+
this.put("storage_acl", acl);
|
|
666
|
+
|
|
667
|
+
return this;
|
|
668
|
+
}
|
|
669
|
+
|
|
610
670
|
/**
|
|
611
671
|
* You can override the default bucket you configured with storage_bucket=<bucket name>.
|
|
612
672
|
*/
|
|
@@ -1082,6 +1142,12 @@ export class AnimateOptions {
|
|
|
1082
1142
|
return this;
|
|
1083
1143
|
}
|
|
1084
1144
|
|
|
1145
|
+
storageACL(acl: string): AnimateOptions {
|
|
1146
|
+
this.put("storage_acl", acl);
|
|
1147
|
+
|
|
1148
|
+
return this;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1085
1151
|
/**
|
|
1086
1152
|
* Sets animation duration.
|
|
1087
1153
|
*/
|