mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-12 08:03:06 -04:00
Add Plugin.start, make Settings actually start/stop plugins
This commit is contained in:
parent
bac8a648b6
commit
f60ccb766f
10 changed files with 146 additions and 58 deletions
|
@ -1,24 +1,31 @@
|
|||
import IPC_EVENTS from './utils/IpcEvents';
|
||||
import { IpcRenderer, ipcRenderer } from 'electron';
|
||||
|
||||
function assertEventAllowed(event: string) {
|
||||
if (!(event in IPC_EVENTS)) throw new Error(`Event ${event} not allowed.`);
|
||||
}
|
||||
export default {
|
||||
getVersions: () => process.versions,
|
||||
ipc: {
|
||||
send(event: string, ...args: any[]) {
|
||||
if (event in IPC_EVENTS) ipcRenderer.send(event, ...args);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
assertEventAllowed(event);
|
||||
ipcRenderer.send(event, ...args);
|
||||
},
|
||||
sendSync<T = any>(event: string, ...args: any[]): T {
|
||||
if (event in IPC_EVENTS) return ipcRenderer.sendSync(event, ...args);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
assertEventAllowed(event);
|
||||
return ipcRenderer.sendSync(event, ...args);
|
||||
},
|
||||
on(event: string, listener: Parameters<IpcRenderer["on"]>[1]) {
|
||||
if (event in IPC_EVENTS) ipcRenderer.on(event, listener);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
assertEventAllowed(event);
|
||||
ipcRenderer.on(event, listener);
|
||||
},
|
||||
off(event: string, listener: Parameters<IpcRenderer["off"]>[1]) {
|
||||
assertEventAllowed(event);
|
||||
ipcRenderer.off(event, listener);
|
||||
},
|
||||
invoke<T = any>(event: string, ...args: any[]): Promise<T> {
|
||||
if (event in IPC_EVENTS) return ipcRenderer.invoke(event, ...args);
|
||||
else throw new Error(`Event ${event} not allowed.`);
|
||||
assertEventAllowed(event);
|
||||
return ipcRenderer.invoke(event, ...args);
|
||||
}
|
||||
},
|
||||
require(mod: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue