-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
24 lines (23 loc) · 1.12 KB
/
Copy pathpreload.js
File metadata and controls
24 lines (23 loc) · 1.12 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
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('photopti', {
getLogoPath: () => ipcRenderer.invoke('get-logo-path'),
listImages: (paths) => ipcRenderer.invoke('list-images', paths),
showInputDialog: (kind) => ipcRenderer.invoke('show-input-dialog', kind),
getThumbnails: (paths, options) => ipcRenderer.invoke('get-thumbnails', paths, options),
getImageInfo: (filePath) => ipcRenderer.invoke('get-image-info', filePath),
showFolderDialog: () => ipcRenderer.invoke('show-folder-dialog'),
cancelProcessing: () => ipcRenderer.invoke('cancel-processing'),
processImages: (paths, options) => {
ipcRenderer.send('process-images', { paths, options });
},
onProgress: (callback) => {
const listener = (_event, data) => callback(data);
ipcRenderer.on('process-progress', listener);
return () => ipcRenderer.removeListener('process-progress', listener);
},
onComplete: (callback) => {
const listener = (_event, data) => callback(data);
ipcRenderer.on('process-complete', listener);
return () => ipcRenderer.removeListener('process-complete', listener);
}
});