monerod-gui/app/preload.js

249 lines
7.6 KiB
JavaScript
Raw Normal View History

// 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);
},
2024-11-10 20:40:33 +00:00
isOnBatteryPower: () => {
ipcRenderer.invoke('is-on-battery-power');
},
onIsOnBatteryPower: (callback) => {
ipcRenderer.on('on-is-on-battery-power', callback);
},
unregisterOnIsOnBatteryPower: () => {
ipcRenderer.removeAllListeners('on-is-on-battery-power');
},
onAc: (callback) => {
ipcRenderer.on('on-ac', callback);
},
onBattery: (callback) => {
ipcRenderer.on('on-battery', callback);
},
2024-11-08 17:36:05 +00:00
unregisterOnGetBatteryLevel: () => {
ipcRenderer.removeAllListeners('on-get-battery-level');
},
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);
},
startMonerod: (args) => {
ipcRenderer.invoke('start-monerod', args);
},
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');
},
unsubscribeOnMonerodStarted: () => {
2024-10-27 23:42:23 +00:00
ipcRenderer.removeAllListeners('monerod-started');
},
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
},
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
},
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');
},
unregisterOnSelectedFolder: () => {
ipcRenderer.removeAllListeners('selected-folder');
},
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);
},
onSelectedFile: (callback) => {
ipcRenderer.on('selected-file', callback);
},
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');
},
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');
},
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
},
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');
}
});