mirror of
https://gitlab.com/deeplydrumming/DeemixFix.git
synced 2026-01-15 16:32:59 -03:00
26 lines
745 B
JavaScript
26 lines
745 B
JavaScript
const {
|
|
contextBridge,
|
|
ipcRenderer
|
|
} = require('electron')
|
|
|
|
// Expose protected methods that allow the renderer process to use
|
|
// the ipcRenderer without exposing the entire object
|
|
contextBridge.exposeInMainWorld(
|
|
'api', {
|
|
send: (channel, data) => {
|
|
// whitelist channels
|
|
const validChannels = ['openDownloadsFolder', 'selectDownloadFolder']
|
|
if (validChannels.includes(channel)) {
|
|
ipcRenderer.send(channel, data)
|
|
}
|
|
},
|
|
receive: (channel, func) => {
|
|
const validChannels = ['downloadFolderSelected']
|
|
if (validChannels.includes(channel)) {
|
|
// Deliberately strip event as it includes `sender`
|
|
ipcRenderer.on(channel, (event, ...args) => func(...args))
|
|
}
|
|
}
|
|
}
|
|
)
|