const url = require ( 'url' ) ; const path = require ( 'path' ) ; const { ConnectionBuilder } = require ( 'electron-cgi' ) ; import { app , BrowserWindow , ipcMain } from 'electron' ; let window ; const createWindow = ( ) => { window = new BrowserWindow ( { width : 1920 , height : 1080 , backgroundColor : '#121212' , autoHideMenuBar : true , titleBarStyle : 'hidden' , webPreferences : { nodeIntegration : true , contextIsolation : false , } , icon : path . join ( '../' , __dirname , 'build/' , 'icon.ico' ) , } ) ; window . loadURL ( url . format ( { pathname : path . join ( __dirname , 'index.html' ) , protocol : 'file:' , slashes : true , } ) ) ; window . on ( 'closed' , ( ) => { window = null ; } ) ; } ; app . on ( 'ready' , createWindow ) ; app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } } ) ; app . on ( 'activate' , ( ) => { if ( window === null ) { createWindow ( ) ; } } ) ; const connection = new ConnectionBuilder ( ) . connectTo ( 'dotnet' , 'run' , '--project' , 'ForzaCore' ) . build ( ) ; connection . onDisconnect = ( ) => { console . log ( 'lost' ) ; } ; connection . on ( 'new-data' , ( data ) => { const dataObj = JSON . parse ( data ) ; window . webContents . send ( 'new-data-for-dashboard' , dataObj ) ; console . log ( `${ dataObj . Steer }` ) ; } ) ; connection . on ( 'switch-recording-mode' , ( data ) => { const dataObj = JSON . parse ( data ) ; window . webContents . send ( 'new-data-for-dashboard' , dataObj ) ; console . log ( `${ dataObj . Steer }` ) ; } ) ; ipcMain . on ( 'switch-recording-mode' , ( event , arg ) => { connection . send ( 'switch-recording-mode' , '' , ( response ) => { } ) ; } ) ;