Class_generator/tests/root-cleanup/debug-modules.js
StillHammer 29bc112c0c Unify vocabulary persistence system - remove dual systems
- Simplified loadPersistedVocabularyData() to use only VocabularyProgressManager
- Updated calculateVocabularyProgress() to use unified data structure
- Removed old system references from knowledge panel data loading
- Fixed field names (drsDiscovered, drsMastered) for unified system
- Knowledge panel now displays vocabulary progress correctly

 TESTED: Vocabulary Knowledge panel working with unified system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 13:39:00 +08:00

94 lines
3.7 KiB
JavaScript

/**
* Debug Module Loading - Helps diagnose what modules are actually loaded
*/
window.debugModules = function() {
console.log('🔍 DEBUGGING MODULE STATUS');
console.log('=========================');
// Check application
console.log('📱 Application:', {
exists: !!window.app,
status: window.app?.getStatus?.()?.status,
core: !!window.app?.getCore(),
moduleLoader: !!window.app?.getCore()?.moduleLoader
});
// Check module loader
if (window.app?.getCore()?.moduleLoader) {
const moduleLoader = window.app.getCore().moduleLoader;
console.log('📦 ModuleLoader status:', moduleLoader.getStatus());
// List all loaded modules
const modules = ['eventBus', 'router', 'intelligentSequencer', 'flashcardLearning',
'unifiedDRS', 'iaEngine', 'llmValidator', 'smartPreviewOrchestrator'];
console.log('📋 Module availability:');
modules.forEach(name => {
const module = moduleLoader.getModule(name);
console.log(` ${name}: ${module ? '✅' : '❌'}`);
if (module && name === 'smartPreviewOrchestrator') {
console.log(` - sharedServices: ${!!module.sharedServices}`);
console.log(` - prerequisiteEngine: ${!!module.sharedServices?.prerequisiteEngine}`);
}
});
}
// Check global variables
console.log('🌐 Global variables:');
const globals = ['contentLoader', 'unifiedDRS', 'iaEngine', 'llmValidator', 'prerequisiteEngine'];
globals.forEach(name => {
console.log(` window.${name}: ${!!window[name]}`);
});
// Check if modules are properly initialized
console.log('🚀 Module initialization:');
if (window.app?.getCore()?.moduleLoader) {
const orchestrator = window.app.getCore().moduleLoader.getModule('smartPreviewOrchestrator');
if (orchestrator) {
console.log(' SmartPreviewOrchestrator:', {
exists: true,
sharedServices: !!orchestrator.sharedServices,
prerequisiteEngine: !!orchestrator.sharedServices?.prerequisiteEngine,
contextMemory: !!orchestrator.sharedServices?.contextMemory,
iaEngine: !!orchestrator.sharedServices?.iaEngine
});
} else {
console.log(' SmartPreviewOrchestrator: ❌ Not found');
}
}
// Try to access prerequisite engine directly
console.log('🎯 PrerequisiteEngine access attempts:');
// Method 1: From global
console.log(` 1. window.prerequisiteEngine: ${!!window.prerequisiteEngine}`);
// Method 2: From orchestrator
if (window.app?.getCore()?.moduleLoader) {
const orchestrator = window.app.getCore().moduleLoader.getModule('smartPreviewOrchestrator');
const fromOrchestrator = orchestrator?.sharedServices?.prerequisiteEngine;
console.log(` 2. From orchestrator: ${!!fromOrchestrator}`);
if (fromOrchestrator) {
console.log(' - markWordDiscovered method:', typeof fromOrchestrator.markWordDiscovered);
console.log(' - isMastered method:', typeof fromOrchestrator.isMastered);
}
}
// Method 3: Check if it exists but not global
if (window.unifiedDRS && window.unifiedDRS._prerequisiteEngine) {
console.log(` 3. From unifiedDRS: ${!!window.unifiedDRS._prerequisiteEngine}`);
}
};
// Auto-run when loaded
setTimeout(() => {
if (window.app && window.app.getStatus && window.app.getStatus().isRunning) {
window.debugModules();
} else {
console.log('⏳ App not ready yet, run debugModules() manually when ready');
}
}, 2000);
console.log('🔍 Debug modules loaded. Run debugModules() to see detailed module status.');