feat: boot-экран, стабильность Windows и оптимизация Pixi/пульта

- Экран загрузки (boot.html, bootWindow): статусы, ensureRoots и проверка лицензии, редактор после готовности; закрытие через destroy при closable:false.

- Упакованное приложение на Windows: disableHardwareAcceleration, sandbox выкл. вне dev, отложенный показ редактора, ensureWindowBecomesVisible, фокус на splash при second-instance.

- Vite: вход boot.html; eslint: игнор release/; тесты boot и maxFPS тикера.

- Пульт: позиция курсора кисти через ref/DOM без setState на каждый move; черновик эффекта через rAF; Pixi: maxFPS 32, resolution cap, antialias off, debounce ResizeObserver, меньше частиц poisonCloud, contain на хосте.

Made-with: Cursor
This commit is contained in:
Ivan Fontosh
2026-04-20 12:12:01 +08:00
parent 20c838da7d
commit e39a72206d
15 changed files with 587 additions and 62 deletions
+115
View File
@@ -0,0 +1,115 @@
import path from 'node:path';
import { app, BrowserWindow } from 'electron';
import { getAppSemanticVersion } from '../versionInfo';
let bootSplashRef: BrowserWindow | null = null;
export function getBootSplashWindow(): BrowserWindow | null {
return bootSplashRef;
}
function loadBootPage(win: BrowserWindow): void {
const dev = process.env.VITE_DEV_SERVER_URL;
if (dev) {
void win.loadURL(new URL('boot.html', dev).toString());
return;
}
const htmlPath = path.join(app.getAppPath(), 'dist', 'renderer', 'boot.html');
void win.loadFile(htmlPath);
}
/** Без preload: только статический экран; статус задаётся из main через executeJavaScript. */
function bootWebPreferences(): Electron.WebPreferences {
const dev = Boolean(process.env.VITE_DEV_SERVER_URL);
return {
contextIsolation: true,
sandbox: dev ? true : process.platform !== 'win32',
nodeIntegration: false,
devTools: dev || process.env.DND_OPEN_DEVTOOLS === '1',
webSecurity: dev,
};
}
/**
* Окно без системного заголовка: логотип, название, строка статуса.
* Показывать после `waitForBootWindowReady`.
*/
export function createBootWindow(): BrowserWindow {
const win = new BrowserWindow({
width: 440,
height: 420,
show: false,
frame: false,
resizable: false,
maximizable: false,
minimizable: false,
closable: false,
center: true,
transparent: false,
backgroundColor: '#09090B',
roundedCorners: true,
webPreferences: bootWebPreferences(),
});
bootSplashRef = win;
win.once('closed', () => {
if (bootSplashRef === win) {
bootSplashRef = null;
}
});
loadBootPage(win);
return win;
}
/**
* Закрыть splash: при `closable: false` на Windows `close()` из main часто не срабатывает — используем `destroy()`.
*/
export function destroyBootWindow(win: BrowserWindow): void {
if (win.isDestroyed()) return;
win.destroy();
}
export function setBootWindowStatus(win: BrowserWindow, text: string): void {
if (win.isDestroyed()) return;
const escaped = JSON.stringify(text);
void win.webContents.executeJavaScript(
`(() => { const el = document.getElementById('boot-status'); if (el) el.textContent = ${escaped}; })()`,
);
}
export function applyBootWindowBranding(win: BrowserWindow): void {
if (win.isDestroyed()) return;
const name = app.getName();
const version = getAppSemanticVersion();
const versionLabel = version.trim().length > 0 ? `v${version.trim()}` : '';
void win.webContents.executeJavaScript(
`(() => {
const t = document.querySelector('[data-boot-title]');
if (t) t.textContent = ${JSON.stringify(name)};
const v = document.querySelector('[data-boot-version]');
if (v) v.textContent = ${JSON.stringify(versionLabel)};
})()`,
);
}
/** Дождаться загрузки разметки экрана загрузки. */
export function waitForBootWindowReady(win: BrowserWindow): Promise<void> {
return new Promise((resolve, reject) => {
if (win.isDestroyed()) {
reject(new Error('boot window destroyed'));
return;
}
const onFail = (): void => {
reject(new Error('boot window failed to load'));
};
win.webContents.once('did-fail-load', onFail);
win.webContents.once('did-finish-load', () => {
win.webContents.removeListener('did-fail-load', onFail);
applyBootWindowBranding(win);
resolve();
});
});
}