/***********************************************************
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License
 **********************************************************/ import { ipcRenderer } from 'electron' ; import { MESSAGE_CHANNELS } from '../constants' ; const allowedChannels = new Set ( Object . values ( MESSAGE_CHANNELS ) ) ; export const invokeInMainWorld = async < T > ( channel , ... args ) : Promise < T > => { if ( ! allowedChannels . has ( channel ) ) { throw new Error ( 'Denied channel' ) ; } const { error , result } = await ipcRenderer . invoke ( channel , ... args ) ; if ( error ) { throw error ; } return result ; } ;