"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.attachLoadingOverlay = attachLoadingOverlay; const electron_1 = require("electron"); /** * Generates the HTML content for the initial loading screen overlay. * This is injected into a WebContentsView and shown to the user before * the main application bundle finishes loading. * * @param foregroundColor - The text and loader animation color (hex or CSS color string). * @param backgroundColor - The background color of the loading view. */ function getLoadingHtml(foregroundColor, backgroundColor) { return `
Loading AG X
`; } /** * Attaches a temporary WebContentsView overlay that shows a loading animation. * It is automatically removed when the window's main content finishes loading. */ function attachLoadingOverlay(win, foregroundColor, backgroundColor) { const view = new electron_1.WebContentsView({ webPreferences: { nodeIntegration: false, contextIsolation: true, }, }); const html = getLoadingHtml(foregroundColor, backgroundColor); void view.webContents.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`); win.contentView.addChildView(view); const updateBounds = () => { const [width, height] = win.getContentSize(); view.setBounds({ x: 0, y: 0, width, height }); }; updateBounds(); win.on('resize', updateBounds); win.webContents.once('did-finish-load', () => { try { win.contentView.removeChildView(view); } catch (_) { // In case window was closed quickly } win.off('resize', updateBounds); }); }