Files
Alta-Proxy-Tool/preload.js
T
peji ace4568f81
APT build checks / build-checks (push) Successful in 37s
APT build checks / build-checks (pull_request) Successful in 37s
feat: release passwordless hierarchical APT v1.2.5
2026-08-22 16:20:12 +00:00

29 lines
1.3 KiB
JavaScript

'use strict';
const { contextBridge, ipcRenderer } = require('electron');
function onConnectionStateChanged(callback) {
if (typeof callback !== 'function') return () => {};
const listener = (_event, state) => callback(state);
ipcRenderer.on('connection-state-changed', listener);
return () => ipcRenderer.removeListener('connection-state-changed', listener);
}
contextBridge.exposeInMainWorld('electronAPI', Object.freeze({
getDevices: () => ipcRenderer.invoke('get-devices'),
getDeviceSites: () => ipcRenderer.invoke('get-device-sites'),
getDeviceGroups: () => ipcRenderer.invoke('get-device-groups'),
getDeviceHierarchy: () => ipcRenderer.invoke('get-device-hierarchy'),
getAuthInfo: () => ipcRenderer.invoke('get-auth-info'),
launchProxy: (deviceId) => ipcRenderer.invoke('launch-proxy', deviceId),
stopProxy: (key) => ipcRenderer.invoke('stop-proxy', key),
disconnect: () => ipcRenderer.invoke('disconnect'),
getConnectionState: () => ipcRenderer.invoke('get-connection-state'),
checkForUpdates: () => ipcRenderer.invoke('check-for-updates'),
openFixedReleasesPage: () => ipcRenderer.invoke('open-fixed-releases-page'),
rotatePairing: () => ipcRenderer.invoke('rotate-pairing'),
revokePairing: () => ipcRenderer.invoke('revoke-pairing'),
getPairingStatus: () => ipcRenderer.invoke('get-pairing-status'),
onConnectionStateChanged,
}));