core refactor for runtime support

This commit is contained in:
nicwands
2026-03-23 16:30:38 -04:00
parent eea1cccf16
commit 4d64bc995f
32 changed files with 634 additions and 486 deletions

View File

@@ -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
}