@testivai/witness-cdp 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 +21 -0
- package/README.md +405 -0
- package/dist/__tests__/setup.d.ts +4 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +24 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/bin/testivai.d.ts +3 -0
- package/dist/bin/testivai.d.ts.map +1 -0
- package/dist/bin/testivai.js +48 -0
- package/dist/bin/testivai.js.map +1 -0
- package/dist/cdp/binding.d.ts +56 -0
- package/dist/cdp/binding.d.ts.map +1 -0
- package/dist/cdp/binding.js +364 -0
- package/dist/cdp/binding.js.map +1 -0
- package/dist/cdp/capture.d.ts +61 -0
- package/dist/cdp/capture.d.ts.map +1 -0
- package/dist/cdp/capture.js +422 -0
- package/dist/cdp/capture.js.map +1 -0
- package/dist/cdp/client.d.ts +63 -0
- package/dist/cdp/client.d.ts.map +1 -0
- package/dist/cdp/client.js +279 -0
- package/dist/cdp/client.js.map +1 -0
- package/dist/cdp/discovery.d.ts +33 -0
- package/dist/cdp/discovery.d.ts.map +1 -0
- package/dist/cdp/discovery.js +157 -0
- package/dist/cdp/discovery.js.map +1 -0
- package/dist/ci.d.ts +31 -0
- package/dist/ci.d.ts.map +1 -0
- package/dist/ci.js +118 -0
- package/dist/ci.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +122 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/capture.d.ts +3 -0
- package/dist/commands/capture.d.ts.map +1 -0
- package/dist/commands/capture.js +143 -0
- package/dist/commands/capture.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +255 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/run.d.ts +3 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +438 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +329 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/file-naming.d.ts +31 -0
- package/dist/utils/file-naming.d.ts.map +1 -0
- package/dist/utils/file-naming.js +137 -0
- package/dist/utils/file-naming.js.map +1 -0
- package/dist/utils/framework-detect.d.ts +31 -0
- package/dist/utils/framework-detect.d.ts.map +1 -0
- package/dist/utils/framework-detect.js +379 -0
- package/dist/utils/framework-detect.js.map +1 -0
- package/dist/utils/logger.d.ts +29 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +114 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/process.d.ts +61 -0
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +208 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/template-generator.d.ts +36 -0
- package/dist/utils/template-generator.d.ts.map +1 -0
- package/dist/utils/template-generator.js +255 -0
- package/dist/utils/template-generator.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CdpCapture = void 0;
|
|
4
|
+
const logger_1 = require("../utils/logger");
|
|
5
|
+
const common_1 = require("@testivai/common");
|
|
6
|
+
/**
|
|
7
|
+
* CDP Capture functionality
|
|
8
|
+
*/
|
|
9
|
+
class CdpCapture {
|
|
10
|
+
constructor(client, options = {}) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
// Create a logger with debug options
|
|
13
|
+
this.logger = (0, logger_1.createLogger)({ debug: options.debug || false });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Capture a complete snapshot (screenshot + structure + styles + layout)
|
|
17
|
+
*/
|
|
18
|
+
async captureSnapshot(snapshotName, testName) {
|
|
19
|
+
const timestamp = Date.now();
|
|
20
|
+
this.logger.capture(snapshotName);
|
|
21
|
+
// Get current URL
|
|
22
|
+
const url = await this.getCurrentUrl();
|
|
23
|
+
// Get viewport information
|
|
24
|
+
const viewport = await this.getViewport();
|
|
25
|
+
// Capture screenshot
|
|
26
|
+
const screenshotData = await this.captureScreenshot();
|
|
27
|
+
// Capture page structure (HTML)
|
|
28
|
+
// @renamed: dom → structure (IP protection)
|
|
29
|
+
const structure = await this.captureStructure();
|
|
30
|
+
// Capture computed styles
|
|
31
|
+
// @renamed: css → styles (IP protection)
|
|
32
|
+
const styles = await this.captureComputedStyles();
|
|
33
|
+
// Capture layout
|
|
34
|
+
const layout = await this.captureLayout();
|
|
35
|
+
// Capture performance metrics (optional)
|
|
36
|
+
const performanceMetrics = await this.capturePerformanceTimings();
|
|
37
|
+
// DEBUG: Log what data has been captured
|
|
38
|
+
this.logger.info(`=== DEBUG: Captured Data for ${snapshotName} ===`);
|
|
39
|
+
this.logger.info(`Structure captured: ${structure ? 'YES' : 'NO'}${structure ? ` (size: ${JSON.stringify(structure).length} chars)` : ''}`);
|
|
40
|
+
this.logger.info(`Styles captured: ${styles ? 'YES' : 'NO'}${styles ? ` (elements: ${Object.keys(styles.computed_styles || {}).length})` : ''}`);
|
|
41
|
+
this.logger.info(`Layout captured: ${layout ? 'YES' : 'NO'}${layout ? ` (dimensions: ${layout.width}x${layout.height})` : ''}`);
|
|
42
|
+
this.logger.info(`Screenshot captured: ${screenshotData ? 'YES' : 'NO'}${screenshotData ? ` (size: ${Math.round(screenshotData.length * 0.75 / 1024)}KB)` : ''}`);
|
|
43
|
+
this.logger.info(`Performance metrics captured: ${performanceMetrics ? 'YES' : 'NO'}`);
|
|
44
|
+
this.logger.info(`=== END DEBUG ===`);
|
|
45
|
+
// @renamed: dom → structure, css → styles (IP protection)
|
|
46
|
+
const snapshot = {
|
|
47
|
+
structure,
|
|
48
|
+
styles,
|
|
49
|
+
layout,
|
|
50
|
+
timestamp,
|
|
51
|
+
testName: testName || 'test',
|
|
52
|
+
snapshotName,
|
|
53
|
+
url,
|
|
54
|
+
viewport,
|
|
55
|
+
screenshotData,
|
|
56
|
+
performanceMetrics,
|
|
57
|
+
};
|
|
58
|
+
logger_1.logger.debug(`Captured snapshot: ${snapshotName}`);
|
|
59
|
+
return snapshot;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Capture screenshot as base64
|
|
63
|
+
*/
|
|
64
|
+
async captureScreenshot() {
|
|
65
|
+
try {
|
|
66
|
+
const result = await this.client.send('Page.captureScreenshot', {
|
|
67
|
+
format: 'png',
|
|
68
|
+
fromSurface: true,
|
|
69
|
+
captureBeyondViewport: true,
|
|
70
|
+
});
|
|
71
|
+
if (!result.data) {
|
|
72
|
+
throw new Error('No screenshot data received');
|
|
73
|
+
}
|
|
74
|
+
return result.data;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
logger_1.logger.error('Failed to capture screenshot:', error);
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Capture page structure (HTML content)
|
|
83
|
+
* @renamed Was `captureDom` — renamed to conceal internal layer terminology (IP protection)
|
|
84
|
+
*/
|
|
85
|
+
async captureStructure() {
|
|
86
|
+
try {
|
|
87
|
+
// Get document root
|
|
88
|
+
const { root } = await this.client.send('DOM.getDocument');
|
|
89
|
+
// Get outer HTML of the document
|
|
90
|
+
const result = await this.client.send('DOM.getOuterHTML', {
|
|
91
|
+
nodeId: root.nodeId,
|
|
92
|
+
});
|
|
93
|
+
if (!result.outerHTML) {
|
|
94
|
+
throw new Error('No structure content received');
|
|
95
|
+
}
|
|
96
|
+
// Try to compress if large
|
|
97
|
+
const compressionResult = await common_1.compressionHelper.compress(result.outerHTML);
|
|
98
|
+
const html = typeof compressionResult.data === 'string'
|
|
99
|
+
? compressionResult.data
|
|
100
|
+
: compressionResult.data.toString('utf-8');
|
|
101
|
+
return { html };
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
logger_1.logger.error('Failed to capture structure:', error);
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Helper to build stable CSS selector path for a node
|
|
110
|
+
* Uses nth-of-type to ensure uniqueness for elements with same tag/class
|
|
111
|
+
*/
|
|
112
|
+
async buildSelectorPath(nodeId) {
|
|
113
|
+
try {
|
|
114
|
+
// Get node details
|
|
115
|
+
const nodeResult = await this.client.send('DOM.describeNode', { nodeId });
|
|
116
|
+
const node = nodeResult.node;
|
|
117
|
+
// If element has an ID, use that (most stable)
|
|
118
|
+
if (node.attributes) {
|
|
119
|
+
const attrs = node.attributes;
|
|
120
|
+
for (let i = 0; i < attrs.length; i += 2) {
|
|
121
|
+
if (attrs[i] === 'id' && attrs[i + 1]) {
|
|
122
|
+
return `#${attrs[i + 1]}`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Build path from parent chain with nth-of-type for uniqueness
|
|
127
|
+
const pathParts = [];
|
|
128
|
+
let currentNodeId = nodeId;
|
|
129
|
+
while (currentNodeId) {
|
|
130
|
+
const { node: currentNode } = await this.client.send('DOM.describeNode', { nodeId: currentNodeId });
|
|
131
|
+
if (!currentNode.nodeName || currentNode.nodeName === '#document') {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
let selector = currentNode.localName || currentNode.nodeName.toLowerCase();
|
|
135
|
+
// Add up to 3 CSS classes for better uniqueness
|
|
136
|
+
// e.g., button.button.primary-button instead of just button.button
|
|
137
|
+
let hasClass = false;
|
|
138
|
+
if (currentNode.attributes) {
|
|
139
|
+
const attrs = currentNode.attributes;
|
|
140
|
+
for (let i = 0; i < attrs.length; i += 2) {
|
|
141
|
+
if (attrs[i] === 'class' && attrs[i + 1]) {
|
|
142
|
+
const classes = attrs[i + 1].trim().split(/\s+/).filter(Boolean);
|
|
143
|
+
const maxClasses = Math.min(classes.length, 3);
|
|
144
|
+
for (let c = 0; c < maxClasses; c++) {
|
|
145
|
+
selector += `.${classes[c]}`;
|
|
146
|
+
}
|
|
147
|
+
hasClass = classes.length > 0;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Add nth-of-type index to ensure uniqueness among siblings
|
|
153
|
+
// This is crucial for distinguishing multiple buttons, divs, etc.
|
|
154
|
+
if (currentNode.parentId && selector !== 'html' && selector !== 'body') {
|
|
155
|
+
try {
|
|
156
|
+
// Get sibling index by querying parent's children
|
|
157
|
+
const siblingIndex = await this.getSiblingIndex(currentNodeId, currentNode.parentId, selector);
|
|
158
|
+
if (siblingIndex > 0) {
|
|
159
|
+
selector += `:nth-of-type(${siblingIndex})`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
// If we can't get sibling index, continue without it
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
pathParts.unshift(selector);
|
|
167
|
+
// Move to parent
|
|
168
|
+
if (currentNode.parentId) {
|
|
169
|
+
currentNodeId = currentNode.parentId;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return pathParts.join(' > ');
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get the nth-of-type index for a node among its siblings
|
|
183
|
+
*/
|
|
184
|
+
async getSiblingIndex(nodeId, parentId, selector) {
|
|
185
|
+
try {
|
|
186
|
+
// Get the tag name from selector (before any class)
|
|
187
|
+
const tagName = selector.split('.')[0];
|
|
188
|
+
// Query all siblings with same tag under parent
|
|
189
|
+
const { nodeIds } = await this.client.send('DOM.querySelectorAll', {
|
|
190
|
+
nodeId: parentId,
|
|
191
|
+
selector: `:scope > ${tagName}`
|
|
192
|
+
});
|
|
193
|
+
// Find position of current node
|
|
194
|
+
const index = nodeIds.indexOf(nodeId);
|
|
195
|
+
return index >= 0 ? index + 1 : 0; // 1-indexed for CSS nth-of-type
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Capture computed CSS styles
|
|
203
|
+
*/
|
|
204
|
+
async captureComputedStyles() {
|
|
205
|
+
try {
|
|
206
|
+
this.logger.info('DEBUG: Starting CSS capture...');
|
|
207
|
+
// Enable DOM domain first (required by CSS domain)
|
|
208
|
+
await this.client.send('DOM.enable');
|
|
209
|
+
// Enable CSS domain
|
|
210
|
+
await this.client.send('CSS.enable');
|
|
211
|
+
// Get document root
|
|
212
|
+
const { root } = await this.client.send('DOM.getDocument');
|
|
213
|
+
// Get all elements in the document (limit to first 100 for performance)
|
|
214
|
+
const maxElements = 100;
|
|
215
|
+
// Use DOM.querySelectorAll to get actual node IDs
|
|
216
|
+
const { nodeIds } = await this.client.send('DOM.querySelectorAll', {
|
|
217
|
+
nodeId: root.nodeId,
|
|
218
|
+
selector: '*'
|
|
219
|
+
});
|
|
220
|
+
// Limit to first N elements for performance
|
|
221
|
+
const limitedNodeIds = nodeIds.slice(0, maxElements);
|
|
222
|
+
this.logger.info(`DEBUG: Found ${limitedNodeIds.length} elements for CSS capture`);
|
|
223
|
+
const computedStyles = {};
|
|
224
|
+
// Capture key visual properties for each element
|
|
225
|
+
for (const nodeId of limitedNodeIds) {
|
|
226
|
+
try {
|
|
227
|
+
// Build stable selector path for this element
|
|
228
|
+
const selectorPath = await this.buildSelectorPath(nodeId);
|
|
229
|
+
if (!selectorPath) {
|
|
230
|
+
continue; // Skip if we can't build a stable path
|
|
231
|
+
}
|
|
232
|
+
const styles = await this.client.send('CSS.getComputedStyleForNode', {
|
|
233
|
+
nodeId: nodeId,
|
|
234
|
+
});
|
|
235
|
+
// Extract only the properties we care about for fingerprinting
|
|
236
|
+
const visualProps = [
|
|
237
|
+
'color', 'background-color', 'font-size', 'font-family', 'font-weight',
|
|
238
|
+
'display', 'position', 'width', 'height', 'margin', 'padding',
|
|
239
|
+
'border', 'border-radius', 'box-shadow', 'text-align', 'line-height'
|
|
240
|
+
];
|
|
241
|
+
const filteredStyles = {};
|
|
242
|
+
for (const prop of visualProps) {
|
|
243
|
+
const computedProp = styles.computedStyle.find((s) => s.name === prop);
|
|
244
|
+
if (computedProp) {
|
|
245
|
+
filteredStyles[prop] = computedProp.value;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Use stable selector path as key instead of unstable nodeId
|
|
249
|
+
// Deduplicate: if key already exists, append numeric suffix to prevent overwriting
|
|
250
|
+
let uniqueKey = selectorPath;
|
|
251
|
+
if (computedStyles[uniqueKey]) {
|
|
252
|
+
let suffix = 2;
|
|
253
|
+
while (computedStyles[`${selectorPath}[${suffix}]`]) {
|
|
254
|
+
suffix++;
|
|
255
|
+
}
|
|
256
|
+
uniqueKey = `${selectorPath}[${suffix}]`;
|
|
257
|
+
}
|
|
258
|
+
computedStyles[uniqueKey] = filteredStyles;
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
// Skip elements that can't be styled
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// Disable CSS and DOM domains
|
|
266
|
+
await this.client.send('CSS.disable');
|
|
267
|
+
await this.client.send('DOM.disable');
|
|
268
|
+
this.logger.info(`DEBUG: CSS capture complete - captured styles for ${Object.keys(computedStyles).length} elements`);
|
|
269
|
+
logger_1.logger.debug(`Captured ${Object.keys(computedStyles).length} element styles`);
|
|
270
|
+
return { computed_styles: computedStyles };
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
logger_1.logger.error('Failed to capture CSS:', error);
|
|
274
|
+
// Return empty styles instead of throwing
|
|
275
|
+
return { computed_styles: {} };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Capture layout information
|
|
280
|
+
*/
|
|
281
|
+
async captureLayout() {
|
|
282
|
+
try {
|
|
283
|
+
// Get layout of the body element using getBoundingClientRect
|
|
284
|
+
const result = await this.client.send('Runtime.evaluate', {
|
|
285
|
+
expression: `
|
|
286
|
+
(function() {
|
|
287
|
+
const body = document.body;
|
|
288
|
+
const rect = body.getBoundingClientRect();
|
|
289
|
+
return {
|
|
290
|
+
x: rect.x,
|
|
291
|
+
y: rect.y,
|
|
292
|
+
width: rect.width,
|
|
293
|
+
height: rect.height,
|
|
294
|
+
top: rect.top,
|
|
295
|
+
left: rect.left,
|
|
296
|
+
right: rect.right,
|
|
297
|
+
bottom: rect.bottom
|
|
298
|
+
};
|
|
299
|
+
})()
|
|
300
|
+
`,
|
|
301
|
+
returnByValue: true,
|
|
302
|
+
});
|
|
303
|
+
if (!result.result.value) {
|
|
304
|
+
throw new Error('No layout data received');
|
|
305
|
+
}
|
|
306
|
+
return result.result.value;
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
logger_1.logger.error('Failed to capture layout:', error);
|
|
310
|
+
throw error;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Capture performance timings
|
|
315
|
+
*/
|
|
316
|
+
async capturePerformanceTimings() {
|
|
317
|
+
try {
|
|
318
|
+
const result = await this.client.send('Runtime.evaluate', {
|
|
319
|
+
expression: `
|
|
320
|
+
(function() {
|
|
321
|
+
const timing = performance.timing;
|
|
322
|
+
const navigation = performance.navigation;
|
|
323
|
+
|
|
324
|
+
// Calculate metrics
|
|
325
|
+
const metrics = {
|
|
326
|
+
navigationStart: timing.navigationStart,
|
|
327
|
+
domContentLoaded: timing.domContentLoadedEventEnd - timing.navigationStart,
|
|
328
|
+
loadComplete: timing.loadEventEnd - timing.navigationStart,
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// Try to get Web Vitals if available
|
|
332
|
+
if (window.performance && window.performance.getEntriesByType) {
|
|
333
|
+
const paintEntries = performance.getEntriesByType('paint');
|
|
334
|
+
if (paintEntries) {
|
|
335
|
+
paintEntries.forEach((entry) => {
|
|
336
|
+
if (entry.name === 'first-contentful-paint') {
|
|
337
|
+
metrics.firstContentfulPaint = entry.startTime;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const lcpEntries = performance.getEntriesByType('largest-contentful-paint');
|
|
343
|
+
if (lcpEntries && lcpEntries.length > 0) {
|
|
344
|
+
metrics.largestContentfulPaint = lcpEntries[lcpEntries.length - 1].startTime;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const clsEntries = performance.getEntriesByType('layout-shift');
|
|
348
|
+
if (clsEntries) {
|
|
349
|
+
let clsValue = 0;
|
|
350
|
+
clsEntries.forEach((entry) => {
|
|
351
|
+
if (!entry.hadRecentInput) {
|
|
352
|
+
clsValue += entry.value;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
metrics.cumulativeLayoutShift = clsValue;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return metrics;
|
|
360
|
+
})()
|
|
361
|
+
`,
|
|
362
|
+
returnByValue: true,
|
|
363
|
+
});
|
|
364
|
+
return result.result.value;
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
logger_1.logger.debug('Failed to capture performance timings:', error);
|
|
368
|
+
// Performance capture is optional, so don't throw
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Get current page URL
|
|
374
|
+
*/
|
|
375
|
+
async getCurrentUrl() {
|
|
376
|
+
try {
|
|
377
|
+
const result = await this.client.send('Runtime.evaluate', {
|
|
378
|
+
expression: 'window.location.href',
|
|
379
|
+
returnByValue: true,
|
|
380
|
+
});
|
|
381
|
+
return result.result.value || 'about:blank';
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
logger_1.logger.debug('Failed to get current URL:', error);
|
|
385
|
+
return 'unknown';
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Get viewport dimensions
|
|
390
|
+
*/
|
|
391
|
+
async getViewport() {
|
|
392
|
+
try {
|
|
393
|
+
const result = await this.client.send('Runtime.evaluate', {
|
|
394
|
+
expression: `
|
|
395
|
+
(function() {
|
|
396
|
+
return {
|
|
397
|
+
width: window.innerWidth,
|
|
398
|
+
height: window.innerHeight
|
|
399
|
+
};
|
|
400
|
+
})()
|
|
401
|
+
`,
|
|
402
|
+
returnByValue: true,
|
|
403
|
+
});
|
|
404
|
+
return result.result.value || { width: 0, height: 0 };
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
logger_1.logger.debug('Failed to get viewport:', error);
|
|
408
|
+
return { width: 0, height: 0 };
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Capture Lighthouse audit (if available)
|
|
413
|
+
*/
|
|
414
|
+
async captureLighthouse() {
|
|
415
|
+
// Lighthouse capture is not implemented in CDP SDK
|
|
416
|
+
// This would require additional setup and dependencies
|
|
417
|
+
// Returning undefined for now
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
exports.CdpCapture = CdpCapture;
|
|
422
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/cdp/capture.ts"],"names":[],"mappings":";;;AACA,4CAAuD;AAEvD,6CAAqD;AAErD;;GAEG;AACH,MAAa,UAAU;IAGrB,YAAoB,MAAiB,EAAE,UAA+B,EAAE;QAApD,WAAM,GAAN,MAAM,CAAW;QACnC,qCAAqC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAA,qBAAY,EAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK,E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
|
1
|
+
import { Client } from 'chrome-remote-interface';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { CdpConnectionInfo } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Chrome DevTools Protocol client wrapper
|
|
6
|
+
*/
|
|
7
|
+
export declare class CdpClient extends EventEmitter {
|
|
8
|
+
private client;
|
|
9
|
+
private connectionInfo;
|
|
10
|
+
private isConnected;
|
|
11
|
+
private reconnectAttempts;
|
|
12
|
+
private maxReconnectAttempts;
|
|
13
|
+
private reconnectDelay;
|
|
14
|
+
/**
|
|
15
|
+
* Connect to Chrome DevTools Protocol
|
|
16
|
+
*/
|
|
17
|
+
connect(port?: number): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Disconnect from CDP
|
|
20
|
+
*/
|
|
21
|
+
disconnect(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if connected
|
|
24
|
+
*/
|
|
25
|
+
isClientConnected(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get the raw CDP client
|
|
28
|
+
*/
|
|
29
|
+
getClient(): Client | null;
|
|
30
|
+
/**
|
|
31
|
+
* Get connection info
|
|
32
|
+
*/
|
|
33
|
+
getConnectionInfo(): CdpConnectionInfo | null;
|
|
34
|
+
/**
|
|
35
|
+
* Enable a domain
|
|
36
|
+
*/
|
|
37
|
+
enableDomain(domain: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Send a command to CDP
|
|
40
|
+
*/
|
|
41
|
+
send<T = any>(method: string, params?: any): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Get available targets (tabs/pages)
|
|
44
|
+
*/
|
|
45
|
+
getTargets(): Promise<any[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Attach to a specific target
|
|
48
|
+
*/
|
|
49
|
+
attachToTarget(targetId: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Create a new tab
|
|
52
|
+
*/
|
|
53
|
+
createTarget(url?: string): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Close a target
|
|
56
|
+
*/
|
|
57
|
+
closeTarget(targetId: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Set up event listeners for specific domains
|
|
60
|
+
*/
|
|
61
|
+
setupEventListeners(): void;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cdp/client.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,qBAAa,SAAU,SAAQ,YAAY;IACzC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,oBAAoB,CAAK;IACjC,OAAO,CAAC,cAAc,CAAO;IAE7B;;OAEG;IACG,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgD3C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAejC;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;OAEG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B;;OAEG;IACH,iBAAiB,IAAI,iBAAiB,GAAG,IAAI;IAI7C;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcjD;;OAEG;IACG,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAe7D;;OAEG;IACG,UAAU,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