60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import Logger from '../logger/logger';
|
|
|
|
const LOG = Logger.create(__filename);
|
|
|
|
LOG.silly('main begins');
|
|
|
|
import * as path from 'path';
|
|
import * as electron from 'electron';
|
|
|
|
import { ExitCodes, ExitCode } from '../exit-codes/exit-codes';
|
|
|
|
process.on('unhandledRejection', async (reason: any, _promise: Promise<any>) => {
|
|
LOG.fatal('unhandled promise rejection:', reason);
|
|
ExitCodes.exit(ExitCode.GENERAL_ERROR);
|
|
});
|
|
|
|
// Initialize electron remote so that we can get console logs all in the same place
|
|
import * as electronMain from '@electron/remote/main';
|
|
electronMain.initialize();
|
|
|
|
(async () => {
|
|
await electron.app.whenReady();
|
|
LOG.silly('electron app is ready');
|
|
|
|
await LOG.ensureSourceMaps();
|
|
LOG.silly('base log source maps loaded');
|
|
|
|
const window = new electron.BrowserWindow({
|
|
width: 1580,//1080,
|
|
height: 720,
|
|
minWidth: 940,
|
|
minHeight: 500,
|
|
frame: false,
|
|
title: 'cordis',
|
|
webPreferences: {
|
|
//@ts-ignore enableRemoteModule is enabled with @electron/remote and not included in electron's typing
|
|
enableRemoteModule: true, // so we can get console logs properly
|
|
preload: path.join(__dirname, 'webapp', 'script.js')
|
|
}
|
|
});
|
|
|
|
window.loadFile(path.join(__dirname, 'webapp', 'index.html'));
|
|
|
|
electronMain.enable(window.webContents);
|
|
|
|
window.webContents.openDevTools();
|
|
|
|
electron.ipcMain.on('minimize', () => {
|
|
window.minimize();
|
|
});
|
|
|
|
electron.ipcMain.on('maximize', () => {
|
|
window.maximize();
|
|
});
|
|
|
|
electron.ipcMain.on('close', () => {
|
|
window.close();
|
|
});
|
|
})();
|