config system + move api to frontend

This commit is contained in:
nicwands
2026-03-11 12:26:40 -04:00
parent efc9c73751
commit a1b339f668
26 changed files with 10833 additions and 1631 deletions

View File

@@ -2,6 +2,11 @@ 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),
openNoteWindow: (noteId) => {
ipcRenderer.send('open-note-window', noteId)
},
@@ -14,21 +19,24 @@ const api = {
onNoteDeleted: (callback) => {
ipcRenderer.on('note-deleted', (_, data) => callback(data))
},
notifyNoteChanged: (event, data) => {
ipcRenderer.send('note-changed', event, data)
},
}
// Implement notes API
const notesAPI = {
call: (method, ...args) =>
ipcRenderer.invoke('notesAPI:call', method, args),
// 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('notesAPI', notesAPI)
contextBridge.exposeInMainWorld('adapter', adapter)
} catch (error) {
console.error(error)
}
} else {
window.api = api
window.adapter = adapter
}