core refactor for runtime support
This commit is contained in:
@@ -2,11 +2,24 @@ import { contextBridge, ipcRenderer } from 'electron'
|
||||
|
||||
// Custom APIs for renderer
|
||||
const api = {
|
||||
getConfig: () => ipcRenderer.invoke('getConfig'),
|
||||
setConfig: (config) => ipcRenderer.invoke('setConfig', config),
|
||||
listPlugins: () => ipcRenderer.invoke('listPlugins'),
|
||||
setActivePlugin: (pluginId) =>
|
||||
ipcRenderer.invoke('setActivePlugin', pluginId),
|
||||
pluginManagerCall: (method, ...args) =>
|
||||
ipcRenderer.invoke(
|
||||
'pluginManager:call',
|
||||
method,
|
||||
...(args.length ? args : []),
|
||||
),
|
||||
configManagerCall: (method, ...args) =>
|
||||
ipcRenderer.invoke(
|
||||
'configManager:call',
|
||||
method,
|
||||
...(args.length ? args : []),
|
||||
),
|
||||
adapterCall: (method, ...args) =>
|
||||
ipcRenderer.invoke(
|
||||
'adapter:call',
|
||||
method,
|
||||
...(args.length ? args : []),
|
||||
),
|
||||
openNoteWindow: (noteId) => {
|
||||
ipcRenderer.send('open-note-window', noteId)
|
||||
},
|
||||
@@ -33,19 +46,12 @@ const api = {
|
||||
},
|
||||
}
|
||||
|
||||
// Implement adapter API - communicates with plugin adapter in main process
|
||||
const adapter = {
|
||||
call: (method, ...args) => ipcRenderer.invoke('adapter:call', method, args),
|
||||
}
|
||||
|
||||
if (process.contextIsolated) {
|
||||
try {
|
||||
contextBridge.exposeInMainWorld('api', api)
|
||||
contextBridge.exposeInMainWorld('adapter', adapter)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
} else {
|
||||
window.api = api
|
||||
window.adapter = adapter
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user