2024-09-30 19:07:57 +00:00
|
|
|
// preload.js
|
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
2024-10-09 21:40:32 +00:00
|
|
|
//const os = require('os');
|
2024-09-30 19:07:57 +00:00
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
|
|
|
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-15 22:38:57 +00:00
|
|
|
unsubscribeOnMonerodStarted: () => {
|
|
|
|
const listeners = ipcRenderer.listeners('monerod-started');
|
|
|
|
|
|
|
|
listeners.forEach((listener) => {
|
|
|
|
ipcRenderer.removeListener('monerod-started', listener);
|
|
|
|
});
|
|
|
|
},
|
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-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
|
|
|
},
|
|
|
|
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-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-09 21:40:32 +00:00
|
|
|
isWifiConnected: () => {
|
|
|
|
ipcRenderer.invoke('is-wifi-connected');
|
|
|
|
},
|
|
|
|
onIsWifiConnectedResponse: (callback) => {
|
|
|
|
ipcRenderer.on('is-wifi-connected-result', callback);
|
|
|
|
},
|
|
|
|
getOsType: () => {
|
|
|
|
ipcRenderer.invoke('get-os-type');
|
|
|
|
},
|
|
|
|
gotOsType: (callback) => {
|
|
|
|
ipcRenderer.on('got-os-type', callback);
|
2024-10-13 18:47:25 +00:00
|
|
|
},
|
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-09-30 19:07:57 +00:00
|
|
|
}
|
|
|
|
});
|