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) => { 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'; LOG.silly('modules loaded'); electronMain.initialize(); (async () => { await electron.app.whenReady(); LOG.silly('electron app is ready'); await LOG.ensureSourceMaps(); LOG.silly('base log source maps loaded'); const display = electron.screen.getPrimaryDisplay(); let width = 1580;//1080 let height = 720; let x = display.workArea.x + display.workAreaSize.width / 2 - width / 2; let y = display.workArea.y + display.workAreaSize.height / 2 - height / 2; const window = new electron.BrowserWindow({ width: width, height: height, x: x, y: y, 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', 'preload.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(); }); })();