// 🎮 MRTVA DOLINA - ELECTRON MAIN PROCESS (ES Module) import electron from 'electron'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); console.log('🚀 Starting Electron process (ESM)...'); console.log('Node version:', process.version); console.log('Platform:', process.platform); if (process.versions.electron) { console.log('✅ Running in Electron:', process.versions.electron); } else { console.log('❌ Not running in Electron context'); } console.log('Electron module type:', typeof electron); if (!electron || typeof electron !== 'object') { console.error('❌ FATAL: Electron module not loaded correctly!'); console.error('Electron value:', electron); process.exit(1); } // Debug: See what's actually in the electron object console.log('🔍 Electron object keys:', Object.keys(electron)); console.log('🔍 Checking electron.app:', electron.app); console.log('🔍 Checking electron.BrowserWindow:', electron.BrowserWindow); console.log('🔍 Checking electron.default:', electron.default); // If electron is a module with a default export let app, BrowserWindow; if (electron.default) { console.log('📦 Using electron.default'); app = electron.default.app; BrowserWindow = electron.default.BrowserWindow; } else { app = electron.app; BrowserWindow = electron.BrowserWindow; } console.log('✅ Electron APIs loaded successfully!'); console.log('app:', typeof app); console.log('BrowserWindow:', typeof BrowserWindow); let mainWindow; function createWindow() { console.log('🪟 Creating main window...'); mainWindow = new BrowserWindow({ width: 1280, height: 720, webPreferences: { nodeIntegration: true, contextIsolation: false }, backgroundColor: '#000000', title: 'Mrtva Dolina - Death Valley' }); mainWindow.loadFile('index.html'); mainWindow.webContents.openDevTools(); mainWindow.on('closed', () => { mainWindow = null; }); console.log('✅ Window created successfully'); } console.log('⏳ Waiting for app to be ready...'); app.whenReady().then(() => { console.log('✅ App is ready, creating window...'); createWindow(); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } }); }); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } }); console.log('✅ Main process script loaded (ESM)');