theseus/quicklinks-preload.js

13 lines
731 B
JavaScript
Raw Normal View History

const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("quicklinks", {
getState: () => ipcRenderer.invoke("quicklinks-get-state"),
open: (id) => ipcRenderer.invoke("quicklinks-open", String(id || "")),
close: () => ipcRenderer.invoke("quicklinks-close"),
// The gear: rect is the button's box in the strip, for placing the menu.
menu: (rect) => ipcRenderer.invoke("quicklinks-menu", rect),
// The strip's new order after a drag: keys "q:<link id>" / "p:<panelId>".
reorder: (order) => ipcRenderer.invoke("quicklinks-reorder", order),
add: () => ipcRenderer.invoke("quicklinks-add"),
onState: (cb) => ipcRenderer.on("quicklinks-state", (_e, d) => cb(d)),
});