theseus/quicklinks-preload.js

16 lines
944 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),
// LLM picker — right-click on the LLM button pops a native menu of
// enabled LLM engines. rect positions the menu next to the button.
llmMenu: (rect) => ipcRenderer.invoke("quicklinks-llm-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)),
});