Files
goose/ui/desktop/src/preload.js
Max Novich cfd3ee8fd9 feat: goose windows (#880)
Co-authored-by: Ryan Versaw <ryan@versaw.com>
2025-02-10 15:05:13 -08:00

30 lines
1.5 KiB
JavaScript

const { contextBridge, ipcRenderer } = require('electron')
const config = JSON.parse(process.argv.find((arg) => arg.startsWith('{')) || '{}');
contextBridge.exposeInMainWorld('appConfig', {
get: (key) => config[key],
getAll: () => config,
});
contextBridge.exposeInMainWorld('electron', {
getConfig: () => config,
hideWindow: () => ipcRenderer.send('hide-window'),
directoryChooser: (replace) => ipcRenderer.send('directory-chooser', replace),
createChatWindow: (query, dir, version) => ipcRenderer.send('create-chat-window', query, dir, version),
logInfo: (txt) => ipcRenderer.send('logInfo', txt),
showNotification: (data) => ipcRenderer.send('notify', data),
createWingToWingWindow: (query) => ipcRenderer.send('create-wing-to-wing-window', query),
openInChrome: (url) => ipcRenderer.send('open-in-chrome', url),
fetchMetadata: (url) => ipcRenderer.invoke('fetch-metadata', url),
reloadApp: () => ipcRenderer.send('reload-app'),
checkForOllama: () => ipcRenderer.invoke('check-ollama'),
selectFileOrDirectory: () => ipcRenderer.invoke('select-file-or-directory'),
startPowerSaveBlocker: () => ipcRenderer.invoke('start-power-save-blocker'),
stopPowerSaveBlocker: () => ipcRenderer.invoke('stop-power-save-blocker'),
getBinaryPath: (binaryName) => ipcRenderer.invoke('get-binary-path', binaryName),
on: (channel, callback) => ipcRenderer.on(channel, callback),
off: (channel, callback) => ipcRenderer.off(channel, callback),
send: (key) => ipcRenderer.send(key)
});