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

@@ -1,9 +1,20 @@
import { contextBridge, ipcRenderer } from "electron";
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);
},
@@ -29,17 +40,12 @@ const api = {
ipcRenderer.invoke("move-closed");
}
};
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;
}