@dynamicu/chromedebug-mcp 2.2.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/CLAUDE.md +344 -0
- package/LICENSE +21 -0
- package/README.md +250 -0
- package/chrome-extension/README.md +41 -0
- package/chrome-extension/background.js +3917 -0
- package/chrome-extension/chrome-session-manager.js +706 -0
- package/chrome-extension/content.css +181 -0
- package/chrome-extension/content.js +3022 -0
- package/chrome-extension/data-buffer.js +435 -0
- package/chrome-extension/dom-tracker.js +411 -0
- package/chrome-extension/extension-config.js +78 -0
- package/chrome-extension/firebase-client.js +278 -0
- package/chrome-extension/firebase-config.js +32 -0
- package/chrome-extension/firebase-config.module.js +22 -0
- package/chrome-extension/firebase-config.module.template.js +27 -0
- package/chrome-extension/firebase-config.template.js +36 -0
- package/chrome-extension/frame-capture.js +407 -0
- package/chrome-extension/icon128.png +1 -0
- package/chrome-extension/icon16.png +1 -0
- package/chrome-extension/icon48.png +1 -0
- package/chrome-extension/license-helper.js +181 -0
- package/chrome-extension/logger.js +23 -0
- package/chrome-extension/manifest.json +73 -0
- package/chrome-extension/network-tracker.js +510 -0
- package/chrome-extension/offscreen.html +10 -0
- package/chrome-extension/options.html +203 -0
- package/chrome-extension/options.js +282 -0
- package/chrome-extension/pako.min.js +2 -0
- package/chrome-extension/performance-monitor.js +533 -0
- package/chrome-extension/pii-redactor.js +405 -0
- package/chrome-extension/popup.html +532 -0
- package/chrome-extension/popup.js +2446 -0
- package/chrome-extension/upload-manager.js +323 -0
- package/chrome-extension/web-vitals.iife.js +1 -0
- package/config/api-keys.json +11 -0
- package/config/chrome-pilot-config.json +45 -0
- package/package.json +126 -0
- package/scripts/cleanup-processes.js +109 -0
- package/scripts/config-manager.js +280 -0
- package/scripts/generate-extension-config.js +53 -0
- package/scripts/setup-security.js +64 -0
- package/src/capture/architecture.js +426 -0
- package/src/capture/error-handling-tests.md +38 -0
- package/src/capture/error-handling-types.ts +360 -0
- package/src/capture/index.js +508 -0
- package/src/capture/interfaces.js +625 -0
- package/src/capture/memory-manager.js +713 -0
- package/src/capture/types.js +342 -0
- package/src/chrome-controller.js +2658 -0
- package/src/cli.js +19 -0
- package/src/config-loader.js +303 -0
- package/src/database.js +2178 -0
- package/src/firebase-license-manager.js +462 -0
- package/src/firebase-privacy-guard.js +397 -0
- package/src/http-server.js +1516 -0
- package/src/index-direct.js +157 -0
- package/src/index-modular.js +219 -0
- package/src/index-monolithic-backup.js +2230 -0
- package/src/index.js +305 -0
- package/src/legacy/chrome-controller-old.js +1406 -0
- package/src/legacy/index-express.js +625 -0
- package/src/legacy/index-old.js +977 -0
- package/src/legacy/routes.js +260 -0
- package/src/legacy/shared-storage.js +101 -0
- package/src/logger.js +10 -0
- package/src/mcp/handlers/chrome-tool-handler.js +306 -0
- package/src/mcp/handlers/element-tool-handler.js +51 -0
- package/src/mcp/handlers/frame-tool-handler.js +957 -0
- package/src/mcp/handlers/request-handler.js +104 -0
- package/src/mcp/handlers/workflow-tool-handler.js +636 -0
- package/src/mcp/server.js +68 -0
- package/src/mcp/tools/index.js +701 -0
- package/src/middleware/auth.js +371 -0
- package/src/middleware/security.js +267 -0
- package/src/port-discovery.js +258 -0
- package/src/routes/admin.js +182 -0
- package/src/services/browser-daemon.js +494 -0
- package/src/services/chrome-service.js +375 -0
- package/src/services/failover-manager.js +412 -0
- package/src/services/git-safety-service.js +675 -0
- package/src/services/heartbeat-manager.js +200 -0
- package/src/services/http-client.js +195 -0
- package/src/services/process-manager.js +318 -0
- package/src/services/process-tracker.js +574 -0
- package/src/services/profile-manager.js +449 -0
- package/src/services/project-manager.js +415 -0
- package/src/services/session-manager.js +497 -0
- package/src/services/session-registry.js +491 -0
- package/src/services/unified-session-manager.js +678 -0
- package/src/shared-storage-old.js +267 -0
- package/src/standalone-server.js +53 -0
- package/src/utils/extension-path.js +145 -0
- package/src/utils.js +187 -0
- package/src/validation/log-transformer.js +125 -0
- package/src/validation/schemas.js +391 -0
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Interaction Capture System - Main Entry Point
|
|
3
|
+
*
|
|
4
|
+
* This module provides the complete unified interaction capture system
|
|
5
|
+
* that replaces the legacy frame recording, workflow recording, and
|
|
6
|
+
* function tracing systems.
|
|
7
|
+
*
|
|
8
|
+
* WHAT THIS SYSTEM PROVIDES:
|
|
9
|
+
* ==========================
|
|
10
|
+
* • Unified data format for all interaction types
|
|
11
|
+
* • Modular architecture enabling parallel development
|
|
12
|
+
* • Memory-efficient capture and storage
|
|
13
|
+
* • High-performance processing pipelines
|
|
14
|
+
* • Extensible design for future capture types
|
|
15
|
+
* • Chrome extension compatibility
|
|
16
|
+
* • Database-optimized storage
|
|
17
|
+
* • Rich query and analysis capabilities
|
|
18
|
+
*
|
|
19
|
+
* SYSTEM ARCHITECTURE:
|
|
20
|
+
* ====================
|
|
21
|
+
*
|
|
22
|
+
* 1. CAPTURE SOURCES: Generate interaction events
|
|
23
|
+
* - Chrome Extension: Screen captures, user interactions, console logs
|
|
24
|
+
* - Puppeteer: DOM snapshots, network traffic, browser state
|
|
25
|
+
* - DevTools: Function traces, performance data, debugging info
|
|
26
|
+
*
|
|
27
|
+
* 2. CAPTURE COLLECTOR: Route and coordinate events
|
|
28
|
+
* - Event routing from sources to processors
|
|
29
|
+
* - Flow control and backpressure management
|
|
30
|
+
* - Source lifecycle management
|
|
31
|
+
*
|
|
32
|
+
* 3. CAPTURE PROCESSORS: Transform and enrich events
|
|
33
|
+
* - Filter out unwanted events
|
|
34
|
+
* - Compress large data (images, DOM)
|
|
35
|
+
* - Enrich with metadata and context
|
|
36
|
+
* - Format for storage optimization
|
|
37
|
+
*
|
|
38
|
+
* 4. CAPTURE STORAGE: Persist events efficiently
|
|
39
|
+
* - Database for metadata and small events
|
|
40
|
+
* - File system for large binary data
|
|
41
|
+
* - Memory cache for recent events
|
|
42
|
+
* - Network storage for backup/sync
|
|
43
|
+
*
|
|
44
|
+
* 5. CAPTURE QUERY: Search and retrieve events
|
|
45
|
+
* - Filter by type, time, session, etc.
|
|
46
|
+
* - Full-text search across event data
|
|
47
|
+
* - Pagination and streaming for large results
|
|
48
|
+
* - Performance-optimized queries
|
|
49
|
+
*
|
|
50
|
+
* 6. CAPTURE ANALYZER: Extract insights and patterns
|
|
51
|
+
* - User interaction patterns
|
|
52
|
+
* - Performance bottlenecks
|
|
53
|
+
* - Error detection and analysis
|
|
54
|
+
* - Session summaries and comparisons
|
|
55
|
+
*
|
|
56
|
+
* MIGRATION FROM LEGACY SYSTEMS:
|
|
57
|
+
* ===============================
|
|
58
|
+
*
|
|
59
|
+
* LEGACY FRAME RECORDING → UNIFIED SCREEN EVENTS:
|
|
60
|
+
* • Frame data becomes ScreenCaptureData events
|
|
61
|
+
* • Console logs become ConsoleCaptureData events
|
|
62
|
+
* • Maintains existing screenshot and logging functionality
|
|
63
|
+
* • Adds support for element-specific captures
|
|
64
|
+
*
|
|
65
|
+
* LEGACY WORKFLOW RECORDING → UNIFIED USER EVENTS:
|
|
66
|
+
* • User actions become UserInteractionData events
|
|
67
|
+
* • DOM snapshots become DOMCaptureData events
|
|
68
|
+
* • Restore points become StateChangeData events
|
|
69
|
+
* • Maintains existing replay functionality
|
|
70
|
+
*
|
|
71
|
+
* LEGACY FUNCTION TRACING → UNIFIED FUNCTION EVENTS:
|
|
72
|
+
* • Function calls become FunctionTraceData events
|
|
73
|
+
* • Execution traces maintain same detail level
|
|
74
|
+
* • Adds support for async function tracking
|
|
75
|
+
* • Better correlation with other event types
|
|
76
|
+
*
|
|
77
|
+
* KEY BENEFITS:
|
|
78
|
+
* =============
|
|
79
|
+
*
|
|
80
|
+
* 1. UNIFIED FORMAT: Single consistent data structure for all events
|
|
81
|
+
* 2. BETTER CORRELATION: Events can be correlated across different types
|
|
82
|
+
* 3. IMPROVED PERFORMANCE: Optimized storage and memory management
|
|
83
|
+
* 4. EXTENSIBILITY: Easy to add new capture types without breaking changes
|
|
84
|
+
* 5. MODULARITY: Independent development and testing of components
|
|
85
|
+
* 6. CHROME COMPATIBILITY: Designed for Chrome extension constraints
|
|
86
|
+
* 7. MEMORY EFFICIENCY: Smart memory management with size-based optimization
|
|
87
|
+
* 8. ANALYTICS: Rich analysis capabilities across all interaction types
|
|
88
|
+
*
|
|
89
|
+
* USAGE EXAMPLES:
|
|
90
|
+
* ===============
|
|
91
|
+
*
|
|
92
|
+
* // Basic system setup
|
|
93
|
+
* import { CaptureSystem } from './capture/index.js';
|
|
94
|
+
*
|
|
95
|
+
* const system = new CaptureSystem();
|
|
96
|
+
* await system.initialize({
|
|
97
|
+
* sources: ['chrome-extension', 'puppeteer'],
|
|
98
|
+
* storage: 'sqlite',
|
|
99
|
+
* memoryLimitMB: 100
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* // Start capture session
|
|
103
|
+
* const session = await system.startSession({
|
|
104
|
+
* name: 'User Journey Test',
|
|
105
|
+
* captureTypes: ['screen', 'user', 'console'],
|
|
106
|
+
* config: {
|
|
107
|
+
* screenshots: { quality: 80, interval: 1000 },
|
|
108
|
+
* userEvents: { includeHover: true }
|
|
109
|
+
* }
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* // Query captured events
|
|
113
|
+
* const events = await system.query.queryEvents({
|
|
114
|
+
* sessionId: session.id,
|
|
115
|
+
* type: 'user',
|
|
116
|
+
* timeRange: { start: Date.now() - 60000, end: Date.now() }
|
|
117
|
+
* });
|
|
118
|
+
*
|
|
119
|
+
* // Analyze session
|
|
120
|
+
* const analysis = await system.analyzer.generateSummary(session.id);
|
|
121
|
+
*
|
|
122
|
+
* // Stop and cleanup
|
|
123
|
+
* await system.stopSession();
|
|
124
|
+
* await system.shutdown();
|
|
125
|
+
*
|
|
126
|
+
* IMPLEMENTATION ROADMAP:
|
|
127
|
+
* =======================
|
|
128
|
+
*
|
|
129
|
+
* PHASE 1: Foundation (THIS DELIVERABLE)
|
|
130
|
+
* • Core data types and interfaces ✓
|
|
131
|
+
* • Module architecture design ✓
|
|
132
|
+
* • Memory management strategy ✓
|
|
133
|
+
* • Data flow architecture ✓
|
|
134
|
+
*
|
|
135
|
+
* PHASE 2: Core Implementation
|
|
136
|
+
* • Basic SQLite storage implementation
|
|
137
|
+
* • Memory buffer and batch processor
|
|
138
|
+
* • Simple query engine
|
|
139
|
+
* • Basic Chrome extension source
|
|
140
|
+
*
|
|
141
|
+
* PHASE 3: Processing Pipeline
|
|
142
|
+
* • Event filtering and transformation
|
|
143
|
+
* • Compression processors
|
|
144
|
+
* • Error handling and recovery
|
|
145
|
+
* • Performance optimization
|
|
146
|
+
*
|
|
147
|
+
* PHASE 4: Advanced Features
|
|
148
|
+
* • Full-text search capabilities
|
|
149
|
+
* • Advanced analytics and insights
|
|
150
|
+
* • Real-time streaming support
|
|
151
|
+
* • Network storage and sync
|
|
152
|
+
*
|
|
153
|
+
* PHASE 5: Migration & Integration
|
|
154
|
+
* • Legacy system compatibility layer
|
|
155
|
+
* • Data migration tools
|
|
156
|
+
* • MCP tool integration
|
|
157
|
+
* • Production deployment
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
// Export core types and interfaces
|
|
161
|
+
export * from './types.js';
|
|
162
|
+
export * from './interfaces.js';
|
|
163
|
+
export * from './architecture.js';
|
|
164
|
+
export * from './memory-manager.js';
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Factory function to create a complete capture system
|
|
168
|
+
* @param {Object} config - System configuration
|
|
169
|
+
* @returns {Promise<ICaptureSystem>} Configured capture system
|
|
170
|
+
*/
|
|
171
|
+
export async function createCaptureSystem(config = {}) {
|
|
172
|
+
const { CaptureSystem } = await import('./implementations/capture-system.js');
|
|
173
|
+
const system = new CaptureSystem();
|
|
174
|
+
await system.initialize(config);
|
|
175
|
+
return system;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Factory function to create storage implementation
|
|
180
|
+
* @param {string} type - Storage type ('sqlite', 'memory', 'filesystem')
|
|
181
|
+
* @param {Object} config - Storage configuration
|
|
182
|
+
* @returns {Promise<ICaptureStorage>} Storage implementation
|
|
183
|
+
*/
|
|
184
|
+
export async function createStorage(type = 'sqlite', config = {}) {
|
|
185
|
+
switch (type) {
|
|
186
|
+
case 'sqlite': {
|
|
187
|
+
const { SQLiteCaptureStorage } = await import('./implementations/sqlite-storage.js');
|
|
188
|
+
const storage = new SQLiteCaptureStorage();
|
|
189
|
+
await storage.initialize(config);
|
|
190
|
+
return storage;
|
|
191
|
+
}
|
|
192
|
+
case 'memory': {
|
|
193
|
+
const { MemoryCaptureStorage } = await import('./implementations/memory-storage.js');
|
|
194
|
+
const storage = new MemoryCaptureStorage();
|
|
195
|
+
await storage.initialize(config);
|
|
196
|
+
return storage;
|
|
197
|
+
}
|
|
198
|
+
case 'filesystem': {
|
|
199
|
+
const { FileSystemCaptureStorage } = await import('./implementations/filesystem-storage.js');
|
|
200
|
+
const storage = new FileSystemCaptureStorage();
|
|
201
|
+
await storage.initialize(config);
|
|
202
|
+
return storage;
|
|
203
|
+
}
|
|
204
|
+
default:
|
|
205
|
+
throw new Error(`Unknown storage type: ${type}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Factory function to create Chrome extension source
|
|
211
|
+
* @param {Object} config - Source configuration
|
|
212
|
+
* @returns {Promise<ICaptureSource>} Chrome extension source
|
|
213
|
+
*/
|
|
214
|
+
export async function createChromeExtensionSource(config = {}) {
|
|
215
|
+
const { ChromeExtensionCaptureSource } = await import('./implementations/chrome-extension-source.js');
|
|
216
|
+
const source = new ChromeExtensionCaptureSource();
|
|
217
|
+
await source.initialize(config);
|
|
218
|
+
return source;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Factory function to create Puppeteer source
|
|
223
|
+
* @param {Object} config - Source configuration
|
|
224
|
+
* @returns {Promise<ICaptureSource>} Puppeteer source
|
|
225
|
+
*/
|
|
226
|
+
export async function createPuppeteerSource(config = {}) {
|
|
227
|
+
const { PuppeteerCaptureSource } = await import('./implementations/puppeteer-source.js');
|
|
228
|
+
const source = new PuppeteerCaptureSource();
|
|
229
|
+
await source.initialize(config);
|
|
230
|
+
return source;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Utility function to validate capture event
|
|
235
|
+
* @param {CaptureEvent} event - Event to validate
|
|
236
|
+
* @returns {boolean} True if valid
|
|
237
|
+
*/
|
|
238
|
+
export function validateCaptureEvent(event) {
|
|
239
|
+
const { CAPTURE_TYPES, EVENT_DATA_TYPES } = require('./types.js');
|
|
240
|
+
|
|
241
|
+
if (!event || typeof event !== 'object') {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Check required fields
|
|
246
|
+
const requiredFields = ['id', 'sessionId', 'sequence', 'timestamp', 'type', 'data'];
|
|
247
|
+
for (const field of requiredFields) {
|
|
248
|
+
if (!(field in event)) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Check event type
|
|
254
|
+
if (!Object.values(CAPTURE_TYPES).includes(event.type)) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Check timestamp format
|
|
259
|
+
if (!event.timestamp.relative || !event.timestamp.absolute) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Check data structure based on type
|
|
264
|
+
const expectedDataType = EVENT_DATA_TYPES[event.type];
|
|
265
|
+
if (expectedDataType && event.data) {
|
|
266
|
+
// Basic validation - could be extended with JSON schema
|
|
267
|
+
return typeof event.data === 'object';
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Utility function to estimate event memory usage
|
|
275
|
+
* @param {CaptureEvent} event - Event to estimate
|
|
276
|
+
* @returns {number} Estimated bytes
|
|
277
|
+
*/
|
|
278
|
+
export function estimateEventMemoryUsage(event) {
|
|
279
|
+
if (!event) return 0;
|
|
280
|
+
|
|
281
|
+
let size = 0;
|
|
282
|
+
|
|
283
|
+
// Base event structure
|
|
284
|
+
size += JSON.stringify({
|
|
285
|
+
id: event.id,
|
|
286
|
+
sessionId: event.sessionId,
|
|
287
|
+
sequence: event.sequence,
|
|
288
|
+
timestamp: event.timestamp,
|
|
289
|
+
type: event.type,
|
|
290
|
+
subtype: event.subtype,
|
|
291
|
+
pageId: event.pageId,
|
|
292
|
+
url: event.url,
|
|
293
|
+
metadata: event.metadata
|
|
294
|
+
}).length;
|
|
295
|
+
|
|
296
|
+
// Event data size
|
|
297
|
+
if (event.data) {
|
|
298
|
+
switch (event.type) {
|
|
299
|
+
case 'screen':
|
|
300
|
+
// Image data is typically the largest
|
|
301
|
+
if (event.data.imageData) {
|
|
302
|
+
size += event.data.imageData.length;
|
|
303
|
+
}
|
|
304
|
+
break;
|
|
305
|
+
|
|
306
|
+
case 'dom':
|
|
307
|
+
// HTML content size
|
|
308
|
+
if (event.data.html) {
|
|
309
|
+
size += event.data.html.length;
|
|
310
|
+
}
|
|
311
|
+
if (event.data.styles) {
|
|
312
|
+
size += JSON.stringify(event.data.styles).length;
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
|
|
316
|
+
default:
|
|
317
|
+
// For other types, estimate JSON size
|
|
318
|
+
size += JSON.stringify(event.data).length;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return size;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Utility function to create a new capture event
|
|
327
|
+
* @param {Object} options - Event options
|
|
328
|
+
* @returns {CaptureEvent} Created event
|
|
329
|
+
*/
|
|
330
|
+
export function createCaptureEvent(options) {
|
|
331
|
+
const { CaptureEvent, TimestampInfo } = require('./types.js');
|
|
332
|
+
|
|
333
|
+
const now = Date.now();
|
|
334
|
+
const perfNow = performance.now();
|
|
335
|
+
|
|
336
|
+
return {
|
|
337
|
+
...CaptureEvent,
|
|
338
|
+
id: options.id || `evt_${now}_${Math.random().toString(36).substr(2, 9)}`,
|
|
339
|
+
sessionId: options.sessionId || '',
|
|
340
|
+
sequence: options.sequence || 0,
|
|
341
|
+
timestamp: {
|
|
342
|
+
...TimestampInfo,
|
|
343
|
+
relative: options.relativeTime || perfNow,
|
|
344
|
+
absolute: options.absoluteTime || now,
|
|
345
|
+
performance: perfNow
|
|
346
|
+
},
|
|
347
|
+
type: options.type || '',
|
|
348
|
+
subtype: options.subtype || '',
|
|
349
|
+
pageId: options.pageId || '',
|
|
350
|
+
url: options.url || '',
|
|
351
|
+
data: options.data || {},
|
|
352
|
+
metadata: {
|
|
353
|
+
tags: options.tags || [],
|
|
354
|
+
source: options.source || '',
|
|
355
|
+
priority: options.priority || 'normal',
|
|
356
|
+
sizeHint: options.sizeHint || 'small',
|
|
357
|
+
...options.metadata
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Development utilities for testing and debugging
|
|
364
|
+
*/
|
|
365
|
+
export const DevUtils = {
|
|
366
|
+
/**
|
|
367
|
+
* Create mock capture events for testing
|
|
368
|
+
* @param {number} count - Number of events to create
|
|
369
|
+
* @param {Object} options - Event options
|
|
370
|
+
* @returns {CaptureEvent[]} Mock events
|
|
371
|
+
*/
|
|
372
|
+
createMockEvents(count = 10, options = {}) {
|
|
373
|
+
const events = [];
|
|
374
|
+
const sessionId = options.sessionId || `session_${Date.now()}`;
|
|
375
|
+
const types = options.types || ['screen', 'user', 'console'];
|
|
376
|
+
|
|
377
|
+
for (let i = 0; i < count; i++) {
|
|
378
|
+
const type = types[i % types.length];
|
|
379
|
+
events.push(createCaptureEvent({
|
|
380
|
+
sessionId,
|
|
381
|
+
sequence: i,
|
|
382
|
+
type,
|
|
383
|
+
relativeTime: i * 1000,
|
|
384
|
+
data: this.createMockData(type),
|
|
385
|
+
...options
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return events;
|
|
390
|
+
},
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Create mock data for event type
|
|
394
|
+
* @param {string} type - Event type
|
|
395
|
+
* @returns {Object} Mock data
|
|
396
|
+
*/
|
|
397
|
+
createMockData(type) {
|
|
398
|
+
switch (type) {
|
|
399
|
+
case 'screen':
|
|
400
|
+
return {
|
|
401
|
+
imageData: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/',
|
|
402
|
+
format: 'jpeg',
|
|
403
|
+
width: 1920,
|
|
404
|
+
height: 1080,
|
|
405
|
+
quality: 80,
|
|
406
|
+
viewport: { x: 0, y: 0, width: 1920, height: 1080, scale: 1.0 }
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
case 'user':
|
|
410
|
+
return {
|
|
411
|
+
action: 'click',
|
|
412
|
+
target: {
|
|
413
|
+
selector: '#submit-button',
|
|
414
|
+
tagName: 'BUTTON',
|
|
415
|
+
text: 'Submit',
|
|
416
|
+
attributes: { type: 'submit', class: 'btn btn-primary' },
|
|
417
|
+
bounds: { x: 100, y: 200, width: 120, height: 40 }
|
|
418
|
+
},
|
|
419
|
+
coordinates: { x: 160, y: 220 },
|
|
420
|
+
modifiers: [],
|
|
421
|
+
duration: 150
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
case 'console':
|
|
425
|
+
return {
|
|
426
|
+
level: 'info',
|
|
427
|
+
message: 'Mock console message',
|
|
428
|
+
args: ['Mock', 'console', 'message'],
|
|
429
|
+
source: { file: 'test.js', line: 42, column: 10 },
|
|
430
|
+
method: 'log'
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
default:
|
|
434
|
+
return { mockData: true, type };
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Performance test helper
|
|
440
|
+
* @param {Function} fn - Function to test
|
|
441
|
+
* @param {number} iterations - Number of iterations
|
|
442
|
+
* @returns {Object} Performance results
|
|
443
|
+
*/
|
|
444
|
+
async performanceTest(fn, iterations = 1000) {
|
|
445
|
+
const start = performance.now();
|
|
446
|
+
const results = [];
|
|
447
|
+
|
|
448
|
+
for (let i = 0; i < iterations; i++) {
|
|
449
|
+
const iterStart = performance.now();
|
|
450
|
+
await fn(i);
|
|
451
|
+
const iterEnd = performance.now();
|
|
452
|
+
results.push(iterEnd - iterStart);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const end = performance.now();
|
|
456
|
+
const total = end - start;
|
|
457
|
+
const avg = results.reduce((a, b) => a + b, 0) / results.length;
|
|
458
|
+
const min = Math.min(...results);
|
|
459
|
+
const max = Math.max(...results);
|
|
460
|
+
|
|
461
|
+
return {
|
|
462
|
+
total,
|
|
463
|
+
average: avg,
|
|
464
|
+
min,
|
|
465
|
+
max,
|
|
466
|
+
iterations,
|
|
467
|
+
opsPerSecond: iterations / (total / 1000)
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Version and metadata
|
|
474
|
+
*/
|
|
475
|
+
export const META = {
|
|
476
|
+
version: '1.0.0',
|
|
477
|
+
name: 'Unified Interaction Capture System',
|
|
478
|
+
description: 'Modular capture system replacing legacy frame, workflow, and function recording',
|
|
479
|
+
architecture: 'event-driven modular pipeline',
|
|
480
|
+
compatibility: {
|
|
481
|
+
chrome: '>=90',
|
|
482
|
+
node: '>=14',
|
|
483
|
+
databases: ['sqlite', 'postgresql', 'mongodb'],
|
|
484
|
+
storage: ['filesystem', 'memory', 's3', 'gcs']
|
|
485
|
+
},
|
|
486
|
+
features: [
|
|
487
|
+
'unified-event-format',
|
|
488
|
+
'modular-architecture',
|
|
489
|
+
'memory-optimization',
|
|
490
|
+
'chrome-extension-support',
|
|
491
|
+
'real-time-processing',
|
|
492
|
+
'advanced-analytics',
|
|
493
|
+
'extensible-design',
|
|
494
|
+
'performance-optimized'
|
|
495
|
+
]
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
export default {
|
|
499
|
+
createCaptureSystem,
|
|
500
|
+
createStorage,
|
|
501
|
+
createChromeExtensionSource,
|
|
502
|
+
createPuppeteerSource,
|
|
503
|
+
validateCaptureEvent,
|
|
504
|
+
estimateEventMemoryUsage,
|
|
505
|
+
createCaptureEvent,
|
|
506
|
+
DevUtils,
|
|
507
|
+
META
|
|
508
|
+
};
|