// src/main.jsx - Simplified and Fixed
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import AppWithErrorBoundary from './components/AppWithErrorBoundary.jsx';
import BrowserWarning from './components/BrowserWarning.jsx';
import { initializeBrowserSupport, loadPolyfills } from './utils/browserCompatibility.js';
// Performance monitoring
if (typeof performance !== 'undefined' && performance.mark) {
performance.mark('app-init-start');
}
// Main initialization function
async function initializeApp() {
try {
console.log('🚀 Starting application initialization...');
// Check browser support first
const { support, browserInfo } = initializeBrowserSupport();
// Load polyfills for unsupported browsers
if (!support.isSupported) {
console.log('⚠️ Loading polyfills for browser compatibility...');
try {
await loadPolyfills();
} catch (polyfillError) {
console.warn('Failed to load some polyfills:', polyfillError);
}
}
// Get root element
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error('Root element #root not found in DOM');
}
// Create React root
const root = createRoot(rootElement);
// Show browser warning if there are compatibility issues
if (!support.isSupported && support.unsupportedFeatures.length > 0) {
console.warn('🌐 Browser compatibility issues detected:', support.unsupportedFeatures);
// Create warning overlay
const warningDiv = document.createElement('div');
warningDiv.id = 'browser-warning';
warningDiv.className = 'browser-warning-overlay';
document.body.appendChild(warningDiv);
const warningRoot = createRoot(warningDiv);
warningRoot.render(
We're sorry, but Resume Tools encountered an error during startup. This could be due to network issues, browser compatibility, or a temporary server problem.
Technical Details:
${error.message}
If this problem persists, try clearing your browser cache or using a different browser.