fix: fixing eslint problems
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
// To secure user platform when running renderer process stuff,
|
||||
// Node.JS and Electron APIs are only available in this script
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
import { contextBridge, ipcRenderer, IpcRendererEvent } from "electron";
|
||||
import { WindowApi, WindowApiConst } from "shared-lib";
|
||||
|
||||
// So we expose protected methods that allow the renderer process
|
||||
// to use the ipcRenderer without exposing the entire object
|
||||
const windowApi: WindowApi = {
|
||||
send: (channel: any, ...data: any) => {
|
||||
send: <In>(channel: string, input: In) => {
|
||||
if (WindowApiConst.SENDING_SAFE_CHANNELS.includes(channel)) {
|
||||
ipcRenderer.send(channel, ...data);
|
||||
ipcRenderer.send(channel, input);
|
||||
}
|
||||
},
|
||||
receive: (channel: string, func: (...data: any) => void) => {
|
||||
receive: <Out>(channel: string, func: (output: Out) => void) => {
|
||||
if (WindowApiConst.RECEIVING_SAFE_CHANNELS.includes(channel)) {
|
||||
// Deliberately strip event as it includes `sender`
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
ipcRenderer.on(channel, (event: IpcRendererEvent, ...args: any[]) =>
|
||||
func(args[0])
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
declare const window: any;
|
||||
declare const window: Window;
|
||||
if (process.env.X_NODE_ENV === "e2e-test") {
|
||||
// Injecting windowApi directly
|
||||
window.api = windowApi;
|
||||
@@ -29,4 +31,5 @@ if (process.env.X_NODE_ENV === "e2e-test") {
|
||||
contextBridge.exposeInMainWorld("api", windowApi);
|
||||
}
|
||||
|
||||
console.log(typeof window);
|
||||
console.log("The preload script has been injected successfully.");
|
||||
|
||||
Reference in New Issue
Block a user