@copperline/rendex 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Copperline Labs LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # @copperline/rendex
2
+
3
+ Official TypeScript SDK for the [Rendex](https://rendex.dev) screenshot API. Capture any webpage as a high-quality image with a single function call.
4
+
5
+ - Zero runtime dependencies (uses native `fetch`)
6
+ - Full TypeScript types with IntelliSense
7
+ - Works in Node.js 18+, Deno, Bun, and browsers
8
+ - Typed error handling with API error codes
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @copperline/rendex
14
+ # or
15
+ pnpm add @copperline/rendex
16
+ # or
17
+ bun add @copperline/rendex
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import { Rendex } from "@copperline/rendex";
24
+
25
+ const rendex = new Rendex("your-api-key");
26
+
27
+ // Capture a screenshot (returns binary image)
28
+ const { image, metadata } = await rendex.screenshot({
29
+ url: "https://example.com",
30
+ format: "png",
31
+ fullPage: true,
32
+ });
33
+
34
+ // Write to file (Node.js)
35
+ import { writeFile } from "node:fs/promises";
36
+ await writeFile("screenshot.png", image);
37
+
38
+ console.log(`${metadata.bytesSize} bytes, loaded in ${metadata.loadTimeMs}ms`);
39
+ ```
40
+
41
+ ## API Reference
42
+
43
+ ### `new Rendex(apiKey, config?)`
44
+
45
+ Create a new Rendex client.
46
+
47
+ ```typescript
48
+ const rendex = new Rendex("your-api-key", {
49
+ baseUrl: "https://api.rendex.dev", // optional, default
50
+ });
51
+ ```
52
+
53
+ | Parameter | Type | Description |
54
+ |-----------|------|-------------|
55
+ | `apiKey` | `string` | Your Rendex API key. Get one at [rendex.dev](https://rendex.dev) |
56
+ | `config.baseUrl` | `string` | Override the API base URL |
57
+ | `config.fetch` | `typeof fetch` | Custom fetch implementation (for testing) |
58
+
59
+ ### `rendex.screenshot(options)`
60
+
61
+ Capture a screenshot and return the binary image with metadata.
62
+
63
+ ```typescript
64
+ const { image, metadata } = await rendex.screenshot({
65
+ url: "https://example.com",
66
+ format: "webp",
67
+ width: 1920,
68
+ height: 1080,
69
+ darkMode: true,
70
+ });
71
+ ```
72
+
73
+ **Returns** `Promise<ScreenshotResult>`:
74
+ - `image` — `Uint8Array` of the captured image
75
+ - `metadata` — `ScreenshotMetadata` with URL, dimensions, format, bytes, load time, quality signal
76
+
77
+ ### `rendex.screenshotJson(options)`
78
+
79
+ Capture a screenshot and return JSON with a base64-encoded image.
80
+
81
+ ```typescript
82
+ const result = await rendex.screenshotJson({
83
+ url: "https://example.com",
84
+ });
85
+
86
+ console.log(result.data.image); // base64 string
87
+ console.log(result.data.bytesSize); // 45823
88
+ console.log(result.meta.usage?.remaining); // 499
89
+ ```
90
+
91
+ **Returns** `Promise<ScreenshotJsonResponse>` with `data` (image + metadata) and `meta` (request ID, usage).
92
+
93
+ ### `rendex.screenshotUrl(options)`
94
+
95
+ Generate a GET URL for embedding. No network call — pure URL builder.
96
+
97
+ ```typescript
98
+ const url = rendex.screenshotUrl({
99
+ url: "https://example.com",
100
+ format: "png",
101
+ width: 1200,
102
+ });
103
+ // Use in <img> tags, OpenGraph, etc.
104
+ ```
105
+
106
+ > **Note**: The API key is included in the URL. Use server-side only.
107
+
108
+ **Returns** `string` — a complete URL to the screenshot endpoint.
109
+
110
+ ### Screenshot Options
111
+
112
+ All options except `url` are optional:
113
+
114
+ | Option | Type | Default | Description |
115
+ |--------|------|---------|-------------|
116
+ | `url` | `string` | *required* | The webpage URL to capture |
117
+ | `format` | `"png" \| "jpeg" \| "webp" \| "pdf"` | `"png"` | Output format |
118
+ | `width` | `number` | `1280` | Viewport width (320–3840) |
119
+ | `height` | `number` | `800` | Viewport height (240–2160) |
120
+ | `fullPage` | `boolean` | `false` | Capture the full scrollable page |
121
+ | `quality` | `number` | — | JPEG/WebP quality (1–100) |
122
+ | `delay` | `number` | `0` | Delay before capture in ms (0–10000) |
123
+ | `darkMode` | `boolean` | `false` | Emulate dark mode |
124
+ | `deviceScaleFactor` | `number` | `1` | Device pixel ratio (1–3) for Retina |
125
+ | `blockAds` | `boolean` | `true` | Block ads and trackers |
126
+ | `blockResourceTypes` | `string[]` | — | Block: `"font"`, `"image"`, `"media"`, `"stylesheet"`, `"other"` |
127
+ | `timeout` | `number` | `30` | Page load timeout in seconds (5–60) |
128
+ | `waitUntil` | `string` | `"networkidle2"` | Wait strategy: `"load"`, `"domcontentloaded"`, `"networkidle0"`, `"networkidle2"` |
129
+ | `waitForSelector` | `string` | — | CSS selector to wait for before capture |
130
+ | `bestAttempt` | `boolean` | `true` | Return best-effort screenshot on timeout |
131
+ | `selector` | `string` | — | Capture a specific element by CSS selector |
132
+
133
+ ## Error Handling
134
+
135
+ ```typescript
136
+ import { Rendex, RendexApiError, RendexNetworkError } from "@copperline/rendex";
137
+
138
+ const rendex = new Rendex("your-api-key");
139
+
140
+ try {
141
+ await rendex.screenshot({ url: "https://example.com" });
142
+ } catch (error) {
143
+ if (error instanceof RendexApiError) {
144
+ // API returned an error
145
+ console.error(error.errorCode); // "RATE_LIMITED", "VALIDATION_ERROR", etc.
146
+ console.error(error.statusCode); // 429, 400, etc.
147
+ console.error(error.requestId); // For debugging with Rendex support
148
+ console.error(error.details); // Validation details (if any)
149
+ } else if (error instanceof RendexNetworkError) {
150
+ // Network failure (DNS, timeout, connection refused)
151
+ console.error("Network error:", error.message);
152
+ }
153
+ }
154
+ ```
155
+
156
+ ### Error Codes
157
+
158
+ | Code | HTTP Status | Description |
159
+ |------|-------------|-------------|
160
+ | `VALIDATION_ERROR` | 400 | Invalid request parameters |
161
+ | `INVALID_URL` | 400 | URL failed SSRF validation |
162
+ | `TIMEOUT` | 408 | Page took too long to load |
163
+ | `CAPTURE_FAILED` | 500 | Browser rendering error |
164
+ | `RATE_LIMITED` | 429 | Rate limit exceeded |
165
+ | `USAGE_EXCEEDED` | 429 | Monthly credit limit reached |
166
+ | `MISSING_API_KEY` | 401 | No API key provided |
167
+ | `INVALID_API_KEY` | 401 | API key verification failed |
168
+
169
+ ## License
170
+
171
+ MIT - [Copperline Labs LLC](https://copperlinelabs.com)
@@ -0,0 +1,72 @@
1
+ import type { BatchCreateResponse, BatchOptions, BatchStatusResponse, JobStatusResponse, RendexConfig, ScreenshotJsonResponse, ScreenshotOptions, ScreenshotResult } from "./types.js";
2
+ export declare class Rendex {
3
+ private readonly apiKey;
4
+ private readonly baseUrl;
5
+ private readonly _fetch;
6
+ constructor(apiKey: string, config?: RendexConfig);
7
+ /**
8
+ * Capture a screenshot and return the binary image with metadata.
9
+ *
10
+ * ```ts
11
+ * const { image, metadata } = await rendex.screenshot({ url: "https://example.com" });
12
+ * ```
13
+ */
14
+ screenshot(options: ScreenshotOptions): Promise<ScreenshotResult>;
15
+ /**
16
+ * Capture a screenshot and return a JSON response with base64-encoded image.
17
+ *
18
+ * ```ts
19
+ * const result = await rendex.screenshotJson({ url: "https://example.com" });
20
+ * console.log(result.data.bytesSize, result.meta.usage?.remaining);
21
+ * ```
22
+ */
23
+ screenshotJson(options: ScreenshotOptions): Promise<ScreenshotJsonResponse>;
24
+ /**
25
+ * Generate a signed GET URL for embedding (no network call).
26
+ *
27
+ * Useful for `<img>` tags, OpenGraph images, or anywhere you need a URL.
28
+ *
29
+ * **Note**: The API key is included in the URL. Use server-side only.
30
+ *
31
+ * ```ts
32
+ * const url = rendex.screenshotUrl({ url: "https://example.com" });
33
+ * // => "https://api.rendex.dev/v1/screenshot?url=...&key=..."
34
+ * ```
35
+ */
36
+ screenshotUrl(options: ScreenshotOptions): string;
37
+ /**
38
+ * Submit a batch of URLs for async capture.
39
+ *
40
+ * ```ts
41
+ * const batch = await rendex.batch({
42
+ * urls: ["https://example.com", "https://github.com"],
43
+ * defaults: { format: "webp", fullPage: true },
44
+ * });
45
+ * console.log(batch.data.batchId); // poll with batchStatus()
46
+ * ```
47
+ */
48
+ batch(options: BatchOptions): Promise<BatchCreateResponse>;
49
+ /**
50
+ * Check the status of an async job.
51
+ *
52
+ * ```ts
53
+ * const job = await rendex.jobStatus("uuid-here");
54
+ * if (job.data.status === "completed") console.log(job.data.resultUrl);
55
+ * ```
56
+ */
57
+ jobStatus(jobId: string): Promise<JobStatusResponse>;
58
+ /**
59
+ * Check the status of a batch and all its jobs.
60
+ *
61
+ * ```ts
62
+ * const batch = await rendex.batchStatus("uuid-here");
63
+ * console.log(`${batch.data.completedJobs}/${batch.data.totalJobs} done`);
64
+ * ```
65
+ */
66
+ batchStatus(batchId: string): Promise<BatchStatusResponse>;
67
+ private _post;
68
+ private _get;
69
+ private _handleErrorResponse;
70
+ private _parseMetadataHeaders;
71
+ }
72
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EAEtB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;gBAErC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY;IASjD;;;;;;OAMG;IACG,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IASvE;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAiBjF;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM;IAqBjD;;;;;;;;;;OAUG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAiBhE;;;;;;;OAOG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiB1D;;;;;;;OAOG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAmBlD,KAAK;YAyBL,IAAI;YAuBJ,oBAAoB;IAoBlC,OAAO,CAAC,qBAAqB;CAc9B"}
package/dist/client.js ADDED
@@ -0,0 +1,195 @@
1
+ // ─── Rendex SDK Client ───────────────────────────────────────────────
2
+ import { RendexApiError, RendexError, RendexNetworkError } from "./errors.js";
3
+ const DEFAULT_BASE_URL = "https://api.rendex.dev";
4
+ export class Rendex {
5
+ apiKey;
6
+ baseUrl;
7
+ _fetch;
8
+ constructor(apiKey, config) {
9
+ if (!apiKey) {
10
+ throw new RendexError("API key is required. Get one at https://rendex.dev");
11
+ }
12
+ this.apiKey = apiKey;
13
+ this.baseUrl = (config?.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
14
+ this._fetch = config?.fetch ?? globalThis.fetch;
15
+ }
16
+ /**
17
+ * Capture a screenshot and return the binary image with metadata.
18
+ *
19
+ * ```ts
20
+ * const { image, metadata } = await rendex.screenshot({ url: "https://example.com" });
21
+ * ```
22
+ */
23
+ async screenshot(options) {
24
+ const response = await this._post("/v1/screenshot", options);
25
+ const image = new Uint8Array(await response.arrayBuffer());
26
+ const metadata = this._parseMetadataHeaders(response.headers, image.byteLength);
27
+ return { image, metadata };
28
+ }
29
+ /**
30
+ * Capture a screenshot and return a JSON response with base64-encoded image.
31
+ *
32
+ * ```ts
33
+ * const result = await rendex.screenshotJson({ url: "https://example.com" });
34
+ * console.log(result.data.bytesSize, result.meta.usage?.remaining);
35
+ * ```
36
+ */
37
+ async screenshotJson(options) {
38
+ const response = await this._post("/v1/screenshot/json", options);
39
+ const body = await response.json();
40
+ if (!body.success) {
41
+ throw new RendexApiError(body.error?.message ?? "Unknown error", response.status, body.error?.code ?? "UNKNOWN", body.meta?.requestId, body.error?.details);
42
+ }
43
+ return body;
44
+ }
45
+ /**
46
+ * Generate a signed GET URL for embedding (no network call).
47
+ *
48
+ * Useful for `<img>` tags, OpenGraph images, or anywhere you need a URL.
49
+ *
50
+ * **Note**: The API key is included in the URL. Use server-side only.
51
+ *
52
+ * ```ts
53
+ * const url = rendex.screenshotUrl({ url: "https://example.com" });
54
+ * // => "https://api.rendex.dev/v1/screenshot?url=...&key=..."
55
+ * ```
56
+ */
57
+ screenshotUrl(options) {
58
+ const params = new URLSearchParams();
59
+ params.set("key", this.apiKey);
60
+ // Only simple scalars and arrays go in query params.
61
+ // Complex objects (cookies, headers, pdfMargin) are POST-only.
62
+ for (const [key, value] of Object.entries(options)) {
63
+ if (value === undefined || value === null)
64
+ continue;
65
+ if (typeof value === "object" && !Array.isArray(value))
66
+ continue;
67
+ if (Array.isArray(value)) {
68
+ for (const item of value) {
69
+ params.append(key, String(item));
70
+ }
71
+ }
72
+ else {
73
+ params.set(key, String(value));
74
+ }
75
+ }
76
+ return `${this.baseUrl}/v1/screenshot?${params.toString()}`;
77
+ }
78
+ /**
79
+ * Submit a batch of URLs for async capture.
80
+ *
81
+ * ```ts
82
+ * const batch = await rendex.batch({
83
+ * urls: ["https://example.com", "https://github.com"],
84
+ * defaults: { format: "webp", fullPage: true },
85
+ * });
86
+ * console.log(batch.data.batchId); // poll with batchStatus()
87
+ * ```
88
+ */
89
+ async batch(options) {
90
+ const response = await this._post("/v1/screenshot/batch", options);
91
+ const body = await response.json();
92
+ if (!body.success) {
93
+ throw new RendexApiError(body.error?.message ?? "Unknown error", response.status, body.error?.code ?? "UNKNOWN", body.meta?.requestId, body.error?.details);
94
+ }
95
+ return body;
96
+ }
97
+ /**
98
+ * Check the status of an async job.
99
+ *
100
+ * ```ts
101
+ * const job = await rendex.jobStatus("uuid-here");
102
+ * if (job.data.status === "completed") console.log(job.data.resultUrl);
103
+ * ```
104
+ */
105
+ async jobStatus(jobId) {
106
+ const response = await this._get(`/v1/jobs/${jobId}`);
107
+ const body = await response.json();
108
+ if (!body.success) {
109
+ throw new RendexApiError(body.error?.message ?? "Unknown error", response.status, body.error?.code ?? "UNKNOWN", body.meta?.requestId, body.error?.details);
110
+ }
111
+ return body;
112
+ }
113
+ /**
114
+ * Check the status of a batch and all its jobs.
115
+ *
116
+ * ```ts
117
+ * const batch = await rendex.batchStatus("uuid-here");
118
+ * console.log(`${batch.data.completedJobs}/${batch.data.totalJobs} done`);
119
+ * ```
120
+ */
121
+ async batchStatus(batchId) {
122
+ const response = await this._get(`/v1/batches/${batchId}`);
123
+ const body = await response.json();
124
+ if (!body.success) {
125
+ throw new RendexApiError(body.error?.message ?? "Unknown error", response.status, body.error?.code ?? "UNKNOWN", body.meta?.requestId, body.error?.details);
126
+ }
127
+ return body;
128
+ }
129
+ // ─── Private ─────────────────────────────────────────────────────
130
+ async _post(path, body) {
131
+ let response;
132
+ try {
133
+ response = await this._fetch(`${this.baseUrl}${path}`, {
134
+ method: "POST",
135
+ headers: {
136
+ "Content-Type": "application/json",
137
+ Authorization: `Bearer ${this.apiKey}`,
138
+ },
139
+ body: JSON.stringify(body),
140
+ });
141
+ }
142
+ catch (err) {
143
+ throw new RendexNetworkError(`Network request to ${this.baseUrl}${path} failed: ${err instanceof Error ? err.message : String(err)}`, err);
144
+ }
145
+ if (!response.ok) {
146
+ await this._handleErrorResponse(response);
147
+ }
148
+ return response;
149
+ }
150
+ async _get(path) {
151
+ let response;
152
+ try {
153
+ response = await this._fetch(`${this.baseUrl}${path}`, {
154
+ method: "GET",
155
+ headers: {
156
+ Authorization: `Bearer ${this.apiKey}`,
157
+ },
158
+ });
159
+ }
160
+ catch (err) {
161
+ throw new RendexNetworkError(`Network request to ${this.baseUrl}${path} failed: ${err instanceof Error ? err.message : String(err)}`, err);
162
+ }
163
+ if (!response.ok) {
164
+ await this._handleErrorResponse(response);
165
+ }
166
+ return response;
167
+ }
168
+ async _handleErrorResponse(response) {
169
+ let body;
170
+ try {
171
+ body = await response.json();
172
+ }
173
+ catch {
174
+ // Response body isn't JSON — throw with status info only
175
+ }
176
+ const error = body?.error;
177
+ const meta = body?.meta;
178
+ throw new RendexApiError(error?.message ?? `HTTP ${response.status}`, response.status, error?.code ?? "UNKNOWN", meta?.requestId, error?.details);
179
+ }
180
+ _parseMetadataHeaders(headers, fallbackSize) {
181
+ return {
182
+ url: headers.get("x-screenshot-url") ?? "",
183
+ width: parseInt(headers.get("x-screenshot-width") ?? "0", 10),
184
+ height: parseInt(headers.get("x-screenshot-height") ?? "0", 10),
185
+ format: headers.get("x-rendex-format") ?? "png",
186
+ bytesSize: parseInt(headers.get("x-screenshot-size") ?? String(fallbackSize), 10),
187
+ capturedAt: headers.get("x-screenshot-captured-at") ?? new Date().toISOString(),
188
+ quality: (headers.get("x-rendex-quality") ?? "full"),
189
+ waitStrategy: headers.get("x-rendex-wait-strategy") ?? "unknown",
190
+ loadTimeMs: parseInt(headers.get("x-rendex-load-time-ms") ?? "0", 10),
191
+ truncated: headers.get("x-rendex-truncated") === "true",
192
+ };
193
+ }
194
+ }
195
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAa9E,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD,MAAM,OAAO,MAAM;IACA,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,MAAM,CAA0B;IAEjD,YAAY,MAAc,EAAE,MAAqB;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,WAAW,CAAC,oDAAoD,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IAClD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAE7D,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAEhF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC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EACvD,QAAQ,CAAC,MAAM,EACd,KAAK,EAAE,IAAe,IAAI,SAAS,EACpC,IAAI,EAAE,SAA+B,EACrC,KAAK,EAAE,OAAO,CACf,CAAC;IACJ,CAAC;IAEO,qBAAqB,CAAC,OAAgB,EAAE,YAAoB;QAClE,OAAO;YACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE;YAC1C,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC;YAC7D,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC;YAC/D,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,KAAK;YAC/C,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;YACjF,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YAC/E,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,MAAM,CAAkC;YACrF,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,SAAS;YAChE,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,GAAG,EAAE,EAAE,CAAC;YACrE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,MAAM;SACxD,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import type { ApiErrorCode } from "./types.js";
2
+ /** Base error for all Rendex SDK errors. */
3
+ export declare class RendexError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /** Error returned by the Rendex API (non-2xx response with a parsed body). */
7
+ export declare class RendexApiError extends RendexError {
8
+ /** HTTP status code (e.g. 400, 401, 429, 500). */
9
+ readonly statusCode: number;
10
+ /** API error code (e.g. "RATE_LIMITED", "VALIDATION_ERROR"). */
11
+ readonly errorCode: ApiErrorCode | string;
12
+ /** Unique request ID for debugging with Rendex support. */
13
+ readonly requestId: string | undefined;
14
+ /** Additional error details (e.g. validation field errors). */
15
+ readonly details: unknown;
16
+ constructor(message: string, statusCode: number, errorCode: string, requestId?: string, details?: unknown);
17
+ }
18
+ /** Network-level error (DNS failure, timeout, connection refused, etc.). */
19
+ export declare class RendexNetworkError extends RendexError {
20
+ /** The underlying error from fetch. */
21
+ readonly cause: unknown;
22
+ constructor(message: string, cause: unknown);
23
+ }
24
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,4CAA4C;AAC5C,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,8EAA8E;AAC9E,qBAAa,cAAe,SAAQ,WAAW;IAC7C,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,CAAC;IAC1C,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAGxB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO;CASpB;AAED,4EAA4E;AAC5E,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;CAK5C"}
package/dist/errors.js ADDED
@@ -0,0 +1,38 @@
1
+ // ─── Rendex SDK Errors ───────────────────────────────────────────────
2
+ /** Base error for all Rendex SDK errors. */
3
+ export class RendexError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = "RendexError";
7
+ }
8
+ }
9
+ /** Error returned by the Rendex API (non-2xx response with a parsed body). */
10
+ export class RendexApiError extends RendexError {
11
+ /** HTTP status code (e.g. 400, 401, 429, 500). */
12
+ statusCode;
13
+ /** API error code (e.g. "RATE_LIMITED", "VALIDATION_ERROR"). */
14
+ errorCode;
15
+ /** Unique request ID for debugging with Rendex support. */
16
+ requestId;
17
+ /** Additional error details (e.g. validation field errors). */
18
+ details;
19
+ constructor(message, statusCode, errorCode, requestId, details) {
20
+ super(message);
21
+ this.name = "RendexApiError";
22
+ this.statusCode = statusCode;
23
+ this.errorCode = errorCode;
24
+ this.requestId = requestId;
25
+ this.details = details;
26
+ }
27
+ }
28
+ /** Network-level error (DNS failure, timeout, connection refused, etc.). */
29
+ export class RendexNetworkError extends RendexError {
30
+ /** The underlying error from fetch. */
31
+ cause;
32
+ constructor(message, cause) {
33
+ super(message);
34
+ this.name = "RendexNetworkError";
35
+ this.cause = cause;
36
+ }
37
+ }
38
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAIxE,4CAA4C;AAC5C,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,8EAA8E;AAC9E,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,kDAAkD;IACzC,UAAU,CAAS;IAC5B,gEAAgE;IACvD,SAAS,CAAwB;IAC1C,2DAA2D;IAClD,SAAS,CAAqB;IACvC,+DAA+D;IACtD,OAAO,CAAU;IAE1B,YACE,OAAe,EACf,UAAkB,EAClB,SAAiB,EACjB,SAAkB,EAClB,OAAiB;QAEjB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IACjD,uCAAuC;IAC9B,KAAK,CAAU;IAExB,YAAY,OAAe,EAAE,KAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { Rendex } from "./client.js";
2
+ export { RendexError, RendexApiError, RendexNetworkError } from "./errors.js";
3
+ export type { ScreenshotOptions, ScreenshotResult, ScreenshotMetadata, ScreenshotJsonResponse, ScreenshotData, BatchOptions, BatchCreateResponse, BatchStatusResponse, JobStatusResponse, JobStatus, BatchStatus, CookieParam, PdfMargin, ResponseMeta, UsageInfo, RendexConfig, ApiErrorCode, } 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":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9E,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // ─── @copperline/rendex — Official TypeScript SDK ────────────────────
2
+ export { Rendex } from "./client.js";
3
+ export { RendexError, RendexApiError, RendexNetworkError } from "./errors.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,219 @@
1
+ /** Cookie to set before navigation. */
2
+ export interface CookieParam {
3
+ name: string;
4
+ value: string;
5
+ /** Cookie domain. Auto-derived from URL if omitted. */
6
+ domain?: string;
7
+ /** Cookie path. @default "/" */
8
+ path?: string;
9
+ httpOnly?: boolean;
10
+ secure?: boolean;
11
+ sameSite?: "Strict" | "Lax" | "None";
12
+ /** Unix timestamp for expiry. */
13
+ expires?: number;
14
+ }
15
+ /** PDF margin configuration (CSS units: "0", "1cm", "20px", etc.). */
16
+ export interface PdfMargin {
17
+ top?: string;
18
+ right?: string;
19
+ bottom?: string;
20
+ left?: string;
21
+ }
22
+ /** Options for capturing a screenshot or PDF. Provide either `url` or `html` (not both). */
23
+ export interface ScreenshotOptions {
24
+ /** The URL to capture. Mutually exclusive with `html`. */
25
+ url?: string;
26
+ /** Raw HTML to render. Mutually exclusive with `url`. Max 5MB. */
27
+ html?: string;
28
+ /** Output format. "pdf" returns a PDF document instead of an image. @default "png" */
29
+ format?: "png" | "jpeg" | "webp" | "pdf";
30
+ /** Viewport width in pixels (320–3840). @default 1280 */
31
+ width?: number;
32
+ /** Viewport height in pixels (240–2160). @default 800 */
33
+ height?: number;
34
+ /** Capture the full scrollable page. @default false */
35
+ fullPage?: boolean;
36
+ /** JPEG/WebP quality (1–100). Ignored for PNG and PDF. */
37
+ quality?: number;
38
+ /** Delay in milliseconds before capture (0–10000). @default 0 */
39
+ delay?: number;
40
+ /** Emulate dark mode (prefers-color-scheme: dark). @default false */
41
+ darkMode?: boolean;
42
+ /** Device pixel ratio (1–3). @default 1 */
43
+ deviceScaleFactor?: number;
44
+ /** Block ads and trackers. @default true */
45
+ blockAds?: boolean;
46
+ /** Resource types to block. */
47
+ blockResourceTypes?: ("font" | "image" | "media" | "stylesheet" | "other")[];
48
+ /** Page load timeout in seconds (5–60). @default 30 */
49
+ timeout?: number;
50
+ /** Navigation wait strategy. @default "networkidle2" */
51
+ waitUntil?: "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
52
+ /** Wait for a CSS selector to appear before capture. */
53
+ waitForSelector?: string;
54
+ /** Return best-effort screenshot on timeout instead of erroring. @default true */
55
+ bestAttempt?: boolean;
56
+ /** CSS selector to capture a specific element instead of the full page. */
57
+ selector?: string;
58
+ /** Custom CSS to inject into the page before capture. Max 50KB. */
59
+ css?: string;
60
+ /** Custom JavaScript to execute in the page before capture. Max 50KB. */
61
+ js?: string;
62
+ /** Cookies to set before navigation. Max 50. */
63
+ cookies?: CookieParam[];
64
+ /** Custom HTTP headers for the navigation request. */
65
+ headers?: Record<string, string>;
66
+ /** Override the browser user agent string. */
67
+ userAgent?: string;
68
+ /** PDF page size. @default "A4" */
69
+ pdfFormat?: "A4" | "Letter" | "Legal" | "Tabloid" | "A3";
70
+ /** PDF landscape orientation. @default false */
71
+ pdfLandscape?: boolean;
72
+ /** Print background colors/images in PDF. @default true */
73
+ pdfPrintBackground?: boolean;
74
+ /** PDF page margins (CSS units). */
75
+ pdfMargin?: PdfMargin;
76
+ /** PDF scale factor (0.1–2). @default 1 */
77
+ pdfScale?: number;
78
+ /** ISO 3166-1 alpha-2 country code for geo-targeted capture (e.g., "US", "DE", "JP"). Pro/Enterprise only. */
79
+ geo?: string;
80
+ /** City for more precise geo-targeting. Requires `geo` to be set. */
81
+ geoCity?: string;
82
+ /** State/region for more precise geo-targeting. Requires `geo` to be set. */
83
+ geoState?: string;
84
+ /** Return a job ID immediately instead of waiting for the result. */
85
+ async?: boolean;
86
+ /** URL to receive a webhook when the capture completes. */
87
+ webhookUrl?: string;
88
+ /** How long the signed result URL stays valid, in seconds (3600–2592000). @default 86400 */
89
+ cacheTtl?: number;
90
+ }
91
+ /** Metadata extracted from response headers for binary screenshots. */
92
+ export interface ScreenshotMetadata {
93
+ url: string;
94
+ width: number;
95
+ height: number;
96
+ format: string;
97
+ bytesSize: number;
98
+ capturedAt: string;
99
+ quality: "full" | "degraded" | "best_attempt";
100
+ waitStrategy: string;
101
+ loadTimeMs: number;
102
+ truncated: boolean;
103
+ renderingEngine?: "cf-browser" | "decodo-proxy";
104
+ geoCountry?: string;
105
+ }
106
+ /** Result from `Rendex.screenshot()` — binary image with metadata. */
107
+ export interface ScreenshotResult {
108
+ /** Raw image bytes. Write to file, upload to S3, etc. */
109
+ image: Uint8Array;
110
+ /** Capture metadata extracted from response headers. */
111
+ metadata: ScreenshotMetadata;
112
+ }
113
+ /** Usage information from the API response. */
114
+ export interface UsageInfo {
115
+ credits: number;
116
+ remaining: number;
117
+ }
118
+ /** Response metadata envelope. */
119
+ export interface ResponseMeta {
120
+ requestId: string;
121
+ timestamp: string;
122
+ usage?: UsageInfo;
123
+ }
124
+ /** Screenshot data from the JSON endpoint. */
125
+ export interface ScreenshotData {
126
+ /** Base64-encoded image data. */
127
+ image: string;
128
+ contentType: string;
129
+ url: string;
130
+ width: number;
131
+ height: number;
132
+ format: string;
133
+ bytesSize: number;
134
+ capturedAt: string;
135
+ quality: "full" | "degraded" | "best_attempt";
136
+ waitStrategy: string;
137
+ loadTimeMs: number;
138
+ truncated?: boolean;
139
+ }
140
+ /** Result from `Rendex.screenshotJson()`. */
141
+ export interface ScreenshotJsonResponse {
142
+ success: true;
143
+ data: ScreenshotData;
144
+ meta: ResponseMeta;
145
+ }
146
+ /** SDK configuration options. */
147
+ export interface RendexConfig {
148
+ /** Override the base API URL. @default "https://api.rendex.dev" */
149
+ baseUrl?: string;
150
+ /** Custom fetch implementation (for testing or custom environments). */
151
+ fetch?: typeof globalThis.fetch;
152
+ }
153
+ /** Job status from `GET /v1/jobs/:jobId`. */
154
+ export type JobStatus = "queued" | "processing" | "completed" | "failed";
155
+ /** Response from `Rendex.jobStatus()`. */
156
+ export interface JobStatusResponse {
157
+ success: true;
158
+ data: {
159
+ jobId: string;
160
+ status: JobStatus;
161
+ resultUrl?: string;
162
+ error?: string;
163
+ createdAt: string;
164
+ completedAt?: string;
165
+ };
166
+ meta: ResponseMeta;
167
+ }
168
+ /** Batch status. */
169
+ export type BatchStatus = "processing" | "completed" | "partial" | "failed";
170
+ /** Options for `Rendex.batch()`. */
171
+ export interface BatchOptions {
172
+ /** URLs to capture (1–500 depending on plan). */
173
+ urls: string[];
174
+ /** Default capture params applied to all URLs. */
175
+ defaults?: Omit<ScreenshotOptions, "url" | "html" | "async" | "webhookUrl" | "cacheTtl">;
176
+ /** Webhook URL called when the entire batch completes. */
177
+ webhookUrl?: string;
178
+ /** Signed URL TTL in seconds (3600–2592000). @default 86400 */
179
+ cacheTtl?: number;
180
+ }
181
+ /** Response from `Rendex.batch()` — 202 Accepted. */
182
+ export interface BatchCreateResponse {
183
+ success: true;
184
+ data: {
185
+ batchId: string;
186
+ totalJobs: number;
187
+ jobs: Array<{
188
+ jobId: string;
189
+ url: string;
190
+ status: "queued";
191
+ }>;
192
+ };
193
+ meta: ResponseMeta;
194
+ }
195
+ /** Response from `Rendex.batchStatus()`. */
196
+ export interface BatchStatusResponse {
197
+ success: true;
198
+ data: {
199
+ batchId: string;
200
+ status: BatchStatus;
201
+ totalJobs: number;
202
+ completedJobs: number;
203
+ failedJobs: number;
204
+ createdAt: string;
205
+ completedAt?: string;
206
+ jobs: Array<{
207
+ jobId: string;
208
+ status: JobStatus;
209
+ resultUrl?: string;
210
+ error?: string;
211
+ createdAt: string;
212
+ completedAt?: string;
213
+ }>;
214
+ };
215
+ meta: ResponseMeta;
216
+ }
217
+ /** Known API error codes returned by the Rendex API. */
218
+ export type ApiErrorCode = "VALIDATION_ERROR" | "INVALID_URL" | "INVALID_JSON" | "TIMEOUT" | "CAPTURE_FAILED" | "MISSING_API_KEY" | "INVALID_API_KEY" | "KEY_DISABLED" | "RATE_LIMITED" | "USAGE_EXCEEDED" | "NOT_FOUND" | "GEO_FEATURE_UNAVAILABLE" | "PLAN_UPGRADE_REQUIRED" | "CONFIGURATION_ERROR";
219
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,uCAAuC;AACvC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sEAAsE;AACtE,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,4FAA4F;AAC5F,MAAM,WAAW,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tB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,KAAK,CAAC;YACV,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,SAAS,CAAC;YAClB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,SAAS,EAAE,MAAM,CAAC;YAClB,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC,CAAC;KACJ,CAAC;IACF,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,wDAAwD;AACxD,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,aAAa,GACb,cAAc,GACd,SAAS,GACT,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,yBAAyB,GACzB,uBAAuB,GACvB,qBAAqB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ // ─── Rendex SDK Types ────────────────────────────────────────────────
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,wEAAwE"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@copperline/rendex",
3
+ "version": "1.0.0",
4
+ "description": "Official TypeScript SDK for the Rendex screenshot API — capture any webpage as an image",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "typecheck": "tsc --noEmit",
22
+ "dev": "tsc --watch",
23
+ "prepublishOnly": "tsc"
24
+ },
25
+ "keywords": [
26
+ "rendex",
27
+ "screenshot",
28
+ "screenshot-api",
29
+ "webpage-capture",
30
+ "sdk",
31
+ "typescript",
32
+ "copperline",
33
+ "ai-agent",
34
+ "mcp"
35
+ ],
36
+ "author": "Copperline Labs LLC",
37
+ "license": "MIT",
38
+ "homepage": "https://rendex.dev",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/copperline-labs/copperline-labs",
42
+ "directory": "packages/rendex-js"
43
+ },
44
+ "devDependencies": {
45
+ "typescript": "^5.7.0"
46
+ }
47
+ }