/**
 * This module executes inside of electron's main process. You can start
 * electron renderer process from here and communicate with the other processes
 * through IPC.
 *
 * When running `yarn build` or `yarn build-main`, this file is compiled to
 * `./app/main.prod.js` using webpack. This gives us some performance wins.
 */ import 'core-js/stable' ; import 'regenerator-runtime/runtime' ; import path from 'path' ; import { app , BrowserWindow , ipcMain , IpcMainEvent } from 'electron' ; import updater from './utils/autoUpdater' ; import MenuBuilder from './menu' ; let mainWindow = null ; if ( process . env . NODE_ENV === 'production' ) { const sourceMapSupport = require ( 'source-map-support' ) ; sourceMapSupport . install ( ) ; } if ( process . env . NODE_ENV === 'development' || process . env . DEBUG_PROD === 'true' ) { require ( 'electron-debug' ) ( ) ; } const installExtensions = async ( ) => { const installer = require ( 'electron-devtools-installer' ) ; const forceDownload = ! ! process . env . UPGRADE_EXTENSIONS ; const extensions = [ 'REACT_DEVELOPER_TOOLS' , 'REDUX_DEVTOOLS' ] ; return Promise . all ( extensions . map ( ( name ) => installer . default ( installer [ name ] , forceDownload ) ) ) . catch ( console . log ) ; } ; const createWindow = async ( ) => { if ( process . env . NODE_ENV === 'development' || process . env . DEBUG_PROD === 'true' ) { await installExtensions ( ) ; } mainWindow = new BrowserWindow ( { show : false , width : 1024 , height : 728 , webPreferences : ( process . env . NODE_ENV === 'development' || process . env . E2E_BUILD === 'true' ) && process . env . ERB_SECURE !== 'true' ? { nodeIntegration : true , } : { preload : path . join ( __dirname , 'dist/renderer.prod.js' ) , } , } ) ; mainWindow . loadURL ( `file://${ __dirname }/app.html` ) ; mainWindow . webContents . on ( 'did-finish-load' , ( ) => { if ( ! mainWindow ) { throw new Error ( '"mainWindow" is not defined' ) ; } const configuration = { appDataFolder : app . getPath ( 'appData' ) , isDevelopment : process . env . NODE_ENV === 'development' , } ; mainWindow . webContents . send ( 'window-loaded-configuration' , configuration ) ; if ( process . env . START_MINIMIZED ) { mainWindow . minimize ( ) ; } else { mainWindow . show ( ) ; mainWindow . focus ( ) ; mainWindow . maximize ( ) ; } ipcMain . on ( 'board/board-changes' , ( event , boardTitle ) => { mainWindow ?. setTitle ( `My Personal Kanban - ${ boardTitle }` ) ; } ) ; } ) ; mainWindow . on ( 'closed' , ( ) => { mainWindow = null ; } ) ; const menuBuilder = new MenuBuilder ( mainWindow ) ; menuBuilder . buildMenu ( ) ; updater ( mainWindow ) ; } ; /**
 * Add event listeners...
 */ app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } } ) ; if ( process . env . E2E_BUILD === 'true' ) { app . whenReady ( ) . then ( createWindow ) ; } else { app . on ( 'ready' , createWindow ) ; } app . on ( 'activate' , ( ) => { if ( mainWindow === null ) createWindow ( ) ; } ) ; app . setAboutPanelOptions ( { applicationName : 'My Personal Kanban' , copyright : 'Greg Gigon 2020' , version : app . getVersion ( ) , } ) ;