2025-07-24 22:17:38 +02:00
|
|
|
// Main entry point for Calendar Plantempus
|
|
|
|
|
import { eventBus } from './core/EventBus.js';
|
2025-08-07 00:15:44 +02:00
|
|
|
import { calendarConfig } from './core/CalendarConfig.js';
|
2025-08-09 00:31:44 +02:00
|
|
|
import { CalendarTypeFactory } from './factories/CalendarTypeFactory.js';
|
2025-08-17 23:44:30 +02:00
|
|
|
import { ManagerFactory } from './factories/ManagerFactory.js';
|
2025-07-24 22:17:38 +02:00
|
|
|
|
|
|
|
|
/**
|
2025-08-09 01:16:04 +02:00
|
|
|
* Initialize the calendar application with simple direct calls
|
2025-07-24 22:17:38 +02:00
|
|
|
*/
|
2025-08-09 00:31:44 +02:00
|
|
|
async function initializeCalendar(): Promise<void> {
|
2025-08-17 23:44:30 +02:00
|
|
|
console.log('🗓️ Initializing Calendar Plantempus with factory pattern...');
|
2025-07-24 22:17:38 +02:00
|
|
|
|
2025-08-09 00:31:44 +02:00
|
|
|
try {
|
|
|
|
|
// Use the singleton calendar configuration
|
|
|
|
|
const config = calendarConfig;
|
|
|
|
|
|
|
|
|
|
// Initialize the CalendarTypeFactory before creating managers
|
2025-08-09 01:16:04 +02:00
|
|
|
console.log('🏭 Initializing CalendarTypeFactory...');
|
2025-08-09 00:31:44 +02:00
|
|
|
CalendarTypeFactory.initialize();
|
|
|
|
|
|
2025-08-17 23:44:30 +02:00
|
|
|
// Create managers using factory pattern
|
|
|
|
|
const managerFactory = ManagerFactory.getInstance();
|
|
|
|
|
const managers = managerFactory.createManagers(eventBus, config);
|
2025-08-09 00:31:44 +02:00
|
|
|
|
|
|
|
|
// Enable debug mode for development
|
|
|
|
|
eventBus.setDebug(true);
|
|
|
|
|
|
2025-08-17 23:44:30 +02:00
|
|
|
// Initialize all managers
|
|
|
|
|
await managerFactory.initializeManagers(managers);
|
2025-08-09 00:31:44 +02:00
|
|
|
|
|
|
|
|
console.log('🎊 Calendar Plantempus initialized successfully!');
|
2025-08-17 23:44:30 +02:00
|
|
|
console.log('📊 Initialization Report:', managers.calendarManager.getInitializationReport());
|
|
|
|
|
|
|
|
|
|
// Expose to window for debugging
|
|
|
|
|
(window as any).calendarDebug = {
|
|
|
|
|
eventBus,
|
|
|
|
|
...managers
|
|
|
|
|
};
|
2025-08-09 00:31:44 +02:00
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('💥 Calendar initialization failed:', error);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2025-07-24 22:17:38 +02:00
|
|
|
}
|
|
|
|
|
|
2025-08-09 00:31:44 +02:00
|
|
|
// Initialize when DOM is ready - now handles async properly
|
2025-07-24 22:17:38 +02:00
|
|
|
if (document.readyState === 'loading') {
|
2025-08-09 00:31:44 +02:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
initializeCalendar().catch(error => {
|
|
|
|
|
console.error('Failed to initialize calendar:', error);
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-07-24 22:17:38 +02:00
|
|
|
} else {
|
2025-08-09 00:31:44 +02:00
|
|
|
initializeCalendar().catch(error => {
|
|
|
|
|
console.error('Failed to initialize calendar:', error);
|
|
|
|
|
});
|
2025-07-24 22:17:38 +02:00
|
|
|
}
|