52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import { contextBridge, ipcRenderer } from "electron";
|
|
console.log("setting PreLoad")
|
|
|
|
|
|
contextBridge.exposeInMainWorld('electron', {
|
|
login: (credentials: { email: string, password: string }) => ipcRenderer.invoke('login-request', credentials),
|
|
logout: () => ipcRenderer.invoke('logout-request'),
|
|
forgotPassword: (email: string) => ipcRenderer.invoke("forgot-password", email),
|
|
getToken: (TOKEN_KEY: "ACCESS_TOKEN" | "REFRESH_TOKEN") => ipcRenderer.invoke('get-token', TOKEN_KEY),
|
|
uploadScreenshot: () => ipcRenderer.invoke('upload-screenshot'),
|
|
getActiveAppDetails: () => ipcRenderer.invoke('get-active-app'),
|
|
toggleCloseBtn: (shouldEnable: boolean) => ipcRenderer.invoke('toggle-close-btn', shouldEnable),
|
|
resizeWindow: (width: number, height: number) => ipcRenderer.invoke('resize-window', width, height),
|
|
getProjectList: () => ipcRenderer.invoke("get-project-list"),
|
|
onWindowUpdate: (callback) =>
|
|
ipcRenderer.on("window:updated", (_, data) => callback(data)),
|
|
|
|
startProjectTracking: (data) => ipcRenderer.invoke("start-project-tracking", data),
|
|
stopProjectTracking: (data) => ipcRenderer.invoke("stop-project-tracking", data),
|
|
trackingTabsOpeningClosing: (data) =>
|
|
ipcRenderer.invoke("tracking-tabs-opening-and-closing", data),
|
|
|
|
getProjectLogs: (
|
|
projectID: string,
|
|
fromDate?: string,
|
|
toDate?: string
|
|
) => ipcRenderer.invoke("get-project-logs", { projectID, fromDate, toDate }),
|
|
|
|
} satisfies Window['electron']);
|
|
|
|
// function ipcInvoke<Key extends keyof EventPayloadMapping>(
|
|
// key: Key
|
|
// ): Promise<EventPayloadMapping[Key]> {
|
|
// return ipcRenderer.invoke(key);
|
|
// }
|
|
|
|
// function ipcOn<Key extends keyof EventPayloadMapping>(
|
|
// key: Key,
|
|
// callback: (payload: EventPayloadMapping[Key]) => void
|
|
// ) {
|
|
// const cb = (_: Electron.IpcRendererEvent, payload: any) => callback(payload);
|
|
// ipcRenderer.on(key, cb);
|
|
// return () => ipcRenderer.off(key, cb);
|
|
// }
|
|
|
|
// function ipcSend<Key extends keyof EventPayloadMapping>(
|
|
// key: Key,
|
|
// payload: EventPayloadMapping[Key]
|
|
// ) {
|
|
// ipcRenderer.send(key, payload);
|
|
// }
|