@ever-works/screenshotone-plugin 1.0.0 → 1.0.2
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/index.cjs +488 -0
- package/dist/index.d.cts +99 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +463 -0
- package/package.json +94 -81
- package/LICENSE +0 -661
- package/src/__tests__/screenshotone.plugin.spec.ts +0 -349
- package/src/index.ts +0 -2
- package/src/screenshotone.plugin.ts +0 -542
- package/tsconfig.json +0 -23
- package/tsup.config.ts +0 -12
- package/vitest.config.ts +0 -13
|
@@ -1,542 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IPlugin,
|
|
3
|
-
IScreenshotPlugin,
|
|
4
|
-
PluginContext,
|
|
5
|
-
PluginCategory,
|
|
6
|
-
PluginManifest,
|
|
7
|
-
PluginHealthCheck,
|
|
8
|
-
JsonSchema,
|
|
9
|
-
PluginSettings,
|
|
10
|
-
ScreenshotOptions,
|
|
11
|
-
ScreenshotResult,
|
|
12
|
-
ScreenshotFormat,
|
|
13
|
-
ScreenshotValidationResult,
|
|
14
|
-
ConnectionValidationResult
|
|
15
|
-
} from '@ever-works/plugin';
|
|
16
|
-
|
|
17
|
-
import * as screenshotone from 'screenshotone-api-sdk';
|
|
18
|
-
|
|
19
|
-
// Security (SSRF): shared lexical guard rejecting non-HTTP(S) schemes and
|
|
20
|
-
// literal private/loopback/link-local/cloud-metadata IPs. Imported directly
|
|
21
|
-
// from the helper subpath because the plugin barrel intentionally does not
|
|
22
|
-
// re-export it (it pulls in node:net / node:dns).
|
|
23
|
-
import { isSafeWebhookUrl } from '@ever-works/plugin/helpers/ssrf-guard';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* ScreenshotOne plugin settings interface
|
|
27
|
-
*/
|
|
28
|
-
interface ScreenshotOneSettings {
|
|
29
|
-
readonly accessKey?: string;
|
|
30
|
-
readonly secretKey?: string;
|
|
31
|
-
readonly viewportWidth?: number;
|
|
32
|
-
readonly viewportHeight?: number;
|
|
33
|
-
readonly format?: ScreenshotFormat;
|
|
34
|
-
readonly fullPage?: boolean;
|
|
35
|
-
readonly deviceScaleFactor?: number;
|
|
36
|
-
readonly blockAds?: boolean;
|
|
37
|
-
readonly blockTrackers?: boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* ScreenshotOne Plugin
|
|
42
|
-
*
|
|
43
|
-
* Provides screenshot capture capabilities using the ScreenshotOne API service.
|
|
44
|
-
* Supports configurable viewport sizes, formats, and advanced options like ad blocking.
|
|
45
|
-
*
|
|
46
|
-
* Settings Resolution:
|
|
47
|
-
* The API keys are resolved through the 4-level hierarchy:
|
|
48
|
-
* 1. Work settings (highest priority)
|
|
49
|
-
* 2. User settings
|
|
50
|
-
* 3. Admin settings
|
|
51
|
-
* 4. Environment variables: PLUGIN_SCREENSHOTONE_ACCESS_KEY, PLUGIN_SCREENSHOTONE_SECRET_KEY
|
|
52
|
-
* 5. Not configured (plugin unavailable)
|
|
53
|
-
*
|
|
54
|
-
* Configuration mode: hybrid - allows admin-level defaults with user/work overrides.
|
|
55
|
-
*/
|
|
56
|
-
export class ScreenshotOnePlugin implements IPlugin, IScreenshotPlugin {
|
|
57
|
-
// ============================================================================
|
|
58
|
-
// IPlugin Properties
|
|
59
|
-
// ============================================================================
|
|
60
|
-
|
|
61
|
-
readonly id = 'screenshotone';
|
|
62
|
-
readonly name = 'ScreenshotOne';
|
|
63
|
-
readonly version = '1.0.0';
|
|
64
|
-
readonly category: PluginCategory = 'screenshot';
|
|
65
|
-
readonly capabilities: readonly string[] = ['screenshot'];
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Provider name for facade identification
|
|
69
|
-
*/
|
|
70
|
-
readonly providerName = 'ScreenshotOne';
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Settings schema with environment variable fallback.
|
|
74
|
-
*
|
|
75
|
-
* The 'x-envVar' extension tells the PluginSettingsService to check
|
|
76
|
-
* the environment variable when no other setting is found.
|
|
77
|
-
*/
|
|
78
|
-
readonly settingsSchema: JsonSchema = {
|
|
79
|
-
type: 'object',
|
|
80
|
-
properties: {
|
|
81
|
-
accessKey: {
|
|
82
|
-
type: 'string',
|
|
83
|
-
title: 'Access Key',
|
|
84
|
-
description: 'Your ScreenshotOne access key. Get one at https://screenshotone.com',
|
|
85
|
-
// Security marker - encrypt and never return via API
|
|
86
|
-
'x-secret': true,
|
|
87
|
-
// Environment variable fallback
|
|
88
|
-
'x-envVar': 'PLUGIN_SCREENSHOTONE_ACCESS_KEY',
|
|
89
|
-
'x-scope': 'user'
|
|
90
|
-
},
|
|
91
|
-
secretKey: {
|
|
92
|
-
type: 'string',
|
|
93
|
-
title: 'Secret Key',
|
|
94
|
-
description: 'Your ScreenshotOne secret key for signed URLs (recommended for security)',
|
|
95
|
-
// Security marker - encrypt and never return via API
|
|
96
|
-
'x-secret': true,
|
|
97
|
-
// Environment variable fallback
|
|
98
|
-
'x-envVar': 'PLUGIN_SCREENSHOTONE_SECRET_KEY',
|
|
99
|
-
'x-scope': 'user'
|
|
100
|
-
},
|
|
101
|
-
viewportWidth: {
|
|
102
|
-
type: 'number',
|
|
103
|
-
title: 'Viewport Width',
|
|
104
|
-
description: 'Default viewport width in pixels',
|
|
105
|
-
default: 1280,
|
|
106
|
-
minimum: 320,
|
|
107
|
-
maximum: 3840,
|
|
108
|
-
'x-envVar': 'PLUGIN_SCREENSHOTONE_VIEWPORT_WIDTH'
|
|
109
|
-
},
|
|
110
|
-
viewportHeight: {
|
|
111
|
-
type: 'number',
|
|
112
|
-
title: 'Viewport Height',
|
|
113
|
-
description: 'Default viewport height in pixels',
|
|
114
|
-
default: 800,
|
|
115
|
-
minimum: 200,
|
|
116
|
-
maximum: 2160,
|
|
117
|
-
'x-envVar': 'PLUGIN_SCREENSHOTONE_VIEWPORT_HEIGHT'
|
|
118
|
-
},
|
|
119
|
-
format: {
|
|
120
|
-
type: 'string',
|
|
121
|
-
title: 'Image Format',
|
|
122
|
-
description: 'Default output image format',
|
|
123
|
-
enum: ['png', 'jpg', 'jpeg', 'webp'],
|
|
124
|
-
default: 'png',
|
|
125
|
-
'x-envVar': 'PLUGIN_SCREENSHOTONE_FORMAT'
|
|
126
|
-
},
|
|
127
|
-
fullPage: {
|
|
128
|
-
type: 'boolean',
|
|
129
|
-
title: 'Full Page',
|
|
130
|
-
description: 'Capture full page by default',
|
|
131
|
-
default: false
|
|
132
|
-
},
|
|
133
|
-
deviceScaleFactor: {
|
|
134
|
-
type: 'number',
|
|
135
|
-
title: 'Device Scale Factor',
|
|
136
|
-
description: 'Device scale factor (1 = normal, 2 = retina)',
|
|
137
|
-
default: 1,
|
|
138
|
-
minimum: 0.5,
|
|
139
|
-
maximum: 3
|
|
140
|
-
},
|
|
141
|
-
blockAds: {
|
|
142
|
-
type: 'boolean',
|
|
143
|
-
title: 'Block Ads',
|
|
144
|
-
description: 'Block ads when capturing screenshots',
|
|
145
|
-
default: true
|
|
146
|
-
},
|
|
147
|
-
blockTrackers: {
|
|
148
|
-
type: 'boolean',
|
|
149
|
-
title: 'Block Trackers',
|
|
150
|
-
description: 'Block trackers when capturing screenshots',
|
|
151
|
-
default: true
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
required: ['accessKey']
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Configuration mode: hybrid allows admin-level defaults with user overrides
|
|
159
|
-
*/
|
|
160
|
-
readonly configurationMode: 'admin-only' | 'user-required' | 'hybrid' = 'hybrid';
|
|
161
|
-
|
|
162
|
-
private context?: PluginContext;
|
|
163
|
-
|
|
164
|
-
// ============================================================================
|
|
165
|
-
// IScreenshotPlugin Interface
|
|
166
|
-
// ============================================================================
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Capture a screenshot using ScreenshotOne API
|
|
170
|
-
*/
|
|
171
|
-
async capture(options: ScreenshotOptions): Promise<ScreenshotResult> {
|
|
172
|
-
const startTime = Date.now();
|
|
173
|
-
const settings = this.mergeSettings(options.settings);
|
|
174
|
-
|
|
175
|
-
// Security (SSRF): `options.url` is attacker-controllable (work source
|
|
176
|
-
// URLs, LLM-generated item URLs) and is forwarded to the ScreenshotOne
|
|
177
|
-
// backend to render. Block non-HTTP(S) schemes and literal
|
|
178
|
-
// private/loopback/link-local/cloud-metadata targets (e.g.
|
|
179
|
-
// http://169.254.169.254/...) before building TakeOptions. Legitimate
|
|
180
|
-
// https item URLs are unaffected.
|
|
181
|
-
if (!isSafeWebhookUrl(options.url)) {
|
|
182
|
-
return {
|
|
183
|
-
success: false,
|
|
184
|
-
error: `URL host is not safe to capture (SSRF guard blocked: ${options.url})`
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
const client = this.createClient(settings);
|
|
190
|
-
const takeOptions = this.buildTakeOptions(options, settings);
|
|
191
|
-
|
|
192
|
-
// Download the screenshot
|
|
193
|
-
const imageBlob = await client.take(takeOptions);
|
|
194
|
-
const arrayBuffer = await imageBlob.arrayBuffer();
|
|
195
|
-
const buffer = Buffer.from(arrayBuffer);
|
|
196
|
-
|
|
197
|
-
// Generate the screenshot URL for reference
|
|
198
|
-
const imageUrl = settings.secretKey
|
|
199
|
-
? await Promise.resolve(client.generateSignedTakeURL(takeOptions))
|
|
200
|
-
: await Promise.resolve(client.generateTakeURL(takeOptions));
|
|
201
|
-
|
|
202
|
-
return {
|
|
203
|
-
success: true,
|
|
204
|
-
imageBuffer: buffer,
|
|
205
|
-
imageBase64: buffer.toString('base64'),
|
|
206
|
-
imageUrl: String(imageUrl),
|
|
207
|
-
width: options.viewportWidth ?? settings.viewportWidth ?? 1280,
|
|
208
|
-
height: options.viewportHeight ?? settings.viewportHeight ?? 800,
|
|
209
|
-
fileSize: buffer.length
|
|
210
|
-
};
|
|
211
|
-
} catch (error) {
|
|
212
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
213
|
-
this.context?.logger.error(`ScreenshotOne capture failed: ${errorMessage}`);
|
|
214
|
-
|
|
215
|
-
return {
|
|
216
|
-
success: false,
|
|
217
|
-
error: errorMessage
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Get screenshot URL without actually capturing
|
|
224
|
-
* Uses signed URLs when secret key is available
|
|
225
|
-
*/
|
|
226
|
-
async getScreenshotUrl(options: ScreenshotOptions): Promise<string | null> {
|
|
227
|
-
const settings = this.mergeSettings(options.settings);
|
|
228
|
-
|
|
229
|
-
// Security (SSRF): same guard as capture() — `options.url` is
|
|
230
|
-
// attacker-controllable and ends up in the generated ScreenshotOne
|
|
231
|
-
// take URL. Refuse non-HTTP(S) schemes and private/loopback/link-local/
|
|
232
|
-
// cloud-metadata targets; return null (the existing failure shape).
|
|
233
|
-
if (!isSafeWebhookUrl(options.url)) {
|
|
234
|
-
this.context?.logger.error(
|
|
235
|
-
`ScreenshotOne URL generation blocked by SSRF guard for unsafe URL: ${options.url}`
|
|
236
|
-
);
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
try {
|
|
241
|
-
const client = this.createClient(settings);
|
|
242
|
-
const takeOptions = this.buildTakeOptions(options, settings);
|
|
243
|
-
|
|
244
|
-
// Use signed URL if secret key is available
|
|
245
|
-
const url = settings.secretKey
|
|
246
|
-
? await Promise.resolve(client.generateSignedTakeURL(takeOptions))
|
|
247
|
-
: await Promise.resolve(client.generateTakeURL(takeOptions));
|
|
248
|
-
|
|
249
|
-
return String(url);
|
|
250
|
-
} catch (error) {
|
|
251
|
-
this.context?.logger.error(
|
|
252
|
-
`ScreenshotOne URL generation failed: ${error instanceof Error ? error.message : String(error)}`
|
|
253
|
-
);
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Check if the service is available (API key configured)
|
|
260
|
-
*/
|
|
261
|
-
async isAvailable(): Promise<boolean> {
|
|
262
|
-
if (!this.context) return false;
|
|
263
|
-
const settings = await this.context.getSettings();
|
|
264
|
-
return Boolean(settings?.accessKey);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
async validateConnection(settings: Record<string, unknown>): Promise<ConnectionValidationResult> {
|
|
268
|
-
const accessKey = settings.accessKey as string | undefined;
|
|
269
|
-
if (!accessKey) {
|
|
270
|
-
return { success: false, message: 'ScreenshotOne access key is not configured.' };
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
try {
|
|
274
|
-
const resolvedSettings = this.mergeSettings(settings);
|
|
275
|
-
const client = this.createClient(resolvedSettings);
|
|
276
|
-
const testOptions = screenshotone.TakeOptions.url('https://example.com');
|
|
277
|
-
|
|
278
|
-
const url = resolvedSettings.secretKey
|
|
279
|
-
? await Promise.resolve(client.generateSignedTakeURL(testOptions))
|
|
280
|
-
: await Promise.resolve(client.generateTakeURL(testOptions));
|
|
281
|
-
|
|
282
|
-
const urlString = String(url);
|
|
283
|
-
if (urlString && urlString.includes('api.screenshotone.com')) {
|
|
284
|
-
return { success: true, message: 'ScreenshotOne connection verified.' };
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return { success: false, message: 'ScreenshotOne credentials appear invalid.' };
|
|
288
|
-
} catch (error) {
|
|
289
|
-
return {
|
|
290
|
-
success: false,
|
|
291
|
-
message: `ScreenshotOne connection failed: ${error instanceof Error ? error.message : String(error)}`
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Validate API credentials by making a test request
|
|
298
|
-
*/
|
|
299
|
-
async validateCredentials(): Promise<ScreenshotValidationResult> {
|
|
300
|
-
if (!this.context) {
|
|
301
|
-
return {
|
|
302
|
-
valid: false,
|
|
303
|
-
message: 'Plugin not initialized'
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
try {
|
|
308
|
-
const settings = await this.context.getSettings();
|
|
309
|
-
const resolvedSettings = this.mergeSettings(settings);
|
|
310
|
-
|
|
311
|
-
if (!resolvedSettings.accessKey) {
|
|
312
|
-
return {
|
|
313
|
-
valid: false,
|
|
314
|
-
message: 'Access key is not configured'
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Try to generate a URL - if credentials are invalid, this should fail
|
|
319
|
-
const client = this.createClient(resolvedSettings);
|
|
320
|
-
const testOptions = screenshotone.TakeOptions.url('https://example.com');
|
|
321
|
-
|
|
322
|
-
// Generate URL to verify credentials format
|
|
323
|
-
const url = resolvedSettings.secretKey
|
|
324
|
-
? await Promise.resolve(client.generateSignedTakeURL(testOptions))
|
|
325
|
-
: await Promise.resolve(client.generateTakeURL(testOptions));
|
|
326
|
-
|
|
327
|
-
const urlString = String(url);
|
|
328
|
-
if (urlString && urlString.includes('api.screenshotone.com')) {
|
|
329
|
-
return {
|
|
330
|
-
valid: true,
|
|
331
|
-
message: 'Credentials are valid'
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
return {
|
|
336
|
-
valid: false,
|
|
337
|
-
message: 'Invalid credentials format'
|
|
338
|
-
};
|
|
339
|
-
} catch (error) {
|
|
340
|
-
return {
|
|
341
|
-
valid: false,
|
|
342
|
-
message: error instanceof Error ? error.message : 'Unknown error'
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Get supported screenshot formats
|
|
349
|
-
*/
|
|
350
|
-
getSupportedFormats(): readonly ScreenshotFormat[] {
|
|
351
|
-
return ['png', 'jpg', 'jpeg', 'webp'] as const;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Get maximum viewport dimensions
|
|
356
|
-
*/
|
|
357
|
-
getMaxDimensions(): { width: number; height: number } {
|
|
358
|
-
return { width: 3840, height: 2160 };
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* EW-602 — ScreenshotOne charges roughly $0.005 per screenshot on
|
|
363
|
-
* the developer plan (rounds to 1 cent for budget tracking). Free
|
|
364
|
-
* tier covers 100 shots/month; beyond that the platform attributes
|
|
365
|
-
* the per-call cost to PluginUsageEvent on every successful capture.
|
|
366
|
-
*/
|
|
367
|
-
getPricing(): { costPerCallCents: number; currency: string; note: string } {
|
|
368
|
-
return {
|
|
369
|
-
costPerCallCents: 1,
|
|
370
|
-
currency: 'usd',
|
|
371
|
-
note: 'Approx. $0.005/screenshot (free tier: 100/month).'
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// ============================================================================
|
|
376
|
-
// Private Helper Methods
|
|
377
|
-
// ============================================================================
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Create a ScreenshotOne client with the resolved settings
|
|
381
|
-
*/
|
|
382
|
-
private createClient(settings: ScreenshotOneSettings): screenshotone.Client {
|
|
383
|
-
const accessKey = settings.accessKey;
|
|
384
|
-
const secretKey = settings.secretKey ?? '';
|
|
385
|
-
|
|
386
|
-
if (!accessKey) {
|
|
387
|
-
throw new Error(
|
|
388
|
-
'ScreenshotOne access key not configured. ' +
|
|
389
|
-
'Set it in plugin settings or via PLUGIN_SCREENSHOTONE_ACCESS_KEY environment variable.'
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return new screenshotone.Client(accessKey, secretKey);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Build TakeOptions from screenshot options and settings
|
|
398
|
-
*/
|
|
399
|
-
private buildTakeOptions(options: ScreenshotOptions, settings: ScreenshotOneSettings): screenshotone.TakeOptions {
|
|
400
|
-
const takeOptions = screenshotone.TakeOptions.url(options.url);
|
|
401
|
-
|
|
402
|
-
// Viewport settings
|
|
403
|
-
const viewportWidth = options.viewportWidth ?? settings.viewportWidth ?? 1280;
|
|
404
|
-
const viewportHeight = options.viewportHeight ?? settings.viewportHeight ?? 800;
|
|
405
|
-
takeOptions.viewportWidth(viewportWidth);
|
|
406
|
-
takeOptions.viewportHeight(viewportHeight);
|
|
407
|
-
|
|
408
|
-
// Format
|
|
409
|
-
const format = options.format ?? settings.format ?? 'png';
|
|
410
|
-
takeOptions.format(format);
|
|
411
|
-
|
|
412
|
-
// Full page
|
|
413
|
-
const fullPage = options.fullPage ?? settings.fullPage ?? false;
|
|
414
|
-
takeOptions.fullPage(fullPage);
|
|
415
|
-
|
|
416
|
-
// Device scale factor
|
|
417
|
-
const deviceScaleFactor = options.deviceScaleFactor ?? settings.deviceScaleFactor ?? 1;
|
|
418
|
-
takeOptions.deviceScaleFactor(deviceScaleFactor);
|
|
419
|
-
|
|
420
|
-
// Ad and tracker blocking
|
|
421
|
-
const blockAds = options.blockAds ?? settings.blockAds ?? true;
|
|
422
|
-
const blockTrackers = options.blockTrackers ?? settings.blockTrackers ?? true;
|
|
423
|
-
takeOptions.blockAds(blockAds);
|
|
424
|
-
takeOptions.blockTrackers(blockTrackers);
|
|
425
|
-
|
|
426
|
-
// Cookie banners
|
|
427
|
-
if (options.blockCookieBanners) {
|
|
428
|
-
takeOptions.blockCookieBanners(true);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// Delay
|
|
432
|
-
if (options.delay !== undefined) {
|
|
433
|
-
takeOptions.delay(options.delay / 1000); // Convert ms to seconds
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// Caching
|
|
437
|
-
if (options.cache) {
|
|
438
|
-
takeOptions.cache(true);
|
|
439
|
-
if (options.cacheTtl !== undefined) {
|
|
440
|
-
takeOptions.cacheTtl(options.cacheTtl);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// Wait for selector
|
|
445
|
-
if (options.waitForSelector) {
|
|
446
|
-
takeOptions.selector(options.waitForSelector);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// User agent
|
|
450
|
-
if (options.userAgent) {
|
|
451
|
-
takeOptions.userAgent(options.userAgent);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
return takeOptions;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Merge settings with defaults
|
|
459
|
-
*/
|
|
460
|
-
private mergeSettings(settings?: PluginSettings): ScreenshotOneSettings {
|
|
461
|
-
return {
|
|
462
|
-
accessKey: settings?.accessKey as string | undefined,
|
|
463
|
-
secretKey: settings?.secretKey as string | undefined,
|
|
464
|
-
viewportWidth: (settings?.viewportWidth as number | undefined) ?? 1280,
|
|
465
|
-
viewportHeight: (settings?.viewportHeight as number | undefined) ?? 800,
|
|
466
|
-
format: (settings?.format as ScreenshotFormat | undefined) ?? 'png',
|
|
467
|
-
fullPage: (settings?.fullPage as boolean | undefined) ?? false,
|
|
468
|
-
deviceScaleFactor: (settings?.deviceScaleFactor as number | undefined) ?? 1,
|
|
469
|
-
blockAds: (settings?.blockAds as boolean | undefined) ?? true,
|
|
470
|
-
blockTrackers: (settings?.blockTrackers as boolean | undefined) ?? true
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// ============================================================================
|
|
475
|
-
// IPlugin Lifecycle
|
|
476
|
-
// ============================================================================
|
|
477
|
-
|
|
478
|
-
async onLoad(context: PluginContext): Promise<void> {
|
|
479
|
-
this.context = context;
|
|
480
|
-
context.logger.log('ScreenshotOne Plugin loaded');
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
async onUnload(): Promise<void> {
|
|
484
|
-
this.context = undefined;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
async healthCheck(): Promise<PluginHealthCheck> {
|
|
488
|
-
// Note: We can't do a real health check without settings context
|
|
489
|
-
// The facade will pass settings when making actual calls
|
|
490
|
-
return {
|
|
491
|
-
status: 'healthy',
|
|
492
|
-
message: 'ScreenshotOne plugin is ready (API key required for operations)',
|
|
493
|
-
checkedAt: Date.now()
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
getManifest(): PluginManifest {
|
|
498
|
-
return {
|
|
499
|
-
id: this.id,
|
|
500
|
-
name: this.name,
|
|
501
|
-
version: this.version,
|
|
502
|
-
description: 'Automatically capture website screenshots for your work items',
|
|
503
|
-
category: this.category,
|
|
504
|
-
capabilities: [...this.capabilities],
|
|
505
|
-
author: { name: 'Ever Works Team' },
|
|
506
|
-
license: 'AGPL-3.0',
|
|
507
|
-
builtIn: false,
|
|
508
|
-
systemPlugin: false,
|
|
509
|
-
readme: [
|
|
510
|
-
'## What does ScreenshotOne do?',
|
|
511
|
-
'',
|
|
512
|
-
'ScreenshotOne is a screenshot capture API. When work items include source URLs, this plugin automatically generates preview images by capturing a screenshot of each page.',
|
|
513
|
-
'',
|
|
514
|
-
'## Why use it?',
|
|
515
|
-
'',
|
|
516
|
-
'- **Automated capture** — preview images are generated for each work item without manual effort',
|
|
517
|
-
'- **Consistent output** — every screenshot uses the same viewport size, format, and rendering settings',
|
|
518
|
-
'- **Ad and tracker blocking** — captures clean screenshots free of ads and cookie banners',
|
|
519
|
-
'- **Multiple formats** — supports PNG, JPG, and WebP output with configurable resolution',
|
|
520
|
-
'',
|
|
521
|
-
'## How it works in Ever Works',
|
|
522
|
-
'',
|
|
523
|
-
'During work generation, the screenshot facade sends capture requests to ScreenshotOne for items that have a source URL. The resulting images are used as item preview thumbnails. You can configure viewport dimensions, image format, device scale factor, and caching behavior.',
|
|
524
|
-
'',
|
|
525
|
-
'## Getting started',
|
|
526
|
-
'',
|
|
527
|
-
'1. Sign up at [screenshotone.com](https://screenshotone.com)',
|
|
528
|
-
'2. Copy your access key and optional secret key (for signed URLs)',
|
|
529
|
-
'3. Enable the ScreenshotOne plugin on this page',
|
|
530
|
-
'4. Enter your credentials in the settings below'
|
|
531
|
-
].join('\n'),
|
|
532
|
-
homepage: 'https://screenshotone.com',
|
|
533
|
-
icon: {
|
|
534
|
-
type: 'lucide',
|
|
535
|
-
value: 'Camera',
|
|
536
|
-
backgroundColor: '#4f46e5'
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
export default ScreenshotOnePlugin;
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "ESNext",
|
|
4
|
-
"moduleResolution": "bundler",
|
|
5
|
-
"target": "ES2021",
|
|
6
|
-
"types": ["node"],
|
|
7
|
-
"strict": true,
|
|
8
|
-
"strictNullChecks": true,
|
|
9
|
-
"noImplicitAny": true,
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"outDir": "./dist",
|
|
14
|
-
"rootDir": "./src",
|
|
15
|
-
"esModuleInterop": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"forceConsistentCasingInFileNames": true,
|
|
18
|
-
"isolatedModules": true,
|
|
19
|
-
"noEmit": true
|
|
20
|
-
},
|
|
21
|
-
"include": ["src/**/*"],
|
|
22
|
-
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
|
23
|
-
}
|
package/tsup.config.ts
DELETED
package/vitest.config.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
globals: true,
|
|
6
|
-
environment: 'node',
|
|
7
|
-
include: ['src/**/*.{test,spec}.ts'],
|
|
8
|
-
coverage: {
|
|
9
|
-
reporter: ['text', 'json', 'html'],
|
|
10
|
-
exclude: ['node_modules/', 'dist/']
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
});
|