2020-07-25 02:02:37 +02:00
|
|
|
/* eslint-disable import/order -- this is the entry point for the application and some things have to happen before others */
|
2020-02-08 23:26:57 +01:00
|
|
|
import { container } from './main/core/container';
|
2020-02-09 20:25:05 +01:00
|
|
|
import './main/core/install';
|
|
|
|
|
|
|
|
import { app } from 'electron';
|
2020-08-05 22:48:00 +02:00
|
|
|
import { isDev } from './main/core/env';
|
2021-01-06 02:35:46 +01:00
|
|
|
import type { AppWindowInterface } from './main/modules/app-window/app-window-interface';
|
2019-12-10 23:33:48 +01:00
|
|
|
|
2020-08-05 22:48:00 +02:00
|
|
|
/**
|
|
|
|
* have a read: https://github.com/nodejs/node/issues/20392, over 100 comments as of 2020-07-26
|
|
|
|
* https://nodejs.org/api/process.html#process_event_unhandledrejection
|
|
|
|
*/
|
|
|
|
process.on('unhandledRejection', (reason) => {
|
2021-01-06 02:35:46 +01:00
|
|
|
const logger: LoggerInterface = container.get('logger');
|
2020-08-05 22:48:00 +02:00
|
|
|
void logger.fatal(`Unhandled Rejection, see ${logger.getExceptionsLogFile()}`);
|
|
|
|
throw reason;
|
|
|
|
});
|
|
|
|
|
|
|
|
process.on('uncaughtException', (error) => {
|
2021-01-06 02:35:46 +01:00
|
|
|
const logger: LoggerInterface = container.get('logger');
|
2020-08-05 22:48:00 +02:00
|
|
|
void logger.exception(error);
|
2020-11-09 18:15:30 +01:00
|
|
|
if (isDev()) {
|
|
|
|
// eslint-disable-next-line no-console -- only for development purposes
|
|
|
|
console.error(error);
|
|
|
|
}
|
2020-08-05 22:48:00 +02:00
|
|
|
});
|
|
|
|
|
2019-06-30 01:18:21 +02:00
|
|
|
async function createWindow(): Promise<void> {
|
2021-01-06 02:35:46 +01:00
|
|
|
const appWindowMain: AppWindowInterface = container.get('app-window-main');
|
2020-02-08 23:26:57 +01:00
|
|
|
await appWindowMain.open();
|
2019-06-08 00:36:44 +02:00
|
|
|
|
2020-11-09 18:15:30 +01:00
|
|
|
appWindowMain.window?.on('closed', () => {
|
|
|
|
app.quit();
|
|
|
|
});
|
2019-06-08 00:36:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method will be called when Electron has finished
|
|
|
|
// initialization and is ready to create browser windows.
|
|
|
|
// Some APIs can only be used after this event occurs.
|
2021-01-24 19:48:06 +01:00
|
|
|
app.on('ready', () => {
|
|
|
|
void createWindow();
|
|
|
|
});
|
2019-06-08 00:36:44 +02:00
|
|
|
|
|
|
|
// Quit when all windows are closed.
|
|
|
|
app.on('window-all-closed', () => {
|
2020-11-09 18:15:30 +01:00
|
|
|
app.quit();
|
2019-06-08 00:36:44 +02:00
|
|
|
});
|
|
|
|
|
2021-01-24 19:48:06 +01:00
|
|
|
app.on('activate', () => {
|
2019-06-08 00:36:44 +02:00
|
|
|
// On OS X it"s common to re-create a window in the app when the
|
|
|
|
// dock icon is clicked and there are no other windows open.
|
2021-01-06 02:35:46 +01:00
|
|
|
const appWindowMain: AppWindowInterface = container.get('app-window-main');
|
2020-02-08 23:26:57 +01:00
|
|
|
if (appWindowMain.isClosed()) {
|
2021-01-24 19:48:06 +01:00
|
|
|
void createWindow();
|
2019-06-08 00:36:44 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// In this file you can include the rest of your app"s specific main process
|
|
|
|
// code. You can also put them in separate files and require them here.
|