36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { app } from 'electron';
|
|
import { registerIpcHandlers } from './ipc/handlers.ts';
|
|
import { handleArtProtocol, registerArtScheme } from './services/background-art/art-protocol.ts';
|
|
import { startLauncherLogging } from './services/diagnostics/launcher-log.ts';
|
|
import { createMainWindow, showMainWindow } from './services/main-window.ts';
|
|
|
|
/**
|
|
* Main process entry. Order:
|
|
* 1. the user data folder (a scratch folder for development runs), the background art scheme and
|
|
* the single-instance lock;
|
|
* 2. IPC handlers and the background art protocol;
|
|
* 3. the window.
|
|
*/
|
|
|
|
// Development runs point this at a scratch folder so they never touch a real installation's
|
|
// settings (it also gives them their own single-instance lock).
|
|
const userDataOverride = process.env['WTO_LAUNCHER_USER_DATA'];
|
|
if (userDataOverride) app.setPath('userData', userDataOverride);
|
|
|
|
if (process.platform === 'win32') app.setAppUserModelId('com.wtoffline.launcher');
|
|
registerArtScheme();
|
|
|
|
if (!app.requestSingleInstanceLock()) {
|
|
app.quit();
|
|
} else {
|
|
startLauncherLogging();
|
|
app.on('second-instance', () => showMainWindow());
|
|
app.on('window-all-closed', () => app.quit());
|
|
// A top-level await on whenReady deadlocks an ESM main entry on Windows.
|
|
void app.whenReady().then(() => {
|
|
registerIpcHandlers();
|
|
handleArtProtocol();
|
|
createMainWindow();
|
|
});
|
|
}
|