screenshotone-api-sdk 1.0.20 → 1.0.22

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/README.md CHANGED
@@ -43,6 +43,14 @@ fs.writeFileSync("example.png", buffer)
43
43
  // the screenshot is store in the example.png file
44
44
  ```
45
45
 
46
+ ## Build and publish (a manual for SDK developers)
47
+
48
+ To build and publish the SDK:
49
+
50
+ 1. Bump the version property in the `package.json` file.
51
+ 2. Run `npm run prepare`.
52
+ 3. Run `npm publish`.
53
+
46
54
  ## License
47
55
 
48
56
  `screenshotone/jssdk` is released under [the MIT license](LICENSE).
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Represents an API client for the ScreenshotOne.com API.
3
+ */
4
+ export declare class Client {
5
+ private readonly accessKey;
6
+ private readonly secretKey;
7
+ constructor(accessKey: string, secretKey: string);
8
+ generateTakeURL(options: TakeOptions): string;
9
+ take(options: TakeOptions): Promise<Blob>;
10
+ }
11
+ /**
12
+ * Represents options for taking screenshots.
13
+ */
14
+ export declare class TakeOptions {
15
+ private readonly query;
16
+ private constructor();
17
+ /**
18
+ * Initializes take screenshot options with provided website URL.
19
+ */
20
+ static url(url: string): TakeOptions;
21
+ /**
22
+ * Initializes take screenshot options with provided HTML.
23
+ */
24
+ static html(html: string): TakeOptions;
25
+ /**
26
+ * Initializes take screenshot options with provided Markdown.
27
+ */
28
+ static markdown(markdown: string): TakeOptions;
29
+ private put;
30
+ /**
31
+ * Selector is a CSS-like selector of the element to take a screenshot of.
32
+ */
33
+ selector(selector: string): this;
34
+ /**
35
+ * It determines the behavior of what to do when selector is not found.
36
+ */
37
+ errorOnSelectorNotFound(errorOn: boolean): this;
38
+ /**
39
+ * When reduced_motion set to `true`,
40
+ * the API will request the site to minimize the amount of non-essential motion it uses.
41
+ * When the site supports it, it should use animations as least as possible.
42
+ */
43
+ reducedMotion(darkMode: boolean): TakeOptions;
44
+ /**
45
+ * If you want to request the page and it is supported to be rendered for printers, specify `print`.
46
+ * If the page is by default rendered for printers and you want it to be rendered for screens,
47
+ * use `screen`.
48
+ */
49
+ mediaType(mediaType: string): TakeOptions;
50
+ /**
51
+ * Set `true` to request site rendering, if supported, in the dark mode.
52
+ * Set `false` to request site rendering in the light mode if supported.
53
+ * If you don’t set the parameter. The site is rendered in the default mode.
54
+ */
55
+ darkMode(darkMode: boolean): TakeOptions;
56
+ /**
57
+ * The `hide_selectors` option allows hiding elements before taking a screenshot.
58
+ * You can specify as many selectors as you wish.
59
+ * All elements that match each selector will be hidden by
60
+ * setting the `display` style property to none `!important`.
61
+ */
62
+ hideSelectors(...selectors: string[]): TakeOptions;
63
+ /**
64
+ * The scripts_wain_until option allows you to wait until a given
65
+ * set of events after the scripts were executed.
66
+ * It accepts the same values as wait_until and can have multiple values:
67
+ * - `load`: the navigation is successful when the load even is fired;
68
+ * - `domcontentloaded`: the navigation is finished when the DOMContentLoaded even is fired;
69
+ * - `networkidle0`: the navigation is finished when there are no more than 0 network connections for at least 500 ms;
70
+ * _ `networkidle2`: consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
71
+ */
72
+ scriptsWaitUntil(...until: string[]): TakeOptions;
73
+ /**
74
+ * Styles specifies custom CSS styles for the page.
75
+ */
76
+ styles(styles: string): this;
77
+ /**
78
+ * Scripts specifies custom scripts for the page.
79
+ */
80
+ scripts(scripts: string): this;
81
+ /**
82
+ * Renders the full page.
83
+ */
84
+ fullPage(fullPage: boolean): TakeOptions;
85
+ /**
86
+ * Sets response format, one of: "png", "jpeg", "webp" or "jpg".
87
+ */
88
+ format(format: string): TakeOptions;
89
+ /**
90
+ * Renders image with the specified quality. Available for the next formats: "jpeg" ("jpg"), "webp".
91
+ */
92
+ imageQuality(imageQuality: number): TakeOptions;
93
+ /**
94
+ * Renders a transparent background for the image. Works only if the site has not defined background color.
95
+ * Available for the following response formats: "png", "webp".
96
+ */
97
+ omitBackground(omitBackground: boolean): TakeOptions;
98
+ /**
99
+ * Instead of manually specifying viewport parameters like width and height,
100
+ * you can specify a device to use for emulation.
101
+ * In addition, other parameters of the viewport, including the user agent,
102
+ * will be set automatically.
103
+ */
104
+ viewportDevice(viewportDevice: string): TakeOptions;
105
+ /**
106
+ * Sets the width of the browser viewport (pixels).
107
+ */
108
+ viewportWidth(viewportWidth: number): TakeOptions;
109
+ /**
110
+ * Sets the height of the browser viewport (pixels).
111
+ */
112
+ viewportHeight(viewportHeight: number): TakeOptions;
113
+ /**
114
+ * Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
115
+ */
116
+ deviceScaleFactor(deviceScaleFactor: number): TakeOptions;
117
+ /**
118
+ * Whether the meta viewport tag is taken into account. Defaults to `false`.
119
+ */
120
+ viewportMobile(isMobile: boolean): TakeOptions;
121
+ /**
122
+ * The default value is `false`. Set to `true` if the viewport supports touch events.
123
+ */
124
+ viewportHasTouch(hasTouch: boolean): TakeOptions;
125
+ /**
126
+ * The default value is `false`. Set to `true` if the viewport is in landscape mode.
127
+ */
128
+ viewportLandscape(landscape: boolean): TakeOptions;
129
+ /**
130
+ * Sets geolocation latitude for the request.
131
+ * Both latitude and longitude are required if one of them is set.
132
+ */
133
+ geolocationLatitude(latitude: number): TakeOptions;
134
+ /**
135
+ * Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
136
+ */
137
+ geolocationLongitude(longitude: number): TakeOptions;
138
+ /**
139
+ * Sets the geolocation accuracy in meters.
140
+ */
141
+ geolocationAccuracy(accuracy: number): TakeOptions;
142
+ /**
143
+ * Blocks ads.
144
+ */
145
+ blockAds(blockAds: boolean): TakeOptions;
146
+ /**
147
+ * Blocks cookie banners.
148
+ */
149
+ blockCookieBanners(block: boolean): TakeOptions;
150
+ /**
151
+ * Blocks chats.
152
+ */
153
+ blockChats(block: boolean): TakeOptions;
154
+ /**
155
+ * Blocks trackers.
156
+ */
157
+ blockTrackers(blockTrackers: boolean): TakeOptions;
158
+ /**
159
+ * Blocks requests by specifying URL, domain, or even a simple pattern.
160
+ */
161
+ blockRequests(...blockRequests: string[]): TakeOptions;
162
+ /**
163
+ * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",
164
+ * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
165
+ */
166
+ blockResources(...blockResources: string[]): TakeOptions;
167
+ /**
168
+ * Enables caching.
169
+ */
170
+ cache(cache: boolean): TakeOptions;
171
+ /**
172
+ * Sets cache TTL.
173
+ */
174
+ cacheTtl(cacheTTL: number): TakeOptions;
175
+ /**
176
+ * Sets cache key.
177
+ */
178
+ cacheKey(cacheKey: string): TakeOptions;
179
+ /**
180
+ * Sets a user agent for the request.
181
+ */
182
+ userAgent(userAgent: string): TakeOptions;
183
+ /**
184
+ * Sets an authorization header for the request.
185
+ */
186
+ authorization(authorization: string): TakeOptions;
187
+ /**
188
+ * Set cookies for the request.
189
+ */
190
+ cookies(...cookies: string[]): TakeOptions;
191
+ /**
192
+ * Sets extra headers for the request.
193
+ */
194
+ headers(...headers: string[]): this;
195
+ /**
196
+ * TimeZone sets time zone for the request.
197
+ * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
198
+ * "Europe/Madrid", "Pacific/Majuro", "Asia/Kuala_Lumpur", "Pacific/Auckland", "Europe/Lisbon", "Europe/Kiev",
199
+ * "Asia/Tashkent", "Europe/London".
200
+ */
201
+ timeZone(timeZone: string): TakeOptions;
202
+ /**
203
+ * Sets delay.
204
+ */
205
+ delay(delay: number): TakeOptions;
206
+ /**
207
+ * Sets timeout.
208
+ */
209
+ timeout(timeout: number): TakeOptions;
210
+ toQuery(): URLSearchParams;
211
+ }
package/dist/main.js CHANGED
@@ -44,7 +44,6 @@ class Client {
44
44
  const query = options.toQuery();
45
45
  query.append("access_key", this.accessKey);
46
46
  let queryString = query.toString();
47
- console.log(queryString);
48
47
  const signature = crypto.createHmac("sha256", this.secretKey)
49
48
  .update(queryString, 'utf-8')
50
49
  .digest('hex');
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.20",
4
+ "version": "1.0.22",
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
@@ -22,8 +22,6 @@ export class Client {
22
22
  query.append("access_key", this.accessKey);
23
23
  let queryString = query.toString();
24
24
 
25
- console.log(queryString);
26
-
27
25
  const signature = crypto.createHmac("sha256", this.secretKey)
28
26
  .update(queryString, 'utf-8')
29
27
  .digest('hex');