2024-09-30 19:07:57 +00:00
|
|
|
// preload.js
|
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
2024-11-08 17:36:05 +00:00
|
|
|
getBatteryLevel: () => {
|
|
|
|
ipcRenderer.invoke('get-battery-level');
|
|
|
|
},
|
|
|
|
onGetBatteryLevel: (callback) => {
|
|
|
|
ipcRenderer.on('on-get-battery-level', callback);
|
|
|
|
},
|
|
|
|
unregisterOnGetBatteryLevel: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-get-battery-level');
|
|
|
|
},
|
2024-11-06 20:19:30 +00:00
|
|
|
copyToClipboard: (content) => {
|
|
|
|
ipcRenderer.invoke('copy-to-clipboard', content);
|
|
|
|
},
|
2024-11-01 13:39:47 +00:00
|
|
|
onTrayStartDaemon: (callback) => {
|
|
|
|
ipcRenderer.on('on-tray-start-daemon', callback);
|
|
|
|
},
|
|
|
|
onTrayStopDaemon: (callback) => {
|
|
|
|
ipcRenderer.on('on-tray-stop-daemon', callback);
|
|
|
|
},
|
|
|
|
onTrayQuitDaemon: (callback) => {
|
|
|
|
ipcRenderer.on('on-tray-quit-daemon', callback);
|
|
|
|
},
|
|
|
|
onTrayStartSync: (callback) => {
|
|
|
|
ipcRenderer.on('on-tray-start-sync', callback);
|
|
|
|
},
|
|
|
|
onTrayStopSync: (callback) => {
|
|
|
|
ipcRenderer.on('on-tray-stop-sync', callback);
|
|
|
|
},
|
|
|
|
setTrayItemEnabled: (id, enabled) => {
|
|
|
|
ipcRenderer.invoke('set-tray-item-enabled', id, enabled);
|
|
|
|
},
|
|
|
|
setTrayToolTip: (toolTip) => {
|
|
|
|
ipcRenderer.invoke('set-tray-tool-tip', toolTip);
|
|
|
|
},
|
2024-09-30 19:07:57 +00:00
|
|
|
startMonerod: (args) => {
|
|
|
|
ipcRenderer.invoke('start-monerod', args);
|
|
|
|
},
|
2024-10-14 21:08:02 +00:00
|
|
|
onMonerodStarted: (callback) => {
|
|
|
|
ipcRenderer.on('monerod-started', callback);
|
|
|
|
},
|
2024-10-16 16:18:43 +00:00
|
|
|
monitorMonerod: () => {
|
|
|
|
ipcRenderer.invoke('monitor-monerod');
|
|
|
|
},
|
|
|
|
onMonitorMonerod: (callback) => {
|
|
|
|
ipcRenderer.on('on-monitor-monerod', callback);
|
|
|
|
},
|
|
|
|
onMonitorMonerodError: (callback) => {
|
|
|
|
ipcRenderer.on('on-monitor-monerod-error', callback);
|
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterOnMonitorMonerod: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-monitor-monerod');
|
|
|
|
},
|
|
|
|
unregisterOnMonitorMonerodError: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-monitor-monerod-error');
|
|
|
|
},
|
2024-10-15 22:38:57 +00:00
|
|
|
unsubscribeOnMonerodStarted: () => {
|
2024-10-27 23:42:23 +00:00
|
|
|
ipcRenderer.removeAllListeners('monerod-started');
|
2024-10-15 22:38:57 +00:00
|
|
|
},
|
2024-09-30 19:07:57 +00:00
|
|
|
onMoneroStdout: (callback) => {
|
|
|
|
ipcRenderer.on('monero-stdout', callback);
|
|
|
|
},
|
|
|
|
onMoneroClose: (callback) => {
|
|
|
|
ipcRenderer.on('monero-close', callback);
|
2024-10-01 18:45:10 +00:00
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterOnMoneroStdout: () => {
|
|
|
|
ipcRenderer.removeAllListeners('monero-stdout');
|
|
|
|
},
|
2024-10-09 19:44:37 +00:00
|
|
|
getMoneroVersion: (monerodPath) => {
|
|
|
|
ipcRenderer.invoke('get-monero-version', monerodPath);
|
2024-10-01 18:45:10 +00:00
|
|
|
},
|
|
|
|
onMoneroVersion: (callback) => {
|
|
|
|
ipcRenderer.on('monero-version', callback);
|
|
|
|
},
|
|
|
|
onMoneroVersionError: (callback) => {
|
|
|
|
ipcRenderer.on('monero-version-error', callback);
|
2024-10-07 21:47:52 +00:00
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterOnMoneroVersion: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-monero-version');
|
|
|
|
},
|
|
|
|
unregisterOnMoneroVersionError: () => {
|
|
|
|
ipcRenderer.removeAllListeners('unregister-on-monero-version-error');
|
|
|
|
},
|
2024-10-07 21:47:52 +00:00
|
|
|
downloadMonerod: (downloadUrl, destination) => {
|
|
|
|
ipcRenderer.invoke('download-monerod', downloadUrl, destination);
|
|
|
|
},
|
|
|
|
onDownloadProgress: (callback) => {
|
|
|
|
ipcRenderer.on('download-progress', callback);
|
2024-10-09 18:53:38 +00:00
|
|
|
},
|
2024-10-18 20:41:53 +00:00
|
|
|
checkValidMonerodPath: (path) => {
|
|
|
|
ipcRenderer.invoke('check-valid-monerod-path', path);
|
|
|
|
},
|
|
|
|
onCheckValidMonerodPath: (callback) => {
|
|
|
|
ipcRenderer.on('on-check-valid-monerod-path', callback);
|
|
|
|
},
|
2024-10-09 18:53:38 +00:00
|
|
|
selectFolder: () => {
|
|
|
|
ipcRenderer.invoke('select-folder')
|
|
|
|
},
|
|
|
|
onSelectedFolder: (callback) => {
|
|
|
|
ipcRenderer.on('selected-folder', callback);
|
2024-10-09 21:40:32 +00:00
|
|
|
},
|
2024-10-31 15:47:48 +00:00
|
|
|
readFile: (filePath) => {
|
|
|
|
ipcRenderer.invoke('read-file', filePath);
|
|
|
|
},
|
|
|
|
onReadFile: (callback) => {
|
|
|
|
ipcRenderer.on('on-read-file', callback);
|
|
|
|
},
|
|
|
|
onReadFileError: (callback) => {
|
|
|
|
ipcRenderer.on('on-read-file-error', callback);
|
|
|
|
},
|
|
|
|
unregisterOnReadFile: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-read-file');
|
|
|
|
ipcRenderer.removeAllListeners('on-read-file-error');
|
|
|
|
},
|
2024-10-29 15:29:32 +00:00
|
|
|
unregisterOnSelectedFolder: () => {
|
|
|
|
ipcRenderer.removeAllListeners('selected-folder');
|
|
|
|
},
|
2024-10-31 15:47:48 +00:00
|
|
|
saveFile: (defaultPath, content) => {
|
|
|
|
ipcRenderer.invoke('save-file', defaultPath, content);
|
|
|
|
},
|
|
|
|
onSaveFileError: (callback) => {
|
|
|
|
ipcRenderer.on('on-save-file-error', callback);
|
|
|
|
},
|
|
|
|
onSaveFile: (callback) => {
|
|
|
|
ipcRenderer.on('on-save-file', callback);
|
|
|
|
},
|
|
|
|
unregisterOnSaveFile: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-save-file-error');
|
|
|
|
ipcRenderer.removeAllListeners('on-save-file');
|
|
|
|
},
|
2024-10-19 10:27:40 +00:00
|
|
|
selectFile: (extensions = undefined) => {
|
|
|
|
ipcRenderer.invoke('select-file', extensions);
|
2024-10-16 15:19:49 +00:00
|
|
|
},
|
|
|
|
onSelectedFile: (callback) => {
|
|
|
|
ipcRenderer.on('selected-file', callback);
|
|
|
|
},
|
2024-10-29 15:29:32 +00:00
|
|
|
unregisterOnSelectedFile: () => {
|
|
|
|
ipcRenderer.removeAllListeners('selected-file');
|
|
|
|
},
|
2024-10-09 21:40:32 +00:00
|
|
|
isWifiConnected: () => {
|
|
|
|
ipcRenderer.invoke('is-wifi-connected');
|
|
|
|
},
|
|
|
|
onIsWifiConnectedResponse: (callback) => {
|
|
|
|
ipcRenderer.on('is-wifi-connected-result', callback);
|
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterOnIsWifiConnectedResponse: () => {
|
|
|
|
ipcRenderer.removeAllListeners('is-wifi-connected-result');
|
|
|
|
},
|
2024-10-31 15:47:48 +00:00
|
|
|
getPath: (path) => {
|
|
|
|
ipcRenderer.invoke('get-path', path);
|
|
|
|
},
|
|
|
|
onGetPath: (callback) => {
|
|
|
|
ipcRenderer.on('on-get-path', callback);
|
|
|
|
},
|
|
|
|
unregisterOnGetPath: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-get-path');
|
|
|
|
},
|
2024-10-09 21:40:32 +00:00
|
|
|
getOsType: () => {
|
|
|
|
ipcRenderer.invoke('get-os-type');
|
|
|
|
},
|
|
|
|
gotOsType: (callback) => {
|
|
|
|
ipcRenderer.on('got-os-type', callback);
|
2024-10-13 18:47:25 +00:00
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterGotOsType: () => {
|
|
|
|
ipcRenderer.removeAllListeners('got-os-type');
|
|
|
|
},
|
|
|
|
|
2024-10-18 20:41:53 +00:00
|
|
|
showNotification: (options) => {
|
|
|
|
ipcRenderer.invoke('show-notification', options);
|
|
|
|
},
|
2024-10-13 18:47:25 +00:00
|
|
|
quit: () => {
|
|
|
|
ipcRenderer.invoke('quit');
|
2024-10-21 20:36:05 +00:00
|
|
|
},
|
2024-10-24 14:36:33 +00:00
|
|
|
enableAutoLaunch: (minimized) => {
|
|
|
|
ipcRenderer.invoke('enable-auto-launch', minimized);
|
2024-10-21 20:36:05 +00:00
|
|
|
},
|
|
|
|
isAutoLaunchEnabled: () => {
|
|
|
|
ipcRenderer.invoke('is-auto-launch-enabled');
|
|
|
|
},
|
|
|
|
onIsAutoLaunchEnabled: (callback) => {
|
2024-10-21 21:34:32 +00:00
|
|
|
ipcRenderer.on('on-is-auto-launch-enabled', callback);
|
2024-10-21 20:36:05 +00:00
|
|
|
},
|
2024-10-25 22:07:55 +00:00
|
|
|
unregisterOnIsAutoLaunchEnabled: () => {
|
2024-10-27 23:42:23 +00:00
|
|
|
ipcRenderer.removeAllListeners('on-is-auto-launch-enabled');
|
2024-10-25 22:07:55 +00:00
|
|
|
},
|
2024-10-21 20:36:05 +00:00
|
|
|
onEnableAutoLaunchError: (callback) => {
|
|
|
|
ipcRenderer.on('on-enable-auto-launch-error', callback);
|
|
|
|
},
|
|
|
|
onEnableAutoLaunchSuccess: (callback) => {
|
|
|
|
ipcRenderer.on('on-enable-auto-launch-success', callback);
|
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterOnEnableAutoLaunchError: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-enable-auto-launch-error');
|
|
|
|
},
|
|
|
|
unregisterOnEnableAutoLaunchSuccess: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-enable-auto-launch-success')
|
|
|
|
},
|
2024-10-21 20:36:05 +00:00
|
|
|
disableAutoLaunch: () => {
|
|
|
|
ipcRenderer.invoke('disable-auto-launch');
|
|
|
|
},
|
|
|
|
onDisableAutoLaunchError: (callback) => {
|
|
|
|
ipcRenderer.on('on-disable-auto-launch-error', callback);
|
|
|
|
},
|
|
|
|
onDisableAutoLaunchSuccess: (callback) => {
|
|
|
|
ipcRenderer.on('on-disable-auto-launch-success', callback);
|
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterOnDisableAutoLaunchError: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-disable-auto-launch-error');
|
|
|
|
},
|
|
|
|
unregisterOnDisableAutoLaunchSuccess: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-disable-auto-launch-success')
|
|
|
|
},
|
2024-10-21 20:36:05 +00:00
|
|
|
isAppImage: () => {
|
|
|
|
ipcRenderer.invoke('is-app-image');
|
|
|
|
},
|
|
|
|
onIsAppImage: (callback) => {
|
|
|
|
ipcRenderer.on('on-is-app-image', callback);
|
2024-10-23 17:01:24 +00:00
|
|
|
},
|
2024-10-27 23:42:23 +00:00
|
|
|
unregisterOnIsAppImage: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-is-app-image');
|
|
|
|
},
|
2024-10-23 17:01:24 +00:00
|
|
|
isAutoLaunched: () => {
|
|
|
|
ipcRenderer.invoke('is-auto-launched');
|
|
|
|
},
|
|
|
|
onIsAutoLaunched: (callback) => {
|
|
|
|
ipcRenderer.on('on-is-auto-launched', callback);
|
2024-10-25 22:07:55 +00:00
|
|
|
},
|
|
|
|
unregisterOnIsAutoLaunched: () => {
|
|
|
|
ipcRenderer.removeAllListeners('on-is-auto-launched');
|
2024-09-30 19:07:57 +00:00
|
|
|
}
|
|
|
|
});
|