import { contextBridge } from 'electron' ; import { inspect } from 'util' ; import { logger } from '@app-config/logging' ; import type { ExportedConfig } from '@app-config/main' ; let additionalPreload ; let config ; for ( const arg of process . argv ) { if ( arg . startsWith ( '--user-preload=' ) ) { additionalPreload = arg . substr ( 15 ) ; } if ( arg . startsWith ( '--app-config=' ) ) { try { config = JSON . parse ( arg . substr ( 13 ) ) as ExportedConfig ; } catch ( err ) { logger . error ( `Got invalid JSON from config: ${ inspect ( err ) }` ) ; } } } if ( config ) { contextBridge . exposeInMainWorld ( '_appConfig' , config ) ; logger . info ( `⚙️ Injected app-config` ) ; } if ( additionalPreload ) { require ( additionalPreload ) ; }