@rendshot/sdk 0.1.0

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.
@@ -0,0 +1,14 @@
1
+ import type { RendshotClientConfig, RenderImageOptions, ScreenshotUrlOptions, ImageResult, ImageMetadata, UsageResult } from './types.js';
2
+ export declare class RendshotClient {
3
+ private baseUrl;
4
+ private apiKey;
5
+ constructor(config: RendshotClientConfig);
6
+ renderImage(options: RenderImageOptions): Promise<ImageResult>;
7
+ screenshotUrl(options: ScreenshotUrlOptions): Promise<ImageResult>;
8
+ getUsage(): Promise<UsageResult>;
9
+ getImage(imageId: string): Promise<ImageMetadata>;
10
+ private post;
11
+ private get;
12
+ private handleResponse;
13
+ }
14
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAA;AAEnB,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,MAAM,CAAQ;gBAEV,MAAM,EAAE,oBAAoB;IAKlC,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAI9D,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAIlE,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAIhC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YAIzC,IAAI;YAaJ,GAAG;YAUH,cAAc;CAoB7B"}
package/dist/client.js ADDED
@@ -0,0 +1,61 @@
1
+ import { RendshotError } from './errors.js';
2
+ import { VERSION } from './version.js';
3
+ export class RendshotClient {
4
+ baseUrl;
5
+ apiKey;
6
+ constructor(config) {
7
+ this.apiKey = config.apiKey;
8
+ this.baseUrl = (config.baseUrl || 'https://api.rendshot.ai').replace(/\/$/, '');
9
+ }
10
+ async renderImage(options) {
11
+ return this.post('/v1/image', options);
12
+ }
13
+ async screenshotUrl(options) {
14
+ return this.post('/v1/screenshot', options);
15
+ }
16
+ async getUsage() {
17
+ return this.get('/v1/usage');
18
+ }
19
+ async getImage(imageId) {
20
+ return this.get(`/v1/image/${encodeURIComponent(imageId)}`);
21
+ }
22
+ async post(path, body) {
23
+ const res = await fetch(`${this.baseUrl}${path}`, {
24
+ method: 'POST',
25
+ headers: {
26
+ 'Authorization': `Bearer ${this.apiKey}`,
27
+ 'Content-Type': 'application/json',
28
+ 'User-Agent': `rendshot-sdk/${VERSION}`,
29
+ },
30
+ body: JSON.stringify(body),
31
+ });
32
+ return this.handleResponse(res);
33
+ }
34
+ async get(path) {
35
+ const res = await fetch(`${this.baseUrl}${path}`, {
36
+ headers: {
37
+ 'Authorization': `Bearer ${this.apiKey}`,
38
+ 'User-Agent': `rendshot-sdk/${VERSION}`,
39
+ },
40
+ });
41
+ return this.handleResponse(res);
42
+ }
43
+ async handleResponse(res) {
44
+ let data;
45
+ try {
46
+ data = await res.json();
47
+ }
48
+ catch {
49
+ if (!res.ok) {
50
+ throw new RendshotError('UNKNOWN_ERROR', `API error: ${res.status}`, res.status);
51
+ }
52
+ throw new Error(`Unexpected non-JSON response (status ${res.status})`);
53
+ }
54
+ if (!res.ok) {
55
+ const err = data?.error;
56
+ throw new RendshotError(err?.code || 'UNKNOWN_ERROR', err?.message || `API error: ${res.status}`, err?.status || res.status);
57
+ }
58
+ return data;
59
+ }
60
+ }
61
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAU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,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE;YAChD,OAAO,EAAE;gBACP,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;gBACxC,YAAY,EAAE,gBAAgB,OAAO,EAAE;aACxC;SACF,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;IACjC,CAAC;IAEO,KAAK,CAAC,cAAc,CAAI,GAAa;QAC3C,IAAI,IAAS,CAAA;QACb,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,cAAc,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;YAClF,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAA;QACxE,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,GAAG,GAAG,IAAI,EAAE,KAAK,CAAA;YACvB,MAAM,IAAI,aAAa,CACrB,GAAG,EAAE,IAAI,IAAI,eAAe,EAC5B,GAAG,EAAE,OAAO,IAAI,cAAc,GAAG,CAAC,MAAM,EAAE,EAC1C,GAAG,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,CAC1B,CAAA;QACH,CAAC;QACD,OAAO,IAAS,CAAA;IAClB,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export declare class RendshotError extends Error {
2
+ code: string;
3
+ status: number;
4
+ constructor(code: string, message: string, status: number);
5
+ }
6
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IAE7B,IAAI,EAAE,MAAM;IAEZ,MAAM,EAAE,MAAM;gBAFd,IAAI,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACR,MAAM,EAAE,MAAM;CAKxB"}
package/dist/errors.js ADDED
@@ -0,0 +1,11 @@
1
+ export class RendshotError extends Error {
2
+ code;
3
+ status;
4
+ constructor(code, message, status) {
5
+ super(message);
6
+ this.code = code;
7
+ this.status = status;
8
+ this.name = 'RendshotError';
9
+ }
10
+ }
11
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAc,SAAQ,KAAK;IAE7B;IAEA;IAHT,YACS,IAAY,EACnB,OAAe,EACR,MAAc;QAErB,KAAK,CAAC,OAAO,CAAC,CAAA;QAJP,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAQ;QAGrB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { RendshotClient } from './client.js';
2
+ export { RendshotError } from './errors.js';
3
+ export type { RendshotClientConfig, RenderImageOptions, ScreenshotUrlOptions, ImageResult, ImageMetadata, UsageResult, } from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,YAAY,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { RendshotClient } from './client.js';
2
+ export { RendshotError } from './errors.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,44 @@
1
+ export interface RendshotClientConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ export interface RenderImageOptions {
6
+ html: string;
7
+ css?: string;
8
+ width?: number;
9
+ height?: number;
10
+ format?: 'png' | 'jpg';
11
+ quality?: number;
12
+ deviceScale?: 1 | 2 | 3;
13
+ fonts?: string[];
14
+ timeout?: number;
15
+ }
16
+ export interface ScreenshotUrlOptions {
17
+ url: string;
18
+ width?: number;
19
+ height?: number;
20
+ format?: 'png' | 'jpg';
21
+ quality?: number;
22
+ fullPage?: boolean;
23
+ deviceScale?: 1 | 2 | 3;
24
+ timeout?: number;
25
+ }
26
+ export interface ImageResult {
27
+ imageId: string;
28
+ url: string;
29
+ width: number;
30
+ height: number;
31
+ format: string;
32
+ size: number;
33
+ createdAt: string;
34
+ }
35
+ export interface ImageMetadata extends ImageResult {
36
+ expiresAt: string;
37
+ }
38
+ export interface UsageResult {
39
+ month: string;
40
+ count: number;
41
+ limit: number;
42
+ plan: string;
43
+ }
44
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAGD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAGD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAGD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const VERSION = "0.1.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const VERSION = '0.1.0';
2
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@rendshot/sdk",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Official JavaScript SDK for RendShot — HTML-to-image rendering and URL screenshots",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "keywords": [
18
+ "rendshot",
19
+ "screenshot",
20
+ "html-to-image",
21
+ "rendering",
22
+ "sdk"
23
+ ],
24
+ "license": "MIT",
25
+ "engines": {
26
+ "node": ">=18"
27
+ },
28
+ "devDependencies": {
29
+ "vitest": "^3"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "test": "vitest run",
34
+ "clean": "rm -rf dist"
35
+ }
36
+ }