File size: 1,503 Bytes
8ed13f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72be969
8ed13f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// bootstrap.js - SINGLE ENTRY POINT for application initialization
// This is the ONLY file that auto-executes
// All initialization happens here in a well-defined sequence

async function bootstrap() {
    try {
        // Step 1: Load artifacts (areas already loaded in <head>)
        const { loadArtifacts } = await import('./init.js');
        await loadArtifacts();
        
        // Step 2: Initialize router (will render initial page)
        const { router } = await import('./utils/router.js');
        // Router auto-initializes in constructor, no need to call init()
        
        // Step 3: Initialize UI components (search, scroll-to-top, etc.)
        const { initializeUI } = await import('./main.js');
        await initializeUI();
    } catch (error) {
        console.error('Bootstrap failed:', error);
        // Show user-friendly error
        const mainContent = document.getElementById('main-content');
        if (mainContent) {
            mainContent.innerHTML = `
                <div class="p-8 text-center">
                    <h2 class="text-2xl font-bold text-red-600 mb-4">Failed to Load Application</h2>
                    <p class="text-gray-700 mb-4">Please refresh the page. If the problem persists, contact support.</p>
                    <pre class="text-left text-sm bg-gray-100 p-4 rounded overflow-auto">${error.stack || error.message}</pre>
                </div>
            `;
        }
    }
}

// Start immediately when module loads
bootstrap();