const { contextBridge , ipcRenderer } = require ( 'electron' ) ; contextBridge . exposeInMainWorld ( 'electron' , { storeImage : ( arg ) => ipcRenderer . invoke ( 'store-image' , arg ) , storeVideo : ( arg ) => ipcRenderer . invoke ( 'store-video' , arg ) , storeAudio : ( arg ) => ipcRenderer . invoke ( 'store-audio' , arg ) , openPreview : ( arg ) => ipcRenderer . invoke ( 'open-preview' , arg ) , renderPreview : ( arg ) => ipcRenderer . invoke ( 'render-preview' , arg ) , exportAsZip : ( arg ) => ipcRenderer . invoke ( 'export-as-zip' , arg ) , resetStory : ( ) => ipcRenderer . invoke ( 'reset-story' ) , saveAs : ( arg ) => ipcRenderer . invoke ( 'save-as' , arg ) , directories : ipcRenderer . sendSync ( 'directories' ) , onOpenFile : ( callback ) => { ipcRenderer . removeAllListeners ( 'open-file' ) ; ipcRenderer . on ( 'open-file' , ( event , args ) => { callback ( event , args ) ; } ) ; } , onSaveAsMenuClick : ( callback , onSaved ) => { ipcRenderer . removeAllListeners ( 'save-as-menu-click' ) ; ipcRenderer . removeAllListeners ( 'saved-file-path' ) ; ipcRenderer . on ( 'save-as-menu-click' , ( event ) => { callback ( event ) ; } ) ; ipcRenderer . on ( 'saved-file-path' , ( event , args ) => onSaved ( event , args ) ) ; } , onSave : ( callback ) => { ipcRenderer . removeAllListeners ( 'save-click' ) ; ipcRenderer . on ( 'save-click' , callback ) ; } , toggleSave : ( isDirty ) => { ipcRenderer . removeAllListeners ( 'toggle-save' ) ; ipcRenderer . send ( 'toggle-save' , isDirty ) ; } , onExport : ( callback ) => { ipcRenderer . removeAllListeners ( 'export-click' ) ; ipcRenderer . on ( 'export-click' , callback ) ; } , onPreview : ( callback ) => { ipcRenderer . removeAllListeners ( 'preview-click' ) ; ipcRenderer . on ( 'preview-click' , callback ) ; } , onLoading : ( callback ) => { ipcRenderer . removeAllListeners ( 'on-loading' ) ; ipcRenderer . on ( 'on-loading' , ( event , loading ) => callback ( loading ) ) ; } , } ) ;