overview / js /bootstrap.js
Yacine Jernite
v07
8ed13f7
raw
history blame
1.92 kB
// 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() {
console.log('=== Bootstrap Started ===');
try {
// Step 1: Load artifacts (areas already loaded in <head>)
console.log('Loading artifacts...');
const { loadArtifacts } = await import('./init.js');
await loadArtifacts();
console.log('βœ“ Artifacts loaded:', window.allArtifacts?.length || 0);
// Step 2: Initialize router (will render initial page)
console.log('Initializing router...');
const { router } = await import('./utils/router.js');
// Router auto-initializes in constructor, no need to call init()
console.log('βœ“ Router initialized');
// Step 3: Initialize UI components (search, scroll-to-top, etc.)
console.log('Initializing UI...');
const { initializeUI } = await import('./main.js');
await initializeUI();
console.log('βœ“ UI initialized');
console.log('=== Bootstrap Complete ===');
} 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();