import { Message , MessageCallback , Messages , onBridgeMessageGeneric , onMessageGeneric } from 'root/lib/messages' ; export function sendMessageToIpcMain ( message , data ) { window . postMessage ( { message , data } , '*' ) ; } const allCallbacks = new Map < Message , MessageCallback < Message > [ ] > ( ) ; window . addEventListener ( 'message' , ( ev ) => { onBridgeMessageGeneric ( allCallbacks , ev . data ) ; } ) ; export function onMessageFromIpcMain < M extends Message > ( message , cb ) { onMessageGeneric ( allCallbacks , message , cb ) ; }