import { app , BrowserWindow } from 'electron' ; import installExtension , { VUEJS_DEVTOOLS } from 'electron-devtools-installer' ; import { createProtocol } from 'vue-cli-plugin-electron-builder/lib' ; import logger from './logging/logger' ; import Sentry from './logging/sentry' ; import { registerHandlers } from './handlers' ; Sentry . initializeReporter ( ) ; const isDevelopment = process . env . NODE_ENV !== 'production' ; let mainWindow ; function createWindow ( ) { mainWindow = new BrowserWindow ( { height : 563 , useContentSize : true , width : 1000 , webPreferences : { nodeIntegration : ( process . env . ELECTRON_NODE_INTEGRATION as unknown ) as boolean | undefined , } , } ) ; const loadURL = ( url ) => setTimeout ( ( ) => mainWindow . loadURL ( url ) , 100 ) ; if ( process . env . WEBPACK_DEV_SERVER_URL ) { loadURL ( process . env . WEBPACK_DEV_SERVER_URL ) ; if ( ! process . env . IS_TEST ) mainWindow . webContents . openDevTools ( ) ; } else { createProtocol ( 'app' ) ; loadURL ( 'app://./index.html' ) ; } registerHandlers ( ) ; mainWindow . on ( 'closed' , ( ) => { mainWindow = null ; } ) ; } app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } } ) ; app . on ( 'activate' , ( ) => { if ( mainWindow === null ) { createWindow ( ) ; } } ) ; app . on ( 'ready' , async ( ) => { if ( isDevelopment && ! process . env . IS_TEST ) { try { await installExtension ( VUEJS_DEVTOOLS ) ; } catch ( e ) { logger . info ( 'Vue Devtools failed to install:' , e . toString ( ) ) ; } } createWindow ( ) ; } ) ; if ( isDevelopment ) { if ( process . platform === 'win32' ) { process . on ( 'message' , ( data ) => { if ( data === 'graceful-exit' ) { app . quit ( ) ; } } ) ; } else { process . on ( 'SIGTERM' , ( ) => { app . quit ( ) ; } ) ; } }