-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
27 lines (23 loc) · 1.48 KB
/
preload.js
File metadata and controls
27 lines (23 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { contextBridge, ipcRenderer } = require('electron');
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld('electronAPI', {
// Repository management
getRepositories: () => ipcRenderer.invoke('get-repositories'),
removeRepository: (repoId) => ipcRenderer.invoke('remove-repository', repoId),
addRepositoryDialog: () => ipcRenderer.invoke('add-repository-dialog'),
// Git operations
getStashes: (repoPath) => ipcRenderer.invoke('get-stashes', repoPath),
getStashContent: (repoPath, index) => ipcRenderer.invoke('get-stash-content', repoPath, index),
getStashFiles: (repoPath, index) => ipcRenderer.invoke('get-stash-files', repoPath, index),
getStashFileContent: (repoPath, index, filename) => ipcRenderer.invoke('get-stash-file-content', repoPath, index, filename),
applyStash: (repoPath, index) => ipcRenderer.invoke('apply-stash', repoPath, index),
dropStash: (repoPath, index) => ipcRenderer.invoke('drop-stash', repoPath, index),
getRepoStatus: (repoPath) => ipcRenderer.invoke('get-repo-status', repoPath),
stashChanges: (repoPath) => ipcRenderer.invoke('stash-changes', repoPath),
// Event listeners
onRepositoryAdded: (callback) => ipcRenderer.on('repository-added', callback),
onRefreshRequested: (callback) => ipcRenderer.on('refresh-requested', callback),
// Remove listeners
removeAllListeners: (channel) => ipcRenderer.removeAllListeners(channel)
});