ai-debug-local-mcp
Version:
🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh
786 lines • 33.8 kB
JavaScript
import { LogTruncator } from './log-truncator.js';
import { ProblemDebugEngine } from './problem-debug-engine.js';
import { JavaScriptExecutionEngine } from './javascript-execution-engine.js';
import { AsyncTrackingEngine } from './async-tracking-engine.js';
import { JavaScriptErrorDetectionEngine } from './javascript-error-detection-engine.js';
import { JavaScriptAnalysisCoordinator } from './local-debug-engine/javascript-analysis-coordinator.js';
import { FlutterAnalysisCoordinator } from './local-debug-engine/flutter-analysis-coordinator.js';
import { UserActionCoordinator } from './local-debug-engine/user-action-coordinator.js';
import { DebugSessionCoordinator } from './local-debug-engine/debug-session-coordinator.js';
import { NetworkCoordinator } from './local-debug-engine/network-coordinator.js';
import { ReactStateEngine } from './react-state-engine.js';
import { DatabaseTraceEngine } from './database-trace-engine.js';
import { BrowserPermissionHandler } from './browser-permission-handler.js';
import { BrowserManager } from './local-debug-engine/browser-manager.js';
import { EventCollector } from './local-debug-engine/event-collector.js';
import { StateCapture } from './local-debug-engine/state-capture.js';
import { FrameworkDetector } from './local-debug-engine/framework-detector.js';
import { DebugInjector } from './local-debug-engine/debug-injector.js';
import { EventMonitor } from './local-debug-engine/event-monitor.js';
import { ReactStateCoordinator } from './local-debug-engine/react-state-coordinator.js';
import { ElementInspectionCoordinator } from './local-debug-engine/element-inspection-coordinator.js';
import { PerformanceCoordinator } from './local-debug-engine/performance-coordinator.js';
export class LocalDebugEngine {
browser;
page;
browserManager;
eventCollector;
stateCapture;
frameworkDetector;
debugInjector;
eventMonitor;
flutterEngine; // Lazy loaded
flutterEnhancedEngine; // Lazy loaded
problemEngine;
nextjsEngine; // Lazy loaded
nextjsEnhancedEngine; // Lazy loaded
serverFrameworkEngine; // Lazy loaded
metaFrameworkEngine; // Lazy loaded
tidewaveIntegration; // Lazy loaded
tidewaveCapabilities;
jsExecutionEngine;
asyncTrackingEngine;
jsErrorDetectionEngine;
jsAnalysisCoordinator;
flutterAnalysisCoordinator;
userActionCoordinator;
debugSessionCoordinator;
networkCoordinator;
reactStateCoordinator;
elementInspectionCoordinator;
performanceCoordinator;
reactStateEngine;
databaseTraceEngine; // Lazy loaded
constructor() {
this.browserManager = new BrowserManager();
this.eventCollector = new EventCollector();
this.problemEngine = new ProblemDebugEngine();
this.jsExecutionEngine = new JavaScriptExecutionEngine();
this.asyncTrackingEngine = new AsyncTrackingEngine();
this.jsErrorDetectionEngine = new JavaScriptErrorDetectionEngine();
this.jsAnalysisCoordinator = new JavaScriptAnalysisCoordinator(this.jsExecutionEngine, this.asyncTrackingEngine, this.jsErrorDetectionEngine);
this.reactStateEngine = new ReactStateEngine();
this.databaseTraceEngine = new DatabaseTraceEngine();
// Initialize StateCapture with engine dependencies
this.stateCapture = new StateCapture(this.reactStateEngine, this.jsExecutionEngine, undefined // flutterEnhancedEngine - will be set when Flutter is detected
);
// Initialize FrameworkDetector with required dependencies
this.frameworkDetector = new FrameworkDetector(this.reactStateEngine, this.jsExecutionEngine, this.stateCapture);
// Initialize FlutterAnalysisCoordinator (engines will be set during framework detection)
this.flutterAnalysisCoordinator = new FlutterAnalysisCoordinator(null, // flutterEngine - will be set when Flutter is detected
null, // flutterEnhancedEngine - will be set when Flutter is detected
this.stateCapture);
// Initialize UserActionCoordinator
this.userActionCoordinator = new UserActionCoordinator();
// Initialize NetworkCoordinator
this.networkCoordinator = new NetworkCoordinator();
// Initialize ReactStateCoordinator
this.reactStateCoordinator = new ReactStateCoordinator(this.reactStateEngine, this.stateCapture, this.networkCoordinator);
// Initialize ElementInspectionCoordinator
this.elementInspectionCoordinator = new ElementInspectionCoordinator();
// Initialize PerformanceCoordinator
this.performanceCoordinator = new PerformanceCoordinator(this.networkCoordinator, this.jsAnalysisCoordinator, this.flutterAnalysisCoordinator
// nextjsEnhancedEngine will be passed when available
);
// Initialize DebugInjector
this.debugInjector = new DebugInjector();
// Initialize DebugSessionCoordinator
this.debugSessionCoordinator = new DebugSessionCoordinator(this.stateCapture, this.debugInjector, this.frameworkDetector);
// Initialize EventMonitor with required dependencies
this.eventMonitor = new EventMonitor(this.eventCollector, this.databaseTraceEngine);
// Set up event handlers to bridge BrowserManager with EventCollector
this.setupBrowserManagerHandlers();
}
/**
* Set up event handlers to bridge BrowserManager events with existing data collection
*/
setupBrowserManagerHandlers() {
// Console message handler - delegate to EventCollector
this.browserManager.onConsoleMessage((message) => {
this.eventCollector.addConsoleMessage(message);
});
// Request handler - delegate to EventCollector
this.browserManager.onRequest(async (request) => {
this.eventCollector.addNetworkRequest(request);
});
// Response handler - delegate to EventCollector with response processing
this.browserManager.onResponse(async (response) => {
let responseBody = null;
let responseSize = 0;
try {
// Only capture body for relevant content types
const contentType = response.headers()['content-type'] || '';
if (contentType.includes('json') ||
contentType.includes('text') ||
contentType.includes('html') ||
contentType.includes('xml')) {
const body = await response.body();
responseBody = body.toString('utf-8');
responseSize = body.length;
// Try to parse JSON responses
if (contentType.includes('json')) {
try {
responseBody = JSON.parse(responseBody);
}
catch (e) {
// Keep as string if not valid JSON
}
}
}
}
catch (e) {
// Some responses may not have accessible body
}
this.eventCollector.updateNetworkRequest(response, responseBody, responseSize);
});
}
async attachToPage(page) {
this.page = page;
// Delegate browser management to BrowserManager
await this.browserManager.attachToPage(page);
// Coordinate core session attachment through DebugSessionCoordinator
await this.debugSessionCoordinator.attachToPage(page);
// Set up UserActionCoordinator with current page
this.userActionCoordinator.setPage(page);
// Set up NetworkCoordinator with current page
await this.networkCoordinator.setupNetworkMonitoring(page);
// Set up ElementInspectionCoordinator with current page
await this.elementInspectionCoordinator.attachToPage(page);
// Set up browser permissions handling for all frameworks
await BrowserPermissionHandler.configurePermissions(page, {
permissions: ['geolocation', 'notifications', 'camera', 'microphone', 'clipboard-read'],
geolocation: { latitude: 40.7128, longitude: -74.0060 }, // New York by default
autoAcceptDialogs: true
});
// Attach problem detection engine with reference to this engine
await this.problemEngine.attachToPage(page, this);
// Attach JavaScript analysis coordinator (handles all JS engines)
await this.jsAnalysisCoordinator.attachToPage(page, page.context());
// Attach React state engine
await this.reactStateEngine.attach(page);
// Attach database trace engine
await this.databaseTraceEngine.attach(page);
// Start automatic error detection through coordinator
await this.jsAnalysisCoordinator.startMonitoring();
}
async captureState() {
return await this.debugSessionCoordinator.captureSessionState();
}
async captureDOMSnapshot() {
return await this.debugSessionCoordinator.captureDOMSnapshot();
}
async injectDebuggingCode(code) {
if (!this.page) {
throw new Error('No page attached');
}
return await this.debugSessionCoordinator.injectDebuggingCode(this.page, code);
}
async inspectElement(selector) {
return await this.elementInspectionCoordinator.inspectElement(selector);
}
// Additional element inspection methods for enhanced functionality
async inspectMultipleElements(selectors) {
return await this.elementInspectionCoordinator.inspectMultipleElements(selectors);
}
async elementExists(selector) {
return await this.elementInspectionCoordinator.elementExists(selector);
}
async isElementVisible(selector) {
return await this.elementInspectionCoordinator.isElementVisible(selector);
}
async getElementCount(selector) {
return await this.elementInspectionCoordinator.getElementCount(selector);
}
async getElementAttributes(selector) {
return await this.elementInspectionCoordinator.getElementAttributes(selector);
}
async getComputedStyles(selector, properties) {
return await this.elementInspectionCoordinator.getComputedStyles(selector, properties);
}
async getElementBounds(selector) {
return await this.elementInspectionCoordinator.getElementBounds(selector);
}
async findAllElements(selector) {
return await this.elementInspectionCoordinator.findAllElements(selector);
}
async simulateUserAction(action, selector, value) {
// Delegate to UserActionCoordinator
return await this.userActionCoordinator.simulateUserAction(action, selector, value);
}
getConsoleMessages(filter) {
// Get messages from EventCollector, but preserve LogTruncator logic
let messages = this.eventCollector.getConsoleMessages({
type: filter?.type,
since: filter?.since
});
// Apply intelligent truncation if needed (preserving existing LogTruncator logic)
if (filter?.maxTokens) {
// First try grouping similar messages
messages = LogTruncator.groupSimilarLogs(messages);
// Then truncate to fit token limit
messages = LogTruncator.truncateLogs(messages, {
maxTokens: filter.maxTokens,
preserveLatest: true,
prioritizeErrors: true
});
}
return messages;
}
getNetworkRequests(filter) {
// Delegate to EventMonitor module for backward compatibility
return this.eventMonitor.getNetworkRequests(filter);
}
// New NetworkCoordinator delegation methods
getCapturedNetworkRequests() {
return this.networkCoordinator.getCapturedRequests();
}
getCapturedNetworkResponses() {
return this.networkCoordinator.getCapturedResponses();
}
getNetworkErrors() {
return this.networkCoordinator.getNetworkErrors();
}
getNetworkMetrics() {
return this.performanceCoordinator.getNetworkMetrics();
}
generateNetworkReport() {
return this.networkCoordinator.generateNetworkReport();
}
async findReactComponents() {
return await this.reactStateCoordinator.findReactComponents();
}
async findPhoenixLiveViewState() {
return await this.debugSessionCoordinator.findPhoenixLiveViewState();
}
async detectFramework(page) {
this.page = page;
// Delegate to FrameworkDetector module
const result = await this.frameworkDetector.detectFramework(page);
// Update engine references from the detector
const engines = this.frameworkDetector.getEngines();
this.metaFrameworkEngine = engines.metaFrameworkEngine;
this.nextjsEngine = engines.nextjsEngine;
this.nextjsEnhancedEngine = engines.nextjsEnhancedEngine;
this.serverFrameworkEngine = engines.serverFrameworkEngine;
this.flutterEngine = engines.flutterEngine;
this.flutterEnhancedEngine = engines.flutterEnhancedEngine;
// Update FlutterAnalysisCoordinator with detected engines
this.flutterAnalysisCoordinator.setEngines(this.flutterEngine || null, this.flutterEnhancedEngine || null);
// Update PerformanceCoordinator with detected Next.js engine
if (this.nextjsEnhancedEngine) {
this.performanceCoordinator.setNextJSEngine(this.nextjsEnhancedEngine);
}
// Update UserActionCoordinator with Flutter enhanced engine if available
if (this.flutterEnhancedEngine) {
this.userActionCoordinator.setFlutterEnhancedEngine(this.flutterEnhancedEngine);
}
return result.framework;
}
async injectDebugging(page, framework) {
this.page = page;
// Delegate to DebugSessionCoordinator
return await this.debugSessionCoordinator.injectFrameworkDebugging(page, framework);
}
async monitorEvents(page, duration) {
// Delegate to EventMonitor module
return await this.eventMonitor.monitorEvents(page, duration);
}
basicAnalysis(events) {
// Delegate to EventMonitor module
return this.eventMonitor.basicAnalysis(events);
}
async simulateAction(page, action, selector, value, coordinates) {
// Delegate to UserActionCoordinator
return await this.userActionCoordinator.simulateAction(page, action, selector, value, coordinates);
}
async captureRecentEvents(page, duration) {
// Delegate to EventMonitor module
return await this.eventMonitor.captureRecentEvents(page, duration);
}
async extractPageState(page) {
return await this.debugSessionCoordinator.extractPageState(page);
}
generateBasicReport(session) {
// Delegate to EventMonitor module
return this.eventMonitor.generateBasicReport(session);
}
async addNetworkMock(urlPattern, response) {
this.browserManager.addMockResponse(urlPattern, {
status: response.status || 200,
body: response.body || {},
headers: response.headers,
delay: response.delay
});
}
removeNetworkMock(urlPattern) {
this.browserManager.removeMockResponse(urlPattern);
return true; // BrowserManager doesn't return boolean, so we assume success
}
clearAllMocks() {
this.browserManager.clearMockResponses();
}
getMockedUrls() {
// BrowserManager doesn't expose the keys, so we return empty array
// This method might need enhancement in BrowserManager if detailed tracking is needed
return [];
}
// Flutter-specific methods
async getFlutterWidgetTree() {
return await this.flutterAnalysisCoordinator.getFlutterWidgetTree();
}
async getFlutterPerformance() {
return await this.performanceCoordinator.getFlutterPerformance();
}
async inspectFlutterWidget(widgetId) {
return await this.flutterAnalysisCoordinator.inspectFlutterWidget(widgetId);
}
async highlightFlutterWidget(widgetId) {
return await this.flutterAnalysisCoordinator.highlightFlutterWidget(widgetId);
}
async getFlutterMemoryUsage() {
return await this.flutterAnalysisCoordinator.getFlutterMemoryUsage();
}
isFlutterConnected() {
return this.flutterAnalysisCoordinator.isFlutterConnected();
}
isFlutterDetected() {
return this.flutterAnalysisCoordinator.isFlutterDetected();
}
// Problem-focused debugging methods
async getHydrationIssues() {
return await this.problemEngine.getHydrationIssues();
}
async getBundleAnalysis() {
return await this.problemEngine.getBundleAnalysis();
}
async getRouteChanges() {
return await this.problemEngine.getRouteChanges();
}
async detectCommonProblems() {
return await this.problemEngine.detectCommonProblems();
}
async attachFrameworkEngines(page) {
// Delegate to FrameworkDetector module
await this.frameworkDetector.attachFrameworkEngines(page);
}
// Next.js specific methods
async getNextJSPageInfo() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.getPageInfo();
}
async getNextJSBuildInfo() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.getBuildInfo();
}
async getNextJSHydrationErrors() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.getHydrationErrors();
}
async getNextJSImageIssues() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.getImageOptimizationIssues();
}
async getNextJSServerClientBoundaries() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.getServerClientBoundaries();
}
async getNextJSDataFetching() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.getDataFetching();
}
async analyzeNextJSServerClientFlow() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.analyzeServerClientFlow();
}
async detectNextJSProblems() {
if (!this.nextjsEngine) {
throw new Error('Next.js engine not initialized');
}
return await this.nextjsEngine.detectNextJSProblems();
}
// Enhanced Next.js methods
async getNextJSConfig() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getConfig();
}
async getNextJSAppRouterInfo() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getAppRouterInfo();
}
async getNextJSDataFetchingAnalysis() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getDataFetchingAnalysis();
}
async getNextJSBundleAnalysis() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getBundleAnalysis();
}
async analyzeNextJSServerComponentFlow() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.analyzeServerClientFlow();
}
async getNextJSMiddlewareAnalysis() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getMiddlewareAnalysis();
}
async getNextJSServerActionMonitor() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getServerActionMonitor();
}
async getNextJSCacheInspector() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getCacheInspector();
}
async getNextJSFontAnalysis() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getFontLoadingAnalysis();
}
async getNextJSSecurityAnalysis() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getSecurityAnalysis();
}
async getNextJSISRMonitor(route) {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getISRMonitor(route);
}
async getNextJSEdgeRuntimeInfo() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getEdgeRuntimeInfo();
}
async getNextJSPPRAnalysis() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getPPRAnalysis();
}
async getNextJSHMRAnalysis() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.getHMRAnalysis();
}
async debugNextJSRoute() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.debugRoute();
}
async analyzeNextJSBundleDetails() {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
return await this.nextjsEnhancedEngine.analyzeBundle();
}
async clearNextJSCache(type) {
if (!this.nextjsEnhancedEngine) {
throw new Error('Enhanced Next.js engine not initialized');
}
await this.nextjsEnhancedEngine.clearNextCache(type);
}
async getNextJSPerformanceScore() {
return await this.performanceCoordinator.getNextJSPerformanceScore();
}
// Server framework specific methods
async getTurboEvents() {
if (!this.serverFrameworkEngine) {
throw new Error('Server framework engine not initialized');
}
return await this.serverFrameworkEngine.getTurboEvents();
}
async getStimulusControllers() {
if (!this.serverFrameworkEngine) {
throw new Error('Server framework engine not initialized');
}
return await this.serverFrameworkEngine.getStimulusControllers();
}
async getCSRFIssues() {
if (!this.serverFrameworkEngine) {
throw new Error('Server framework engine not initialized');
}
return await this.serverFrameworkEngine.getCSRFIssues();
}
async detectServerFrameworkProblems() {
if (!this.serverFrameworkEngine) {
throw new Error('Server framework engine not initialized');
}
return await this.serverFrameworkEngine.detectServerFrameworkProblems();
}
async getFormSubmissions() {
if (!this.serverFrameworkEngine) {
throw new Error('Server framework engine not initialized');
}
return await this.serverFrameworkEngine.getFormSubmissions();
}
isNextJSConnected() {
return this.nextjsEngine !== undefined;
}
isServerFrameworkConnected() {
return this.serverFrameworkEngine !== undefined;
}
// Meta-framework specific methods
async getMetaFrameworkInfo() {
return this.metaFrameworkEngine?.getMetaFrameworkInfo();
}
async getRemixLoaderData() {
if (!this.metaFrameworkEngine) {
throw new Error('Meta-framework engine not initialized');
}
return await this.metaFrameworkEngine.getRemixLoaderData();
}
async getRemixRouteModules() {
if (!this.metaFrameworkEngine) {
throw new Error('Meta-framework engine not initialized');
}
return await this.metaFrameworkEngine.getRemixRouteModules();
}
async getAstroIslands() {
if (!this.metaFrameworkEngine) {
throw new Error('Meta-framework engine not initialized');
}
return await this.metaFrameworkEngine.getAstroIslands();
}
async getNuxtPayload() {
if (!this.metaFrameworkEngine) {
throw new Error('Meta-framework engine not initialized');
}
return await this.metaFrameworkEngine.getNuxtPayload();
}
async getQwikResumability() {
if (!this.metaFrameworkEngine) {
throw new Error('Meta-framework engine not initialized');
}
return await this.metaFrameworkEngine.getQwikResumability();
}
async getViteHMREvents() {
if (!this.metaFrameworkEngine) {
throw new Error('Meta-framework engine not initialized');
}
return await this.metaFrameworkEngine.getViteHMREvents();
}
async detectMetaFrameworkProblems() {
if (!this.metaFrameworkEngine) {
throw new Error('Meta-framework engine not initialized');
}
return await this.metaFrameworkEngine.detectMetaFrameworkProblems();
}
isMetaFrameworkConnected() {
return this.metaFrameworkEngine !== undefined;
}
// JavaScript Execution Tracking Methods - Delegated to JavaScriptAnalysisCoordinator
async enableJavaScriptTracing() {
return await this.jsAnalysisCoordinator.enableJavaScriptTracing();
}
async disableJavaScriptTracing() {
return await this.jsAnalysisCoordinator.disableJavaScriptTracing();
}
async instrumentFunction(functionPath, functionName) {
return await this.jsAnalysisCoordinator.instrumentFunction(functionPath, functionName);
}
async getJavaScriptExecutionTrace() {
return await this.jsAnalysisCoordinator.getJavaScriptExecutionTrace();
}
async getJavaScriptCallGraph() {
return await this.jsAnalysisCoordinator.getJavaScriptCallGraph();
}
async getJavaScriptPerformanceProfile() {
return await this.performanceCoordinator.getJavaScriptPerformanceProfile();
}
async captureVariableState(variablePath, scope) {
return await this.debugSessionCoordinator.captureVariableState(variablePath, scope);
}
// Async Operation Tracking Methods - Delegated to JavaScriptAnalysisCoordinator
async enableAsyncTracking() {
return await this.jsAnalysisCoordinator.enableAsyncTracking();
}
async disableAsyncTracking() {
return await this.jsAnalysisCoordinator.disableAsyncTracking();
}
async getAsyncOperationTrace() {
return await this.jsAnalysisCoordinator.getAsyncOperationTrace();
}
async getPromiseChain(promiseId) {
return await this.jsAnalysisCoordinator.getPromiseChain(promiseId);
}
async getAsyncStackTrace(operationId) {
return await this.jsAnalysisCoordinator.getAsyncStackTrace(operationId);
}
async detectAsyncLeaks() {
return await this.jsAnalysisCoordinator.detectAsyncLeaks();
}
// JavaScript Error Detection Methods - Delegated to JavaScriptAnalysisCoordinator
async detectJavaScriptErrors() {
return await this.jsAnalysisCoordinator.detectJavaScriptErrors();
}
async validateScriptTags() {
return await this.jsAnalysisCoordinator.validateScriptTags();
}
async stopErrorMonitoring() {
return await this.jsAnalysisCoordinator.stopMonitoring();
}
// Enhanced network analysis methods
getFailedRequests() {
return this.eventCollector.getFailedRequests();
}
getSlowRequests(thresholdMs = 1000) {
return this.eventCollector.getSlowRequests(thresholdMs);
}
getApiRequests() {
return this.eventCollector.getApiRequests();
}
getRequestsByStatus(status) {
return this.eventCollector.getRequestsByStatus(status);
}
// Find data mismatches between API responses and what might be displayed
async detectApiDataMismatches() {
const mismatches = [];
const apiRequests = this.getApiRequests();
for (const request of apiRequests) {
if (request.responseBody && typeof request.responseBody === 'object') {
// Check if response has array data
const arrays = this.findArraysInObject(request.responseBody);
for (const { path, array } of arrays) {
if (array.length > 0) {
// Check if UI might be showing different count
const possibleMismatch = {
url: request.url,
dataPath: path,
apiCount: array.length,
apiSample: array.slice(0, 3),
timestamp: request.timestamp,
hint: `API returned ${array.length} items at ${path}`
};
mismatches.push(possibleMismatch);
}
}
}
}
return mismatches;
}
findArraysInObject(obj, path = '') {
const arrays = [];
if (Array.isArray(obj)) {
arrays.push({ path: path || 'root', array: obj });
}
else if (obj && typeof obj === 'object') {
for (const [key, value] of Object.entries(obj)) {
const newPath = path ? `${path}.${key}` : key;
arrays.push(...this.findArraysInObject(value, newPath));
}
}
return arrays;
}
// React State Inspection Methods - Delegated to ReactStateCoordinator
async getReactComponentTree() {
return await this.reactStateCoordinator.getReactComponentTree();
}
async getReactState() {
return await this.reactStateCoordinator.getReactState();
}
async detectReactStateMismatches() {
return await this.reactStateCoordinator.detectReactStateMismatches();
}
async monitorReactStateChanges(duration) {
return await this.reactStateCoordinator.monitorReactStateChanges(duration);
}
async getReactComponentByName(name) {
return await this.reactStateCoordinator.getReactComponentByName(name);
}
// Database Query Tracing Methods
async captureDatabaseQueries(duration) {
return await this.databaseTraceEngine.captureQueries(duration);
}
getDatabaseQueries(filter) {
return this.databaseTraceEngine.getQueries(filter);
}
detectN1Queries() {
return this.databaseTraceEngine.detectN1Queries();
}
getSlowDatabaseQueries(thresholdMs = 100) {
return this.databaseTraceEngine.getSlowQueries(thresholdMs);
}
getDatabaseQueryStats() {
return this.databaseTraceEngine.getQueryStats();
}
clearDatabaseQueries() {
// Delegate to EventMonitor module
this.eventMonitor.clearDatabaseQueries();
}
// Enhanced Flutter debugging methods - Delegated to FlutterAnalysisCoordinator
async getFlutterConfig() {
return await this.flutterAnalysisCoordinator.getFlutterConfig();
}
async getFlutterDiagnostics() {
return await this.flutterAnalysisCoordinator.getFlutterDiagnostics();
}
async getFlutterPerformanceMetrics() {
return await this.performanceCoordinator.getFlutterPerformanceMetrics();
}
async detectFlutterWebIssues() {
return await this.flutterAnalysisCoordinator.detectFlutterWebIssues();
}
async analyzeFlutterWidgetTree() {
return await this.flutterAnalysisCoordinator.analyzeFlutterWidgetTree();
}
async detectFlutterMemoryLeaks() {
return await this.flutterAnalysisCoordinator.detectFlutterMemoryLeaks();
}
async captureFlutterStateSnapshot() {
return await this.flutterAnalysisCoordinator.captureFlutterStateSnapshot();
}
async analyzeFlutterAssetLoading() {
return await this.flutterAnalysisCoordinator.analyzeFlutterAssetLoading();
}
async getFlutterBrowserCompatibility() {
return await this.flutterAnalysisCoordinator.getFlutterBrowserCompatibility();
}
async getFlutterHealthCheck() {
return await this.flutterAnalysisCoordinator.getFlutterHealthCheck();
}
async getFlutterPerformanceBaseline() {
return await this.performanceCoordinator.getFlutterPerformanceBaseline();
}
// Cleanup method for proper resource management
async cleanup() {
this.networkCoordinator.cleanup();
this.performanceCoordinator.cleanup();
}
}
//# sourceMappingURL=local-debug-engine.js.map