Files
geo/apps/desktop-client/src/preload/bridge.ts
T

29 lines
1.3 KiB
TypeScript
Raw Normal View History

import { contextBridge, ipcRenderer } from "electron/renderer";
import type { DesktopAccountInfo, DesktopRuntimeSessionSyncRequest } from "@geo/shared-types";
import type { DesktopRuntimeSnapshot } from "../renderer/types";
const desktopBridge = {
app: {
ping: () => ipcRenderer.invoke("desktop:ping") as Promise<string>,
runtimeSnapshot: () =>
ipcRenderer.invoke("desktop:runtime-snapshot") as Promise<DesktopRuntimeSnapshot>,
bindPublishAccount: (platformId: string) =>
ipcRenderer.invoke("desktop:bind-publish-account", platformId) as Promise<DesktopAccountInfo>,
openPublishAccountConsole: (account: {
id: string;
platform: string;
platformUid: string;
displayName: string;
}) =>
ipcRenderer.invoke("desktop:open-publish-account-console", account) as Promise<null>,
openTaskReview: (taskId: string) =>
ipcRenderer.invoke("desktop:task-open-review", taskId) as Promise<null>,
resolveParkedTask: (taskId: string, status: "succeeded" | "failed" | "unknown") =>
ipcRenderer.invoke("desktop:task-resolve-parked", taskId, status) as Promise<null>,
syncRuntimeSession: (session: DesktopRuntimeSessionSyncRequest | null) =>
ipcRenderer.invoke("desktop:runtime-session-sync", session) as Promise<null>,
},
};
contextBridge.exposeInMainWorld("desktopBridge", desktopBridge);