monerod-gui/app/preload.js
argenius 920a9cfa34
Some checks are pending
Lint Test / build (20) (push) Waiting to run
MacOS Build / build (20) (push) Waiting to run
MacOS 12 - x64 DMG Build / build (20) (push) Waiting to run
Ubuntu 22.04 - AppImage Build / build (20) (push) Waiting to run
Ubuntu 22.04 - x64 DEB Build / build (20) (push) Waiting to run
Ubuntu 24.04 - x64 DEB Build / build (20) (push) Waiting to run
Windows Build / build (20) (push) Waiting to run
Minor fixes, hash rate chart, refactory about page
2024-11-06 21:19:30 +01:00

224 lines
6.9 KiB
JavaScript

// preload.js
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
copyToClipboard: (content) => {
ipcRenderer.invoke('copy-to-clipboard', content);
},
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);
},
monitorMonerod: () => {
ipcRenderer.invoke('monitor-monerod');
},
onMonitorMonerod: (callback) => {
ipcRenderer.on('on-monitor-monerod', callback);
},
onMonitorMonerodError: (callback) => {
ipcRenderer.on('on-monitor-monerod-error', callback);
},
unregisterOnMonitorMonerod: () => {
ipcRenderer.removeAllListeners('on-monitor-monerod');
},
unregisterOnMonitorMonerodError: () => {
ipcRenderer.removeAllListeners('on-monitor-monerod-error');
},
unsubscribeOnMonerodStarted: () => {
ipcRenderer.removeAllListeners('monerod-started');
},
onMoneroStdout: (callback) => {
ipcRenderer.on('monero-stdout', callback);
},
onMoneroClose: (callback) => {
ipcRenderer.on('monero-close', callback);
},
unregisterOnMoneroStdout: () => {
ipcRenderer.removeAllListeners('monero-stdout');
},
getMoneroVersion: (monerodPath) => {
ipcRenderer.invoke('get-monero-version', monerodPath);
},
onMoneroVersion: (callback) => {
ipcRenderer.on('monero-version', callback);
},
onMoneroVersionError: (callback) => {
ipcRenderer.on('monero-version-error', callback);
},
unregisterOnMoneroVersion: () => {
ipcRenderer.removeAllListeners('on-monero-version');
},
unregisterOnMoneroVersionError: () => {
ipcRenderer.removeAllListeners('unregister-on-monero-version-error');
},
downloadMonerod: (downloadUrl, destination) => {
ipcRenderer.invoke('download-monerod', downloadUrl, destination);
},
onDownloadProgress: (callback) => {
ipcRenderer.on('download-progress', callback);
},
checkValidMonerodPath: (path) => {
ipcRenderer.invoke('check-valid-monerod-path', path);
},
onCheckValidMonerodPath: (callback) => {
ipcRenderer.on('on-check-valid-monerod-path', callback);
},
selectFolder: () => {
ipcRenderer.invoke('select-folder')
},
onSelectedFolder: (callback) => {
ipcRenderer.on('selected-folder', callback);
},
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');
},
selectFile: (extensions = undefined) => {
ipcRenderer.invoke('select-file', extensions);
},
onSelectedFile: (callback) => {
ipcRenderer.on('selected-file', callback);
},
unregisterOnSelectedFile: () => {
ipcRenderer.removeAllListeners('selected-file');
},
isWifiConnected: () => {
ipcRenderer.invoke('is-wifi-connected');
},
onIsWifiConnectedResponse: (callback) => {
ipcRenderer.on('is-wifi-connected-result', callback);
},
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');
},
getOsType: () => {
ipcRenderer.invoke('get-os-type');
},
gotOsType: (callback) => {
ipcRenderer.on('got-os-type', callback);
},
unregisterGotOsType: () => {
ipcRenderer.removeAllListeners('got-os-type');
},
showNotification: (options) => {
ipcRenderer.invoke('show-notification', options);
},
quit: () => {
ipcRenderer.invoke('quit');
},
enableAutoLaunch: (minimized) => {
ipcRenderer.invoke('enable-auto-launch', minimized);
},
isAutoLaunchEnabled: () => {
ipcRenderer.invoke('is-auto-launch-enabled');
},
onIsAutoLaunchEnabled: (callback) => {
ipcRenderer.on('on-is-auto-launch-enabled', callback);
},
unregisterOnIsAutoLaunchEnabled: () => {
ipcRenderer.removeAllListeners('on-is-auto-launch-enabled');
},
onEnableAutoLaunchError: (callback) => {
ipcRenderer.on('on-enable-auto-launch-error', callback);
},
onEnableAutoLaunchSuccess: (callback) => {
ipcRenderer.on('on-enable-auto-launch-success', callback);
},
unregisterOnEnableAutoLaunchError: () => {
ipcRenderer.removeAllListeners('on-enable-auto-launch-error');
},
unregisterOnEnableAutoLaunchSuccess: () => {
ipcRenderer.removeAllListeners('on-enable-auto-launch-success')
},
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);
},
unregisterOnDisableAutoLaunchError: () => {
ipcRenderer.removeAllListeners('on-disable-auto-launch-error');
},
unregisterOnDisableAutoLaunchSuccess: () => {
ipcRenderer.removeAllListeners('on-disable-auto-launch-success')
},
isAppImage: () => {
ipcRenderer.invoke('is-app-image');
},
onIsAppImage: (callback) => {
ipcRenderer.on('on-is-app-image', callback);
},
unregisterOnIsAppImage: () => {
ipcRenderer.removeAllListeners('on-is-app-image');
},
isAutoLaunched: () => {
ipcRenderer.invoke('is-auto-launched');
},
onIsAutoLaunched: (callback) => {
ipcRenderer.on('on-is-auto-launched', callback);
},
unregisterOnIsAutoLaunched: () => {
ipcRenderer.removeAllListeners('on-is-auto-launched');
}
});