core refactor for runtime support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user